explain_mkdtemp(3)
π NAME π
explain_mkdtemp β bestie, this whole page is about explaining mkdtemp(3) errors. That's it, that's the job. π
(Also hi, this is a Library Functions Manual page, so you're in the right place, don't worry.)
β¨ SYNOPSIS β¨
#include <libexplain/mkdtemp.h>
const char *explain_mkdtemp(char *pathname);
const char *explain_errno_mkdtemp(int errnum, char *pathname);
void explain_message_mkdtemp(char *message, int message_size, char
*pathname);
void explain_message_errno_mkdtemp(char *message, int message_size, int
errnum, char *pathname);
π DESCRIPTION π
okay so, these functions are the little glow-up squad for errors. You use them to get actual explanations for errors that mkdtemp(3) threw back at you. No more squinting at a bare number like π
π¦ explain_mkdtemp π¦
const char *explain_mkdtemp(char *pathname);
The explain_mkdtemp function is here to get you an explanation of an error returned by the mkdtemp(3) system call. The least the message will contain is the value of strerror(errno), but usually it does soooo much better and tells you the underlying cause in way more detail. Lowkey overachiever. β¨
The errno global variable is what it uses to grab the error value it's gonna decode.
pathnameβ the original pathname, exactly as passed to themkdtemp(3)system call. Exactly, bestie, don't get creative with it.
Returns: the message explaining the error. Heads up: this message buffer is shared by all libexplain functions that don't supply a buffer in their argument list. So it will get 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 so do many other functions in this library. It's giving "communal snack bowl". π
Example: this function is intended to be used in a fashion similar to the following example:
char *result = mkdtemp(pathname);
if (!result)
{
fprintf(stderr, "%s\n", explain_mkdtemp(pathname));
exit(EXIT_FAILURE);
}
The above code example is available pre-packaged as the explain_mkdtemp_or_die(3) function. Free snack, already plated. π«Ά
πΈ explain_errno_mkdtemp πΈ
const char *explain_errno_mkdtemp(int errnum, char *pathname);
The explain_errno_mkdtemp function is used to obtain an explanation of an error returned by the mkdtemp(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. Same energy as its sibling, just with the error handed over manually.
errnumβ the error value to be decoded, usually obtained from theerrnoglobal variable just before this function is called. You need this if you have to call any code between the system call being explained and this function, because so many libc functions will alter the value oferrno. Sneaky little things. πpathnameβ the original pathname, exactly as passed to themkdtemp(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 = mkdtemp(pathname);
if (!result)
{
int err = errno;
fprintf(stderr, "%s\n", explain_errno_mkdtemp(err,
pathname));
exit(EXIT_FAILURE);
}
The above code example is available pre-packaged as the explain_mkdtemp_or_die(3) function.
π explain_message_mkdtemp π
void explain_message_mkdtemp(char *message, int message_size, char
*pathname);
The explain_message_mkdtemp function is used to obtain an explanation of an error returned by the mkdtemp(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. And here's the slay part: if you supply a suitable message return buffer, this function is thread safe. Iconic behaviour, honestly. πmessage_sizeβ the size in bytes of the location in which to store the returned message.pathnameβ the original pathname, exactly as passed to themkdtemp(3)system call.
Example: this function is intended to be used in a fashion similar to the following example:
char *result = mkdtemp(pathname);
if (!result)
{
char message[3000];
explain_message_mkdtemp(message, sizeof(message), pathname);
fprintf(stderr, "%s\n", message);
exit(EXIT_FAILURE);
}
The above code example is available pre-packaged as the explain_mkdtemp_or_die(3) function.
π explain_message_errno_mkdtemp π
void explain_message_errno_mkdtemp(char *message, int message_size, int
errnum, char *pathname);
The explain_message_errno_mkdtemp function is used to obtain an explanation of an error returned by the mkdtemp(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. It's the full combo meal: your own buffer and the error value you saved. π₯
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 themkdtemp(3)system call.
Example: this function is intended to be used in a fashion similar to the following example:
char *result = mkdtemp(pathname);
if (!result)
{
int err = errno;
char message[3000];
explain_message_errno_mkdtemp(message, sizeof(message), err,
pathname);
fprintf(stderr, "%s\n", message);
exit(EXIT_FAILURE);
}
The above code example is available pre-packaged as the explain_mkdtemp_or_die(3) function.
π SEE ALSO π
mkdtemp(3)β create a unique temporary directoryexplain_mkdtemp_or_die(3)β create a unique temporary directory and report errors
π COPYRIGHT π
libexplainversion1.4- Copyright (C) 2009 Peter Miller
and that's the whole page, bestie π that was explain_mkdtemp(3) from the Library Functions Manual β libexplain version 1.4, Copyright (C) 2009 Peter Miller, iykyk. go forth and explain your errors, 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) 2009-2011 Peter Miller
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms