explain_fstatfs(3)

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

πŸ’– explain_fstatfs β€” bestie edition πŸ’–

okay so this is explain_fstatfs(3), a libexplain page, and it lives in the Library Functions Manual. it's all about turning those cursed fstatfs(2) errors into actual human sentences. no more staring at a bare errno like πŸ‘οΈπŸ‘„πŸ‘οΈ


✨ NAME ✨

explain_fstatfs β€” bestie, let me explain your fstatfs(2) errors πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

#include <libexplain/fstatfs.h>
const char *explain_fstatfs(int fildes, struct statfs *data);
const char *explain_errno_fstatfs(int errnum, int fildes, struct statfs *data);
void explain_message_fstatfs(char *message, int message_size, int fildes, struct statfs *data);
void explain_message_errno_fstatfs(char *message, int message_size, int errnum, int fildes, struct statfs *data);

🌸 DESCRIPTION 🌸

so these functions are literally here to hand you explanations for errors that the fstatfs(2) system call throws back at you. it's giving translator, it's giving "what did the kernel MEAN by that". 🧚

explain_fstatfs

const char *explain_fstatfs(int fildes, struct statfs *data);

the explain_fstatfs function gets you an explanation of an error returned by the fstatfs(2) system call. the least the message will contain is the value of strerror(errno), but usually it goes way harder than that and tells you the underlying cause in more detail. like, it actually spills the tea. πŸ”₯

the errno global variable is what gets used to obtain the error value to be decoded.

  • fildes β€” the original fildes, exactly as passed to the fstatfs(2) system call. no notes, verbatim.
  • data β€” the original data, exactly as passed to the fstatfs(2) system call.

Returns:

  • the message explaining the error. this message buffer is shared by all libexplain functions that don't supply a buffer in their argument list. it will be overwritten by the next call to any libexplain function that shares this buffer, including other threads. so like... screenshot it or copy it, don't just vibe with the pointer. 😭
Note: this function is not thread safe, because it shares a return buffer across all threads, and many other functions in this library do too.

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

if (fstatfs(fildes, data) < 0)
{
    fprintf(stderr, "%s\n", explain_fstatfs(fildes, data));
    exit(EXIT_FAILURE);
}

the above code example is available pre‐packaged as the explain_fstatfs_or_die(3) function. convenient much? πŸ‘‘


explain_errno_fstatfs

const char *explain_errno_fstatfs(int errnum, int fildes, struct statfs *data);

the explain_errno_fstatfs function gets you an explanation of an error returned by the fstatfs(2) system call. same deal: the least the message will contain is the value of strerror(errno), but usually it does much better and points at the underlying cause in more detail. ✨

  • errnum β€” the error value to be decoded, usually obtained from the errno global variable just before this function is called. this one is necessary if you need to call any code between the system call to be explained and this function, because many libc functions will alter the value of errno. yes bestie, it's that fragile. πŸ™ˆ
  • fildes β€” the original fildes, exactly as passed to the fstatfs(2) system call.
  • data β€” the original data, exactly as passed to the fstatfs(2) system call.

Returns:

  • the message explaining the error. this message buffer is shared by all libexplain functions that don't supply a buffer in their argument list. it will be overwritten by the next call to any libexplain function that shares this buffer, including other threads.
Note: this function is not thread safe, because it shares a return buffer across all threads, and many other functions in this library do too.

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

if (fstatfs(fildes, data) < 0)
{
    int err = errno;
    fprintf(stderr, "%s\n", explain_errno_fstatfs(err, fildes, data));
    exit(EXIT_FAILURE);
}

the above code example is available pre‐packaged as the explain_fstatfs_or_die(3) function. 🌈


explain_message_fstatfs

void explain_message_fstatfs(char *message, int message_size, int fildes, struct statfs *data);

the explain_message_fstatfs function gets you an explanation of an error returned by the fstatfs(2) system call. the least the message will contain is the value of strerror(errno), but usually it will do much better and indicate the underlying cause in more detail. πŸ’«

the errno global variable is what gets used to obtain the error value to be decoded.

  • message β€” the location in which to store the returned message. if a suitable message return buffer is supplied, this function is thread safe. look at her, being all responsible. 🫢
  • message_size β€” the size in bytes of the location in which to store the returned message.
  • fildes β€” the original fildes, exactly as passed to the fstatfs(2) system call.
  • data β€” the original data, exactly as passed to the fstatfs(2) system call.

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

if (fstatfs(fildes, data) < 0)
{
    char message[3000];
    explain_message_fstatfs(message, sizeof(message), fildes, data);
    fprintf(stderr, "%s\n", message);
    exit(EXIT_FAILURE);
}

the above code example is available pre‐packaged as the explain_fstatfs_or_die(3) function. πŸŽ€


explain_message_errno_fstatfs

void explain_message_errno_fstatfs(char *message, int message_size, int errnum, int fildes, struct statfs *data);

the explain_message_errno_fstatfs function gets you an explanation of an error returned by the fstatfs(2) system call. the least the message will contain is the value of strerror(errno), but usually it will do much better and indicate the underlying cause in more detail. it ate, honestly. πŸ”₯

  • message β€” the location in which to store the returned message. if a suitable message return buffer is supplied, this function is thread safe.
  • message_size β€” the size in bytes of the location in which to store the returned message.
  • errnum β€” the error value to be decoded, usually obtained from the errno global variable just before this function is called. this is necessary if you need to call any code between the system call to be explained and this function, because many libc functions will alter the value of errno.
  • fildes β€” the original fildes, exactly as passed to the fstatfs(2) system call.
  • data β€” the original data, exactly as passed to the fstatfs(2) system call.

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

if (fstatfs(fildes, data) < 0)
{
    int err = errno;
    char message[3000];
    explain_message_errno_fstatfs(message, sizeof(message), err, fildes, data);
    fprintf(stderr, "%s\n", message);
    exit(EXIT_FAILURE);
}

the above code example is available pre‐packaged as the explain_fstatfs_or_die(3) function. πŸ’œ


πŸ¦‹ SEE ALSO πŸ¦‹


libexplain version 1.4

Copyright (C) 2009 Peter Miller


okay that's the whole page bestie, you're officially fluent in explain_fstatfs(3) now πŸ’…βœ¨

this little scroll of knowledge comes to you from libexplain version 1.4, copyright (C) 2009 Peter Miller β€” and yes that footer is giving main character energy, as it should πŸŽ€

πŸ“¦ where this page comes from