summaryrefslogtreecommitdiff
path: root/block.c
diff options
context:
space:
mode:
authorbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>2006-04-25 22:36:06 +0000
committerbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>2006-04-25 22:36:06 +0000
commitec530c81efea6ddb1f75758658fd6769a29c3ade (patch)
tree2d8afdd2021666eaf854195ed0a32603b97044f5 /block.c
parent96b74a0221a7d552a4b3016af2b8bc87628fdab3 (diff)
downloadqemu-ec530c81efea6ddb1f75758658fd6769a29c3ade.tar.gz
Solaris port (Ben Taylor)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1855 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'block.c')
-rw-r--r--block.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/block.c b/block.c
index 6924cee67d..b908167186 100644
--- a/block.c
+++ b/block.c
@@ -44,6 +44,10 @@
#include <CoreFoundation/CoreFoundation.h>
#endif
+#ifdef __sun__
+#include <sys/dkio.h>
+#endif
+
static BlockDriverState *bdrv_first;
static BlockDriver *first_drv;
@@ -648,7 +652,6 @@ void bdrv_info(void)
}
}
-
/**************************************************************/
/* RAW block driver */
@@ -669,6 +672,10 @@ static int raw_open(BlockDriverState *bs, const char *filename)
#ifdef _BSD
struct stat sb;
#endif
+#ifdef __sun__
+ struct dk_minfo minfo;
+ int rv;
+#endif
fd = open(filename, O_RDWR | O_BINARY | O_LARGEFILE);
if (fd < 0) {
@@ -689,6 +696,17 @@ static int raw_open(BlockDriverState *bs, const char *filename)
#endif
} else
#endif
+#ifdef __sun__
+ /*
+ * use the DKIOCGMEDIAINFO ioctl to read the size.
+ */
+ rv = ioctl ( fd, DKIOCGMEDIAINFO, &minfo );
+ if ( rv != -1 ) {
+ size = minfo.dki_lbsize * minfo.dki_capacity;
+ } else /* there are reports that lseek on some devices
+ fails, but irc discussion said that contingency
+ on contingency was overkill */
+#endif
{
size = lseek(fd, 0, SEEK_END);
}