summaryrefslogtreecommitdiffhomepage
path: root/pkg/iovec/iovec.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/iovec/iovec.go')
-rw-r--r--pkg/iovec/iovec.go18
1 files changed, 6 insertions, 12 deletions
diff --git a/pkg/iovec/iovec.go b/pkg/iovec/iovec.go
index 0789c74bf..f6791060f 100644
--- a/pkg/iovec/iovec.go
+++ b/pkg/iovec/iovec.go
@@ -20,12 +20,8 @@ package iovec
import (
"golang.org/x/sys/unix"
- "gvisor.dev/gvisor/pkg/abi/linux"
)
-// MaxIovs is the maximum number of iovecs host platform can accept.
-var MaxIovs = linux.UIO_MAXIOV
-
// Builder is a builder for slice of unix.Iovec.
type Builder struct {
iovec []unix.Iovec
@@ -47,10 +43,10 @@ func (b *Builder) Add(buf []byte) {
b.addByAppend(buf)
return
}
- b.iovec = append(b.iovec, unix.Iovec{
- Base: &buf[0],
- Len: uint64(len(buf)),
- })
+
+ b.iovec = append(b.iovec, unix.Iovec{Base: &buf[0]})
+ b.iovec[len(b.iovec)-1].SetLen(len(buf))
+
// Keep the last buf if iovec is at max capacity. We will need to append to it
// for later bufs.
if len(b.iovec) == MaxIovs {
@@ -61,10 +57,8 @@ func (b *Builder) Add(buf []byte) {
func (b *Builder) addByAppend(buf []byte) {
b.overflow = append(b.overflow, buf...)
- b.iovec[len(b.iovec)-1] = unix.Iovec{
- Base: &b.overflow[0],
- Len: uint64(len(b.overflow)),
- }
+ b.iovec[len(b.iovec)-1] = unix.Iovec{Base: &b.overflow[0]}
+ b.iovec[len(b.iovec)-1].SetLen(len(b.overflow))
}
// Build returns the final Iovec slice. The length of returned iovec will not