diff options
author | rsc <devnull@localhost> | 2007-05-15 13:10:51 +0000 |
---|---|---|
committer | rsc <devnull@localhost> | 2007-05-15 13:10:51 +0000 |
commit | 9752950804975918aa299b8cd525961c1c2bae45 (patch) | |
tree | c8b9e7379ecd726a7ca0fcd704a915cf93d16d86 | |
parent | 43f16cfa921aabdddf07bc996d8690dd66c1f364 (diff) | |
download | plan9port-9752950804975918aa299b8cd525961c1c2bae45.tar.gz plan9port-9752950804975918aa299b8cd525961c1c2bae45.tar.bz2 plan9port-9752950804975918aa299b8cd525961c1c2bae45.zip |
new media size from Lou Kamenov
-rw-r--r-- | src/lib9/_p9dir.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/lib9/_p9dir.c b/src/lib9/_p9dir.c index e092b0cf..60c9b10c 100644 --- a/src/lib9/_p9dir.c +++ b/src/lib9/_p9dir.c @@ -7,13 +7,16 @@ #include <pwd.h> #include <grp.h> -#if defined(__FreeBSD__) || defined(__OpenBSD__) +#if defined(__FreeBSD__) +#include <sys/disk.h> #include <sys/disklabel.h> #include <sys/ioctl.h> -#define _HAVEDISKLABEL #endif #if defined(__OpenBSD__) +#include <sys/disklabel.h> +#include <sys/ioctl.h> +#define _HAVEDISKLABEL static int diskdev[] = { 151, /* aacd */ 116, /* ad */ @@ -249,7 +252,18 @@ _p9dir(struct stat *lst, struct stat *st, char *name, Dir *d, char **str, char * close(fd); } #endif -#ifdef _HAVEDISKLABEL +#if defined(__FreeBSD__) + if(isdisk(st)){ + int fd; + off_t mediasize; + + if((fd = open(name, O_RDONLY)) >= 0){ + if(ioctl(fd, DIOCGMEDIASIZE, &mediasize) >= 0) + d->length = mediasize; + close(fd); + } + } +#elif defined(_HAVEDISKLABEL) if(isdisk(st)){ int fd, n; struct disklabel lab; |