X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fstat%2Fstatvfs.c;h=bfbb5feed5255f0f03a36e7348ad787fd89f6120;hb=246f1c811448f37a44b41cd8df8d0ef9736d95f4;hp=637bf82f64653fecee935c8d0df03ce5c76b217c;hpb=400c5e5c8307a2ebe44ef1f203f5a15669f20347;p=musl diff --git a/src/stat/statvfs.c b/src/stat/statvfs.c index 637bf82f..bfbb5fee 100644 --- a/src/stat/statvfs.c +++ b/src/stat/statvfs.c @@ -1,10 +1,10 @@ #include #include #include "syscall.h" -#include "libc.h" -int __statfs(const char *path, struct statfs *buf) +static int __statfs(const char *path, struct statfs *buf) { + *buf = (struct statfs){0}; #ifdef SYS_statfs64 return syscall(SYS_statfs64, path, sizeof *buf, buf); #else @@ -12,8 +12,9 @@ int __statfs(const char *path, struct statfs *buf) #endif } -int __fstatfs(int fd, struct statfs *buf) +static int __fstatfs(int fd, struct statfs *buf) { + *buf = (struct statfs){0}; #ifdef SYS_fstatfs64 return syscall(SYS_fstatfs64, fd, sizeof *buf, buf); #else @@ -26,14 +27,15 @@ weak_alias(__fstatfs, fstatfs); static void fixup(struct statvfs *out, const struct statfs *in) { + *out = (struct statvfs){0}; out->f_bsize = in->f_bsize; - out->f_frsize = in->f_bsize; + out->f_frsize = in->f_frsize ? in->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_favail = in->f_ffree; out->f_fsid = in->f_fsid.__val[0]; out->f_flag = in->f_flags; out->f_namemax = in->f_namelen; @@ -54,8 +56,3 @@ int fstatvfs(int fd, struct statvfs *buf) fixup(buf, &kbuf); return 0; } - -LFS64(statvfs); -LFS64(statfs); -LFS64(fstatvfs); -LFS64(fstatfs);