2020-03-13 18:51:55 -04:00
|
|
|
package mount // import "github.com/docker/docker/pkg/mount"
|
|
|
|
|
2020-03-13 20:01:48 -04:00
|
|
|
// Deprecated: this package is not maintained and will be removed.
|
|
|
|
// Use github.com/moby/sys/mount and github.com/moby/sys/mountinfo instead.
|
|
|
|
|
2020-03-13 18:51:55 -04:00
|
|
|
import (
|
|
|
|
"github.com/moby/sys/mountinfo"
|
|
|
|
)
|
|
|
|
|
|
|
|
//nolint:golint
|
|
|
|
type (
|
2020-04-02 14:29:42 -04:00
|
|
|
// FilterFunc is a type.
|
|
|
|
// Deprecated: use github.com/moby/sys/mountinfo instead.
|
2020-10-06 08:43:29 -04:00
|
|
|
FilterFunc = func(*Info) (skip, stop bool)
|
|
|
|
|
|
|
|
// Info is a type
|
2020-04-02 14:29:42 -04:00
|
|
|
// Deprecated: use github.com/moby/sys/mountinfo instead.
|
2020-10-06 08:43:29 -04:00
|
|
|
Info struct {
|
|
|
|
ID, Parent, Major, Minor int
|
|
|
|
Root, Mountpoint, Opts, Optional, Fstype, Source, VfsOpts string
|
|
|
|
}
|
2020-03-13 18:51:55 -04:00
|
|
|
)
|
|
|
|
|
2020-03-13 20:01:48 -04:00
|
|
|
// Deprecated: use github.com/moby/sys/mountinfo instead.
|
2020-03-13 18:51:55 -04:00
|
|
|
//nolint:golint
|
|
|
|
var (
|
2020-10-06 08:43:29 -04:00
|
|
|
Mounted = mountinfo.Mounted
|
2020-03-13 18:51:55 -04:00
|
|
|
PrefixFilter = mountinfo.PrefixFilter
|
|
|
|
SingleEntryFilter = mountinfo.SingleEntryFilter
|
|
|
|
ParentsFilter = mountinfo.ParentsFilter
|
2020-09-16 04:27:03 -04:00
|
|
|
FstypeFilter = mountinfo.FSTypeFilter
|
2020-03-13 18:51:55 -04:00
|
|
|
)
|
2020-10-06 08:43:29 -04:00
|
|
|
|
|
|
|
// GetMounts is a function.
|
|
|
|
//
|
|
|
|
// Deprecated: use github.com/moby/sys/mountinfo.GetMounts() instead.
|
|
|
|
//nolint:golint
|
|
|
|
func GetMounts(f FilterFunc) ([]*Info, error) {
|
|
|
|
fi := func(i *mountinfo.Info) (skip, stop bool) {
|
|
|
|
return f(toLegacyInfo(i))
|
|
|
|
}
|
|
|
|
|
|
|
|
mounts, err := mountinfo.GetMounts(fi)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
mi := make([]*Info, len(mounts))
|
|
|
|
for i, m := range mounts {
|
|
|
|
mi[i] = toLegacyInfo(m)
|
|
|
|
}
|
|
|
|
return mi, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func toLegacyInfo(m *mountinfo.Info) *Info {
|
|
|
|
return &Info{
|
|
|
|
ID: m.ID,
|
|
|
|
Parent: m.Parent,
|
|
|
|
Major: m.Major,
|
|
|
|
Minor: m.Minor,
|
|
|
|
Root: m.Root,
|
|
|
|
Mountpoint: m.Mountpoint,
|
|
|
|
Opts: m.Options,
|
|
|
|
Fstype: m.FSType,
|
|
|
|
Source: m.Source,
|
|
|
|
VfsOpts: m.VFSOptions,
|
|
|
|
}
|
|
|
|
}
|