mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Include the cgroup name in the superblock options in /proc/self/mountinfo.
Java 11 parses /proc/self/mountinfo for cgroup information. Java 11.0.4 uses the mount path to determine what cgroups existed, but Java 11.0.5 reads the cgroup names from the superblock options. This CL adds the cgroup name to the superblock options if the filesystem type is "cgroup". Since gVisor doesn't actually support cgroups yet, we just infer the cgroup name from the path. PiperOrigin-RevId: 290434323
This commit is contained in:
committed by
gVisor bot
parent
47d85257d3
commit
10401599e1
@@ -18,6 +18,7 @@ import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"gvisor.dev/gvisor/pkg/sentry/context"
|
||||
"gvisor.dev/gvisor/pkg/sentry/fs"
|
||||
@@ -146,14 +147,35 @@ func (mif *mountInfoFile) ReadSeqFileData(ctx context.Context, handle seqfile.Se
|
||||
// (10) Mount source: filesystem-specific information or "none".
|
||||
fmt.Fprintf(&buf, "none ")
|
||||
|
||||
// (11) Superblock options. Only "ro/rw" is supported for now,
|
||||
// and is the same as the filesystem option.
|
||||
fmt.Fprintf(&buf, "%s\n", opts)
|
||||
// (11) Superblock options, and final newline.
|
||||
fmt.Fprintf(&buf, "%s\n", superBlockOpts(mountPath, mroot.Inode.MountSource))
|
||||
})
|
||||
|
||||
return []seqfile.SeqData{{Buf: buf.Bytes(), Handle: (*mountInfoFile)(nil)}}, 0
|
||||
}
|
||||
|
||||
func superBlockOpts(mountPath string, msrc *fs.MountSource) string {
|
||||
// gVisor doesn't (yet) have a concept of super block options, so we
|
||||
// use the ro/rw bit from the mount flag.
|
||||
opts := "rw"
|
||||
if msrc.Flags.ReadOnly {
|
||||
opts = "ro"
|
||||
}
|
||||
|
||||
// NOTE(b/147673608): If the mount is a cgroup, we also need to include
|
||||
// the cgroup name in the options. For now we just read that from the
|
||||
// path.
|
||||
// TODO(gvisor.dev/issues/190): Once gVisor has full cgroup support, we
|
||||
// should get this value from the cgroup itself, and not rely on the
|
||||
// path.
|
||||
if msrc.FilesystemType == "cgroup" {
|
||||
splitPath := strings.Split(mountPath, "/")
|
||||
cgroupType := splitPath[len(splitPath)-1]
|
||||
opts += "," + cgroupType
|
||||
}
|
||||
return opts
|
||||
}
|
||||
|
||||
// mountsFile is used to implement /proc/[pid]/mounts.
|
||||
//
|
||||
// +stateify savable
|
||||
|
||||
Reference in New Issue
Block a user