From 4ac34a143fd62c527600655a35f77fc2ff9df093 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/os as they are already wrapped. Since errors from filepath/ost 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 | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/mountinfo/mounted_unix.go b/mountinfo/mounted_unix.go index 45ddad23..242f82cc 100644 --- a/mountinfo/mounted_unix.go +++ b/mountinfo/mounted_unix.go @@ -4,7 +4,6 @@ package mountinfo import ( - "fmt" "os" "path/filepath" @@ -33,13 +32,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 }