explain_fstatat(3)
π¦ 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 originalfildes, exactly as passed to thefstatat(2)system call.pathnameβ the originalpathname, exactly as passed to thefstatat(2)system call.dataβ the originaldata, exactly as passed to thefstatat(2)system call.flagsβ the originalflags, exactly as passed to thefstatat(2)system call.- Returns: the message explaining the error. this message buffer is shared by all
libexplainfunctions which do not supply a buffer in their argument list. it will be overwritten by the next call to anylibexplainfunction 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 theerrnoglobal 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 oferrno. fr fr,errnois feral like that.fildesβ the originalfildes, exactly as passed to thefstatat(2)system call.pathnameβ the originalpathname, exactly as passed to thefstatat(2)system call.dataβ the originaldata, exactly as passed to thefstatat(2)system call.flagsβ the originalflags, exactly as passed to thefstatat(2)system call.- Returns: the message explaining the error. this message buffer is shared by all
libexplainfunctions which do not supply a buffer in their argument list. it will be overwritten by the next call to anylibexplainfunction 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 originalfildes, exactly as passed to thefstatat(2)system call.pathnameβ the originalpathname, exactly as passed to thefstatat(2)system call.dataβ the originaldata, exactly as passed to thefstatat(2)system call.flagsβ the originalflags, exactly as passed to thefstatat(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 theerrnoglobal 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 oferrno. (catch it before it gets away π€)fildesβ the originalfildes, exactly as passed to thefstatat(2)system call.pathnameβ the originalpathname, exactly as passed to thefstatat(2)system call.dataβ the originaldata, exactly as passed to thefstatat(2)system call.flagsβ the originalflags, exactly as passed to thefstatat(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 descriptorexplain_fstatat_or_die(3)β get file status relative to a directory file descriptor and report errors
π COPYRIGHT π
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
- debian bookworm: libexplain-dev 1.4.D001-12+b1 Β· LGPL-3.0-or-later
- debian trixie: libexplain-dev 1.4.D001-16 Β· LGPL-3.0-or-later
- ubuntu jammy: libexplain-dev 1.4.D001-12 Β· LGPL-3.0-or-later
- ubuntu noble: libexplain-dev 1.4.D001-13 Β· LGPL-3.0-or-later
- ubuntu resolute: libexplain-dev 1.4.D001-16 Β· LGPL-3.0-or-later
- Copyright (C) 2013 Peter Miller
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms