Hello, I'm trying to get Inotify to give way to the IN_UNMOUNT event, but it didn’t interact with me at all, so I went and did a simple experiment with inotifywait, and this is the result below:
paul@imaskar ~ $ inotifywait -r /storage/test/ -m Setting up watches. Beware: since -r was given, this may take a while! Watches established. /storage/test/ CREATE,ISDIR a /storage/test/ OPEN,ISDIR a /storage/test/ CLOSE_NOWRITE,CLOSE,ISDIR a /storage/test/ DELETE,ISDIR a /storage/test/a/ DELETE_SELF /storage/test/a/ IGNORED /storage/test/ IGNORED
Basically, what happens is that it will take away all other events, such as create, open, etc., but when I turn off / storage / test /, it gives IGNORED for all the clocks that it created, but it never fires an event UNMOUNT ...
So, it looks like I cannot get the IN_UNMOUNT event, but all the inotify documentation I read says that the kernel will add the IN_UNMOUNT bit flag to the event when the monitored storage of backup files / directories is disabled ...
Here is a simple C code from Fix Patch
#include <stdio.h> #include <stdlib.h> #include <sys/inotify.h> int main(int argc, char **argv) { char buf[1024]; struct inotify_event *ie; char *p; int i; ssize_t l; p = argv[1]; i = inotify_init(); inotify_add_watch(i, p, ~0); l = read(i, buf, sizeof(buf)); printf("read %d bytes\n", l); ie = (struct inotify_event *) buf; printf("event mask: %x\n", ie->mask); return 0; }
In any case, I took the following steps:
gcc -oinotify inotify.c mkdir mnt sudo mount -ttmpfs none mnt mkdir mnt/d ./inotify mnt/d/
And finally, this is what it emits
read 16 bytes event mask: 8000
So, at the moment I'm not sure if the problem is in the code or something else?