[PATCH] common: get fs type again using device canonical name in _fs_type

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]



When testing with lvm, a previous btrfsck run could change df output
from something like

/dev/mapper/rhel_hp--dl388eg8--01-testlv1 btrfs 15728640 900 13602172 1% /mnt/btrfs

to

/dev/dm-3 btrfs 15728640 900 13602172 1% /mnt/btrfs

So "_fs_type $device" couldn't find the mounted btrfs in
_check_btrfs_filesystem and the fs couldn't get unmounted, then a latter
btrfsck reports the btrfs is currently mounted, which could fail the test.

Signed-off-by: Eryu Guan <eguan@xxxxxxxxxx>
---
 common/rc | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/common/rc b/common/rc
index 2c83340..a4fb21d 100644
--- a/common/rc
+++ b/common/rc
@@ -802,7 +802,13 @@ _fs_type()
     # Fix the filesystem type up here so that the callers don't
     # have to bother with this quirk.
     #
-    _df_device $1 | $AWK_PROG '{ print $2 }' | sed -e 's/nfs4/nfs/'
+    local fstype=`_df_device $1 | $AWK_PROG '{ print $2 }' | sed -e 's/nfs4/nfs/'`
+    # in case $device is a symlink(lvm) and df gives out the canonical name
+    if [ "$fstype" == "" ]; then
+        _df_device `_real_dev $1` | $AWK_PROG '{ print $2 }' | sed -e 's/nfs4/nfs/'`
+    else
+        echo $fstype
+    fi
 }
 
 # return the FS mount options of a mounted device
-- 
1.9.3

--
To unsubscribe from this list: send the line "unsubscribe fstests" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Filesystems Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux