explain_chroot_or_die(3)

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

πŸ’– NAME πŸ’–

explain_chroot_or_die β€” bestie, this is the one that changes your root directory and then tells you all about it if it goes wrong ✨


πŸŽ€ SYNOPSIS πŸŽ€

#include <libexplain/chroot.h>
void explain_chroot_or_die(const char *pathname);
int explain_chroot_on_error(const char *pathname))

(yes the second one really has two closing parens at the end, that's the actual signature, iykyk πŸ’…)


🌸 DESCRIPTION 🌸

okay so, the explain_chroot_or_die function is your girl for calling the chroot(2) system call. but here's the thing β€” if it fails, it doesn't just ghost you 😭 it prints an explanation to stderr, grabbed straight from the explain_chroot(3) function, and then the process terminates by calling exit(EXIT_FAILURE). like, it's done, it's over, it's not coming back. periodt πŸ’€

the explain_chroot_on_error function also calls the chroot(2) system call. on failure it prints an explanation to stderr β€” same deal, that explanation comes from explain_chroot(3) β€” but this one is way more chill: it still returns to the caller. no dramatic exit, no goodbye, just vibes πŸ¦‹

🌈 pathname

the pathname, exactly as to be passed to the chroot(2) system call. exactly. character for character. don't get creative with it, bestie πŸ™ˆ


✨ RETURN VALUE ✨

the explain_chroot_or_die function only returns on success β€” and if you want more on what success even means here, go read chroot(2). on failure it prints an explanation and exits. it does not return. not even a little. πŸ‘‘

the explain_chroot_on_error function always returns the value returned by the wrapped chroot(2) system call. always. every time. that's the whole point, that's the assignment, and it ate πŸ“


πŸ’… EXAMPLE πŸ’…

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

explain_chroot_or_die(pathname);

that's it. that's the whole moment. iconic 🌟


πŸ¦‹ SEE ALSO πŸ¦‹


libexplain version 1.4 Copyright (C) 2009 Peter Miller


and that's the whole page, bestie 🫢 this was explain_chroot_or_die(3) from the Library Functions Manual, running on libexplain version 1.4, with copyright vibes dating all the way back to 2009 Peter Miller β€” go forth and chroot responsibly, mwah πŸ’–πŸŽ€

πŸ“¦ where this page comes from