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
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
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