diff options
| author | forsyth <forsyth@vitanuova.com> | 2011-08-20 14:02:37 -0400 |
|---|---|---|
| committer | forsyth <forsyth@vitanuova.com> | 2011-08-20 14:02:37 -0400 |
| commit | 48cb024ae0359615b78f436c402069348cf5f332 (patch) | |
| tree | b481925bc34df15b02ad7469f90ce55243dcd98d /emu/Linux/devfs.c | |
| parent | 42c934e1cbff05e8f5b5ba58cfde3c1f5a9f73ab (diff) | |
20110820-1401
Diffstat (limited to 'emu/Linux/devfs.c')
| -rw-r--r-- | emu/Linux/devfs.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/emu/Linux/devfs.c b/emu/Linux/devfs.c index 9017c3fc..d697d7b4 100644 --- a/emu/Linux/devfs.c +++ b/emu/Linux/devfs.c @@ -1 +1,26 @@ #include "devfs-posix.c" + +#include <linux/hdreg.h> +#include <linux/fs.h> +#include <sys/ioctl.h> + +static vlong +osdisksize(int fd) +{ + uvlong u64; + long l; + struct hd_geometry geo; + + memset(&geo, 0, sizeof geo); + l = 0; + u64 = 0; +#ifdef BLKGETSIZE64 + if(ioctl(fd, BLKGETSIZE64, &u64) >= 0) + return u64; +#endif + if(ioctl(fd, BLKGETSIZE, &l) >= 0) + return l*512; + if(ioctl(fd, HDIO_GETGEO, &geo) >= 0) + return (vlong)geo.heads*geo.sectors*geo.cylinders*512; + return 0; +} |
