disks: more rework

Signed-off-by: AuxXxilium <info@auxxxilium.tech>
This commit is contained in:
AuxXxilium 2024-05-06 23:47:28 +02:00
parent 224afdbee1
commit b72c1c88fb

View File

@ -313,7 +313,7 @@ function dtModel() {
} }
function nondtModel() { function nondtModel() {
if [ "${2}" = "force" ]; then if [ "${2}" = "true" ]; then
MAXDISKS=26 MAXDISKS=26
USBPORTCFG=0x00 USBPORTCFG=0x00
ESATAPORTCFG=0x00 ESATAPORTCFG=0x00
@ -340,7 +340,7 @@ function nondtModel() {
IDX=$(_atoi ${I/\/sys\/block\/sd/}) IDX=$(_atoi ${I/\/sys\/block\/sd/})
[ $((${IDX} + 1)) -ge ${MAXDISKS} ] && MAXDISKS=$((${IDX} + 1)) [ $((${IDX} + 1)) -ge ${MAXDISKS} ] && MAXDISKS=$((${IDX} + 1))
ISUSB="$(cat ${I}/uevent 2>/dev/null | grep PHYSDEVPATH | grep usb)" ISUSB="$(cat ${I}/uevent 2>/dev/null | grep PHYSDEVPATH | grep usb)"
if [ -n "${ISUSB}" ] && [ "${2}" = "true" ]; then if [ -n "${ISUSB}" ]; then
([ ${IDX} -lt ${USBMINIDX} ] || [ "${hasUSB}" = "false" ]) && USBMINIDX=${IDX} ([ ${IDX} -lt ${USBMINIDX} ] || [ "${hasUSB}" = "false" ]) && USBMINIDX=${IDX}
([ ${IDX} -gt ${USBMAXIDX} ] || [ "${hasUSB}" = "false" ]) && USBMAXIDX=${IDX} ([ ${IDX} -gt ${USBMAXIDX} ] || [ "${hasUSB}" = "false" ]) && USBMAXIDX=${IDX}
hasUSB=true hasUSB=true
@ -352,43 +352,48 @@ function nondtModel() {
[ $((${USBMINIDX} + ${USBDISKNUM})) -gt ${MAXDISKS} ] && MAXDISKS=$((${USBMINIDX} + ${USBDISKNUM})) [ $((${USBMINIDX} + ${USBDISKNUM})) -gt ${MAXDISKS} ] && MAXDISKS=$((${USBMINIDX} + ${USBDISKNUM}))
USBPORTCFG=$(($((2 ** ${MAXDISKS} - 1)) ^ $((2 ** ${USBMINIDX} - 1)))) USBPORTCFG=$(($((2 ** ${MAXDISKS} - 1)) ^ $((2 ** ${USBMINIDX} - 1))))
# Check for custom MAXDISKS
if _check_post_k "rd" "maxdisks"; then if _check_post_k "rd" "maxdisks"; then
MAXDISKS=$(($(_get_conf_kv maxdisks))) MAXDISKS=$(($(_get_conf_kv maxdisks)))
echo "get maxdisks=${MAXDISKS}" printf "get maxdisks=%d\n" "${MAXDISKS}"
else
# fix isSingleBay issue: if maxdisks is 1, there is no create button in the storage panel
# [ ${MAXDISKS} -le 2 ] && MAXDISKS=4
printf "cal maxdisks=%d\n" "${MAXDISKS}"
fi fi
# Check for custom USBPORTCFG
# # Raidtool will read maxdisks, but when maxdisks is greater than 27, formatting error will occur 8%.
# if ! _check_rootraidstatus && [ ${MAXDISKS} -gt 26 ]; then
# MAXDISKS=26
# printf "set maxdisks=26 [%d]\n" "${MAXDISKS}"
# fi
if _check_post_k "rd" "usbportcfg"; then if _check_post_k "rd" "usbportcfg"; then
USBPORTCFG=$(($(_get_conf_kv usbportcfg))) USBPORTCFG=$(($(_get_conf_kv usbportcfg)))
printf 'get usbportcfg=0x%.2x\n' "${USBPORTCFG}" printf 'get usbportcfg=0x%.2x\n' "${USBPORTCFG}"
else
USBPORTCFG=$(($((2 ** ${MAXDISKS} - 1)) ^ $((2 ** ${USBMINIDX} - 1))))
_set_conf_kv rd "usbportcfg" "$(printf '0x%.2x' ${USBPORTCFG})"
printf 'set usbportcfg=0x%.2x\n' "${USBPORTCFG}"
fi fi
# Check for custom ESATAPORTCFG
if _check_post_k "rd" "esataportcfg"; then if _check_post_k "rd" "esataportcfg"; then
ESATAPORTCFG=$(($(_get_conf_kv esataportcfg))) ESATAPORTCFG=$(($(_get_conf_kv esataportcfg)))
printf 'get esataportcfg=0x%.2x\n' "${ESATAPORTCFG}" printf 'get esataportcfg=0x%.2x\n' "${ESATAPORTCFG}"
else
_set_conf_kv rd "esataportcfg" "$(printf "0x%.2x" ${ESATAPORTCFG})"
printf 'set esataportcfg=0x%.2x\n' "${ESATAPORTCFG}"
fi fi
# Check for custom INTERNALPORTCFG
if _check_post_k "rd" "internalportcfg"; then if _check_post_k "rd" "internalportcfg"; then
INTERNALPORTCFG=$(($(_get_conf_kv internalportcfg))) INTERNALPORTCFG=$(($(_get_conf_kv internalportcfg)))
printf 'get internalportcfg=0x%.2x\n' "${INTERNALPORTCFG}" printf 'get internalportcfg=0x%.2x\n' "${INTERNALPORTCFG}"
else else
if [ "${2}" = "true" ]; then
INTERNALPORTCFG=$(($((2 ** ${MAXDISKS} - 1)) ^ ${USBPORTCFG} ^ ${ESATAPORTCFG})) INTERNALPORTCFG=$(($((2 ** ${MAXDISKS} - 1)) ^ ${USBPORTCFG} ^ ${ESATAPORTCFG}))
else
INTERNALPORTCFG=$((2 ** ${MAXDISKS} - 1))
fi
fi
# Set Maxdisks and Portconfig
_set_conf_kv rd "maxdisks" "${MAXDISKS}"
printf "set maxdisks=%d\n" "${MAXDISKS}"
_set_conf_kv rd "usbportcfg" "$(printf '0x%.2x' ${USBPORTCFG})"
printf 'set usbportcfg=0x%.2x\n' "${USBPORTCFG}"
_set_conf_kv rd "esataportcfg" "$(printf "0x%.2x" ${ESATAPORTCFG})"
printf 'set esataportcfg=0x%.2x\n' "${ESATAPORTCFG}"
_set_conf_kv rd "internalportcfg" "$(printf "0x%.2x" ${INTERNALPORTCFG})" _set_conf_kv rd "internalportcfg" "$(printf "0x%.2x" ${INTERNALPORTCFG})"
printf 'set internalportcfg=0x%.2x\n' "${INTERNALPORTCFG}" printf 'set internalportcfg=0x%.2x\n' "${INTERNALPORTCFG}"
fi fi
_set_conf_kv rd "maxdisks" "${MAXDISKS}"
printf "set maxdisks=%d\n" "${MAXDISKS}"
if [ "${1}" = "true" ]; then if [ "${1}" = "true" ]; then
echo "TODO: no-DT's sort!!!" echo "TODO: no-DT's sort!!!"
fi fi