(where && PATH_IN_SET(where, "/usr", accept_root ? "/" : NULL));
}
-static int write_timeout(
- FILE *f,
- const char *where,
- const char *opts,
- const char *filter,
- const char *unit_setting) {
-
- _cleanup_free_ char *timeout = NULL;
- usec_t u;
- int r;
-
- assert(f);
- assert(where);
- assert(filter);
- assert(unit_setting);
-
- r = fstab_filter_options(opts, filter, NULL, &timeout, NULL, NULL);
- if (r < 0)
- return log_error_errno(r, "Failed to parse options for '%s': %m", where);
- if (r == 0)
- return 0;
-
- r = parse_sec_fix_0(timeout, &u);
- if (r < 0) {
- log_warning_errno(r, "Failed to parse timeout '%s' for '%s', ignoring: %m", timeout, where);
- return 0;
- }
-
- fprintf(f, "%s=%s\n", unit_setting, FORMAT_TIMESPAN(u, 0));
-
- return 0;
-}
-
static int write_idle_timeout(FILE *f, const char *where, const char *opts) {
- return write_timeout(f, where, opts,
- "x-systemd.idle-timeout\0", "TimeoutIdleSec");
-}
-
-static int write_mount_timeout(FILE *f, const char *where, const char *opts) {
- return write_timeout(f, where, opts,
- "x-systemd.mount-timeout\0", "TimeoutSec");
+ return generator_write_unit_timeout(f, where, opts,
+ "x-systemd.idle-timeout\0", "TimeoutIdleSec");
}
static int write_dependency(
return r;
}
- r = write_mount_timeout(f, where, opts);
+ r = generator_write_mount_timeout(f, where, opts);
if (r < 0)
return r;
return 1;
}
+int generator_write_unit_timeout(
+ FILE *f,
+ const char *where,
+ const char *opts,
+ const char *filter,
+ const char *unit_setting) {
+
+ _cleanup_free_ char *timeout = NULL;
+ usec_t u;
+ int r;
+
+ assert(f);
+ assert(where);
+ assert(filter);
+ assert(unit_setting);
+
+ r = fstab_filter_options(opts, filter, NULL, &timeout, NULL, NULL);
+ if (r < 0)
+ return log_error_errno(r, "Failed to parse options for '%s': %m", where);
+ if (r == 0)
+ return 0;
+
+ r = parse_sec_fix_0(timeout, &u);
+ if (r < 0) {
+ log_warning_errno(r, "Failed to parse timeout '%s' for '%s', ignoring: %m", timeout, where);
+ return 0;
+ }
+
+ fprintf(f, "%s=%s\n", unit_setting, FORMAT_TIMESPAN(u, 0));
+
+ return 0;
+}
+
int generator_write_network_device_deps(
const char *dir,
const char *what,
const char *opts,
char **filtered);
+int generator_write_unit_timeout(
+ FILE *f,
+ const char *where,
+ const char *opts,
+ const char *filter,
+ const char *unit_setting);
+static inline int generator_write_mount_timeout(FILE *f, const char *where, const char *opts) {
+ return generator_write_unit_timeout(f, where, opts,
+ "x-systemd.mount-timeout\0", "TimeoutSec");
+}
+
int generator_write_blockdev_dependency(FILE *f, const char *what);
int generator_write_network_device_deps(