2.6.2: "-" or "_", thats the question
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 12 lines · Harald Dunkel
Quoted 9 lines · Coywolf Qi Hunt
Quoted 5 lines · Harald Dunkel
What would be the correct way to get the filename of a loaded module? The basename would be sufficient.
The symbole names used in source code, like function names tend to use "_", while the file names use "-" IMHO.
Quoted 6 lines
Naturally the symbols in the code use '_', cause for C '-' is not allowed within symbol names.
I am interested in the module file names. 'cat
/proc/modules' should return the correct module names, but for some modules (likeuhci_hcdvs uhci-hcd.ko) '_' and '-' are messed up.
According to the modprobe man page, the two symbols are interchangeable.
Signature · 2 lines
Ryan Reich [email protected]
Quoted 10 lines · Ryan Reich
Quoted 4 lines · Harald Dunkel
I am interested in the module file names. 'cat
/proc/modules' should return the correct module names, but for some modules (likeuhci_hcdvs uhci-hcd.ko) '_' and '-' are messed up.According to the modprobe man page, the two symbols are interchangeable.
I know. But this requires some very ugly workarounds outside of module-init-tools. For example, if you want to check whether a module $module_name has already been loaded, you cannot use
grep -q "^${module_name} " /proc/modulesInstead you have to use a workaround like
x="`echo $module_name | sed -e 's/-/_/g'`"
cat /proc/modules | sed -e 's/-/_/g' | grep -q "^${x} "This is inefficient and error-prone.
Maybe somebody has another idea for the workaround, but I like the first version.
Regards
Harri
Quoted 19 lines · Harald Dunkel
Quoted 9 lines · Ryan Reich
Quoted 4 lines · Harald Dunkel
I am interested in the module file names. 'cat
/proc/modules' should return the correct module names, but for some modules (likeuhci_hcdvs uhci-hcd.ko) '_' and '-' are messed up.According to the modprobe man page, the two symbols are interchangeable.
I know. But this requires some very ugly workarounds outside of module-init-tools. For example, if you want to check whether a module $module_name has already been loaded, you cannot use
grep -q "^${module_name} " /proc/modulesInstead you have to use a workaround like
Quoted 7 lines
x="`echo $module_name | sed -e 's/-/_/g'`" cat /proc/modules | sed -e 's/-/_/g' | grep -q "^${x} "This is inefficient and error-prone.
Maybe somebody has another idea for the workaround, but I like the first version.
/proc/modules uses only _ so you could use ${module_name/-/_}.
Signature · 2 lines
Måns Rullgård [email protected]
Quoted 5 lines · Måns Rullgård
Harald Dunkel <[email protected]> writes:
/proc/modulesuses only _ so you could use ${module_name/-/_}.
Please check the archive: My original complaint was about the inconsistency between /proc/modules listing all modules with '_', and the module filenames using both '-' and '_'. For me it is not important which version is better. As a developer I have to assume that '_' and '-' are ambiguous in this context. This ambiguity is pretty strange for Unix, isn't it?
Regards
Harri
Quoted 20 lines · Harald Dunkel
Quoted 10 lines · Ryan Reich
Quoted 4 lines · Harald Dunkel
I am interested in the module file names. 'cat
/proc/modules' should return the correct module names, but for some modules (likeuhci_hcdvs uhci-hcd.ko) '_' and '-' are messed up.According to the modprobe man page, the two symbols are interchangeable.
I know. But this requires some very ugly workarounds outside of module-init-tools. For example, if you want to check whether a module $module_name has already been loaded, you cannot use
grep -q "^${module_name} " /proc/modulesInstead you have to use a workaround like
Quoted 7 lines
x="`echo $module_name | sed -e 's/-/_/g'`" cat /proc/modules | sed -e 's/-/_/g' | grep -q "^${x} "This is inefficient and error-prone.
Maybe somebody has another idea for the workaround, but I like the first version.
Well, you can shorten it by using 'tr':
cat /proc/modules | tr _ - | grep -q "^${module_name} "
/proc/modules uses the '_' and I suppose your problem is that your module name list uses the '-', so this solves both at once.
Signature · 2 lines
Ryan Reich [email protected]
Quoted 30 lines · Ryan Reich
Quoted 20 lines · Harald Dunkel
Quoted 10 lines · Ryan Reich
Quoted 4 lines · Harald Dunkel
I am interested in the module file names. 'cat
/proc/modules' should return the correct module names, but for some modules (likeuhci_hcdvs uhci-hcd.ko) '_' and '-' are messed up.According to the modprobe man page, the two symbols are interchangeable.
I know. But this requires some very ugly workarounds outside of module-init-tools. For example, if you want to check whether a module $module_name has already been loaded, you cannot use
grep -q "^${module_name} " /proc/modulesInstead you have to use a workaround like
Quoted 7 lines
x="`echo $module_name | sed -e 's/-/_/g'`" cat /proc/modules | sed -e 's/-/_/g' | grep -q "^${x} "This is inefficient and error-prone.
Maybe somebody has another idea for the workaround, but I like the first version.
Quoted 6 lines
Well, you can shorten it by using 'tr':
cat
/proc/modules| tr _ - | grep -q "^${module_name} "
/proc/modulesuses the '_' and I suppose your problem is that your module name list uses the '-', so this solves both at once.
Sorry, I didn't realize that your problem was also the inconsistency in module names. Someone else suggested using a shell expansion; you could try
cat /proc/modules | tr _ - | grep -q "^${module_name/_/-}"
which is both short and works.
Signature · 2 lines
Ryan Reich [email protected]
Quoted 11 lines · Ryan Reich
On Mon, 16 Feb 2004, Ryan Reich wrote:
Sorry, I didn't realize that your problem was also the inconsistency in module names. Someone else suggested using a shell expansion; you could try
cat
/proc/modules| tr _ - | grep -q "^${module_name/_/-}"which is both short and works.
tr is usually in /usr/bin, which might not be available at boot time. And probably you mean 'grep -q "^${module_name//_/-}"'
Did I mention that the inconsistency requires ugly and error- prone workarounds? QED
Regards
Harri
Quoted 9 lines · Harald Dunkel
I know. But this requires some very ugly workarounds outside of module-init-tools. For example, if you want to check whether a module $module_name has already been loaded, you cannot use
grep -q "^${module_name} " /proc/modulesInstead you have to use a workaround like
Quoted 7 lines
x="`echo $module_name | sed -e 's/-/_/g'`" cat /proc/modules | sed -e 's/-/_/g' | grep -q "^${x} "This is inefficient and error-prone.
Maybe somebody has another idea for the workaround, but I like the first version.
just run modprobe? Then you don't have to care.
IN_KERNEL=$(/sbin/modprobe -vn "${module_name}")
if [ -z "${IN_KERNEL}" ; then
/bin/echo "Module: ${module_name} is in the kernel"
else
/bin/echo "Module: ${module_name} would need to be loaded"
/bin/echo "${IN_KERNEL}"fi
Or similar. Yeah it's a little ugly but only as prone to failure as module-init-tools
Yours Tony
linux.conf.au http://lca2005.linux.org.au/
Apr 18-23 2005 The Australian Linux Technical Conference!