aboutsummaryrefslogtreecommitdiff
path: root/emu/Android/devfs.c
diff options
context:
space:
mode:
authorbhgv <bhgv.empire@gmail.com>2018-03-01 16:54:45 +0200
committerbhgv <bhgv.empire@gmail.com>2018-03-01 16:54:45 +0200
commitb786f20bbab5a59046aa78a2c6c2a11536497202 (patch)
tree0851ecdec889eb9b7ba3751cc04d4f0b474e4a9e /emu/Android/devfs.c
inferno-os tree was separated from the inferno-os-android (separated from the Android driver)
Diffstat (limited to 'emu/Android/devfs.c')
-rw-r--r--emu/Android/devfs.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/emu/Android/devfs.c b/emu/Android/devfs.c
new file mode 100644
index 0000000..60a051d
--- /dev/null
+++ b/emu/Android/devfs.c
@@ -0,0 +1,26 @@
+#include "devfs-posix-a.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;
+}