diff options
author | alfred <alfred@FreeBSD.org> | 2002-07-12 06:51:57 +0000 |
---|---|---|
committer | alfred <alfred@FreeBSD.org> | 2002-07-12 06:51:57 +0000 |
commit | 598d9de7159896359d35efcf71926db072992c2f (patch) | |
tree | 7a0bf043b02e40a3c00a04f2d19bb5c356f97759 /sys/kern/uipc_syscalls.c | |
parent | 482e3b64c1d15ab11a302f934114bfe22bfe7cf9 (diff) | |
download | FreeBSD-src-598d9de7159896359d35efcf71926db072992c2f.zip FreeBSD-src-598d9de7159896359d35efcf71926db072992c2f.tar.gz |
Create a bug-for-bug FreeBSD4 compatible version of sendfile and move the
fixed sendfile over. This is needed to preserve binary compatibility from
4.x to 5.x.
Diffstat (limited to 'sys/kern/uipc_syscalls.c')
-rw-r--r-- | sys/kern/uipc_syscalls.c | 39 |
1 files changed, 36 insertions, 3 deletions
diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c index 1e9c5fa..02cce09 100644 --- a/sys/kern/uipc_syscalls.c +++ b/sys/kern/uipc_syscalls.c @@ -81,6 +81,7 @@ static int sendit(struct thread *td, int s, struct msghdr *mp, int flags); static int recvit(struct thread *td, int s, struct msghdr *mp, void *namelenp); static int accept1(struct thread *td, struct accept_args *uap, int compat); +static int do_sendfile(struct thread *td, struct sendfile_args *uap, int compat); static int getsockname1(struct thread *td, struct getsockname_args *uap, int compat); static int getpeername1(struct thread *td, struct getpeername_args *uap, @@ -1637,6 +1638,31 @@ sf_buf_free(void *addr, void *args) int sendfile(struct thread *td, struct sendfile_args *uap) { + + return (do_sendfile(td, uap, 0)); +} + +#ifdef COMPAT_FREEBSD4 +int +freebsd4_sendfile(struct thread *td, struct freebsd4_sendfile_args *uap) +{ + struct sendfile_args args; + + args.fd = uap->fd; + args.s = uap->s; + args.offset = uap->offset; + args.nbytes = uap->nbytes; + args.hdtr = uap->hdtr; + args.sbytes = uap->sbytes; + args.flags = uap->flags; + + return (do_sendfile(td, &args, 1)); +} +#endif /* COMPAT_FREEBSD4 */ + +static int +do_sendfile(struct thread *td, struct sendfile_args *uap, int compat) +{ struct vnode *vp; struct vm_object *obj; struct socket *so = NULL; @@ -1694,7 +1720,10 @@ sendfile(struct thread *td, struct sendfile_args *uap) error = writev(td, &nuap); if (error) goto done; - hdtr_size += td->td_retval[0]; + if (compat) + sbytes += td->td_retval[0]; + else + hdtr_size += td->td_retval[0]; } } @@ -1921,7 +1950,10 @@ retry_space: error = writev(td, &nuap); if (error) goto done; - hdtr_size += td->td_retval[0]; + if (compat) + sbytes += td->td_retval[0]; + else + hdtr_size += td->td_retval[0]; } done: @@ -1933,7 +1965,8 @@ done: td->td_retval[0] = 0; } if (uap->sbytes != NULL) { - sbytes += hdtr_size; + if (!compat) + sbytes += hdtr_size; copyout(&sbytes, uap->sbytes, sizeof(off_t)); } if (vp) |