mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
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
This commit is contained in:
+10
-3
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user