Re: [PATCH 2/3] hfsplus: implement attributes file's header node initialization code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 20 Sep 2013 14:04:09 +0400 Vyacheslav Dubeyko <slava@xxxxxxxxxxx> wrote:

> From: Vyacheslav Dubeyko <slava@xxxxxxxxxxx>
> Subject: [PATCH 2/3] hfsplus: implement attributes file's header node initialization code
> 
> This patch implements functionality of AttributesFile's header
> node initialization.
> 
> ...
>
> --- a/fs/hfsplus/hfsplus_raw.h
> +++ b/fs/hfsplus/hfsplus_raw.h
> @@ -187,6 +187,9 @@ struct hfs_btree_header_rec {
>  /* HFS+ BTree misc info */
>  #define HFSPLUS_TREE_HEAD 0
>  #define HFSPLUS_NODE_MXSZ 32768
> +#define HFSPLUS_ATTR_TREE_NODE_SIZE		8192
> +#define HFSPLUS_BTREE_HDR_NODE_RECS_COUNT	3
> +#define HFSPLUS_BTREE_HDR_USER_BYTES		128
>  
>  /* Some special File ID numbers (stolen from hfs.h) */
>  #define HFSPLUS_POR_CNID		1	/* Parent Of the Root */
> diff --git a/fs/hfsplus/xattr.c b/fs/hfsplus/xattr.c
> index bd8471f..31f70f5 100644
> --- a/fs/hfsplus/xattr.c
> +++ b/fs/hfsplus/xattr.c
> @@ -127,6 +127,69 @@ static int can_set_xattr(struct inode *inode, const char *name,
>  	return 0;
>  }
>  
> +#define SETOFFSET(buf, ndsiz, offset, rec) \
> +	(*(u16 *)((u8 *)(buf) + (ndsiz) + (-2 * (rec))) = (cpu_to_be16(offset)))

This is pretty ghastly.  Can you take a look at reimplementing it in a C
function?  Add any necessary comments to explain what's happening and I
expect you will find that it produces a much nicer result.

I'd also suggest taking a look at the type of `buf' and `bmp'.  They're
never really *used* as char*'s, so why not make them u8* or even void*
and avoid some typecasting?

> +static void hfsplus_init_header_node(struct inode *attr_file,
> +					u32 clump_size,
> +					char *buf, size_t node_size)
> +{
> +	struct hfs_bnode_desc *desc;
> +	struct hfs_btree_header_rec *head;
> +	u16 offset;
> +	u32 hdr_node_map_rec_bits;
> +	char *bmp;
> +	u32 temp;
> +
>
> ...
>
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux