MCPcopy
hub / github.com/google/gvisor / Seek

Method Seek

pkg/sentry/fsimpl/fuse/regular_file.go:90–111  ·  view source on GitHub ↗

Seek implements vfs.FileDescriptionImpl.Seek.

(ctx context.Context, offset int64, whence int32)

Source from the content-addressed store, hash-verified

88
89// Seek implements vfs.FileDescriptionImpl.Seek.
90func (fd *regularFileFD) Seek(ctx context.Context, offset int64, whence int32) (int64, error) {
91 fd.offMu.Lock()
92 defer fd.offMu.Unlock()
93 inode := fd.inode()
94 inode.attrMu.Lock()
95 defer inode.attrMu.Unlock()
96 switch whence {
97 case linux.SEEK_SET:
98 // use offset as specified
99 case linux.SEEK_CUR:
100 offset += fd.off
101 case linux.SEEK_END:
102 offset += int64(inode.size.Load())
103 default:
104 return 0, linuxerr.EINVAL
105 }
106 if offset < 0 {
107 return 0, linuxerr.EINVAL
108 }
109 fd.off = offset
110 return offset, nil
111}
112
113// PRead implements vfs.FileDescriptionImpl.PRead.
114func (fd *regularFileFD) PRead(ctx context.Context, dst usermem.IOSequence, offset int64, opts vfs.ReadOptions) (int64, error) {

Callers

nothing calls this directly

Calls 4

LockMethod · 0.65
UnlockMethod · 0.65
LoadMethod · 0.65
inodeMethod · 0.45

Tested by

no test coverage detected