kldstat and module ref count

Toni Andjelkovic toni at soth.at
Thu Mar 25 22:45:01 PST 2004


On Fri, Mar 26 2004 (09:15:26 +1100), Sam Lawrance wrote:
> I've tried to find the answer to this but am stuck. How can I prevent a
> kld module being unloaded if it is still in use?
> 
> Filesystem modules give "device busy" if you try to kldunload them while
> still in use. Any sort of quick pointer in the right direction would be
> much appreciated.

You may veto the unload by returning an error > 0 from the module event
handler. See md_modevent() in sys/dev/md/md.c or vfs_modevent() in
sys/kern/vfs_init.c for examples.

Cheers,
Toni


More information about the freebsd-hackers mailing list