fs-util: try AT_EMPTY_PATH for access_fd() first
This commit is contained in:
@@ -675,6 +675,14 @@ int access_fd(int fd, int mode) {
|
||||
|
||||
/* Like access() but operates on an already open fd */
|
||||
|
||||
if (faccessat(fd, "", mode, AT_EMPTY_PATH) >= 0)
|
||||
return 0;
|
||||
if (errno != EINVAL)
|
||||
return -errno;
|
||||
|
||||
/* Support for AT_EMPTY_PATH is added rather late (kernel 5.8), so fall back to going through /proc/
|
||||
* if unavailable. */
|
||||
|
||||
if (access(FORMAT_PROC_FD_PATH(fd), mode) < 0) {
|
||||
if (errno != ENOENT)
|
||||
return -errno;
|
||||
|
||||
Reference in New Issue
Block a user