mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
pkg/mount: include optional field
one linux, the optional field designates the sharedsubtree information, if any. Signed-off-by: Vincent Batts <vbatts@redhat.com>
This commit is contained in:
parent
5b03a21963
commit
91b4ac320f
2 changed files with 12 additions and 7 deletions
|
@ -2,6 +2,6 @@ package mount
|
|||
|
||||
type MountInfo struct {
|
||||
Id, Parent, Major, Minor int
|
||||
Root, Mountpoint, Opts string
|
||||
Root, Mountpoint, Opts, Optional string
|
||||
Fstype, Source, VfsOpts string
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ const (
|
|||
(9) filesystem type: name of filesystem of the form "type[.subtype]"
|
||||
(10) mount source: filesystem specific information or "none"
|
||||
(11) super options: per super block options*/
|
||||
mountinfoFormat = "%d %d %d:%d %s %s %s "
|
||||
mountinfoFormat = "%d %d %d:%d %s %s %s %s"
|
||||
)
|
||||
|
||||
// Parse /proc/self/mountinfo because comparing Dev and ino does not work from bind mounts
|
||||
|
@ -51,11 +51,12 @@ func parseInfoFile(r io.Reader) ([]*MountInfo, error) {
|
|||
var (
|
||||
p = &MountInfo{}
|
||||
text = s.Text()
|
||||
optionalFields string
|
||||
)
|
||||
|
||||
if _, err := fmt.Sscanf(text, mountinfoFormat,
|
||||
&p.Id, &p.Parent, &p.Major, &p.Minor,
|
||||
&p.Root, &p.Mountpoint, &p.Opts); err != nil {
|
||||
&p.Root, &p.Mountpoint, &p.Opts, &optionalFields); err != nil {
|
||||
return nil, fmt.Errorf("Scanning '%s' failed: %s", text, err)
|
||||
}
|
||||
// Safe as mountinfo encodes mountpoints with spaces as \040.
|
||||
|
@ -65,6 +66,10 @@ func parseInfoFile(r io.Reader) ([]*MountInfo, error) {
|
|||
return nil, fmt.Errorf("Error found less than 3 fields post '-' in %q", text)
|
||||
}
|
||||
|
||||
if optionalFields != "-" {
|
||||
p.Optional = optionalFields
|
||||
}
|
||||
|
||||
p.Fstype = postSeparatorFields[0]
|
||||
p.Source = postSeparatorFields[1]
|
||||
p.VfsOpts = strings.Join(postSeparatorFields[2:], " ")
|
||||
|
|
Loading…
Reference in a new issue