explain_statvfs_or_die(3)

πŸ“¦
version 1.4.D001 Β· 2 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble, ubuntu resolute

✨ explain_statvfs_or_die(3) β€” Library Functions Manual ✨

okay bestie, gather round πŸ’– this one is a <pink>library functions manual</pink> situation, so it lives in the same world as your other libexplain pages. let's get into it.


🌸 NAME 🌸

explain_statvfs_or_die β€” get file system statistics and report errors πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

#include <libexplain/statvfs.h>
void explain_statvfs_or_die(const char *pathname, struct statvfs *data);
int explain_statvfs_on_error(const char *pathname, struct statvfs *data);

like, look at those signatures. they ate. no notes. πŸ‘‘


πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea β˜• β€” the explain_statvfs_or_die function is the one that calls the statvfs(2) system call. and if things go sideways? an explanation gets printed to stderr, pulled straight from the explain_statvfs(3) function, and then the process just terminates by calling exit(EXIT_FAILURE). like, it's done. it said what it said. πŸ’€

the explain_statvfs_on_error function also calls the statvfs(2) system call. and yeah, on failure it also prints an explanation to stderr from explain_statvfs(3) β€” but this one is the chill sibling 🫢 it still returns to the caller instead of noping out of existence.

  • pathname β€” the pathname, exactly as to be passed to the statvfs(2) system call. exactly. no remixing, no vibes-based editing. ✨
  • data β€” the data, exactly as to be passed to the statvfs(2) system call. same energy, same rules. 🌈

πŸ’œ RETURN VALUE πŸ’œ

the explain_statvfs_or_die function only returns on success β€” see statvfs(2) for more info if you wanna know more. on failure it prints an explanation and exits, so like… it does not return. it's giving "not coming back from this one". 😭

the explain_statvfs_on_error function always returns the value returned by the wrapped statvfs(2) system call. consistent queen. πŸ‘‘


πŸ“ EXAMPLE πŸ“

the explain_statvfs_or_die function is intended to be used in a fashion similar to the following example:

explain_statvfs_or_die(pathname, data);

that's it. that's the whole example. short, sweet, slays. πŸ’–


⭐ SEE ALSO ⭐

  • statvfs(2) β€” get file system statistics
  • explain_statvfs(3) β€” explain statvfs(2) errors
  • exit(2) β€” terminate the calling process

iykyk, these three are the friend group. 🌸


libexplain version 1.4 Copyright (C) 2010 Peter Miller


okay bestie that's the whole page, no cap. go forth and call statvfs(2) responsibly, and remember: if it fails, at least it fails with an explanation. main character error handling fr fr πŸ’…βœ¨

libexplain version 1.4 Β· Copyright (C) 2010 Peter Miller β€” mwah, that's the sign-off, hope this helped πŸŽ€πŸ¦‹πŸ’–

πŸ“¦ where this page comes from