explain_linkat_or_die(3)
π explain_linkat_or_die β bestie edition π
okay so you're deep in the explain_linkat_or_die(3) page of the Library Functions Manual and you need the tea. sit down, hydrate, let's go π«Ά
β¨ NAME β¨
explain_linkat_or_die β link a file relative to directory and report errors. that's the whole vibe, no cap π
πΈ SYNOPSIS πΈ
#include <libexplain/linkat.h>
void explain_linkat_or_die(int old_dirfd, const char *old_path, int
new_fildes, const char *new_path, int flags);
int explain_linkat_on_error(int old_dirfd, const char *old_path, int
new_fildes, const char *new_path, int flags);
like. two functions. both iconic. that's the whole thing π
π¦ DESCRIPTION π¦
so explain_linkat_or_die is the function you call when you wanna call the linkat(2) system call. but here's the twist β if it fails, an explanation gets printed to stderr (pulled straight from the explain_linkat(3) function, slay) and then the process terminates by calling exit(EXIT_FAILURE). it's giving "we don't do partial failure here." dramatic? maybe. effective? absolutely. π
and then explain_linkat_on_error is its chill sibling β also calls the linkat(2) system call, also prints that explanation to stderr from explain_linkat(3) on failure, BUT it still returns to the caller. no exit. no drama. just vibes and a return value. π
now the arguments, bestie, all five of them:
old_dirfdβ theold_dirfd, exactly as to be passed to thelinkat(2)system call. no notes, pass it through π«Άold_pathβ theold_path, exactly as to be passed to thelinkat(2)system call. same energy β¨new_fildesβ thenew_fildes, exactly as to be passed to thelinkat(2)system call. yes it's spelled that way, yes it's the parameter name, we don't question it πnew_pathβ thenew_path, exactly as to be passed to thelinkat(2)system call. you know the drill πΈflagsβ theflags, exactly as to be passed to thelinkat(2)system call. all of it. unchanged. periodt π
π RETURN VALUE π
explain_linkat_or_die only returns on success β check linkat(2) for more info on that. on failure it prints an explanation and exits, so like. it does not return. it's gone. it left the chat. π
explain_linkat_on_error always returns the value returned by the wrapped linkat(2) system call. every single time. reliable queen π
β EXAMPLE β
the explain_linkat_or_die function is intended to be used in a fashion similar to the following example:
explain_linkat_or_die(old_dirfd, old_path, new_fildes, new_path, flags);
that's it. that's the example. clean, simple, ate π₯
π§ SEE ALSO π§
linkat(2)β create a file link relative to directory file descriptorsexplain_linkat(3)β explainlinkat(2)errorsexit(2)β terminate the calling process
go read them, iykyk π
π COPYRIGHT π
libexplain version 1.4 Copyright (C) 2013 Peter Miller
and that's the whole page, bestie π«Ά this little love letter to explain_linkat_or_die(3) came to you courtesy of libexplain version 1.4, Β© 2013 Peter Miller β go forth, link your files relative to directory file descriptors, and may your stderr always be explanatory β¨ππΈ
π¦ 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) 2013 Peter Miller
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms