aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/moby/sys/mountinfo/mountinfo.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/moby/sys/mountinfo/mountinfo.go')
-rw-r--r--vendor/github.com/moby/sys/mountinfo/mountinfo.go23
1 files changed, 14 insertions, 9 deletions
diff --git a/vendor/github.com/moby/sys/mountinfo/mountinfo.go b/vendor/github.com/moby/sys/mountinfo/mountinfo.go
index 136b14167..1987fcbb2 100644
--- a/vendor/github.com/moby/sys/mountinfo/mountinfo.go
+++ b/vendor/github.com/moby/sys/mountinfo/mountinfo.go
@@ -1,6 +1,9 @@
package mountinfo
-import "io"
+import (
+ "io"
+ "os"
+)
// GetMounts retrieves a list of mounts for the current running process,
// with an optional filter applied (use nil for no filter).
@@ -16,15 +19,17 @@ func GetMountsFromReader(reader io.Reader, f FilterFunc) ([]*Info, error) {
return parseInfoFile(reader, f)
}
-// Mounted determines if a specified mountpoint has been mounted.
-// On Linux it looks at /proc/self/mountinfo.
-func Mounted(mountpoint string) (bool, error) {
- entries, err := GetMounts(SingleEntryFilter(mountpoint))
- if err != nil {
- return false, err
+// Mounted determines if a specified path is a mount point.
+//
+// The argument must be an absolute path, with all symlinks resolved, and clean.
+// One way to ensure it is to process the path using filepath.Abs followed by
+// filepath.EvalSymlinks before calling this function.
+func Mounted(path string) (bool, error) {
+ // root is always mounted
+ if path == string(os.PathSeparator) {
+ return true, nil
}
-
- return len(entries) > 0, nil
+ return mounted(path)
}
// Info reveals information about a particular mounted filesystem. This