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>
#include "blkdev.h"
#include "all-io.h"
#include "rpmatch.h"
+#include "loopdev.h"
#include "libfdisk.h"
#include "fdisk-list.h"
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;