explain_mount(3)

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

πŸ’… explain_mount β€” the libexplain girlie's guide πŸ’…

okay so bestie, welcome to explain_mount(3), a page straight out of the Library Functions Manual and literally the most useful thing when mount(2) is acting up and you're just standing there like πŸ§β™€οΈ. no cap.


✨ NAME ✨

explain_mount β€” it explains mount(2) errors. that's it. that's the job. it's giving "translator for when the kernel is being cryptic." 🫢


🌸 SYNOPSIS 🌸

#include <libexplain/mount.h>
const char *explain_mount(const char *source, const char *target, const
char *file_systems_type, unsigned long flags, const void *data);
const char *explain_errno_mount(int errnum, const char *source, const
char *target, const char *file_systems_type, unsigned long flags, const
void *data);
void explain_message_mount(char *message, int message_size, const char
*source, const char *target, const char *file_systems_type, unsigned
long flags, const void *data);
void explain_message_errno_mount(char *message, int message_size, int
errnum, const char *source, const char *target, const char
*file_systems_type, unsigned long flags, const void *data);

πŸ‘‘ DESCRIPTION πŸ‘‘

so like, these functions are the whole point: you use them to get explanations for errors that the mount(2) system call threw back at you. instead of squinting at a bare errno like 😭, you get actual words. periodt.


πŸŽ€ explain_mount πŸŽ€

const char *explain_mount(const char *source, const char *target, const
char *file_systems_type, unsigned long flags, const void *data);

the explain_mount function is how you get an explanation of an error returned by the mount(2) system call. the least the message is gonna contain is the value of strerror(errno) β€” but fr fr, usually it does so much better and tells you the underlying cause in way more detail. iconic behaviour honestly. ✨

the errno global variable gets used to obtain the error value that's gonna be decoded.

  • source β€” the original source, exactly as passed to the mount(2) system call.
  • target β€” the original target, exactly as passed to the mount(2) system call.
  • file_systems_type β€” the original file_systems_type, exactly as passed to the mount(2) system call.
  • flags β€” the original flags, exactly as passed to the mount(2) system call.
  • data β€” the original data, exactly as passed to the mount(2) system call.

Returns: the message explaining the error. 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. πŸ’€

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. be careful out there bestie.

Example: this function is meant to be used in a fashion similar to the following example:

if (mount(source, target, file_systems_type, flags, data) < 0)
{
    fprintf(stderr, "%s\n", explain_mount(source, target,
    file_systems_type, flags, data));
    exit(EXIT_FAILURE);
}

the above code example is available pre-packaged as the explain_mount_or_die(3) function. slay. 🫢


πŸ¦‹ explain_errno_mount πŸ¦‹

const char *explain_errno_mount(int errnum, const char *source, const
char *target, const char *file_systems_type, unsigned long flags, const
void *data);

the explain_errno_mount function is how you get an explanation of an error returned by the mount(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. πŸ’–

  • errnum β€” the error value to be decoded, usually obtained from the errno global 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 of errno. lowkey the whole reason this variant exists.
  • source β€” the original source, exactly as passed to the mount(2) system call.
  • target β€” the original target, exactly as passed to the mount(2) system call.
  • file_systems_type β€” the original file_systems_type, exactly as passed to the mount(2) system call.
  • flags β€” the original flags, exactly as passed to the mount(2) system call.
  • data β€” the original data, exactly as passed to the mount(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 (mount(source, target, file_systems_type, flags, data) < 0)
{
    int err = errno;
    fprintf(stderr, "%s\n", explain_errno_mount(err, source,
    target, file_systems_type, flags, data));
    exit(EXIT_FAILURE);
}

the above code example is available pre-packaged as the explain_mount_or_die(3) function. πŸŽ€


🌈 explain_message_mount 🌈

void explain_message_mount(char *message, int message_size, const char
*source, const char *target, const char *file_systems_type, unsigned
long flags, const void *data);

the explain_message_mount function is used to obtain an explanation of an error returned by the mount(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. finally!!
  • message_size β€” the size in bytes of the location in which to store the returned message.
  • source β€” the original source, exactly as passed to the mount(2) system call.
  • target β€” the original target, exactly as passed to the mount(2) system call.
  • file_systems_type β€” the original file_systems_type, exactly as passed to the mount(2) system call.
  • flags β€” the original flags, exactly as passed to the mount(2) system call.
  • data β€” the original data, exactly as passed to the mount(2) system call.

Example: this function is intended to be used in a fashion similar to the following example:

if (mount(source, target, file_systems_type, flags, data) < 0)
{
    char message[3000];
    explain_message_mount(message, sizeof(message), source,
    target, file_systems_type, flags, data);
    fprintf(stderr, "%s\n", message);
    exit(EXIT_FAILURE);
}

the above code example is available pre-packaged as the explain_mount_or_die(3) function. πŸ’œ


πŸ“ explain_message_errno_mount πŸ“

void explain_message_errno_mount(char *message, int message_size, int
errnum, const char *source, const char *target, const char
*file_systems_type, unsigned long flags, const void *data);

the explain_message_errno_mount function is used to obtain an explanation of an error returned by the mount(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 the errno global 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 of errno.
  • source β€” the original source, exactly as passed to the mount(2) system call.
  • target β€” the original target, exactly as passed to the mount(2) system call.
  • file_systems_type β€” the original file_systems_type, exactly as passed to the mount(2) system call.
  • flags β€” the original flags, exactly as passed to the mount(2) system call.
  • data β€” the original data, exactly as passed to the mount(2) system call.

Example: this function is intended to be used in a fashion similar to the following example:

if (mount(source, target, file_systems_type, flags, data) < 0)
{
    int err = errno;
    char message[3000];
    explain_message_errno_mount(message, sizeof(message), err,
    source, target, file_systems_type, flags, data);
    fprintf(stderr, "%s\n", message);
    exit(EXIT_FAILURE);
}

the above code example is available pre-packaged as the explain_mount_or_die(3) function. 🧚


πŸ’– SEE ALSO πŸ’–


libexplain version 1.4 Copyright (C) 2013 Peter Miller


and that's the whole page bestie, explain_mount(3), part of the Library Functions Manual β€” from libexplain version 1.4, copyright (C) 2013 Peter Miller. go mount something safely, ily, bye πŸ’…βœ¨πŸ¦‹

πŸ“¦ where this page comes from