diff options
author | Jamie Liu <jamieliu@google.com> | 2019-04-11 00:41:42 -0700 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2019-04-11 00:43:04 -0700 |
commit | 4209edafb6a9eeff8741a4360100557179b47b35 (patch) | |
tree | 95f392faead1f2b1ffb905e45521601a8520d113 /pkg/sentry/fs/proc/fds.go | |
parent | cc48969bb72e3efdc22746c5e7463b79b1942c2b (diff) |
Use open fids when fstat()ing gofer files.
PiperOrigin-RevId: 243018347
Change-Id: I1e5b80607c1df0747482abea61db7fcf24536d37
Diffstat (limited to 'pkg/sentry/fs/proc/fds.go')
-rw-r--r-- | pkg/sentry/fs/proc/fds.go | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/pkg/sentry/fs/proc/fds.go b/pkg/sentry/fs/proc/fds.go index 3c471bad9..939ebaba1 100644 --- a/pkg/sentry/fs/proc/fds.go +++ b/pkg/sentry/fs/proc/fds.go @@ -91,7 +91,7 @@ func readDescriptors(t *kernel.Task, c *fs.DirCtx, offset int64, toDentAttr func // fd implements fs.InodeOperations for a file in /proc/TID/fd/. type fd struct { ramfs.Symlink - *fs.File + file *fs.File } var _ fs.InodeOperations = (*fd)(nil) @@ -103,7 +103,7 @@ func newFd(t *kernel.Task, f *fs.File, msrc *fs.MountSource) *fs.Inode { fd := &fd{ // RootOwner overridden by taskOwnedInodeOps.UnstableAttrs(). Symlink: *ramfs.NewSymlink(t, fs.RootOwner, ""), - File: f, + file: f, } return newProcInode(fd, msrc, fs.Symlink, t) } @@ -112,8 +112,8 @@ func newFd(t *kernel.Task, f *fs.File, msrc *fs.MountSource) *fs.Inode { // arguments are ignored. func (f *fd) GetFile(context.Context, *fs.Dirent, fs.FileFlags) (*fs.File, error) { // Take a reference on the fs.File. - f.File.IncRef() - return f.File, nil + f.file.IncRef() + return f.file, nil } // Readlink returns the current target. @@ -122,14 +122,14 @@ func (f *fd) Readlink(ctx context.Context, _ *fs.Inode) (string, error) { if root != nil { defer root.DecRef() } - n, _ := f.Dirent.FullName(root) + n, _ := f.file.Dirent.FullName(root) return n, nil } // Getlink implements fs.InodeOperations.Getlink. func (f *fd) Getlink(context.Context, *fs.Inode) (*fs.Dirent, error) { - f.Dirent.IncRef() - return f.Dirent, nil + f.file.Dirent.IncRef() + return f.file.Dirent, nil } // Truncate is ignored. @@ -139,12 +139,12 @@ func (f *fd) Truncate(context.Context, *fs.Inode, int64) error { func (f *fd) Release(ctx context.Context) { f.Symlink.Release(ctx) - f.File.DecRef() + f.file.DecRef() } // Close releases the reference on the file. func (f *fd) Close() error { - f.DecRef() + f.file.DecRef() return nil } @@ -212,7 +212,8 @@ func (f *fdDir) GetFile(ctx context.Context, dirent *fs.Dirent, flags fs.FileFla // +stateify savable type fdDirFile struct { - fsutil.DirFileOperations `state:"nosave"` + fsutil.DirFileOperations `state:"nosave"` + fsutil.FileUseInodeUnstableAttr `state:"nosave"` isInfoFile bool |