안녕하세요. Inotify가 IN_UNMOUNT 이벤트를 발생 시키려고했지만 그와 전혀 협력하지 않으므로 inotifywait을 사용하여 간단한 실험을했는데 이것이 아래의 결과입니다.Inotify에서 IN_UNMOUNT 이벤트를 적절하게 내 보냅니다.
[email protected] ~ $ 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
는 기본적으로 무슨 일이는 등, 생성, 개방과 같은 다른 모든 이벤트를 선택할 것입니다 ....하지만 난 /저장/테스트/을 마운트 해제 할 때 그것은 가 무시 방출합니다 모든 시계를 만들었지 만 UNMOUNT 이벤트를 내 보내지는 않습니다 ...
그래서 IN_UNMOUNT 이벤트를 얻을 수 없지만 읽은 모든 inotify 문서는 모니터링되는 파일/디렉토리 백업 저장소가 마운트 해제되었을 때 커널이 이벤트에 IN_UNMOUNT 비트 플래그를 추가한다고 말합니다 ...
여기에서 간단한 C 코드입니다 - 어쨌든 Inotify 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;
}
내가 다음 단계 않았다가 방출하는 것을 마침내 여기
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
이 시점에서 문제가 코드에 있는지 또는 다른 것이 있는지 확실하지 않습니다.