X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fpath.c;h=bd40ab6f99bfa1fc41583e67125abedcf496dc50;hp=0d594197779f40366bb2dcc31035a313a346a669;hb=3351dc07213d17c2d5443c40d7fe100c0c4dce9a;hpb=4313fc2ceb6aa4dd9b8ddc02be65903cd5e071ac diff --git a/src/path.c b/src/path.c index 0d5941977..bd40ab6f9 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; @@ -279,7 +279,7 @@ static void path_set_state(Path *p, PathState state) { path_state_to_string(old_state), path_state_to_string(state)); - unit_notify(UNIT(p), state_translation_table[old_state], state_translation_table[state]); + unit_notify(UNIT(p), state_translation_table[old_state], state_translation_table[state], true); } static void path_enter_waiting(Path *p, bool initial, bool recheck);