diff options
author | Michael Olbrich <m.olbrich@pengutronix.de> | 2015-04-14 22:01:48 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2015-04-21 20:23:41 +0200 |
commit | deb0a77cf0b409141c4b116ae30becb3d878e1ad (patch) | |
tree | eb40f2d8df1cb1a6e7e5c6fbb367b3b8bdfc1a5f /src/fstab-generator | |
parent | 297f24a902110921a0627b40372ed2332229b706 (diff) |
automount: add expire support
Diffstat (limited to 'src/fstab-generator')
-rw-r--r-- | src/fstab-generator/fstab-generator.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c index 57fb7c3321..cb5112ec6d 100644 --- a/src/fstab-generator/fstab-generator.c +++ b/src/fstab-generator/fstab-generator.c @@ -154,6 +154,28 @@ static bool mount_in_initrd(struct mntent *me) { streq(me->mnt_dir, "/usr"); } +static int write_idle_timeout(FILE *f, const char *where, const char *opts, char **filtered) { + _cleanup_free_ char *timeout = NULL; + char timespan[FORMAT_TIMESPAN_MAX]; + usec_t u; + int r; + + r = fstab_filter_options(opts, "x-systemd.idle-timeout\0", NULL, &timeout, filtered); + if (r < 0) + return log_warning_errno(r, "Failed to parse options: %m"); + if (r == 0) + return 0; + + r = parse_sec(timeout, &u); + if (r < 0) { + log_warning("Failed to parse timeout for %s, ignoring: %s", where, timeout); + return 0; + } + + fprintf(f, "TimeoutIdleSec=%s\n", format_timespan(timespan, sizeof(timespan), u, 0)); + + return 0; +} static int add_mount( const char *what, const char *where, @@ -293,6 +315,10 @@ static int add_mount( "Where=%s\n", where); + r = write_idle_timeout(f, where, opts, &filtered); + if (r < 0) + return r; + fflush(f); if (ferror(f)) return log_error_errno(errno, "Failed to write unit file %s: %m", automount_unit); |