You are not logged in.

#1 2012-01-25 22:55:58

Henry78
Member
Registered: 2012-01-23
Posts: 50

modprobe -l replacement for kmod?

A I learned, the '-l' switch - a it was present in m-i-t, doesn't exist for kmod. So what is your replacement for the lost '-l' functionality? Searching for *ko files in /lib/modules? Thats rather cumbersome...

Offline

#2 2012-01-26 00:10:46

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: modprobe -l replacement for kmod?

What exactly did it do? A piece of the output and manpage might help my aging memory / imagination.

Offline

#3 2012-01-26 00:45:30

byte
Member
From: Düsseldorf (DE)
Registered: 2006-05-01
Posts: 2,046

Re: modprobe -l replacement for kmod?

from Debian:

-l --list
List  all  modules matching the given wildcard (or "*" if no wildcard is given).  This option is provided for backwards compatibility and may go away in future: see find(1) and basename(1) for a more flexible alternative.

simple function for .bashrc:

fkm() {
  find /lib/modules/$(uname -r)/ -iname "*$1*.ko*" | cut -d/ -f5-
  if [[ "$(uname -r)" != "$(/bin/ls -1 /lib/modules/ | head -1)" ]]; then
    echo "Did you reboot after updating your kernel?"
  fi
}

('find kernel module', or whatever you like)


[edit: wtf, trailing-whitespace-cleanup]

Last edited by byte (2012-01-26 11:32:03)


1000

Offline

#4 2012-01-26 10:16:33

Henry78
Member
Registered: 2012-01-23
Posts: 50

Re: modprobe -l replacement for kmod?

Still would be nice, if kmod provided such a feature.

I like your function, thank you for sharing! But I like it more if the suffix is stripped:

fkm() {
    find /lib/modules/$(uname -r)/ -iname "*$1*.ko*" -exec basename {} .ko.gz \;

    if [[ "$(uname -r)" != "$(/bin/ls -1 /lib/modules/ | head -1)" ]]; then
        echo "Did you reboot after updating your kernel?"
    fi
}

Offline

#5 2012-01-26 11:04:43

falconindy
Developer
From: New York, USA
Registered: 2009-10-22
Posts: 4,110
Website

Re: modprobe -l replacement for kmod?

needs more bash... dashes and underscores should be treated equally as well -- they're interchangeable in the land of modules, so automatically "escape" them into globs.

fkm() {
  local kver=$(uname -r) arg=${1//[-_]/[-_]}
  find "/lib/modules/$kver" -iname "*$arg*.ko*" \
    -exec bash -c 'mods=("${@##*/}"); printf "%s\n" "${mods[@]%.ko*}"' _ {} +
  
  if [[ ! -e /lib/modules/$kver/kernel ]]; then
    echo "reboot!" >&2
  fi
}

Offline

Board footer

Powered by FluxBB