explain_fchownat(3)
π explain_fchownat(3) β Library Functions Manual
okay bestie, sit down, hydrate, because we're about to make sense of explain_fchownat from the libexplain crew. this is the page that explains how to get actually useful error messages out of the fchownat(2) syscall instead of just staring at a cryptic errno like it owes you money. π
β¨ NAME β¨
explain_fchownat β explain fchownat(2) errors
πΈ SYNOPSIS πΈ
#include <libexplain/fchownat.h>
const char *explain_fchownat(int dirfd, const char *pathname, int owner,
int group, int flags);
const char *explain_errno_fchownat(int errnum, int dirfd, const char
*pathname, int owner, int group, int flags);
void explain_message_fchownat(char *message, int message_size, int
dirfd, const char *pathname, int owner, int group, int flags);
void explain_message_errno_fchownat(char *message, int message_size, int
errnum, int dirfd, const char *pathname, int owner, int group, int
flags);
π¦ DESCRIPTION π¦
these functions? they're the glow-up your error handling deserves. you use them to obtain explanations for errors returned by the fchownat(2) system call. like, the whole point is that instead of a sad little mystery number, you get words. real words. sentences. iconic. π
π explain_fchownat
const char *explain_fchownat(int dirfd, const char *pathname, int owner,
int group, int flags);
the explain_fchownat function is used to obtain an explanation of an error returned by the fchownat(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 bare minimum vs. the full tea. π΅
the errno global variable will be used to obtain the error value to be decoded.
dirfdβ the originaldirfd, exactly as passed to thefchownat(2)system call.pathnameβ the originalpathname, exactly as passed to thefchownat(2)system call.ownerβ the originalowner, exactly as passed to thefchownat(2)system call.groupβ the originalgroup, exactly as passed to thefchownat(2)system call.flagsβ the originalflags, exactly as passed to thefchownat(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. no cap, watch out for that one. π
Example: this function is intended to be used in a fashion similar to the following example:
if (fchownat(dirfd, pathname, owner, group, flags) < 0)
{
fprintf(stderr, "%s\n", explain_fchownat(dirfd, pathname,
owner, group, flags));
exit(EXIT_FAILURE);
}
the above code example is available pre-packaged as the explain_fchownat_or_die(3) function. π«Ά
π explain_errno_fchownat
const char *explain_errno_fchownat(int errnum, int dirfd, const char
*pathname, int owner, int group, int flags);
the explain_errno_fchownat function is used to obtain an explanation of an error returned by the fchownat(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.
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. (she's fragile, protect her π)dirfdβ the originaldirfd, exactly as passed to thefchownat(2)system call.pathnameβ the originalpathname, exactly as passed to thefchownat(2)system call.ownerβ the originalowner, exactly as passed to thefchownat(2)system call.groupβ the originalgroup, exactly as passed to thefchownat(2)system call.flagsβ the originalflags, exactly as passed to thefchownat(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 (fchownat(dirfd, pathname, owner, group, flags) < 0)
{
int err = errno;
fprintf(stderr, "%s\n", explain_errno_fchownat(err, dirfd,
pathname, owner, group, flags));
exit(EXIT_FAILURE);
}
the above code example is available pre-packaged as the explain_fchownat_or_die(3) function. β¨
π explain_message_fchownat
void explain_message_fchownat(char *message, int message_size, int
dirfd, const char *pathname, int owner, int group, int flags);
the explain_message_fchownat function is used to obtain an explanation of an error returned by the fchownat(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. (the glow-up!! π₯Ή)message_sizeβ the size in bytes of the location in which to store the returned message.dirfdβ the originaldirfd, exactly as passed to thefchownat(2)system call.pathnameβ the originalpathname, exactly as passed to thefchownat(2)system call.ownerβ the originalowner, exactly as passed to thefchownat(2)system call.groupβ the originalgroup, exactly as passed to thefchownat(2)system call.flagsβ the originalflags, exactly as passed to thefchownat(2)system call.
Example: this function is intended to be used in a fashion similar to the following example:
if (fchownat(dirfd, pathname, owner, group, flags) < 0)
{
char message[3000];
explain_message_fchownat(message, sizeof(message), dirfd,
pathname, owner, group, flags);
fprintf(stderr, "%s\n", message);
exit(EXIT_FAILURE);
}
the above code example is available pre-packaged as the explain_fchownat_or_die(3) function. πΈ
π explain_message_errno_fchownat
void explain_message_errno_fchownat(char *message, int message_size, int
errnum, int dirfd, const char *pathname, int owner, int group, int
flags);
the explain_message_errno_fchownat function is used to obtain an explanation of an error returned by the fchownat(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.dirfdβ the originaldirfd, exactly as passed to thefchownat(2)system call.pathnameβ the originalpathname, exactly as passed to thefchownat(2)system call.ownerβ the originalowner, exactly as passed to thefchownat(2)system call.groupβ the originalgroup, exactly as passed to thefchownat(2)system call.flagsβ the originalflags, exactly as passed to thefchownat(2)system call.
Example: this function is intended to be used in a fashion similar to the following example:
if (fchownat(dirfd, pathname, owner, group, flags) < 0)
{
int err = errno;
char message[3000];
explain_message_errno_fchownat(message, sizeof(message), err,
dirfd, pathname, owner, group, flags);
fprintf(stderr, "%s\n", message);
exit(EXIT_FAILURE);
}
the above code example is available pre-packaged as the explain_fchownat_or_die(3) function. π
β SEE ALSO β
fchownat(2)β change ownership of a file relative to a directoryexplain_fchownat_or_die(3)β change ownership of a file relative to a directory and report errors
π COPYRIGHT π
libexplain version 1.4
Copyright (C) 2013 Peter Miller
and that's the whole page bestie, you ate that πβ¨ go forth and explain_fchownat your way through every cursed errno you meet β mwah π
π¦ this was explain_fchownat(3) from the Library Functions Manual, libexplain version 1.4, Copyright (C) 2013 Peter Miller, and yes she's dated 2013 and still serving. periodt. π
π¦ 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