explain_fchmod(3)
π explain_fchmod(3) π
okay bestie, so this is a page from the Library Functions Manual β like, the actual libexplain manual, and today's main character is explain_fchmod. It's literally the whole reason you're here. Let's get into it π«Ά
β¨ NAME β¨
explain_fchmod β explain fchmod(2) errors
(yeah that's it, that's the whole name. short, sweet, iconic.)
πΈ SYNOPSIS πΈ
#include <libexplain/fchmod.h>
const char *explain_fchmod(int fildes, mode_t mode);
const char *explain_errno_fchmod(int errnum, int fildes, mode_t mode);
void explain_message_fchmod(char *message, int message_size, int fildes,
mode_t mode);
void explain_message_errno_fchmod(char *message, int message_size, int
errnum, int fildes, mode_t mode);
π¦ DESCRIPTION π¦
These functions may be used to obtain explanations for errors returned by the fchmod(2) system call. Basically: your syscall flopped, and now you wanna know why, in human words, instead of squinting at an errno like it owes you money. π
π explain_fchmod
const char *explain_fchmod(int fildes, mode_t mode);
The explain_fchmod function is used to obtain an explanation of an error returned by the fchmod(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. So like β bare minimum is the basics, but most of the time it's giving β¨full contextβ¨.
The errno global variable will be used to obtain the error value to be decoded.
fildesβ The original fildes, exactly as passed to thefchmod(2)system call.modeβ The original mode, exactly as passed to thefchmod(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. (so like, don't hold onto it, bestie, it's not yours to keep π)
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. β οΈ
Example: This function is intended to be used in a fashion similar to the following example:
if (fchmod(fildes, mode) < 0)
{
fprintf(stderr, "%s\n", explain_fchmod(fildes, mode));
exit(EXIT_FAILURE);
}
The above code example is available pre-packaged as the explain_fchmod_or_die(3) function. (convenient? obsessed.)
π explain_errno_fchmod
const char *explain_errno_fchmod(int errnum, int fildes, mode_t mode);
The explain_errno_fchmod function is used to obtain an explanation of an error returned by the fchmod(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. (translation: graberrnoFIRST, because other libc calls will absolutely snatch it out from under you π)fildesβ The original fildes, exactly as passed to thefchmod(2)system call.modeβ The original mode, exactly as passed to thefchmod(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 (fchmod(fildes, mode) < 0)
{
int err = errno;
fprintf(stderr, "%s\n", explain_errno_fchmod(err, fildes,
mode));
exit(EXIT_FAILURE);
}
The above code example is available pre-packaged as the explain_fchmod_or_die(3) function.
π explain_message_fchmod
void explain_message_fchmod(char *message, int message_size, int fildes,
mode_t mode);
The explain_message_fchmod function is used to obtain an explanation of an error returned by the fchmod(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. (oh look, thread safety! she's doing great π)message_sizeβ The size in bytes of the location in which to store the returned message.fildesβ The original fildes, exactly as passed to thefchmod(2)system call.modeβ The original mode, exactly as passed to thefchmod(2)system call.
Example: This function is intended to be used in a fashion similar to the following example:
if (fchmod(fildes, mode) < 0)
{
char message[3000];
explain_message_fchmod(message, sizeof(message), fildes,
mode);
fprintf(stderr, "%s\n", message);
exit(EXIT_FAILURE);
}
The above code example is available pre-packaged as the explain_fchmod_or_die(3) function.
π explain_message_errno_fchmod
void explain_message_errno_fchmod(char *message, int message_size, int
errnum, int fildes, mode_t mode);
The explain_message_errno_fchmod function is used to obtain an explanation of an error returned by the fchmod(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.fildesβ The original fildes, exactly as passed to thefchmod(2)system call.modeβ The original mode, exactly as passed to thefchmod(2)system call.
Example: This function is intended to be used in a fashion similar to the following example:
if (fchmod(fildes, mode) < 0)
{
int err = errno;
char message[3000];
explain_message_errno_fchmod(message, sizeof(message), err,
fildes, mode);
fprintf(stderr, "%s\n", message);
exit(EXIT_FAILURE);
}
The above code example is available pre-packaged as the explain_fchmod_or_die(3) function.
π SEE ALSO π
fchmod(2)β change permissions of an open fileexplain_fchmod_or_die(3)β change permissions of an open file and report errors
π COPYRIGHT π
libexplain version 1.4 Copyright (C) 2013 Peter Miller
and that's the whole page, bestie!! π go forth and debug your fchmod(2) errors with main character energy. this little libexplain situation is version 1.4, copyright (C) 2013 Peter Miller β and it was a page from the Library Functions Manual, if you didn't catch that at the top. 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