chiark / gitweb /
bootctl: create loader.conf only if it doesn't exist yet
authorLennart Poettering <lennart@poettering.net>
Tue, 21 Feb 2017 16:44:35 +0000 (17:44 +0100)
committerSven Eden <yamakuzure@gmx.net>
Mon, 17 Jul 2017 15:58:36 +0000 (17:58 +0200)
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
src/basic/fs-util.h

index 3f47537de147fb2b0689cc89f238f3596ccf7f16..60f465a4d919bf2a301bdd66c916c6994b732a29 100644 (file)
@@ -104,3 +104,9 @@ static inline void rmdir_and_free(char *p) {
         free(p);
 }
 DEFINE_TRIVIAL_CLEANUP_FUNC(char*, rmdir_and_free);
         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);