From 57e275a08d46f976ab2a2edf9b7b507bbca1d1ca Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Fri, 2 Mar 2012 21:09:49 -0500 Subject: init_functions: lazily resolve UUID/LABEL tags Relying on blkid to do tag resolution will fail when the root device doesn't yet exist. This is, of course, bad for USB root devices. Signed-off-by: Dave Reisner --- init_functions | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'init_functions') diff --git a/init_functions b/init_functions index e9a0cb9..bf6f11a 100644 --- a/init_functions +++ b/init_functions @@ -154,16 +154,33 @@ fsck_root() { } resolve_device() { - local major minor dev device=$1 + local major minor dev tagval device=$1 + # do lazy resolution of devices by tag when udev is + # available. this allows us to wait on disks that + # might not show up immediately (e.g. USB). If udev + # isn't running, fall back on using blkid. case $device in - # resolve tag name to block device - UUID=*|LABEL=*) - dev=$(blkid -lt "$device" -o device) - [ -n "$device" ] && device=$dev + UUID=*) + tagval=${device#*=} + if [ "$udevd_running" -eq 1 ]; then + dev=/dev/disk/by-uuid/$tagval + else + dev=$(blkid -U "$tagval") + fi + ;; + LABEL=*) + tagval=${device#*=} + if [ "$udevd_running" -eq 1 ]; then + dev=/dev/disk/by-label/$tagval + else + dev=$(blkid -L "$tagval") + fi ;; esac + [ -n "$dev" ] && device=$dev + case $device in /dev/*) if poll_device "$device" "$rootdelay"; then -- cgit v1.2.3-24-g4f1b