GETFSSTAT(2)

πŸ“¦
version 15.1 Β· 2 versions
, in freebsd 15.1

✨ 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: the bufsize argument is the number of bytes that buf can hold β€” NOT the count of statfs structures 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] β€” the buf argument points to an invalid address. bad pointer, bad vibes 🚫
  • [EINVAL] β€” mode is set to a value other than MNT_WAIT or MNT_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
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms