summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/fs/fsutil
diff options
context:
space:
mode:
authorJamie Liu <jamieliu@google.com>2019-04-11 00:41:42 -0700
committerShentubot <shentubot@google.com>2019-04-11 00:43:04 -0700
commit4209edafb6a9eeff8741a4360100557179b47b35 (patch)
tree95f392faead1f2b1ffb905e45521601a8520d113 /pkg/sentry/fs/fsutil
parentcc48969bb72e3efdc22746c5e7463b79b1942c2b (diff)
Use open fids when fstat()ing gofer files.
PiperOrigin-RevId: 243018347 Change-Id: I1e5b80607c1df0747482abea61db7fcf24536d37
Diffstat (limited to 'pkg/sentry/fs/fsutil')
-rw-r--r--pkg/sentry/fs/fsutil/file.go35
-rw-r--r--pkg/sentry/fs/fsutil/inode.go19
2 files changed, 33 insertions, 21 deletions
diff --git a/pkg/sentry/fs/fsutil/file.go b/pkg/sentry/fs/fsutil/file.go
index ce329b37a..df34dc788 100644
--- a/pkg/sentry/fs/fsutil/file.go
+++ b/pkg/sentry/fs/fsutil/file.go
@@ -224,7 +224,7 @@ func (FileNoIoctl) Ioctl(ctx context.Context, io usermem.IO, args arch.SyscallAr
}
// DirFileOperations implements most of fs.FileOperations for directories,
-// except for Readdir which the embedding type must implement.
+// except for Readdir and UnstableAttr which the embedding type must implement.
type DirFileOperations struct {
waiter.AlwaysReady
FileGenericSeek
@@ -250,7 +250,8 @@ func (*DirFileOperations) Write(context.Context, *fs.File, usermem.IOSequence, i
//
// +stateify savable
type StaticDirFileOperations struct {
- DirFileOperations
+ DirFileOperations `state:"nosave"`
+ FileUseInodeUnstableAttr `state:"nosave"`
// dentryMap is a SortedDentryMap used to implement Readdir.
dentryMap *fs.SortedDentryMap
@@ -291,16 +292,17 @@ func (sdfo *StaticDirFileOperations) Readdir(ctx context.Context, file *fs.File,
//
// +stateify savable
type NoReadWriteFile struct {
- waiter.AlwaysReady `state:"nosave"`
- FileGenericSeek `state:"nosave"`
- FileNoIoctl `state:"nosave"`
- FileNoMMap `state:"nosave"`
- FileNoopFsync `state:"nosave"`
- FileNoopFlush `state:"nosave"`
- FileNoopRelease `state:"nosave"`
- FileNoRead `state:"nosave"`
- FileNoWrite `state:"nosave"`
- FileNotDirReaddir `state:"nosave"`
+ waiter.AlwaysReady `state:"nosave"`
+ FileGenericSeek `state:"nosave"`
+ FileNoIoctl `state:"nosave"`
+ FileNoMMap `state:"nosave"`
+ FileNoopFsync `state:"nosave"`
+ FileNoopFlush `state:"nosave"`
+ FileNoopRelease `state:"nosave"`
+ FileNoRead `state:"nosave"`
+ FileNoWrite `state:"nosave"`
+ FileNotDirReaddir `state:"nosave"`
+ FileUseInodeUnstableAttr `state:"nosave"`
}
var _ fs.FileOperations = (*NoReadWriteFile)(nil)
@@ -365,3 +367,12 @@ type FileNoopRead struct{}
func (FileNoopRead) Read(context.Context, *fs.File, usermem.IOSequence, int64) (int64, error) {
return 0, nil
}
+
+// FileUseInodeUnstableAttr implements fs.FileOperations.UnstableAttr by calling
+// InodeOperations.UnstableAttr.
+type FileUseInodeUnstableAttr struct{}
+
+// UnstableAttr implements fs.FileOperations.UnstableAttr.
+func (FileUseInodeUnstableAttr) UnstableAttr(ctx context.Context, file *fs.File) (fs.UnstableAttr, error) {
+ return file.Dirent.Inode.UnstableAttr(ctx)
+}
diff --git a/pkg/sentry/fs/fsutil/inode.go b/pkg/sentry/fs/fsutil/inode.go
index 37490e5b2..468171a9b 100644
--- a/pkg/sentry/fs/fsutil/inode.go
+++ b/pkg/sentry/fs/fsutil/inode.go
@@ -238,15 +238,16 @@ func (i *InodeSimpleExtendedAttributes) Listxattr(_ *fs.Inode) (map[string]struc
//
// +stateify savable
type staticFile struct {
- waiter.AlwaysReady `state:"nosave"`
- FileGenericSeek `state:"nosave"`
- FileNoIoctl `state:"nosave"`
- FileNoMMap `state:"nosave"`
- FileNoopFsync `state:"nosave"`
- FileNoopFlush `state:"nosave"`
- FileNoopRelease `state:"nosave"`
- FileNoopWrite `state:"nosave"`
- FileNotDirReaddir `state:"nosave"`
+ waiter.AlwaysReady `state:"nosave"`
+ FileGenericSeek `state:"nosave"`
+ FileNoIoctl `state:"nosave"`
+ FileNoMMap `state:"nosave"`
+ FileNoopFsync `state:"nosave"`
+ FileNoopFlush `state:"nosave"`
+ FileNoopRelease `state:"nosave"`
+ FileNoopWrite `state:"nosave"`
+ FileNotDirReaddir `state:"nosave"`
+ FileUseInodeUnstableAttr `state:"nosave"`
FileStaticContentReader
}