From 580272ed41dd82139c9730dfa7e410954984f929 Mon Sep 17 00:00:00 2001 From: Rusty Bird Date: Fri, 15 Jul 2016 16:15:41 +0000 Subject: [PATCH] udev-block-add-change: better mount status check The canonical device name is not necessarily used in /proc/mounts or /proc/self/mountinfo, see /dev/dm-0 vs. /dev/mapper/dmroot. (And only checking by major:minor is not possible in the case of btrfs.) Also fixes another bug where e.g. dm-10 would match when really only dm-1 was mounted, or when the mountpoint path included the device name, etc. Also catches enabled swap. (cherry picked from commit e7d7111f13ad60703a652e83be094d1565360a54) --- udev/udev-block-add-change | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/udev/udev-block-add-change b/udev/udev-block-add-change index b9f970b..e0eaadd 100755 --- a/udev/udev-block-add-change +++ b/udev/udev-block-add-change @@ -20,8 +20,8 @@ xs_remove() { is_used() { local sys_devpath=$1 - # mounted - if fgrep -q $(basename $sys_devpath) /proc/mounts; then + # mounted; or enabled swap + if lsblk -dnr -o MOUNTPOINT "$DEVNAME" | grep -q .; then return 0 fi # part of other device-mapper