-/*
- * Create a shadow directory in the upper layer.
- * The new vnode is returned locked.
- */
-static int
-union_mkshadow(dvp, cnp, vpp)
- struct vnode *dvp;
- struct componentname *cnp;
- struct vnode *vpp;
-{
- int error;
- struct vattr va;
- struct proc *p = cnp->cn_proc;
- struct componentname cn;
-
- /*
- * policy: when creating the shadow directory in the
- * upper layer, create it owned by the current user,
- * group from parent directory, and mode 777 modified
- * by umask (ie mostly identical to the mkdir syscall).
- * (jsp, kb)
- * TODO: create the directory owned by the user who
- * did the mount (um->um_cred).
- */
-
- /*
- * A new componentname structure must be faked up because
- * there is no way to know where the upper level cnp came
- * from or what it is being used for. This must duplicate
- * some of the work done by NDINIT, some of the work done
- * by namei, some of the work done by lookup and some of
- * the work done by VOP_LOOKUP when given a CREATE flag.
- * Conclusion: Horrible.
- *
- * The pathname buffer will be FREEed by VOP_MKDIR.
- */
- cn.cn_pnbuf = malloc(cnp->cn_namelen+1, M_NAMEI, M_WAITOK);
- bcopy(cnp->cn_nameptr, cn.cn_pnbuf, cnp->cn_namelen+1);
-
- cn.cn_nameiop = CREATE;
- cn.cn_flags = HASBUF | SAVENAME | ISLASTCN;
- cn.cn_proc = cnp->cn_proc;
- cn.cn_cred = cnp->cn_cred;
- cn.cn_nameptr = cn.cn_pnbuf;
- cn.cn_namelen = cnp->cn_namelen;
- cn.cn_hash = cnp->cn_hash;
- cn.cn_consume = cnp->cn_consume;
-
- VATTR_NULL(&va);
- va.va_type = VDIR;
- va.va_mode = UN_DIRMODE &~ p->p_fd->fd_cmask;
-
- /* LEASE_CHECK: dvp is locked */
- LEASE_CHECK(dvp, p, p->p_ucred, LEASE_WRITE);
-
- VREF(dvp);
- error = VOP_MKDIR(dvp, vpp, &cn, &va);
- VOP_LOCK(dvp);
- return (error);
-}
-