diff options
-rw-r--r-- | configure.ac | 1 | ||||
-rw-r--r-- | lib/blkdev.c | 16 |
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; |