diff options
author | Rich Felker <dalias@aerifal.cx> | 2011-09-19 23:35:48 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2011-09-19 23:35:48 -0400 |
commit | 114c80f1416617399c85c2df09dd307532399903 (patch) | |
tree | 5168ccc178e9b854385fa23caab3e055ea7a555c | |
parent | 8c07f6eac843c2acb217083d48c4cef95f2b891c (diff) | |
download | musl-114c80f1416617399c85c2df09dd307532399903.zip musl-114c80f1416617399c85c2df09dd307532399903.tar.gz musl-114c80f1416617399c85c2df09dd307532399903.tar.bz2 |
fix the definition of struct statvfs to match lsb abi
at the same time, make struct statfs match the traditional definition
and make it more useful, especially the fsid_t stuff.
-rw-r--r-- | arch/arm/bits/statfs.h | 21 | ||||
-rw-r--r-- | arch/i386/bits/statfs.h | 21 | ||||
-rw-r--r-- | arch/x86_64/bits/statfs.h | 20 | ||||
-rw-r--r-- | include/sys/statfs.h | 11 | ||||
-rw-r--r-- | include/sys/statvfs.h | 20 | ||||
-rw-r--r-- | src/stat/fstatvfs.c | 17 | ||||
-rw-r--r-- | src/stat/statvfs.c | 48 |
7 files changed, 88 insertions, 70 deletions
diff --git a/arch/arm/bits/statfs.h b/arch/arm/bits/statfs.h index 9dda440..f103f4e 100644 --- a/arch/arm/bits/statfs.h +++ b/arch/arm/bits/statfs.h @@ -1,16 +1,7 @@ -struct statvfs { - unsigned long f_type; - unsigned long f_bsize; - fsblkcnt_t f_blocks; - fsblkcnt_t f_bfree; - fsblkcnt_t f_bavail; - fsfilcnt_t f_files; - fsfilcnt_t f_ffree; - unsigned long f_fsid; - unsigned long __unused; - unsigned long f_namemax; - unsigned long f_frsize; - fsfilcnt_t f_favail; - unsigned long f_flag; - unsigned long __reserved[2]; +struct statfs { + unsigned long f_type, f_bsize; + fsblkcnt_t f_blocks, f_bfree, f_bavail; + fsfilcnt_t f_files, f_ffree; + fsid_t f_fsid; + unsigned long f_namelen, f_frsize, f_flags, f_spare[4]; }; diff --git a/arch/i386/bits/statfs.h b/arch/i386/bits/statfs.h index 9dda440..f103f4e 100644 --- a/arch/i386/bits/statfs.h +++ b/arch/i386/bits/statfs.h @@ -1,16 +1,7 @@ -struct statvfs { - unsigned long f_type; - unsigned long f_bsize; - fsblkcnt_t f_blocks; - fsblkcnt_t f_bfree; - fsblkcnt_t f_bavail; - fsfilcnt_t f_files; - fsfilcnt_t f_ffree; - unsigned long f_fsid; - unsigned long __unused; - unsigned long f_namemax; - unsigned long f_frsize; - fsfilcnt_t f_favail; - unsigned long f_flag; - unsigned long __reserved[2]; +struct statfs { + unsigned long f_type, f_bsize; + fsblkcnt_t f_blocks, f_bfree, f_bavail; + fsfilcnt_t f_files, f_ffree; + fsid_t f_fsid; + unsigned long f_namelen, f_frsize, f_flags, f_spare[4]; }; diff --git a/arch/x86_64/bits/statfs.h b/arch/x86_64/bits/statfs.h index 63de75b..f103f4e 100644 --- a/arch/x86_64/bits/statfs.h +++ b/arch/x86_64/bits/statfs.h @@ -1,15 +1,7 @@ -struct statvfs { - unsigned long f_type; - unsigned long f_bsize; - fsblkcnt_t f_blocks; - fsblkcnt_t f_bfree; - fsblkcnt_t f_bavail; - fsfilcnt_t f_files; - fsfilcnt_t f_ffree; - unsigned long f_fsid; - unsigned long f_namemax; - unsigned long f_frsize; - fsfilcnt_t f_favail; - unsigned long f_flag; - unsigned long __reserved[3]; +struct statfs { + unsigned long f_type, f_bsize; + fsblkcnt_t f_blocks, f_bfree, f_bavail; + fsfilcnt_t f_files, f_ffree; + fsid_t f_fsid; + unsigned long f_namelen, f_frsize, f_flags, f_spare[4]; }; diff --git a/include/sys/statfs.h b/include/sys/statfs.h index 7eaa7e7..51ef30a 100644 --- a/include/sys/statfs.h +++ b/include/sys/statfs.h @@ -3,8 +3,13 @@ #include <sys/statvfs.h> -#define statfs statvfs -#define fstatfs fstatvfs -#define f_namelen f_namemax +typedef struct { + int val[2]; +} fsid_t; + +#include <bits/statfs.h> + +int statfs (const char *, struct statfs *); +int fstatfs (int, struct statfs *); #endif diff --git a/include/sys/statvfs.h b/include/sys/statvfs.h index 6479be6..fd22fab 100644 --- a/include/sys/statvfs.h +++ b/include/sys/statvfs.h @@ -6,15 +6,28 @@ #define __NEED_fsfilcnt_t #include <bits/alltypes.h> -#include <bits/statfs.h> +#include <endian.h> + +struct statvfs { + unsigned long f_bsize, f_frsize; + fsblkcnt_t f_blocks, f_bfree, f_bavail; + fsfilcnt_t f_files, f_ffree, f_favail; +#if __BYTE_ORDER == __LITTLE_ENDIAN + unsigned long f_fsid; + unsigned :8*(2*sizeof(int)-sizeof(long)); +#else + unsigned :8*(2*sizeof(int)-sizeof(long)); + unsigned long f_fsid; +#endif + unsigned long f_flag, f_namemax; + int __reserved[6]; +}; int statvfs (const char *, struct statvfs *); int fstatvfs (int, struct statvfs *); #define ST_RDONLY 1 #define ST_NOSUID 2 - -#if 0 #define ST_NODEV 4 #define ST_NOEXEC 8 #define ST_SYNCHRONOUS 16 @@ -24,7 +37,6 @@ int fstatvfs (int, struct statvfs *); #define ST_IMMUTABLE 512 #define ST_NOATIME 1024 #define ST_NODIRATIME 2048 -#endif #endif diff --git a/src/stat/fstatvfs.c b/src/stat/fstatvfs.c deleted file mode 100644 index 806c3fd..0000000 --- a/src/stat/fstatvfs.c +++ /dev/null @@ -1,17 +0,0 @@ -#include <sys/statvfs.h> -#include "syscall.h" -#include "libc.h" - -int fstatvfs(int fd, struct statvfs *buf) -{ -#ifdef SYS_fstatfs64 - return syscall(SYS_fstatfs64, fd, sizeof *buf, buf); -#else - return syscall(SYS_fstatfs, fd, buf); -#endif -} - -weak_alias(fstatvfs, fstatfs); - -LFS64(fstatvfs); -LFS64(fstatfs); diff --git a/src/stat/statvfs.c b/src/stat/statvfs.c index e72c225..11ad754 100644 --- a/src/stat/statvfs.c +++ b/src/stat/statvfs.c @@ -1,8 +1,9 @@ #include <sys/statvfs.h> +#include <sys/statfs.h> #include "syscall.h" #include "libc.h" -int statvfs(const char *path, struct statvfs *buf) +int __statfs(const char *path, struct statfs *buf) { #ifdef SYS_statfs64 return syscall(SYS_statfs64, path, sizeof *buf, buf); @@ -11,7 +12,50 @@ int statvfs(const char *path, struct statvfs *buf) #endif } -weak_alias(statvfs, statfs); +int __fstatfs(int fd, struct statfs *buf) +{ +#ifdef SYS_fstatfs64 + return syscall(SYS_fstatfs64, fd, sizeof *buf, buf); +#else + return syscall(SYS_fstatfs, fd, buf); +#endif +} + +weak_alias(__statfs, statfs); +weak_alias(__fstatfs, fstatfs); + +static void fixup(struct statvfs *out, const struct statfs *in) +{ + out->f_bsize = in->f_bsize; + out->f_frsize = in->f_bsize; + out->f_blocks = in->f_blocks; + out->f_bfree = in->f_bfree; + out->f_bavail = in->f_bavail; + out->f_files = in->f_files; + out->f_ffree = in->f_ffree; + out->f_favail = 0; + out->f_fsid = in->f_fsid.val[0]; + out->f_flag = in->f_flags; + out->f_namemax = in->f_namelen; +} + +int statvfs(const char *path, struct statvfs *buf) +{ + struct statfs kbuf; + if (__statfs(path, &kbuf)<0) return -1; + fixup(buf, &kbuf); + return 0; +} + +int fstatvfs(int fd, struct statvfs *buf) +{ + struct statfs kbuf; + if (__fstatfs(fd, &kbuf)<0) return -1; + fixup(buf, &kbuf); + return 0; +} LFS64(statvfs); LFS64(statfs); +LFS64(fstatvfs); +LFS64(fstatfs); |