stat-util: Add verify_regular_at()

This commit is contained in:
Daan De Meyer
2023-03-22 12:17:14 +01:00
parent 997bc9ec56
commit bd7a79528c
2 changed files with 13 additions and 0 deletions
+12
View File
@@ -307,6 +307,18 @@ int fd_verify_regular(int fd) {
return stat_verify_regular(&st);
}
int verify_regular_at(int dir_fd, const char *path, bool follow) {
struct stat st;
assert(dir_fd >= 0 || dir_fd == AT_FDCWD);
assert(path);
if (fstatat(dir_fd, path, &st, (isempty(path) ? AT_EMPTY_PATH : 0) | (follow ? 0 : AT_SYMLINK_NOFOLLOW)) < 0)
return -errno;
return stat_verify_regular(&st);
}
int stat_verify_directory(const struct stat *st) {
assert(st);
+1
View File
@@ -65,6 +65,7 @@ int path_is_network_fs(const char *path);
int stat_verify_regular(const struct stat *st);
int fd_verify_regular(int fd);
int verify_regular_at(int dir_fd, const char *path, bool follow);
int stat_verify_directory(const struct stat *st);
int fd_verify_directory(int fd);