diff options
Diffstat (limited to 'sys/miscfs/fdesc/fdesc_vnops.c')
-rw-r--r-- | sys/miscfs/fdesc/fdesc_vnops.c | 110 |
1 files changed, 60 insertions, 50 deletions
diff --git a/sys/miscfs/fdesc/fdesc_vnops.c b/sys/miscfs/fdesc/fdesc_vnops.c index 7d916ef544a..c9d702f0e43 100644 --- a/sys/miscfs/fdesc/fdesc_vnops.c +++ b/sys/miscfs/fdesc/fdesc_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fdesc_vnops.c,v 1.8 1997/10/06 15:19:01 csapuntz Exp $ */ +/* $OpenBSD: fdesc_vnops.c,v 1.9 1997/10/06 21:04:43 deraadt Exp $ */ /* $NetBSD: fdesc_vnops.c,v 1.32 1996/04/11 11:24:29 mrg Exp $ */ /* @@ -91,10 +91,11 @@ LIST_HEAD(fdhashhead, fdescnode) *fdhashtbl; u_long fdhash; int fdesc_badop __P((void *)); +int fdesc_enotsupp __P((void *)); int fdesc_lookup __P((void *)); -#define fdesc_create eopnotsupp -#define fdesc_mknod eopnotsupp +#define fdesc_create fdesc_enotsupp +#define fdesc_mknod fdesc_enotsupp int fdesc_open __P((void *)); #define fdesc_close nullop #define fdesc_access nullop @@ -104,35 +105,34 @@ int fdesc_read __P((void *)); int fdesc_write __P((void *)); int fdesc_ioctl __P((void *)); int fdesc_select __P((void *)); -#define fdesc_mmap eopnotsupp +#define fdesc_mmap fdesc_enotsupp #define fdesc_fsync nullop #define fdesc_seek nullop -#define fdesc_remove eopnotsupp -#define fdesc_revoke vop_revoke +#define fdesc_remove fdesc_enotsupp int fdesc_link __P((void *)); -#define fdesc_rename eopnotsupp -#define fdesc_mkdir eopnotsupp -#define fdesc_rmdir eopnotsupp +#define fdesc_rename fdesc_enotsupp +#define fdesc_mkdir fdesc_enotsupp +#define fdesc_rmdir fdesc_enotsupp int fdesc_symlink __P((void *)); int fdesc_readdir __P((void *)); int fdesc_readlink __P((void *)); int fdesc_abortop __P((void *)); int fdesc_inactive __P((void *)); int fdesc_reclaim __P((void *)); -#define fdesc_lock vop_nolock -#define fdesc_unlock vop_nounlock +#define fdesc_lock nullop +#define fdesc_unlock nullop #define fdesc_bmap fdesc_badop #define fdesc_strategy fdesc_badop int fdesc_print __P((void *)); int fdesc_pathconf __P((void *)); -#define fdesc_islocked vop_noislocked -#define fdesc_advlock eopnotsupp -#define fdesc_blkatoff eopnotsupp -#define fdesc_valloc eopnotsupp +#define fdesc_islocked nullop +#define fdesc_advlock fdesc_enotsupp +#define fdesc_blkatoff fdesc_enotsupp +#define fdesc_valloc fdesc_enotsupp int fdesc_vfree __P((void *)); -#define fdesc_truncate eopnotsupp -#define fdesc_update eopnotsupp -#define fdesc_bwrite eopnotsupp +#define fdesc_truncate fdesc_enotsupp +#define fdesc_update fdesc_enotsupp +#define fdesc_bwrite fdesc_enotsupp static int fdesc_attr __P((int, struct vattr *, struct ucred *, struct proc *)); @@ -150,7 +150,6 @@ struct vnodeopv_entry_desc fdesc_vnodeop_entries[] = { { &vop_read_desc, fdesc_read }, /* read */ { &vop_write_desc, fdesc_write }, /* write */ { &vop_ioctl_desc, fdesc_ioctl }, /* ioctl */ - { &vop_revoke_desc, fdesc_revoke }, /* revoke */ { &vop_select_desc, fdesc_select }, /* select */ { &vop_mmap_desc, fdesc_mmap }, /* mmap */ { &vop_fsync_desc, fdesc_fsync }, /* fsync */ @@ -189,9 +188,8 @@ struct vnodeopv_desc fdesc_vnodeop_opv_desc = /* * Initialise cache headers */ -int -fdesc_init(vfsp) - struct vfsconf *vfsp; +void +fdesc_init() { int cttymajor; @@ -201,7 +199,6 @@ fdesc_init(vfsp) break; devctty = makedev(cttymajor, 0); fdhashtbl = hashinit(NFDCACHE, M_CACHE, &fdhash); - return (0); } int @@ -211,7 +208,6 @@ fdesc_allocvp(ftype, ix, mp, vpp) struct mount *mp; struct vnode **vpp; { - struct proc *p = curproc; /* XXX */ struct fdhashhead *fc; struct fdescnode *fd; int error = 0; @@ -220,7 +216,7 @@ fdesc_allocvp(ftype, ix, mp, vpp) loop: for (fd = fc->lh_first; fd != 0; fd = fd->fd_hash.le_next) { if (fd->fd_ix == ix && fd->fd_vnode->v_mount == mp) { - if (vget(fd->fd_vnode, 0, p)) + if (vget(fd->fd_vnode, 0)) goto loop; *vpp = fd->fd_vnode; return (error); @@ -276,23 +272,25 @@ fdesc_lookup(v) } */ *ap = v; struct vnode **vpp = ap->a_vpp; struct vnode *dvp = ap->a_dvp; - struct componentname *cnp = ap->a_cnp; - char *pname = cnp->cn_nameptr; - struct proc *p = cnp->cn_proc; - int nfiles = p->p_fd->fd_nfiles; + char *pname; + struct proc *p; + int nfiles; unsigned fd = 0; int error; struct vnode *fvp; char *ln; - VOP_UNLOCK(dvp, 0, p); - if (cnp->cn_namelen == 1 && *pname == '.') { + pname = ap->a_cnp->cn_nameptr; + if (ap->a_cnp->cn_namelen == 1 && *pname == '.') { *vpp = dvp; - VREF(dvp); - vn_lock(dvp, LK_SHARED | LK_RETRY, p); + VREF(dvp); + VOP_LOCK(dvp); return (0); } + p = ap->a_cnp->cn_proc; + nfiles = p->p_fd->fd_nfiles; + switch (VTOFDESC(dvp)->fd_type) { default: case Flink: @@ -302,17 +300,17 @@ fdesc_lookup(v) goto bad; case Froot: - if (cnp->cn_namelen == 2 && bcmp(pname, "fd", 2) == 0) { + if (ap->a_cnp->cn_namelen == 2 && bcmp(pname, "fd", 2) == 0) { error = fdesc_allocvp(Fdevfd, FD_DEVFD, dvp->v_mount, &fvp); if (error) goto bad; *vpp = fvp; fvp->v_type = VDIR; - vn_lock(fvp, LK_SHARED | LK_RETRY, p); + VOP_LOCK(fvp); return (0); } - if (cnp->cn_namelen == 3 && bcmp(pname, "tty", 3) == 0) { + if (ap->a_cnp->cn_namelen == 3 && bcmp(pname, "tty", 3) == 0) { struct vnode *ttyvp = cttyvp(p); if (ttyvp == NULL) { error = ENXIO; @@ -323,12 +321,12 @@ fdesc_lookup(v) goto bad; *vpp = fvp; fvp->v_type = VCHR; - vn_lock(fvp, LK_SHARED | LK_RETRY, p); + VOP_LOCK(fvp); return (0); } ln = 0; - switch (cnp->cn_namelen) { + switch (ap->a_cnp->cn_namelen) { case 5: if (bcmp(pname, "stdin", 5) == 0) { ln = "fd/0"; @@ -354,7 +352,7 @@ fdesc_lookup(v) VTOFDESC(fvp)->fd_link = ln; *vpp = fvp; fvp->v_type = VLNK; - vn_lock(fvp, LK_SHARED | LK_RETRY, p); + VOP_LOCK(fvp); return (0); } else { error = ENOENT; @@ -364,11 +362,9 @@ fdesc_lookup(v) /* FALL THROUGH */ case Fdevfd: - if (cnp->cn_namelen == 2 && bcmp(pname, "..", 2) == 0) { - if ((error = fdesc_root(dvp->v_mount, vpp))) - goto bad; - - return (0); + if (ap->a_cnp->cn_namelen == 2 && bcmp(pname, "..", 2) == 0) { + error = fdesc_root(dvp->v_mount, vpp); + return (error); } fd = 0; @@ -392,13 +388,11 @@ fdesc_lookup(v) if (error) goto bad; VTOFDESC(fvp)->fd_fd = fd; - vn_lock(fvp, LK_SHARED | LK_RETRY, p); *vpp = fvp; return (0); } bad:; - vn_lock(dvp, LK_SHARED | LK_RETRY, p); *vpp = NULL; return (error); } @@ -689,14 +683,16 @@ fdesc_readdir(v) struct uio *a_uio; struct ucred *a_cred; int *a_eofflag; - int *a_ncookies; - u_long **a_cookies; + u_long *a_cookies; + int a_ncookies; } */ *ap = v; struct uio *uio = ap->a_uio; struct dirent d; struct filedesc *fdp; int i; int error; + u_long *cookies = ap->a_cookies; + int ncookies = ap->a_ncookies; switch (VTOFDESC(ap->a_vp)->fd_type) { case Fctty: @@ -749,6 +745,8 @@ fdesc_readdir(v) if ((error = uiomove((caddr_t)&d, UIO_MX, uio)) != 0) break; + if (ncookies-- > 0) + *cookies++ = i + 1; } } else { for (; i - 2 < fdp->fd_nfiles && uio->uio_resid >= UIO_MX; @@ -774,6 +772,8 @@ fdesc_readdir(v) if ((error = uiomove((caddr_t)&d, UIO_MX, uio)) != 0) break; + if (ncookies-- > 0) + *cookies++ = i + 1; } } @@ -916,7 +916,6 @@ fdesc_inactive(v) { struct vop_inactive_args /* { struct vnode *a_vp; - struct proc *a_p; } */ *ap = v; struct vnode *vp = ap->a_vp; @@ -924,7 +923,6 @@ fdesc_inactive(v) * Clear out the v_type field to avoid * nasty things happening in vgone(). */ - VOP_UNLOCK(vp, 0, ap->a_p); vp->v_type = VNON; return (0); } @@ -1050,6 +1048,18 @@ fdesc_abortop(v) } /* + * /dev/fd vnode unsupported operation + */ +/*ARGSUSED*/ +int +fdesc_enotsupp(v) + void *v; +{ + + return (EOPNOTSUPP); +} + +/* * /dev/fd "should never get here" operation */ /*ARGSUSED*/ |