[systemd-devel] [PATCH] fstab-generator: If we wait indefinitely for a mount, wait also for the device

harald at redhat.com harald at redhat.com
Fri Mar 1 06:13:44 PST 2013


From: Harald Hoyer <harald at redhat.com>

Write out "JobTimeoutSec=0" for the device the mountpoint (which does
not timeout) waits for.

This helps with grabbing a cup of coffee while booting and not have
the crypto password dialog timeout and systemd in a failed state.
---
 src/fstab-generator/fstab-generator.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c
index d4470f4..026d070 100644
--- a/src/fstab-generator/fstab-generator.c
+++ b/src/fstab-generator/fstab-generator.c
@@ -313,6 +313,32 @@ static int add_mount(const char *what, const char *where, const char *type, cons
                                 return r;
 
                         if (r > 0) {
+                                if (wait) {
+                                        free(unit);
+                                        unit = strjoin(arg_dest, "/", device, ".d/JobTimeoutSec0.conf", NULL);
+
+                                        mkdir_parents_label(unit, 0755);
+
+                                        fclose(f);
+                                        f = fopen(unit, "wxe");
+                                        if (!f) {
+                                                log_error("Failed to create unit file %s: %m", unit);
+                                                return -errno;
+                                        }
+
+                                        fprintf(f,
+                                                "# Automatically generated by systemd-cryptsetup-generator\n\n"
+                                                "[Unit]\n"
+                                                "JobTimeoutSec=0\n"
+                                                );
+                                        fflush(f);
+
+                                        if (ferror(f)) {
+                                                log_error("Failed to write file %s: %m", unit);
+                                                return -errno;
+                                        }
+                                }
+
                                 free(lnk);
                                 lnk = strjoin(arg_dest, "/", device, ".wants/", name, NULL);
                                 if (!lnk)
-- 
1.8.1



More information about the systemd-devel mailing list