module-init-tools 0.9.3, rmmod modules with '-'
Hi Rusty,
It seems we cannot unload modules if they have a '-' in their name. filename2modname() in rmmod.c converts a '-' in the filename to '_'. Why? Are dashes not allowed as part of module names?
For eg: (kernel 2.5.52/module-init-tools 0.9.3)
[root@llm10 test-modules]# ./insmod probe-test.o [root@llm10 test-modules]# ./lsmod
Module Size Used by
probe-test 943 0
[root@llm10 test-modules]# cat /proc/modules probe-test 943 0
[root@llm10 test-modules]# ./rmmod -V module-init-tools version 0.9.3
[root@llm10 test-modules]# ./rmmod probe-test
ERROR: Module probe_test does not exist in /proc/modules
^note this
Editing filename2modname() to remove this special test for '-' seems to fix it. But, this is done explicitly, so I wonder if there is a deeper meaning to this. Can you please take a look and explain?
Thanks,
Vamsi.
Signature · 23 lines
Vamsi Krishna S. Linux Technology Center, IBM Software Lab, Bangalore. Ph: +91 80 5044959 Internet: [email protected] -- --- rmmod-old.c 2002-12-13 21:11:57.000000000 +0530 +++ rmmod.c 2002-12-13 21:10:44.000000000 +0530 @@ -157,9 +157,12 @@ else afterslash++; - /* stop at first . */ + /* Convert to underscores, stop at first . */ for (i = 0; afterslash[i] && afterslash[i] != '.'; i++) { - modname[i] = afterslash[i]; + if (afterslash[i] == '-') + modname[i] = '_'; + else + modname[i] = afterslash[i]; } modname[i] = '\0'; }
In message <[email protected]> you write:
Quoted 5 lines
Hi Rusty,
It seems we cannot unload modules if they have a '-' in their name.
filename2modname()inrmmod.cconverts a '-' in the filename to '_'. Why? Are dashes not allowed as part of module names?
How did you get a module which has - in its name? The build system *should* turn them into _'s.
Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
Quoted 2 lines · Rusty Russell
How did you get a module which has - in its name? The build system *should* turn them into _'s.
ALSA modules?
-rw-r--r-- 1 root root 170125 Dec 15 00:10 snd-mixer-oss.ko -rw-r--r-- 1 root root 143685 Dec 15 00:10 snd-mpu401-uart.ko -rw-r--r-- 1 root root 312564 Dec 15 00:10 snd-opl3-lib.ko -rw-r--r-- 1 root root 194307 Dec 15 00:10 snd-opl3sa2.ko -rw-r--r-- 1 root root 612512 Dec 15 00:10 snd-opl3-synth.ko -rw-r--r-- 1 root root 1160272 Dec 15 00:10 snd-pcm.ko
But they do get converted when we load ie snd-pcm turns into snd_pcm
Signature · 1 line
function.linuxpower.ca
In message <[email protected]> y ou write:
Quoted 14 lines · Rusty Russell
Quoted 3 lines
How did you get a module which has - in its name? The build system *should* turn them into _'s.
ALSA modules?
(quoted diff) +0
-6-rw-r--r-- 1 root root 170125 Dec 15 00:10 snd-mixer-oss.ko -rw-r--r-- 1 root root 143685 Dec 15 00:10 snd-mpu401-uart.ko -rw-r--r-- 1 root root 312564 Dec 15 00:10 snd-opl3-lib.ko -rw-r--r-- 1 root root 194307 Dec 15 00:10 snd-opl3sa2.ko -rw-r--r-- 1 root root 612512 Dec 15 00:10 snd-opl3-synth.ko -rw-r--r-- 1 root root 1160272 Dec 15 00:10 snd-pcm.ko
Quoted 1 line
But they do get converted when we load ie snd-pcm turns into
snd_pcm
Yes, the filenames are unchanged. But if you modprobe snd-mixer-oss, you'll see snd_mixer_oss in /proc/modules. But rmmod "snd-mixer-oss" works as expected. Basically, the kernel and tools see them as
equivalent: anything else is a bug, please report.
BTW, this was done for (1) simplicity, (2) so KBUILD_MODNAME can be used to construct identifiers, and (3) so parameters when the module is built-in have a consistent name.
Hope that clarifies!
Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
Quoted 5 lines · Rusty Russell
BTW, this was done for (1) simplicity, (2) so
KBUILD_MODNAMEcan be used to construct identifiers, and (3) so parameters when the module is built-in have a consistent name.
Ok, I see it now, this magic happens in scripts/Makefile.lib. My module has been built outside the kernel build system, that's why I saw this problem.
I guess avoiding '-' should do it, but is there a simple way to correctly build (simple, test) modules outside the kernel tree now?
Thanks,
Vamsi.
Signature · 5 lines
Vamsi Krishna S. Linux Technology Center, IBM Software Lab, Bangalore. Ph: +91 80 5044959 Internet: [email protected]
In message <[email protected]> you write:
Quoted 6 lines · Rusty Russell
Quoted 5 lines
BTW, this was done for (1) simplicity, (2) so
KBUILD_MODNAMEcan be used to construct identifiers, and (3) so parameters when the module is built-in have a consistent name.
Quoted 6 lines
Ok, I see it now, this magic happens in
scripts/Makefile.lib. My module has been built outside the kernel build system, that's why I saw this problem.I guess avoiding '-' should do it, but is there a simple way to correctly build (simple, test) modules outside the kernel tree now?
Has there ever been a simple way? You can either use _ in the name, or use tr on the -DKBUILD_MODNAME line, I guess.
Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
Quoted 7 lines · Rusty Russell
In message <[email protected]> you write:
Quoted 6 lines · Rusty Russell
Quoted 5 lines
BTW, this was done for (1) simplicity, (2) so
KBUILD_MODNAMEcan be used to construct identifiers, and (3) so parameters when the module is built-in have a consistent name.
Quoted 8 lines
Quoted 6 lines
Ok, I see it now, this magic happens in
scripts/Makefile.lib. My module has been built outside the kernel build system, that's why I saw this problem.I guess avoiding '-' should do it, but is there a simple way to correctly build (simple, test) modules outside the kernel tree now?
Has there ever been a simple way?
Well, you can do
cd my_module
echo "obj-m := my_module.o" > Makefile
vi my_module.c
make -C <path/to/kernel/src> SUBDIRS=$PWD modules
That's not too bad (and basically works for 2.4 as well)
--Kai
In message <[email protected]> y ou write:
Quoted 11 lines · Rusty Russell
Quoted 1 line
Has there ever been a simple way?
Well, you can do
cd
my_module
echo "obj-m := my_module.o" >Makefile
vimy_module.c
make -C <path/to/kernel/src> SUBDIRS=$PWD modulesThat's not too bad (and basically works for 2.4 as well)
And then you're independent of changes in the build system, too. I like it.
Thanks for the tip!
Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
Quoted 18 lines · Kai Germaschewski
Quoted 7 lines · Rusty Russell
In message <[email protected]> you write:
Quoted 6 lines · Rusty Russell
Quoted 5 lines
BTW, this was done for (1) simplicity, (2) so
KBUILD_MODNAMEcan be used to construct identifiers, and (3) so parameters when the module is built-in have a consistent name.Quoted 8 lines
Quoted 6 lines
Ok, I see it now, this magic happens in
scripts/Makefile.lib. My module has been built outside the kernel build system, that's why I saw this problem.I guess avoiding '-' should do it, but is there a simple way to correctly build (simple, test) modules outside the kernel tree now?
Has there ever been a simple way?
Quoted 9 lines
Well, you can do
cd
my_module
echo "obj-m := my_module.o" >Makefile
vimy_module.c
make -C <path/to/kernel/src> SUBDIRS=$PWD modulesThat's not too bad (and basically works for 2.4 as well)
That's way cool! Thank you.
Signature · 5 lines
Vamsi Krishna S. Linux Technology Center, IBM Software Lab, Bangalore. Ph: +91 80 5044959 Internet: [email protected]