FSTATVFS(3POSIX)

πŸ’– FSTATVFS(3POSIX) πŸ’–

okay so bestie, this one lives in the POSIX Programmer's Manual (yes, the whole POSIX Programmer's Manual, we're fancy like that) ✨


🫢 PROLOG 🫢

real talk before we even start: this manual page is part of the POSIX Programmer's Manual. the Linux implementation of this interface may differ (so like, go check the corresponding Linux manual page for the deets on Linux behavior, bestie), or the interface may not be implemented on Linux at all. no cap. πŸ’€


✨ 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 πŸ‘‘

okay so here's the tea. the fstatvfs() function shall obtain information about the file system containing the file referenced by fildes. πŸ¦‹

the statvfs() function shall obtain information about the file system containing the file named by path. πŸ’…

for both functions, the buf argument is a pointer to a statvfs structure that shall be filled. and listen β€” read, write, or execute permission of the named file is not required. we love a low-effort icon. πŸ”₯

the following flags can be returned in the f_flag member:

  • ST_RDONLY β€” read-only file system. it's giving "look but don't touch" πŸ™ˆ
  • ST_NOSUID β€” setuid/setgid bits ignored by exec. the bits are literally being ghosted πŸ’€
it is unspecified whether all members of the statvfs structure have meaningful values on all file systems. so like... some of them might just be vibes. don't come for me. 😭

⭐ RETURN VALUE ⭐

upon successful completion, statvfs() shall return 0. otherwise, it shall return -1 and set errno to indicate the error. periodt. πŸ’œ


πŸ’… ERRORS πŸ’…

the fstatvfs() and statvfs() functions shall fail if:

  • EIO β€” an I/O error occurred while reading the file system. the file system said "not today" 😭
  • EINTR β€” a signal was caught during execution of the function. rude of it, honestly πŸ“
  • EOVERFLOW β€” one of the values to be returned cannot be represented correctly in the structure pointed to by buf. it's too much for the struct, the struct is overwhelmed, relatable 🌸

the fstatvfs() function shall fail if:

  • EBADF β€” the fildes argument is not an open file descriptor. bestie that fd is not fding 🧚

the statvfs() function shall fail if:

  • EACCES β€” search permission is denied on a component of the path prefix. no entry for you 🚫
  • ELOOP β€” a loop exists in symbolic links encountered during resolution of the path argument. the symlinks are going in circles fr fr πŸ”„
  • ENAMETOOLONG β€” the length of a component of a pathname is longer than {NAME_MAX}. it's giving main character name that's too long for the credits 😭
  • ENOENT β€” a component of path does not name an existing file or path is an empty string. nothing there. ghost town. πŸ’€
  • ENOTDIR β€” a component of the path prefix names an existing file that is neither a directory nor a symbolic link to a directory, or the path argument 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. (yes that's the whole sentence, i'm not cutting it, every word is load-bearing πŸ’…)

the statvfs() function may fail if:

  • ELOOP β€” more than {SYMLOOP_MAX} symbolic links were encountered during resolution of the path argument. like okay we get it, you're linking πŸŒ€
  • 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}. too long. iconic behavior honestly but no βœ‹

the following sections are informative. (aka: the lore, not the law πŸ‘‘)


🌸 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. empty. the silence is the message. 🫢


⭐ RATIONALE ⭐

None. no thoughts, head empty, standard says nothing, we move πŸ’…


🌈 FUTURE DIRECTIONS 🌈

None. the future is unspecified and honestly? slay. ✨


πŸ”₯ 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> πŸ“š


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 . πŸ›


okay that's the whole page bestie, and the sign-off is literally IEEE/The Open Group, 2017 β€” that's the source and the date, we're giving them their flowers πŸ’, and the page itself is FSTATVFS(3POSIX) if you ever need to summon it again. go forth and statvfs() responsibly, mwah πŸ’‹πŸ¦‹βœ¨