If a user process is working with kernel module, I want that another process can't fire rmmod for that module. How to achieve this type of functionality?
-beginner in Linux kernel programming.
If a user process is working with kernel module, I want that another process can't fire rmmod for that module. How to achieve this type of functionality?
-beginner in Linux kernel programming.
rmmod
can only unload a module when the refcount is zero.
If the reference count is incremented when a user process is connected (and decremented when it disconnects), you'll be fine.
If the module exposes a device, or is mounted as a filesystem, this should be handled naturally - if not, I guess it'll depend on the userspace interface, but this where to start looking.
By the way, lsmod
will show your module refcount. You can check whether it's incremented when the userspace process connects.