diff options
author | Niklas Hallqvist <niklas@cvs.openbsd.org> | 1996-02-27 08:09:04 +0000 |
---|---|---|
committer | Niklas Hallqvist <niklas@cvs.openbsd.org> | 1996-02-27 08:09:04 +0000 |
commit | cc3168f1451f2932dea676a480d95729d9900183 (patch) | |
tree | 32c98bb3688ab7410d3d97f643ef2f9ab90da2c7 /sys | |
parent | 08747189dfbfeed5008511fba7bd5f54eabd6b9a (diff) |
From NetBSD: update to 960217 sources
Diffstat (limited to 'sys')
-rw-r--r-- | sys/miscfs/union/union.h | 9 | ||||
-rw-r--r-- | sys/miscfs/union/union_subr.c | 28 | ||||
-rw-r--r-- | sys/miscfs/union/union_vfsops.c | 37 | ||||
-rw-r--r-- | sys/miscfs/union/union_vnops.c | 477 |
4 files changed, 334 insertions, 217 deletions
diff --git a/sys/miscfs/union/union.h b/sys/miscfs/union/union.h index 71db34cad6f..e7485705181 100644 --- a/sys/miscfs/union/union.h +++ b/sys/miscfs/union/union.h @@ -1,4 +1,5 @@ -/* $NetBSD: union.h,v 1.8 1995/05/30 18:55:28 mycroft Exp $ */ +/* $OpenBSD: union.h,v 1.2 1996/02/27 08:08:59 niklas Exp $ */ +/* $NetBSD: union.h,v 1.9 1996/02/09 22:41:08 christos Exp $ */ /* * Copyright (c) 1994 The Regents of the University of California. @@ -127,6 +128,10 @@ extern void union_newsize __P((struct vnode *, off_t, off_t)); #define UPPERVP(vp) (VTOUNION(vp)->un_uppervp) #define OTHERVP(vp) (UPPERVP(vp) ? UPPERVP(vp) : LOWERVP(vp)) -extern int (**union_vnodeop_p)(); +extern int (**union_vnodeop_p) __P((void *)); extern struct vfsops union_vfsops; + +void union_init __P((void)); +int union_freevp __P((struct vnode *)); + #endif /* _KERNEL */ diff --git a/sys/miscfs/union/union_subr.c b/sys/miscfs/union/union_subr.c index 4a74d33cd60..9a5827bccf1 100644 --- a/sys/miscfs/union/union_subr.c +++ b/sys/miscfs/union/union_subr.c @@ -1,4 +1,5 @@ -/* $NetBSD: union_subr.c,v 1.17 1995/10/05 06:26:12 mycroft Exp $ */ +/* $OpenBSD: union_subr.c,v 1.2 1996/02/27 08:09:00 niklas Exp $ */ +/* $NetBSD: union_subr.c,v 1.18 1996/02/09 22:41:10 christos Exp $ */ /* * Copyright (c) 1994 Jan-Simon Pendry @@ -69,7 +70,17 @@ static LIST_HEAD(unhead, union_node) unhead[NHASH]; static int unvplock[NHASH]; -int +static int union_list_lock __P((int)); +static void union_list_unlock __P((int)); +void union_updatevp __P((struct union_node *, struct vnode *, struct vnode *)); +static int union_relookup __P((struct union_mount *, struct vnode *, + struct vnode **, struct componentname *, + struct componentname *, char *, int)); +int union_vn_close __P((struct vnode *, int, struct ucred *, struct proc *)); +static void union_dircache_r __P((struct vnode *, struct vnode ***, int *)); +struct vnode *union_dircache __P((struct vnode *)); + +void union_init() { int i; @@ -275,11 +286,10 @@ union_allocvp(vpp, mp, undvp, dvp, cnp, uppervp, lowervp, docache) int docache; { int error; - struct union_node *un; - struct union_node **pp; + struct union_node *un = NULL; struct vnode *xlowervp = NULLVP; struct union_mount *um = MOUNTTOUNIONMOUNT(mp); - int hash; + int hash = 0; int vflag; int try; @@ -809,7 +819,6 @@ union_mkwhiteout(um, dvp, cnp, path) char *path; { int error; - struct vattr va; struct proc *p = cnp->cn_proc; struct vnode *wvp; struct componentname cn; @@ -861,7 +870,6 @@ union_vn_create(vpp, un, p) int fmode = FFLAGS(O_WRONLY|O_CREAT|O_TRUNC|O_EXCL); int error; int cmode = UN_FILEMODE & ~p->p_fd->fd_cmask; - char *cp; struct componentname cn; *vpp = NULLVP; @@ -887,7 +895,7 @@ union_vn_create(vpp, un, p) cn.cn_consume = 0; VREF(un->un_dirvp); - if (error = relookup(un->un_dirvp, &vp, &cn)) + if ((error = relookup(un->un_dirvp, &vp, &cn)) != 0) return (error); vrele(un->un_dirvp); @@ -915,10 +923,10 @@ union_vn_create(vpp, un, p) vap->va_type = VREG; vap->va_mode = cmode; VOP_LEASE(un->un_dirvp, p, cred, LEASE_WRITE); - if (error = VOP_CREATE(un->un_dirvp, &vp, &cn, vap)) + if ((error = VOP_CREATE(un->un_dirvp, &vp, &cn, vap)) != 0) return (error); - if (error = VOP_OPEN(vp, fmode, cred, p)) { + if ((error = VOP_OPEN(vp, fmode, cred, p)) != 0) { vput(vp); return (error); } diff --git a/sys/miscfs/union/union_vfsops.c b/sys/miscfs/union/union_vfsops.c index f85b9c0d4fc..654d6ba0acc 100644 --- a/sys/miscfs/union/union_vfsops.c +++ b/sys/miscfs/union/union_vfsops.c @@ -1,3 +1,4 @@ +/* $OpenBSD: union_vfsops.c,v 1.2 1996/02/27 08:09:02 niklas Exp $ */ /* $NetBSD: union_vfsops.c,v 1.10 1995/06/18 14:47:47 cgd Exp $ */ /* @@ -56,6 +57,19 @@ #include <sys/queue.h> #include <miscfs/union/union.h> +int union_mount __P((struct mount *, char *, caddr_t, struct nameidata *, + struct proc *)); +int union_start __P((struct mount *, int, struct proc *)); +int union_unmount __P((struct mount *, int, struct proc *)); +int union_root __P((struct mount *, struct vnode **)); +int union_quotactl __P((struct mount *, int, uid_t, caddr_t, struct proc *)); +int union_statfs __P((struct mount *, struct statfs *, struct proc *)); +int union_sync __P((struct mount *, int, struct ucred *, struct proc *)); +int union_vget __P((struct mount *, ino_t, struct vnode **)); +int union_fhtovp __P((struct mount *, struct fid *, struct mbuf *, + struct vnode **, int *, struct ucred **)); +int union_vptofh __P((struct vnode *, struct fid *)); + /* * Mount union filesystem */ @@ -73,8 +87,6 @@ union_mount(mp, path, data, ndp, p) struct vnode *upperrootvp = NULLVP; struct union_mount *um = 0; struct ucred *cred = 0; - struct ucred *scred; - struct vattr va; char *cp; int len; size_t size; @@ -99,7 +111,8 @@ union_mount(mp, path, data, ndp, p) /* * Get argument */ - if (error = copyin(data, (caddr_t)&args, sizeof(struct union_args))) + error = copyin(data, (caddr_t)&args, sizeof(struct union_args)); + if (error) goto bad; lowerrootvp = mp->mnt_vnodecovered; @@ -111,7 +124,7 @@ union_mount(mp, path, data, ndp, p) NDINIT(ndp, LOOKUP, FOLLOW|WANTPARENT, UIO_USERSPACE, args.target, p); - if (error = namei(ndp)) + if ((error = namei(ndp)) != 0) goto bad; upperrootvp = ndp->ni_vp; @@ -214,6 +227,12 @@ union_mount(mp, path, data, ndp, p) case UNMNT_REPLACE: cp = ""; break; + default: + cp = "<invalid>:"; +#ifdef DIAGNOSTIC + panic("union_mount: bad um_op"); +#endif + break; } len = strlen(cp); bcopy(cp, mp->mnt_stat.f_mntfromname, len); @@ -247,6 +266,7 @@ bad: * on the underlying filesystem(s) will have been called * when that filesystem was mounted. */ + /*ARGSUSED*/ int union_start(mp, flags, p) struct mount *mp; @@ -284,7 +304,7 @@ union_unmount(mp, mntflags, p) flags |= FORCECLOSE; } - if (error = union_root(mp, &um_rootvp)) + if ((error = union_root(mp, &um_rootvp)) != 0) return (error); /* @@ -390,6 +410,7 @@ union_root(mp, vpp) return (error); } +/*ARGSUSED*/ int union_quotactl(mp, cmd, uid, arg, p) struct mount *mp; @@ -476,6 +497,7 @@ union_statfs(mp, sbp, p) return (0); } +/*ARGSUSED*/ int union_sync(mp, waitfor, cred, p) struct mount *mp; @@ -490,6 +512,7 @@ union_sync(mp, waitfor, cred, p) return (0); } +/*ARGSUSED*/ int union_vget(mp, ino, vpp) struct mount *mp; @@ -500,6 +523,7 @@ union_vget(mp, ino, vpp) return (EOPNOTSUPP); } +/*ARGSUSED*/ int union_fhtovp(mp, fidp, nam, vpp, exflagsp, credanonp) struct mount *mp; @@ -513,6 +537,7 @@ union_fhtovp(mp, fidp, nam, vpp, exflagsp, credanonp) return (EOPNOTSUPP); } +/*ARGSUSED*/ int union_vptofh(vp, fhp) struct vnode *vp; @@ -522,8 +547,6 @@ union_vptofh(vp, fhp) return (EOPNOTSUPP); } -int union_init __P((void)); - struct vfsops union_vfsops = { MOUNT_UNION, union_mount, diff --git a/sys/miscfs/union/union_vnops.c b/sys/miscfs/union/union_vnops.c index fa4482484e5..d46d06f3f2e 100644 --- a/sys/miscfs/union/union_vnops.c +++ b/sys/miscfs/union/union_vnops.c @@ -1,4 +1,5 @@ -/* $NetBSD: union_vnops.c,v 1.25 1995/07/13 13:19:18 mycroft Exp $ */ +/* $OpenBSD: union_vnops.c,v 1.3 1996/02/27 08:09:03 niklas Exp $ */ +/* $NetBSD: union_vnops.c,v 1.28 1996/02/13 13:13:03 mycroft Exp $ */ /* * Copyright (c) 1992, 1993, 1994 The Regents of the University of California. @@ -54,11 +55,108 @@ #include <sys/queue.h> #include <miscfs/union/union.h> +/* + * Global vfs data structures + */ + +int union_lookup __P((void *)); +int union_create __P((void *)); +int union_whiteout __P((void *)); +int union_mknod __P((void *)); +int union_open __P((void *)); +int union_close __P((void *)); +int union_access __P((void *)); +int union_getattr __P((void *)); +int union_setattr __P((void *)); +int union_read __P((void *)); +int union_write __P((void *)); +int union_lease __P((void *)); +int union_ioctl __P((void *)); +int union_select __P((void *)); +int union_mmap __P((void *)); +int union_fsync __P((void *)); +int union_seek __P((void *)); +int union_remove __P((void *)); +int union_link __P((void *)); +int union_rename __P((void *)); +int union_mkdir __P((void *)); +int union_rmdir __P((void *)); +int union_symlink __P((void *)); +int union_readdir __P((void *)); +int union_readlink __P((void *)); +int union_abortop __P((void *)); +int union_inactive __P((void *)); +int union_reclaim __P((void *)); +int union_lock __P((void *)); +int union_unlock __P((void *)); +int union_bmap __P((void *)); +int union_print __P((void *)); +int union_islocked __P((void *)); +int union_pathconf __P((void *)); +int union_advlock __P((void *)); +int union_strategy __P((void *)); + +int (**union_vnodeop_p) __P((void *)); +struct vnodeopv_entry_desc union_vnodeop_entries[] = { + { &vop_default_desc, vn_default_error }, + { &vop_lookup_desc, union_lookup }, /* lookup */ + { &vop_create_desc, union_create }, /* create */ + { &vop_whiteout_desc, union_whiteout }, /* whiteout */ + { &vop_mknod_desc, union_mknod }, /* mknod */ + { &vop_open_desc, union_open }, /* open */ + { &vop_close_desc, union_close }, /* close */ + { &vop_access_desc, union_access }, /* access */ + { &vop_getattr_desc, union_getattr }, /* getattr */ + { &vop_setattr_desc, union_setattr }, /* setattr */ + { &vop_read_desc, union_read }, /* read */ + { &vop_write_desc, union_write }, /* write */ + { &vop_lease_desc, union_lease }, /* lease */ + { &vop_ioctl_desc, union_ioctl }, /* ioctl */ + { &vop_select_desc, union_select }, /* select */ + { &vop_mmap_desc, union_mmap }, /* mmap */ + { &vop_fsync_desc, union_fsync }, /* fsync */ + { &vop_seek_desc, union_seek }, /* seek */ + { &vop_remove_desc, union_remove }, /* remove */ + { &vop_link_desc, union_link }, /* link */ + { &vop_rename_desc, union_rename }, /* rename */ + { &vop_mkdir_desc, union_mkdir }, /* mkdir */ + { &vop_rmdir_desc, union_rmdir }, /* rmdir */ + { &vop_symlink_desc, union_symlink }, /* symlink */ + { &vop_readdir_desc, union_readdir }, /* readdir */ + { &vop_readlink_desc, union_readlink }, /* readlink */ + { &vop_abortop_desc, union_abortop }, /* abortop */ + { &vop_inactive_desc, union_inactive }, /* inactive */ + { &vop_reclaim_desc, union_reclaim }, /* reclaim */ + { &vop_lock_desc, union_lock }, /* lock */ + { &vop_unlock_desc, union_unlock }, /* unlock */ + { &vop_bmap_desc, union_bmap }, /* bmap */ + { &vop_strategy_desc, union_strategy }, /* strategy */ + { &vop_print_desc, union_print }, /* print */ + { &vop_islocked_desc, union_islocked }, /* islocked */ + { &vop_pathconf_desc, union_pathconf }, /* pathconf */ + { &vop_advlock_desc, union_advlock }, /* advlock */ +#ifdef notdef + { &vop_blkatoff_desc, union_blkatoff }, /* blkatoff */ + { &vop_valloc_desc, union_valloc }, /* valloc */ + { &vop_vfree_desc, union_vfree }, /* vfree */ + { &vop_truncate_desc, union_truncate }, /* truncate */ + { &vop_update_desc, union_update }, /* update */ + { &vop_bwrite_desc, union_bwrite }, /* bwrite */ +#endif + { (struct vnodeop_desc*)NULL, (int(*) __P((void *)))NULL } +}; +struct vnodeopv_desc union_vnodeop_opv_desc = + { &union_vnodeop_p, union_vnodeop_entries }; + #define FIXUP(un) { \ if (((un)->un_flags & UN_ULOCK) == 0) { \ union_fixup(un); \ } \ } +static void union_fixup __P((struct union_node *)); +static int union_lookup1 __P((struct vnode *, struct vnode **, + struct vnode **, struct componentname *)); + static void union_fixup(un) @@ -133,7 +231,7 @@ union_lookup1(udvp, dvpp, vpp, cnp) continue; } - if (error = VFS_ROOT(mp, &tdvp)) { + if ((error = VFS_ROOT(mp, &tdvp)) != 0) { vput(dvp); return (error); } @@ -147,14 +245,15 @@ union_lookup1(udvp, dvpp, vpp, cnp) } int -union_lookup(ap) +union_lookup(v) + void *v; +{ struct vop_lookup_args /* { struct vnodeop_desc *a_desc; struct vnode *a_dvp; struct vnode **a_vpp; struct componentname *a_cnp; - } */ *ap; -{ + } */ *ap = v; int error; int uerror, lerror; struct vnode *uppervp, *lowervp; @@ -163,9 +262,8 @@ union_lookup(ap) struct union_node *dun = VTOUNION(dvp); struct componentname *cnp = ap->a_cnp; int lockparent = cnp->cn_flags & LOCKPARENT; - int rdonly = cnp->cn_flags & RDONLY; struct union_mount *um = MOUNTTOUNIONMOUNT(dvp->v_mount); - struct ucred *saved_cred; + struct ucred *saved_cred = NULL; int iswhiteout; struct vattr va; @@ -406,14 +504,15 @@ union_lookup(ap) } int -union_create(ap) +union_create(v) + void *v; +{ struct vop_create_args /* { struct vnode *a_dvp; struct vnode **a_vpp; struct componentname *a_cnp; struct vattr *a_vap; - } */ *ap; -{ + } */ *ap = v; struct union_node *un = VTOUNION(ap->a_dvp); struct vnode *dvp; @@ -451,13 +550,14 @@ union_create(ap) } int -union_whiteout(ap) +union_whiteout(v) + void *v; +{ struct vop_whiteout_args /* { struct vnode *a_dvp; struct componentname *a_cnp; int a_flags; - } */ *ap; -{ + } */ *ap = v; struct union_node *un = VTOUNION(ap->a_dvp); if (un->un_uppervp == NULLVP) @@ -468,14 +568,15 @@ union_whiteout(ap) } int -union_mknod(ap) +union_mknod(v) + void *v; +{ struct vop_mknod_args /* { struct vnode *a_dvp; struct vnode **a_vpp; struct componentname *a_cnp; struct vattr *a_vap; - } */ *ap; -{ + } */ *ap = v; struct union_node *un = VTOUNION(ap->a_dvp); struct vnode *dvp; @@ -515,15 +616,16 @@ union_mknod(ap) } int -union_open(ap) +union_open(v) + void *v; +{ struct vop_open_args /* { struct vnodeop_desc *a_desc; struct vnode *a_vp; int a_mode; struct ucred *a_cred; struct proc *a_p; - } */ *ap; -{ + } */ *ap = v; struct union_node *un = VTOUNION(ap->a_vp); struct vnode *tvp; int mode = ap->a_mode; @@ -568,14 +670,15 @@ union_open(ap) } int -union_close(ap) +union_close(v) + void *v; +{ struct vop_close_args /* { struct vnode *a_vp; int a_fflag; struct ucred *a_cred; struct proc *a_p; - } */ *ap; -{ + } */ *ap = v; struct union_node *un = VTOUNION(ap->a_vp); struct vnode *vp; @@ -611,15 +714,16 @@ union_close(ap) * the user caused an implicit file copy. */ int -union_access(ap) +union_access(v) + void *v; +{ struct vop_access_args /* { struct vnodeop_desc *a_desc; struct vnode *a_vp; int a_mode; struct ucred *a_cred; struct proc *a_p; - } */ *ap; -{ + } */ *ap = v; struct union_node *un = VTOUNION(ap->a_vp); int error = EACCES; struct vnode *vp; @@ -652,14 +756,15 @@ union_access(ap) * track object sizes */ int -union_getattr(ap) +union_getattr(v) + void *v; +{ struct vop_getattr_args /* { struct vnode *a_vp; struct vattr *a_vap; struct ucred *a_cred; struct proc *a_p; - } */ *ap; -{ + } */ *ap = v; int error; struct union_node *un = VTOUNION(ap->a_vp); struct vnode *vp = un->un_uppervp; @@ -720,14 +825,15 @@ union_getattr(ap) } int -union_setattr(ap) +union_setattr(v) + void *v; +{ struct vop_setattr_args /* { struct vnode *a_vp; struct vattr *a_vap; struct ucred *a_cred; struct proc *a_p; - } */ *ap; -{ + } */ *ap = v; struct union_node *un = VTOUNION(ap->a_vp); int error; @@ -763,14 +869,15 @@ union_setattr(ap) } int -union_read(ap) +union_read(v) + void *v; +{ struct vop_read_args /* { struct vnode *a_vp; struct uio *a_uio; int a_ioflag; struct ucred *a_cred; - } */ *ap; -{ + } */ *ap = v; int error; struct vnode *vp = OTHERVP(ap->a_vp); int dolock = (vp == LOWERVP(ap->a_vp)); @@ -806,14 +913,15 @@ union_read(ap) } int -union_write(ap) +union_write(v) + void *v; +{ struct vop_read_args /* { struct vnode *a_vp; struct uio *a_uio; int a_ioflag; struct ucred *a_cred; - } */ *ap; -{ + } */ *ap = v; int error; struct vnode *vp; struct union_node *un = VTOUNION(ap->a_vp); @@ -839,14 +947,16 @@ union_write(ap) return (error); } -union_lease(ap) +int +union_lease(v) + void *v; +{ struct vop_lease_args /* { struct vnode *a_vp; struct proc *a_p; struct ucred *a_cred; int a_flag; - } */ *ap; -{ + } */ *ap = v; register struct vnode *vp = OTHERVP(ap->a_vp); ap->a_vp = vp; @@ -854,7 +964,9 @@ union_lease(ap) } int -union_ioctl(ap) +union_ioctl(v) + void *v; +{ struct vop_ioctl_args /* { struct vnode *a_vp; u_long a_command; @@ -862,8 +974,7 @@ union_ioctl(ap) int a_fflag; struct ucred *a_cred; struct proc *a_p; - } */ *ap; -{ + } */ *ap = v; register struct vnode *vp = OTHERVP(ap->a_vp); ap->a_vp = vp; @@ -871,15 +982,16 @@ union_ioctl(ap) } int -union_select(ap) +union_select(v) + void *v; +{ struct vop_select_args /* { struct vnode *a_vp; int a_which; int a_fflags; struct ucred *a_cred; struct proc *a_p; - } */ *ap; -{ + } */ *ap = v; register struct vnode *vp = OTHERVP(ap->a_vp); ap->a_vp = vp; @@ -887,14 +999,15 @@ union_select(ap) } int -union_mmap(ap) +union_mmap(v) + void *v; +{ struct vop_mmap_args /* { struct vnode *a_vp; int a_fflags; struct ucred *a_cred; struct proc *a_p; - } */ *ap; -{ + } */ *ap = v; register struct vnode *vp = OTHERVP(ap->a_vp); ap->a_vp = vp; @@ -902,14 +1015,15 @@ union_mmap(ap) } int -union_fsync(ap) +union_fsync(v) + void *v; +{ struct vop_fsync_args /* { struct vnode *a_vp; struct ucred *a_cred; int a_waitfor; struct proc *a_p; - } */ *ap; -{ + } */ *ap = v; int error = 0; struct vnode *targetvp = OTHERVP(ap->a_vp); @@ -930,14 +1044,15 @@ union_fsync(ap) } int -union_seek(ap) +union_seek(v) + void *v; +{ struct vop_seek_args /* { struct vnode *a_vp; off_t a_oldoff; off_t a_newoff; struct ucred *a_cred; - } */ *ap; -{ + } */ *ap = v; register struct vnode *vp = OTHERVP(ap->a_vp); ap->a_vp = vp; @@ -945,13 +1060,14 @@ union_seek(ap) } int -union_remove(ap) +union_remove(v) + void *v; +{ struct vop_remove_args /* { struct vnode *a_dvp; struct vnode *a_vp; struct componentname *a_cnp; - } */ *ap; -{ + } */ *ap = v; int error; struct union_node *dun = VTOUNION(ap->a_dvp); struct union_node *un = VTOUNION(ap->a_vp); @@ -990,24 +1106,25 @@ union_remove(ap) return (error); } -/* a_vp: directory in which to link - a_tdvp: new target of the link +/* a_dvp: directory in which to link + a_vp: new target of the link a_cnp: name for the link */ int -union_link(ap) +union_link(v) + void *v; +{ struct vop_link_args /* { + struct vnode *a_dvp; struct vnode *a_vp; - struct vnode *a_tdvp; struct componentname *a_cnp; - } */ *ap; -{ + } */ *ap = v; int error = 0; - struct union_node *un; + struct union_node *dun; + struct vnode *dvp; struct vnode *vp; - struct vnode *tdvp; - un = VTOUNION(ap->a_vp); + dun = VTOUNION(ap->a_dvp); #ifdef DIAGNOSTIC if (!(ap->a_cnp->cn_flags & LOCKPARENT)) { @@ -1015,21 +1132,22 @@ union_link(ap) error = EIO; /* need some error code for "caller is a bozo" */ } else #endif - if (ap->a_vp->v_op != ap->a_tdvp->v_op) { - tdvp = ap->a_tdvp; + if (ap->a_dvp->v_op != ap->a_vp->v_op) { + vp = ap->a_vp; } else { - struct union_node *tdun = VTOUNION(ap->a_tdvp); - if (tdun->un_uppervp == NULLVP) { + struct union_node *un = VTOUNION(ap->a_vp); + + if (un->un_uppervp == NULLVP) { /* * needs to be copied up before we can link it. */ - VOP_LOCK(ap->a_tdvp); - if (un->un_uppervp == tdun->un_dirvp) { - VOP_UNLOCK(ap->a_vp); + VOP_LOCK(ap->a_vp); + if (dun->un_uppervp == un->un_dirvp) { + VOP_UNLOCK(ap->a_dvp); } - error = union_copyup(tdun, 1, ap->a_cnp->cn_cred, + error = union_copyup(un, 1, ap->a_cnp->cn_cred, ap->a_cnp->cn_proc); - if (un->un_uppervp == tdun->un_dirvp) { + if (dun->un_uppervp == un->un_dirvp) { /* During copyup, we dropped the lock on the * dir and invalidated any saved namei lookup * state for the directory we'll be entering @@ -1040,51 +1158,53 @@ union_link(ap) * reset the state. */ vp = NULLVP; - if (un->un_uppervp == NULLVP || + if (dun->un_uppervp == NULLVP || /* * relookup starts with an unlocked node, * and since LOCKPARENT is set returns * the starting directory locked. */ - (error = relookup(ap->a_vp, - &vp, ap->a_cnp))) { - vrele(ap->a_vp); - VOP_UNLOCK(ap->a_tdvp); + (error = relookup(ap->a_dvp, + &dvp, ap->a_cnp))) { + vrele(ap->a_dvp); + VOP_UNLOCK(ap->a_vp); return EROFS; } - if (vp != NULLVP) { + if (dvp != NULLVP) { /* The name we want to create has mysteriously appeared (a race?) */ error = EEXIST; - VOP_UNLOCK(ap->a_tdvp); + VOP_UNLOCK(ap->a_vp); goto croak; } } - VOP_UNLOCK(ap->a_tdvp); + VOP_UNLOCK(ap->a_vp); } - tdvp = tdun->un_uppervp; + vp = un->un_uppervp; } - vp = un->un_uppervp; - if (vp == NULLVP) + dvp = dun->un_uppervp; + if (dvp == NULLVP) error = EROFS; if (error) { croak: - vput(ap->a_vp); + vput(ap->a_dvp); return (error); } - FIXUP(un); - VREF(vp); - un->un_flags |= UN_KLOCK; - vput(ap->a_vp); + FIXUP(dun); + VREF(dvp); + dun->un_flags |= UN_KLOCK; + vput(ap->a_dvp); - return (VOP_LINK(vp, tdvp, ap->a_cnp)); + return (VOP_LINK(dvp, vp, ap->a_cnp)); } int -union_rename(ap) +union_rename(v) + void *v; +{ struct vop_rename_args /* { struct vnode *a_fdvp; struct vnode *a_fvp; @@ -1092,8 +1212,7 @@ union_rename(ap) struct vnode *a_tdvp; struct vnode *a_tvp; struct componentname *a_tcnp; - } */ *ap; -{ + } */ *ap = v; int error; struct vnode *fdvp = ap->a_fdvp; @@ -1192,14 +1311,15 @@ bad: } int -union_mkdir(ap) +union_mkdir(v) + void *v; +{ struct vop_mkdir_args /* { struct vnode *a_dvp; struct vnode **a_vpp; struct componentname *a_cnp; struct vattr *a_vap; - } */ *ap; -{ + } */ *ap = v; struct union_node *un = VTOUNION(ap->a_dvp); struct vnode *dvp = un->un_uppervp; @@ -1237,13 +1357,14 @@ union_mkdir(ap) } int -union_rmdir(ap) +union_rmdir(v) + void *v; +{ struct vop_rmdir_args /* { struct vnode *a_dvp; struct vnode *a_vp; struct componentname *a_cnp; - } */ *ap; -{ + } */ *ap = v; int error; struct union_node *dun = VTOUNION(ap->a_dvp); struct union_node *un = VTOUNION(ap->a_vp); @@ -1283,22 +1404,22 @@ union_rmdir(ap) } int -union_symlink(ap) +union_symlink(v) + void *v; +{ struct vop_symlink_args /* { struct vnode *a_dvp; struct vnode **a_vpp; struct componentname *a_cnp; struct vattr *a_vap; char *a_target; - } */ *ap; -{ + } */ *ap = v; struct union_node *un = VTOUNION(ap->a_dvp); struct vnode *dvp = un->un_uppervp; if (dvp != NULLVP) { int error; struct vnode *vp; - struct mount *mp = ap->a_dvp->v_mount; FIXUP(un); VREF(dvp); @@ -1322,7 +1443,9 @@ union_symlink(ap) * eliminating duplicate names from the returned data stream. */ int -union_readdir(ap) +union_readdir(v) + void *v; +{ struct vop_readdir_args /* { struct vnodeop_desc *a_desc; struct vnode *a_vp; @@ -1331,8 +1454,7 @@ union_readdir(ap) int *a_eofflag; u_long *a_cookies; int a_ncookies; - } */ *ap; -{ + } */ *ap = v; register struct union_node *un = VTOUNION(ap->a_vp); register struct vnode *vp; @@ -1345,13 +1467,14 @@ union_readdir(ap) } int -union_readlink(ap) +union_readlink(v) + void *v; +{ struct vop_readlink_args /* { struct vnode *a_vp; struct uio *a_uio; struct ucred *a_cred; - } */ *ap; -{ + } */ *ap = v; int error; struct vnode *vp = OTHERVP(ap->a_vp); int dolock = (vp == LOWERVP(ap->a_vp)); @@ -1369,12 +1492,13 @@ union_readlink(ap) } int -union_abortop(ap) +union_abortop(v) + void *v; +{ struct vop_abortop_args /* { struct vnode *a_dvp; struct componentname *a_cnp; - } */ *ap; -{ + } */ *ap = v; int error; struct vnode *vp = OTHERVP(ap->a_dvp); struct union_node *un = VTOUNION(ap->a_dvp); @@ -1396,11 +1520,12 @@ union_abortop(ap) } int -union_inactive(ap) +union_inactive(v) + void *v; +{ struct vop_inactive_args /* { struct vnode *a_vp; - } */ *ap; -{ + } */ *ap = v; struct union_node *un = VTOUNION(ap->a_vp); /* @@ -1432,11 +1557,12 @@ union_inactive(ap) } int -union_reclaim(ap) +union_reclaim(v) + void *v; +{ struct vop_reclaim_args /* { struct vnode *a_vp; - } */ *ap; -{ + } */ *ap = v; union_freevp(ap->a_vp); @@ -1444,9 +1570,10 @@ union_reclaim(ap) } int -union_lock(ap) - struct vop_lock_args *ap; +union_lock(v) + void *v; { + struct vop_lock_args *ap = v; struct vnode *vp = ap->a_vp; struct union_node *un; @@ -1513,9 +1640,10 @@ start: */ int -union_unlock(ap) - struct vop_lock_args *ap; +union_unlock(v) + void *v; { + struct vop_lock_args *ap = v; struct union_node *un = VTOUNION(ap->a_vp); #ifdef DIAGNOSTIC @@ -1546,15 +1674,16 @@ union_unlock(ap) } int -union_bmap(ap) +union_bmap(v) + void *v; +{ struct vop_bmap_args /* { struct vnode *a_vp; daddr_t a_bn; struct vnode **a_vpp; daddr_t *a_bnp; int *a_runp; - } */ *ap; -{ + } */ *ap = v; int error; struct vnode *vp = OTHERVP(ap->a_vp); int dolock = (vp == LOWERVP(ap->a_vp)); @@ -1572,15 +1701,17 @@ union_bmap(ap) } int -union_print(ap) +union_print(v) + void *v; +{ struct vop_print_args /* { struct vnode *a_vp; - } */ *ap; -{ + } */ *ap = v; struct vnode *vp = ap->a_vp; printf("\ttag VT_UNION, vp=%x, uppervp=%x, lowervp=%x\n", - vp, UPPERVP(vp), LOWERVP(vp)); + (unsigned int) vp, (unsigned int) UPPERVP(vp), + (unsigned int) LOWERVP(vp)); if (UPPERVP(vp)) vprint("uppervp", UPPERVP(vp)); if (LOWERVP(vp)) @@ -1595,23 +1726,25 @@ union_print(ap) } int -union_islocked(ap) +union_islocked(v) + void *v; +{ struct vop_islocked_args /* { struct vnode *a_vp; - } */ *ap; -{ + } */ *ap = v; return ((VTOUNION(ap->a_vp)->un_flags & UN_LOCKED) ? 1 : 0); } int -union_pathconf(ap) +union_pathconf(v) + void *v; +{ struct vop_pathconf_args /* { struct vnode *a_vp; int a_name; register_t *a_retval; - } */ *ap; -{ + } */ *ap = v; int error; struct vnode *vp = OTHERVP(ap->a_vp); int dolock = (vp == LOWERVP(ap->a_vp)); @@ -1629,15 +1762,16 @@ union_pathconf(ap) } int -union_advlock(ap) +union_advlock(v) + void *v; +{ struct vop_advlock_args /* { struct vnode *a_vp; caddr_t a_id; int a_op; struct flock *a_fl; int a_flags; - } */ *ap; -{ + } */ *ap = v; register struct vnode *vp = OTHERVP(ap->a_vp); ap->a_vp = vp; @@ -1651,11 +1785,12 @@ union_advlock(ap) * This goes away with a merged VM/buffer cache. */ int -union_strategy(ap) +union_strategy(v) + void *v; +{ struct vop_strategy_args /* { struct buf *a_bp; - } */ *ap; -{ + } */ *ap = v; struct buf *bp = ap->a_bp; int error; struct vnode *savedvp; @@ -1677,57 +1812,3 @@ union_strategy(ap) return (error); } -/* - * Global vfs data structures - */ -int (**union_vnodeop_p)(); -struct vnodeopv_entry_desc union_vnodeop_entries[] = { - { &vop_default_desc, vn_default_error }, - { &vop_lookup_desc, union_lookup }, /* lookup */ - { &vop_create_desc, union_create }, /* create */ - { &vop_whiteout_desc, union_whiteout }, /* whiteout */ - { &vop_mknod_desc, union_mknod }, /* mknod */ - { &vop_open_desc, union_open }, /* open */ - { &vop_close_desc, union_close }, /* close */ - { &vop_access_desc, union_access }, /* access */ - { &vop_getattr_desc, union_getattr }, /* getattr */ - { &vop_setattr_desc, union_setattr }, /* setattr */ - { &vop_read_desc, union_read }, /* read */ - { &vop_write_desc, union_write }, /* write */ - { &vop_lease_desc, union_lease }, /* lease */ - { &vop_ioctl_desc, union_ioctl }, /* ioctl */ - { &vop_select_desc, union_select }, /* select */ - { &vop_mmap_desc, union_mmap }, /* mmap */ - { &vop_fsync_desc, union_fsync }, /* fsync */ - { &vop_seek_desc, union_seek }, /* seek */ - { &vop_remove_desc, union_remove }, /* remove */ - { &vop_link_desc, union_link }, /* link */ - { &vop_rename_desc, union_rename }, /* rename */ - { &vop_mkdir_desc, union_mkdir }, /* mkdir */ - { &vop_rmdir_desc, union_rmdir }, /* rmdir */ - { &vop_symlink_desc, union_symlink }, /* symlink */ - { &vop_readdir_desc, union_readdir }, /* readdir */ - { &vop_readlink_desc, union_readlink }, /* readlink */ - { &vop_abortop_desc, union_abortop }, /* abortop */ - { &vop_inactive_desc, union_inactive }, /* inactive */ - { &vop_reclaim_desc, union_reclaim }, /* reclaim */ - { &vop_lock_desc, union_lock }, /* lock */ - { &vop_unlock_desc, union_unlock }, /* unlock */ - { &vop_bmap_desc, union_bmap }, /* bmap */ - { &vop_strategy_desc, union_strategy }, /* strategy */ - { &vop_print_desc, union_print }, /* print */ - { &vop_islocked_desc, union_islocked }, /* islocked */ - { &vop_pathconf_desc, union_pathconf }, /* pathconf */ - { &vop_advlock_desc, union_advlock }, /* advlock */ -#ifdef notdef - { &vop_blkatoff_desc, union_blkatoff }, /* blkatoff */ - { &vop_valloc_desc, union_valloc }, /* valloc */ - { &vop_vfree_desc, union_vfree }, /* vfree */ - { &vop_truncate_desc, union_truncate }, /* truncate */ - { &vop_update_desc, union_update }, /* update */ - { &vop_bwrite_desc, union_bwrite }, /* bwrite */ -#endif - { (struct vnodeop_desc*)NULL, (int(*)())NULL } -}; -struct vnodeopv_desc union_vnodeop_opv_desc = - { &union_vnodeop_p, union_vnodeop_entries }; |