Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/distrib/common If gpt label "cgd.conf" contains a valid /etc...



details:   https://anonhg.NetBSD.org/src/rev/afe92a6e00d9
branches:  trunk
changeset: 1004947:afe92a6e00d9
user:      alnsn <alnsn%NetBSD.org@localhost>
date:      Fri Nov 22 00:27:30 2019 +0000

description:
If gpt label "cgd.conf" contains a valid /etc/cgd file system,
try mounting gpt label "cgdroot" as a root filesystem first and
only mount /dev/cgd0a if that gpt label doesn't exist or fails
to mount.

XXX pullup to 8 and 9.

diffstat:

 distrib/common/cgdroot.rc |  34 ++++++++++++++++++++++++++++------
 1 files changed, 28 insertions(+), 6 deletions(-)

diffs (68 lines):

diff -r 4f4385853d48 -r afe92a6e00d9 distrib/common/cgdroot.rc
--- a/distrib/common/cgdroot.rc Thu Nov 21 23:06:15 2019 +0000
+++ b/distrib/common/cgdroot.rc Fri Nov 22 00:27:30 2019 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: cgdroot.rc,v 1.4 2018/12/29 13:09:35 alnsn Exp $
+#      $NetBSD: cgdroot.rc,v 1.5 2019/11/22 00:27:30 alnsn Exp $
 #
 # Copyright (c) 2013 Pierre Pronchery <khorben%defora.org@localhost>
 # All rights reserved.
@@ -36,17 +36,20 @@
 
 umask 022
 
-mounted=
+# Mount /etc/cgd.
+etc_cgd_mount=
 for dev in NAME=cgd.conf /dev/wd0a /dev/ld0a ; do
        if mount -o ro $dev /etc/cgd 2>/dev/null ; then
-               mounted=$dev
+               etc_cgd_mount=$dev
                break
        fi
 done
-if [ -z "$mounted" ]; then
+if [ -z "${etc_cgd_mount}" ]; then
        echo "Could not mount the boot partition" 1>&2
        exit 2
 fi
+
+# Configure cgd device(s).
 /sbin/wsconsctl -d -w splash.enable=0 > /dev/null 2>&1
 cgdconfig -C
 if [ $? -ne 0 ]; then
@@ -54,13 +57,32 @@
        umount /etc/cgd
        exit 2
 fi
-mount -o ro /dev/cgd0a /altroot
-if [ $? -ne 0 ]; then
+
+# Select candidates for a root mount.
+root_mounts=
+if [ -z "${etc_cgd_mount##NAME=*}" ]; then
+       root_mounts="NAME=cgdroot /dev/cgd0a"
+else
+       root_mounts=/dev/cgd0a
+fi
+
+# Mount the root filesystem.
+mounted=
+for dev in ${root_mounts} ; do
+       if mount -o ro $dev /altroot 2>/dev/null ; then
+               mounted=$dev
+               break
+       fi
+done
+
+if [ -z "$mounted" ]; then
        echo "Could not mount the root partition" 1>&2
        cgdconfig -U
        umount /etc/cgd
        exit 2
 fi
+
+# Boot into /altroot.
 umount /etc/cgd
 /sbin/wsconsctl -d -w splash.enable=1 > /dev/null 2>&1
 sysctl -w init.root=/altroot



Home | Main Index | Thread Index | Old Index