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
428#endif428#endif
429asmlinkage long sys_fallocate(int fd, int mode, loff_t offset, loff_t len);429asmlinkage long sys_fallocate(int fd, int mode, loff_t offset, loff_t len);
430asmlinkage long sys_faccessat(int dfd, const char __user *filename, int mode);430asmlinkage long sys_faccessat(int dfd, const char __user *filename, int mode);
431asmlinkage long sys_faccessat2(int dfd, const char __user *filename, int mode,
432 int flags);
431asmlinkage long sys_chdir(const char __user *filename);433asmlinkage long sys_chdir(const char __user *filename);
432asmlinkage long sys_fchdir(unsigned int fd);434asmlinkage long sys_fchdir(unsigned int fd);
433asmlinkage long sys_chroot(const char __user *filename);435asmlinkage 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
1333 return do_fchmodat(AT_FDCWD, filename, mode);1335 return do_fchmodat(AT_FDCWD, filename, mode);
1334}1336}
1335 1337
1336extern long do_faccessat(int dfd, const char __user *filename, int mode);1338long do_faccessat(int dfd, const char __user *filename, int mode, int flags);
1337 1339
1338static inline long ksys_access(const char __user *filename, int mode)1340static inline long ksys_access(const char __user *filename, int mode)
1339{1341{
1340 return do_faccessat(AT_FDCWD, filename, mode);1342 return do_faccessat(AT_FDCWD, filename, mode, 0);
1341}1343}
1342 1344
1343extern int do_fchownat(int dfd, const char __user *filename, uid_t user,1345extern int do_fchownat(int dfd, const char __user *filename, uid_t user,