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:
@@ -13,6 +13,12 @@ set -o pipefail
|
|||||||
|
|
||||||
VERSION="1.1.0"
|
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
|
# show_usage
|
||||||
#
|
#
|
||||||
@@ -619,8 +625,8 @@ build_drive_map() {
|
|||||||
[[ -z "$path" || -z "$slot" ]] && continue
|
[[ -z "$path" || -z "$slot" ]] && continue
|
||||||
|
|
||||||
BAY_TO_PCI_PATH[$slot]="$path"
|
BAY_TO_PCI_PATH[$slot]="$path"
|
||||||
if [[ -L "/dev/disk/by-path/$path" ]]; then
|
if [[ -L "${DISK_BY_PATH}/$path" ]]; then
|
||||||
local drive="$(readlink -f "/dev/disk/by-path/$path" | sed 's/.*\///')"
|
local drive="$(readlink -f "${DISK_BY_PATH}/$path" | sed 's/.*\///')"
|
||||||
DRIVE_MAP[$slot]="$drive"
|
DRIVE_MAP[$slot]="$drive"
|
||||||
((mapped_count++))
|
((mapped_count++))
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user