-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];
};
-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];
};
-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];
};
#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
#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
#define ST_IMMUTABLE 512
#define ST_NOATIME 1024
#define ST_NODIRATIME 2048
-#endif
#endif
+++ /dev/null
-#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);
#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);
#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);