summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/fs/fsutil/file.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/sentry/fs/fsutil/file.go')
-rw-r--r--pkg/sentry/fs/fsutil/file.go35
1 files changed, 23 insertions, 12 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)
+}