From: "Leonid Krivoshein" <klark.devel@gmail.com>
To: make-initrd@lists.altlinux.org
Subject: [make-initrd] [PATCH v6 07/22] bootchain-waitdev: added optional prefix CDROM: to device spec
Date: Sun, 24 Oct 2021 17:20:57 -0000
Message-ID: <20211024172057.Bd5NQlzFqkj5mrrpe5U0JKxQkiYm_2pEB5BJV-V3sic@z> (raw)
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 <klark.devel@gmail.com>
---
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
reply other threads:[~2021-10-24 17:20 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211024172057.Bd5NQlzFqkj5mrrpe5U0JKxQkiYm_2pEB5BJV-V3sic@z \
--to=klark.devel@gmail.com \
--cc=make-initrd@lists.altlinux.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Make-initrd development discussion
This inbox may be cloned and mirrored by anyone:
git clone --mirror http://lore.altlinux.org/make-initrd/0 make-initrd/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 make-initrd make-initrd/ http://lore.altlinux.org/make-initrd \
make-initrd@lists.altlinux.org make-initrd@lists.altlinux.ru make-initrd@lists.altlinux.com
public-inbox-index make-initrd
Example config snippet for mirrors.
Newsgroup available over NNTP:
nntp://lore.altlinux.org/org.altlinux.lists.make-initrd
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git