stat-util: Add verify_regular_at()
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user