LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Kernel (http://www.linuxquestions.org/questions/linux-kernel-70/)
-   -   module dependence (http://www.linuxquestions.org/questions/linux-kernel-70/module-dependence-597958/)

linuxgentoo 11-08-2007 12:06 AM

module dependence
 
PHP Code:

root@lynn:/home/lynn# lsmod
Module                  Size  Used by
ipv6                  273892  10 

i want to know which modules dependent on ipv6 module


thanks

Simon Bridge 11-08-2007 09:47 AM

You could remove it and see which modules vanish :)

archtoad6 11-08-2007 06:50 PM

I think:
Code:

MOD='ipv6'
lsmod  | grep [^^]$MOD  | less -S

will give the answer you are looking for. You can omit the "less" at the risk of being confused by folded output lines. You could also/instead pipe it into a column selector that would remove the "(Used) by" modules. E.g., an awk or cut statement.


Notes on lsmod
The man page is, to say the least, sparse. IMNRHO, its brevity sucks. (With all due respect to the author, Rusty Russell, who is legendary for his work on netfilter & iptables.)

It is so bad, I originally thought there is a bug in the headers: column 3 seemed to be the # pages the module uses & col. 4 the list of other modules that use it. http://www.faqs.org/faqs/linux/faq/part4/ seems to support this idea:
Code:

Module        Pages    Used by
memory_cs          2            0
ds                2    [memory_cs]    3
i82365            4            2

However, http://www.cyberciti.biz/faq/howto-d...kernel/print/:
Quote:

First column is Module name and second column is size of modules i..e the output format is module name, size, use count, list of referring modules.
and http://osdir.com/ml/linux.evms.devel...msg00045.html:
Quote:

At a given time, if a module has "0" in the lsmod "Used" column and either
nothing or (unused) or (autoclean) in the "by" column, there are reasonable
chances that it is unused.
say otherwise.


An explanation of the meaning of the columns in the man page would save countless hours of grief. Changing "by" to "...by" in the headers wouldn't hurt either.

Why not change
Quote:

lsmod is a trivial program which nicely formats the contents of the /proc/modules, showing what kernel modules are currently loaded.
to
Quote:

lsmod is a trivial program which nicely formats the contents of /proc/modules, showing what kernel modules are currently loaded in a 4 column format:
"Module" - the name of the module
"Size" - the amount of memory it uses
"Used" - its use count
"by" - a "tight" (no spaces) comma separated list of referring modules
Although it only appears once - for brevity in the output - "Used" is to be mentally read twice: i.e. "by" is to be understood as "Used by", that is why it is not capitalized.


I also don't like lsmod's column formatting, esp. col. #3.
Code:

lsmod  | awk '{printf "%-21s %6s  %2s %s\n",$1,$2,$3,$4}'
or
Code:

lsmod  \
| sed '1s,by,...by,'  \
| awk '{printf "%-21s %6s  %2s %s\n",$1,$2,$3,$4}'

would be a good aliases for the current lsmod.

linuxgentoo 11-08-2007 08:44 PM

Quote:

Originally Posted by Simon Bridge (Post 2952198)
You could remove it and see which modules vanish :)

PHP Code:

localhost lynn # rmmod ipv6
ERRORModule ipv6 is in use 


tthtlc 11-08-2007 09:27 PM

depmod is the command - which generate the modules.dep file, in /lib/modules/xxxx/ directory:

For example:

/lib/modules/2.6.23/kernel/crypto/cbc.ko: /lib/modules/2.6.23/kernel/crypto/blkcipher.ko

From above we know that cbc is depending on blkcipher.ko.


All times are GMT -5. The time now is 08:08 AM.