]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
sfdisk: don't use BLKRRPART to check loopdev usage
authorKarel Zak <kzak@redhat.com>
Fri, 17 Apr 2015 08:32:48 +0000 (10:32 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 29 Apr 2015 10:39:51 +0000 (12:39 +0200)
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 <kzak@redhat.com>
disk-utils/sfdisk.c

index 35c371d6ab6a279f38c71b365c8cb1f73391ca9d..d8428d1f37a7f8cba6115037e086257e337c8312 100644 (file)
@@ -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;