From 64de9165ba2e7479bac5b5b5758138f29ac87c3e Mon Sep 17 00:00:00 2001 From: pnookala-px Date: Wed, 20 Mar 2024 05:04:55 +0000 Subject: [PATCH] PWX-36522: In case of devices use Exact match with mount and not a prefix match 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 aa8c22ecd..e04cf7f34 100644 --- a/pkg/mount/mount.go +++ b/pkg/mount/mount.go @@ -368,7 +368,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 } @@ -387,12 +387,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 {