Module Name: src Committed By: christos Date: Sun Sep 11 16:42:07 UTC 2022
Modified Files: src/sys/fs/unionfs: unionfs_subr.c unionfs_vfsops.c unionfs_vnops.c Log Message: catch up; make this compile again. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/sys/fs/unionfs/unionfs_subr.c cvs rdiff -u -r1.14 -r1.15 src/sys/fs/unionfs/unionfs_vfsops.c cvs rdiff -u -r1.18 -r1.19 src/sys/fs/unionfs/unionfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/fs/unionfs/unionfs_subr.c diff -u src/sys/fs/unionfs/unionfs_subr.c:1.15 src/sys/fs/unionfs/unionfs_subr.c:1.16 --- src/sys/fs/unionfs/unionfs_subr.c:1.15 Tue Jun 29 18:39:20 2021 +++ src/sys/fs/unionfs/unionfs_subr.c Sun Sep 11 12:42:07 2022 @@ -96,8 +96,7 @@ unionfs_nodeget(struct mount *mp, struct * unless layers are inverted. */ vnode_t *svp = (uppervp != NULLVP) ? uppervp : lowervp; - error = getnewvnode(VT_UNION, mp, unionfs_vnodeop_p, - svp->v_interlock, &vp); + error = vcache_get(mp, svp, sizeof(svp), &vp); if (error != 0) { return (error); } @@ -139,14 +138,11 @@ unionfs_nodeget(struct mount *mp, struct void unionfs_noderem(struct vnode *vp) { - struct unionfs_mount *ump; struct unionfs_node *unp; struct unionfs_node_status *unsp; struct vnode *lvp; struct vnode *uvp; - ump = MOUNTTOUNIONFSMOUNT(vp->v_mount); - /* * Use the interlock to protect the clearing of v_data to * prevent faults in unionfs_lock(). Index: src/sys/fs/unionfs/unionfs_vfsops.c diff -u src/sys/fs/unionfs/unionfs_vfsops.c:1.14 src/sys/fs/unionfs/unionfs_vfsops.c:1.15 --- src/sys/fs/unionfs/unionfs_vfsops.c:1.14 Fri Jan 17 15:08:08 2020 +++ src/sys/fs/unionfs/unionfs_vfsops.c Sun Sep 11 12:42:07 2022 @@ -94,7 +94,7 @@ unionfs_mount(struct mount *mp, const ch if (*data_len < sizeof *args) return EINVAL; - UNIONFSDEBUG("unionfs_mount(mp = %p)\n", (void *)mp); + UNIONFSDEBUG("%s(mp = %p)\n", __func__, mp); error = 0; below = 0; @@ -105,11 +105,10 @@ unionfs_mount(struct mount *mp, const ch copymode = UNIONFS_TRANSPARENT; /* default */ whitemode = UNIONFS_WHITE_ALWAYS; ndp = &nd; - cred = kauth_cred_get(); if (mp->mnt_flag & MNT_ROOTFS) { - printf("union_mount: cannot union mount root filesystem\n"); - return (EOPNOTSUPP); + printf("%s: cannot union mount root filesystem\n", __func__); + return EOPNOTSUPP; } if (mp->mnt_flag & MNT_GETARGS) { @@ -126,10 +125,11 @@ unionfs_mount(struct mount *mp, const ch * Update is a no operation. */ if (mp->mnt_flag & MNT_UPDATE) { - printf("union_mount: cannot update union mount\n"); - return (EOPNOTSUPP); + printf("%s: cannot update union mount\n", __func__); + return EOPNOTSUPP; } + cred = kauth_cred_get(); vn_lock(mp->mnt_vnodecovered, LK_EXCLUSIVE | LK_RETRY); error = VOP_GETATTR(mp->mnt_vnodecovered, &va, cred); if (!error) { @@ -142,7 +142,7 @@ unionfs_mount(struct mount *mp, const ch } VOP_UNLOCK(mp->mnt_vnodecovered); if (error) - return (error); + return error; switch (args->mntflags & UNMNT_OPMASK) { case UNMNT_ABOVE: @@ -164,17 +164,16 @@ unionfs_mount(struct mount *mp, const ch gid = kauth_cred_getgid(cred); } - UNIONFSDEBUG("unionfs_mount: uid=%d, gid=%d\n", uid, gid); - UNIONFSDEBUG("unionfs_mount: udir=0%03o, ufile=0%03o\n", udir, ufile); - UNIONFSDEBUG("unionfs_mount: copymode=%d\n", copymode); + UNIONFSDEBUG("%s: uid=%d, gid=%d\n", __func__, uid, gid); + UNIONFSDEBUG("%s: udir=%#03o, ufile=%#03o\n", __func__, udir, ufile); + UNIONFSDEBUG("%s: copymode=%d\n", __func__, copymode); /* * Find upper node */ error = pathbuf_copyin(args->target, &pb); - if (error) { + if (error) return error; - } NDINIT(ndp, LOOKUP, FOLLOW | LOCKLEAF, pb); if ((error = namei(ndp))) { pathbuf_destroy(pb); @@ -190,8 +189,7 @@ unionfs_mount(struct mount *mp, const ch pathbuf_destroy(pb); /* create unionfs_mount */ - ump = (struct unionfs_mount *)malloc(sizeof(struct unionfs_mount), - M_UNIONFSMNT, M_WAITOK | M_ZERO); + ump = kmem_zalloc(sizeof(*ump), KM_SLEEP); /* * Save reference @@ -236,9 +234,7 @@ unionfs_mount(struct mount *mp, const ch vrele(upperrootvp); } else vput(ump->um_uppervp); - free(ump, M_UNIONFSMNT); - mp->mnt_data = NULL; - return (error); + goto out; } } @@ -256,9 +252,7 @@ unionfs_mount(struct mount *mp, const ch NULLVP, &(ump->um_rootvp), NULL); vrele(upperrootvp); if (error) { - free(ump, M_UNIONFSMNT); - mp->mnt_data = NULL; - return (error); + goto out; } /* @@ -277,9 +271,7 @@ unionfs_mount(struct mount *mp, const ch mp->mnt_op->vfs_name, mp, curlwp); if (error) { unionfs_noderem(ump->um_rootvp); - free(ump, M_UNIONFSMNT); - mp->mnt_data = NULL; - return (error); + goto out; } switch (ump->um_op) { @@ -290,7 +282,9 @@ unionfs_mount(struct mount *mp, const ch cp = "<below>:"; break; default: - panic("union_mount: bad um_op"); +#ifdef DIAGNOSTIC + panic("%s: bad um_op", __func__); +#endif break; } len = strlen(cp); @@ -300,10 +294,14 @@ unionfs_mount(struct mount *mp, const ch (void) copyinstr(args->target, xp, len - 1, &size); memset(xp + size, 0, len - size); - UNIONFSDEBUG("unionfs_mount: from %s, on %s\n", + UNIONFSDEBUG("%s: from %s, on %s\n", __func__, mp->mnt_stat.f_mntfromname, mp->mnt_stat.f_mntonname); - return (0); + return 0; +out: + kmem_free(ump, sizeof(*ump)); + mp->mnt_data = NULL; + return error; } /* @@ -317,7 +315,7 @@ unionfs_unmount(struct mount *mp, int mn int freeing; int flags; - UNIONFSDEBUG("unionfs_unmount: mp = %p\n", (void *)mp); + UNIONFSDEBUG("%s: mp = %p\n", __func__, mp); ump = MOUNTTOUNIONFSMOUNT(mp); flags = 0; @@ -327,13 +325,16 @@ unionfs_unmount(struct mount *mp, int mn /* vflush (no need to call vrele) */ for (freeing = 0; (error = vflush(mp, NULL, flags)) != 0;) { + struct vnode_iterator *marker; struct vnode *vp; int n; /* count #vnodes held on mount list */ + vfs_vnode_iterator_init(mp, &marker); n = 0; - TAILQ_FOREACH(vp, &mp->mnt_vnodelist, v_mntvnodes) + while ((vp = vfs_vnode_iterator_next(marker, NULL, NULL))) n++; + vfs_vnode_iterator_destroy(marker); /* if this is unchanged then stop */ if (n == freeing) @@ -344,9 +345,9 @@ unionfs_unmount(struct mount *mp, int mn } if (error) - return (error); + return error; - free(ump, M_UNIONFSMNT); + kmem_free(ump, sizeof(*ump)); mp->mnt_data = NULL; return (0); @@ -361,7 +362,7 @@ unionfs_root(struct mount *mp, int lktyp ump = MOUNTTOUNIONFSMOUNT(mp); vp = ump->um_rootvp; - UNIONFSDEBUG("unionfs_root: rootvp=%p locked=%x\n", + UNIONFSDEBUG("%s: rootvp=%p locked=%#x\n", __func__, vp, VOP_ISLOCKED(vp)); vref(vp); @@ -369,7 +370,7 @@ unionfs_root(struct mount *mp, int lktyp *vpp = vp; - return (0); + return 0; } int @@ -382,7 +383,7 @@ unionfs_quotactl(struct mount *mp, struc /* * Writing is always performed to upper vnode. */ - return (VFS_QUOTACTL(ump->um_uppervp->v_mount, args)); + return VFS_QUOTACTL(ump->um_uppervp->v_mount, args); } int @@ -391,12 +392,12 @@ unionfs_statvfs(struct mount *mp, struct struct unionfs_mount *ump; int error; uint64_t lbsize; - struct statvfs *sbuf = malloc(sizeof(*sbuf), M_TEMP, M_WAITOK | M_ZERO); + struct statvfs *sbuf = kmem_alloc(sizeof(*sbuf), KM_SLEEP); ump = MOUNTTOUNIONFSMOUNT(mp); - UNIONFSDEBUG("unionfs_statvfs(mp = %p, lvp = %p, uvp = %p)\n", - (void *)mp, (void *)ump->um_lowervp, (void *)ump->um_uppervp); + UNIONFSDEBUG("%s(mp = %p, lvp = %p, uvp = %p)\n", + __func__, mp, ump->um_lowervp, ump->um_uppervp); error = VFS_STATVFS(ump->um_lowervp->v_mount, sbuf); if (error) @@ -430,27 +431,15 @@ unionfs_statvfs(struct mount *mp, struct sbp->f_ffree = sbuf->f_ffree; done: - free(sbuf, M_TEMP); - return (error); + kmem_free(sbuf, sizeof(*sbuf)); + return error; } int unionfs_sync(struct mount *mp, int waitfor, kauth_cred_t cred) { /* nothing to do */ - return (0); -} - -int -unionfs_vget(struct mount *mp, ino_t ino, int lktype, struct vnode **vpp) -{ - return (EOPNOTSUPP); -} - -int -unionfs_fhtovp(struct mount *mp, struct fid *fidp, int lktype, struct vnode **vpp) -{ - return (EOPNOTSUPP); + return 0; } int @@ -464,11 +453,11 @@ unionfs_extattrctl(struct mount *mp, int unp = VTOUNIONFS(filename_vp); if (unp->un_uppervp != NULLVP) { - return (VFS_EXTATTRCTL(ump->um_uppervp->v_mount, cmd, - unp->un_uppervp, namespace, attrname)); + return VFS_EXTATTRCTL(ump->um_uppervp->v_mount, cmd, + unp->un_uppervp, namespace, attrname); } else { - return (VFS_EXTATTRCTL(ump->um_lowervp->v_mount, cmd, - unp->un_lowervp, namespace, attrname)); + return VFS_EXTATTRCTL(ump->um_lowervp->v_mount, cmd, + unp->un_lowervp, namespace, attrname); } } @@ -478,7 +467,7 @@ unionfs_extattrctl(struct mount *mp, int void unionfs_init(void) { - UNIONFSDEBUG("unionfs_init\n"); /* printed during system boot */ + UNIONFSDEBUG("%s\n", __func__); /* printed during system boot */ } static int @@ -502,7 +491,7 @@ int unionfs_start(struct mount *mp, int flags) { - return (0); + return 0; } void @@ -530,8 +519,8 @@ struct vfsops unionfs_vfsops = { .vfs_quotactl = (void *)eopnotsupp, .vfs_statvfs = unionfs_statvfs, .vfs_sync = unionfs_sync, - .vfs_vget = unionfs_vget, - .vfs_fhtovp = (void *)eopnotsupp, + .vfs_vget = (void *)eopnotsupp, + .vfs_fhtovp = (void *)eopnotsupp, .vfs_vptofh = (void *)eopnotsupp, .vfs_init = unionfs_init, .vfs_done = unionfs_done, @@ -555,11 +544,11 @@ unionfs_modcmd(modcmd_t cmd, void *arg) if (error != 0) break; sysctl_createv(&unionfs_sysctl_log, 0, NULL, NULL, - CTLFLAG_PERMANENT, - CTLTYPE_NODE, "union", - SYSCTL_DESCR("Union file system"), - NULL, 0, NULL, 0, - CTL_VFS, 15, CTL_EOL); + CTLFLAG_PERMANENT, + CTLTYPE_NODE, "union", + SYSCTL_DESCR("Union file system"), + NULL, 0, NULL, 0, + CTL_VFS, 15, CTL_EOL); /* * XXX the "15" above could be dynamic, thereby eliminating * one more instance of the "number to vfs" mapping problem, @@ -577,5 +566,5 @@ unionfs_modcmd(modcmd_t cmd, void *arg) break; } - return (error); + return error; } Index: src/sys/fs/unionfs/unionfs_vnops.c diff -u src/sys/fs/unionfs/unionfs_vnops.c:1.18 src/sys/fs/unionfs/unionfs_vnops.c:1.19 --- src/sys/fs/unionfs/unionfs_vnops.c:1.18 Sun Mar 27 12:23:08 2022 +++ src/sys/fs/unionfs/unionfs_vnops.c Sun Sep 11 12:42:07 2022 @@ -56,6 +56,8 @@ #include <sys/proc.h> #include <fs/unionfs/unionfs.h> +#include <miscfs/genfs/genfs.h> +#include <miscfs/specfs/specdev.h> #if 0 #define UNIONFS_INTERNAL_DEBUG(msg, args...) printf(msg, ## args) @@ -103,9 +105,13 @@ unionfs_parsepath(void *v) static int unionfs_lookup(void *v) { - struct vop_lookup_args *ap = v; + struct vop_lookup_v2_args /* { + struct vnodeop_desc *a_desc; + struct vnode *a_dvp; + struct vnode **a_vpp; + struct componentname *a_cnp; + } */ *ap = v; int iswhiteout; - int lockflag; int error , uerror, lerror; u_long nameiop; u_long cnflags, cnflagsbk; @@ -115,7 +121,6 @@ unionfs_lookup(void *v) struct componentname *cnp; iswhiteout = 0; - lockflag = 0; error = uerror = lerror = ENOENT; cnp = ap->a_cnp; nameiop = cnp->cn_nameiop; @@ -327,7 +332,12 @@ unionfs_lookup_out: static int unionfs_create(void *v) { - struct vop_create_args *ap = v; + struct vop_create_v3_args /* { + struct vnode *a_dvp; + struct vnode **a_vpp; + struct componentname *a_cnp; + struct vattr *a_vap; + } */ *ap = v; struct unionfs_node *dunp; struct componentname *cnp; struct vnode *udvp; @@ -395,7 +405,12 @@ unionfs_whiteout(void *v) static int unionfs_mknod(void *v) { - struct vop_mknod_args *ap = v; + struct vop_mknod_v3_args /* { + struct vnode *a_dvp; + struct vnode **a_vpp; + struct componentname *a_cnp; + struct vattr *a_vap; + } */ *ap = v; struct unionfs_node *dunp; struct componentname *cnp; struct vnode *udvp; @@ -566,7 +581,6 @@ unionfs_close_abort: static int unionfs_check_corrected_access(u_short mode, struct vattr *va, kauth_cred_t cred) { - int error; uid_t uid; /* upper side vnode's uid */ gid_t gid; /* upper side vnode's gid */ u_short vmode; /* upper side vnode's mode */ @@ -613,13 +627,18 @@ unionfs_check_corrected_access(u_short m static int unionfs_access(void *v) { - struct vop_access_args *ap = v; + struct vop_access_args /* { + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + accmode_t a_accmode; + kauth_cred_t a_cred; + } */ *ap = v; struct unionfs_mount *ump; struct unionfs_node *unp; struct vnode *uvp; struct vnode *lvp; struct vattr va; - int mode; + int accmode; int error; UNIONFS_INTERNAL_DEBUG("unionfs_access: enter\n"); @@ -628,10 +647,10 @@ unionfs_access(void *v) unp = VTOUNIONFS(ap->a_vp); uvp = unp->un_uppervp; lvp = unp->un_lowervp; - mode = ap->a_mode; + accmode = ap->a_accmode; error = EACCES; - if ((mode & VWRITE) && + if ((accmode & VWRITE) && (ap->a_vp->v_mount->mnt_flag & MNT_RDONLY)) { switch (ap->a_vp->v_type) { case VREG: @@ -644,7 +663,7 @@ unionfs_access(void *v) } if (uvp != NULLVP) { - error = VOP_ACCESS(uvp, mode, ap->a_cred); + error = VOP_ACCESS(uvp, accmode, ap->a_cred); UNIONFS_INTERNAL_DEBUG("unionfs_access: leave (%d)\n", error); @@ -652,7 +671,7 @@ unionfs_access(void *v) } if (lvp != NULLVP) { - if (mode & VWRITE) { + if (accmode & VWRITE) { if (ump->um_uppervp->v_mount->mnt_flag & MNT_RDONLY) { switch (ap->a_vp->v_type) { case VREG: @@ -671,15 +690,15 @@ unionfs_access(void *v) return (error); error = unionfs_check_corrected_access( - mode, &va, ap->a_cred); + accmode, &va, ap->a_cred); if (error != 0) return (error); } } - mode &= ~VWRITE; - mode |= VREAD; /* will copy to upper */ + accmode &= ~VWRITE; + accmode |= VREAD; /* will copy to upper */ } - error = VOP_ACCESS(lvp, mode, ap->a_cred); + error = VOP_ACCESS(lvp, accmode, ap->a_cred); } UNIONFS_INTERNAL_DEBUG("unionfs_access: leave (%d)\n", error); @@ -740,7 +759,11 @@ unionfs_getattr(void *v) static int unionfs_setattr(void *v) { - struct vop_setattr_args *ap = v; + struct vop_setattr_args /* { + struct vnode *a_vp; + struct vattr *a_vap; + kauth_cred_t a_cred; + } */ *ap = v; int error; struct unionfs_node *unp; struct vnode *uvp; @@ -756,7 +779,8 @@ unionfs_setattr(void *v) vap = ap->a_vap; if ((ap->a_vp->v_mount->mnt_flag & MNT_RDONLY) && - (vap->va_flags != VNOVAL || vap->va_uid != (uid_t)VNOVAL || + (vap->va_flags != (unsigned long )VNOVAL || + vap->va_uid != (uid_t)VNOVAL || vap->va_gid != (gid_t)VNOVAL || vap->va_atime.tv_sec != VNOVAL || vap->va_mtime.tv_sec != VNOVAL || vap->va_mode != (mode_t)VNOVAL)) return (EROFS); @@ -1196,7 +1220,12 @@ unionfs_rename_abort: static int unionfs_mkdir(void *v) { - struct vop_mkdir_args *ap = v; + struct vop_mkdir_v3_args /* { + struct vnode *a_dvp; + struct vnode **a_vpp; + struct componentname *a_cnp; + struct vattr *a_vap; + } */ *ap = v; int error; struct unionfs_node *dunp; struct componentname *cnp; @@ -1295,7 +1324,13 @@ unionfs_rmdir(void *v) static int unionfs_symlink(void *v) { - struct vop_symlink_args *ap = v; + struct vop_symlink_v3_args /* { + struct vnode *a_dvp; + struct vnode **a_vpp; + struct componentname *a_cnp; + struct vattr *a_vap; + char *a_target; + } */ *ap = v; int error; struct unionfs_node *dunp; struct componentname *cnp; @@ -1333,7 +1368,6 @@ unionfs_readdir(void *v) struct vop_readdir_args *ap = v; int error; int eofflag; - int locked; struct unionfs_node *unp; struct unionfs_node_status *unsp; struct uio *uio; @@ -1348,7 +1382,6 @@ unionfs_readdir(void *v) error = 0; eofflag = 0; - locked = 0; unp = VTOUNIONFS(ap->a_vp); uio = ap->a_uio; uvp = unp->un_uppervp;