FCHDIR(3POSIX)

✨ PROLOG ✨

ok so bestie, real talk before we even get into it: this page is part of the POSIX Programmer's Manual πŸ’– and the Linux implementation of this interface may differ from what's written here. like, literally, consult the corresponding Linux manual page for details of Linux behavior. or β€” plot twist β€” the interface might not even be implemented on Linux at all. so don't come for me if it's giving nothing on your machine πŸ™ˆ


🌸 NAME 🌸

fchdir β€” change working directory. that's it, that's the whole vibe, she changes your cwd πŸ’…

✨ SYNOPSIS ✨

#include <unistd.h>

int fchdir(int fildes);

πŸ¦‹ DESCRIPTION πŸ¦‹

so fchdir() shall be equivalent to chdir() β€” same energy, same job β€” EXCEPT that the directory that's gonna be your new current working directory is specified by the file descriptor fildes instead of a path. that's the entire plot twist, no cap πŸŽ€

and here's the tea for a conforming application: you can obtain a file descriptor for a file of type directory using open(), provided that the file status flags and access modes do not contain O_WRONLY or O_RDWR. so like, read-only or nothing, bestie, that's the rule πŸ”₯

πŸ’– RETURN VALUE πŸ’–

upon successful completion, fchdir() shall return 0. slay. ✨

otherwise it shall return -1 and set errno to indicate the error 😭 and on failure the current working directory shall remain unchanged β€” so like, no surprise glow-down, your cwd stays exactly where it was, periodt.

πŸ‘‘ ERRORS πŸ‘‘

the fchdir() function shall fail if:

  • EACCES β€” search permission is denied for the directory referenced by fildes. she said no entry, respectfully πŸ’€
  • EBADF β€” the fildes argument is not an open file descriptor. girl that's not even a real fd 😭
  • ENOTDIR β€” the open file descriptor fildes does not refer to a directory. like, bestie, that's a file. that is not a directory. read the room 🫢

the fchdir() may fail if:

  • EINTR β€” a signal was caught during the execution of fchdir(). interruptions, the audacity πŸ™ˆ
  • EIO β€” an I/O error occurred while reading from or writing to the file system. the hardware is not giving today 🌧️
and jsyk: the following sections are informative. they're the vibe context, not the rules πŸ’œ

πŸŽ€ EXAMPLES πŸŽ€

None. β€” nothing here, she's booked and busy elsewhere ✨

🧚 APPLICATION USAGE 🧚

None. β€” also empty, no notes, iconic behavior πŸ’…

🌈 RATIONALE 🌈

None. β€” she didn't feel like explaining herself and honestly? respect πŸ‘‘

⭐ FUTURE DIRECTIONS ⭐

None. β€” the future is bright but this section is blank 🌸

πŸ’œ SEE ALSO πŸ’œ

  • chdir()
  • dirfd()
  • the Base Definitions volume of POSIX.1‐2017, <unistd.h>

ok so the legal bit, and we do NOT skip the legal bit bestie, here it is in full:

portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. in the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. the original Standard can be obtained online at http://www.opengroup.org/unix/online.html .

any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. to report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .


and that's the whole page, bestie!! 🫢 this one's from the POSIX Programmer's Manual, FCHDIR(3POSIX), brought to you by IEEE/The Open Group, dated 2017 β€” mwah, drink water, go change a directory πŸ’–βœ¨πŸŽ€