From: Harald Hoyer Date: Fri, 2 Dec 2011 15:47:24 +0000 (+0100) Subject: 99fs-lib/fs-lib.sh: accept "UUID=" and "LABEL=" for fsck_single X-Git-Tag: 014~4 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1939a4f96e8f0827964dd41c0b285e939b5e44c8;p=thirdparty%2Fdracut.git 99fs-lib/fs-lib.sh: accept "UUID=" and "LABEL=" for fsck_single with the reuse of crypt-lib.sh devnames() and putting it in dracut-lib.sh, fsck_single() can use more generic names from /etc/fstab --- diff --git a/modules.d/90crypt/crypt-lib.sh b/modules.d/90crypt/crypt-lib.sh index 69f14d0f8..5d0b27213 100755 --- a/modules.d/90crypt/crypt-lib.sh +++ b/modules.d/90crypt/crypt-lib.sh @@ -100,43 +100,6 @@ test_dev() { return $ret } -# Get kernel name for given device. Device may be the name too (then the same -# is returned), a symlink (full path), UUID (prefixed with "UUID=") or label -# (prefixed with "LABEL="). If just a beginning of the UUID is specified or -# even an empty, function prints all device names which UUIDs match - every in -# single line. -# -# NOTICE: The name starts with "/dev/". -# -# Example: -# devnames UUID=123 -# May print: -# /dev/dm-1 -# /dev/sdb1 -# /dev/sdf3 -devnames() { - local dev="$1"; local d; local names - - case "$dev" in - UUID=*) - dev="$(foreach_uuid_until '! blkid -U $___' "${dev#UUID=}")" \ - && return 255 - [ -z "$dev" ] && return 255 - ;; - LABEL=*) dev="$(blkid -L "${dev#LABEL=}")" || return 255 ;; - /dev/?*) ;; - *) return 255 ;; - esac - - for d in $dev; do - names="$names -$(readlink -e -q "$d")" || return 255 - done - - echo "${names# -}" -} - # match_dev devpattern dev # # Returns true if 'dev' matches 'devpattern'. Both 'devpattern' and 'dev' are diff --git a/modules.d/99base/dracut-lib.sh b/modules.d/99base/dracut-lib.sh index 3a31dc4a5..e86d2097b 100755 --- a/modules.d/99base/dracut-lib.sh +++ b/modules.d/99base/dracut-lib.sh @@ -555,6 +555,44 @@ foreach_uuid_until() ( return 1 ) +# Get kernel name for given device. Device may be the name too (then the same +# is returned), a symlink (full path), UUID (prefixed with "UUID=") or label +# (prefixed with "LABEL="). If just a beginning of the UUID is specified or +# even an empty, function prints all device names which UUIDs match - every in +# single line. +# +# NOTICE: The name starts with "/dev/". +# +# Example: +# devnames UUID=123 +# May print: +# /dev/dm-1 +# /dev/sdb1 +# /dev/sdf3 +devnames() { + local dev="$1"; local d; local names + + case "$dev" in + UUID=*) + dev="$(foreach_uuid_until '! blkid -U $___' "${dev#UUID=}")" \ + && return 255 + [ -z "$dev" ] && return 255 + ;; + LABEL=*) dev="$(blkid -L "${dev#LABEL=}")" || return 255 ;; + /dev/?*) ;; + *) return 255 ;; + esac + + for d in $dev; do + names="$names +$(readlink -e -q "$d")" || return 255 + done + + echo "${names# +}" +} + + usable_root() { local _d [ -d $1 ] || return 1 diff --git a/modules.d/99fs-lib/fs-lib.sh b/modules.d/99fs-lib/fs-lib.sh index 772d5c060..6f2664aa1 100755 --- a/modules.d/99fs-lib/fs-lib.sh +++ b/modules.d/99fs-lib/fs-lib.sh @@ -184,7 +184,9 @@ fsck_single() { local _drv [ $# -lt 2 ] && return 255 - + # if UUID= marks more than one device, take only the first one + [ -e "$_dev" ] || _dev=$(devnames "$_dev"| while read line; do if [ -n "$line" ]; then echo $line; break;fi;done) + [ -e "$_dev" ] || return 255 _fs=$(det_fs "$_dev" "$_fs") fsck_able "$_fs" || return 255