diff options
| author | Richard Maw <richard.maw@codethink.co.uk> | 2014-06-12 12:04:01 +0100 |
|---|---|---|
| committer | Richard Maw <richard.maw@codethink.co.uk> | 2014-06-12 12:04:01 +0100 |
| commit | c5c1033c5c7deda8abe3448ec81bbb33c72219e0 (patch) | |
| tree | 6e5cef29b85161eea8a7488a029f5a32f982c6ab /disk-utils/blockdev.c | |
| parent | 462008f79be9e195670b202cb43827b8aeb1e60b (diff) | |
| parent | 2fb567c080e1762ec6a2147564f03068f55d4f14 (diff) | |
| download | util-linux-baserock/morph.tar.gz | |
Merge branch 'baserock/richardmaw/yakshave/util-linux-blkid' into baserock/morphbaserock/morph
Reviewed-by: Lars Wirzenius
Reviewed-by: Sam Thursfield
Diffstat (limited to 'disk-utils/blockdev.c')
| -rw-r--r-- | disk-utils/blockdev.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/disk-utils/blockdev.c b/disk-utils/blockdev.c index 4543818bd..efaa0ead2 100644 --- a/disk-utils/blockdev.c +++ b/disk-utils/blockdev.c @@ -16,6 +16,7 @@ #include "blkdev.h" #include "pathnames.h" #include "closestream.h" +#include "sysfs.h" struct bdc { long ioc; /* ioctl code */ @@ -127,7 +128,7 @@ static const struct bdc bdcms[] = .argname = "<bytes>", .argtype = ARG_INT, .flags = FL_NORESULT, - .help = N_("set blocksize") + .help = N_("set blocksize on file descriptor opening the block device") },{ IOCTL_ENTRY(BLKGETSIZE), .name = "--getsize", @@ -436,7 +437,9 @@ static void report_device(char *device, int quiet) int ro, ssz, bsz; long ra; unsigned long long bytes; - struct hd_geometry g; + uint64_t start = 0; + struct sysfs_cxt cxt; + struct stat st; fd = open(device, O_RDONLY | O_NONBLOCK); if (fd < 0) { @@ -446,15 +449,22 @@ static void report_device(char *device, int quiet) } ro = ssz = bsz = 0; - g.start = ra = 0; + ra = 0; + if (fstat(fd, &st) == 0) { + if (sysfs_init(&cxt, st.st_rdev, NULL)) + err(EXIT_FAILURE, + _("%s: failed to initialize sysfs handler"), + device); + sysfs_read_u64(&cxt, "start", &start); + sysfs_deinit(&cxt); + } if (ioctl(fd, BLKROGET, &ro) == 0 && ioctl(fd, BLKRAGET, &ra) == 0 && ioctl(fd, BLKSSZGET, &ssz) == 0 && ioctl(fd, BLKBSZGET, &bsz) == 0 && - ioctl(fd, HDIO_GETGEO, &g) == 0 && blkdev_get_size(fd, &bytes) == 0) { - printf("%s %5ld %5d %5d %10ld %15lld %s\n", - ro ? "ro" : "rw", ra, ssz, bsz, g.start, bytes, device); + printf("%s %5ld %5d %5d %10ju %15lld %s\n", + ro ? "ro" : "rw", ra, ssz, bsz, start, bytes, device); } else { if (!quiet) warnx(_("ioctl error on %s"), device); |
