summaryrefslogtreecommitdiffstats
path: root/libmount/src/utils.c
diff options
context:
space:
mode:
authorKarel Zak2015-12-09 10:26:16 +0100
committerKarel Zak2015-12-09 10:26:16 +0100
commit6589a1632b313db1304b673a6ce41a48f203eb98 (patch)
treebf8398e1a37e228359235121a9901a49b4e835fe /libmount/src/utils.c
parentlibmount: add cgroup2 pseudo FS (diff)
downloadkernel-qcow2-util-linux-6589a1632b313db1304b673a6ce41a48f203eb98.tar.gz
kernel-qcow2-util-linux-6589a1632b313db1304b673a6ce41a48f203eb98.tar.xz
kernel-qcow2-util-linux-6589a1632b313db1304b673a6ce41a48f203eb98.zip
libmount: use fstatat(AT_NO_AUTOMOUNT) for mountpoints
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libmount/src/utils.c')
-rw-r--r--libmount/src/utils.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/libmount/src/utils.c b/libmount/src/utils.c
index 6c9217ee9..e57eb33ba 100644
--- a/libmount/src/utils.c
+++ b/libmount/src/utils.c
@@ -117,6 +117,15 @@ static int fstype_cmp(const void *v1, const void *v2)
return strcmp(s1, s2);
}
+int mnt_stat_mountpoint(const char *target, struct stat *st)
+{
+#ifdef AT_NO_AUTOMOUNT
+ return fstatat(-1, target, st, AT_NO_AUTOMOUNT);
+#else
+ return stat(target, st);
+#endif
+}
+
/*
* Note that the @target has to be an absolute path (so at least "/"). The
* @filename returns an allocated buffer with the last path component, for example:
@@ -983,7 +992,7 @@ char *mnt_get_mountpoint(const char *path)
if (*mnt == '/' && *(mnt + 1) == '\0')
goto done;
- if (stat(mnt, &st))
+ if (mnt_stat_mountpoint(mnt, &st))
goto err;
base = st.st_dev;
@@ -992,7 +1001,7 @@ char *mnt_get_mountpoint(const char *path)
if (!p)
break;
- if (stat(*mnt ? mnt : "/", &st))
+ if (mnt_stat_mountpoint(*mnt ? mnt : "/", &st))
goto err;
dir = st.st_dev;
if (dir != base) {