From 10f666af84d48e89e4e2960415c9b616fce4077f Mon Sep 17 00:00:00 2001 From: dyson Date: Mon, 10 Feb 1997 02:22:35 +0000 Subject: This is the kernel Lite/2 commit. There are some requisite userland changes, so don't expect to be able to run the kernel as-is (very well) without the appropriate Lite/2 userland changes. The system boots and can mount UFS filesystems. Untested: ext2fs, msdosfs, NFS Known problems: Incorrect Berkeley ID strings in some files. Mount_std mounts will not work until the getfsent library routine is changed. Reviewed by: various people Submitted by: Jeffery Hsu --- sys/fs/portalfs/portal_vfsops.c | 97 +++++++++-------------------------------- sys/fs/portalfs/portal_vnops.c | 57 ++++++++++++++++-------- 2 files changed, 60 insertions(+), 94 deletions(-) (limited to 'sys/fs/portalfs') diff --git a/sys/fs/portalfs/portal_vfsops.c b/sys/fs/portalfs/portal_vfsops.c index a980f65..74e1542 100644 --- a/sys/fs/portalfs/portal_vfsops.c +++ b/sys/fs/portalfs/portal_vfsops.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1992, 1993 + * Copyright (c) 1992, 1993, 1995 * The Regents of the University of California. All rights reserved. * * This code is derived from software donated to Berkeley by @@ -33,7 +33,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)portal_vfsops.c 8.6 (Berkeley) 1/21/94 + * @(#)portal_vfsops.c 8.11 (Berkeley) 5/14/95 * * $FreeBSD$ */ @@ -62,28 +62,18 @@ #include #include -static int portal_init __P((void)); static int portal_mount __P((struct mount *mp, char *path, caddr_t data, struct nameidata *ndp, struct proc *p)); static int portal_start __P((struct mount *mp, int flags, struct proc *p)); static int portal_unmount __P((struct mount *mp, int mntflags, struct proc *p)); static int portal_root __P((struct mount *mp, struct vnode **vpp)); -static int portal_quotactl __P((struct mount *mp, int cmd, uid_t uid, - caddr_t arg, struct proc *p)); static int portal_statfs __P((struct mount *mp, struct statfs *sbp, struct proc *p)); -static int portal_sync __P((struct mount *mp, int waitfor, - struct ucred *cred, struct proc *p)); -static int portal_vget __P((struct mount *mp, ino_t ino, - struct vnode **vpp)); -static int portal_fhtovp __P((struct mount *mp, struct fid *fhp, - struct mbuf *nam, struct vnode **vpp, - int *exflagsp, struct ucred **credanonp)); -static int portal_vptofh __P((struct vnode *vp, struct fid *fhp)); static int -portal_init() +portal_init(vfsp) + struct vfsconf *vfsp; { return (0); @@ -150,7 +140,7 @@ portal_mount(mp, path, data, ndp, p) mp->mnt_flag |= MNT_LOCAL; mp->mnt_data = (qaddr_t) fmp; - getnewfsid(mp, MOUNT_PORTAL); + vfs_getnewfsid(mp); (void)copyinstr(path, mp->mnt_stat.f_mntonname, MNAMELEN - 1, &size); bzero(mp->mnt_stat.f_mntonname + size, MNAMELEN - size); @@ -186,12 +176,8 @@ portal_unmount(mp, mntflags, p) int error, flags = 0; - if (mntflags & MNT_FORCE) { - /* portal can never be rootfs so don't check for it */ - if (!doforce) - return (EINVAL); + if (mntflags & MNT_FORCE) flags |= FORCECLOSE; - } /* * Clear out buffer cache. I don't think we @@ -241,39 +227,26 @@ portal_root(mp, vpp) struct mount *mp; struct vnode **vpp; { + struct proc *p = curproc; /* XXX */ struct vnode *vp; - /* * Return locked reference to root. */ vp = VFSTOPORTAL(mp)->pm_root; VREF(vp); - VOP_LOCK(vp); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); *vpp = vp; return (0); } static int -portal_quotactl(mp, cmd, uid, arg, p) - struct mount *mp; - int cmd; - uid_t uid; - caddr_t arg; - struct proc *p; -{ - - return (EOPNOTSUPP); -} - -static int portal_statfs(mp, sbp, p) struct mount *mp; struct statfs *sbp; struct proc *p; { - sbp->f_type = MOUNT_PORTAL; sbp->f_flags = 0; sbp->f_bsize = DEV_BSIZE; sbp->f_iosize = DEV_BSIZE; @@ -283,6 +256,7 @@ portal_statfs(mp, sbp, p) sbp->f_files = 1; /* Allow for "." */ sbp->f_ffree = 0; /* 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); @@ -290,48 +264,17 @@ portal_statfs(mp, sbp, p) return (0); } -static int -portal_sync(mp, waitfor, cred, p) - struct mount *mp; - int waitfor; - struct ucred *cred; - struct proc *p; -{ - - return (0); -} - -static int -portal_vget(mp, ino, vpp) - struct mount *mp; - ino_t ino; - struct vnode **vpp; -{ - - return (EOPNOTSUPP); -} - -static int -portal_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); -} - -static int -portal_vptofh(vp, fhp) - struct vnode *vp; - struct fid *fhp; -{ - - return (EOPNOTSUPP); -} +#define portal_fhtovp ((int (*) __P((struct mount *, struct fid *, \ + struct mbuf *, struct vnode **, int *, struct ucred **)))eopnotsupp) +#define portal_quotactl ((int (*) __P((struct mount *, int, uid_t, caddr_t, \ + struct proc *)))eopnotsupp) +#define portal_sync ((int (*) __P((struct mount *, int, struct ucred *, \ + struct proc *)))nullop) +#define portal_sysctl ((int (*) __P((int *, u_int, void *, size_t *, void *, \ + size_t, struct proc *)))eopnotsupp) +#define portal_vget ((int (*) __P((struct mount *, ino_t, struct vnode **))) \ + eopnotsupp) +#define portal_vptofh ((int (*) __P((struct vnode *, struct fid *)))eopnotsupp) static struct vfsops portal_vfsops = { portal_mount, diff --git a/sys/fs/portalfs/portal_vnops.c b/sys/fs/portalfs/portal_vnops.c index 8135a5e..19b439c 100644 --- a/sys/fs/portalfs/portal_vnops.c +++ b/sys/fs/portalfs/portal_vnops.c @@ -33,7 +33,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)portal_vnops.c 8.8 (Berkeley) 1/21/94 + * @(#)portal_vnops.c 8.14 (Berkeley) 5/21/95 * * $FreeBSD$ */ @@ -112,17 +112,25 @@ portal_lookup(ap) struct componentname * a_cnp; } */ *ap; { - char *pname = ap->a_cnp->cn_nameptr; + struct componentname *cnp = ap->a_cnp; + struct vnode **vpp = ap->a_vpp; + struct vnode *dvp = ap->a_dvp; + char *pname = cnp->cn_nameptr; struct portalnode *pt; int error; struct vnode *fvp = 0; char *path; int size; - if (ap->a_cnp->cn_namelen == 1 && *pname == '.') { - *ap->a_vpp = ap->a_dvp; - VREF(ap->a_dvp); - /*VOP_LOCK(ap->a_dvp);*/ + *vpp = NULLVP; + + if (cnp->cn_nameiop == DELETE || cnp->cn_nameiop == RENAME) + return (EROFS); + + if (cnp->cn_namelen == 1 && *pname == '.') { + *vpp = dvp; + VREF(dvp); + /*VOP_LOCK(dvp);*/ return (0); } @@ -134,7 +142,7 @@ portal_lookup(ap) MALLOC(pt, struct portalnode *, sizeof(struct portalnode), M_TEMP, M_WAITOK); - error = getnewvnode(VT_PORTAL, ap->a_dvp->v_mount, portal_vnodeop_p, &fvp); + error = getnewvnode(VT_PORTAL, dvp->v_mount, portal_vnodeop_p, &fvp); if (error) { FREE(pt, M_TEMP); goto bad; @@ -148,22 +156,20 @@ portal_lookup(ap) */ for (size = 0, path = pname; *path; path++) size++; - ap->a_cnp->cn_consume = size - ap->a_cnp->cn_namelen; + cnp->cn_consume = size - cnp->cn_namelen; pt->pt_arg = malloc(size+1, M_TEMP, M_WAITOK); pt->pt_size = size+1; bcopy(pname, pt->pt_arg, pt->pt_size); pt->pt_fileid = portal_fileid++; - *ap->a_vpp = fvp; + *vpp = fvp; /*VOP_LOCK(fvp);*/ return (0); bad:; - if (fvp) { + if (fvp) vrele(fvp); - } - *ap->a_vpp = NULL; return (error); } @@ -444,6 +450,7 @@ portal_getattr(ap) { struct vnode *vp = ap->a_vp; struct vattr *vap = ap->a_vap; + struct timeval tv; bzero(vap, sizeof(*vap)); vattr_null(vap); @@ -452,8 +459,8 @@ portal_getattr(ap) vap->va_fsid = vp->v_mount->mnt_stat.f_fsid.val[0]; vap->va_size = DEV_BSIZE; vap->va_blocksize = DEV_BSIZE; - microtime((struct timeval *)&vap->va_atime); - TIMEVAL_TO_TIMESPEC((struct timeval *)&vap->va_atime, (struct timespec *)&vap->va_atime); + microtime(&tv); + TIMEVAL_TO_TIMESPEC(&tv, &vap->va_atime); vap->va_mtime = vap->va_atime; vap->va_ctime = vap->va_ctime; vap->va_gen = 0; @@ -509,9 +516,19 @@ portal_readdir(ap) struct vnode *a_vp; struct uio *a_uio; struct ucred *a_cred; + int *a_eofflag; + u_long *a_cookies; + int a_ncookies; } */ *ap; { + /* + * We don't allow exporting portal mounts, and currently local + * requests do not need cookies. + */ + if (ap->a_ncookies) + panic("portal_readdir: not hungry"); + return (0); } @@ -519,9 +536,11 @@ static int portal_inactive(ap) struct vop_inactive_args /* { struct vnode *a_vp; + struct proc *a_p; } */ *ap; { + VOP_UNLOCK(ap->a_vp, 0, ap->a_p); return (0); } @@ -639,6 +658,7 @@ portal_badop() #define portal_ioctl ((int (*) __P((struct vop_ioctl_args *)))portal_enotsupp) #define portal_select ((int (*) __P((struct vop_select_args *)))portal_enotsupp) #define portal_mmap ((int (*) __P((struct vop_mmap_args *)))portal_enotsupp) +#define portal_revoke vop_revoke #define portal_fsync ((int (*) __P((struct vop_fsync_args *)))nullop) #define portal_seek ((int (*) __P((struct vop_seek_args *)))nullop) #define portal_remove ((int (*) __P((struct vop_remove_args *)))portal_enotsupp) @@ -651,12 +671,14 @@ portal_badop() #define portal_readlink \ ((int (*) __P((struct vop_readlink_args *)))portal_enotsupp) #define portal_abortop ((int (*) __P((struct vop_abortop_args *)))nullop) -#define portal_lock ((int (*) __P((struct vop_lock_args *)))nullop) -#define portal_unlock ((int (*) __P((struct vop_unlock_args *)))nullop) +#define portal_lock ((int (*) __P((struct vop_lock_args *)))vop_nolock) +#define portal_unlock ((int (*) __P((struct vop_unlock_args *)))vop_nounlock) #define portal_bmap ((int (*) __P((struct vop_bmap_args *)))portal_badop) #define portal_strategy \ ((int (*) __P((struct vop_strategy_args *)))portal_badop) -#define portal_islocked ((int (*) __P((struct vop_islocked_args *)))nullop) +#define portal_islocked \ + ((int (*) __P((struct vop_islocked_args *)))vop_noislocked) +#define fifo_islocked ((int(*) __P((struct vop_islocked_args *)))vop_noislocked) #define portal_advlock \ ((int (*) __P((struct vop_advlock_args *)))portal_enotsupp) #define portal_blkatoff \ @@ -687,6 +709,7 @@ static struct vnodeopv_entry_desc portal_vnodeop_entries[] = { { &vop_ioctl_desc, (vop_t *)portal_ioctl }, /* ioctl */ { &vop_select_desc, (vop_t *)portal_select }, /* select */ { &vop_mmap_desc, (vop_t *)portal_mmap }, /* mmap */ + { &vop_revoke_desc, (vop_t *)portal_revoke }, /* revoke */ { &vop_fsync_desc, (vop_t *)portal_fsync }, /* fsync */ { &vop_seek_desc, (vop_t *)portal_seek }, /* seek */ { &vop_remove_desc, (vop_t *)portal_remove }, /* remove */ -- cgit v1.1