summaryrefslogtreecommitdiffhomepage
path: root/pkg
diff options
context:
space:
mode:
authorNicolas Lacasse <nlacasse@google.com>2018-08-20 11:18:06 -0700
committerShentubot <shentubot@google.com>2018-08-20 11:19:15 -0700
commit0050e3e71cd07e6ed7cdf08784c042f7c067a5ff (patch)
treec1d8704eee529a68547e64e8c721fd8192b3c008 /pkg
parent11800311a537bf1286f71ab419fa251a1e81e54f (diff)
sysfs: Add (empty) cpu directories for each cpu in /sys/devices/system/cpu.
Numpy needs these. Also added the "present" directory, since the contents are the same as possible and online. PiperOrigin-RevId: 209451777 Change-Id: I2048de3f57bf1c57e9b5421d607ca89c2a173684
Diffstat (limited to 'pkg')
-rw-r--r--pkg/sentry/fs/sys/devices.go16
1 files changed, 13 insertions, 3 deletions
diff --git a/pkg/sentry/fs/sys/devices.go b/pkg/sentry/fs/sys/devices.go
index 03eddeb93..2cf3a6f98 100644
--- a/pkg/sentry/fs/sys/devices.go
+++ b/pkg/sentry/fs/sys/devices.go
@@ -57,10 +57,20 @@ func newPossible(ctx context.Context, msrc *fs.MountSource) *fs.Inode {
}
func newCPU(ctx context.Context, msrc *fs.MountSource) *fs.Inode {
- return newDir(ctx, msrc, map[string]*fs.Inode{
- "possible": newPossible(ctx, msrc),
+ m := map[string]*fs.Inode{
"online": newPossible(ctx, msrc),
- })
+ "possible": newPossible(ctx, msrc),
+ "present": newPossible(ctx, msrc),
+ }
+
+ // Add directories for each of the cpus.
+ if k := kernel.KernelFromContext(ctx); k != nil {
+ for i := 0; uint(i) < k.ApplicationCores(); i++ {
+ m[fmt.Sprintf("cpu%d", i)] = newDir(ctx, msrc, nil)
+ }
+ }
+
+ return newDir(ctx, msrc, m)
}
func newSystemDir(ctx context.Context, msrc *fs.MountSource) *fs.Inode {