esac
}
-# check that a FS on a device is mounted
-# if so, return mount point
-#
-_is_mounted()
+# check if the given device is mounted, if so, return mount point
+_is_dev_mounted()
{
- if [ $# -ne 1 ]
- then
- echo "Usage: _is_mounted device" 1>&2
- exit 1
- fi
+ local dev=$1
+ local fstype=${2:-$FSTYP}
- device=$1
+ if [ $# -lt 1 ]; then
+ echo "Usage: _is_dev_mounted <device> [fstype]" 1>&2
+ exit 1
+ fi
- if _mount | grep "$device " | $AWK_PROG -v pattern="type $FSTYP" '
- pattern { print $3 ; exit 0 }
- END { exit 1 }
- '
- then
- echo "_is_mounted: $device is not a mounted $FSTYP FS"
- exit 1
- fi
+ findmnt -rncv -S $dev -t $fstype -o TARGET | head -1
}
# remount a FS to a new mode (ro or rw)
fi
device=$1
- mountpoint=`_is_mounted $device`
+ mountpoint=`_is_dev_mounted $device`
if [ $USE_REMOUNT -eq 0 ]; then
$UMOUNT_PROG $device
ok=1
# Run online scrub if we can.
- mntpt="$(_is_mounted $device)"
+ mntpt="$(_is_dev_mounted $device)"
if [ -n "$mntpt" ] && _supports_xfs_scrub "$mntpt" "$device"; then
"$XFS_SCRUB_PROG" $scrubflag -v -d -n $device > $tmp.scrub 2>&1
if [ $? -ne 0 ]; then