3

How do I access a list of users/programs that accessed a certain module?

I run:

lsmod | grep ^uvcvideo

This returns this line when no application is using my video camera:

uvcvideo               86016  0

Well, I have something running that when "0" at the end of the line turns to anything but 0 (in practice this is usually 1) it sends me a notification that my camera is in use.

I want to know if there is a log of programs that turned that 0 to a 1, or which modules are accessed when/how.

2

Usually, there is no log file for this. There are tools you can use to make one though!

The kernel has a built-in tracepoint for the try_module_get() function. That's the function that increases the reference count of a module. This tracepoint is in the module subsystem and is called module_get.

https://stackoverflow.com/questions/448999/is-there-a-way-to-figure-out-what-is-using-a-linux-kernel-module/449856 (long read).

To get you started, you can try perf trace -a --no-syscalls -e module:module_get -e module:module_put. This shows the program name, but it does not show the PID.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.