From 233b4380ad02bd6a4128ea20f12334df1395d7d2 Mon Sep 17 00:00:00 2001 From: Manu Gupta Date: Wed, 6 Apr 2022 17:17:04 -0700 Subject: [PATCH] Do not wrap errors from filepath and stat as they are already wrapped. Since errors from filepath and lstat are already wrapped, they do not need to be wrapped again. Wrapping them again will cause os.IsErrNotExist(err) to return false while some providers may want it to be true. Signed-off-by: Manu Gupta --- mountinfo/mounted_unix.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mountinfo/mounted_unix.go b/mountinfo/mounted_unix.go index 45ddad23..ba3c778b 100644 --- a/mountinfo/mounted_unix.go +++ b/mountinfo/mounted_unix.go @@ -33,13 +33,13 @@ func mountedByStat(path string) (bool, error) { func normalizePath(path string) (realPath string, err error) { if realPath, err = filepath.Abs(path); err != nil { - return "", fmt.Errorf("unable to get absolute path for %q: %w", path, err) + return "", err } if realPath, err = filepath.EvalSymlinks(realPath); err != nil { - return "", fmt.Errorf("failed to canonicalise path for %q: %w", path, err) + return "", err } if _, err := os.Stat(realPath); err != nil { - return "", fmt.Errorf("failed to stat target of %q: %w", path, err) + return "", err } return realPath, nil }