[prev in list] [next in list] [prev in thread] [next in thread] 

List:       linux-kernel
Subject:    Re: Linux 2.3.18ac5
From:       Richard Guenther <zxmpm11 () student ! uni-tuebingen ! de>
Date:       1999-09-17 8:03:38
[Download RAW message or body]

Hi!

After some hours of thought I came up with the following solution
for the MODULE_NAME problem (see attached patch, the basic idea
is to pass a MODULE_NAME string at compile time (ugh!), i.e. I
had to read the make info-pages...).
So for every dumb module that does _not_ already use prefixed
names nothing needs to be changed. For other modules (like the
isapnp module which has "isapnp_" as prefix already) you can
either "fix" them or simply redefine
the MODULE_NAME before the #include <linux/module> line (see
example patch, for isapnp). Oh, if you dont fix the broken
ones, for modprobe/insmod nothing changes, but the kernel command
line needs double prefixes like isapnp_isapnp_reserve_irq=...

Caveats: you dont have control over MODULE_NAME - it gets
created out of the source file name.

Still to be done is the userspace part so that modprobe/insmod
also accept module parameters with prefix.

Richard.

PS: this was really the least intrusive solution I could think
    of that works for both, module and compiled in version.
PPS: beware! hand-edited patch, may not apply. (modules.h part)


--- linux-2.3.16/include/linux/module.h.original	Sat Sep 11 15:04:03 1999
+++ linux-2.3.16/include/linux/module.h	Thu Sep 16 23:11:28 1999
@@ -173,6 +174,8 @@
 	s	string
 */
 
+const char __module_name[] __attribute__((section(".modinfo"))) = MODULE_NAME;
+
 #define MODULE_PARM(var,type)			\
 const char __module_parm_##var[]		\
 __attribute__((section(".modinfo"))) =		\
@@ -207,11 +210,17 @@
 #endif
 
 #else /* MODULE */
 extern int parse_parameters(void *var, char *type, char *str);
 #define MODULE_AUTHOR(name)
 #define MODULE_DESCRIPTION(desc)
 #define MODULE_SUPPORTED_DEVICE(name)
 #define MODULE_PARM(var,type) \
 static char *modparm##var##_setup_type __initdata = type;\
 static int __init modparm##var##_setup(char *str)\
 {\
   return parse_parameters(var, modparm##var##_setup_type, str);\
 }\
-__setup(#var "=", modparm##var##_setup);
+__setup(MODULE_NAME #var "=", modparm##var##_setup);
 #define MODULE_PARM_DESC(var,desc)
 
 #ifndef __GENKSYMS__
--- linux-2.3.16/Rules.make.original	Thu Sep 16 23:03:12 1999
+++ linux-2.3.16/Rules.make	Thu Sep 16 23:18:00 1999
@@ -51,7 +51,7 @@
 	$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@) -E $< > $@
 
 %.o: %.c
-	$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@) -c -o $@ $<
+	$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@) -DMODULE_NAME=\"$(subst .c,_,$<)\" -c \
-o $@ $<  @ ( \
 	    echo 'ifeq ($(strip $(subst $(comma),:,$(CFLAGS) $(EXTRA_CFLAGS) \
$(CFLAGS_$@))),$$(strip $$(subst $$(comma),:,$$(CFLAGS) $$(EXTRA_CFLAGS) \
$$(CFLAGS_$@))))' ; \  echo 'FILES_FLAGS_UP_TO_DATE += $@' ; \
@@ -245,7 +245,7 @@
 
 ifneq "$(strip $(SYMTAB_OBJS))" ""
 $(SYMTAB_OBJS): $(TOPDIR)/include/linux/modversions.h $(SYMTAB_OBJS:.o=.c)
-	$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@) -DEXPORT_SYMTAB -c $(@:.o=.c)
+	$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@) -DEXPORT_SYMTAB \
-DMODULE_NAME=\"$(subst .o,_,$@)\" -c $(@:.o=.c)  @ ( \
 	    echo 'ifeq ($(strip $(subst $(comma),:,$(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@) \
-DEXPORT_SYMTAB)),$$(strip $$(subst $$(comma),:,$$(CFLAGS) $$(EXTRA_CFLAGS) \
$$(CFLAGS_$@) -DEXPORT_SYMTAB)))' ; \  echo 'FILES_FLAGS_UP_TO_DATE += $@' ; \
--- linux-2.3.16/drivers/pnp/isapnp.c.original	Thu Sep 16 23:28:12 1999
+++ linux-2.3.16/drivers/pnp/isapnp.c	Thu Sep 16 23:41:04 1999
@@ -21,6 +21,8 @@
 
 #include <linux/config.h>
 #include <linux/version.h>
+#undef MODULE_NAME
+#define MODULE_NAME ""
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/errno.h>


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic