View | Details | Raw Unified
Collapse All | Expand All

(-) devfs/devfs.h (-1 / +1 lines)
 Lines 163-169    Link Here 
void devfs_rules_apply(struct devfs_mount *dm, struct devfs_dirent *de);
void devfs_rules_apply(struct devfs_mount *dm, struct devfs_dirent *de);
void devfs_rules_cleanup (struct devfs_mount *dm);
void devfs_rules_cleanup (struct devfs_mount *dm);
int devfs_rules_ioctl(struct devfs_mount *dm, u_long cmd, caddr_t data, struct thread *td);
int devfs_rules_ioctl(struct devfs_mount *dm, u_long cmd, caddr_t data, struct thread *td);
int devfs_allocv (struct devfs_dirent *de, struct mount *mp, struct vnode **vpp, struct thread *td);
int devfs_allocv (struct devfs_dirent *de, struct mount *mp, struct vnode **vpp, int *dm_unlock, struct thread *td);
struct cdev **devfs_itod (int inode);
struct cdev **devfs_itod (int inode);
struct devfs_dirent **devfs_itode (struct devfs_mount *dm, int inode);
struct devfs_dirent **devfs_itode (struct devfs_mount *dm, int inode);
void devfs_delete(struct devfs_mount *dm, struct devfs_dirent *de);
void devfs_delete(struct devfs_mount *dm, struct devfs_dirent *de);
(-) devfs/devfs_vfsops.c (-1 / +3 lines)
 Lines 139-147    Link Here 
	int error;
	int error;
	struct vnode *vp;
	struct vnode *vp;
	struct devfs_mount *dmp;
	struct devfs_mount *dmp;
	int dm_unlock;
	dmp = VFSTODEVFS(mp);
	dmp = VFSTODEVFS(mp);
	error = devfs_allocv(dmp->dm_rootdir, mp, &vp, td);
	dm_unlock = 0;
	error = devfs_allocv(dmp->dm_rootdir, mp, &vp, &dm_unlock, td);
	if (error)
	if (error)
		return (error);
		return (error);
	vp->v_vflag |= VV_ROOT;
	vp->v_vflag |= VV_ROOT;
(-) devfs/devfs_vnops.c (-10 / +30 lines)
 Lines 124-139    Link Here 
}
}
int
int
devfs_allocv(struct devfs_dirent *de, struct mount *mp, struct vnode **vpp, struct thread *td)
devfs_allocv(struct devfs_dirent *de, struct mount *mp, struct vnode **vpp,
	int *dm_unlock, struct thread *td)
{
{
	int error;
	int error;
	struct vnode *vp;
	struct vnode *vp;
	struct cdev *dev;
	struct cdev *dev;
	struct devfs_mount *dmp;
	KASSERT(td == curthread, ("devfs_allocv: td != curthread"));
	KASSERT(td == curthread, ("devfs_allocv: td != curthread"));
	dmp = VFSTODEVFS(mp);
loop:
loop:
	vp = de->de_vnode;
	vp = de->de_vnode;
	if (vp != NULL) {
	if (vp != NULL) {
		if (*dm_unlock) {
			sx_xunlock(&dmp->dm_lock);
			*dm_unlock = 0;
		}
		if (vget(vp, LK_EXCLUSIVE, td))
		if (vget(vp, LK_EXCLUSIVE, td))
			goto loop;
			goto loop;
		*vpp = vp;
		*vpp = vp;
 Lines 173-178    Link Here 
	}
	}
	vp->v_data = de;
	vp->v_data = de;
	de->de_vnode = vp;
	de->de_vnode = vp;
	if (*dm_unlock) {
		sx_xunlock(&dmp->dm_lock);
		*dm_unlock = 0;
	}
	vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td);
	vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td);
#ifdef MAC
#ifdef MAC
	mac_associate_vnode_devfs(mp, de, vp);
	mac_associate_vnode_devfs(mp, de, vp);
 Lines 453-459    Link Here 
}
}
static int
static int
devfs_lookupx(struct vop_lookup_args *ap)
devfs_lookupx(struct vop_lookup_args *ap, int *dm_unlock)
{
{
	struct componentname *cnp;
	struct componentname *cnp;
	struct vnode *dvp, **vpp;
	struct vnode *dvp, **vpp;
 Lines 504-510    Link Here 
		de = TAILQ_FIRST(&dd->de_dlist);	/* "." */
		de = TAILQ_FIRST(&dd->de_dlist);	/* "." */
		de = TAILQ_NEXT(de, de_list);		/* ".." */
		de = TAILQ_NEXT(de, de_list);		/* ".." */
		de = de->de_dir;
		de = de->de_dir;
		error = devfs_allocv(de, dvp->v_mount, vpp, td);
		error = devfs_allocv(de, dvp->v_mount, vpp, dm_unlock, td);
		vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY, td);
		vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY, td);
		return (error);
		return (error);
	}
	}
 Lines 561-567    Link Here 
			return (0);
			return (0);
		}
		}
	}
	}
	error = devfs_allocv(de, dvp->v_mount, vpp, td);
	error = devfs_allocv(de, dvp->v_mount, vpp, dm_unlock, td);
	return (error);
	return (error);
}
}
 Lines 570-580    Link Here 
{
{
	int j;
	int j;
	struct devfs_mount *dmp;
	struct devfs_mount *dmp;
	int dm_unlock;
	dmp = VFSTODEVFS(ap->a_dvp->v_mount);
	dmp = VFSTODEVFS(ap->a_dvp->v_mount);
	dm_unlock = 1;
	sx_xlock(&dmp->dm_lock);
	sx_xlock(&dmp->dm_lock);
	j = devfs_lookupx(ap);
	j = devfs_lookupx(ap, &dm_unlock);
	sx_xunlock(&dmp->dm_lock);
	if (dm_unlock == 1)
		sx_xunlock(&dmp->dm_lock);
	return (j);
	return (j);
}
}
 Lines 586-591    Link Here 
	struct thread *td;
	struct thread *td;
	struct devfs_dirent *dd, *de;
	struct devfs_dirent *dd, *de;
	struct devfs_mount *dmp;
	struct devfs_mount *dmp;
	int dm_unlock;
	int error;
	int error;
	/*
	/*
 Lines 597-602    Link Here 
	dvp = ap->a_dvp;
	dvp = ap->a_dvp;
	dmp = VFSTODEVFS(dvp->v_mount);
	dmp = VFSTODEVFS(dvp->v_mount);
	sx_xlock(&dmp->dm_lock);
	sx_xlock(&dmp->dm_lock);
	dm_unlock = 1;
	cnp = ap->a_cnp;
	cnp = ap->a_cnp;
	vpp = ap->a_vpp;
	vpp = ap->a_vpp;
 Lines 617-625    Link Here 
	if (de == NULL)
	if (de == NULL)
		goto notfound;
		goto notfound;
	de->de_flags &= ~DE_WHITEOUT;
	de->de_flags &= ~DE_WHITEOUT;
	error = devfs_allocv(de, dvp->v_mount, vpp, td);
	error = devfs_allocv(de, dvp->v_mount, vpp, &dm_unlock, td);
notfound:
notfound:
	sx_xunlock(&dmp->dm_lock);
	if (dm_unlock == 1)
		sx_xunlock(&dmp->dm_lock);
	return (error);
	return (error);
}
}
 Lines 1101-1106    Link Here 
	struct devfs_dirent *de;
	struct devfs_dirent *de;
	struct devfs_mount *dmp;
	struct devfs_mount *dmp;
	struct thread *td;
	struct thread *td;
	int dm_unlock;
	td = ap->a_cnp->cn_thread;
	td = ap->a_cnp->cn_thread;
	KASSERT(td == curthread, ("devfs_symlink: td != curthread"));
	KASSERT(td == curthread, ("devfs_symlink: td != curthread"));
 Lines 1119-1130    Link Here 
	de->de_symlink = malloc(i, M_DEVFS, M_WAITOK);
	de->de_symlink = malloc(i, M_DEVFS, M_WAITOK);
	bcopy(ap->a_target, de->de_symlink, i);
	bcopy(ap->a_target, de->de_symlink, i);
	sx_xlock(&dmp->dm_lock);
	sx_xlock(&dmp->dm_lock);
	dm_unlock = 1;
#ifdef MAC
#ifdef MAC
	mac_create_devfs_symlink(ap->a_cnp->cn_cred, dmp->dm_mount, dd, de);
	mac_create_devfs_symlink(ap->a_cnp->cn_cred, dmp->dm_mount, dd, de);
#endif
#endif
	TAILQ_INSERT_TAIL(&dd->de_dlist, de, de_list);
	TAILQ_INSERT_TAIL(&dd->de_dlist, de, de_list);
	devfs_allocv(de, ap->a_dvp->v_mount, ap->a_vpp, td);
	devfs_allocv(de, ap->a_dvp->v_mount, ap->a_vpp, &dm_unlock, td);
	sx_xunlock(&dmp->dm_lock);
	if (dm_unlock == 1)
		sx_xunlock(&dmp->dm_lock);
	return (0);
	return (0);
}
}