[Ocfs2-tools-devel] [PATCH 05/11] ocfs2-tools: add xattr support in lib
Joel Becker
Joel.Becker at oracle.com
Mon Mar 2 17:58:39 PST 2009
On Fri, Feb 27, 2009 at 03:53:40PM +0800, Tiger Yang wrote:
> +errcode_t ocfs2_read_xattr_block(ocfs2_filesys *fs,
> + uint64_t blkno,
> + char *xb_buf)
> +{
> + errcode_t ret = 0;
> + char *blk;
> + struct ocfs2_xattr_block *xb;
> +
> + if ((blkno < OCFS2_SUPER_BLOCK_BLKNO) ||
> + (blkno > fs->fs_blocks))
> + return OCFS2_ET_BAD_BLKNO;
> +
> + ret = ocfs2_malloc_block(fs->fs_io, &blk);
> + if (ret)
> + return ret;
> +
> + ret = io_read_block(fs->fs_io, blkno, 1, blk);
> + if (ret)
> + goto out;
> +
> + xb = (struct ocfs2_xattr_block *)blk;
> +
> + ret = ocfs2_validate_meta_ecc(fs, blk, &xb->xb_check);
> + if (ret)
> + goto out;
> +
Don't know how I missed this before. You should be checking the
signature after validating the ecc, just like in ocfs2_read_inode().
Oh, I see, it was in the earlier version. It should still be here, just
after the ecc check.
> +errcode_t ocfs2_xattr_get_rec(ocfs2_filesys *fs,
> + struct ocfs2_xattr_block *xb,
> + uint32_t name_hash,
> + uint64_t *p_blkno,
> + uint32_t *e_cpos,
> + uint32_t *num_clusters)
> +{
> + int i;
> + errcode_t ret = 0;
> + char *eb_buf = NULL;
> + struct ocfs2_extent_block *eb;
> + struct ocfs2_extent_rec *rec = NULL;
> + struct ocfs2_extent_list *el = &xb->xb_attrs.xb_root.xt_list;
> + uint64_t e_blkno = 0;
> +
You probably want to check xb->xb_flags to make sure
OCFS2_XATTR_INDEXED is set and return an error if it isn't.
Joel
--
"Born under a bad sign.
I been down since I began to crawl.
If it wasn't for bad luck,
I wouldn't have no luck at all."
Joel Becker
Principal Software Developer
Oracle
E-mail: joel.becker at oracle.com
Phone: (650) 506-8127
More information about the Ocfs2-tools-devel
mailing list