Skip to content

Commit

Permalink
filesystem: remove canonicalizePath() (#185)
Browse files Browse the repository at this point in the history
canonicalizePath() is now only used by an error path in
getMountFromLink(), which we can make use getDeviceName() instead.
  • Loading branch information
ebiggers authored and josephlr committed Jan 23, 2020
1 parent 303616d commit f2eb79f
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 19 deletions.
3 changes: 1 addition & 2 deletions filesystem/mountpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,9 +319,8 @@ func getMountFromLink(link string) (*Mount, error) {
}
mnt, ok := mountsByDevice[deviceNumber]
if !ok {
devicePath, _ := canonicalizePath(searchPath)
return nil, errors.Wrapf(ErrFollowLink, "no mounts for device %q (%v)",
devicePath, deviceNumber)
getDeviceName(deviceNumber), deviceNumber)
}
if mnt == nil {
return nil, filesystemRootDirNotVisibleError(deviceNumber)
Expand Down
17 changes: 0 additions & 17 deletions filesystem/path.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"fmt"
"log"
"os"
"path/filepath"

"golang.org/x/sys/unix"

Expand All @@ -41,22 +40,6 @@ func OpenFileOverridingUmask(name string, flag int, perm os.FileMode) (*os.File,
// We only check the unix permissions and the sticky bit
const permMask = os.ModeSticky | os.ModePerm

// canonicalizePath turns path into an absolute path without symlinks.
func canonicalizePath(path string) (string, error) {
path, err := filepath.Abs(path)
if err != nil {
return "", err
}
path, err = filepath.EvalSymlinks(path)

// Get a better error if we have an invalid path
if pathErr, ok := err.(*os.PathError); ok {
err = errors.Wrap(pathErr.Err, pathErr.Path)
}

return path, err
}

// loggedStat runs os.Stat, but it logs the error if stat returns any error
// other than nil or IsNotExist.
func loggedStat(name string) (os.FileInfo, error) {
Expand Down

0 comments on commit f2eb79f

Please sign in to comment.