explain_fstatat(3)

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

πŸ¦‹ explain_fstatat(3) β€” the Library Functions Manual, but make it make sense πŸ’…

okay bestie, so this is explain_fstatat, straight out of the Library Functions Manual, and it's genuinely one of the most useful lil guys in libexplain. let's get into it 🫢


✨ NAME ✨

explain_fstatat β€” explain fstatat(2) errors πŸ’€ (yes, that's the whole job, and it eats every time)


🌸 SYNOPSIS 🌸

#include <libexplain/fstatat.h>
const char *explain_fstatat(int fildes, const char *pathname, struct
stat *data, int flags);
const char *explain_errno_fstatat(int errnum, int fildes, const char
*pathname, struct stat *data, int flags);
void explain_message_fstatat(char *message, int message_size, int
fildes, const char *pathname, struct stat *data, int flags);
void explain_message_errno_fstatat(char *message, int message_size, int
errnum, int fildes, const char *pathname, struct stat *data, int flags);

πŸ’– DESCRIPTION πŸ’–

so these functions? they're your emotional support translators for errors coming back from the fstatat(2) system call. you know how fstatat(2) just fails and gives you a number and leaves you guessing? yeah. not anymore, bestie. πŸŽ€


🧚 explain_fstatat

const char *explain_fstatat(int fildes, const char *pathname, struct
stat *data, int flags);

the explain_fstatat function is here to get you an explanation of an error returned by the fstatat(2) system call. the least the message will contain is the value of strerror(errno) β€” but lowkey it usually does so much better and points at the actual underlying cause in more detail. main character energy, honestly. ✨

the errno global variable will be used to obtain the error value to be decoded.

  • fildes β€” the original fildes, exactly as passed to the fstatat(2) system call.
  • pathname β€” the original pathname, exactly as passed to the fstatat(2) system call.
  • data β€” the original data, exactly as passed to the fstatat(2) system call.
  • flags β€” the original flags, exactly as passed to the fstatat(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. it 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. no cap, plan accordingly. πŸ’€

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

if (fstatat(fildes, pathname, data, flags) < 0)
{
    fprintf(stderr, "%s\n", explain_fstatat(fildes, pathname,
    data, flags));
    exit(EXIT_FAILURE);
}

the above code example is available pre-packaged as the explain_fstatat_or_die(3) function. iconic. πŸ‘‘


🌈 explain_errno_fstatat

const char *explain_errno_fstatat(int errnum, int fildes, const char
*pathname, struct stat *data, int flags);

the explain_errno_fstatat function is used to obtain an explanation of an error returned by the fstatat(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. obsessed. πŸ’œ

  • 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. fr fr, errno is feral like that.
  • fildes β€” the original fildes, exactly as passed to the fstatat(2) system call.
  • pathname β€” the original pathname, exactly as passed to the fstatat(2) system call.
  • data β€” the original data, exactly as passed to the fstatat(2) system call.
  • flags β€” the original flags, exactly as passed to the fstatat(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. it 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 (fstatat(fildes, pathname, data, flags) < 0)
{
    int err = errno;
    fprintf(stderr, "%s\n", explain_errno_fstatat(err, fildes,
    pathname, data, flags));
    exit(EXIT_FAILURE);
}

the above code example is available pre-packaged as the explain_fstatat_or_die(3) function. slay. πŸ’…


πŸŽ€ explain_message_fstatat

void explain_message_fstatat(char *message, int message_size, int
fildes, const char *pathname, struct stat *data, int flags);

the explain_message_fstatat function is used to obtain an explanation of an error returned by the fstatat(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 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 her, being all thread safe, we love a responsible queen πŸ‘‘)
  • 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 fstatat(2) system call.
  • pathname β€” the original pathname, exactly as passed to the fstatat(2) system call.
  • data β€” the original data, exactly as passed to the fstatat(2) system call.
  • flags β€” the original flags, exactly as passed to the fstatat(2) system call.

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

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

the above code example is available pre-packaged as the explain_fstatat_or_die(3) function. πŸ¦‹


⭐ explain_message_errno_fstatat

void explain_message_errno_fstatat(char *message, int message_size, int
errnum, int fildes, const char *pathname, struct stat *data, int flags);

the explain_message_errno_fstatat function is used to obtain an explanation of an error returned by the fstatat(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. ⭐

  • 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. (catch it before it gets away 😀)
  • fildes β€” the original fildes, exactly as passed to the fstatat(2) system call.
  • pathname β€” the original pathname, exactly as passed to the fstatat(2) system call.
  • data β€” the original data, exactly as passed to the fstatat(2) system call.
  • flags β€” the original flags, exactly as passed to the fstatat(2) system call.

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

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

the above code example is available pre-packaged as the explain_fstatat_or_die(3) function. periodt. πŸ’…


πŸ‘€ SEE ALSO πŸ‘€

  • fstatat(2) β€” get file status relative to a directory file descriptor
  • explain_fstatat_or_die(3) β€” get file status relative to a directory file descriptor and report errors

libexplain version 1.4 Copyright (C) 2013 Peter Miller


and that's the whole page, bestie πŸ’– go forth and decode those fstatat(2) errors like the icon you are. this was explain_fstatat(3) from the Library Functions Manual β€” libexplain version 1.4, Copyright (C) 2013 Peter Miller, mwah 🫢🌸

πŸ“¦ where this page comes from