Skip to content

Commit

Permalink
Merge pull request #90 from kolyshkin/fix-mounted
Browse files Browse the repository at this point in the history
mountinfo.Mounted(): fix
  • Loading branch information
thaJeztah authored Nov 3, 2021
2 parents 1bcc0b1 + 90da438 commit 26b84be
Show file tree
Hide file tree
Showing 5 changed files with 316 additions and 228 deletions.
9 changes: 4 additions & 5 deletions mountinfo/mounted_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ func mountedByOpenat2(path string) (bool, error) {
Flags: unix.O_PATH | unix.O_CLOEXEC,
})
if err != nil {
if err == unix.ENOENT { // not a mount
return false, nil
}
return false, &os.PathError{Op: "openat2", Path: dir, Err: err}
}
fd, err := unix.Openat2(dirfd, last, &unix.OpenHow{
Expand All @@ -32,14 +29,16 @@ func mountedByOpenat2(path string) (bool, error) {
return false, nil
case unix.EXDEV: // definitely a mount
return true, nil
case unix.ENOENT: // not a mount
return false, nil
}
// not sure
return false, &os.PathError{Op: "openat2", Path: path, Err: err}
}

func mounted(path string) (bool, error) {
path, err := normalizePath(path)
if err != nil {
return false, err
}
// Try a fast path, using openat2() with RESOLVE_NO_XDEV.
mounted, err := mountedByOpenat2(path)
if err == nil {
Expand Down
Loading

0 comments on commit 26b84be

Please sign in to comment.