GETFSSTAT(2)
β¨ GETFSSTAT(2) β¨
okay bestie, so this is getfsstat from section 2 of the System Calls Manual, and honestly? she's a whole vibe. let's get into it π
π NAME π
getfsstat β get list of all mounted file systems
like, all of them. every single one. no gatekeeping π
π LIBRARY π
Standard C Library (libc, -lc)
she lives in libc, iconic behavior, that's where all the cool kids hang out β¨
π¦ SYNOPSIS π¦
#include <sys/param.h>
#include <sys/ucred.h>
#include <sys/mount.h>
int
getfsstat(struct statfs *buf, long bufsize, int mode);
yes you need all three includes, don't @ me, just copy them fr fr π«Ά
πΈ DESCRIPTION πΈ
so the getfsstat() system call returns information about all mounted file systems. all of them!! the buf argument is a pointer to statfs structures, exactly as described in statfs(2) β go read that one too, she's the sister page π
now here's the tea π΅ β fields that are undefined for a particular file system get set to -1. very "we don't know her" of them. the buffer gets filled with an array of statfs structures, one for each mounted file system, up to the byte count specified by bufsize.
β οΈ lowkey important: thebufsizeargument is the number of bytes thatbufcan hold β NOT the count ofstatfsstructures it will hold. like, bytes. not structs. do not confuse them, bestie, that's how you get bugs π
if buf is given as NULL, getfsstat() returns just the number of mounted file systems. cute lil headcount. no data, just vibes π§
normally mode should be specified as MNT_WAIT. that's the main character setting π
if mode is set to MNT_NOWAIT, getfsstat() will return the information it has available without requesting an update from each file system. so yeah β some of the information will be out of date π, but getfsstat() will not block waiting for information from a file system that is unable to respond. it's giving "not gonna wait around for you" energy.
it will also skip any file system that is in the process of being unmounted, even if the unmount would eventually fail. she's skipping that whole situation π
β¨ RETURN VALUES β¨
upon successful completion, the number of statfs structures is returned. slay π
otherwise, -1 is returned and the global variable errno is set to indicate the error. not slay, but informative π
π ERRORS π
the getfsstat() system call fails if one or more of the following are true:
[EFAULT]β thebufargument points to an invalid address. bad pointer, bad vibes π«[EINVAL]βmodeis set to a value other thanMNT_WAITorMNT_NOWAIT. you had two options, bestie π[EIO]β an I/O error occurred while reading from or writing to the file system.[EINTEGRITY]β corrupted data was detected while reading from the file system. π«
π₯ SEE ALSO π₯
iykyk, go read all three π
π HISTORY π
the getfsstat() system call first appeared in 4.4BSD. vintage. ancestral. we stan a legacy icon π
okay that's the whole page bestie, you're so ready for your vibe check now π¦πβ¨
this lil era of the manual was brought to you by Debian, dated March 30, 2020 β mwah, xoxo ππ
π¦ where this page comes from
- freebsd 15.1: base 15.1
- Copyright (c) 1989, 1991, 1993 The Regents of the University of California. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms