diff options
author | gVisor bot <gvisor-bot@google.com> | 2020-02-04 19:43:45 +0000 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-02-04 19:43:45 +0000 |
commit | 44d86281bb85a0f60d4952c16ad15159831c7b45 (patch) | |
tree | 40fb73c7606e3a761c2b775193a6361868a68d7a /pkg/safemem | |
parent | 9bd06563049671dbc979ce25ca931a1dfd906570 (diff) | |
parent | 492229d0176c1af2ab4ea4cf91bf211e940b5b12 (diff) |
Merge release-20200127.0-59-g492229d (automated)
Diffstat (limited to 'pkg/safemem')
-rwxr-xr-x | pkg/safemem/seq_unsafe.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/pkg/safemem/seq_unsafe.go b/pkg/safemem/seq_unsafe.go index 354a95dde..dcdfc9600 100755 --- a/pkg/safemem/seq_unsafe.go +++ b/pkg/safemem/seq_unsafe.go @@ -18,6 +18,7 @@ import ( "bytes" "fmt" "reflect" + "syscall" "unsafe" ) @@ -297,3 +298,19 @@ func ZeroSeq(dsts BlockSeq) (uint64, error) { } return done, nil } + +// IovecsFromBlockSeq returns a []syscall.Iovec representing seq. +func IovecsFromBlockSeq(bs BlockSeq) []syscall.Iovec { + iovs := make([]syscall.Iovec, 0, bs.NumBlocks()) + for ; !bs.IsEmpty(); bs = bs.Tail() { + b := bs.Head() + iovs = append(iovs, syscall.Iovec{ + Base: &b.ToSlice()[0], + Len: uint64(b.Len()), + }) + // We don't need to care about b.NeedSafecopy(), because the host + // kernel will handle such address ranges just fine (by returning + // EFAULT). + } + return iovs +} |