コード例 #1
0
/*
 * Enable an EA using the passed filesystem, backing vnode, attribute name,
 * namespace, and proc.  Will perform a VOP_OPEN() on the vp, so expects vp
 * to be locked when passed in.  The vnode will be returned unlocked,
 * regardless of success/failure of the function.  As a result, the caller
 * will always need to vrele(), but not vput().
 */
static int
ufs_extattr_enable_with_open(struct myfs_ufsmount *ump, struct vnode *vp,
    int attrnamespace, const char *attrname, struct thread *td)
{
	int error;

	error = VOP_OPEN(vp, FREAD|FWRITE, td->td_ucred, td, NULL);
	if (error) {
		printf("ufs_extattr_enable_with_open.VOP_OPEN(): failed "
		    "with %d\n", error);
		VOP_UNLOCK(vp, 0);
		return (error);
	}

	vp->v_writecount++;

	vref(vp);

	VOP_UNLOCK(vp, 0);

	error = ufs_extattr_enable(ump, attrnamespace, attrname, vp, td);
	if (error != 0)
		vn_close(vp, FREAD|FWRITE, td->td_ucred, td);
	return (error);
}
コード例 #2
0
ファイル: ufs_extattr.c プロジェクト: markjdb/freebsd-dev
/*
 * Enable an EA using the passed filesystem, backing vnode, attribute name,
 * namespace, and proc.  Will perform a VOP_OPEN() on the vp, so expects vp
 * to be locked when passed in.  The vnode will be returned unlocked,
 * regardless of success/failure of the function.  As a result, the caller
 * will always need to vrele(), but not vput().
 */
static int
ufs_extattr_enable_with_open(struct ufsmount *ump, struct vnode *vp,
    int attrnamespace, const char *attrname, struct thread *td)
{
	int error;

	error = VOP_OPEN(vp, FREAD|FWRITE, td->td_ucred, td, NULL);
	if (error) {
		printf("ufs_extattr_enable_with_open.VOP_OPEN(): failed "
		    "with %d\n", error);
		VOP_UNLOCK(vp, 0);
		return (error);
	}

	error = VOP_ADD_WRITECOUNT(vp, 1);
	if (error != 0) {
		VOP_CLOSE(vp, FREAD | FWRITE, td->td_ucred, td);
		VOP_UNLOCK(vp, 0);
		return (error);
	}
	CTR3(KTR_VFS, "%s: vp %p v_writecount increased to %d", __func__, vp,
	    vp->v_writecount);

	vref(vp);

	VOP_UNLOCK(vp, 0);

	error = ufs_extattr_enable(ump, attrnamespace, attrname, vp, td);
	if (error != 0)
		vn_close(vp, FREAD|FWRITE, td->td_ucred, td);
	return (error);
}
コード例 #3
0
ファイル: ufs_extattr.c プロジェクト: MarginC/kame
/*
 * Enable an EA using the passed file system, backing vnode, attribute name,
 * namespace, and proc.  Will perform a VOP_OPEN() on the vp, so expects vp
 * to be locked when passed in.  The vnode will be returned unlocked,
 * regardless of success/failure of the function.  As a result, the caller
 * will always need to vrele(), but not vput().
 */
static int
ufs_extattr_enable_with_open(struct ufsmount *ump, struct vnode *vp,
    int attrnamespace, const char *attrname, struct proc *p)
{
	int error;

	error = VOP_OPEN(vp, FREAD|FWRITE, p->p_ucred, p);
	if (error) {
		printf("ufs_extattr_enable_with_open.VOP_OPEN(): failed "
		    "with %d\n", error);
		VOP_UNLOCK(vp, 0, p);
		return (error);
	}

#if 0
	/* - XXX */
	/*
	 * XXX: Note, should VOP_CLOSE() if vfs_object_create() fails, but due
	 * to a similar piece of code in vn_open(), we don't.
	 */
	if (vn_canvmio(vp) == TRUE)
		if ((error = vfs_object_create(vp, p, p->p_ucred)) != 0) {
			/*
			 * XXX: bug replicated from vn_open(): should
			 * VOP_CLOSE() here.
			 */
			VOP_UNLOCK(vp, 0, p);
			return (error);
		}
#endif

	vp->v_writecount++;

	vref(vp);

	VOP_UNLOCK(vp, 0, p);

	error = ufs_extattr_enable(ump, attrnamespace, attrname, vp, p);
	if (error != 0)
		vn_close(vp, FREAD|FWRITE, p->p_ucred, p);
	return (error);
}