こんにちは、私は Inotify に IN_UNMOUNT イベントを生成させようとしていますが、まったく協力していないので、inotifywait で簡単な実験を行ったところ、以下の結果が得られました。
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
基本的に何が起こるかというと、作成、オープンなどの他のすべてのイベントを取得します....しかし、/storage/test/をアンマウントすると、作成したすべてのウォッチに対してIGNOREDが発行されますが、発行されることはありません。 UNMOUNT イベント...
そのため、IN_UNMOUNT イベントを取得できないようですが、私が読んだすべての inotify ドキュメントには、監視対象のファイル/ディレクトリ バッキング ストレージがアンマウントされたときに、カーネルがイベントに IN_UNMOUNT ビットフラグを追加すると書かれていました...
これは、 Inotify パッチからの単純な C コードです。
#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;
}
とにかく、次の手順を実行しました。
gcc -oinotify inotify.c
mkdir mnt
sudo mount -ttmpfs none mnt
mkdir mnt/d
./inotify mnt/d/
# Different shell
sudo umount mnt
そして最後に、これがそれが放出するものです
read 16 bytes
event mask: 8000
現時点では、問題がコードにあるのか、それとも他の何かにあるのかわかりません。