chiark / gitweb /
util: make path_is_mount_point() recognize bind mounts, too
authorLennart Poettering <lennart@poettering.net>
Fri, 24 Aug 2012 22:10:17 +0000 (00:10 +0200)
committerLennart Poettering <lennart@poettering.net>
Tue, 4 Sep 2012 01:59:05 +0000 (18:59 -0700)
TODO
src/shared/path-util.c

diff --git a/TODO b/TODO
index 9fa240cc4e8bd70ae0f89241fb681c7228d45c12..9a888eccf7c72caf9ce9c6c4c4abc1c6a1c4ebf6 100644 (file)
--- a/TODO
+++ b/TODO
@@ -49,11 +49,11 @@ Bugfixes:
 
 Features:
 
-* introduce $container_boot_id
+* introduce /run/kmsg in containers?
 
-* wall messages for shutdown should move to logind
+* introduce $container_boot_id?
 
-* remove wants from journald.service
+* wall messages for shutdown should move to logind
 
 * allow writing multiple conditions in unit files on one line
 
index 8bc7955020e1ba7fec1cc9719ff96e91c9d10b7b..2bdbd22dc71becce8484dec92fb81dc8326e68ef 100644 (file)
@@ -330,15 +330,22 @@ bool path_equal(const char *a, const char *b) {
 }
 
 int path_is_mount_point(const char *t, bool allow_symlink) {
-        struct stat a, b;
         char *parent;
         int r;
+        struct file_handle *h;
+        int mount_id, mount_id_parent;
 
-        if (allow_symlink)
-                r = stat(t, &a);
-        else
-                r = lstat(t, &a);
+        /* We are not actually interested in the file handles, but
+         * name_to_handle_at() also passes us the mount ID, hence use
+         * it but throw the handle away */
+
+        if (path_equal(t, "/"))
+                return 1;
 
+        h = alloca(MAX_HANDLE_SZ);
+        h->handle_bytes = MAX_HANDLE_SZ;
+
+        r = name_to_handle_at(AT_FDCWD, t, h, &mount_id, allow_symlink ? AT_SYMLINK_FOLLOW : 0);
         if (r < 0) {
                 if (errno == ENOENT)
                         return 0;
@@ -350,13 +357,15 @@ int path_is_mount_point(const char *t, bool allow_symlink) {
         if (r < 0)
                 return r;
 
-        r = lstat(parent, &b);
+        h->handle_bytes = MAX_HANDLE_SZ;
+        r = name_to_handle_at(AT_FDCWD, parent, h, &mount_id_parent, 0);
         free(parent);
 
         if (r < 0)
                 return -errno;
 
-        return a.st_dev != b.st_dev;
+
+        return mount_id != mount_id_parent;
 }
 
 int path_is_read_only_fs(const char *path) {