diff options
author | Rahat Mahmood <rahat@google.com> | 2018-12-12 17:47:01 -0800 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2018-12-12 17:47:55 -0800 |
commit | ccce1d4281ce82fe551d7c8569fe3a545c62e296 (patch) | |
tree | cbcfbd64ba151097c5734102f6d1e1dfecdcd160 /pkg/sentry/fs/tmpfs/tmpfs.go | |
parent | f93c288dd70846f335239e2d0cb351135a756f51 (diff) |
Filesystems shouldn't be saving references to Platform.
Platform objects are not savable, storing references to them in
filesystem datastructures would cause save to fail if someone actually
passed in a Platform.
Current implementations work because everywhere a Platform is
expected, we currently pass in a Kernel object which embeds Platform
and thus satisfies the interface.
Eliminate this indirection and save pointers to Kernel directly.
PiperOrigin-RevId: 225288336
Change-Id: Ica399ff43f425e15bc150a0d7102196c3d54a2ab
Diffstat (limited to 'pkg/sentry/fs/tmpfs/tmpfs.go')
-rw-r--r-- | pkg/sentry/fs/tmpfs/tmpfs.go | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/pkg/sentry/fs/tmpfs/tmpfs.go b/pkg/sentry/fs/tmpfs/tmpfs.go index 91b782540..40a8c4b1e 100644 --- a/pkg/sentry/fs/tmpfs/tmpfs.go +++ b/pkg/sentry/fs/tmpfs/tmpfs.go @@ -20,8 +20,8 @@ import ( "gvisor.googlesource.com/gvisor/pkg/sentry/context" "gvisor.googlesource.com/gvisor/pkg/sentry/fs" "gvisor.googlesource.com/gvisor/pkg/sentry/fs/ramfs" + "gvisor.googlesource.com/gvisor/pkg/sentry/kernel" "gvisor.googlesource.com/gvisor/pkg/sentry/kernel/pipe" - "gvisor.googlesource.com/gvisor/pkg/sentry/platform" "gvisor.googlesource.com/gvisor/pkg/sentry/socket/unix/transport" "gvisor.googlesource.com/gvisor/pkg/sentry/usage" "gvisor.googlesource.com/gvisor/pkg/sentry/usermem" @@ -54,13 +54,13 @@ func rename(ctx context.Context, oldParent *fs.Inode, oldName string, newParent type Dir struct { ramfs.Dir - // platform is used to allocate storage for tmpfs Files. - platform platform.Platform + // kernel is used to allocate platform memory as storage for tmpfs Files. + kernel *kernel.Kernel } // NewDir returns a new directory. -func NewDir(ctx context.Context, contents map[string]*fs.Inode, owner fs.FileOwner, perms fs.FilePermissions, msrc *fs.MountSource, platform platform.Platform) *fs.Inode { - d := &Dir{platform: platform} +func NewDir(ctx context.Context, contents map[string]*fs.Inode, owner fs.FileOwner, perms fs.FilePermissions, msrc *fs.MountSource, kernel *kernel.Kernel) *fs.Inode { + d := &Dir{kernel: kernel} d.InitDir(ctx, contents, owner, perms) // Manually set the CreateOps. @@ -84,7 +84,7 @@ func (d *Dir) afterLoad() { func (d *Dir) newCreateOps() *ramfs.CreateOps { return &ramfs.CreateOps{ NewDir: func(ctx context.Context, dir *fs.Inode, perms fs.FilePermissions) (*fs.Inode, error) { - return NewDir(ctx, nil, fs.FileOwnerFromContext(ctx), perms, dir.MountSource, d.platform), nil + return NewDir(ctx, nil, fs.FileOwnerFromContext(ctx), perms, dir.MountSource, d.kernel), nil }, NewFile: func(ctx context.Context, dir *fs.Inode, perms fs.FilePermissions) (*fs.Inode, error) { uattr := fs.WithCurrentTime(ctx, fs.UnstableAttr{ @@ -93,7 +93,7 @@ func (d *Dir) newCreateOps() *ramfs.CreateOps { // Always start unlinked. Links: 0, }) - iops := NewInMemoryFile(ctx, usage.Tmpfs, uattr, d.platform) + iops := NewInMemoryFile(ctx, usage.Tmpfs, uattr, d.kernel) return fs.NewInode(iops, dir.MountSource, fs.StableAttr{ DeviceID: tmpfsDevice.DeviceID(), InodeID: tmpfsDevice.NextIno(), |