From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 55B95138359 for ; Wed, 19 Aug 2020 21:31:09 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 73F7BE0A93; Wed, 19 Aug 2020 21:31:08 +0000 (UTC) Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 4E5EAE0A93 for ; Wed, 19 Aug 2020 21:31:08 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id ECB7934F07D for ; Wed, 19 Aug 2020 21:31:06 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 67A962FE for ; Wed, 19 Aug 2020 21:31:05 +0000 (UTC) From: "Thomas Deutschmann" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Thomas Deutschmann" Message-ID: <1597872574.848f9d5eb48f6fe7cf1d11a2ccb2df9198f474f1.whissi@gentoo> Subject: [gentoo-commits] proj/genkernel:master commit in: defaults/ X-VCS-Repository: proj/genkernel X-VCS-Files: defaults/initrd.scripts defaults/linuxrc X-VCS-Directories: defaults/ X-VCS-Committer: whissi X-VCS-Committer-Name: Thomas Deutschmann X-VCS-Revision: 848f9d5eb48f6fe7cf1d11a2ccb2df9198f474f1 X-VCS-Branch: master Date: Wed, 19 Aug 2020 21:31:05 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: f62e240d-70cc-49e9-acac-33c75a6092f9 X-Archives-Hash: 088f27170f0b7477292c2ace924dcf4d commit: 848f9d5eb48f6fe7cf1d11a2ccb2df9198f474f1 Author: Thomas Deutschmann gentoo org> AuthorDate: Wed Aug 19 21:29:34 2020 +0000 Commit: Thomas Deutschmann gentoo org> CommitDate: Wed Aug 19 21:29:34 2020 +0000 URL: https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=848f9d5e defaults/linuxrc: Process /etc/initramfs.mounts multiple times We need to mount mountpoints listed in /etc/initramfs.mounts before validating REAL_INIT in case init is located on seperate mount. In addition the code was moved to a dedicated function named process_initramfs_mounts() to allow to run it multiple times which is needed if REAL_INIT wasn't verified (in case system was booted from livecd). Link: https://forums.gentoo.org/viewtopic-t-1117762.html Signed-off-by: Thomas Deutschmann gentoo.org> defaults/initrd.scripts | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ defaults/linuxrc | 41 +++++++---------------------------------- 2 files changed, 56 insertions(+), 34 deletions(-) diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts index 14f3c4e..f34e5a3 100644 --- a/defaults/initrd.scripts +++ b/defaults/initrd.scripts @@ -1249,6 +1249,55 @@ preserve_log() { fi } +process_initramfs_mounts() { + local fslist= + + if [ -f "${NEW_ROOT}/etc/initramfs.mounts" ] + then + fslist="$(get_mounts_list)" + else + fslist="/usr" + fi + + local dev= fs= fstype= opts= mnt= cmd= + for fs in ${fslist} + do + mnt="${NEW_ROOT}${fs}" + if run mountpoint -q "${mnt}" + then + good_msg "${fs} already mounted, skipping..." + continue + fi + + dev=$(get_mount_device "${fs}") + [ -z "${dev}" ] && continue + # Resolve it like util-linux mount does + [ -L "${dev}" ] && dev=$(realpath "${dev}") + # In this case, it's probably part of the filesystem + # and not a mountpoint + [ -z "${dev}" ] && continue + + fstype=$(get_mount_fstype "${fs}") + if get_mount_options "${fs}" | grep -Fq bind + then + opts="bind" + dev="${NEW_ROOT}${dev}" + else + # ro must be trailing, and the options will always + # contain at least 'defaults' + opts="$(get_mount_options ${fs} | strip_mount_options)" + opts="${opts},ro" + fi + + cmd="mount -t ${fstype} -o ${opts} ${dev} ${mnt}" + good_msg "Mounting ${dev} as ${fs}: ${cmd}" + if ! run ${cmd} + then + bad_msg "Unable to mount ${dev} for ${fs}" + fi + done +} + prompt_user() { # $1 = variable whose value is the path (examples: "REAL_ROOT", # "LUKS_KEYDEV") diff --git a/defaults/linuxrc b/defaults/linuxrc index 3ca7e86..e0704f7 100644 --- a/defaults/linuxrc +++ b/defaults/linuxrc @@ -930,6 +930,11 @@ do # else not a good root and start over. if [ "${mountret}" = '0' ] then + # Make sure that entries from $NEWROOT/etc/initramfs.mounts + # are mounted before validating $REAL_INIT in case init isn't + # located on $REAL_ROOT. + process_initramfs_mounts + init_binary_file="${NEW_ROOT}${REAL_INIT:-/sbin/init}" init_binary_fallback_file="${NEW_ROOT}/bin/sh" @@ -1261,40 +1266,8 @@ else fi fi # if [ "${CDROOT}" = '1' ] -# Mount the additional things as required by udev & systemd -if [ -f ${NEW_ROOT}/etc/initramfs.mounts ] -then - fslist=$(get_mounts_list) -else - fslist="/usr" -fi - -for fs in ${fslist} -do - dev=$(get_mount_device ${fs}) - [ -z "${dev}" ] && continue - # Resolve it like util-linux mount does - [ -L ${dev} ] && dev=$(readlink ${dev}) - # In this case, it's probably part of the filesystem - # and not a mountpoint - [ -z "${dev}" ] && continue - fstype=$(get_mount_fstype ${fs}) - if get_mount_options ${fs} | grep -Fq bind - then - opts='bind' - dev=${NEW_ROOT}${dev} - else - # ro must be trailing, and the options will always contain at least 'defaults' - opts="$(get_mount_options ${fs} | strip_mount_options),ro" - fi - mnt=${NEW_ROOT}${fs} - cmd="mount -t ${fstype} -o ${opts} ${dev} ${mnt}" - good_msg "Mounting ${dev} as ${fs}: ${cmd}" - if ! ${cmd} - then - bad_msg "Unable to mount ${dev} for ${fs}" - fi -done # for fs in $fslist; do +# Re-run to ensure $NEWROOT/etc/initramfs.mounts was processed at least once +process_initramfs_mounts # Execute script on the cdrom just before boot to update things if necessary cdupdate