mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-28 07:18:30 +00:00
Polyfill statfs() and fstatfs() on Windows
This commit is contained in:
parent
f7ee9d7d99
commit
c2211c9e63
16 changed files with 370 additions and 50 deletions
|
@ -17,10 +17,13 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/calls/strace.internal.h"
|
||||
#include "libc/calls/struct/statfs-meta.internal.h"
|
||||
#include "libc/calls/struct/statfs.internal.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/runtime/stack.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
|
||||
/**
|
||||
* Returns information about filesystem.
|
||||
|
@ -29,8 +32,14 @@ int fstatfs(int fd, struct statfs *sf) {
|
|||
int rc;
|
||||
union statfs_meta m;
|
||||
CheckLargeStackAllocation(&m, sizeof(m));
|
||||
if ((rc = sys_fstatfs(fd, &m)) != -1) {
|
||||
statfs2cosmo(sf, &m);
|
||||
if (!IsWindows()) {
|
||||
if ((rc = sys_fstatfs(fd, &m)) != -1) {
|
||||
statfs2cosmo(sf, &m);
|
||||
}
|
||||
} else if (__isfdopen(fd)) {
|
||||
rc = sys_fstatfs_nt(g_fds.p[fd].handle, sf);
|
||||
} else {
|
||||
rc = ebadf();
|
||||
}
|
||||
STRACE("fstatfs(%d, [%s]) → %d% m", fd, DescribeStatfs(rc, sf));
|
||||
return rc;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue