summaryrefslogtreecommitdiffhomepage
path: root/pkg/p9/p9.go
diff options
context:
space:
mode:
authorZach Koopmans <zkoopmans@google.com>2020-07-01 13:13:04 -0700
committergVisor bot <gvisor-bot@google.com>2020-07-01 13:14:44 -0700
commit6a90c88b97481a6d81b05f09d5c8ed7158225dd5 (patch)
treee22db333e636d2dae96bcbf4f36d48eb81df3d0d /pkg/p9/p9.go
parent68e1c870d3ef5db71226927aee703f2fba61cab7 (diff)
Port fallocate to VFS2.
PiperOrigin-RevId: 319283715
Diffstat (limited to 'pkg/p9/p9.go')
-rw-r--r--pkg/p9/p9.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/pkg/p9/p9.go b/pkg/p9/p9.go
index 28d851ff5..122c457d2 100644
--- a/pkg/p9/p9.go
+++ b/pkg/p9/p9.go
@@ -1091,6 +1091,19 @@ type AllocateMode struct {
Unshare bool
}
+// ToAllocateMode returns an AllocateMode from a fallocate(2) mode.
+func ToAllocateMode(mode uint64) AllocateMode {
+ return AllocateMode{
+ KeepSize: mode&unix.FALLOC_FL_KEEP_SIZE != 0,
+ PunchHole: mode&unix.FALLOC_FL_PUNCH_HOLE != 0,
+ NoHideStale: mode&unix.FALLOC_FL_NO_HIDE_STALE != 0,
+ CollapseRange: mode&unix.FALLOC_FL_COLLAPSE_RANGE != 0,
+ ZeroRange: mode&unix.FALLOC_FL_ZERO_RANGE != 0,
+ InsertRange: mode&unix.FALLOC_FL_INSERT_RANGE != 0,
+ Unshare: mode&unix.FALLOC_FL_UNSHARE_RANGE != 0,
+ }
+}
+
// ToLinux converts to a value compatible with fallocate(2)'s mode.
func (a *AllocateMode) ToLinux() uint32 {
rv := uint32(0)