summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorNicolas Lacasse <nlacasse@google.com>2019-03-04 16:56:11 -0800
committerShentubot <shentubot@google.com>2019-03-04 16:57:14 -0800
commit0d683c9961a6d39d06896a230b8d52edfcf6e0cc (patch)
tree9ecef3b8060465fc58cb8c6ee15f0e6148745246
parent662da3350cbf00f51c5a1dc7396910106c2555b8 (diff)
Make tmpfs respect MountNoATime now that fs.Handle is gone.
PiperOrigin-RevId: 236752802 Change-Id: I9e50600b2ae25d5f2ac632c4405a7a185bdc3c92
-rw-r--r--pkg/sentry/fs/tmpfs/file_regular.go2
-rw-r--r--pkg/sentry/fs/tmpfs/inode_file.go12
-rw-r--r--test/syscalls/linux/mount.cc4
3 files changed, 9 insertions, 9 deletions
diff --git a/pkg/sentry/fs/tmpfs/file_regular.go b/pkg/sentry/fs/tmpfs/file_regular.go
index 2c1eb0fd2..be6298130 100644
--- a/pkg/sentry/fs/tmpfs/file_regular.go
+++ b/pkg/sentry/fs/tmpfs/file_regular.go
@@ -44,7 +44,7 @@ type regularFileOperations struct {
// Read implements fs.FileOperations.Read.
func (r *regularFileOperations) Read(ctx context.Context, file *fs.File, dst usermem.IOSequence, offset int64) (int64, error) {
- return r.iops.read(ctx, dst, offset)
+ return r.iops.read(ctx, file, dst, offset)
}
// Write implements fs.FileOperations.Write.
diff --git a/pkg/sentry/fs/tmpfs/inode_file.go b/pkg/sentry/fs/tmpfs/inode_file.go
index 1cc972afa..5648ff8f4 100644
--- a/pkg/sentry/fs/tmpfs/inode_file.go
+++ b/pkg/sentry/fs/tmpfs/inode_file.go
@@ -250,7 +250,7 @@ func (*fileInodeOperations) StatFS(context.Context) (fs.Info, error) {
return fsInfo, nil
}
-func (f *fileInodeOperations) read(ctx context.Context, dst usermem.IOSequence, offset int64) (int64, error) {
+func (f *fileInodeOperations) read(ctx context.Context, file *fs.File, dst usermem.IOSequence, offset int64) (int64, error) {
var start time.Time
if fs.RecordWaitTime {
start = time.Now()
@@ -280,10 +280,12 @@ func (f *fileInodeOperations) read(ctx context.Context, dst usermem.IOSequence,
}
n, err := dst.CopyOutFrom(ctx, &fileReadWriter{f, offset})
- // Compare Linux's mm/filemap.c:do_generic_file_read() => file_accessed().
- f.attrMu.Lock()
- f.attr.AccessTime = ktime.NowFromContext(ctx)
- f.attrMu.Unlock()
+ if !file.Dirent.Inode.MountSource.Flags.NoAtime {
+ // Compare Linux's mm/filemap.c:do_generic_file_read() => file_accessed().
+ f.attrMu.Lock()
+ f.attr.AccessTime = ktime.NowFromContext(ctx)
+ f.attrMu.Unlock()
+ }
fs.IncrementWait(readWait, start)
return n, err
}
diff --git a/test/syscalls/linux/mount.cc b/test/syscalls/linux/mount.cc
index 76da8b75a..6bb4287a3 100644
--- a/test/syscalls/linux/mount.cc
+++ b/test/syscalls/linux/mount.cc
@@ -250,9 +250,7 @@ PosixErrorOr<absl::Time> ATime(absl::string_view file) {
return absl::TimeFromTimespec(s.st_atim);
}
-// FIXME: Disabled until tmpfs stops using Handle, as only the gofer
-// and host file system respect the MS_NOATIME flag.
-TEST(MountTest, DISABLED_MountNoAtime) {
+TEST(MountTest, MountNoAtime) {
SKIP_IF(!ASSERT_NO_ERRNO_AND_VALUE(HaveCapability(CAP_SYS_ADMIN)));
auto const dir = ASSERT_NO_ERRNO_AND_VALUE(TempPath::CreateDir());