diff options
author | Fabricio Voznika <fvoznika@google.com> | 2019-05-09 15:34:44 -0700 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2019-05-09 15:35:49 -0700 |
commit | 1bee43be13549b01e18d87df194ac219845de5cf (patch) | |
tree | 4b93064a7ec8b7de2cd515a692f11f0fc311b483 /pkg/sentry/fs/fsutil/host_mappable.go | |
parent | 0f4be95a336bd5dbf214bc40eb5d1bbb5fce36a4 (diff) |
Implement fallocate(2)
Closes #225
PiperOrigin-RevId: 247508791
Change-Id: I04f47cf2770b30043e5a272aba4ba6e11d0476cc
Diffstat (limited to 'pkg/sentry/fs/fsutil/host_mappable.go')
-rw-r--r-- | pkg/sentry/fs/fsutil/host_mappable.go | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/pkg/sentry/fs/fsutil/host_mappable.go b/pkg/sentry/fs/fsutil/host_mappable.go index 28686f3b3..ad0518b8f 100644 --- a/pkg/sentry/fs/fsutil/host_mappable.go +++ b/pkg/sentry/fs/fsutil/host_mappable.go @@ -149,7 +149,7 @@ func (h *HostMappable) Truncate(ctx context.Context, newSize int64) error { } // Invalidate COW mappings that may exist beyond the new size in case the file - // is being shrunk. Other mappinsg don't need to be invalidated because + // is being shrunk. Other mappings don't need to be invalidated because // translate will just return identical mappings after invalidation anyway, // and SIGBUS will be raised and handled when the mappings are touched. // @@ -167,6 +167,14 @@ func (h *HostMappable) Truncate(ctx context.Context, newSize int64) error { return nil } +// Allocate reserves space in the backing file. +func (h *HostMappable) Allocate(ctx context.Context, offset int64, length int64) error { + h.truncateMu.RLock() + err := h.backingFile.Allocate(ctx, offset, length) + h.truncateMu.RUnlock() + return err +} + // Write writes to the file backing this mappable. func (h *HostMappable) Write(ctx context.Context, src usermem.IOSequence, offset int64) (int64, error) { h.truncateMu.RLock() |