]> git.pld-linux.org Git - projects/geninitrd.git/commitdiff
check if /newroot/dev/console creation can succeed 12818
authorJan Palus <atler@pld-linux.org>
Wed, 28 Sep 2022 20:06:30 +0000 (22:06 +0200)
committerJan Palus <atler@pld-linux.org>
Wed, 28 Sep 2022 20:06:30 +0000 (22:06 +0200)
/newroot is mounted read-only hence by default nothing can be created
below it unless /newroot/dev is mounted to something else.

unfortunately `test -w /newroot/dev` in initrd does not check whether
containing filesystem is mounted read-only

geninitrd

index 0a422ee4c9820f1517773ed0d09d71f1de6f3eaa..46b2fc6fb6f5ecbbf3f58f7ffdc78ba37dcb2cec 100755 (executable)
--- a/geninitrd
+++ b/geninitrd
@@ -1066,9 +1066,9 @@ initrd_gen_initramfs_switchroot() {
        kmsg "geninitrd/$VERSION switching root"
 
        umount_all
-       busybox_applet switch_root usleep
+       busybox_applet switch_root usleep mountpoint
        add_linuxrc <<-'EOF'
-               [ ! -e /newroot/dev/console ] && mknod -m 660 /newroot/dev/console c 5 1
+               [ ! -e /newroot/dev/console ] && mountpoint -q /newroot/dev && mknod -m 660 /newroot/dev/console c 5 1
 
                # switch root to empty dir will make kernel panic, so sleep 10s before it
                # switch_root needs to be pid 1, so there's no other way to recover from here
This page took 0.538363 seconds and 4 git commands to generate.