Add kern_pread() and kern_pwrite(), and use it in compats instead
of their sys_*() counterparts. The svr4 is left unchanged. Reviewed by: kib@ MFC after: 2 weeks Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D9379
This commit is contained in:
parent
5db72ef2e4
commit
b38b22b0b2
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=313018
@ -1452,25 +1452,17 @@ freebsd4_freebsd32_fhstatfs(struct thread *td, struct freebsd4_freebsd32_fhstatf
|
||||
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
|
||||
@ -1559,25 +1551,17 @@ freebsd32_getdirentries(struct thread *td,
|
||||
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
|
||||
|
@ -997,20 +997,13 @@ linux_fdatasync(td, uap)
|
||||
}
|
||||
|
||||
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 @@ linux_pread(td, uap)
|
||||
}
|
||||
|
||||
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
|
||||
|
@ -220,39 +220,37 @@ struct pread_args {
|
||||
};
|
||||
#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);
|
||||
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 @@ struct pwrite_args {
|
||||
};
|
||||
#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
|
||||
|
||||
|
@ -171,11 +171,15 @@ int kern_posix_fallocate(struct thread *td, int fd, off_t offset,
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user