diff options
author | adrian <adrian@FreeBSD.org> | 2013-11-26 02:02:05 +0000 |
---|---|---|
committer | adrian <adrian@FreeBSD.org> | 2013-11-26 02:02:05 +0000 |
commit | 52a5b970b701b4c9abe6e2062e8d7ba3cfca4e76 (patch) | |
tree | 185f1e8bbc31503e0c3926509b52b8c03b486ade | |
parent | 79a423dd991a804ab3322ed5eb8733c66c8a16d6 (diff) | |
download | FreeBSD-src-52a5b970b701b4c9abe6e2062e8d7ba3cfca4e76.zip FreeBSD-src-52a5b970b701b4c9abe6e2062e8d7ba3cfca4e76.tar.gz |
Refactor out the sendfile copyout in order to make vn_sendfile()
callable from the kernel.
Right now vn_sendfile() can't be called from anything other than
a syscall handler _and_ return the number of bytes queued.
This simply moves the copyout() to do_sendfile() so that any kernel
code can initiate vn_sendfile() outside of a syscall context.
Tested:
* tiny little sendfile program spitting things out a tcp socket
Sponsored by: Netflix, Inc.
-rw-r--r-- | sys/kern/uipc_syscalls.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c index 5fd4821..134df9d 100644 --- a/sys/kern/uipc_syscalls.c +++ b/sys/kern/uipc_syscalls.c @@ -1908,6 +1908,7 @@ do_sendfile(struct thread *td, struct sendfile_args *uap, int compat) struct file *fp; cap_rights_t rights; int error; + off_t sbytes; /* * File offset must be positive. If it goes beyond EOF @@ -1947,9 +1948,11 @@ do_sendfile(struct thread *td, struct sendfile_args *uap, int compat) } error = fo_sendfile(fp, uap->s, hdr_uio, trl_uio, uap->offset, - uap->nbytes, uap->sbytes, uap->flags, compat ? SFK_COMPAT : 0, td); + uap->nbytes, &sbytes, uap->flags, compat ? SFK_COMPAT : 0, td); fdrop(fp, td); - + if (uap->sbytes != NULL) { + copyout(&sbytes, uap->sbytes, sizeof(off_t)); + } out: free(hdr_uio, M_IOV); free(trl_uio, M_IOV); @@ -2546,7 +2549,7 @@ out: td->td_retval[0] = 0; } if (sent != NULL) { - copyout(&sbytes, sent, sizeof(off_t)); + (*sent) = sbytes; } if (obj != NULL) vm_object_deallocate(obj); |