[Ocfs2-devel] [PATCH 08/15] ocfs2: Add extended attribute support v2

Mark Fasheh mfasheh at suse.com
Tue Jul 15 14:28:03 PDT 2008


On Fri, Jun 27, 2008 at 03:27:35PM +0800, Tiger Yang wrote:
> +/*
> + * ocfs2_xattr_set()
> + *
> + * Set, replace or remove an extended attribute for this inode.
> + * value is NULL to remove an existing extended attribute, else either
> + * create or replace an extended attribute.
> + */
> +int ocfs2_xattr_set(struct inode *inode,
> +		    int name_index,
> +		    const char *name,
> +		    const void *value,
> +		    size_t value_len,
> +		    int flags)
> +{
> +	struct buffer_head *di_bh = NULL;
> +	struct ocfs2_dinode *di;
> +	int ret;
> +
> +	struct ocfs2_xattr_info xi = {
> +		.name_index = name_index,
> +		.name = name,
> +		.value = value,
> +		.value_len = value_len,
> +	};
> +
> +	struct ocfs2_xattr_search xis = {
> +		.not_found = -ENODATA,
> +	};
> +
> +	struct ocfs2_xattr_search xbs = {
> +		.not_found = -ENODATA,
> +	};
> +
> +	ret = ocfs2_inode_lock(inode, &di_bh, 1);
> +	if (ret < 0) {
> +		mlog_errno(ret);
> +		return ret;
> +	}
> +	xis.inode_bh = xbs.inode_bh = di_bh;
> +	di = (struct ocfs2_dinode *)di_bh->b_data;
> +
> +
> +	/*
> +	 * Scan inode and external block to find the same name
> +	 * extended attribute and collect search infomation.
> +	 */
> +	ret = ocfs2_xattr_ibody_find(inode, name_index, name, &xis);
> +	if (ret)
> +		goto cleanup;
> +	if (xis.not_found) {
> +		ret = ocfs2_xattr_block_find(inode, name_index, name, &xbs);
> +		if (ret)
> +			goto cleanup;
> +	}
> +
> +	if (xis.not_found && xbs.not_found) {
> +		ret = -ENODATA;
> +		if (flags & XATTR_REPLACE)
> +			goto cleanup;
> +		ret = 0;
> +		if (!value)
> +		goto cleanup;

Btw, your indentation here needs fixing.
	--Mark

--
Mark Fasheh



More information about the Ocfs2-devel mailing list