From 06336fb26da5dd29f920ac2498cb09f4acbbcf59 Mon Sep 17 00:00:00 2001 From: Alfred Perlstein Date: Thu, 26 Apr 2001 00:14:14 +0000 Subject: [PATCH] Sendfile is documented to return 0 on success, however if when a sf_hdtr is used to provide writev(2) style headers/trailers on the sent data the return value is actually either the result of writev(2) from the trailers or headers of no tailers are specified. Fix sendfile to comply with the documentation, by returning 0 on success. Ok'd by: dg --- sys/kern/uipc_syscalls.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c index 33f7902916b6..74e1dc6bf1ba 100644 --- a/sys/kern/uipc_syscalls.c +++ b/sys/kern/uipc_syscalls.c @@ -1832,6 +1832,13 @@ sendfile(struct proc *p, struct sendfile_args *uap) } done: + /* + * If there was no error we have to clear p->p_retval[0] + * because it may have been set by writev. + */ + if (error == 0) { + p->p_retval[0] = 0; + } if (uap->sbytes != NULL) { copyout(&sbytes, uap->sbytes, sizeof(off_t)); }