fs-util: introduce open_parent() helper

We often open the parent directory of a path. Let's add a common helper
for that, that shortens our code a bit and adds some extra safety
checks, for example it will fail if used on the root directory (which
doesn't really have a parent).

The helper is actually generalized from a function in btrfs-util.[ch]
which already existed for this purpose.
This commit is contained in:
Lennart Poettering
2018-07-23 13:38:18 +02:00
parent 09942654d3
commit ef8becfac5
3 changed files with 34 additions and 20 deletions
+2
View File
@@ -103,3 +103,5 @@ void unlink_tempfilep(char (*p)[]);
int unlinkat_deallocate(int fd, const char *name, int flags);
int fsync_directory_of_file(int fd);
int open_parent(const char *path, int flags, mode_t mode);