531551
diff -up util-linux-2.23.2/disk-utils/blockdev.c.kzak util-linux-2.23.2/disk-utils/blockdev.c
531551
--- util-linux-2.23.2/disk-utils/blockdev.c.kzak	2015-06-23 11:29:27.818001654 +0200
531551
+++ util-linux-2.23.2/disk-utils/blockdev.c	2015-06-23 11:29:43.752884860 +0200
531551
@@ -16,6 +16,7 @@
531551
 #include "blkdev.h"
531551
 #include "pathnames.h"
531551
 #include "closestream.h"
531551
+#include "sysfs.h"
531551
 
531551
 struct bdc {
531551
 	long		ioc;		/* ioctl code */
531551
@@ -364,7 +365,7 @@ static void do_commands(int fd, char **a
531551
 		}
531551
 
531551
 		if (res == -1) {
531551
-			perror(bdcms[j].iocname);
531551
+			warn(_("ioctl error on %s"), bdcms[j].iocname);
531551
 			if (verbose)
531551
 				printf(_("%s failed.\n"), _(bdcms[j].help));
531551
 			exit(EXIT_FAILURE);
531551
@@ -436,7 +437,8 @@ static void report_device(char *device,
531551
 	int ro, ssz, bsz;
531551
 	long ra;
531551
 	unsigned long long bytes;
531551
-	struct hd_geometry g;
531551
+	uint64_t start = 0;
531551
+	struct stat st;
531551
 
531551
 	fd = open(device, O_RDONLY | O_NONBLOCK);
531551
 	if (fd < 0) {
531551
@@ -446,15 +448,27 @@ static void report_device(char *device,
531551
 	}
531551
 
531551
 	ro = ssz = bsz = 0;
531551
-	g.start = ra = 0;
531551
+	ra = 0;
531551
+	if (fstat(fd, &st) == 0 && !sysfs_devno_is_wholedisk(st.st_rdev)) {
531551
+		struct sysfs_cxt cxt;
531551
+
531551
+		if (sysfs_init(&cxt, st.st_rdev, NULL))
531551
+			err(EXIT_FAILURE,
531551
+				_("%s: failed to initialize sysfs handler"),
531551
+				device);
531551
+		if (sysfs_read_u64(&cxt, "start", &start))
531551
+			err(EXIT_FAILURE,
531551
+				_("%s: failed to read partition start from sysfs"),
531551
+				device);
531551
+		sysfs_deinit(&cxt);
531551
+	}
531551
 	if (ioctl(fd, BLKROGET, &ro) == 0 &&
531551
 	    ioctl(fd, BLKRAGET, &ra) == 0 &&
531551
 	    ioctl(fd, BLKSSZGET, &ssz) == 0 &&
531551
 	    ioctl(fd, BLKBSZGET, &bsz) == 0 &&
531551
-	    ioctl(fd, HDIO_GETGEO, &g) == 0 &&
531551
 	    blkdev_get_size(fd, &bytes) == 0) {
531551
-		printf("%s %5ld %5d %5d %10ld %15lld   %s\n",
531551
-		       ro ? "ro" : "rw", ra, ssz, bsz, g.start, bytes, device);
531551
+		printf("%s %5ld %5d %5d %10ju %15lld   %s\n",
531551
+		       ro ? "ro" : "rw", ra, ssz, bsz, start, bytes, device);
531551
 	} else {
531551
 		if (!quiet)
531551
 			warnx(_("ioctl error on %s"), device);
531551
diff -up util-linux-2.23.2/include/sysfs.h.kzak util-linux-2.23.2/include/sysfs.h
531551
--- util-linux-2.23.2/include/sysfs.h.kzak	2015-06-23 11:32:12.709793086 +0200
531551
+++ util-linux-2.23.2/include/sysfs.h	2015-06-23 11:32:31.909652361 +0200
531551
@@ -72,6 +72,7 @@ extern int sysfs_is_partition_dirent(DIR
531551
 
531551
 extern int sysfs_devno_to_wholedisk(dev_t dev, char *diskname,
531551
             size_t len, dev_t *diskdevno);
531551
+extern int sysfs_devno_is_wholedisk(dev_t devno);
531551
 
531551
 extern int sysfs_scsi_get_hctl(struct sysfs_cxt *cxt, int *h,
531551
 			       int *c, int *t, int *l);
531551
diff -up util-linux-2.23.2/lib/sysfs.c.kzak util-linux-2.23.2/lib/sysfs.c
531551
--- util-linux-2.23.2/lib/sysfs.c.kzak	2015-06-23 11:31:32.166090250 +0200
531551
+++ util-linux-2.23.2/lib/sysfs.c	2015-06-23 11:31:59.684888551 +0200
531551
@@ -638,6 +638,18 @@ err:
531551
     return -1;
531551
 }
531551
 
531551
+/*
531551
+ * Return 0 or 1, or < 0 in case of error
531551
+ */
531551
+int sysfs_devno_is_wholedisk(dev_t devno)
531551
+{
531551
+	dev_t disk;
531551
+
531551
+	if (sysfs_devno_to_wholedisk(devno, NULL, 0, &disk) != 0)
531551
+		return -1;
531551
+
531551
+	return devno == disk;
531551
+}
531551
 
531551
 int sysfs_scsi_get_hctl(struct sysfs_cxt *cxt, int *h, int *c, int *t, int *l)
531551
 {