#ifndef VLIBC_SYS_STATVFS_H #define VLIBC_SYS_STATVFS_H /* * vlibc — . * * Filesystem statistics in an ABI-independent POSIX shape: block and file * counts as unsigned counts over a reported block size, plus the read-only * and setuid-disabling mount flags and the longest file name. This header * carries only the portable view; the Linux kernel's private * layout (signed longs, an int-pair f_fsid, a f_spare tail) never leaks * into it. * * Level 2 (muslmimic): the whole header (statvfs and fstatvfs are XSI * [CX] in POSIX.1-2008, not base; the base filesystem * queries are stat()/fstat() in ). * * f_flag holds ST_RDONLY and/or ST_NOSUID, and f_fsid is a best-effort * filesystem identifier (the kernel does not populate it for every * filesystem). The block counts are measured in f_frsize units (which is * f_bsize when the filesystem does not distinguish a transfer size). * * None of these declarations carries an intent attribute: both functions * perform I/O with side effects and report failures through errno, so * const/pure would be unsound. */ #include #include /* fsblkcnt_t, fsfilcnt_t */ #ifdef __cplusplus extern "C" { #endif #if VLIBC_LEVEL_GE(2) /* Level 2 (muslmimic): XSI. */ /* * Filesystem statistics. f_flag is a bitwise OR of ST_RDONLY and * ST_NOSUID; f_frsize is the fundamental block size the count fields are * expressed in. f_fsid is 0 when the filesystem provides no identifier. */ struct statvfs { unsigned long f_bsize; /* preferred I/O block size, bytes */ unsigned long f_frsize; /* fundamental block size, bytes */ fsblkcnt_t f_blocks; /* total blocks, in f_frsize units */ fsblkcnt_t f_bfree; /* free blocks */ fsblkcnt_t f_bavail; /* free blocks available to an unprivileged process */ fsfilcnt_t f_files; /* total file serial numbers (inodes) */ fsfilcnt_t f_ffree; /* free file serial numbers */ fsfilcnt_t f_favail; /* free serial numbers available to an unprivileged process */ unsigned long f_fsid; /* filesystem ID (best effort) */ unsigned long f_flag; /* mount flags: ST_RDONLY | ST_NOSUID */ unsigned long f_namemax; /* maximum file name length */ }; /* f_flag values (also the kernel's f_flags bits on Linux). */ #define ST_RDONLY 1 /* read-only filesystem */ #define ST_NOSUID 2 /* set-user-ID/set-group-ID bits ignored on exec */ /* * Store statistics for the filesystem holding path into buf; return 0, or * -1 with errno set. XSI. */ int statvfs(const char *restrict path, struct statvfs *restrict buf); /* * Like statvfs(), for the filesystem holding the open descriptor fildes; * return 0, or -1 with errno set. XSI. */ int fstatvfs(int fildes, struct statvfs *buf); #endif /* VLIBC_LEVEL_GE(2) */ #ifdef __cplusplus } #endif #endif /* VLIBC_SYS_STATVFS_H */