]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
fstab/gpt-auto: hook up validatefs to /sysroot/usr/ rather than /sysusr/usr/
authorMike Yuan <me@yhndnzj.com>
Sat, 12 Apr 2025 13:06:36 +0000 (15:06 +0200)
committerMike Yuan <me@yhndnzj.com>
Sat, 12 Apr 2025 14:33:22 +0000 (16:33 +0200)
We carry a special logic for /usr/ in initrd that it initially gets
mounted to /sysusr/usr/ and later bind mounted to /sysroot/usr/.
When hooking up validatefs it is hence necessary to wait for
the bind mount and validate that, rather than the /sysusr/usr/
established as intermediate transport.

Alternative to #37102

src/fstab-generator/fstab-generator.c
src/gpt-auto-generator/gpt-auto-generator.c

index 88aafd95db63b8d8e6c32f0557b5353bb9809a21..3b3bc9db67009d5cbd83f1fde4f5c819f4aa5386 100644 (file)
@@ -813,7 +813,9 @@ static bool sysfs_check(void) {
         return cached;
 }
 
-static int add_sysusr_sysroot_usr_bind_mount(const char *source) {
+static int add_sysusr_sysroot_usr_bind_mount(const char *source, bool validatefs) {
+        log_debug("Synthesizing entry what=/sysusr/usr where=/sysroot/usr opts=bind validatefs=%s", yes_no(validatefs));
+
         return add_mount(source,
                          arg_dest,
                          "/sysusr/usr",
@@ -822,7 +824,7 @@ static int add_sysusr_sysroot_usr_bind_mount(const char *source) {
                          /* fstype= */ NULL,
                          "bind",
                          /* passno= */ 0,
-                         /* flags= */ 0,
+                         validatefs ? MOUNT_VALIDATEFS : 0,
                          SPECIAL_INITRD_FS_TARGET,
                          /* extra_after= */ NULL);
 }
@@ -1004,15 +1006,14 @@ static int parse_fstab_one(
                       fstype,
                       options,
                       passno,
-                      flags,
+                      flags & ~(is_sysroot_usr ? MOUNT_VALIDATEFS : 0),
                       target_unit,
                       /* extra_after= */ NULL);
         if (r <= 0)
                 return r;
 
         if (is_sysroot_usr) {
-                log_debug("Synthesizing fstab entry what=/sysusr/usr where=/sysroot/usr opts=bind");
-                r = add_sysusr_sysroot_usr_bind_mount(source);
+                r = add_sysusr_sysroot_usr_bind_mount(source, flags & MOUNT_VALIDATEFS);
                 if (r < 0)
                         return r;
         }
@@ -1324,9 +1325,7 @@ static int add_sysroot_usr_mount(void) {
         if (r < 0)
                 return r;
 
-        log_debug("Synthesizing entry what=/sysusr/usr where=/sysroot/usr opts=bind");
-
-        r = add_sysusr_sysroot_usr_bind_mount("/proc/cmdline");
+        r = add_sysusr_sysroot_usr_bind_mount("/proc/cmdline", /* validatefs = */ false);
         if (r < 0)
                 return r;
 
index 73c4183f16c893169f2262b77a7690d7b33992a6..103acffe772c989ae1f5c6c1e653b157b00308ff 100644 (file)
@@ -979,7 +979,7 @@ static int add_usr_mount(void) {
                       "/dev/disk/by-designator/usr",
                       in_initrd() ? "/sysusr/usr" : "/usr",
                       arg_usr_fstype,
-                      (in_initrd() ? MOUNT_VALIDATEFS : 0),
+                      /* flags = */ 0,
                       options,
                       "/usr/ Partition",
                       in_initrd() ? SPECIAL_INITRD_USR_FS_TARGET : SPECIAL_LOCAL_FS_TARGET);
@@ -993,7 +993,7 @@ static int add_usr_mount(void) {
                               "/sysusr/usr",
                               "/sysroot/usr",
                               /* fstype= */ NULL,
-                              /* flags= */ 0,
+                              MOUNT_VALIDATEFS,
                               "bind",
                               "/usr/ Partition (Final)",
                               SPECIAL_INITRD_FS_TARGET);