Better management of disks tools

* redirect disklabel, bioctl and atactl errors to stdin to be captured by $last_result
* ignore one of the errors in bioctl and atactl due to incompatible disk types
This commit is contained in:
Jérémy Dubois 2023-03-16 17:14:01 +01:00
parent b1642d39cb
commit 108e081464
2 changed files with 7 additions and 5 deletions

View file

@ -17,6 +17,8 @@ The **patch** part changes is incremented if multiple releases happen the same m
### Changed
* redirect disklabel errors to /dev/null
* redirect disklabel, bioctl and atactl errors to stdin to be captured by $last_result
* ignore one of the errors in bioctl and atactl due to incompatible disk types
### Fixed

View file

@ -293,7 +293,7 @@ task_disks() {
for disk in ${disks}; do
disklabel_bin=$(command -v disklabel)
if [ -n "${disklabel_bin}" ]; then
last_result=$(${disklabel_bin} "${disk}" 2>/dev/null > "${dump_dir}/partitions-${disk}")
last_result=$(${disklabel_bin} "${disk}" 2>&1 > "${dump_dir}/partitions-${disk}")
last_rc=$?
if [ ${last_rc} -eq 0 ]; then
@ -309,10 +309,10 @@ task_disks() {
bioctl_bin=$(command -v bioctl)
if [ -n "${bioctl_bin}" ]; then
last_result=$(${bioctl_bin} "${disk}" 2>/dev/null > "${dump_dir}/bioctl-${disk}")
last_result=$(${bioctl_bin} "${disk}" 2>&1 > "${dump_dir}/bioctl-${disk}")
last_rc=$?
if [ ${last_rc} -eq 0 ]; then
if [ ${last_rc} -eq 0 ] || { [ ${last_rc} -ne 0 ] && [ "${last_result}" = "bioctl: DIOCINQ: Inappropriate ioctl for device" ]; }; then
debug "* bioctl ${disk} OK"
else
debug "* bioctl ${disk} ERROR"
@ -325,10 +325,10 @@ task_disks() {
atactl_bin=$(command -v atactl)
if [ -n "${atactl_bin}" ]; then
last_result=$(${atactl_bin} "${disk}" 2>/dev/null > "${dump_dir}/atactl-${disk}")
last_result=$(${atactl_bin} "${disk}" 2>&1 > "${dump_dir}/atactl-${disk}")
last_rc=$?
if [ ${last_rc} -eq 0 ]; then
if [ ${last_rc} -eq 0 ] || { [ ${last_rc} -ne 0 ] && [ "${last_result}" = "atactl: ATA device returned error register 0" ]; }; then
debug "* atactl ${disk} OK"
else
debug "* atactl ${disk} ERROR"