From: Lennart Poettering Date: Tue, 21 Feb 2017 16:44:35 +0000 (+0100) Subject: bootctl: create loader.conf only if it doesn't exist yet X-Git-Tag: v233.3~43 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=1fb53ab1ff945fd78916943a46437dd21f02caf0;p=elogind.git 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 --- diff --git a/src/basic/fs-util.h b/src/basic/fs-util.h index 3f47537de..60f465a4d 100644 --- a/src/basic/fs-util.h +++ b/src/basic/fs-util.h @@ -104,3 +104,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);