LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (http://www.linuxquestions.org/questions/slackware-14/)
-   -   modprobe -l option not available (http://www.linuxquestions.org/questions/slackware-14/modprobe-l-option-not-available-4175429717/)

polch 09-30-2012 06:21 AM

modprobe -l option not available
 
Hi.

The "-l" option of modprobe isn't available anymore ? Is there any replacement ?

Regards.

Paul.

Didier Spaier 09-30-2012 06:45 AM

That's right. In the manual page of the version shipped in Slackware 13.37 we were warned:
Quote:

This option is provided for backwards compatibility and may go away in future
You could do something like this instead:
Code:

find /lib/modules/<kernel version>/ -type f -name "*ko"
EDIT You can replace <kernel version> with $(uname -r) or `uname -r` if you want to list the modules associated with the running kernel.

Eternal_Newbie 09-30-2012 09:00 AM

EDIT: Ignore this, it's wrong! (thanks Didier, for spotting the glaring error)

You could always use lsmod, that would be slightly more elegant than Didier's solution.

GNU/Linux 09-30-2012 10:21 AM

I've been using rc.firewall (from Projectfiles.com). So with Slackware 14 it spits out that error and I've decided to use 'lsmod' instead of lsmod -l in the line:
Code:

if (( `modprobe -l | grep -c "$MODULE"` )); then
I hope that's fine, but I do think that there are some other changes that came in with new kernel. So should I abandon the script and look somewhere else, since there might be other changes in iptables that are not available in the latest stable.

Anybody else still using the firewall from projectfiles?

Didier Spaier 09-30-2012 01:10 PM

Quote:

Originally Posted by Eternal_Newbie (Post 4793200)
You could always use lsmod, that would be slightly more elegant than Didier's solution.

"lsmod" only list loaded modules. Instead, "modprobe -l" (did) list all modules, be they loaded or not and the solution I proposed do the same. So they are not equivalent.

polch 10-01-2012 01:45 AM

Thank you.

I didn't notice the warning in the manual of the 13.37.

Thank for the tip.

Didier Spaier 10-01-2012 03:27 AM

Quote:

Originally Posted by GNU/Linux (Post 4793253)
I've been using rc.firewall (from Projectfiles.com). So with Slackware 14 it spits out that error and I've decided to use 'lsmod' instead of lsmod -l in the line:
Code:

if (( `modprobe -l | grep -c "$MODULE"` )); then
I hope that's fine

No, that's not fine.

I suppose you are thinking about making the replacement in this code snippet (from line #1189):
Code:

  for MODULE in $REQUIRED_MODULES; do
    if (( `modprobe -l | grep -c "$MODULE"` )); then
      modprobe $MODULE > /dev/null 2>&1
    fi
  done

So replacing "modprobe -l" with "lsmod" would have the effect of only loading modules that are already loaded, which was certainly not intended by the author. ;) Furthermore as the script date back 2006 the list of modules in $REQUIRED_MODULES should most probably be updated.

I would suggest you try the Easy Firewall Generator for IPTables from Alien Bob instead.

Eternal_Newbie 10-01-2012 04:17 AM

Quote:

Originally Posted by Didier Spaier (Post 4793374)
"lsmod" only list loaded modules. Instead, "modprobe -l" (did) list all modules, be they loaded or not and the solution I proposed do the same. So they are not equivalent.

Thanks for catching my mistake. I wonder why they got rid of modprobe -l when there is obviously a need for it?

Didier Spaier 10-01-2012 04:37 AM

Quote:

Originally Posted by Eternal_Newbie (Post 4793783)
I wonder why they got rid of modprobe -l when there is obviously a need for it?

Because it's easy enough to replace with a "find" command, as shown above. In previous "man modprobe" it was suggested to use "find" and "basename" instead. Let's do that (I suppose you want to list only the modules' names, without their paths):
Code:

for i in $(find /lib/modules/$(uname -r)/ -type f -name "*ko"); do basename $i; done
Proposing a simpler solution is left as an exercise .

EDIT Nostalgia? Add following line to your ~/.bashrc

Code:

alias ls-l='for i in $(find /lib/modules/$(uname -r)/ -type f -name "*ko"); do basename $i; done'
Then fire up a terminal and type:
Code:

ls-l

FeyFre 10-01-2012 05:16 AM

Quote:

Because it's easy enough to replace with a "find" command, as shown above. In previous "man modprobe" it was suggested to use "find" and "basename" instead. Let's do that:
So instead of simple spawning "modporbe -l" from my C code I forced to spawn shell(which can be absent)? I don't think I shall like it.

Didier Spaier 10-01-2012 05:21 AM

Quote:

Originally Posted by FeyFre (Post 4793838)
So instead of simple spawning "modporbe -l" from my C code I forced to spawn shell(which can be absent)? I don't think I shall like it.

I assume that you will easily replace the shell command by a subroutine written in C.


All times are GMT -5. The time now is 03:16 PM.