Archived
1
0
Fork 0

inotify.c: call add/rmwatch on files to (symbolic links).

This commit is contained in:
Henrik Hautakoski 2011-02-28 19:29:47 +01:00
parent 361f30c6b3
commit 2d5f94374c

View file

@ -46,7 +46,7 @@ static int inotify_watch(const char *path) {
int wd = inotify_add_watch(fd, path, WATCH_MASK);
if (wd < 0) {
if (errno != EACCES)
if (errno != EACCES && errno != ENOTDIR)
logerrno(LOG_CRIT, "inotify_watch", errno);
return -1;
}
@ -122,13 +122,17 @@ static int rmwatch(const char *path, const char *name) {
return -1;
}
logmsg(LOG_DEBUG, "remove watch: %i %s", wd, fpath);
free(fpath);
if (inotify_unmap_path(fpath) == 0) {
if (inotify_rm_watch(fd, wd) < 0) {
logerrno(LOG_CRIT, "intotify_rm_watch", errno);
return -1;
logmsg(LOG_DEBUG, "remove watch: %i %s", wd, fpath);
if (inotify_rm_watch(fd, wd) < 0) {
logerrno(LOG_CRIT, "intotify_rm_watch", errno);
free(fpath);
return -1;
}
}
free(fpath);
return 0;
}
@ -173,23 +177,13 @@ static void proc_event(inoev *iev) {
switch(iev->mask) {
case IN_CREATE :
if (event->dir) {
logmsg(LOG_DEBUG, "IN_CREATE on directory, adding");
addwatch(event->path, event->filename);
}
type = NOTIFY_CREATE;
break;
case IN_MOVED_TO :
if (event->dir) {
logmsg(LOG_DEBUG, "IN_MOVED_TO on directory, adding");
addwatch(event->path, event->filename);
}
addwatch(event->path, event->filename);
type = NOTIFY_CREATE;
break;
case IN_MOVED_FROM :
if (event->dir)
rmwatch(event->path, event->filename);
case IN_DELETE :
case IN_MOVED_FROM :
rmwatch(event->path, event->filename);
type = NOTIFY_DELETE;
break;
}