summaryrefslogtreecommitdiff
path: root/src/basic/fs-util.h
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2017-02-21 17:44:35 +0100
committerLennart Poettering <lennart@poettering.net>2017-02-21 21:55:43 +0100
commitf5b84de2abbb48b33c710ec76c8b2f59e90386ae (patch)
tree640caf9b4c7997d24f5b24bf1c34ea9012d7f35e /src/basic/fs-util.h
parent175d308cad2075658b925e5abdbdfe7fa5fda466 (diff)
bootctl: create loader.conf only if it doesn't exist yet
If the snippet aleady exists, don't do anything, as the file was already installed then. (This also reworks the code to create the file atomically) Fixes: #5396
Diffstat (limited to 'src/basic/fs-util.h')
-rw-r--r--src/basic/fs-util.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/basic/fs-util.h b/src/basic/fs-util.h
index 5fe5c71ff0..094acf1799 100644
--- a/src/basic/fs-util.h
+++ b/src/basic/fs-util.h
@@ -91,3 +91,9 @@ static inline void rmdir_and_free(char *p) {
free(p);
}
DEFINE_TRIVIAL_CLEANUP_FUNC(char*, rmdir_and_free);
+
+static inline void unlink_and_free(char *p) {
+ (void) unlink(p);
+ free(p);
+}
+DEFINE_TRIVIAL_CLEANUP_FUNC(char*, unlink_and_free);