explain_chown(3)
π NAME π
explain_chown β ok so bestie, this is the girl who explains your chown(2) errors to you in full sentences instead of just yelling "no". It lives in the Library Functions Manual, page explain_chown(3). β¨
π SYNOPSIS π
#include <libexplain/chown.h>
const char *explain_chown(const char *pathname, int owner, int group);
const char *explain_errno_chown(int errnum, const char *pathname, int owner, int group);
void explain_message_chown(char *message, int message_size, const char *pathname, int owner, int group);
void explain_message_errno_chown(char *message, int message_size, int errnum, const char *pathname, int owner, int group);
πΈ DESCRIPTION πΈ
These functions are literally your emotional support translators for errors that come back from the chown(2) system call. π«Ά You hand them what you handed the kernel, they hand you back a whole explanation.
π¦ explain_chown π¦
const char *explain_chown(const char *pathname, int owner, int group);
explain_chown is the one you call to get an explanation of an error returned by the chown(2) system call. The least you're gonna get in that message is the value of strerror(errno), but bestie, usually it does so much better and actually tells you the underlying cause in way more detail. π
The errno global variable is what gets used to grab the error value that needs decoding.
This function is meant to be used in a vibe like the following example:
if (chown(pathname, owner, group) < 0)
{
fprintf(stderr, "%s\n", explain_chown(pathname, owner, group));
exit(EXIT_FAILURE);
}
pathnameβ The original pathname, exactly as passed to thechown(2)system call. No edits, no glow-up.ownerβ The original owner, exactly as passed to thechown(2)system call.groupβ The original group, exactly as passed to thechown(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 sharing that buffer, including calls from 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 do too. Fr fr, don't fight it.
π§ explain_errno_chown π§
const char *explain_errno_chown(int errnum, const char *pathname, int owner, int group);
explain_errno_chown is the version where you bring the errno, because you know the drill. It gives you an explanation of an error returned by the chown(2) system call. The least the message will contain is the value of strerror(errnum), but usually it does way better and points at the underlying cause in more detail. β¨
This function is intended to be used in a fashion similar to the following example:
if (chown(pathname, owner, group) < 0)
{
int err = errno;
fprintf(stderr, "%s\n", explain_errno_chown(err, pathname, owner,
group));
exit(EXIT_FAILURE);
}
errnumβ The error value to be decoded, usually grabbed from theerrnoglobal variable right before this function is called. This is necessary if you need to run any code between the system call being explained and this function, because many libc functions will alter the value oferrno. She's fickle like that. πpathnameβ The original pathname, exactly as passed to thechown(2)system call.ownerβ The original owner, exactly as passed to thechown(2)system call.groupβ The original group, exactly as passed to thechown(2)system call.
Returns: The message explaining the error. Same tea as before: this message buffer is shared by all libexplain functions which do not supply a buffer in their argument list, and 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.
π explain_message_chown π
void explain_message_chown(char *message, int message_size, const char *pathname, int owner, int group);
explain_message_chown may be used to obtain an explanation of an error returned by the chown(2) system call. The least the message will contain is the value of strerror(errno), but usually it does much better and indicates the underlying cause in more detail. π
The errno global variable will be used to obtain the error value to be decoded.
This function is intended to be used in a fashion similar to the following example:
if (chown(pathname, owner, group) < 0)
{
char message[3000];
explain_message_chown(message, sizeof(message), pathname, owner, group);
fprintf(stderr, "%s\n", message);
exit(EXIT_FAILURE);
}
messageβ The location in which to store the returned message. If a suitable message return buffer is supplied, this function is thread safe. Slay. πmessage_sizeβ The size in bytes of the location in which to store the returned message.pathnameβ The original pathname, exactly as passed to thechown(2)system call.ownerβ The original owner, exactly as passed to thechown(2)system call.groupβ The original group, exactly as passed to thechown(2)system call.
π explain_message_errno_chown π
void explain_message_errno_chown(char *message, int message_size, int errnum, const char *pathname, int owner, int group);
explain_message_errno_chown may be used to obtain an explanation of an error returned by the chown(2) system call. The least the message will contain is the value of strerror(errnum), but usually it does much better and indicates the underlying cause in more detail. π¦
This function is intended to be used in a fashion similar to the following example:
if (chown(pathname, owner, group) < 0)
{
int err = errno;
char message[3000];
explain_message_errno_chown(message, sizeof(message), err,
pathname, owner, group);
fprintf(stderr, "%s\n", message);
exit(EXIT_FAILURE);
}
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. πpathnameβ The original pathname, exactly as passed to thechown(2)system call.ownerβ The original owner, exactly as passed to thechown(2)system call.groupβ The original group, exactly as passed to thechown(2)system call.
π SEE ALSO π
chown(2)β change ownership of a fileexplain_chown_or_die(3)β change ownership of a file and report errors
π COPYRIGHT π
libexplain version 1.4 Copyright (C) 2008 Peter Miller
ok that's the whole page bestie, go forth and decode your chown(2) errors with main character energy. πβ¨ this was explain_chown(3) from the Library Functions Manual, brought to you by libexplain version 1.4, Copyright (C) 2008 Peter Miller β mwah, no cap. ππ¦π
π¦ 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) 2008, 2009, 2011 Peter Miller
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms