diff options
author | Karel Zak | 2018-05-30 11:24:40 +0200 |
---|---|---|
committer | Karel Zak | 2018-06-21 13:19:28 +0200 |
commit | 345ddd2828ee4bac6e94e256150bd718e5a5ca5b (patch) | |
tree | 925aad6f79f029f6fa69c6d820b3d9c3a19e5005 /disk-utils | |
parent | partx: use new ul_path_* API (diff) | |
download | kernel-qcow2-util-linux-345ddd2828ee4bac6e94e256150bd718e5a5ca5b.tar.gz kernel-qcow2-util-linux-345ddd2828ee4bac6e94e256150bd718e5a5ca5b.tar.xz kernel-qcow2-util-linux-345ddd2828ee4bac6e94e256150bd718e5a5ca5b.zip |
blockdev: use new ul_path_* API
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'disk-utils')
-rw-r--r-- | disk-utils/blockdev.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/disk-utils/blockdev.c b/disk-utils/blockdev.c index f1ea53347..5122460f0 100644 --- a/disk-utils/blockdev.c +++ b/disk-utils/blockdev.c @@ -468,18 +468,21 @@ static void report_device(char *device, int quiet) ro = ssz = bsz = 0; ra = 0; - if (fstat(fd, &st) == 0 && !sysfs_devno_is_wholedisk(st.st_rdev)) { - struct sysfs_cxt cxt; - - if (sysfs_init(&cxt, st.st_rdev, NULL)) - err(EXIT_FAILURE, - _("%s: failed to initialize sysfs handler"), - device); - if (sysfs_read_u64(&cxt, "start", &start)) - err(EXIT_FAILURE, - _("%s: failed to read partition start from sysfs"), - device); - sysfs_deinit(&cxt); + if (fstat(fd, &st) == 0) { + dev_t disk; + struct path_cxt *pc; + + pc = ul_new_sysfs_path(st.st_rdev, NULL, NULL); + if (pc && + sysfs_blkdev_get_wholedisk(pc, NULL, 0, &disk) == 0 && + disk != st.st_rdev) { + + if (ul_path_read_u64(pc, &start, "start") != 0) + err(EXIT_FAILURE, + _("%s: failed to read partition start from sysfs"), + device); + } + ul_unref_path(pc); } if (ioctl(fd, BLKROGET, &ro) == 0 && ioctl(fd, BLKRAGET, &ra) == 0 && |