[systemd-commits] 2 commits - src/path.c TODO

Kay Sievers kay at kemper.freedesktop.org
Wed Dec 1 07:57:01 PST 2010


 TODO       |    2 --
 src/path.c |   10 +++++-----
 2 files changed, 5 insertions(+), 7 deletions(-)

New commits:
commit da2400b3749be84db50c36569db5bbf7ae979a36
Author: Kay Sievers <kay.sievers at vrfy.org>
Date:   Wed Dec 1 16:56:41 2010 +0100

    update TODO

diff --git a/TODO b/TODO
index 098beb5..fa4f05c 100644
--- a/TODO
+++ b/TODO
@@ -1,5 +1,3 @@
-* test and adjust rate limiter. triggers with scsi_debug
-
 * bind mounts with 'fsck' fail and block for a minute:
     /foo /bar none bind 1 1
   (using fsck is wrong, but why do we block for a minute

commit 67575eef76e99cc03b2860f8a93009a34ce37583
Author: Michal Schmidt <mschmidt at redhat.com>
Date:   Wed Dec 1 15:39:52 2010 +0100

    path: fix watching the root directory
    
    If you have a path unit with:
      DirectoryNotEmpty=/foo
    and "/foo" does not exist, creating it later escapes the attention of systemd.
    
    When adding watches for parent directories, systemd never adds one for the root
    directory. It attempts to add a watch for an empty string instead, which fails.
    
    If the path is "/", we must not trim the slash.

diff --git a/src/path.c b/src/path.c
index 0d59419..77de32d 100644
--- a/src/path.c
+++ b/src/path.c
@@ -189,7 +189,7 @@ static int path_watch_one(Path *p, PathSpec *s) {
         };
 
         bool exists = false;
-        char *k;
+        char *k, *slash;
         int r;
 
         assert(p);
@@ -213,15 +213,15 @@ static int path_watch_one(Path *p, PathSpec *s) {
         if ((s->primary_wd = inotify_add_watch(s->inotify_fd, k, flags_table[s->type])) >= 0)
                 exists = true;
 
-        for (;;) {
+        do {
                 int flags;
-                char *slash;
 
                 /* This assumes the path was passed through path_kill_slashes()! */
                 if (!(slash = strrchr(k, '/')))
                         break;
 
-                *slash = 0;
+                /* Trim the path at the last slash. Keep the slash if it's the root dir. */
+                slash[slash == k] = 0;
 
                 flags = IN_DELETE_SELF|IN_MOVE_SELF|IN_ATTRIB;
                 if (!exists)
@@ -229,7 +229,7 @@ static int path_watch_one(Path *p, PathSpec *s) {
 
                 if (inotify_add_watch(s->inotify_fd, k, flags) >= 0)
                         exists = true;
-        }
+        } while (slash != k);
 
         return 0;
 



More information about the systemd-commits mailing list