summaryrefslogtreecommitdiffhomepage
path: root/pkg/safemem
diff options
context:
space:
mode:
authorgVisor bot <gvisor-bot@google.com>2020-02-04 19:43:45 +0000
committergVisor bot <gvisor-bot@google.com>2020-02-04 19:43:45 +0000
commit44d86281bb85a0f60d4952c16ad15159831c7b45 (patch)
tree40fb73c7606e3a761c2b775193a6361868a68d7a /pkg/safemem
parent9bd06563049671dbc979ce25ca931a1dfd906570 (diff)
parent492229d0176c1af2ab4ea4cf91bf211e940b5b12 (diff)
Merge release-20200127.0-59-g492229d (automated)
Diffstat (limited to 'pkg/safemem')
-rwxr-xr-xpkg/safemem/seq_unsafe.go17
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
+}