login
Header Space

 
 

inotify does not work on /sys/module

November 21, 2007 - 6:35am
Submitted by Anonymous on November 21, 2007 - 6:35am.
Linux

I have tested the inotify system calls by using the inotify-tools on
the "/sys/module" directory.
my goal: i want to get informed if a kernel module has been loaded or removed.

test behavior on a non sysfs directory is o.k.
test on sysfs (/sys) does not work as exepected -> see test logs below.

Linux kernel: 2.6.21.1 (not patched, from kernel.org)
inotify-tools: inotify-tools-3.11

test 1 (o.k.):
--------------
bash shell 1:
inotifywatch -v -e create -e delete /tmp
Establishing watches...
Total of 1 watches.

bash shell 2:
mkdir /tmp/XXX; rmdir /tmp/XXX

after that i abort inotifywatch in "bash shell 1" with CTRL-C:
Finished establishing watches, now collecting statistics.
total create delete filename
2 1 1 /tmp/

=> that is what i have expected!

test 2 (BUG ?):
---------------
Now i am testing if the inotify "create" and "delete" event works on
/sys/module (to get informed if a kernel module has been loaded
or removed):

bash shell 1:
inotifywatch -v -e create -e delete /sys/module/
Establishing watches...
Total of 1 watches.

bash shell 2:
#load and remove a "hello world" kernel module
#(directory "/sys/module/hello/" should be created and removed)
/sbin/insmod hello.ko; sleep 5; /sbin/rmmod hello

after that i abort inotifywatch in "bash shell 1" with CTRL-C:
Finished establishing watches, now collecting statistics.
total delete filename
1 1 /sys/module

=> directory creation has been not notified !!!!!!!
why ??

... thanks for your help ...

Sysfs is a psuedo filesystem

November 21, 2007 - 11:53am

Probably because the sysfs is a pseudo filesystem. Hence, it does not read/write/create/delete/modify files or directories the same way that a standard FS (ext3, for instance) would.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
speck-geostationary