X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fcore%2Fmount.c;h=812d57dd06e3196cef5f0e4db68d16cc6d951534;hb=46bcf49291874c5a6b5b34ad6413c5a0f7725f4c;hp=679d15c50a4767618d6e4d803dc6fe060cc914ce;hpb=5cca8defd2717669c69d13c479c0885af5b534bd;p=elogind.git diff --git a/src/core/mount.c b/src/core/mount.c index 679d15c50..812d57dd0 100644 --- a/src/core/mount.c +++ b/src/core/mount.c @@ -74,13 +74,13 @@ static bool mount_needs_network(const char *options, const char *fstype) { return false; } -static bool mount_is_network(MountParameters *p) { +static bool mount_is_network(const MountParameters *p) { assert(p); return mount_needs_network(p->options, p->fstype); } -static bool mount_is_bind(MountParameters *p) { +static bool mount_is_bind(const MountParameters *p) { assert(p); if (mount_test_option(p->options, "bind")) @@ -98,13 +98,13 @@ static bool mount_is_bind(MountParameters *p) { return false; } -static bool mount_is_auto(MountParameters *p) { +static bool mount_is_auto(const MountParameters *p) { assert(p); return !mount_test_option(p->options, "noauto"); } -static bool needs_quota(MountParameters *p) { +static bool needs_quota(const MountParameters *p) { assert(p); if (mount_is_network(p)) @@ -1624,6 +1624,8 @@ static int mount_enumerate(Manager *m) { if (m->utab_inotify_fd < 0) goto fail_with_errno; + (void) mkdir_p_label("/run/mount", 0755); + r = inotify_add_watch(m->utab_inotify_fd, "/run/mount", IN_MOVED_TO); if (r < 0) goto fail_with_errno; @@ -1660,8 +1662,8 @@ static int mount_dispatch_io(sd_event_source *source, int fd, uint32_t revents, /* The manager calls this for every fd event happening on the * /proc/self/mountinfo file, which informs us about mounting - * table changes - * This may also be called for /run/mount events */ + * table changes, and for /run/mount events which we watch + * for mount options. */ if (fd == m->utab_inotify_fd) { char inotify_buffer[sizeof(struct inotify_event) + NAME_MAX + 1]; @@ -1669,18 +1671,18 @@ static int mount_dispatch_io(sd_event_source *source, int fd, uint32_t revents, char *p; int rescan = 0; - while ((r = read(fd, inotify_buffer, sizeof(inotify_buffer))) > 0) { + while ((r = read(fd, inotify_buffer, sizeof(inotify_buffer))) > 0) for (p = inotify_buffer; p < inotify_buffer + r; ) { event = (struct inotify_event *) p; /* only care about changes to utab, but we have * to monitor the directory to reliably get * notifications about when utab is replaced * using rename(2) */ - if (strcmp(event->name, "utab") == 0) + if ((event->mask & IN_Q_OVERFLOW) || streq(event->name, "utab")) rescan = 1; p += sizeof(struct inotify_event) + event->len; } - } + if (!rescan) return 0; }