diff options
| author | Igor Pashev <pashev.igor@gmail.com> | 2014-02-16 01:50:31 +0400 |
|---|---|---|
| committer | Igor Pashev <pashev.igor@gmail.com> | 2014-02-17 22:57:08 +0400 |
| commit | 38ae67bdcca49b174b4629bab7c2ed26a6c400bf (patch) | |
| tree | 1d71e38dd2bb3b3ab0f2fd9857284e82b8564c0c | |
| parent | 1fd3abf1cc3751b70aac3287803ba4a0216327d5 (diff) | |
| download | util-linux-38ae67bdcca49b174b4629bab7c2ed26a6c400bf.tar.gz | |
blkdev_get_size() for illumos
| -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 dac050db..c809d651 100644 --- a/configure.ac +++ b/configure.ac @@ -184,6 +184,7 @@ AC_CHECK_HEADERS([ \ sys/endian.h \ sys/disk.h \ sys/disklabel.h \ + sys/dkio.h \ sys/file.h \ sys/io.h \ sys/ioccom.h \ 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; |
