[make-initrd] [PATCH v6 07/22] bootchain-waitdev: added optional prefix CDROM: to device spec
Leonid Krivoshein
klark.devel at gmail.com
Sun Oct 24 20:20:57 MSK 2021
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 at 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
More information about the Make-initrd
mailing list