* [PATCH] MODULE_PARM "c" support
@ 2002-12-26 7:11 Rusty Russell
0 siblings, 0 replies; only message in thread
From: Rusty Russell @ 2002-12-26 7:11 UTC (permalink / raw)
To: torvalds; +Cc: linux-kernel, jt
Hi Linus,
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).
Please apply,
Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
Name: Implement c in MODULE_PARM compatibility wedge
Author: Rusty Russell and Jean Tourrilhes
Status: Experimental
D: The "c" MODULE_PARM type was missing, as pointed out by Jean Tourrilhes.
diff -urNp --exclude TAGS -X /home/rusty/current-dontdiff --minimal linux-2.5.52/kernel/module.c working-2.5.52-cparam/kernel/module.c
--- linux-2.5.52/kernel/module.c Tue Dec 17 08:11:03 2002
+++ working-2.5.52-cparam/kernel/module.c Tue Dec 17 14:42:05 2002
@@ -569,10 +569,19 @@ static int param_string(const char *name
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,8 +614,29 @@ extern int set_obsolete(const char *val,
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;
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2002-12-26 9:46 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-12-26 7:11 [PATCH] MODULE_PARM "c" support Rusty Russell
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox