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 /runsc/fsgofer/fsgofer.go | |
parent | 0f4be95a336bd5dbf214bc40eb5d1bbb5fce36a4 (diff) |
Implement fallocate(2)
Closes #225
PiperOrigin-RevId: 247508791
Change-Id: I04f47cf2770b30043e5a272aba4ba6e11d0476cc
Diffstat (limited to 'runsc/fsgofer/fsgofer.go')
-rw-r--r-- | runsc/fsgofer/fsgofer.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/runsc/fsgofer/fsgofer.go b/runsc/fsgofer/fsgofer.go index 3a0806837..b185015b6 100644 --- a/runsc/fsgofer/fsgofer.go +++ b/runsc/fsgofer/fsgofer.go @@ -731,6 +731,18 @@ func (l *localFile) SetAttr(valid p9.SetAttrMask, attr p9.SetAttr) error { return err } +// Allocate implements p9.File. +func (l *localFile) Allocate(mode p9.AllocateMode, offset, length uint64) error { + if !l.isOpen() { + return syscall.EBADF + } + + if err := syscall.Fallocate(l.file.FD(), mode.ToLinux(), int64(offset), int64(length)); err != nil { + return extractErrno(err) + } + return nil +} + // Rename implements p9.File; this should never be called. func (l *localFile) Rename(p9.File, string) error { panic("rename called directly") |