diff options
author | Karel Zak | 2017-06-30 11:49:29 +0200 |
---|---|---|
committer | Karel Zak | 2017-07-14 11:34:55 +0200 |
commit | ea0acfc3358aa6ce2d3733ab6ac9cbbc7aec1535 (patch) | |
tree | 221b0edd8102b4b43fbbb32eb6c96a06e7ad53d2 /disk-utils | |
parent | libfdisk: add fdisk_device_is_used() (diff) | |
download | kernel-qcow2-util-linux-ea0acfc3358aa6ce2d3733ab6ac9cbbc7aec1535.tar.gz kernel-qcow2-util-linux-ea0acfc3358aa6ce2d3733ab6ac9cbbc7aec1535.tar.xz kernel-qcow2-util-linux-ea0acfc3358aa6ce2d3733ab6ac9cbbc7aec1535.zip |
sfdisk: use fdisk_device_is_used()
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'disk-utils')
-rw-r--r-- | disk-utils/sfdisk.c | 28 |
1 files changed, 1 insertions, 27 deletions
diff --git a/disk-utils/sfdisk.c b/disk-utils/sfdisk.c index c3a97a479..0cca4ebe0 100644 --- a/disk-utils/sfdisk.c +++ b/disk-utils/sfdisk.c @@ -48,7 +48,6 @@ #include "blkdev.h" #include "all-io.h" #include "rpmatch.h" -#include "loopdev.h" #include "optutils.h" #include "libfdisk.h" @@ -1392,31 +1391,6 @@ static size_t last_pt_partno(struct sfdisk *sf) return partno; } -#ifdef BLKRRPART -static int is_device_used(struct sfdisk *sf) -{ - struct stat st; - int fd; - - assert(sf); - assert(sf->cxt); - - fd = fdisk_get_devfd(sf->cxt); - if (fd < 0) - return 0; - - if (fstat(fd, &st) == 0 && S_ISBLK(st.st_mode) - && major(st.st_rdev) != LOOPDEV_MAJOR) - return ioctl(fd, BLKRRPART) != 0; - return 0; -} -#else -static int is_device_used(struct sfdisk *sf __attribute__((__unused__))) -{ - return 0; -} -#endif - #ifdef HAVE_LIBREADLINE static char *sfdisk_fgets(struct fdisk_script *dp, char *buf, size_t bufsz, FILE *f) @@ -1629,7 +1603,7 @@ static int command_fdisk(struct sfdisk *sf, int argc, char **argv) if (!sf->noact && !sf->noreread) { if (!sf->quiet) fputs(_("Checking that no-one is using this disk right now ..."), stdout); - if (is_device_used(sf)) { + if (fdisk_device_is_used(sf->cxt)) { if (!sf->quiet) fputs(_(" FAILED\n\n"), stdout); |