summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry
diff options
context:
space:
mode:
authorAndrei Vagin <avagin@google.com>2019-06-21 17:24:11 -0700
committergVisor bot <gvisor-bot@google.com>2019-06-21 17:25:17 -0700
commitab6774cebf5c618d0cae579e84bd39666857f78b (patch)
tree1adedba5fd2cc33a7145a47f3fb173d0d1c2cd5d /pkg/sentry
parent6f933a934f715f4bcd4f4e4430d4040b6cf61032 (diff)
gvisor/fs: getdents returns 0 if offset is equal to FileMaxOffset
FileMaxOffset is a special case when lseek(d, 0, SEEK_END) has been called. PiperOrigin-RevId: 254498777
Diffstat (limited to 'pkg/sentry')
-rw-r--r--pkg/sentry/fs/dirent.go13
1 files changed, 10 insertions, 3 deletions
diff --git a/pkg/sentry/fs/dirent.go b/pkg/sentry/fs/dirent.go
index ca417d2bc..3cba259d9 100644
--- a/pkg/sentry/fs/dirent.go
+++ b/pkg/sentry/fs/dirent.go
@@ -948,9 +948,6 @@ func direntReaddir(ctx context.Context, d *Dirent, it DirIterator, root *Dirent,
if dirCtx.Serializer == nil {
panic("Dirent.Readdir: serializer must not be nil")
}
- if d.frozen {
- return d.readdirFrozen(root, offset, dirCtx)
- }
// Check that this is actually a directory before emitting anything.
// Once we have written entries for "." and "..", future errors from
@@ -959,6 +956,16 @@ func direntReaddir(ctx context.Context, d *Dirent, it DirIterator, root *Dirent,
return 0, syserror.ENOTDIR
}
+ // This is a special case for lseek(fd, 0, SEEK_END).
+ // See SeekWithDirCursor for more details.
+ if offset == FileMaxOffset {
+ return offset, nil
+ }
+
+ if d.frozen {
+ return d.readdirFrozen(root, offset, dirCtx)
+ }
+
// Collect attrs for "." and "..".
dot, dotdot := d.GetDotAttrs(root)