From b1288166e0f73ddc7f5b8de210db62e987dda609 Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Wed, 17 Jan 2018 22:36:58 +0000 Subject: [PATCH] Use long for the last argument to VOP_PATHCONF rather than a register_t. pathconf(2) and fpathconf(2) both return a long. The kern_[f]pathconf() functions now accept a pointer to a long value rather than modifying td_retval directly. Instead, the system calls explicitly store the returned long value in td_retval[0]. Requested by: bde Reviewed by: kib Sponsored by: Chelsio Communications --- sys/fs/fdescfs/fdesc_vnops.c | 2 +- sys/fs/nfs/nfs_commonport.c | 4 ++-- sys/fs/nfs/nfs_var.h | 3 +-- sys/fs/nfsserver/nfs_nfsdserv.c | 2 +- sys/fs/smbfs/smbfs_vnops.c | 2 +- sys/fs/tmpfs/tmpfs_vnops.c | 2 +- sys/i386/ibcs2/ibcs2_misc.c | 6 +++++- sys/kern/kern_descrip.c | 15 ++++++++++----- sys/kern/vfs_syscalls.c | 21 ++++++++++++++++----- sys/kern/vnode_if.src | 2 +- sys/sys/syscallsubr.h | 4 ++-- 11 files changed, 41 insertions(+), 22 deletions(-) diff --git a/sys/fs/fdescfs/fdesc_vnops.c b/sys/fs/fdescfs/fdesc_vnops.c index 59ea8d92bfb3..0c4105b6cbbe 100644 --- a/sys/fs/fdescfs/fdesc_vnops.c +++ b/sys/fs/fdescfs/fdesc_vnops.c @@ -418,7 +418,7 @@ fdesc_pathconf(struct vop_pathconf_args *ap) vref(vp); VOP_UNLOCK(vp, 0); error = kern_fpathconf(curthread, VTOFDESC(vp)->fd_fd, - ap->a_name); + ap->a_name, ap->a_retval); vn_lock(vp, LK_SHARED | LK_RETRY); vunref(vp); return (error); diff --git a/sys/fs/nfs/nfs_commonport.c b/sys/fs/nfs/nfs_commonport.c index ece5626d83cc..f08f7f1186ae 100644 --- a/sys/fs/nfs/nfs_commonport.c +++ b/sys/fs/nfs/nfs_commonport.c @@ -316,7 +316,7 @@ nfsvno_getfs(struct nfsfsinfo *sip, int isdgram) * Do the pathconf vnode op. */ int -nfsvno_pathconf(struct vnode *vp, int flag, register_t *retf, +nfsvno_pathconf(struct vnode *vp, int flag, long *retf, struct ucred *cred, struct thread *p) { int error; @@ -688,7 +688,7 @@ int nfs_supportsnfsv4acls(struct vnode *vp) { int error; - register_t retval; + long retval; ASSERT_VOP_LOCKED(vp, "nfs supports nfsv4acls"); diff --git a/sys/fs/nfs/nfs_var.h b/sys/fs/nfs/nfs_var.h index 5a6c5fb749fd..f1f3efe3958d 100644 --- a/sys/fs/nfs/nfs_var.h +++ b/sys/fs/nfs/nfs_var.h @@ -371,8 +371,7 @@ struct ucred *newnfs_getcred(void); void newnfs_setroot(struct ucred *); int nfs_catnap(int, int, const char *); struct nfsreferral *nfsv4root_getreferral(vnode_t, vnode_t, u_int32_t); -int nfsvno_pathconf(vnode_t, int, register_t *, struct ucred *, - NFSPROC_T *); +int nfsvno_pathconf(vnode_t, int, long *, struct ucred *, NFSPROC_T *); int nfsrv_atroot(vnode_t, uint64_t *); void newnfs_timer(void *); int nfs_supportsnfsv4acls(vnode_t); diff --git a/sys/fs/nfsserver/nfs_nfsdserv.c b/sys/fs/nfsserver/nfs_nfsdserv.c index 346610b8e3b4..61f561b1d49a 100644 --- a/sys/fs/nfsserver/nfs_nfsdserv.c +++ b/sys/fs/nfsserver/nfs_nfsdserv.c @@ -2133,7 +2133,7 @@ nfsrvd_pathconf(struct nfsrv_descript *nd, __unused int isdgram, { struct nfsv3_pathconf *pc; int getret = 1; - register_t linkmax, namemax, chownres, notrunc; + long linkmax, namemax, chownres, notrunc; struct nfsvattr at; if (nd->nd_repstat) { diff --git a/sys/fs/smbfs/smbfs_vnops.c b/sys/fs/smbfs/smbfs_vnops.c index e65578888201..09d21b8c4bb5 100644 --- a/sys/fs/smbfs/smbfs_vnops.c +++ b/sys/fs/smbfs/smbfs_vnops.c @@ -895,7 +895,7 @@ smbfs_pathconf (ap) { struct smbmount *smp = VFSTOSMBFS(VTOVFS(ap->a_vp)); struct smb_vc *vcp = SSTOVC(smp->sm_share); - register_t *retval = ap->a_retval; + long *retval = ap->a_retval; int error = 0; switch (ap->a_name) { diff --git a/sys/fs/tmpfs/tmpfs_vnops.c b/sys/fs/tmpfs/tmpfs_vnops.c index 78402f3886b1..dbacfd7858ce 100644 --- a/sys/fs/tmpfs/tmpfs_vnops.c +++ b/sys/fs/tmpfs/tmpfs_vnops.c @@ -1343,7 +1343,7 @@ tmpfs_pathconf(struct vop_pathconf_args *v) { struct vnode *vp = v->a_vp; int name = v->a_name; - register_t *retval = v->a_retval; + long *retval = v->a_retval; int error; diff --git a/sys/i386/ibcs2/ibcs2_misc.c b/sys/i386/ibcs2/ibcs2_misc.c index c166d78a1486..ea7f133a0161 100644 --- a/sys/i386/ibcs2/ibcs2_misc.c +++ b/sys/i386/ibcs2/ibcs2_misc.c @@ -737,12 +737,16 @@ int ibcs2_pathconf(struct thread *td, struct ibcs2_pathconf_args *uap) { char *path; + long value; int error; CHECKALTEXIST(td, uap->path, &path); uap->name++; /* iBCS2 _PC_* defines are offset by one */ - error = kern_pathconf(td, path, UIO_SYSSPACE, uap->name, FOLLOW); + error = kern_pathconf(td, path, UIO_SYSSPACE, uap->name, FOLLOW, + &value); free(path, M_TEMP); + if (error == 0) + td->td_retval[0] = value; return (error); } diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index c1100b7c8fdf..385514fbfabf 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -1418,12 +1418,17 @@ struct fpathconf_args { int sys_fpathconf(struct thread *td, struct fpathconf_args *uap) { + long value; + int error; - return (kern_fpathconf(td, uap->fd, uap->name)); + error = kern_fpathconf(td, uap->fd, uap->name, &value); + if (error == 0) + td->td_retval[0] = value; + return (error); } int -kern_fpathconf(struct thread *td, int fd, int name) +kern_fpathconf(struct thread *td, int fd, int name, long *valuep) { struct file *fp; struct vnode *vp; @@ -1435,19 +1440,19 @@ kern_fpathconf(struct thread *td, int fd, int name) return (error); if (name == _PC_ASYNC_IO) { - td->td_retval[0] = _POSIX_ASYNCHRONOUS_IO; + *valuep = _POSIX_ASYNCHRONOUS_IO; goto out; } vp = fp->f_vnode; if (vp != NULL) { vn_lock(vp, LK_SHARED | LK_RETRY); - error = VOP_PATHCONF(vp, name, td->td_retval); + error = VOP_PATHCONF(vp, name, valuep); VOP_UNLOCK(vp, 0); } else if (fp->f_type == DTYPE_PIPE || fp->f_type == DTYPE_SOCKET) { if (name != _PC_PIPE_BUF) { error = EINVAL; } else { - td->td_retval[0] = PIPE_BUF; + *valuep = PIPE_BUF; error = 0; } } else { diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index 7114ca9f3d94..d28c588ebfd9 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -2384,8 +2384,14 @@ struct pathconf_args { int sys_pathconf(struct thread *td, struct pathconf_args *uap) { + long value; + int error; - return (kern_pathconf(td, uap->path, UIO_USERSPACE, uap->name, FOLLOW)); + error = kern_pathconf(td, uap->path, UIO_USERSPACE, uap->name, FOLLOW, + &value); + if (error == 0) + td->td_retval[0] = value; + return (error); } #ifndef _SYS_SYSPROTO_H_ @@ -2397,14 +2403,19 @@ struct lpathconf_args { int sys_lpathconf(struct thread *td, struct lpathconf_args *uap) { + long value; + int error; - return (kern_pathconf(td, uap->path, UIO_USERSPACE, uap->name, - NOFOLLOW)); + error = kern_pathconf(td, uap->path, UIO_USERSPACE, uap->name, + NOFOLLOW, &value); + if (error == 0) + td->td_retval[0] = value; + return (error); } int kern_pathconf(struct thread *td, char *path, enum uio_seg pathseg, int name, - u_long flags) + u_long flags, long *valuep) { struct nameidata nd; int error; @@ -2415,7 +2426,7 @@ kern_pathconf(struct thread *td, char *path, enum uio_seg pathseg, int name, return (error); NDFREE(&nd, NDF_ONLY_PNBUF); - error = VOP_PATHCONF(nd.ni_vp, name, td->td_retval); + error = VOP_PATHCONF(nd.ni_vp, name, valuep); vput(nd.ni_vp); return (error); } diff --git a/sys/kern/vnode_if.src b/sys/kern/vnode_if.src index 30f5d752f62b..90cef879c4ed 100644 --- a/sys/kern/vnode_if.src +++ b/sys/kern/vnode_if.src @@ -429,7 +429,7 @@ vop_print { vop_pathconf { IN struct vnode *vp; IN int name; - OUT register_t *retval; + OUT long *retval; }; diff --git a/sys/sys/syscallsubr.h b/sys/sys/syscallsubr.h index a0f8fc0be384..d03595286694 100644 --- a/sys/sys/syscallsubr.h +++ b/sys/sys/syscallsubr.h @@ -118,7 +118,7 @@ int kern_fcntl(struct thread *td, int fd, int cmd, intptr_t arg); int kern_fcntl_freebsd(struct thread *td, int fd, int cmd, long arg); int kern_fhstat(struct thread *td, fhandle_t fh, struct stat *buf); int kern_fhstatfs(struct thread *td, fhandle_t fh, struct statfs *buf); -int kern_fpathconf(struct thread *td, int fd, int name); +int kern_fpathconf(struct thread *td, int fd, int name, long *valuep); int kern_fstat(struct thread *td, int fd, struct stat *sbp); int kern_fstatfs(struct thread *td, int fd, struct statfs *buf); int kern_fsync(struct thread *td, int fd, bool fullsync); @@ -187,7 +187,7 @@ int kern_ogetdirentries(struct thread *td, struct ogetdirentries_args *uap, int kern_openat(struct thread *td, int fd, char *path, enum uio_seg pathseg, int flags, int mode); int kern_pathconf(struct thread *td, char *path, enum uio_seg pathseg, - int name, u_long flags); + int name, u_long flags, long *valuep); int kern_pipe(struct thread *td, int fildes[2], int flags, struct filecaps *fcaps1, struct filecaps *fcaps2); int kern_poll(struct thread *td, struct pollfd *fds, u_int nfds,