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