From 2aa8015bc4ff0bd61eca13eceb59aaa672335b76 Mon Sep 17 00:00:00 2001 From: Reid Wahl Date: Thu, 30 Aug 2018 18:36:11 -0700 Subject: [PATCH] Filesystem: Support symlink as mountpoint directory Filesystem monitor operation fails when the `directory` attribute is a symlink. The monitor operation calls the `list_mounts` function, which cats `/proc/mounts` if it exists, else cats `/etc/mtab` if it exists, else runs the `mount` command. It then greps for `" $MOUNTPOINT "` in the output, where `$MOUNTPOINT` is the value of the `directory` attribute. `/proc/mounts`, `/etc/mtab`, and the `mount` command resolve symlinks to their canonical targets. So while the monitor operation greps for the symlink path (surrounded by spaces) as defined in the directory attribute, the symlink will not be present in the `list_mounts` output. Only the symlink's target will be present. This patch uses `readlink -f $MOUNTPOINT` to resolve the symlink to its canonical name before using it as a grep pattern in the `Filesystem_status` function. --- heartbeat/Filesystem | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heartbeat/Filesystem b/heartbeat/Filesystem index 7c73b0b97..fc4b8fcd5 100755 --- a/heartbeat/Filesystem +++ b/heartbeat/Filesystem @@ -580,7 +580,7 @@ Filesystem_stop() # Filesystem_status() { - if list_mounts | grep -q " $MOUNTPOINT " >/dev/null 2>&1; then + if list_mounts | grep -q " $(readlink -f $MOUNTPOINT) " >/dev/null 2>&1; then rc=$OCF_SUCCESS msg="$MOUNTPOINT is mounted (running)" else