inotify: Watch out for files moved to/from watched dirs
authorDaniel Wagner <daniel.wagner@bmw-carit.de>
Tue, 13 Nov 2012 12:50:03 +0000 (13:50 +0100)
committerDaniel Wagner <daniel.wagner@bmw-carit.de>
Fri, 23 Nov 2012 12:45:10 +0000 (13:45 +0100)
When we do not watch watch for IN_MOVED_TO or IN_MOVED_FROM we can
easily inconsistent. The user creates a file and moves it then
from the watched directory. We wouldn't see this change and therefore
keep the configuration. That is a rather anoying behavoir
for the policy plugin.

src/inotify.c

index 6646f5e..f451f1c 100644 (file)
@@ -116,7 +116,8 @@ static int create_watch(const char *path, struct connman_inotify *inotify)
                return -EIO;
 
        inotify->wd = inotify_add_watch(fd, path,
-                                       IN_MODIFY | IN_CREATE | IN_DELETE);
+                                       IN_MODIFY | IN_CREATE | IN_DELETE |
+                                       IN_MOVED_TO | IN_MOVED_FROM);
        if (inotify->wd < 0) {
                connman_error("Creation of %s watch failed", path);
                close(fd);