fstab/gpt-auto: hook up validatefs to /sysroot/usr/ rather than /sysusr/usr/

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
This commit is contained in:
Mike Yuan
2025-04-12 16:33:22 +02:00
parent 39642b0130
commit 7369c037e2
2 changed files with 9 additions and 10 deletions
+7 -8
View 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;
+2 -2
View 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);