[systemd-devel] [PATCH] fstab-generator: fsck /sysroot before we mount it rw

harald at redhat.com harald at redhat.com
Thu Mar 7 09:14:22 PST 2013


From: Harald Hoyer <harald at redhat.com>

---
 src/fstab-generator/fstab-generator.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c
index 910bbc1..b5fe0fa 100644
--- a/src/fstab-generator/fstab-generator.c
+++ b/src/fstab-generator/fstab-generator.c
@@ -449,6 +449,7 @@ static int parse_new_root_from_proc_cmdline(void) {
         char *w, *state;
         _cleanup_free_ char *what = NULL, *type = NULL, *opts = NULL, *line = NULL;
         int r;
+        int fsck_passno = 0;
         size_t l;
 
         r = read_one_line_file("/proc/cmdline", &line);
@@ -490,7 +491,16 @@ static int parse_new_root_from_proc_cmdline(void) {
                         if (!opts)
                                 return log_oom();
 
-                } else if (streq(word, "ro") || streq(word, "rw")) {
+                } else if (streq(word, "ro")) {
+                        fsck_passno = 0;
+                        tmp_word = opts;
+                        opts = strjoin(opts, ",", word, NULL);
+                        free(tmp_word);
+                        if (!opts)
+                                return log_oom();
+
+                } else if (streq(word, "rw")) {
+                        fsck_passno = 1;
                         tmp_word = opts;
                         opts = strjoin(opts, ",", word, NULL);
                         free(tmp_word);
@@ -513,7 +523,7 @@ static int parse_new_root_from_proc_cmdline(void) {
         }
 
         log_debug("Found entry what=%s where=/sysroot type=%s", what, type);
-        r = add_mount(what, "/sysroot", type, opts, 0, false, false, false,
+        r = add_mount(what, "/sysroot", type, opts, fsck_passno, false, false, false,
                       false, false, "/proc/cmdline");
 
         return (r < 0) ? r : 0;
-- 
1.8.1



More information about the systemd-devel mailing list