Skip to content

Commit ab4557d

Browse files
Update scripts/vm/hypervisor/kvm/kvmsmpheartbeat.sh
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent d30ca6e commit ab4557d

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

scripts/vm/hypervisor/kvm/kvmsmpheartbeat.sh

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,25 @@ then
7474
help
7575
fi
7676

77-
# Ensure mount point exists and is writable
77+
# Validate mount point exists, is (if possible) a mounted filesystem, and is writable
7878
if [ ! -d "$MountPoint" ]; then
79-
mkdir -p "$MountPoint" 2>/dev/null
80-
if [ $? -ne 0 ]; then
81-
echo "Failed to create mount point directory: $MountPoint" >&2
79+
echo "Mount point directory does not exist: $MountPoint" >&2
80+
exit 1
81+
fi
82+
83+
# If the 'mountpoint' utility is available, ensure this is an actual mount
84+
if command -v mountpoint >/dev/null 2>&1; then
85+
if ! mountpoint -q "$MountPoint"; then
86+
echo "Mount point is not a mounted filesystem: $MountPoint" >&2
8287
exit 1
8388
fi
8489
fi
8590

91+
# Ensure the mount point is writable
92+
if [ ! -w "$MountPoint" ]; then
93+
echo "Mount point is not writable: $MountPoint" >&2
94+
exit 1
95+
fi
8696
#delete VMs on this mountpoint (best-effort)
8797
deleteVMs() {
8898
local mountPoint=$1

0 commit comments

Comments
 (0)