X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fcore%2Fnamespace.c;h=718da2384dc21adc294384d26941b7ec7d11713b;hb=4543768d13946e9193b367330cb32ded4d96058a;hp=38325030133cf8e4b5f63f0c4bc2ea4987757c52;hpb=dc75168823540076b354135f6e2de7a9a978fbca;p=elogind.git diff --git a/src/core/namespace.c b/src/core/namespace.c index 383250301..718da2384 100644 --- a/src/core/namespace.c +++ b/src/core/namespace.c @@ -83,9 +83,11 @@ static int append_mounts(BindMount **p, char **strv, MountMode mode) { static int mount_path_compare(const void *a, const void *b) { const BindMount *p = a, *q = b; + int d; - if (path_equal(p->path, q->path)) { + d = path_compare(p->path, q->path); + if (!d) { /* If the paths are equal, check the mode */ if (p->mode < q->mode) return -1; @@ -97,13 +99,7 @@ static int mount_path_compare(const void *a, const void *b) { } /* If the paths are not equal, then order prefixes first */ - if (path_startswith(p->path, q->path)) - return 1; - - if (path_startswith(q->path, p->path)) - return -1; - - return 0; + return d; } static void drop_duplicates(BindMount *m, unsigned *n) { @@ -164,7 +160,10 @@ static int mount_dev(BindMount *m) { } devptmx = strjoina(temporary_mount, "/dev/ptmx"); - symlink("pts/ptmx", devptmx); + if (symlink("pts/ptmx", devptmx) < 0) { + r = -errno; + goto fail; + } devshm = strjoina(temporary_mount, "/dev/shm"); (void) mkdir(devshm, 01777); @@ -176,14 +175,14 @@ static int mount_dev(BindMount *m) { devmqueue = strjoina(temporary_mount, "/dev/mqueue"); (void) mkdir(devmqueue, 0755); - mount("/dev/mqueue", devmqueue, NULL, MS_BIND, NULL); + (void) mount("/dev/mqueue", devmqueue, NULL, MS_BIND, NULL); devhugepages = strjoina(temporary_mount, "/dev/hugepages"); (void) mkdir(devhugepages, 0755); - mount("/dev/hugepages", devhugepages, NULL, MS_BIND, NULL); + (void) mount("/dev/hugepages", devhugepages, NULL, MS_BIND, NULL); devlog = strjoina(temporary_mount, "/dev/log"); - symlink("/run/systemd/journal/dev-log", devlog); + (void) symlink("/run/systemd/journal/dev-log", devlog); NULSTR_FOREACH(d, devnodes) { _cleanup_free_ char *dn = NULL; @@ -294,7 +293,7 @@ static int mount_kdbus(BindMount *m) { goto fail; } - r = mount(m->path, busnode, "bind", MS_BIND, NULL); + r = mount(m->path, busnode, NULL, MS_BIND, NULL); if (r < 0) { log_error_errno(errno, "bind mount of %s failed: %m", m->path); r = -errno; @@ -524,7 +523,7 @@ fail: if (n > 0) { for (m = mounts; m < mounts + n; ++m) if (m->done) - umount2(m->path, MNT_DETACH); + (void) umount2(m->path, MNT_DETACH); } return r;