summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/fs/sys/sys.go
diff options
context:
space:
mode:
authorChenggang Qin <chenggang.qcg@gmail.com>2018-08-16 16:27:14 -0700
committerShentubot <shentubot@google.com>2018-08-16 16:28:14 -0700
commitaeec7a4c007ac53401e05bf72894a3b998eead95 (patch)
tree60277fb6794708073c26f14624d0c351b9e83479 /pkg/sentry/fs/sys/sys.go
parentfbd5df9c6fec9119c8036bf5664a27afb35a08ec (diff)
fs: Support possible and online knobs for cpu
Some linux commands depend on /sys/devices/system/cpu/possible, such as 'lscpu'. Add 2 knobs for cpu: /sys/devices/system/cpu/possible /sys/devices/system/cpu/online Both the values are '0 - Kernel.ApplicationCores()-1'. Change-Id: Iabd8a4e559cbb630ed249686b92c22b4e7120663 PiperOrigin-RevId: 209070163
Diffstat (limited to 'pkg/sentry/fs/sys/sys.go')
-rw-r--r--pkg/sentry/fs/sys/sys.go18
1 files changed, 15 insertions, 3 deletions
diff --git a/pkg/sentry/fs/sys/sys.go b/pkg/sentry/fs/sys/sys.go
index b9b2fb4a1..b1c3d48eb 100644
--- a/pkg/sentry/fs/sys/sys.go
+++ b/pkg/sentry/fs/sys/sys.go
@@ -22,13 +22,25 @@ import (
"gvisor.googlesource.com/gvisor/pkg/sentry/usermem"
)
+// sys is a root sys node.
+//
// +stateify savable
-type dir struct {
+type sys struct {
ramfs.Dir
}
+func newFile(node fs.InodeOperations, msrc *fs.MountSource) *fs.Inode {
+ sattr := fs.StableAttr{
+ DeviceID: sysfsDevice.DeviceID(),
+ InodeID: sysfsDevice.NextIno(),
+ BlockSize: usermem.PageSize,
+ Type: fs.SpecialFile,
+ }
+ return fs.NewInode(node, msrc, sattr)
+}
+
func newDir(ctx context.Context, msrc *fs.MountSource, contents map[string]*fs.Inode) *fs.Inode {
- d := &dir{}
+ d := &sys{}
d.InitDir(ctx, contents, fs.RootOwner, fs.FilePermsFromMode(0555))
return fs.NewInode(d, msrc, fs.StableAttr{
DeviceID: sysfsDevice.DeviceID(),
@@ -48,7 +60,7 @@ func New(ctx context.Context, msrc *fs.MountSource) *fs.Inode {
"bus": newDir(ctx, msrc, nil),
"class": newDir(ctx, msrc, nil),
"dev": newDir(ctx, msrc, nil),
- "devices": newDir(ctx, msrc, nil),
+ "devices": newDevicesDir(ctx, msrc),
"firmware": newDir(ctx, msrc, nil),
"fs": newDir(ctx, msrc, nil),
"kernel": newDir(ctx, msrc, nil),