diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1997-10-06 21:04:52 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1997-10-06 21:04:52 +0000 |
commit | d042ad0a2a321d6b685d1212df8e2c67b693ea38 (patch) | |
tree | 9b948218c6c8713f2b26a74216c652e6d8d2de78 /sys/miscfs/fdesc | |
parent | 63fbed82d279556a12545b0450cba696bbe74d53 (diff) |
back out vfs lite2 till after 2.2
Diffstat (limited to 'sys/miscfs/fdesc')
-rw-r--r-- | sys/miscfs/fdesc/fdesc.h | 4 | ||||
-rw-r--r-- | sys/miscfs/fdesc/fdesc_vfsops.c | 81 | ||||
-rw-r--r-- | sys/miscfs/fdesc/fdesc_vnops.c | 110 |
3 files changed, 124 insertions, 71 deletions
diff --git a/sys/miscfs/fdesc/fdesc.h b/sys/miscfs/fdesc/fdesc.h index 9a2aa369ad3..35b28bfb755 100644 --- a/sys/miscfs/fdesc/fdesc.h +++ b/sys/miscfs/fdesc/fdesc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: fdesc.h,v 1.3 1997/10/06 15:19:00 csapuntz Exp $ */ +/* $OpenBSD: fdesc.h,v 1.4 1997/10/06 21:04:42 deraadt Exp $ */ /* $NetBSD: fdesc.h,v 1.9 1996/02/09 22:40:03 christos Exp $ */ /* @@ -76,7 +76,7 @@ struct fdescnode { #define VTOFDESC(vp) ((struct fdescnode *)(vp)->v_data) extern dev_t devctty; -extern int fdesc_init __P((struct vfsconf *)); +extern void fdesc_init __P((void)); extern int fdesc_root __P((struct mount *, struct vnode **)); extern int fdesc_allocvp __P((fdntype, int, struct mount *, struct vnode **)); extern int (**fdesc_vnodeop_p) __P((void *)); diff --git a/sys/miscfs/fdesc/fdesc_vfsops.c b/sys/miscfs/fdesc/fdesc_vfsops.c index 33a6f5589cc..f6493dd5c4f 100644 --- a/sys/miscfs/fdesc/fdesc_vfsops.c +++ b/sys/miscfs/fdesc/fdesc_vfsops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fdesc_vfsops.c,v 1.3 1997/10/06 15:19:01 csapuntz Exp $ */ +/* $OpenBSD: fdesc_vfsops.c,v 1.4 1997/10/06 21:04:42 deraadt Exp $ */ /* $NetBSD: fdesc_vfsops.c,v 1.21 1996/02/09 22:40:07 christos Exp $ */ /* @@ -105,7 +105,7 @@ fdesc_mount(mp, path, data, ndp, p) fmp->f_root = rvp; mp->mnt_flag |= MNT_LOCAL; mp->mnt_data = (qaddr_t)fmp; - vfs_getnewfsid(mp); + getnewfsid(mp, makefstype(MOUNT_FDESC)); (void) copyinstr(path, mp->mnt_stat.f_mntonname, MNAMELEN - 1, &size); bzero(mp->mnt_stat.f_mntonname + size, MNAMELEN - size); @@ -131,10 +131,15 @@ fdesc_unmount(mp, mntflags, p) { int error; int flags = 0; + extern int doforce; struct vnode *rootvp = VFSTOFDESC(mp)->f_root; - if (mntflags & MNT_FORCE) + if (mntflags & MNT_FORCE) { + /* fdesc can never be rootfs so don't check for it */ + if (!doforce) + return (EINVAL); flags |= FORCECLOSE; + } /* * Clear out buffer cache. I don't think we @@ -169,18 +174,30 @@ fdesc_root(mp, vpp) struct vnode **vpp; { struct vnode *vp; - struct proc *p = curproc; /* XXX */ + /* * Return locked reference to root. */ vp = VFSTOFDESC(mp)->f_root; VREF(vp); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + VOP_LOCK(vp); *vpp = vp; return (0); } int +fdesc_quotactl(mp, cmd, uid, arg, p) + struct mount *mp; + int cmd; + uid_t uid; + caddr_t arg; + struct proc *p; +{ + + return (EOPNOTSUPP); +} + +int fdesc_statfs(mp, sbp, p) struct mount *mp; struct statfs *sbp; @@ -226,12 +243,11 @@ fdesc_statfs(mp, sbp, p) sbp->f_files = lim + 1; /* Allow for "." */ sbp->f_ffree = freefd; /* See comments above */ if (sbp != &mp->mnt_stat) { - sbp->f_type = mp->mnt_vfc->vfc_typenum; bcopy(&mp->mnt_stat.f_fsid, &sbp->f_fsid, sizeof(sbp->f_fsid)); bcopy(mp->mnt_stat.f_mntonname, sbp->f_mntonname, MNAMELEN); bcopy(mp->mnt_stat.f_mntfromname, sbp->f_mntfromname, MNAMELEN); } - strncpy(sbp->f_fstypename, mp->mnt_vfc->vfc_name, MFSNAMELEN); + strncpy(sbp->f_fstypename, mp->mnt_op->vfs_name, MFSNAMELEN); return (0); } @@ -247,17 +263,46 @@ fdesc_sync(mp, waitfor, uc, p) return (0); } -#define fdesc_fhtovp ((int (*) __P((struct mount *, struct fid *, \ - struct mbuf *, struct vnode **, int *, struct ucred **)))eopnotsupp) -#define fdesc_quotactl ((int (*) __P((struct mount *, int, uid_t, caddr_t, \ - struct proc *)))eopnotsupp) -#define fdesc_sysctl ((int (*) __P((int *, u_int, void *, size_t *, void *, \ - size_t, struct proc *)))eopnotsupp) -#define fdesc_vget ((int (*) __P((struct mount *, ino_t, struct vnode **))) \ - eopnotsupp) -#define fdesc_vptofh ((int (*) __P((struct vnode *, struct fid *)))eopnotsupp) - +/* + * Fdesc flat namespace lookup. + * Currently unsupported. + */ +int +fdesc_vget(mp, ino, vpp) + struct mount *mp; + ino_t ino; + struct vnode **vpp; +{ + + return (EOPNOTSUPP); +} + + +/*ARGSUSED*/ +int +fdesc_fhtovp(mp, fhp, nam, vpp, exflagsp, credanonp) + struct mount *mp; + struct fid *fhp; + struct mbuf *nam; + struct vnode **vpp; + int *exflagsp; + struct ucred **credanonp; +{ + + return (EOPNOTSUPP); +} + +/*ARGSUSED*/ +int +fdesc_vptofh(vp, fhp) + struct vnode *vp; + struct fid *fhp; +{ + return (EOPNOTSUPP); +} + struct vfsops fdesc_vfsops = { + MOUNT_FDESC, fdesc_mount, fdesc_start, fdesc_unmount, @@ -269,6 +314,4 @@ struct vfsops fdesc_vfsops = { fdesc_fhtovp, fdesc_vptofh, fdesc_init, - fdesc_sysctl }; - 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*/ |