unixlinux-kernelinsmod

How to determine if a specific module is loaded in linux kernel


I am just curious is there any way to determine if a particular module is loaded/installed.

$ lsmod lists all modules (device driver loaded).

Is there any way to check or a command that returns true/false boolean output if a module name is polled. For eg. if keyboard.o exists return true else false. I need this tip to complete my driver auto refresh program.

PS: tried modinfo. I am using busybox client in my test DUT so can you give some alternatives other than modinfo?


Solution

  • not sure if modinfo modname and checking $? will work for you, just a suggestion.

    /tmp$ sudo modinfo e1000
    /tmp$ echo $?
    0
    /tmp$ sudo modinfo keyboard
    ERROR: modinfo: could not find module keyboard
    /tmp$ echo $?
    1
    

    alternatively you also grep /proc/modules