summaryrefslogtreecommitdiffstats
path: root/src/fstab-generator
diff options
context:
space:
mode:
authorMike Yuan <me@yhndnzj.com>2024-12-08 20:47:41 +0100
committerMike Yuan <me@yhndnzj.com>2024-12-09 19:25:59 +0100
commit149e05c7e98738c5c29b4a0db71b42d56283e861 (patch)
treea1ca974b979d08d74c14a9a25803399984d4c860 /src/fstab-generator
parenthibernate-resume: always respect user-defined timeout (diff)
downloadsystemd-149e05c7e98738c5c29b4a0db71b42d56283e861.tar.xz
systemd-149e05c7e98738c5c29b4a0db71b42d56283e861.zip
fstab-generator: move write_(mount_)timeout() to shared/generator
Diffstat (limited to 'src/fstab-generator')
-rw-r--r--src/fstab-generator/fstab-generator.c44
1 files changed, 3 insertions, 41 deletions
diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c
index 6a7cf57ba3..4dfe9fea89 100644
--- a/src/fstab-generator/fstab-generator.c
+++ b/src/fstab-generator/fstab-generator.c
@@ -325,47 +325,9 @@ static bool mount_in_initrd(const char *where, const char *options, bool accept_
(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(
@@ -684,7 +646,7 @@ static int add_mount(
return r;
}
- r = write_mount_timeout(f, where, opts);
+ r = generator_write_mount_timeout(f, where, opts);
if (r < 0)
return r;