Index: sys/compat/freebsd32/freebsd32_misc.c =================================================================== --- sys/compat/freebsd32/freebsd32_misc.c +++ sys/compat/freebsd32/freebsd32_misc.c @@ -1452,25 +1452,17 @@ int freebsd32_pread(struct thread *td, struct freebsd32_pread_args *uap) { - struct pread_args ap; - ap.fd = uap->fd; - ap.buf = uap->buf; - ap.nbyte = uap->nbyte; - ap.offset = PAIR32TO64(off_t,uap->offset); - return (sys_pread(td, &ap)); + return (kern_pread(td, uap->fd, uap->buf, uap->nbyte, + PAIR32TO64(off_t, uap->offset))); } int freebsd32_pwrite(struct thread *td, struct freebsd32_pwrite_args *uap) { - struct pwrite_args ap; - ap.fd = uap->fd; - ap.buf = uap->buf; - ap.nbyte = uap->nbyte; - ap.offset = PAIR32TO64(off_t,uap->offset); - return (sys_pwrite(td, &ap)); + return (kern_pwrite(td, uap->fd, uap->buf, uap->nbyte, + PAIR32TO64(off_t, uap->offset))); } #ifdef COMPAT_43 @@ -1561,25 +1553,17 @@ int freebsd6_freebsd32_pread(struct thread *td, struct freebsd6_freebsd32_pread_args *uap) { - struct pread_args ap; - ap.fd = uap->fd; - ap.buf = uap->buf; - ap.nbyte = uap->nbyte; - ap.offset = PAIR32TO64(off_t,uap->offset); - return (sys_pread(td, &ap)); + return (kern_pread(td, uap->fd, uap->buf, uap->nbyte, + PAIR32TO64(off_t, uap->offset))); } int freebsd6_freebsd32_pwrite(struct thread *td, struct freebsd6_freebsd32_pwrite_args *uap) { - struct pwrite_args ap; - ap.fd = uap->fd; - ap.buf = uap->buf; - ap.nbyte = uap->nbyte; - ap.offset = PAIR32TO64(off_t,uap->offset); - return (sys_pwrite(td, &ap)); + return (kern_pwrite(td, uap->fd, uap->buf, uap->nbyte, + PAIR32TO64(off_t, uap->offset))); } int Index: sys/compat/linux/linux_file.c =================================================================== --- sys/compat/linux/linux_file.c +++ sys/compat/linux/linux_file.c @@ -997,20 +997,13 @@ } int -linux_pread(td, uap) - struct thread *td; - struct linux_pread_args *uap; +linux_pread(struct thread *td, struct linux_pread_args *uap) { - struct pread_args bsd; cap_rights_t rights; struct vnode *vp; int error; - bsd.fd = uap->fd; - bsd.buf = uap->buf; - bsd.nbyte = uap->nbyte; - bsd.offset = uap->offset; - error = sys_pread(td, &bsd); + error = kern_pread(td, uap->fd, uap->buf, uap->nbyte, uap->offset); if (error == 0) { /* This seems to violate POSIX but linux does it */ error = fgetvp(td, uap->fd, @@ -1027,17 +1020,10 @@ } int -linux_pwrite(td, uap) - struct thread *td; - struct linux_pwrite_args *uap; +linux_pwrite(struct thread *td, struct linux_pwrite_args *uap) { - struct pwrite_args bsd; - bsd.fd = uap->fd; - bsd.buf = uap->buf; - bsd.nbyte = uap->nbyte; - bsd.offset = uap->offset; - return (sys_pwrite(td, &bsd)); + return (kern_pwrite(td, uap->fd, uap->buf, uap->nbyte, uap->offset)); } int Index: sys/kern/sys_generic.c =================================================================== --- sys/kern/sys_generic.c +++ sys/kern/sys_generic.c @@ -220,39 +220,37 @@ }; #endif int -sys_pread(td, uap) - struct thread *td; - struct pread_args *uap; +sys_pread(struct thread *td, struct pread_args *uap) +{ + + return (kern_pread(td, uap->fd, uap->buf, uap->nbyte, uap->offset)); +} + +int +kern_pread(struct thread *td, int fd, void *buf, size_t nbyte, off_t offset) { struct uio auio; struct iovec aiov; int error; - if (uap->nbyte > IOSIZE_MAX) + if (nbyte > IOSIZE_MAX) return (EINVAL); - aiov.iov_base = uap->buf; - aiov.iov_len = uap->nbyte; + aiov.iov_base = buf; + aiov.iov_len = nbyte; auio.uio_iov = &aiov; auio.uio_iovcnt = 1; - auio.uio_resid = uap->nbyte; + auio.uio_resid = nbyte; auio.uio_segflg = UIO_USERSPACE; - error = kern_preadv(td, uap->fd, &auio, uap->offset); - return(error); + error = kern_preadv(td, fd, &auio, offset); + return (error); } #if defined(COMPAT_FREEBSD6) int -freebsd6_pread(td, uap) - struct thread *td; - struct freebsd6_pread_args *uap; +freebsd6_pread(struct thread *td, struct freebsd6_pread_args *uap) { - struct pread_args oargs; - oargs.fd = uap->fd; - oargs.buf = uap->buf; - oargs.nbyte = uap->nbyte; - oargs.offset = uap->offset; - return (sys_pread(td, &oargs)); + return (kern_pread(td, uap->fd, uap->buf, uap->nbyte, uap->offset)); } #endif @@ -435,39 +433,38 @@ }; #endif int -sys_pwrite(td, uap) - struct thread *td; - struct pwrite_args *uap; +sys_pwrite(struct thread *td, struct pwrite_args *uap) +{ + + return (kern_pwrite(td, uap->fd, uap->buf, uap->nbyte, uap->offset)); +} + +int +kern_pwrite(struct thread *td, int fd, const void *buf, size_t nbyte, + off_t offset) { struct uio auio; struct iovec aiov; int error; - if (uap->nbyte > IOSIZE_MAX) + if (nbyte > IOSIZE_MAX) return (EINVAL); - aiov.iov_base = (void *)(uintptr_t)uap->buf; - aiov.iov_len = uap->nbyte; + aiov.iov_base = (void *)(uintptr_t)buf; + aiov.iov_len = nbyte; auio.uio_iov = &aiov; auio.uio_iovcnt = 1; - auio.uio_resid = uap->nbyte; + auio.uio_resid = nbyte; auio.uio_segflg = UIO_USERSPACE; - error = kern_pwritev(td, uap->fd, &auio, uap->offset); + error = kern_pwritev(td, fd, &auio, offset); return(error); } #if defined(COMPAT_FREEBSD6) int -freebsd6_pwrite(td, uap) - struct thread *td; - struct freebsd6_pwrite_args *uap; +freebsd6_pwrite(struct thread *td, struct freebsd6_pwrite_args *uap) { - struct pwrite_args oargs; - oargs.fd = uap->fd; - oargs.buf = uap->buf; - oargs.nbyte = uap->nbyte; - oargs.offset = uap->offset; - return (sys_pwrite(td, &oargs)); + return (kern_pwrite(td, uap->fd, uap->buf, uap->nbyte, uap->offset)); } #endif Index: sys/sys/syscallsubr.h =================================================================== --- sys/sys/syscallsubr.h +++ sys/sys/syscallsubr.h @@ -167,11 +167,15 @@ off_t len); int kern_procctl(struct thread *td, enum idtype idtype, id_t id, int com, void *data); +int kern_pread(struct thread *td, int fd, void *buf, size_t nbyte, + off_t offset); int kern_preadv(struct thread *td, int fd, struct uio *auio, off_t offset); int kern_pselect(struct thread *td, int nd, fd_set *in, fd_set *ou, fd_set *ex, struct timeval *tvp, sigset_t *uset, int abi_nfdbits); int kern_ptrace(struct thread *td, int req, pid_t pid, void *addr, int data); +int kern_pwrite(struct thread *td, int fd, const void *buf, size_t nbyte, + off_t offset); int kern_pwritev(struct thread *td, int fd, struct uio *auio, off_t offset); int kern_readlinkat(struct thread *td, int fd, char *path, enum uio_seg pathseg, char *buf, enum uio_seg bufseg, size_t count);