summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Pashev <pashev.igor@gmail.com>2012-06-19 20:32:35 +0000
committerIgor Pashev <pashev.igor@gmail.com>2012-06-19 20:32:35 +0000
commitc5592df6100fa71a0e942bddaca502bb0dd1bd83 (patch)
tree3a38dbf98ae40925e06ef78a4cff1935fdade2a5
parent505e274639684fba6f275da6b4cbffc2088d66b8 (diff)
downloadutil-linux-old-c5592df6100fa71a0e942bddaca502bb0dd1bd83.tar.gz
blkdev_get_size() on Solaris
-rw-r--r--configure.ac1
-rw-r--r--lib/blkdev.c16
2 files changed, 16 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac
index ddff5017..0a243943 100644
--- a/configure.ac
+++ b/configure.ac
@@ -131,6 +131,7 @@ AC_CHECK_HEADERS(
stdlib.h \
sys/disk.h \
sys/disklabel.h \
+ sys/dkio.h \
sys/ioctl.h \
sys/ioccom.h \
sys/io.h \
diff --git a/lib/blkdev.c b/lib/blkdev.c
index 67c4a1ac..5514f867 100644
--- a/lib/blkdev.c
+++ b/lib/blkdev.c
@@ -13,6 +13,10 @@
#include <sys/disklabel.h>
#endif
+#ifdef HAVE_SYS_DKIO_H
+#include <sys/dkio.h>
+#endif
+
#ifdef HAVE_SYS_DISK_H
#ifdef HAVE_SYS_QUEUE_H
#include <sys/queue.h> /* for LIST_HEAD */
@@ -148,7 +152,17 @@ blkdev_get_size(int fd, unsigned long long *bytes)
}
}
#endif /* HAVE_SYS_DISKLABEL_H */
-
+#ifdef DKIOCG_PHYGEOM
+ /* sunos (illumos/solaris) */
+ {
+ struct dk_geom geom;
+ if (ioctl(fd, DKIOCG_PHYGEOM, &geom) >= 0) {
+ *bytes = geom.dkg_ncyl * geom.dkg_nhead * geom.dkg_nsect;
+ *bytes <<= 9; /* x 512 */
+ return 0;
+ }
+ }
+#endif /* DKIOCG_PHYGEOM */
{
struct stat st;