X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fpath.c;h=f62157e80184260a4a04f1a73177a7dea8a9cc2f;hb=57f2a956e63d6b981b9d6277ab800ad4ad386f42;hp=92f99381e85a992e975eb9a04e28a73c3677637c;hpb=00dc5d769ac4a4019d6b6fe22e8383ec8b030a96;p=elogind.git diff --git a/src/path.c b/src/path.c index 92f99381e..f62157e80 100644 --- a/src/path.c +++ b/src/path.c @@ -106,11 +106,15 @@ static int path_add_default_dependencies(Path *p) { assert(p); - if (p->meta.manager->running_as == MANAGER_SYSTEM) + if (p->meta.manager->running_as == MANAGER_SYSTEM) { + if ((r = unit_add_dependency_by_name(UNIT(p), UNIT_BEFORE, SPECIAL_BASIC_TARGET, NULL, true)) < 0) + return r; + if ((r = unit_add_two_dependencies_by_name(UNIT(p), UNIT_AFTER, UNIT_REQUIRES, SPECIAL_SYSINIT_TARGET, NULL, true)) < 0) return r; + } - return unit_add_two_dependencies_by_name(UNIT(p), UNIT_BEFORE, UNIT_CONFLICTED_BY, SPECIAL_SHUTDOWN_TARGET, NULL, true); + return unit_add_two_dependencies_by_name(UNIT(p), UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_SHUTDOWN_TARGET, NULL, true); } static int path_load(Unit *u) { @@ -453,7 +457,8 @@ static void path_fd_event(Unit *u, int fd, uint32_t events, Watch *w) { Path *p = PATH(u); int l; ssize_t k; - struct inotify_event *buf = NULL; + uint8_t *buf = NULL; + struct inotify_event *e; PathSpec *s; assert(p); @@ -493,16 +498,22 @@ static void path_fd_event(Unit *u, int fd, uint32_t events, Watch *w) { goto fail; } - if ((size_t) k < sizeof(struct inotify_event) || - (size_t) k < sizeof(struct inotify_event) + buf->len) { - log_error("inotify event too small."); - goto fail; - } + e = (struct inotify_event*) buf; - if (s->type == PATH_CHANGED && s->primary_wd == buf->wd) - path_enter_running(p); - else - path_enter_waiting(p, false); + while (k > 0) { + size_t step; + + if (s->type == PATH_CHANGED && s->primary_wd == e->wd) + path_enter_running(p); + else + path_enter_waiting(p, false); + + step = sizeof(struct inotify_event) + e->len; + assert(step <= (size_t) k); + + e = (struct inotify_event*) ((uint8_t*) e + step); + k -= step; + } free(buf);