|
|
4af5d6 |
From 98c4a01c21b99b13d8aaa406ab15b7424ee5ef9f Mon Sep 17 00:00:00 2001
|
|
|
4af5d6 |
From: Eric Sandeen <sandeen@redhat.com>
|
|
|
4af5d6 |
Date: Wed, 23 May 2018 16:30:49 -0500
|
|
|
4af5d6 |
Subject: [PATCH] xfsprogs: be careful about what we stat in
|
|
|
4af5d6 |
platform_check_mount
|
|
|
4af5d6 |
|
|
|
4af5d6 |
After we lost ustat(2) in commit 4e7a824, we ended up with a slightly
|
|
|
4af5d6 |
bonkers method to determine if our target block device was mounted:
|
|
|
4af5d6 |
it goes through every entry returned by getmntent and stats the dir
|
|
|
4af5d6 |
to see if its underlying device matches ours.
|
|
|
4af5d6 |
|
|
|
4af5d6 |
Unfortunately that dir might be a hung nfs server and sadness ensues.
|
|
|
4af5d6 |
|
|
|
4af5d6 |
So just do a really simple sanity check before we try to stat the
|
|
|
4af5d6 |
mountpoint: does its device start with a / ? If not, skip it.
|
|
|
4af5d6 |
|
|
|
4af5d6 |
Fixes: 4e7a824 ("libxfs/linux.c: Replace use of ustat by stat")
|
|
|
4af5d6 |
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
|
|
|
4af5d6 |
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
|
|
|
4af5d6 |
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
|
|
|
4af5d6 |
---
|
|
|
4af5d6 |
libfrog/linux.c | 10 ++++++++++
|
|
|
4af5d6 |
1 file changed, 10 insertions(+)
|
|
|
4af5d6 |
|
|
|
4af5d6 |
Index: xfsprogs-4.5.0/libxfs/linux.c
|
|
|
4af5d6 |
===================================================================
|
|
|
4af5d6 |
--- xfsprogs-4.5.0.orig/libxfs/linux.c
|
|
|
4af5d6 |
+++ xfsprogs-4.5.0/libxfs/linux.c
|
|
|
4af5d6 |
@@ -68,7 +68,17 @@ platform_check_ismounted(char *name, cha
|
|
|
4af5d6 |
progname, name);
|
|
|
4af5d6 |
return 1;
|
|
|
4af5d6 |
}
|
|
|
4af5d6 |
+ /*
|
|
|
4af5d6 |
+ * This whole business is to work out if our block device is mounted
|
|
|
4af5d6 |
+ * after we lost ustat(2), see:
|
|
|
4af5d6 |
+ * 4e7a824 libxfs/linux.c: Replace use of ustat by stat
|
|
|
4af5d6 |
+ * We don't really want to stat every single mounted directory,
|
|
|
4af5d6 |
+ * as that may include tmpfs, cgroups, procfs or - worst - hung nfs
|
|
|
4af5d6 |
+ * servers. So first, a simple check: does the "dev" start with "/" ?
|
|
|
4af5d6 |
+ */
|
|
|
4af5d6 |
while ((mnt = getmntent(f)) != NULL) {
|
|
|
4af5d6 |
+ if (mnt->mnt_fsname[0] != '/')
|
|
|
4af5d6 |
+ continue;
|
|
|
4af5d6 |
if (stat64(mnt->mnt_dir, &mst) < 0)
|
|
|
4af5d6 |
continue;
|
|
|
4af5d6 |
if (mst.st_dev != s->st_rdev)
|
|
|
4af5d6 |
@@ -99,7 +109,17 @@ platform_check_iswritable(char *name, ch
|
|
|
4af5d6 |
"mounted filesystem\n"), progname, name);
|
|
|
4af5d6 |
return fatal;
|
|
|
4af5d6 |
}
|
|
|
4af5d6 |
+ /*
|
|
|
4af5d6 |
+ * This whole business is to work out if our block device is mounted
|
|
|
4af5d6 |
+ * after we lost ustat(2), see:
|
|
|
4af5d6 |
+ * 4e7a824 libxfs/linux.c: Replace use of ustat by stat
|
|
|
4af5d6 |
+ * We don't really want to stat every single mounted directory,
|
|
|
4af5d6 |
+ * as that may include tmpfs, cgroups, procfs or - worst - hung nfs
|
|
|
4af5d6 |
+ * servers. So first, a simple check: does the "dev" start with "/" ?
|
|
|
4af5d6 |
+ */
|
|
|
4af5d6 |
while ((mnt = getmntent(f)) != NULL) {
|
|
|
4af5d6 |
+ if (mnt->mnt_fsname[0] != '/')
|
|
|
4af5d6 |
+ continue;
|
|
|
4af5d6 |
if (stat64(mnt->mnt_fsname, &mst) < 0)
|
|
|
4af5d6 |
continue;
|
|
|
4af5d6 |
if ((mst.st_mode & S_IFMT) != S_IFBLK)
|