-.\" $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.
.\" (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
.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
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,
-/* $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 $ */
/*-
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 */
-/* $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>
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;
-/* $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 $ */
/*
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) {
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);
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);
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);
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);
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) {
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);
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;
* 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)
-/* $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 $ */
/*
/* 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);
-/* $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 $ */
/*
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);