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

Method Allocate

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

Seek implements vfs.FileDescriptionImpl.Allocate.

(ctx context.Context, mode, offset, length uint64)

Source from the content-addressed store, hash-verified

59
60// Seek implements vfs.FileDescriptionImpl.Allocate.
61func (fd *regularFileFD) Allocate(ctx context.Context, mode, offset, length uint64) error {
62 if mode & ^uint64(linux.FALLOC_FL_KEEP_SIZE|linux.FALLOC_FL_PUNCH_HOLE|linux.FALLOC_FL_ZERO_RANGE) != 0 {
63 return linuxerr.EOPNOTSUPP
64 }
65 in := linux.FUSEFallocateIn{
66 Fh: fd.Fh,
67 Offset: uint64(offset),
68 Length: uint64(length),
69 Mode: uint32(mode),
70 }
71 i := fd.inode()
72 if err := i.call(ctx, linux.FUSE_FALLOCATE, &in, nil); err != nil {
73 return err
74 }
75 i.attrMu.Lock()
76 defer i.attrMu.Unlock()
77 if uint64(offset+length) > i.size.Load() {
78 if err := i.reviseAttr(ctx, linux.FUSE_GETATTR_FH, fd.Fh); err != nil {
79 return err
80 }
81 // If the offset after update is still too large, return error.
82 if uint64(offset) >= i.size.Load() {
83 return io.EOF
84 }
85 }
86 return nil
87}
88
89// Seek implements vfs.FileDescriptionImpl.Seek.
90func (fd *regularFileFD) Seek(ctx context.Context, offset int64, whence int32) (int64, error) {

Callers

nothing calls this directly

Calls 6

reviseAttrMethod · 0.80
LockMethod · 0.65
UnlockMethod · 0.65
LoadMethod · 0.65
inodeMethod · 0.45
callMethod · 0.45

Tested by

no test coverage detected