From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Morton Subject: Re: [PATCH 2/3] hfsplus: implement attributes file's header node initialization code Date: Wed, 25 Sep 2013 15:54:39 -0700 Message-ID: <20130925155439.ace1e0c0573b181a35b28928@linux-foundation.org> References: <1379671449.2280.28.camel@slavad-ubuntu> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: Linux FS devel list , Al Viro , Christoph Hellwig , Hin-Tak Leung To: slava@dubeyko.com Return-path: Received: from mail.linuxfoundation.org ([140.211.169.12]:50548 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753833Ab3IYWyk (ORCPT ); Wed, 25 Sep 2013 18:54:40 -0400 In-Reply-To: <1379671449.2280.28.camel@slavad-ubuntu> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Fri, 20 Sep 2013 14:04:09 +0400 Vyacheslav Dubeyko wrote: > From: Vyacheslav Dubeyko > 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; > + > > ... >