diff options
| author | Rusty Russell <rusty@rustcorp.com.au> | 2002-12-29 21:04:02 -0800 |
|---|---|---|
| committer | Linus Torvalds <torvalds@home.transmeta.com> | 2002-12-29 21:04:02 -0800 |
| commit | 09619fdbe8b07911722e2ed8894f193160cdd1a8 (patch) | |
| tree | 5e0fab4950f4d6dd73508b0144f65806fb7481ab /kernel/module.c | |
| parent | 5e32ae7ed6f1dd53fbdd9c3540f4b1dcbcc0c5ef (diff) | |
[PATCH] MODULE_PARM "c" support
Turns out there was an undocumented "c" flag for MODULE_PARM.
This implementation is a little ugly, but it works, and will do for
compatibility (I haven't implemented such a two-dimensional array
primitive, but the whole point of the module_parm et al is that they are
extensible).
Diffstat (limited to 'kernel/module.c')
| -rw-r--r-- | kernel/module.c | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/kernel/module.c b/kernel/module.c index c73b19336f1e..bc940cfa7d3b 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -569,10 +569,19 @@ static int param_string(const char *name, const char *val, return 0; } +/* Bounds checking done below */ +static int obsparm_copy_string(const char *val, struct kernel_param *kp) +{ + strcpy(kp->arg, val); + return 0; +} + extern int set_obsolete(const char *val, struct kernel_param *kp) { unsigned int min, max; - char *p, *endp; + unsigned int size, maxsize; + char *endp; + const char *p; struct obsolete_modparm *obsparm = kp->arg; if (!val) { @@ -605,9 +614,30 @@ extern int set_obsolete(const char *val, struct kernel_param *kp) sizeof(long), param_set_long); case 's': return param_string(kp->name, val, min, max, obsparm->addr); + + case 'c': + /* Undocumented: 1-5c50 means 1-5 strings of up to 49 chars, + and the decl is "char xxx[5][50];" */ + p = endp+1; + maxsize = simple_strtol(p, &endp, 10); + /* We check lengths here (yes, this is a hack). */ + p = val; + while (p[size = strcspn(p, ",")]) { + if (size >= maxsize) + goto oversize; + p += size+1; + } + if (size >= maxsize) + goto oversize; + return param_array(kp->name, val, min, max, obsparm->addr, + maxsize, obsparm_copy_string); } printk(KERN_ERR "Unknown obsolete parameter type %s\n", obsparm->type); return -EINVAL; + oversize: + printk(KERN_ERR + "Parameter %s doesn't fit in %u chars.\n", kp->name, maxsize); + return -EINVAL; } static int obsolete_params(const char *name, |
