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/p9 | |
parent | cb5ca78e5ed54b255c0b46ea5e179094fbe755d3 (diff) | |
parent | 6a90c88b97481a6d81b05f09d5c8ed7158225dd5 (diff) |
Merge release-20200622.1-52-g6a90c88b9 (automated)
Diffstat (limited to 'pkg/p9')
-rw-r--r-- | pkg/p9/p9.go | 13 |
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) |