X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=mount-setup.c;h=1b3d32bb37f9faf162ddf154907baccbe27b8511;hp=013e6144cfc142532f17358ccea4e0ab83be3959;hb=185986c61d4f84efcc02cc5766c77e876654a0a9;hpb=2076ca540e4ffdd320e086c8b570a5bf19546022 diff --git a/mount-setup.c b/mount-setup.c index 013e6144c..1b3d32bb3 100644 --- a/mount-setup.c +++ b/mount-setup.c @@ -42,13 +42,15 @@ typedef struct MountPoint { } MountPoint; static const MountPoint mount_table[] = { - { "proc", "/proc", "proc", NULL, MS_NOSUID|MS_NOEXEC|MS_NODEV, true }, - { "sysfs", "/sys", "sysfs", NULL, MS_NOSUID|MS_NOEXEC|MS_NODEV, true }, - { "devtmps", "/dev", "devtmpfs", "mode=755", MS_NOSUID, true }, - { "tmpfs", "/dev/shm", "tmpfs", "mode=1777", MS_NOSUID|MS_NOEXEC|MS_NODEV, true }, - { "devpts", "/dev/pts", "devpts", NULL, MS_NOSUID|MS_NOEXEC|MS_NODEV, false }, - { "cgroup", "/cgroup/debug", "cgroup", "debug", MS_NOSUID|MS_NOEXEC|MS_NODEV, true }, - { "debugfs", "/sys/kernel/debug", "debugfs", NULL, MS_NOSUID|MS_NOEXEC|MS_NODEV, false } + { "proc", "/proc", "proc", NULL, MS_NOSUID|MS_NOEXEC|MS_NODEV, true }, + { "sysfs", "/sys", "sysfs", NULL, MS_NOSUID|MS_NOEXEC|MS_NODEV, true }, + { "devtmps", "/dev", "devtmpfs", "mode=755", MS_NOSUID, true }, + { "tmpfs", "/dev/shm", "tmpfs", "mode=1777", MS_NOSUID|MS_NOEXEC|MS_NODEV, true }, + { "devpts", "/dev/pts", "devpts", NULL, MS_NOSUID|MS_NOEXEC|MS_NODEV, false }, + { "cgroup", "/cgroup/debug", "cgroup", "debug", MS_NOSUID|MS_NOEXEC|MS_NODEV, true }, + { "debugfs", "/sys/kernel/debug", "debugfs", NULL, MS_NOSUID|MS_NOEXEC|MS_NODEV, false }, + { "binfmt_misc", "/proc/sys/fs/binfmt_misc", "binfmt_misc", NULL, MS_NOSUID|MS_NOEXEC|MS_NODEV, false }, + { "mqueue", "/dev/mqueue", "mqueue", NULL, MS_NOSUID|MS_NOEXEC|MS_NODEV, false }, }; bool mount_point_is_api(const char *path) { @@ -61,32 +63,7 @@ bool mount_point_is_api(const char *path) { if (path_startswith(path, mount_table[i].where)) return true; - return false; -} - -static int is_mount_point(const char *t) { - struct stat a, b; - char *copy; - - if (lstat(t, &a) < 0) { - - if (errno == ENOENT) - return 0; - - return -errno; - } - - if (!(copy = strdup(t))) - return -ENOMEM; - - if (lstat(dirname(copy), &b) < 0) { - free(copy); - return -errno; - } - - free(copy); - - return a.st_dev != b.st_dev; + return path_startswith(path, "/cgroup/"); } static int mount_one(const MountPoint *p) { @@ -94,7 +71,7 @@ static int mount_one(const MountPoint *p) { assert(p); - if ((r = is_mount_point(p->where)) < 0) + if ((r = path_is_mount_point(p->where)) < 0) return r; if (r > 0)