From: Karel Zak Date: Fri, 17 Apr 2015 08:32:48 +0000 (+0200) Subject: sfdisk: don't use BLKRRPART to check loopdev usage X-Git-Tag: v2.26.2~26 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2d8b57dcbd589628697f9a4d18f6d796652ca5cc;p=thirdparty%2Futil-linux.git sfdisk: don't use BLKRRPART to check loopdev usage It seesm that kernel always returns EINVAL for BLKRRPART on loop devices, we call the ioctl to check if nobody else uses the device. Signed-off-by: Karel Zak --- diff --git a/disk-utils/sfdisk.c b/disk-utils/sfdisk.c index 35c371d6ab..d8428d1f37 100644 --- a/disk-utils/sfdisk.c +++ b/disk-utils/sfdisk.c @@ -41,6 +41,7 @@ #include "blkdev.h" #include "all-io.h" #include "rpmatch.h" +#include "loopdev.h" #include "libfdisk.h" #include "fdisk-list.h" @@ -1066,7 +1067,8 @@ static int is_device_used(struct sfdisk *sf) if (fd < 0) return 0; - if (fstat(fd, &st) == 0 && S_ISBLK(st.st_mode)) + if (fstat(fd, &st) == 0 && S_ISBLK(st.st_mode) + && major(st.st_rdev) != LOOPDEV_MAJOR) return ioctl(fd, BLKRRPART) != 0; #endif return 0;