From 1fac34b9412154c8e69f77274ae10cb459afc65c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Thu, 28 Nov 2019 13:20:58 +0100 Subject: [PATCH] gpt-auto-generator: use write_drop_in_format() helper and downgrade failure If we fail to write the timeout, let's not exit. (This might happen if another generator writes the same dropin.) No need to make this fatal. Since this is non-fatal now and the name doesn't need to be unique, let's make the drop-in name shorter. --- src/gpt-auto-generator/gpt-auto-generator.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/gpt-auto-generator/gpt-auto-generator.c b/src/gpt-auto-generator/gpt-auto-generator.c index 5f27edc9ee1..99b5da17f5a 100644 --- a/src/gpt-auto-generator/gpt-auto-generator.c +++ b/src/gpt-auto-generator/gpt-auto-generator.c @@ -13,6 +13,7 @@ #include "device-util.h" #include "dirent-util.h" #include "dissect-image.h" +#include "dropin.h" #include "efi-loader.h" #include "fd-util.h" #include "fileio.h" @@ -166,28 +167,25 @@ static int add_cryptsetup(const char *id, const char *what, bool rw, bool requir if (r < 0) return r; - if (require) { - const char *dmname; + const char *dmname; + dmname = strjoina("dev-mapper-", e, ".device"); + if (require) { r = generator_add_symlink(arg_dest, "cryptsetup.target", "requires", n); if (r < 0) return r; - dmname = strjoina("dev-mapper-", e, ".device"); r = generator_add_symlink(arg_dest, dmname, "requires", n); if (r < 0) return r; } - p = strjoina(arg_dest, "/dev-mapper-", e, ".device.d/50-job-timeout-sec-0.conf"); - mkdir_parents_label(p, 0755); - r = write_string_file(p, - "# Automatically generated by systemd-gpt-auto-generator\n\n" - "[Unit]\n" - "JobTimeoutSec=0\n", - WRITE_STRING_FILE_CREATE); /* the binary handles timeouts anyway */ + r = write_drop_in_format(arg_dest, dmname, 50, "job-timeout", + "# Automatically generated by systemd-gpt-auto-generator\n\n" + "[Unit]\n" + "JobTimeoutSec=0"); /* the binary handles timeouts anyway */ if (r < 0) - return log_error_errno(r, "Failed to write device drop-in: %m"); + log_warning_errno(r, "Failed to write device timeout drop-in, ignoring: %m"); if (device) { char *ret; -- 2.47.3