diff --git a/driveAtlas.sh b/driveAtlas.sh index f5b453b..ca21c82 100644 --- a/driveAtlas.sh +++ b/driveAtlas.sh @@ -13,6 +13,12 @@ set -o pipefail VERSION="1.1.0" +#------------------------------------------------------------------------------ +# Path Constants +# Centralized path definitions to avoid hardcoding throughout the script +#------------------------------------------------------------------------------ +readonly DISK_BY_PATH="/dev/disk/by-path" + #------------------------------------------------------------------------------ # show_usage # @@ -619,8 +625,8 @@ build_drive_map() { [[ -z "$path" || -z "$slot" ]] && continue BAY_TO_PCI_PATH[$slot]="$path" - if [[ -L "/dev/disk/by-path/$path" ]]; then - local drive="$(readlink -f "/dev/disk/by-path/$path" | sed 's/.*\///')" + if [[ -L "${DISK_BY_PATH}/$path" ]]; then + local drive="$(readlink -f "${DISK_BY_PATH}/$path" | sed 's/.*\///')" DRIVE_MAP[$slot]="$drive" ((mapped_count++)) else