From: Mike Yuan Date: Sat, 12 Apr 2025 13:06:36 +0000 (+0200) Subject: fstab/gpt-auto: hook up validatefs to /sysroot/usr/ rather than /sysusr/usr/ X-Git-Tag: v258-rc1~831^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7369c037e2f328f0481f13ebc2b968836c4e6250;p=thirdparty%2Fsystemd.git 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 --- diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c index 88aafd95db6..3b3bc9db670 100644 --- a/src/fstab-generator/fstab-generator.c +++ b/src/fstab-generator/fstab-generator.c @@ -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; diff --git a/src/gpt-auto-generator/gpt-auto-generator.c b/src/gpt-auto-generator/gpt-auto-generator.c index 73c4183f16c..103acffe772 100644 --- a/src/gpt-auto-generator/gpt-auto-generator.c +++ b/src/gpt-auto-generator/gpt-auto-generator.c @@ -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);