diff -r 3314f6c2b58a lib9/_p9dir.c --- a/lib9/_p9dir.c Sun May 08 08:26:38 2011 +0000 +++ b/lib9/_p9dir.c Sat May 21 21:51:37 2011 +0200 @@ -1,3 +1,4 @@ +#define _FILE_OFFSET_BITS 64 #include #define NOPLAN9DEFINES #include @@ -61,38 +62,17 @@ return (vlong)lab.d_partitions[n].p_size * lab.d_secsize; } -#elif defined(__linux__) -#include -#include -#include -#undef major -#define major(dev) ((int)(((dev) >> 8) & 0xff)) +#else +#include static vlong disksize(int fd, struct stat *st) { - u64int u64; - long l; - struct hd_geometry geo; + off_t n; - 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; -} - -#else -static vlong -disksize(int fd, struct stat *st) -{ - return 0; + n = lseek(fd, 0, SEEK_END); + if (n == -1) + return 0; + return n; } #endif diff -r 3314f6c2b58a lib9/dirfwstat.c --- a/lib9/dirfwstat.c Sun May 08 08:26:38 2011 +0000 +++ b/lib9/dirfwstat.c Sat May 21 21:51:37 2011 +0200 @@ -4,9 +4,19 @@ #include #include -#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__OpenBSD__) || defined(__linux__) +#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__OpenBSD__) /* do nothing -- futimes exists and is fine */ +#elif defined(__linux__) +static int +futimes(int fd, struct timeval *tv) +{ + char name[32]; + + sprint(name, "/dev/fd/%d", fd); + return utimes(name, tv); +} + #elif defined(__SunOS5_9__) /* use futimesat */ static int diff -r 3314f6c2b58a lib9/dirread.c --- a/lib9/dirread.c Sun May 08 08:26:38 2011 +0000 +++ b/lib9/dirread.c Sat May 21 21:51:37 2011 +0200 @@ -7,16 +7,11 @@ extern int _p9dir(struct stat*, struct stat*, char*, Dir*, char**, char*); #if defined(__linux__) +#include static int mygetdents(int fd, struct dirent *buf, int n) { - off_t off; - int nn; - - /* This doesn't match the man page, but it works in Debian with a 2.2 kernel */ - off = p9seek(fd, 0, 1); - nn = getdirentries(fd, (void*)buf, n, &off); - return nn; + return syscall(SYS_getdents, fd, (void*)buf, n); } #elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) static int diff -r 3314f6c2b58a lib9/libc.h --- a/lib9/libc.h Sun May 08 08:26:38 2011 +0000 +++ b/lib9/libc.h Sat May 21 21:51:37 2011 +0200 @@ -7,7 +7,7 @@ #define _LIBC_H_ 1 #if defined(__cplusplus) extern "C" { -#endif +#endif #include #include diff -r 3314f6c2b58a lib9/readcons.c --- a/lib9/readcons.c Sun May 08 08:26:38 2011 +0000 +++ b/lib9/readcons.c Sat May 21 21:51:37 2011 +0200 @@ -2,7 +2,7 @@ #define NOPLAN9DEFINES #include #include -#include +//#include static int rawx(int fd, int echoing) diff -r 3314f6c2b58a lib9/utf/utfecpy.c --- a/lib9/utf/utfecpy.c Sun May 08 08:26:38 2011 +0000 +++ b/lib9/utf/utfecpy.c Sat May 21 21:51:37 2011 +0200 @@ -11,7 +11,7 @@ * ANY REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. */ -#define _BSD_SOURCE 1 /* memccpy */ +#define _XOPEN_SOURCE 1000 /* memccpy */ #include #include #include "plan9.h"