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.
This commit is contained in:
parent
074cdb953b
commit
1fac34b941
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue