From aeec7a4c007ac53401e05bf72894a3b998eead95 Mon Sep 17 00:00:00 2001 From: Chenggang Qin Date: Thu, 16 Aug 2018 16:27:14 -0700 Subject: 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 --- pkg/sentry/fs/sys/sys.go | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'pkg/sentry/fs/sys/sys.go') 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), -- cgit v1.2.3