fs-util: group access_fd() with access_nofollow()

This commit is contained in:
Mike Yuan
2026-01-19 13:33:27 +01:00
parent 52bf232e82
commit 9b906ae48e
2 changed files with 14 additions and 15 deletions
+13 -13
View File
@@ -360,6 +360,19 @@ int access_nofollow(const char *path, int mode) {
return RET_NERRNO(faccessat(AT_FDCWD, path, mode, AT_SYMLINK_NOFOLLOW));
}
int access_fd(int fd, int mode) {
/* Like access() but operates on an already open fd */
if (fd == AT_FDCWD)
return RET_NERRNO(access(".", mode));
if (fd == XAT_FDROOT)
return RET_NERRNO(access("/", mode));
assert(fd >= 0);
return RET_NERRNO(faccessat(fd, "", mode, AT_EMPTY_PATH));
}
int touch_fd(int fd, usec_t stamp) {
assert(fd >= 0);
@@ -697,19 +710,6 @@ char* unlink_and_free(char *p) {
return mfree(p);
}
int access_fd(int fd, int mode) {
/* Like access() but operates on an already open fd */
if (fd == AT_FDCWD)
return RET_NERRNO(access(".", mode));
if (fd == XAT_FDROOT)
return RET_NERRNO(access("/", mode));
assert(fd >= 0);
return RET_NERRNO(faccessat(fd, "", mode, AT_EMPTY_PATH));
}
int unlinkat_deallocate(int fd, const char *name, UnlinkDeallocateFlags flags) {
_cleanup_close_ int truncate_fd = -EBADF;
struct stat st;