diff options
author | gVisor bot <gvisor-bot@google.com> | 2020-01-09 01:36:28 +0000 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-01-09 01:36:28 +0000 |
commit | 9f0ece5764268caa351cbf455cf2d85aa5489137 (patch) | |
tree | e7d68b5b9e95bd830ea8d092c373824b2a43411b /pkg/sentry/socket/unix/io.go | |
parent | a260570ae4d32ed6feb092309dc33bdc8514c83d (diff) | |
parent | fbb2c008e26a7e9d860f6cbf796ea7c375858502 (diff) |
Merge release-20191213.0-82-gfbb2c00 (automated)
Diffstat (limited to 'pkg/sentry/socket/unix/io.go')
-rw-r--r-- | pkg/sentry/socket/unix/io.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/pkg/sentry/socket/unix/io.go b/pkg/sentry/socket/unix/io.go index 2ec1a662d..2447f24ef 100644 --- a/pkg/sentry/socket/unix/io.go +++ b/pkg/sentry/socket/unix/io.go @@ -83,6 +83,19 @@ type EndpointReader struct { ControlTrunc bool } +// Truncate calls RecvMsg on the endpoint without writing to a destination. +func (r *EndpointReader) Truncate() error { + // Ignore bytes read since it will always be zero. + _, ms, c, ct, err := r.Endpoint.RecvMsg(r.Ctx, [][]byte{}, r.Creds, r.NumRights, r.Peek, r.From) + r.Control = c + r.ControlTrunc = ct + r.MsgSize = ms + if err != nil { + return err.ToError() + } + return nil +} + // ReadToBlocks implements safemem.Reader.ReadToBlocks. func (r *EndpointReader) ReadToBlocks(dsts safemem.BlockSeq) (uint64, error) { return safemem.FromVecReaderFunc{func(bufs [][]byte) (int64, error) { |