diff options
author | gVisor bot <gvisor-bot@google.com> | 2020-07-01 20:26:09 +0000 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-07-01 20:26:09 +0000 |
commit | 68f56161e21a352989caf23fb965ad82d9836622 (patch) | |
tree | ed6b8ef35e1ff9cc7a1b825df822d1abaeca8020 /pkg/sentry/fsimpl/tmpfs | |
parent | cb5ca78e5ed54b255c0b46ea5e179094fbe755d3 (diff) | |
parent | 6a90c88b97481a6d81b05f09d5c8ed7158225dd5 (diff) |
Merge release-20200622.1-52-g6a90c88b9 (automated)
Diffstat (limited to 'pkg/sentry/fsimpl/tmpfs')
-rw-r--r-- | pkg/sentry/fsimpl/tmpfs/regular_file.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/pkg/sentry/fsimpl/tmpfs/regular_file.go b/pkg/sentry/fsimpl/tmpfs/regular_file.go index b805aadd0..6691add96 100644 --- a/pkg/sentry/fsimpl/tmpfs/regular_file.go +++ b/pkg/sentry/fsimpl/tmpfs/regular_file.go @@ -274,6 +274,21 @@ func (fd *regularFileFD) Release() { // noop } +// Allocate implements vfs.FileDescriptionImpl.Allocate. +func (fd *regularFileFD) Allocate(ctx context.Context, mode, offset, length uint64) error { + f := fd.inode().impl.(*regularFile) + + f.inode.mu.Lock() + defer f.inode.mu.Unlock() + oldSize := f.size + size := offset + length + if oldSize >= size { + return nil + } + _, err := f.truncateLocked(size) + return err +} + // PRead implements vfs.FileDescriptionImpl.PRead. func (fd *regularFileFD) PRead(ctx context.Context, dst usermem.IOSequence, offset int64, opts vfs.ReadOptions) (int64, error) { if offset < 0 { |