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;
}
/* 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) {
}
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);
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;
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;
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;