From ec45d969236bb98a83e7da0466bd67e540c5e8b5 Mon Sep 17 00:00:00 2001 From: Ayush Ranjan Date: Mon, 15 Mar 2021 16:38:46 -0700 Subject: [op] Make gofer client handle return partial write length when err is nil. If there was a partial write (when not using the host FD) which did not generate an error, we were incorrectly returning the number of bytes attempted to write instead of the number of bytes actually written. PiperOrigin-RevId: 363058989 --- pkg/sentry/fsimpl/gofer/handle.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'pkg/sentry/fsimpl') diff --git a/pkg/sentry/fsimpl/gofer/handle.go b/pkg/sentry/fsimpl/gofer/handle.go index 0bc201d1c..5c57f6fea 100644 --- a/pkg/sentry/fsimpl/gofer/handle.go +++ b/pkg/sentry/fsimpl/gofer/handle.go @@ -124,8 +124,9 @@ func (h *handle) writeFromBlocksAt(ctx context.Context, srcs safemem.BlockSeq, o return 0, cperr } n, err := h.file.writeAt(ctx, buf[:cp], offset) + // err takes precedence over cperr. if err != nil { return uint64(n), err } - return cp, cperr + return uint64(n), cperr } -- cgit v1.2.3