summaryrefslogtreecommitdiff
path: root/lib/blkdev.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/blkdev.c')
-rw-r--r--lib/blkdev.c16
1 files changed, 15 insertions, 1 deletions
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;