-
Notifications
You must be signed in to change notification settings - Fork 0
/
deprecated.go
67 lines (59 loc) · 1.64 KB
/
deprecated.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package mount // import "github.com/docker/docker/pkg/mount"
// Deprecated: this package is not maintained and will be removed.
// Use github.com/moby/sys/mount and github.com/moby/sys/mountinfo instead.
import (
"github.com/moby/sys/mountinfo"
)
//nolint:golint
type (
// FilterFunc is a type.
// Deprecated: use github.com/moby/sys/mountinfo instead.
FilterFunc = func(*Info) (skip, stop bool)
// Info is a type
// Deprecated: use github.com/moby/sys/mountinfo instead.
Info struct {
ID, Parent, Major, Minor int
Root, Mountpoint, Opts, Optional, Fstype, Source, VfsOpts string
}
)
// Deprecated: use github.com/moby/sys/mountinfo instead.
//nolint:golint
var (
Mounted = mountinfo.Mounted
PrefixFilter = mountinfo.PrefixFilter
SingleEntryFilter = mountinfo.SingleEntryFilter
ParentsFilter = mountinfo.ParentsFilter
FstypeFilter = mountinfo.FSTypeFilter
)
// 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,
}
}