diff options
-rw-r--r-- | share/man/man9/file.9 | 23 | ||||
-rw-r--r-- | sys/compat/linux/linux_misc.c | 4 | ||||
-rw-r--r-- | sys/dev/diskmap.c | 8 | ||||
-rw-r--r-- | sys/kern/vfs_syscalls.c | 22 | ||||
-rw-r--r-- | sys/sys/vnode.h | 4 | ||||
-rw-r--r-- | sys/uvm/uvm_mmap.c | 4 |
6 files changed, 29 insertions, 36 deletions
diff --git a/share/man/man9/file.9 b/share/man/man9/file.9 index 0fdad047692..594679da907 100644 --- a/share/man/man9/file.9 +++ b/share/man/man9/file.9 @@ -1,4 +1,4 @@ -.\" $OpenBSD: file.9,v 1.14 2015/05/06 08:52:17 mpi Exp $ +.\" $OpenBSD: file.9,v 1.15 2015/05/07 08:53:33 mpi Exp $ .\" .\" Copyright (c) 2002 Artur Grabowski <art@openbsd.org> .\" All rights reserved. @@ -22,7 +22,7 @@ .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: May 6 2015 $ +.Dd $Mdocdate: May 7 2015 $ .Dt FILE 9 .Os .Sh NAME @@ -47,7 +47,7 @@ .In sys/filedesc.h .In sys/vnode.h .Ft int -.Fn getvnode "struct filedesc *fdp" "int fd" "struct file **fpp" +.Fn getvnode "struct proc *p" "int fd" "struct file **fpp" .Sh DESCRIPTION These functions provide the interface for the UNIX file descriptors. File descriptors can be used to access vnodes (see @@ -75,27 +75,20 @@ recommended to make complicated kernel APIs that require it. The files are extracted from the file descriptor table using the functions .Fn fd_getfile -and -.Fn getvnode . .Fn fd_getfile performs all necessary checks to see if the file descriptor number is within the range of file descriptor table, and if the descriptor is valid. -.Fn getvnode -is a special case that besides doing -.Fn fd_getfile -also checks if the descriptor is a vnode, returns the proper -errno on error and increases the use count with -.Fn FREF . .Pp The files are extracted from the process context using the function -.Fn getsock . .Fn getsock -is a special case that besides doing +and +.Fn getvnode . +These functions are special cases that besides doing .Fn fd_getfile -also checks if the descriptor is a socket, returns the proper -errno on error and increases the use count with +also check if the descriptor is a socket or a vnode respectively, +return the proper errno on error and increase the use count with .Fn FREF . .Sh CONCURRENT ACCESS Since multiple processes can share the same file descriptor table, diff --git a/sys/compat/linux/linux_misc.c b/sys/compat/linux/linux_misc.c index f960b778f97..be01c8a1516 100644 --- a/sys/compat/linux/linux_misc.c +++ b/sys/compat/linux/linux_misc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: linux_misc.c,v 1.93 2015/05/02 14:43:06 jsg Exp $ */ +/* $OpenBSD: linux_misc.c,v 1.94 2015/05/07 08:53:32 mpi Exp $ */ /* $NetBSD: linux_misc.c,v 1.27 1996/05/20 01:59:21 fvdl Exp $ */ /*- @@ -1187,7 +1187,7 @@ getdents_common(p, v, retval, is64bit) int error; int nbytes = SCARG(uap, count); - if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) + if ((error = getvnode(p, SCARG(uap, fd), &fp)) != 0) return (error); if (nbytes == 1) { /* emulating old, broken behaviour */ diff --git a/sys/dev/diskmap.c b/sys/dev/diskmap.c index 2b54b5c4c21..6086384da6b 100644 --- a/sys/dev/diskmap.c +++ b/sys/dev/diskmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: diskmap.c,v 1.10 2015/03/14 03:38:46 jsg Exp $ */ +/* $OpenBSD: diskmap.c,v 1.11 2015/05/07 08:53:33 mpi Exp $ */ /* * Copyright (c) 2009, 2010 Joel Sing <jsing@openbsd.org> @@ -78,12 +78,12 @@ diskmapioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p) goto invalid; /* Attempt to open actual device. */ + if ((error = getvnode(p, fd, &fp)) != 0) + goto invalid; + fdp = p->p_fd; fdplock(fdp); - if ((error = getvnode(fdp, fd, &fp)) != 0) - goto bad; - ndp.ni_segflg = UIO_SYSSPACE; ndp.ni_dirfd = AT_FDCWD; ndp.ni_dirp = devname; diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index 81667eed88f..2934999a963 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfs_syscalls.c,v 1.219 2015/04/30 09:20:51 mpi Exp $ */ +/* $OpenBSD: vfs_syscalls.c,v 1.220 2015/05/07 08:53:33 mpi Exp $ */ /* $NetBSD: vfs_syscalls.c,v 1.71 1996/04/23 10:29:02 mycroft Exp $ */ /* @@ -591,7 +591,7 @@ sys_fstatfs(struct proc *p, void *v, register_t *retval) struct statfs *sp; int error; - if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) + if ((error = getvnode(p, SCARG(uap, fd), &fp)) != 0) return (error); mp = ((struct vnode *)fp->f_data)->v_mount; if (!mp) { @@ -1883,7 +1883,7 @@ sys_fchflags(struct proc *p, void *v, register_t *retval) struct vnode *vp; int error; - if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) + if ((error = getvnode(p, SCARG(uap, fd), &fp)) != 0) return (error); vp = fp->f_data; vref(vp); @@ -1999,7 +1999,7 @@ sys_fchmod(struct proc *p, void *v, register_t *retval) if (SCARG(uap, mode) & ~(S_IFMT | ALLPERMS)) return (EINVAL); - if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) + if ((error = getvnode(p, SCARG(uap, fd), &fp)) != 0) return (error); vp = (struct vnode *)fp->f_data; vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); @@ -2161,7 +2161,7 @@ sys_fchown(struct proc *p, void *v, register_t *retval) uid_t uid = SCARG(uap, uid); gid_t gid = SCARG(uap, gid); - if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) + if ((error = getvnode(p, SCARG(uap, fd), &fp)) != 0) return (error); vp = (struct vnode *)fp->f_data; vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); @@ -2376,7 +2376,7 @@ dofutimens(struct proc *p, int fd, struct timespec ts[2]) struct vnode *vp; int error; - if ((error = getvnode(p->p_fd, fd, &fp)) != 0) + if ((error = getvnode(p, fd, &fp)) != 0) return (error); vp = (struct vnode *)fp->f_data; vref(vp); @@ -2437,7 +2437,7 @@ sys_ftruncate(struct proc *p, void *v, register_t *retval) off_t len; int error; - if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) + if ((error = getvnode(p, SCARG(uap, fd), &fp)) != 0) return (error); len = SCARG(uap, length); if ((fp->f_flag & FWRITE) == 0 || len < 0) { @@ -2473,7 +2473,7 @@ sys_fsync(struct proc *p, void *v, register_t *retval) struct file *fp; int error; - if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) + if ((error = getvnode(p, SCARG(uap, fd), &fp)) != 0) return (error); vp = (struct vnode *)fp->f_data; vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); @@ -2692,7 +2692,7 @@ sys_getdents(struct proc *p, void *v, register_t *retval) if (buflen > INT_MAX) return EINVAL; - if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) + if ((error = getvnode(p, SCARG(uap, fd), &fp)) != 0) return (error); if ((fp->f_flag & FREAD) == 0) { error = EBADF; @@ -2783,12 +2783,12 @@ out: * On return *fpp is FREF:ed. */ int -getvnode(struct filedesc *fdp, int fd, struct file **fpp) +getvnode(struct proc *p, int fd, struct file **fpp) { struct file *fp; struct vnode *vp; - if ((fp = fd_getfile(fdp, fd)) == NULL) + if ((fp = fd_getfile(p->p_fd, fd)) == NULL) return (EBADF); if (fp->f_type != DTYPE_VNODE) diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h index ca3ee2764f7..5d5f5c87827 100644 --- a/sys/sys/vnode.h +++ b/sys/sys/vnode.h @@ -1,4 +1,4 @@ -/* $OpenBSD: vnode.h,v 1.131 2015/05/01 01:30:58 millert Exp $ */ +/* $OpenBSD: vnode.h,v 1.132 2015/05/07 08:53:33 mpi Exp $ */ /* $NetBSD: vnode.h,v 1.38 1996/02/29 20:59:05 cgd Exp $ */ /* @@ -654,7 +654,7 @@ void vn_syncer_add_to_worklist(struct vnode *, int); /* misc */ int vn_isdisk(struct vnode *, int *); int softdep_fsync(struct vnode *); -int getvnode(struct filedesc *, int, struct file **); +int getvnode(struct proc *, int, struct file **); /* uvm */ void uvm_vnp_setsize(struct vnode *, off_t); diff --git a/sys/uvm/uvm_mmap.c b/sys/uvm/uvm_mmap.c index 9f4205c8d51..bdb63e33713 100644 --- a/sys/uvm/uvm_mmap.c +++ b/sys/uvm/uvm_mmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_mmap.c,v 1.108 2015/03/30 21:08:40 miod Exp $ */ +/* $OpenBSD: uvm_mmap.c,v 1.109 2015/05/07 08:53:33 mpi Exp $ */ /* $NetBSD: uvm_mmap.c,v 1.49 2001/02/18 21:19:08 chs Exp $ */ /* @@ -141,7 +141,7 @@ sys_mquery(struct proc *p, void *v, register_t *retval) flags |= UVM_FLAG_FIXED; if (fd >= 0) { - if ((error = getvnode(p->p_fd, fd, &fp)) != 0) + if ((error = getvnode(p, fd, &fp)) != 0) return (error); uobj = &((struct vnode *)fp->f_data)->v_uvm->u_obj; uoff = SCARG(uap, pos); |