github.com/pwn-term/docker@v0.0.0-20210616085119-6e977cce2565/moby/pkg/mount/deprecated.go (about)

     1  package mount // import "github.com/docker/docker/pkg/mount"
     2  
     3  // Deprecated: this package is not maintained and will be removed.
     4  // Use github.com/moby/sys/mount and github.com/moby/sys/mountinfo instead.
     5  
     6  import (
     7  	"github.com/moby/sys/mountinfo"
     8  )
     9  
    10  //nolint:golint
    11  type (
    12  	// FilterFunc is a type.
    13  	// Deprecated: use github.com/moby/sys/mountinfo instead.
    14  	FilterFunc = func(*Info) (skip, stop bool)
    15  
    16  	// Info is a type
    17  	// Deprecated: use github.com/moby/sys/mountinfo instead.
    18  	Info struct {
    19  		ID, Parent, Major, Minor                                  int
    20  		Root, Mountpoint, Opts, Optional, Fstype, Source, VfsOpts string
    21  	}
    22  )
    23  
    24  // Deprecated: use github.com/moby/sys/mountinfo instead.
    25  //nolint:golint
    26  var (
    27  	Mounted           = mountinfo.Mounted
    28  	PrefixFilter      = mountinfo.PrefixFilter
    29  	SingleEntryFilter = mountinfo.SingleEntryFilter
    30  	ParentsFilter     = mountinfo.ParentsFilter
    31  	FstypeFilter      = mountinfo.FSTypeFilter
    32  )
    33  
    34  // GetMounts is a function.
    35  //
    36  // Deprecated: use github.com/moby/sys/mountinfo.GetMounts() instead.
    37  //nolint:golint
    38  func GetMounts(f FilterFunc) ([]*Info, error) {
    39  	fi := func(i *mountinfo.Info) (skip, stop bool) {
    40  		return f(toLegacyInfo(i))
    41  	}
    42  
    43  	mounts, err := mountinfo.GetMounts(fi)
    44  	if err != nil {
    45  		return nil, err
    46  	}
    47  	mi := make([]*Info, len(mounts))
    48  	for i, m := range mounts {
    49  		mi[i] = toLegacyInfo(m)
    50  	}
    51  	return mi, nil
    52  }
    53  
    54  func toLegacyInfo(m *mountinfo.Info) *Info {
    55  	return &Info{
    56  		ID:         m.ID,
    57  		Parent:     m.Parent,
    58  		Major:      m.Major,
    59  		Minor:      m.Minor,
    60  		Root:       m.Root,
    61  		Mountpoint: m.Mountpoint,
    62  		Opts:       m.Options,
    63  		Fstype:     m.FSType,
    64  		Source:     m.Source,
    65  		VfsOpts:    m.VFSOptions,
    66  	}
    67  }