[PATCH] 1/2 RFC: yaboot --bootonce (userspace)
Dustin Kirkland
dustin.kirkland at us.ibm.com
Tue Sep 19 08:07:25 EST 2006
This is a patch to ybin to allow a --bootonce parameter, such that a
user could specify a label to boot on the very next boot. As such,
support should not be required in the configuration file; the command
line should be sufficient--as this should be one-time and not persistent
functionality.
ybin currently uses dd to zero out 1600 blocks of size 512 bytes (a
little less than 8 megabytes). As the yaboot binary is currently
significantly less than 8 megabytes in size, there should easily be room
for this bootonce capability to use the 1600th block of the boot
partition.
The following patch:
- defines the --help documentation for the --bootonce paramter
- loosely checks (ie, greps) the configuration file for a matching label
- following the dd zero-out, then dd yaboot to the boot device, seeks
1599 blocks in and writes the --bootonce label to that block
Note that this patch could be applied without breaking any existing
functionality (with a disclaimer that the bootloader support required
for this feature is not yet completed). For this functionality to work,
the bootloader itself needs to read this label from the boot device,
clear it out, and boot that kernel. See the next patch for a stubbed
prototype.
A couple of brief test cases follow:
[root at beavis ybin]# ./ybin --help | grep bootonce
--bootonce label of entry to use ONLY on next boot
[root at beavis ybin]# ./ybin -v
ybin: Installing primary bootstrap /usr/local/lib/yaboot/yaboot
onto /dev/sda1...
ybin: Installation successful
[root at beavis ybin]# ./ybin -v --bootonce foobar
ybin: Installing primary bootstrap /usr/local/lib/yaboot/yaboot
onto /dev/sda1...
ybin: bootonce label [foobar] not found in /etc/yaboot.conf
ybin: Installation failed.
[root at beavis ybin]# ./ybin -v --bootonce foo
ybin: Installing primary bootstrap /usr/local/lib/yaboot/yaboot
onto /dev/sda1...
ybin: next reboot will boot the entry labeled [foo]
ybin: Installation successful
[root at beavis ybin]# dd if=/dev/sda1 bs=512 count=1 skip=1599
foo
Signed-off-by: Dustin Kirkland <dustin.kirkland at us.ibm.com>
--- yaboot.orig/ybin/ybin 2006-09-13 18:01:49.000000000 -0500
+++ yaboot.new/ybin/ybin 2006-09-18 16:59:59.000000000 -0500
@@ -85,6 +85,7 @@ protect=no
hide=no
nonvram=0
defaultos=linux
+bootonce=
brokenosx=no
cdrom=no
network=no
@@ -155,6 +156,7 @@ Update/install bootloader onto a bootstr
-b, --boot set bootstrap partition device [ -b /dev/hda2 ]
-o, --ofboot set bootstrap partition OpenFirmware device
default: automatically determined [ -o hd:2 ]
+ --bootonce label of entry to use ONLY on next boot
-i, --install pathname to the actual bootloader binary
default: /usr/{local/}lib/yaboot/yaboot same as
install= in config file [ -i bootloader_file ]
@@ -1148,6 +1150,17 @@ raw_install()
echo 1>&2 "$PRG: Installation failed."
return 1
fi
+ if [ "x$bootonce" != "x" ]; then
+ grep -q "label=$bootonce" $CONF 2> /dev/null
+ if [ $? = 0 ]; then
+ echo $bootonce | dd of="$boot" bs=512 count=1 seek=1599 > /dev/null 2>&1
+ [ "$VERBOSE" = 1 ] && echo "$PRG: next reboot will boot the entry labeled [$bootonce]"
+ else
+ echo 1>&2 "$PRG: bootonce label [$bootonce] not found in $CONF"
+ echo 1>&2 "$PRG: Installation failed."
+ return 1
+ fi
+ fi
sync ; sync
[ "$VERBOSE" = 1 ] && echo "$PRG: Installation successful"
}
@@ -1377,6 +1390,17 @@ if [ $# != 0 ] ; then
exit 1
fi
;;
+ --bootonce)
+ if [ -n "$2" ] ; then
+ bootonce="$2"
+ ARGS="$ARGS $1 $2"
+ shift 2
+ else
+ echo 1>&2 "$PRG: option requires an argument $1"
+ echo 1>&2 "Try \`$PRG --help' for more information."
+ exit 1
+ fi
+ ;;
-i|--install)
if [ -n "$2" ] ; then
install="$2"
More information about the Yaboot-devel
mailing list