mirror of
https://github.com/9fans/plan9port.git
synced 2025-01-27 11:52:03 +00:00
new media size from Lou Kamenov
This commit is contained in:
parent
43f16cfa92
commit
9752950804
1 changed files with 17 additions and 3 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue