File: deprecated.go

package info (click to toggle)
docker.io 20.10.24%2Bdfsg1-1%2Bdeb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 60,824 kB
  • sloc: sh: 5,621; makefile: 593; ansic: 179; python: 162; asm: 7
file content (69 lines) | stat: -rw-r--r-- 1,686 bytes parent folder | download | duplicates (2)
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
68
69
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,
	}
}