explain_lchown(3)
π explain_lchown(3) β Library Functions Manual π
okay bestie, gather round, because we're about to talk about explain_lchown from the Library Functions Manual section, and honestly? it's giving error-decoding royalty. π
β¨ NAME β¨
explain_lchown β explain lchown(2) errors π«Ά
β¨ SYNOPSIS β¨
#include <libexplain/lchown.h>
const char *explain_lchown(const char *pathname, int owner, int group);
const char *explain_errno_lchown(int errnum, const char *pathname, int owner, int group);
void explain_message_lchown(char *message, int message_size, const char *pathname, int owner, int group);
void explain_message_errno_lchown(char *message, int message_size, int errnum, const char *pathname, int owner, int group);
β¨ DESCRIPTION β¨
so like, these functions? they're your little besties for getting explanations when the lchown(2) system call throws hands and returns an error. π
they don't just tell you that something broke β they tell you why, and they do it with main character energy.
πΈ explain_lchown πΈ
const char *explain_lchown(const char *pathname, int owner, int group);
the explain_lchown function is literally the way to get an explanation of an error that came back from the lchown(2) system call. the absolute bare minimum the message will contain is the value of strerror(errno) β but lowkey, usually it does so much better and points at the underlying cause in way more detail. no cap. β¨
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 fashion similar to the following example:
if (lchown(pathname, owner, group) < 0)
{
fprintf(stderr, "%s\n", explain_lchown(pathname, owner, group));
exit(EXIT_FAILURE);
}
pathnameβ the original pathname, exactly as passed to thelchown(2)system call. like, exactly. don't be editing it, bestie. πownerβ the original owner, exactly as passed to thelchown(2)system call.groupβ the original group, exactly as passed to thelchown(2)system call.
Returns:
the message explaining the error. π but listen β this message buffer is shared by all libexplain functions that don't supply a buffer in their argument list. it will get overwritten by the next call to any libexplain function that shares this buffer, including other threads. so don't be clinging to it like it's yours, because it is NOT. π
Note: this function is not thread safe, because it shares a return buffer across all threads, and many other functions in this library. it's giving "communal apartment" energy and not in a cute way. π
π¦ explain_errno_lchown π¦
const char *explain_errno_lchown(int errnum, const char *pathname, int owner, int group);
the explain_errno_lchown function is used to obtain an explanation of an error returned by the lchown(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. iconic behaviour, honestly. π
this function is intended to be used in a fashion similar to the following example:
if (lchown(pathname, owner, group) < 0)
{
int err = errno;
fprintf(stderr, "%s\n", explain_errno_lchown(err,
pathname, owner, group));
exit(EXIT_FAILURE);
}
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. so like, grab it early or it's gone, fr fr. πpathnameβ the original pathname, exactly as passed to thelchown(2)system call.ownerβ the original owner, exactly as passed to thelchown(2)system call.groupβ the original group, exactly as passed to thelchown(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. same communal-buffer situation, bestie, we don't make the rules. π
π explain_message_lchown π
void explain_message_lchown(char *message, int message_size, const char *pathname, int owner, int group);
the explain_message_lchown function may be used to obtain an explanation of an error returned by the lchown(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. she's thorough. she's that girl. π
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 (lchown(pathname, owner, group) < 0)
{
char message[3000];
explain_message_lchown(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. π«Ά the glow-up we've been waiting for!!message_sizeβ the size in bytes of the location in which to store the returned message.pathnameβ the original pathname, exactly as passed to thelchown(2)system call.ownerβ the original owner, exactly as passed to thelchown(2)system call.groupβ the original group, exactly as passed to thelchown(2)system call.
π§ explain_message_errno_lchown π§
void explain_message_errno_lchown(char *message, int message_size, int errnum, const char *pathname, int owner, int group);
the explain_message_errno_lchown function may be used to obtain an explanation of an error returned by the lchown(2) system call. the least the message will contain is the value of strerror(errnum), but usually it will do much better, and indicate the underlying cause in more detail. the whole package. the moment. β
this function is intended to be used in a fashion similar to the following example:
if (lchown(pathname, owner, group) < 0)
{
int err = errno;
char message[3000];
explain_message_errno_lchown(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. π grab it fast!!pathnameβ the original pathname, exactly as passed to thelchown(2)system call.ownerβ the original owner, exactly as passed to thelchown(2)system call.groupβ the original group, exactly as passed to thelchown(2)system call.
β¨ SEE ALSO β¨
lchown(2)β change ownership of a file πexplain_lchown_or_die(3)β change ownership of a file and report errors π
β¨ COPYRIGHT β¨
libexplain version 1.4 Copyright (C) 2008 Peter Miller
and that's the whole page, bestie!! π you just read explain_lchown(3) from libexplain version 1.4, with Copyright (C) 2008 Peter Miller riding shotgun. go forth and decode those errors like the main character you are. π
β¨π
π¦ 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