Constant nix::fcntl::AT_FDCWD

source ·
pub const AT_FDCWD: BorrowedFd<'static>;
Expand description

A file descriptor referring to the working directory of the current process that should be ONLY passed to the dirfd argument of those xxat() functions.

§Examples

Use it in openat():

use nix::fcntl::AT_FDCWD;
use nix::fcntl::openat;
use nix::fcntl::OFlag;
use nix::sys::stat::Mode;

let fd = openat(AT_FDCWD, "foo", OFlag::O_RDONLY | OFlag::O_CLOEXEC, Mode::empty()).unwrap();

§WARNING

Do NOT pass this symbol to non-xxat() functions, it won’t work:

use nix::errno::Errno;
use nix::fcntl::AT_FDCWD;
use nix::sys::stat::fstat;

let never = fstat(AT_FDCWD).unwrap();