Skip to content

Commit

Permalink
sfdisk: don't use BLKRRPART to check loopdev usage
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
karelzak committed Apr 17, 2015
1 parent 2daf61b commit a53e37f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion disk-utils/sfdisk.c
Expand Up @@ -44,6 +44,7 @@
#include "blkdev.h"
#include "all-io.h"
#include "rpmatch.h"
#include "loopdev.h"

#include "libfdisk.h"
#include "fdisk-list.h"
Expand Down Expand Up @@ -1083,7 +1084,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;
Expand Down

0 comments on commit a53e37f

Please sign in to comment.