History

vfs: add faccessat2 syscall

POSIX defines faccessat() as having a fourth "flags" argument, while the linux syscall doesn't have it. Glibc tries to emulate AT_EACCESS and AT_SYMLINK_NOFOLLOW, but AT_EACCESS emulation is broken. Add a new faccessat(2) syscall with the added flags argument and implement both flags. The value of AT_EACCESS is defined in glibc headers to be the same as AT_REMOVEDIR. Use this value for the kernel interface as well, together with the explanatory comment. Also add AT_EMPTY_PATH support, which is not documented by POSIX, but can be useful and is trivial to implement.

Miklos Szeredi committed 6 years ago

Commit c8ffd8b1 parent 55923e423 files · +62 −13Browse files

Showing the changes to include/linux (1 of 23 files). Show all

Unified · Split

include/linux/syscalls.h+4−2
@@ -428,6 +428,8 @@ asmlinkage long sys_ftruncate64(unsigned int fd, loff_t length); · 427 unmodified lines
428428 #endif
429429 asmlinkage long sys_fallocate(int fd, int mode, loff_t offset, loff_t len);
430430 asmlinkage long sys_faccessat(int dfd, const char __user *filename, int mode);
431+asmlinkage long sys_faccessat2(int dfd, const char __user *filename, int mode,
432+ int flags);
431433 asmlinkage long sys_chdir(const char __user *filename);
432434 asmlinkage long sys_fchdir(unsigned int fd);
433435 asmlinkage long sys_chroot(const char __user *filename);
@@ -1333,11 +1335,11 @@ static inline int ksys_chmod(const char __user *filename, umode_t mode) · 899 unmodified lines
13331335 return do_fchmodat(AT_FDCWD, filename, mode);
13341336 }
13351337
1336−extern long do_faccessat(int dfd, const char __user *filename, int mode);
1338+long do_faccessat(int dfd, const char __user *filename, int mode, int flags);
13371339
13381340 static inline long ksys_access(const char __user *filename, int mode)
13391341 {
1340− return do_faccessat(AT_FDCWD, filename, mode);
1342+ return do_faccessat(AT_FDCWD, filename, mode, 0);
13411343 }
13421344
13431345 extern int do_fchownat(int dfd, const char __user *filename, uid_t user,