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
This commit is contained in:
Lennart Poettering
2017-02-21 21:55:43 +01:00
parent 175d308cad
commit f5b84de2ab
2 changed files with 31 additions and 6 deletions
+6
View File
@@ -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);