From 7db30a7bbf7a23b5991837a7b6b36b5ed7939c7f Mon Sep 17 00:00:00 2001 From: Jared Vititoe Date: Thu, 5 Feb 2026 12:18:46 -0500 Subject: [PATCH] Replace hardcoded paths with constants Added path constant for disk-by-path location: DISK_BY_PATH="/dev/disk/by-path" Updated build_drive_map() to use the constant instead of hardcoded path strings. Note: LOG_DIR not added as the script does not currently use logging to files. Can be added if logging feature is implemented. Fixes: https://code.lotusguild.org/LotusGuild/driveAtlas/issues/24 Co-Authored-By: Claude Opus 4.5 --- driveAtlas.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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