From patchwork Thu Aug 4 20:11:15 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Milan Kupcevic X-Patchwork-Id: 108567 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from ozlabs.org (localhost [IPv6:::1]) by ozlabs.org (Postfix) with ESMTP id 0138DB71C3 for ; Fri, 5 Aug 2011 06:48:31 +1000 (EST) Received: from mail.physics.harvard.edu (bait.physics.harvard.edu [128.103.101.13]) by ozlabs.org (Postfix) with ESMTP id 5A3DAB6F88 for ; Fri, 5 Aug 2011 06:48:29 +1000 (EST) Received: from [140.247.79.164] (helo=black.newton.home) by mail.physics.harvard.edu with esmtpsa (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from ) id 1Qp4GT-0004ab-B6; Thu, 04 Aug 2011 16:11:33 -0400 Received: from mico by black.newton.home with local (Exim 4.72) (envelope-from ) id 1Qp4GS-0003QU-Sn; Thu, 04 Aug 2011 16:11:32 -0400 From: Milan Kupcevic To: yaboot-devel@lists.ozlabs.org Subject: [PATCH 2/2] Support persistent device naming symlinks, UUID, and LABEL tags Date: Thu, 4 Aug 2011 16:11:15 -0400 Message-Id: <1312488675-13139-2-git-send-email-milan@physics.harvard.edu> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1312488675-13139-1-git-send-email-milan@physics.harvard.edu> References: <1312488675-13139-1-git-send-email-milan@physics.harvard.edu> X-BeenThere: yaboot-devel@lists.ozlabs.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Technical and development discussion regarding yaboot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: yaboot-devel-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: yaboot-devel-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Support persistent device naming symlinks, UUID, and LABEL tags in addition to openfirmware paths and aliases as traditional Unix block device names are not persistent anymore. Signed-off-by: Milan Kupcevic --- ybin/yabootconfig | 27 ++++++++++++++++++++++++--- ybin/ybin | 6 ++++++ 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/ybin/yabootconfig b/ybin/yabootconfig index 04a513c..4629e10 100755 --- a/ybin/yabootconfig +++ b/ybin/yabootconfig @@ -27,7 +27,7 @@ if [ -n "$PATH_PREFIX" ] ; then PATH="${PATH}:${PATH_PREFIX}/sbin:${PATH_PREFIX}/bin:${PATH_PREFIX}/usr/sbin:${PATH_PREFIX}/usr/bin:${PATH_PREFIX}/usr/local/sbin:${PATH_PREFIX}/usr/local/bin" fi PRG="${0##*/}" -VERSION=1.0.8 +VERSION=1.0.8+debian2 CHROOT=/ ## $CONFIG is relative to $CHROOT CONFIG=etc/yaboot.conf @@ -732,6 +732,27 @@ if [ -n "$INITRDIMG" ] ; then INITRDIMGS="\tinitrd=$INITRDIMG\n\tinitrd-size=8192\n" fi +## Get a symlink which always points to the correct block device. +## If it does not exist, give the unix block device name back. +devsymlink() { + [ "$2" != "nobyid" ] && BYID="/dev/disk/by-id/scsi* /dev/disk/by-id/*" + for SYMLINK in $BYID /dev/disk/by-uuid/* /dev/disk/by-label/*; do + [ "`readlink -f "$SYMLINK"`" = "$1" ] && { + echo $SYMLINK + return + } + done + echo $1 +} + +## Get UUID= or LABEL= for the given unix partition block device. +## If it could not be determined, give the unix partition block device back. +uuidlabel() { + echo `devsymlink "$1" nobyid` \ + | sed -e "s,/dev/disk/by-uuid/,UUID=," \ + -e "s,/dev/disk/by-label/,LABEL=," +} + ## generate global section of yaboot.conf GLOBAL="## yaboot.conf generated by $PRG $VERSION ## @@ -739,9 +760,9 @@ GLOBAL="## yaboot.conf generated by $PRG $VERSION ${HEADER}## ## For a dual-boot menu, add one or more of: ## bsd=/dev/hdaX, macos=/dev/hdaY, macosx=/dev/hdaZ\n -boot=${BOOT}${DEVICE:-} +boot=\"`devsymlink "${BOOT}"`\"${DEVICE:-} partition=$PARTITION -root=$ROOT +root=\"`uuidlabel "${ROOT}"`\" timeout=30 install=${INSTALL}${OFBOOT:-}\n" diff --git a/ybin/ybin b/ybin/ybin index 44e63f4..cbc14f4 100755 --- a/ybin/ybin +++ b/ybin/ybin @@ -1641,6 +1641,12 @@ if [ "$boot" = unconfigured ] ; then exit 1 fi +## also accept quoted symlink names +for v in boot bsd macos macosx darwin ; do + eval $v="\`echo \$$v | tr -d '\"'\`" + eval [ -h \"\$$v\" ] \&\& $v="\`readlink -f \$$v\`" +done + ## if there is still no config file use the automatic generation to make a ## generic yaboot.conf. do this before the confcheck to avoid wierd errors. if [ "$bootconf" = /dev/null ] ; then