vx32

Local 9vx git repository for patches.
git clone git://r-36.net/vx32
Log | Files | Refs

commit 39b60e6a65805bf484d0c46b2f8617c190283ccb
parent a2eb7d516f7c6a824ae891f63f17eaa52ddcf053
Author: Russ Cox <rsc@swtch.com>
Date:   Thu,  3 Jul 2008 17:45:56 -0400

9vx: devfs: add OS X disksize (Anthony Sorace)

Diffstat:
Msrc/9vx/devfs-posix.c | 36++++++++++++++++++++++++++++++------
1 file changed, 30 insertions(+), 6 deletions(-)

diff --git a/src/9vx/devfs-posix.c b/src/9vx/devfs-posix.c @@ -4,16 +4,23 @@ #include <grp.h> /* going to regret this - getgrgid is a stack smasher */ #include <sys/socket.h> #include <sys/un.h> + #if defined(__FreeBSD__) -#include <sys/disk.h> -#include <sys/disklabel.h> -#include <sys/ioctl.h> +#include <sys/disk.h> +#include <sys/disklabel.h> +#include <sys/ioctl.h> +#endif + +#if defined(__APPLE__) +#include <sys/disk.h> #endif + #if defined(__linux__) -#include <linux/hdreg.h> -#include <linux/fs.h> -#include <sys/ioctl.h> +#include <linux/hdreg.h> +#include <linux/fs.h> +#include <sys/ioctl.h> #endif + #include "lib.h" #include "mem.h" #include "dat.h" @@ -907,6 +914,23 @@ disksize(int fd, struct stat *st) return 0; } +#elif defined(__APPLE__) + +static vlong +disksize(int fd, int dev) +{ + u64int bc; + u32int bs; + + bs = 0; + bc = 0; + ioctl(fd, DKIOCGETBLOCKSIZE, &bs); + ioctl(fd, DKIOCGETBLOCKCOUNT, &bc); + if(bs >0 && bc > 0) + return bc*bs; + return 0; +} + #else static vlong