explain_fstatvfs(3)

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

explain_fstatvfs(3) πŸ’…

okay bestie, sit down, hydrate, because we're about to make fstatvfs(2) errors make sense. This is the explain_fstatvfs(3) page from the Library Functions Manual, and it's basically the translator your error messages have been begging for. ✨


🌸 NAME 🌸

explain_fstatvfs β€” no cap, this explains fstatvfs(2) errors for you. πŸ’–


✨ SYNOPSIS ✨

#include <libexplain/fstatvfs.h>
const char *explain_fstatvfs(int fildes, struct statvfs *data);
const char *explain_errno_fstatvfs(int errnum, int fildes, struct statvfs *data);
void explain_message_fstatvfs(char *message, int message_size, int fildes, struct statvfs *data);
void explain_message_errno_fstatvfs(char *message, int message_size, int errnum, int fildes, struct statvfs *data);

πŸ¦‹ DESCRIPTION πŸ¦‹

These functions are your little group chat with fstatvfs(2) β€” you ask, they tell you what went wrong. Specifically, you use them to get explanations for errors returned by the fstatvfs(2) system call. 🫢


πŸŽ€ explain_fstatvfs

const char *explain_fstatvfs(int fildes, struct statvfs *data);

The explain_fstatvfs function is how you get an explanation of an error returned by the fstatvfs(2) system call. The absolute least you're getting is the value of strerror(errno), but honestly? It usually does so much better and tells you the underlying cause in way more detail. iconic behaviour fr fr. πŸ’…

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 fstatvfs(2) system call. don't be cute with it, pass it as-is.
  • data β€” the original data, exactly as passed to the fstatvfs(2) system call.

Returns:

The message explaining the error. Heads up though: this message buffer is shared by all libexplain functions that don't supply a buffer in their argument list. So it gets overwritten by the next call to any libexplain function that shares this buffer β€” including calls from other threads. 😭

Note: this function is not thread safe, because it shares a return buffer across all threads, and so do many other functions in this library. lowkey a situationship with that buffer.

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

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

The above code example is available pre‐packaged as the explain_fstatvfs_or_die(3) function. 🎁


🧚 explain_errno_fstatvfs

const char *explain_errno_fstatvfs(int errnum, int fildes, struct statvfs *data);

The explain_errno_fstatvfs function is used to obtain an explanation of an error returned by the fstatvfs(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. she ate. πŸ”₯

  • errnum β€” the error value to be decoded, usually grabbed from the errno global variable just before this function is called. This matters if you need to run any code between the system call being explained and this function, because so many libc functions will alter the value of errno. catch it early or it's gone bestie.
  • fildes β€” the original fildes, exactly as passed to the fstatvfs(2) system call.
  • data β€” the original data, exactly as passed to the fstatvfs(2) system call.

Returns:

The message explaining the error. This message buffer is shared by all libexplain functions which do not supply a buffer in their argument list. This will be overwritten by the next call to any libexplain function which 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.

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

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

The above code example is available pre‐packaged as the explain_fstatvfs_or_die(3) function. πŸ’


πŸ“ explain_message_fstatvfs

void explain_message_fstatvfs(char *message, int message_size, int fildes, struct statvfs *data);

The explain_message_fstatvfs function is used to obtain an explanation of an error returned by the fstatvfs(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. periodt. ✨

The errno global variable will be 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 you, doing threading right. πŸ‘‘
  • 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 fstatvfs(2) system call.
  • data β€” the original data, exactly as passed to the fstatvfs(2) system call.

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

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

The above code example is available pre‐packaged as the explain_fstatvfs_or_die(3) function. 🌸


πŸ’œ explain_message_errno_fstatvfs

void explain_message_errno_fstatvfs(char *message, int message_size, int errnum, int fildes, struct statvfs *data);

The explain_message_errno_fstatvfs function is used to obtain an explanation of an error returned by the fstatvfs(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 way that this function understands you. πŸ˜­πŸ’–

  • 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 fstatvfs(2) system call.
  • data β€” the original data, exactly as passed to the fstatvfs(2) system call.

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

if (fstatvfs(fildes, data) < 0)
{
    int err = errno;
    char message[3000];
    explain_message_errno_fstatvfs(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_fstatvfs_or_die(3) function. 🫢


🌈 SEE ALSO 🌈

  • fstatvfs(2) β€” get file system statistics ✨
  • explain_fstatvfs_or_die(3) β€” get file system statistics and report errors πŸ’…

libexplain version 1.4 Copyright (C) 2010 Peter Miller


and that's the whole page bestie β€” explain_fstatvfs(3), brought to you by libexplain version 1.4, Copyright (C) 2010 Peter Miller. go forth and have the most well-explained fstatvfs(2) errors of your life. mwah. πŸ’‹

πŸ“¦ where this page comes from