From 9752950804975918aa299b8cd525961c1c2bae45 Mon Sep 17 00:00:00 2001 From: rsc Date: Tue, 15 May 2007 13:10:51 +0000 Subject: new media size from Lou Kamenov --- src/lib9/_p9dir.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'src/lib9') 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 #include -#if defined(__FreeBSD__) || defined(__OpenBSD__) +#if defined(__FreeBSD__) +#include #include #include -#define _HAVEDISKLABEL #endif #if defined(__OpenBSD__) +#include +#include +#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; -- cgit v1.2.3