From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on sa.local.altlinux.org X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,MISSING_DATE,MISSING_MID, NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 From: "Leonid Krivoshein" To: make-initrd@lists.altlinux.org Subject: [make-initrd] [PATCH v6 07/22] bootchain-waitdev: added optional prefix CDROM: to device spec X-BeenThere: make-initrd@lists.altlinux.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: make-initrd@lists.altlinux.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Date: Sun, 24 Oct 2021 17:20:57 -0000 X-List-Received-Date: Sun, 24 Oct 2021 17:20:57 -0000 Message-ID: <20211024172057.Bd5NQlzFqkj5mrrpe5U0JKxQkiYm_2pEB5BJV-V3sic@z> Archived-At: List-Archive: At now, if a device is specified with a "CDROM:" prefix, only ISO-9660 file systems or those labeled "CD-ROM" are expected. If only the prefix is specified in the specification, the first available CD-ROM is expected. Signed-off-by: Leonid Krivoshein --- features/bootchain-core/README.md | 9 ++++++++- features/bootchain-waitdev/README.md | 9 +++++---- .../data/lib/uevent/filters/bootchain-waitdev | 19 ++++++++++++++++++- 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/features/bootchain-core/README.md b/features/bootchain-core/README.md index 7f12f1d..8d341e0 100644 --- a/features/bootchain-core/README.md +++ b/features/bootchain-core/README.md @@ -84,7 +84,14 @@ configurations with `root=pipeline`. on from the parameter. - run() - run an external command. -## Example +## Examples + +Cmdline: root=bootchain bootchain=waitdev,mountfs,mountfs,overlayfs,rootfs waitdev=CDROM:LABEL=ALT_regular-rescue/x86_64 mountfs=DEVNANE mountfs=rescue + +Following these parameters, the daemon waits for a local device with the +ISO-9660 file system and the volume label "ALT_regular-rescue/x86_64", mounts +this media, mounts the "rescue" file from it as squashfs of the root system, +makes it writable using overlayfs and tries to boot from it. Cmdline: root=pipeline pipeline=getimage,mountfs,overlayfs,rootfs getimage=http://ftp.altlinux.org/pub/people/mike/iso/misc/vi-20140918-i586.iso mountfs=rescue diff --git a/features/bootchain-waitdev/README.md b/features/bootchain-waitdev/README.md index bdf736e..126a904 100644 --- a/features/bootchain-waitdev/README.md +++ b/features/bootchain-waitdev/README.md @@ -10,13 +10,14 @@ feature. It allows to wait a specified block or character special devices. ## Boot parameters - `waitdev` describes the local device to wait. The format of this parameter is - the same as `root=`. This parameter can be specified more than once depending - on how many times a corresponding element is mentioned in the `bootchain`. + the same as `root=`, but with optional `CDROM:` prefix. This parameter can be + specified more than once depending on how many times a corresponding element + is mentioned in the `bootchain`. ## Example -Cmdline: root=bootchain bootchain=waitdev,mountfs,mountfs,overlayfs,rootfs waitdev=LABEL=ALT_regular-rescue/x86_64 mountfs=dev mountfs=rescue +Cmdline: root=bootchain bootchain=waitdev,mountfs,mountfs,overlayfs,rootfs waitdev=CDROM:LABEL=ALT_regular-rescue/x86_64 mountfs=dev mountfs=rescue -Following these parameters, the bootchain wait local disk drive labeled as +Following these parameters, the bootchain wait local CDROM drive labeled as "ALT_regular-rescue/x86_64", mount it, mount squash file "rescue" as a loop from it, make final rootfs writable using overlayfs and will try to boot from it. diff --git a/features/bootchain-waitdev/data/lib/uevent/filters/bootchain-waitdev b/features/bootchain-waitdev/data/lib/uevent/filters/bootchain-waitdev index 272aee7..8df8985 100755 --- a/features/bootchain-waitdev/data/lib/uevent/filters/bootchain-waitdev +++ b/features/bootchain-waitdev/data/lib/uevent/filters/bootchain-waitdev @@ -3,6 +3,23 @@ . /.initrd/initenv . initrd-sh-functions +get_dev_prefixed() +{ + local retval="$1" name="$2" + + case "$name" in + CDROM:*) + [ "${ID_CDROM-}" = 1 ] || + [ "${ID_FS_TYPE-}" = iso9660 ] || + return 1 + name="${name#CDROM:}" + name="${name:-/dev/sr0}" + ;; + esac + + get_dev "$retval" "$name" +} + mkdir -p -- /.initrd/bootchain/waitdev cd /.initrd/bootchain/waitdev/ @@ -10,7 +27,7 @@ i=0 while [ "$i" -lt "${WAITDEV:-0}" ]; do eval "spec=\"\${WAITDEV$i-}\"" - if [ -n "$spec" ] && get_dev dev "$spec"; then + if [ -n "$spec" ] && get_dev_prefixed dev "$spec"; then printf '%s\n' "$dev" > "$i" fi -- 2.24.1