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: #24

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-02-05 12:18:46 -05:00
parent 6dc0b00efd
commit 7db30a7bbf

View File

@@ -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