"After=modprobe@loop.service\n",
u_escaped);
- r = generator_write_timeouts(arg_dest, device, name, options, &filtered);
+ r = generator_write_device_timeout(arg_dest, device, options, &filtered);
if (r < 0)
log_warning_errno(r, "Failed to write device timeout drop-in: %m");
return log_error_errno(r, "Failed to write unit file %s: %m", name);
/* use what as where, to have a nicer error message */
- r = generator_write_timeouts(arg_dest, what, what, options, NULL);
+ r = generator_write_device_timeout(arg_dest, what, options, NULL);
if (r < 0)
return r;
fprintf(f, "Type=%s\n", t);
}
- r = generator_write_timeouts(dest, what, where, opts, &filtered);
+ r = generator_write_device_timeout(dest, what, opts, &filtered);
if (r < 0)
return r;
if (r < 0)
log_warning_errno(r, "Failed to write device timeout drop-in, ignoring: %m");
- r = generator_write_timeouts(arg_dest,
- info->device,
- info->device,
- arg_resume_options ?: arg_root_options,
- NULL);
+ r = generator_write_device_timeout(arg_dest, info->device, arg_resume_options ?: arg_root_options, NULL);
if (r < 0)
log_warning_errno(r, "Failed to write device timeout drop-in, ignoring: %m");
return 0;
}
-int generator_write_timeouts(
+int generator_write_device_timeout(
const char *dir,
const char *what,
- const char *where,
const char *opts,
char **filtered) {
usec_t u;
int r;
+ assert(dir);
+ assert(what);
+
r = fstab_filter_options(opts, "comment=systemd.device-timeout\0"
"x-systemd.device-timeout\0",
NULL, &timeout, NULL, filtered);
r = parse_sec_fix_0(timeout, &u);
if (r < 0) {
- log_warning("Failed to parse timeout for %s, ignoring: %s", where, timeout);
+ log_warning("Failed to parse timeout for device '%s', ignoring: %s", what, timeout);
return 0;
}
if (!node)
return log_oom();
if (!is_device_path(node)) {
- log_warning("x-systemd.device-timeout ignored for %s", what);
+ log_warning("'%s' is not a device path, ignoring x-systemd.device-timeout= option.", node);
return 0;
}
r = unit_name_from_path(node, ".device", &unit);
if (r < 0)
- return log_error_errno(r, "Failed to make unit name from path: %m");
+ return log_error_errno(r, "Failed to make unit name from device path '%s': %m", node);
+
+ r = write_drop_in_format(dir, unit, 50, "device-timeout",
+ "# Automatically generated by %s\n"
+ "# from supplied options \"%s\"\n\n"
+ "[Unit]\n"
+ "JobRunningTimeoutSec=%s",
+ program_invocation_short_name,
+ opts,
+ timeout);
+ if (r < 0)
+ return r;
- return write_drop_in_format(dir, unit, 50, "device-timeout",
- "# Automatically generated by %s\n"
- "# from supplied options \"%s\"\n\n"
- "[Unit]\n"
- "JobRunningTimeoutSec=%s",
- program_invocation_short_name,
- opts,
- timeout);
+ return 1;
}
int generator_write_network_device_deps(