logo
Published on KernelTrap (http://kerneltrap.org)

Linux : openat() support in Linux

By Kedar Sovani
Created Jan 20 2006 - 04:23

Recently, patches [1] have been included in the upcoming Linux kernel, to add support to the openat() class of system calls. In the patch log, author, Ulrich Drepper, states "[A] total 13 new system calls which take a file descriptor/filename pair instead of a single file name [have been added]". These system calls interpret the filename relative to the file descriptor passed.

An example should help clarify the point :


int open(const char *path, int oflag, /* mode_t mode */...);
int openat(int dirfd, const char *relative_path, int oflag, /* mode_t mode */...);

This is of great help for implementing virtual per-thread current working directory. In the abscence of this, approaches like cwd_save/restore (which affects the entire process) or "/proc/self/fd/dirfd/relative_path" were being used. Apart from being faster than the older approaches, the new system calls also allow for race-free filesystem traversals. The new system calls include, openat, mkdirat, mknodat, fchownat, futimesat, newfstatat, unlinkat, renameat, linkat, symlinkat, readlinkat, fchmodat, faccessat.

These system calls exist [2] in Solaris for quite a while now. The new Linux openat-variant system calls do not support the extended attribute feature, as is found with the Solaris openat-variants.


Source URL:
http://kerneltrap.org/node/6088