[projects/geninitrd] check if /newroot/dev/console creation can succeed

atler atler at pld-linux.org
Wed Sep 28 22:11:15 CEST 2022


commit 9552a28d03e1b9bf8c5fdb933d5fa8464022a219
Author: Jan Palus <atler at pld-linux.org>
Date:   Wed Sep 28 22:06:30 2022 +0200

    check if /newroot/dev/console creation can succeed
    
    /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 | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/geninitrd b/geninitrd
index 0a422ee..46b2fc6 100755
--- 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
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/projects/geninitrd.git/commitdiff/9552a28d03e1b9bf8c5fdb933d5fa8464022a219



More information about the pld-cvs-commit mailing list