summaryrefslogtreecommitdiff
path: root/src/gpt-auto-generator
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-11-28 13:20:58 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-11-30 17:33:34 +0100
commit1fac34b9412154c8e69f77274ae10cb459afc65c (patch)
tree0ca99d86b8c6a24a57b81f49644b1898b029d3a3 /src/gpt-auto-generator
parent074cdb953bd2d9ae09aa04769c86868ef8bd066d (diff)
downloadsystemd-1fac34b9412154c8e69f77274ae10cb459afc65c.tar.gz
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.
Diffstat (limited to 'src/gpt-auto-generator')
-rw-r--r--src/gpt-auto-generator/gpt-auto-generator.c20
1 files 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 5f27edc9ee..99b5da17f5 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;