From 68b72fc34496a48480e50c5e8e9ef367667e0a39 Mon Sep 17 00:00:00 2001 From: pnookala-px <127919775+pnookala-px@users.noreply.github.com> Date: Thu, 21 Mar 2024 11:18:40 +0530 Subject: [PATCH] PWX-36522: In case of devices use Exact match with mount and not a prefix match (#2431) (#2432) Signed-off-by: pnookala-px --- pkg/mount/mount.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/pkg/mount/mount.go b/pkg/mount/mount.go index ca3d344f5..c791bae03 100644 --- a/pkg/mount/mount.go +++ b/pkg/mount/mount.go @@ -365,7 +365,7 @@ func (m *Mounter) reload(device string, newM *Info) error { } // Purge old mounts. - logrus.Infof("Reload: Adding the device tuple {%v:%v] to mount table", device, newM.Fs) + logrus.Infof("Reload: Adding the device tuple [%v:%v] to mount table", device, newM.Fs) m.mounts[device] = newM return nil } @@ -384,12 +384,15 @@ func (m *Mounter) load(prefixes []*regexp.Regexp, fmp findMountPoint) error { foundPrefix, sourcePath, devicePath = fmp(v, devPrefix, info) targetDevice = getTargetDevice(devPrefix.String()) if !foundPrefix && targetDevice != "" { - foundTarget, _, _ = fmp(v, regexp.MustCompile(regexp.QuoteMeta(targetDevice)), info) - // We could not find a mountpoint for devPrefix (/dev/mapper/vg-lvm1) but found - // one for its target device (/dev/dm-0). Change the sourcePath to devPrefix - // as fmp might have returned an incorrect or empty sourcePath - sourcePath = devPrefix.String() - devicePath = devPrefix.String() + // This should be an Exact Match and not a prefix match. + if strings.EqualFold(targetDevice, v.Source) { + // We could not find a mountpoint for devPrefix (/dev/mapper/vg-lvm1) but found + // one for its target device (/dev/dm-0). Change the sourcePath to devPrefix + // as fmp might have returned an incorrect or empty sourcePath + sourcePath = devPrefix.String() + devicePath = devPrefix.String() + foundTarget = true + } } if foundPrefix || foundTarget {