summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/fsimpl/gofer/special_file.go
diff options
context:
space:
mode:
authorgVisor bot <gvisor-bot@google.com>2020-06-19 13:41:45 +0000
committergVisor bot <gvisor-bot@google.com>2020-06-19 13:41:45 +0000
commit6171e45f4a950ee210b8bf8a255c33e5219a932d (patch)
tree8e392b719739bcb141150f744d050ceeaabea0cb /pkg/sentry/fsimpl/gofer/special_file.go
parent9e921ea05447c2f2b19358f8dc9ce3c38a47f9b6 (diff)
parent6b69b955d7613ff391984661a7269eabc86020e3 (diff)
Merge release-20200608.0-92-g6b69b955d (automated)
Diffstat (limited to 'pkg/sentry/fsimpl/gofer/special_file.go')
-rw-r--r--pkg/sentry/fsimpl/gofer/special_file.go19
1 files changed, 5 insertions, 14 deletions
diff --git a/pkg/sentry/fsimpl/gofer/special_file.go b/pkg/sentry/fsimpl/gofer/special_file.go
index e6e29b329..a92008208 100644
--- a/pkg/sentry/fsimpl/gofer/special_file.go
+++ b/pkg/sentry/fsimpl/gofer/special_file.go
@@ -221,21 +221,12 @@ func (fd *specialFileFD) Seek(ctx context.Context, offset int64, whence int32) (
}
fd.mu.Lock()
defer fd.mu.Unlock()
- switch whence {
- case linux.SEEK_SET:
- // Use offset as given.
- case linux.SEEK_CUR:
- offset += fd.off
- default:
- // SEEK_END, SEEK_DATA, and SEEK_HOLE aren't supported since it's not
- // clear that file size is even meaningful for these files.
- return 0, syserror.EINVAL
- }
- if offset < 0 {
- return 0, syserror.EINVAL
+ newOffset, err := regularFileSeekLocked(ctx, fd.dentry(), fd.off, offset, whence)
+ if err != nil {
+ return 0, err
}
- fd.off = offset
- return offset, nil
+ fd.off = newOffset
+ return newOffset, nil
}
// Sync implements vfs.FileDescriptionImpl.Sync.