X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fpath.c;h=f62157e80184260a4a04f1a73177a7dea8a9cc2f;hb=9c73736da85110ca73d141b5acff6f4989092c07;hp=7a871246adfb7cd6990190ae114abdcf04c36ee0;hpb=fdf20a316035779bbec469e11d73c7544acbf30f;p=elogind.git diff --git a/src/path.c b/src/path.c index 7a871246a..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) { @@ -389,7 +393,8 @@ static int path_start(Unit *u) { return -ENOENT; p->failure = false; -path_enter_waiting(p, true); + path_enter_waiting(p, true); + return 0; } @@ -452,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); @@ -492,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);