FSTATVFS(3P)
FSTATVFS(3P) π
okay bestie, welcome to the POSIX Programmer's Manual β¨ this one's the fstatvfs / statvfs page and it's literally just "hey, tell me about this filesystem" energy. iconic. let's go π«Ά
πΈ PROLOG πΈ
Real talk before we start: this manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ β so if you're on Linux, go check the corresponding Linux manual page for the actual tea. Or, plot twist, the interface may not be implemented on Linux at all. π Not me finding that out the hard way.
β¨ NAME β¨
fstatvfs, statvfs β get file system information π
π SYNOPSIS π
#include <sys/statvfs.h>
int fstatvfs(int fildes, struct statvfs *buf);
int statvfs(const char *restrict path, struct statvfs *restrict buf);
π DESCRIPTION π
So fstatvfs() shall obtain information about the file system containing the file referenced by fildes. That's it. That's the whole vibe. π¦
And statvfs() shall obtain information about the file system containing the file named by path. same energy, different entry point.
For both functions, the buf argument is a pointer to a statvfs structure that shall be filled. And here's the slay: read, write, or execute permission of the named file is not required. π
no gatekeeping, we love to see it.
The following flags can be returned in the f_flag member:
ST_RDONLYβ read-only file system. can't write, don't even try bestie πST_NOSUIDβ setuid/setgid bits ignored by exec. those bits are getting ghosted π»
heads up: it is unspecified whether all members of the statvfs structure have meaningful values on all file systems. so like... some of the struct is giving main character energy and some of it is just standing there. we don't know which. π€·
π₯ RETURN VALUE π₯
Upon successful completion, statvfs() shall return 0. π
Otherwise, it shall return -1 and set errno to indicate the error. π classic.
π ERRORS π
The fstatvfs() and statvfs() functions shall fail if:
EIOβ an I/O error occurred while reading the file system. the disk said no πEINTRβ a signal was caught during execution of the function. rudely interrupted, honestly.EOVERFLOWβ one of the values to be returned cannot be represented correctly in the structure pointed to bybuf. it's too big for the box bestie, the number does not fit π«
The fstatvfs() function shall fail if:
EBADFβ thefildesargument is not an open file descriptor. that fd is fake, no cap π
The statvfs() function shall fail if:
EACCESβ search permission is denied on a component of the path prefix. denied. blocked. not today.ELOOPβ a loop exists in symbolic links encountered during resolution of thepathargument. the symlinks are going in circles and it's giving chaos πͺοΈENAMETOOLONGβ the length of a component of a pathname is longer than{NAME_MAX}. too long, too much, take a breath πENOENTβ a component ofpathdoes not name an existing file orpathis an empty string. it's not there. it never was. π«₯ENOTDIRβ a component of the path prefix names an existing file that is neither a directory nor a symbolic link to a directory, or thepathargument contains at least one non-<slash>character and ends with one or more trailing<slash>characters and the last pathname component names an existing file that is neither a directory nor a symbolic link to a directory. yeah. that whole situation. not a directory, stop asking it to be one π
The statvfs() function may fail if:
ELOOPβ more than{SYMLOOP_MAX}symbolic links were encountered during resolution of thepathargument. that's a LOT of links bestie, the chain has gone too far βοΈENAMETOOLONGβ the length of a pathname exceeds{PATH_MAX}, or pathname resolution of a symbolic link produced an intermediate result with a length that exceeds{PATH_MAX}. overflowing the path budget fr fr π
btw: the following sections are informative. they're the bonus content, not the rules. π
π EXAMPLES π
π¦ Obtaining File System Information Using fstatvfs()
The following example shows how to obtain file system information for the file system upon which the file named /home/cnd/mod1 resides, using the fstatvfs() function. The /home/cnd/mod1 file is opened with read/write privileges and the open file descriptor is passed to the fstatvfs() function.
#include <sys/statvfs.h>
#include <fcntl.h>
struct statvfs buffer;
int status;
...
fildes = open("/home/cnd/mod1", O_RDWR);
status = fstatvfs(fildes, &buffer);
β Obtaining File System Information Using statvfs()
The following example shows how to obtain file system information for the file system upon which the file named /home/cnd/mod1 resides, using the statvfs() function.
#include <sys/statvfs.h>
struct statvfs buffer;
int status;
...
status = statvfs("/home/cnd/mod1", &buffer);
π APPLICATION USAGE π
None. nothing to add, she said nothing and meant it π
π§ RATIONALE π§
None. no reasoning, just vibes β¨
π FUTURE DIRECTIONS π
None. the future is... also none. periodt.
π SEE ALSO π
chmod(), chown(), creat(), dup(), exec, fcntl(), link(), mknod(), open(), pipe(), read(), time(), unlink(), utime(), write()
The Base Definitions volume of POSIX.1β2017, <sys_statvfs.h> π
πΈ COPYRIGHT πΈ
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .
Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .
and that's the whole page bestie!! π«Ά signed, sealed, delivered by IEEE/The Open Group, dated 2017, filed under FSTATVFS(3P) β go get that filesystem info, you absolute icon π β¨
π¦ where this page comes from
- alpine 3.22: man-pages-posix 2017a-r0 Β· custom
- alpine 3.23: man-pages-posix 2017a-r0 Β· custom
- alpine 3.24: man-pages-posix 2017a-r0 Β· custom
- arch rolling: man-pages 6.19-1
- arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages-posix 2017a
- opensuse-leap 16.0: man-pages-posix 2017a-160000.4.1 Β· SUSE-IEEE
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms