From 0050e3e71cd07e6ed7cdf08784c042f7c067a5ff Mon Sep 17 00:00:00 2001 From: Nicolas Lacasse Date: Mon, 20 Aug 2018 11:18:06 -0700 Subject: 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 --- pkg/sentry/fs/sys/devices.go | 16 +++++++++++++--- 1 file 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 { -- cgit v1.2.3