explain_pathconf(3)

πŸ“¦
version 1.4.D001 Β· 2 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble, ubuntu resolute

πŸ’– explain_pathconf(3) β€” the bestie guide πŸ’–

okay so this page lives in the Library Functions Manual, and it's here to explain explain_pathconf β€” a whole little family of functions that hand you ✨actual explanations✨ for errors coming back from the pathconf(3) system call. Not just "something broke", but why it broke. Obsessed.


🌸 NAME 🌸

explain_pathconf β€” bestie, let me explain your pathconf(3) errors πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <libexplain/pathconf.h>

const char *explain_pathconf(const char *pathname, int name);

const char *explain_errno_pathconf(int errnum, const char *pathname, int name);

void explain_message_pathconf(char *message, int message_size,
        const char *pathname, int name);

void explain_message_errno_pathconf(char *message, int message_size, int errnum,
        const char *pathname, int name);

✨ DESCRIPTION ✨

These functions are the glow-up for error messages πŸ’– You use them to get explanations for errors returned by the pathconf(3) system call. So when things go sideways, you actually know what happened. No cap.


πŸŽ€ explain_pathconf

const char *explain_pathconf(const char *pathname, int name);

The explain_pathconf function gets you an explanation of an error returned by the pathconf(3) system call. The least the message will contain is the value of strerror(errno), but usually it does so much better and points at the underlying cause in more detail. It's giving detective energy πŸ”

The errno global variable is the one used to grab the error value that needs decoding.

This function is meant to be used in a way similar to this example:

if (pathconf(pathname, name) < 0)
{
    fprintf(stderr, "%s\n", explain_pathconf(pathname, name));
    exit(EXIT_FAILURE);
}

The above code example is available pre‐packaged as the explain_pathconf_or_die(3) function. Iconic β€” they already did it for you 🫢

  • pathname β€” The original pathname, exactly as passed to the pathconf(3) system call.
  • name β€” The original name, exactly as passed to the pathconf(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. It will be overwritten by the next call to any libexplain function which shares this buffer β€” including calls from other threads. So don't get attached, bestie, it does not stay πŸ’€

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. Sharing is caring except when it's a buffer, lowkey.

πŸŽ€ explain_errno_pathconf

const char *explain_errno_pathconf(int errnum, const char *pathname, int name);

The explain_errno_pathconf function gets you an explanation of an error returned by the pathconf(3) system call. The least the message will contain is the value of strerror(errnum), but usually it does so much better and points at the underlying cause in more detail.

This function is meant to be used in a way similar to this example:

if (pathconf(pathname, name) < 0)
{
    int err = errno;
    fprintf(stderr, "%s\n", explain_errno_pathconf(err, pathname, name));
    exit(EXIT_FAILURE);
}

The above code example is available pre‐packaged as the explain_pathconf_or_die(3) function. Slay ✨

  • errnum β€” The error value to be decoded, usually grabbed from the errno global variable right before this function is called. You need to do this if you have to call any code between the system call you're explaining and this function, because many libc functions will alter the value of errno. Like, they will absolutely mess with it πŸ™ˆ
  • pathname β€” The original pathname, exactly as passed to the pathconf(3) system call.
  • name β€” The original name, exactly as passed to the pathconf(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. It will be overwritten by the next call to any libexplain function which 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 also do. periodt.

πŸŽ€ explain_message_pathconf

void explain_message_pathconf(char *message, int message_size,
        const char *pathname, int name);

The explain_message_pathconf function may be used to get an explanation of an error returned by the pathconf(3) system call. The least the message will contain is the value of strerror(errno), but usually it does so much better and points at the underlying cause in more detail.

The errno global variable is the one used to grab the error value that needs decoding.

This function is meant to be used in a way similar to this example:

if (pathconf(pathname, name) < 0)
{
    char message[3000];
    explain_message_pathconf(message, sizeof(message), pathname, name);
    fprintf(stderr, "%s\n", message);
    exit(EXIT_FAILURE);
}

The above code example is available pre‐packaged as the explain_pathconf_or_die(3) function. Chef's kiss πŸ‘‘

  • message β€” The location in which to store the returned message. If you supply a suitable message return buffer, this function is thread safe. Look at you go πŸŽ€
  • message_size β€” The size in bytes of the location in which to store the returned message.
  • pathname β€” The original pathname, exactly as passed to the pathconf(3) system call.
  • name β€” The original name, exactly as passed to the pathconf(3) system call.

πŸŽ€ explain_message_errno_pathconf

void explain_message_errno_pathconf(char *message, int message_size, int errnum,
        const char *pathname, int name);

The explain_message_errno_pathconf function may be used to get an explanation of an error returned by the pathconf(3) system call. The least the message will contain is the value of strerror(errnum), but usually it does so much better and points at the underlying cause in more detail.

This function is meant to be used in a way similar to this example:

if (pathconf(pathname, name) < 0)
{
    int err = errno;
    char message[3000];
    explain_message_errno_pathconf(message, sizeof(message), err,
        pathname, name);
    fprintf(stderr, "%s\n", message);
    exit(EXIT_FAILURE);
}

The above code example is available pre‐packaged as the explain_pathconf_or_die(3) function. It's giving ✨prepared✨

  • message β€” The location in which to store the returned message. If you supply a suitable message return buffer, 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 grabbed from the errno global variable right before this function is called. You need this if you have to call any code between the system call you're explaining and this function, because many libc functions will alter the value of errno. Fr fr, watch out for that 😭
  • pathname β€” The original pathname, exactly as passed to the pathconf(3) system call.
  • name β€” The original name, exactly as passed to the pathconf(3) system call.

🌈 SEE ALSO 🌈


libexplain version 1.4 Copyright (C) 2008 Peter Miller


and that's the whole page bestie πŸ’… you made it to the end, main character energy fr. shoutout to libexplain version 1.4, copyright (C) 2008 Peter Miller, and the Library Functions Manual for housing all this. go forth and explain your errors πŸ¦‹βœ¨πŸ’–

πŸ“¦ where this page comes from