explain_realpath(3)
π explain_realpath β the manual page, but make it make sense π
okay bestie, so this is a page from the Library Functions Manual, and it's all about explain_realpath, a lil function that tells you why your realpath(3) call flopped. no cap, it's actually so useful. π«Ά
β¨ NAME β¨
explain_realpath β explain realpath(3) errors
like... it explains the errors. from realpath(3). that's the whole vibe. π
πΈ SYNOPSIS πΈ
#include <libexplain/realpath.h>
const char *explain_realpath(const char *pathname, char *resolved_pathname);
const char *explain_errno_realpath(int errnum, const char *pathname,
char *resolved_pathname);
void explain_message_realpath(char *message, int message_size,
const char *pathname, char *resolved_pathname);
void explain_message_errno_realpath(char *message, int message_size, int errnum,
const char *pathname, char *resolved_pathname);
π¦ DESCRIPTION π¦
so basically these functions are your little translators π¬ β you use them to get explanations for errors that the realpath(3) system call hands back to you. it's giving "your code messed up and now someone's gonna tell you exactly why."
π explain_realpath π
const char *explain_realpath(const char *pathname, char *resolved_pathname);
ok so explain_realpath is the one you call to get an explanation of an error that came back from the realpath(3) system call. the least the message is gonna contain is the value of strerror(errno), but honestly? usually it does way better than that and tells you the actual underlying cause in more detail. slay. β¨
the errno global variable is what gets used to grab the error value that's gonna be decoded.
pathnameβ the original pathname, exactly as passed to therealpath(3)system call. exactly. don't be cute about it.resolved_pathnameβ the original resolved_pathname, exactly as passed to therealpath(3)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 that shares this 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. periodt.
Example: this function is meant to be used in a fashion similar to the following example:
char *result = realpath(pathname, resolved_pathname);
if (!result)
{
fprintf(stderr, "%s\n", explain_realpath(pathname,
resolved_pathname));
exit(EXIT_FAILURE);
}
and the above code example? it's available pre-packaged as the explain_realpath_or_die(3) function. iconic. π
π explain_errno_realpath π
const char *explain_errno_realpath(int errnum, const char *pathname,
char *resolved_pathname);
explain_errno_realpath is the one you use to obtain an explanation of an error returned by the realpath(3) 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. fr fr. π
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. don't skip this step bestie, it will bite you. πpathnameβ the original pathname, exactly as passed to therealpath(3)system call.resolved_pathnameβ the original resolved_pathname, exactly as passed to therealpath(3)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:
char *result = realpath(pathname, resolved_pathname);
if (!result)
{
int err = errno;
fprintf(stderr, "%s\n", explain_errno_realpath(err, pathname,
resolved_pathname));
exit(EXIT_FAILURE);
}
the above code example is available pre-packaged as the explain_realpath_or_die(3) function. π
π explain_message_realpath π
void explain_message_realpath(char *message, int message_size,
const char *pathname, char *resolved_pathname);
explain_message_realpath is used to obtain an explanation of an error returned by the realpath(3) 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. π§ that's the glow-up right there.message_sizeβ the size in bytes of the location in which to store the returned message.pathnameβ the original pathname, exactly as passed to therealpath(3)system call.resolved_pathnameβ the original resolved_pathname, exactly as passed to therealpath(3)system call.
Example: this function is intended to be used in a fashion similar to the following example:
char *result = realpath(pathname, resolved_pathname);
if (!result)
{
char message[3000];
explain_message_realpath(message, sizeof(message), pathname,
resolved_pathname);
fprintf(stderr, "%s\n", message);
exit(EXIT_FAILURE);
}
the above code example is available pre-packaged as the explain_realpath_or_die(3) function. β¨
π explain_message_errno_realpath π
void explain_message_errno_realpath(char *message, int message_size, int errnum,
const char *pathname, char *resolved_pathname);
explain_message_errno_realpath is used to obtain an explanation of an error returned by the realpath(3) 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. π seriously, grab thaterrnofirst.pathnameβ the original pathname, exactly as passed to therealpath(3)system call.resolved_pathnameβ the original resolved_pathname, exactly as passed to therealpath(3)system call.
Example: this function is intended to be used in a fashion similar to the following example:
char *result = realpath(pathname, resolved_pathname);
if (!result)
{
int err = errno;
char message[3000];
explain_message_errno_realpath(message, sizeof(message), err,
pathname, resolved_pathname);
fprintf(stderr, "%s\n", message);
exit(EXIT_FAILURE);
}
the above code example is available pre-packaged as the explain_realpath_or_die(3) function. π
π SEE ALSO π
realpath(3)β return the canonicalized absolute pathnameexplain_realpath_or_die(3)β return the canonicalized absolute pathname and report errors
π COPYRIGHT π
- libexplain version 1.4
- Copyright (C) 2011 Peter Miller
ok that's the whole page, bestie, you're officially educated ππ
no notes, you ate. this was the Library Functions Manual edition of explain_realpath(3), brought to you by libexplain version 1.4, copyright 2011 Peter Miller β go forth and debug 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) 2011 Peter Miller
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms