mkdirat
mkdirat is a POSIX-compliant system call that creates a new directory with a pathname relative to a directory file descriptor. If the dirfd argument refers to AT_FDCWD, the pathname is interpreted relative to the process’s current working directory. If pathname is absolute, dirfd is ignored. This design enables creating directories within an already opened directory and helps avoid certain race conditions that can occur when changing directories.
The function prototype is int mkdirat(int dirfd, const char *pathname, mode_t mode). The mode specifies the permissions
Behavior and restrictions: mkdirat creates the directory as a child of the directory described by dirfd. If
Compatibility and usage: mkdirat is widely supported on Linux, BSD variants, and macOS, and forms part of
See also: mkdir, openat, mkdirat on other platforms, fstatat.