diff options
| author | ad <ad@NetBSD.org> | 2008-03-21 21:54:58 +0000 |
|---|---|---|
| committer | ad <ad@NetBSD.org> | 2008-03-21 21:54:58 +0000 |
| commit | a9ca7a3734751f09c9dc4e1f645cd528fd403e8c (patch) | |
| tree | ff26aca94a1a611e6be984fcff411406b466507f /sys/miscfs | |
| parent | c743ad71591a886accf44c9e93c1ff677b45a41f (diff) | |
Catch up with descriptor handling changes. See kern_descrip.c revision
1.173 for details.
Diffstat (limited to 'sys/miscfs')
| -rw-r--r-- | sys/miscfs/fdesc/fdesc_vnops.c | 69 | ||||
| -rw-r--r-- | sys/miscfs/fifofs/fifo_vnops.c | 12 | ||||
| -rw-r--r-- | sys/miscfs/genfs/genfs_vnops.c | 10 | ||||
| -rw-r--r-- | sys/miscfs/portal/portal_vfsops.c | 15 | ||||
| -rw-r--r-- | sys/miscfs/portal/portal_vnops.c | 6 | ||||
| -rw-r--r-- | sys/miscfs/procfs/procfs_fd.c | 27 | ||||
| -rw-r--r-- | sys/miscfs/procfs/procfs_subr.c | 20 | ||||
| -rw-r--r-- | sys/miscfs/procfs/procfs_vnops.c | 45 |
8 files changed, 89 insertions, 115 deletions
diff --git a/sys/miscfs/fdesc/fdesc_vnops.c b/sys/miscfs/fdesc/fdesc_vnops.c index d97fa45206a..e7fe40e79f5 100644 --- a/sys/miscfs/fdesc/fdesc_vnops.c +++ b/sys/miscfs/fdesc/fdesc_vnops.c @@ -1,4 +1,4 @@ -/* $NetBSD: fdesc_vnops.c,v 1.101 2007/12/08 19:29:50 pooka Exp $ */ +/* $NetBSD: fdesc_vnops.c,v 1.102 2008/03/21 21:55:00 ad Exp $ */ /* * Copyright (c) 1992, 1993 @@ -41,7 +41,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: fdesc_vnops.c,v 1.101 2007/12/08 19:29:50 pooka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fdesc_vnops.c,v 1.102 2008/03/21 21:55:00 ad Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -62,6 +62,7 @@ __KERNEL_RCSID(0, "$NetBSD: fdesc_vnops.c,v 1.101 2007/12/08 19:29:50 pooka Exp #include <sys/dirent.h> #include <sys/tty.h> #include <sys/kauth.h> +#include <sys/atomic.h> #include <miscfs/fdesc/fdesc.h> #include <miscfs/genfs/genfs.h> @@ -125,7 +126,7 @@ int fdesc_pathconf(void *); #define fdesc_revoke genfs_revoke #define fdesc_putpages genfs_null_putpages -static int fdesc_attr(int, struct vattr *, kauth_cred_t, struct lwp *); +static int fdesc_attr(int, struct vattr *, kauth_cred_t); int (**fdesc_vnodeop_p)(void *); const struct vnodeopv_entry_desc fdesc_vnodeop_entries[] = { @@ -280,7 +281,8 @@ fdesc_lookup(v) struct lwp *l = curlwp; const char *pname = cnp->cn_nameptr; struct proc *p = l->l_proc; - int numfiles = p->p_fd->fd_nfiles; + filedesc_t *fdp = p->p_fd; + int numfiles = fdp->fd_nfiles; unsigned fd = 0; int error; struct vnode *fvp; @@ -382,11 +384,14 @@ fdesc_lookup(v) goto bad; } - if (fd >= numfiles || p->p_fd->fd_ofiles[fd] == NULL || - FILE_IS_USABLE(p->p_fd->fd_ofiles[fd]) == 0) { + mutex_enter(&fdp->fd_lock); + if (fd >= numfiles ||fdp->fd_ofiles[fd] == NULL || + fdp->fd_ofiles[fd]->ff_file == NULL) { + mutex_exit(&fdp->fd_lock); error = EBADF; goto bad; } + mutex_exit(&fdp->fd_lock); error = fdesc_allocvp(Fdesc, FD_DESC+fd, dvp->v_mount, &fvp); if (error) @@ -440,26 +445,21 @@ fdesc_open(v) } static int -fdesc_attr(fd, vap, cred, l) +fdesc_attr(fd, vap, cred) int fd; struct vattr *vap; kauth_cred_t cred; - struct lwp *l; { - struct proc *p = l->l_proc; - struct filedesc *fdp = p->p_fd; - struct file *fp; + file_t *fp; struct stat stb; int error; - if ((fp = fd_getfile(fdp, fd)) == NULL) + if ((fp = fd_getfile(fd)) == NULL) return (EBADF); switch (fp->f_type) { case DTYPE_VNODE: - FILE_USE(fp); error = VOP_GETATTR((struct vnode *) fp->f_data, vap, cred); - FILE_UNUSE(fp, l); if (error == 0 && vap->va_type == VDIR) { /* * directories can cause loops in the namespace, @@ -470,10 +470,8 @@ fdesc_attr(fd, vap, cred, l) break; default: - FILE_USE(fp); memset(&stb, 0, sizeof(stb)); - error = (*fp->f_ops->fo_stat)(fp, &stb, l); - FILE_UNUSE(fp, l); + error = (*fp->f_ops->fo_stat)(fp, &stb); if (error) break; @@ -508,6 +506,7 @@ fdesc_attr(fd, vap, cred, l) break; } + fd_putfile(fd); return (error); } @@ -578,7 +577,7 @@ fdesc_getattr(v) case Fdesc: fd = VTOFDESC(vp)->fd_fd; - error = fdesc_attr(fd, vap, ap->a_cred, curlwp); + error = fdesc_attr(fd, vap, ap->a_cred); break; default: @@ -601,8 +600,7 @@ fdesc_setattr(v) struct vattr *a_vap; kauth_cred_t a_cred; } */ *ap = v; - struct filedesc *fdp = curlwp->l_proc->p_fd; - struct file *fp; + file_t *fp; unsigned fd; /* @@ -620,7 +618,7 @@ fdesc_setattr(v) } fd = VTOFDESC(ap->a_vp)->fd_fd; - if ((fp = fd_getfile(fdp, fd)) == NULL) + if ((fp = fd_getfile(fd)) == NULL) return (EBADF); /* @@ -628,7 +626,7 @@ fdesc_setattr(v) * On vnode's this will cause truncation and socket/pipes make * no sense. */ - mutex_exit(&fp->f_lock); + fd_putfile(fd); return (0); } @@ -664,7 +662,7 @@ fdesc_readdir(v) } */ *ap = v; struct uio *uio = ap->a_uio; struct dirent d; - struct filedesc *fdp; + filedesc_t *fdp; off_t i; int j; int error; @@ -728,11 +726,10 @@ fdesc_readdir(v) if ((ft->ft_fileno - FD_STDIN) >= fdp->fd_nfiles) continue; + membar_consumer(); if (fdp->fd_ofiles[ft->ft_fileno - FD_STDIN] - == NULL - || FILE_IS_USABLE( - fdp->fd_ofiles[ft->ft_fileno - FD_STDIN]) - == 0) + == NULL || fdp->fd_ofiles[ft->ft_fileno - + FD_STDIN]->ff_file == NULL) continue; break; } @@ -749,6 +746,7 @@ fdesc_readdir(v) } } else { int nfdp = fdp ? fdp->fd_nfiles : 0; + membar_consumer(); if (ap->a_ncookies) { ncookies = min(ncookies, nfdp + 2); cookies = malloc(ncookies * sizeof(off_t), @@ -771,7 +769,7 @@ fdesc_readdir(v) KASSERT(fdp != NULL); j = (int)i - 2; if (fdp == NULL || fdp->fd_ofiles[j] == NULL || - FILE_IS_USABLE(fdp->fd_ofiles[j]) == 0) + fdp->fd_ofiles[j]->ff_file == NULL) continue; d.d_fileno = j + FD_STDIN; d.d_namlen = sprintf(d.d_name, "%d", j); @@ -935,10 +933,8 @@ fdesc_kqfilter(v) struct vnode *a_vp; struct knote *a_kn; } */ *ap = v; - int error; - struct proc *p; - struct lwp *l; - struct file *fp; + int error, fd; + file_t *fp; switch (VTOFDESC(ap->a_vp)->fd_type) { case Fctty: @@ -947,14 +943,11 @@ fdesc_kqfilter(v) case Fdesc: /* just invoke kqfilter for the underlying descriptor */ - l = curlwp; /* XXX hopefully ok to use curproc here */ - p = l->l_proc; - if ((fp = fd_getfile(p->p_fd, VTOFDESC(ap->a_vp)->fd_fd)) == NULL) + fd = VTOFDESC(ap->a_vp)->fd_fd; + if ((fp = fd_getfile(fd)) == NULL) return (1); - - FILE_USE(fp); error = (*fp->f_ops->fo_kqfilter)(fp, ap->a_kn); - FILE_UNUSE(fp, l); + fd_putfile(fd); break; default: diff --git a/sys/miscfs/fifofs/fifo_vnops.c b/sys/miscfs/fifofs/fifo_vnops.c index 80cdaed041d..c3097ba36d8 100644 --- a/sys/miscfs/fifofs/fifo_vnops.c +++ b/sys/miscfs/fifofs/fifo_vnops.c @@ -1,4 +1,4 @@ -/* $NetBSD: fifo_vnops.c,v 1.62 2008/02/11 23:53:32 yamt Exp $ */ +/* $NetBSD: fifo_vnops.c,v 1.63 2008/03/21 21:55:00 ad Exp $ */ /* * Copyright (c) 1990, 1993, 1995 @@ -32,7 +32,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: fifo_vnops.c,v 1.62 2008/02/11 23:53:32 yamt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fifo_vnops.c,v 1.63 2008/03/21 21:55:00 ad Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -341,13 +341,13 @@ fifo_ioctl(void *v) return (0); if (ap->a_fflag & FREAD) { filetmp.f_data = ap->a_vp->v_fifoinfo->fi_readsock; - error = soo_ioctl(&filetmp, ap->a_command, ap->a_data, curlwp); + error = soo_ioctl(&filetmp, ap->a_command, ap->a_data); if (error) return (error); } if (ap->a_fflag & FWRITE) { filetmp.f_data = ap->a_vp->v_fifoinfo->fi_writesock; - error = soo_ioctl(&filetmp, ap->a_command, ap->a_data, curlwp); + error = soo_ioctl(&filetmp, ap->a_command, ap->a_data); if (error) return (error); } @@ -370,12 +370,12 @@ fifo_poll(void *v) if (ap->a_events & (POLLIN | POLLPRI | POLLRDNORM | POLLRDBAND)) { filetmp.f_data = ap->a_vp->v_fifoinfo->fi_readsock; if (filetmp.f_data) - revents |= soo_poll(&filetmp, ap->a_events, curlwp); + revents |= soo_poll(&filetmp, ap->a_events); } if (ap->a_events & (POLLOUT | POLLWRNORM | POLLWRBAND)) { filetmp.f_data = ap->a_vp->v_fifoinfo->fi_writesock; if (filetmp.f_data) - revents |= soo_poll(&filetmp, ap->a_events, curlwp); + revents |= soo_poll(&filetmp, ap->a_events); } return (revents); diff --git a/sys/miscfs/genfs/genfs_vnops.c b/sys/miscfs/genfs/genfs_vnops.c index b7b18012872..d9bb1ad532e 100644 --- a/sys/miscfs/genfs/genfs_vnops.c +++ b/sys/miscfs/genfs/genfs_vnops.c @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_vnops.c,v 1.164 2008/02/05 14:19:53 ad Exp $ */ +/* $NetBSD: genfs_vnops.c,v 1.165 2008/03/21 21:55:00 ad Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -64,7 +64,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.164 2008/02/05 14:19:53 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.165 2008/03/21 21:55:00 ad Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -408,13 +408,13 @@ filt_genfsread(struct knote *kn, long hint) return (1); case 0: mutex_enter(&vp->v_interlock); - kn->kn_data = vp->v_size - kn->kn_fp->f_offset; + kn->kn_data = vp->v_size - ((file_t *)kn->kn_obj)->f_offset; rv = (kn->kn_data != 0); mutex_exit(&vp->v_interlock); return rv; default: KASSERT(mutex_owned(&vp->v_interlock)); - kn->kn_data = vp->v_size - kn->kn_fp->f_offset; + kn->kn_data = vp->v_size - ((file_t *)kn->kn_obj)->f_offset; return (kn->kn_data != 0); } } @@ -445,7 +445,7 @@ filt_genfsvnode(struct knote *kn, long hint) break; } - return (kn->kn_fflags != 0); + return (fflags != 0); } static const struct filterops genfsread_filtops = diff --git a/sys/miscfs/portal/portal_vfsops.c b/sys/miscfs/portal/portal_vfsops.c index baa8e90f49b..d9cb5954cff 100644 --- a/sys/miscfs/portal/portal_vfsops.c +++ b/sys/miscfs/portal/portal_vfsops.c @@ -1,4 +1,4 @@ -/* $NetBSD: portal_vfsops.c,v 1.70 2008/01/28 14:31:19 dholland Exp $ */ +/* $NetBSD: portal_vfsops.c,v 1.71 2008/03/21 21:55:00 ad Exp $ */ /* * Copyright (c) 1992, 1993, 1995 @@ -40,7 +40,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: portal_vfsops.c,v 1.70 2008/01/28 14:31:19 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: portal_vfsops.c,v 1.71 2008/03/21 21:55:00 ad Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_netbsd.h" @@ -121,17 +121,17 @@ portal_mount( return (EOPNOTSUPP); /* getsock() will use the descriptor for us */ - if ((error = getsock(p->p_fd, args->pa_socket, &fp)) != 0) + if ((error = getsock(args->pa_socket, &fp)) != 0) return (error); so = (struct socket *) fp->f_data; if (so->so_proto->pr_domain->dom_family != AF_LOCAL) { - FILE_UNUSE(fp, NULL); + fd_putfile(args->pa_socket); return (ESOCKTNOSUPPORT); } error = getnewvnode(VT_PORTAL, mp, portal_vnodeop_p, &rvp); /* XXX */ if (error) { - FILE_UNUSE(fp, NULL); + fd_putfile(args->pa_socket); return (error); } MALLOC(rvp->v_data, void *, sizeof(struct portalnode), @@ -149,6 +149,7 @@ portal_mount( mutex_enter(&fp->f_lock); fp->f_count++; mutex_exit(&fp->f_lock); + fd_putfile(args->pa_socket); mp->mnt_stat.f_namemax = MAXNAMLEN; mp->mnt_flag |= MNT_LOCAL; @@ -189,14 +190,12 @@ portal_unmount(struct mount *mp, int mntflags) * daemon to wake up, and then the accept will get ECONNABORTED * which it interprets as a request to go and bury itself. */ - mutex_enter(&VFSTOPORTAL(mp)->pm_server->f_lock); - FILE_USE(VFSTOPORTAL(mp)->pm_server); soshutdown((struct socket *) VFSTOPORTAL(mp)->pm_server->f_data, 2); /* * Discard reference to underlying file. Must call closef because * this may be the last reference. */ - closef(VFSTOPORTAL(mp)->pm_server, (struct lwp *) 0); + closef(VFSTOPORTAL(mp)->pm_server); /* * Finally, throw away the portalmount structure */ diff --git a/sys/miscfs/portal/portal_vnops.c b/sys/miscfs/portal/portal_vnops.c index 0da8aacdf5d..23a15991ff9 100644 --- a/sys/miscfs/portal/portal_vnops.c +++ b/sys/miscfs/portal/portal_vnops.c @@ -1,4 +1,4 @@ -/* $NetBSD: portal_vnops.c,v 1.77 2008/01/19 21:54:47 pooka Exp $ */ +/* $NetBSD: portal_vnops.c,v 1.78 2008/03/21 21:55:00 ad Exp $ */ /* * Copyright (c) 1992, 1993 @@ -40,7 +40,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: portal_vnops.c,v 1.77 2008/01/19 21:54:47 pooka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: portal_vnops.c,v 1.78 2008/03/21 21:55:00 ad Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -484,7 +484,7 @@ portal_open(v) * Check that the mode the file is being opened for is a subset * of the mode of the existing descriptor. */ - fp = l->l_proc->p_fd->fd_ofiles[fd]; + fp = l->l_proc->p_fd->fd_ofiles[fd]->ff_file; if (((ap->a_mode & (FREAD|FWRITE)) | fp->f_flag) != fp->f_flag) { portal_closefd(l, fd); /* XXXNJWLWP */ error = EACCES; diff --git a/sys/miscfs/procfs/procfs_fd.c b/sys/miscfs/procfs/procfs_fd.c index 4d52e7a7275..750cda95ae1 100644 --- a/sys/miscfs/procfs/procfs_fd.c +++ b/sys/miscfs/procfs/procfs_fd.c @@ -1,7 +1,7 @@ -/* $NetBSD: procfs_fd.c,v 1.12 2007/11/07 00:23:37 ad Exp $ */ +/* $NetBSD: procfs_fd.c,v 1.13 2008/03/21 21:55:00 ad Exp $ */ /*- - * Copyright (c) 2003 The NetBSD Foundation, Inc. + * Copyright (c) 2003, 2008 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -37,7 +37,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: procfs_fd.c,v 1.12 2007/11/07 00:23:37 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: procfs_fd.c,v 1.13 2008/03/21 21:55:00 ad Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -47,25 +47,18 @@ __KERNEL_RCSID(0, "$NetBSD: procfs_fd.c,v 1.12 2007/11/07 00:23:37 ad Exp $"); #include <sys/vnode.h> #include <sys/file.h> #include <sys/filedesc.h> + #include <miscfs/procfs/procfs.h> int -procfs_dofd( - struct lwp *curl, - struct proc *p, - struct pfsnode *pfs, - struct uio *uio -) +procfs_dofd(lwp_t *curl, proc_t *p, struct pfsnode *pfs, struct uio *uio) { int error; - struct file *fp; + file_t *fp; off_t offs; - fp = fd_getfile(p->p_fd, pfs->pfs_fd); - if (fp == NULL) - return (EBADF); - - FILE_USE(fp); + if ((fp = fd_getfile2(p, pfs->pfs_fd)) == NULL) + return EBADF; offs = fp->f_offset; @@ -74,13 +67,13 @@ procfs_dofd( error = (*fp->f_ops->fo_read)(fp, &offs, uio, curl->l_cred, 0); break; case UIO_WRITE: - error = (*fp->f_ops->fo_write)(fp, &offs, uio, curl->l_cred,0); + error = (*fp->f_ops->fo_write)(fp, &offs, uio, curl->l_cred, 0); break; default: panic("bad uio op"); } - FILE_UNUSE(fp, curl); + closef(fp); return (error); } diff --git a/sys/miscfs/procfs/procfs_subr.c b/sys/miscfs/procfs/procfs_subr.c index f7f527ac3e8..16bc03ce1b7 100644 --- a/sys/miscfs/procfs/procfs_subr.c +++ b/sys/miscfs/procfs/procfs_subr.c @@ -1,7 +1,7 @@ -/* $NetBSD: procfs_subr.c,v 1.85 2008/01/30 09:50:23 ad Exp $ */ +/* $NetBSD: procfs_subr.c,v 1.86 2008/03/21 21:55:00 ad Exp $ */ /*- - * Copyright (c) 2006, 2007 The NetBSD Foundation, Inc. + * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -109,7 +109,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: procfs_subr.c,v 1.85 2008/01/30 09:50:23 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: procfs_subr.c,v 1.86 2008/03/21 21:55:00 ad Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -227,20 +227,18 @@ procfs_allocvp(mp, vpp, pid, pfs_type, fd, p) pfs->pfs_mode = S_IRUSR|S_IXUSR; vp->v_type = VDIR; } else { /* /proc/N/fd/M = [ps-]rw------- */ - struct file *fp; - struct vnode *vxp; + file_t *fp; + vnode_t *vxp; - fp = fd_getfile(p->p_fd, pfs->pfs_fd); - if (fp == NULL) { + if ((fp = fd_getfile2(p, pfs->pfs_fd)) == NULL) { error = EBADF; goto bad; } - FILE_USE(fp); pfs->pfs_mode = S_IRUSR|S_IWUSR; switch (fp->f_type) { case DTYPE_VNODE: - vxp = (struct vnode *)fp->f_data; + vxp = fp->f_data; /* * We make symlinks for directories @@ -265,10 +263,10 @@ procfs_allocvp(mp, vpp, pid, pfs_type, fd, p) break; default: error = EOPNOTSUPP; - FILE_UNUSE(fp, curlwp); + closef(fp); goto bad; } - FILE_UNUSE(fp, curlwp); + closef(fp); } break; diff --git a/sys/miscfs/procfs/procfs_vnops.c b/sys/miscfs/procfs/procfs_vnops.c index 1530a92fedc..610ae600469 100644 --- a/sys/miscfs/procfs/procfs_vnops.c +++ b/sys/miscfs/procfs/procfs_vnops.c @@ -1,7 +1,7 @@ -/* $NetBSD: procfs_vnops.c,v 1.165 2008/01/23 15:04:40 elad Exp $ */ +/* $NetBSD: procfs_vnops.c,v 1.166 2008/03/21 21:55:00 ad Exp $ */ /*- - * Copyright (c) 2006, 2007 The NetBSD Foundation, Inc. + * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -112,7 +112,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: procfs_vnops.c,v 1.165 2008/01/23 15:04:40 elad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: procfs_vnops.c,v 1.166 2008/03/21 21:55:00 ad Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -793,14 +793,13 @@ procfs_getattr(v) case PFSfd: if (pfs->pfs_fd != -1) { - struct file *fp; + file_t *fp; - fp = fd_getfile(procp->p_fd, pfs->pfs_fd); + fp = fd_getfile2(procp, pfs->pfs_fd); if (fp == NULL) { error = EBADF; break; } - FILE_USE(fp); vap->va_nlink = 1; vap->va_uid = kauth_cred_geteuid(fp->f_cred); vap->va_gid = kauth_cred_getegid(fp->f_cred); @@ -813,7 +812,7 @@ procfs_getattr(v) vap->va_bytes = vap->va_size = 0; break; } - FILE_UNUSE(fp, curlwp); + closef(fp); break; } /*FALLTHROUGH*/ @@ -993,7 +992,6 @@ procfs_lookup(v) pid_t pid, vnpid; struct pfsnode *pfs; struct proc *p = NULL; - struct lwp *l = NULL; int i, error; pfstype type; @@ -1110,7 +1108,7 @@ procfs_lookup(v) case PFSfd: { int fd; - struct file *fp; + file_t *fp; if ((error = procfs_proc_lock(pfs->pfs_pid, &p, ENOENT)) != 0) return error; @@ -1130,19 +1128,17 @@ procfs_lookup(v) } fd = atoi(pname, cnp->cn_namelen); - fp = fd_getfile(p->p_fd, fd); + fp = fd_getfile2(p, fd); if (fp == NULL) { procfs_proc_unlock(p); return ENOENT; } - - FILE_USE(fp); - fvp = (struct vnode *)fp->f_data; + fvp = fp->f_data; /* Don't show directories */ if (fp->f_type == DTYPE_VNODE && fvp->v_type != VDIR) { VREF(fvp); - FILE_UNUSE(fp, l); + closef(fp); procfs_proc_unlock(p); vn_lock(fvp, LK_EXCLUSIVE | LK_RETRY | (p == curproc ? LK_CANRECURSE : 0)); @@ -1150,7 +1146,7 @@ procfs_lookup(v) return 0; } - FILE_UNUSE(fp, l); + closef(fp); error = procfs_allocvp(dvp->v_mount, vpp, pfs->pfs_pid, PFSfd, fd, p); procfs_proc_unlock(p); @@ -1336,8 +1332,7 @@ procfs_readdir(v) } case PFSfd: { struct proc *p; - struct filedesc *fdp; - struct file *fp; + file_t *fp; int lim, nc = 0; if ((error = procfs_proc_lock(pfs->pfs_pid, &p, ESRCH)) != 0) @@ -1352,8 +1347,7 @@ procfs_readdir(v) return ESRCH; } - fdp = p->p_fd; - nfd = fdp->fd_nfiles; + nfd = p->p_fd->fd_nfiles; lim = min((int)p->p_rlimit[RLIMIT_NOFILE].rlim_cur, maxfiles); if (i >= lim) { @@ -1387,9 +1381,9 @@ procfs_readdir(v) } for (; uio->uio_resid >= UIO_MX && i < nfd; i++) { /* check the descriptor exists */ - if ((fp = fd_getfile(fdp, i - 2)) == NULL) + if ((fp = fd_getfile2(p, i - 2)) == NULL) continue; - mutex_exit(&fp->f_lock); + closef(fp); d.d_fileno = PROCFS_FILENO(pfs->pfs_pid, PFSfd, i - 2); d.d_namlen = snprintf(d.d_name, sizeof(d.d_name), @@ -1558,30 +1552,27 @@ procfs_readlink(v) procfs_proc_unlock(pown); len = strlen(bp); } else { - struct file *fp; + file_t *fp; struct vnode *vxp, *vp; if ((error = procfs_proc_lock(pfs->pfs_pid, &pown, ESRCH)) != 0) return error; - fp = fd_getfile(pown->p_fd, pfs->pfs_fd); + fp = fd_getfile2(pown, pfs->pfs_fd); if (fp == NULL) { procfs_proc_unlock(pown); return EBADF; } - FILE_USE(fp); switch (fp->f_type) { case DTYPE_VNODE: vxp = (struct vnode *)fp->f_data; if (vxp->v_type != VDIR) { - FILE_UNUSE(fp, curlwp); error = EINVAL; break; } if ((path = malloc(MAXPATHLEN, M_TEMP, M_WAITOK)) == NULL) { - FILE_UNUSE(fp, curlwp); error = ENOMEM; break; } @@ -1620,7 +1611,7 @@ procfs_readlink(v) error = EINVAL; break; } - FILE_UNUSE(fp, curlwp); + closef(fp); procfs_proc_unlock(pown); } |
