fs-util: add XO_REGULAR flag for xopenat()

If this flag is set we guarantee that the fd returned refers to a
regular file. If the file exists and is not one, fails.
This commit is contained in:
Lennart Poettering
2025-01-06 23:20:09 +01:00
parent 2144b5dccf
commit dffafa47ae
3 changed files with 104 additions and 7 deletions
+4 -3
View File
@@ -134,9 +134,10 @@ int posix_fallocate_loop(int fd, uint64_t offset, uint64_t size);
int parse_cifs_service(const char *s, char **ret_host, char **ret_service, char **ret_path);
typedef enum XOpenFlags {
XO_LABEL = 1 << 0,
XO_SUBVOLUME = 1 << 1,
XO_NOCOW = 1 << 2,
XO_LABEL = 1 << 0, /* When creating: relabel */
XO_SUBVOLUME = 1 << 1, /* When creating as directory: make it a subvolume */
XO_NOCOW = 1 << 2, /* Enable NOCOW mode after opening */
XO_REGULAR = 1 << 3, /* Fail if the inode is not a regular file */
} XOpenFlags;
int open_mkdir_at_full(int dirfd, const char *path, int flags, XOpenFlags xopen_flags, mode_t mode);