Brijesh Valera
Brijesh Valera

Reputation: 1117

How to disable rmmod for my own written kernel module?

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.

Upvotes: 1

Views: 1590

Answers (1)

Useless
Useless

Reputation: 67713

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.

Upvotes: 4

Related Questions