Store descriptions for DEVICE_TYPE_DISK and fix static-defaults mapping.
Add a default description for bhyve block disk device while we're here. Approved by: re (glebius)
This commit is contained in:
parent
77d24103c0
commit
6a1ba7cf53
@ -325,8 +325,13 @@ f_device_get_all()
|
||||
continue
|
||||
fi
|
||||
|
||||
f_device_register "$diskname" "" \
|
||||
"/dev/$diskname" $DEVICE_TYPE_DISK 0
|
||||
# Try and find its description
|
||||
f_device_desc "$diskname" $DEVICE_TYPE_DISK desc
|
||||
|
||||
f_device_register "$diskname" "$desc" \
|
||||
"/dev/$diskname" $DEVICE_TYPE_DISK 0 \
|
||||
"" "" "" "" \
|
||||
"$( f_device_capacity "$diskname" )"
|
||||
f_dprintf "Found a disk device named %s" "$diskname"
|
||||
|
||||
# Look for existing partitions to register
|
||||
@ -394,10 +399,27 @@ f_device_name_get()
|
||||
case "$__prop" in type|desc|max) : good ;;
|
||||
*) return $FAILURE; esac
|
||||
|
||||
#
|
||||
# Attempt to create an alternate-form of $__name that contains the
|
||||
# first contiguous string of numbers replaced with `%d' for comparison
|
||||
# against stored pattern names (see MAIN).
|
||||
#
|
||||
local __left="${__name%%[0-9]*}" __right="${__name#*[0-9]}" __dname=
|
||||
if [ "$__left" != "$__name" ]; then
|
||||
# Chop leading digits from right 'til we hit first non-digit
|
||||
while :; do
|
||||
case "$__right" in
|
||||
[0-9]*) __right="${__right#[0-9]}" ;;
|
||||
*) break
|
||||
esac
|
||||
done
|
||||
__dname="${__left}%d$__right"
|
||||
fi
|
||||
|
||||
[ "$__type" = "$DEVICE_TYPE_ANY" ] && __type=
|
||||
for __dev in $DEVICE_NAMES; do
|
||||
__n=$(( $__n + 1 ))
|
||||
[ "$__dev" = "$__name" ] || continue
|
||||
[ "$__dev" = "$__name" -o "$__dev" = "$__dname" ] || continue
|
||||
f_getvar _device_type$__n __devtype
|
||||
[ "${__type:-$__devtype}" = "$__devtype" ] || continue
|
||||
f_getvar _device_$__prop$__n $__var_to_set
|
||||
@ -478,6 +500,39 @@ f_device_desc()
|
||||
fi
|
||||
fi
|
||||
|
||||
#
|
||||
# For disks, attempt to return camcontrol(8) descriptions.
|
||||
# Otherwise fall through to below static list.
|
||||
#
|
||||
f_have camcontrol &&
|
||||
[ "${__type:-$DEVICE_TYPE_DISK}" = "$DEVICE_TYPE_DISK" ] &&
|
||||
__cp=$( camcontrol devlist 2> /dev/null | awk -v disk="$__name" '
|
||||
$0~"(\\(|,)"disk"(,|\\))" {
|
||||
if (!match($0, "<[^>]+>")) next
|
||||
print substr($0, RSTART+1, RLENGTH-2)
|
||||
found = 1
|
||||
exit
|
||||
}
|
||||
END { exit ! found }
|
||||
' ) && setvar "$__var_to_set" "$__cp" && return $SUCCESS
|
||||
|
||||
#
|
||||
# Attempt to create an alternate-form of $__name that contains the
|
||||
# first contiguous string of numbers replaced with `%d' for comparison
|
||||
# against stored pattern names (see MAIN).
|
||||
#
|
||||
local __left="${__name%%[0-9]*}" __right="${__name#*[0-9]}" __dname=
|
||||
if [ "$__left" != "$__name" ]; then
|
||||
# Chop leading digits from right 'til we hit first non-digit
|
||||
while :; do
|
||||
case "$__right" in
|
||||
[0-9]*) __right="${__right#[0-9]}" ;;
|
||||
*) break
|
||||
esac
|
||||
done
|
||||
__dname="${__left}%d$__right"
|
||||
fi
|
||||
|
||||
local __dev __devtype __n=0
|
||||
for __dev in $DEVICE_NAMES; do
|
||||
__n=$(( $__n + 1 ))
|
||||
@ -487,11 +542,8 @@ f_device_desc()
|
||||
__devname=$( f_substr "$__name" 0 ${#__dev} )
|
||||
[ "$__devname" = "$__dev" ] || continue
|
||||
else
|
||||
__devname="${__name%%[0-9]*}"
|
||||
__devunit="${__name#$__devname}"
|
||||
__devunit="${__devunit%%[!0-9]*}"
|
||||
__devname=$( printf "$__dev" $__devunit )
|
||||
[ "$__devname" = "$__name" ] || continue
|
||||
[ "$__dev" = "$__name" -o "$__dev" = "$__dname" ] ||
|
||||
continue
|
||||
fi
|
||||
debug= f_getvar _device_desc$__n $__var_to_set
|
||||
return $?
|
||||
@ -714,6 +766,7 @@ f_disk "ipsd%d" "IBM ServeRAID RAID array" 4
|
||||
f_disk "mfid%d" "LSI MegaRAID SAS array" 4
|
||||
f_disk "mlxd%d" "Mylex RAID disk" 4
|
||||
f_disk "twed%d" "3ware ATA RAID array" 4
|
||||
f_disk "vtbd%d" "VirtIO Block Device" 16
|
||||
f_floppy "fd%d" "Floppy Drive unit A" 4
|
||||
f_serial "cuau%d" "%s on device %s (COM%d)" 16
|
||||
f_usb "da%da" "USB Mass Storage Device" 16
|
||||
|
Loading…
x
Reference in New Issue
Block a user