openat
Openat is a system call and C library wrapper that opens a file relative to a directory file descriptor. It provides a way to perform file access operations using an existing directory descriptor rather than the process’s working directory. The typical signature is int openat(int dirfd, const char *pathname, int flags, ...); where dirfd is a directory file descriptor obtained from open or dup, or the special value AT_FDCWD to use the process’s current working directory. If pathname is absolute, dirfd is ignored.
When pathname is relative, its resolution is anchored to the directory referred to by dirfd. If O_CREAT
Openat is part of a family of at functions that includes fstatat, mkdirat, unlinkat, renameat, and others,
Openat has been complemented by openat2 in newer Linux kernels, which offers more flexible and extended pathname