summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorIgor Pashev <pashev.igor@gmail.com>2014-02-16 01:50:31 +0400
committerIgor Pashev <pashev.igor@gmail.com>2014-02-17 22:57:08 +0400
commit38ae67bdcca49b174b4629bab7c2ed26a6c400bf (patch)
tree1d71e38dd2bb3b3ab0f2fd9857284e82b8564c0c /lib
parent1fd3abf1cc3751b70aac3287803ba4a0216327d5 (diff)
downloadutil-linux-38ae67bdcca49b174b4629bab7c2ed26a6c400bf.tar.gz
blkdev_get_size() for illumos
Diffstat (limited to 'lib')
-rw-r--r--lib/blkdev.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/lib/blkdev.c b/lib/blkdev.c
index f8182c0b..c84091e6 100644
--- a/lib/blkdev.c
+++ b/lib/blkdev.c
@@ -18,6 +18,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 */
@@ -160,7 +164,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;