[Tux3] [PATCH 03/10] Fix ileaf aligment

Daniel Phillips phillips at phunq.net
Fri Oct 17 03:34:17 PDT 2008


On Friday 17 October 2008 03:02, OGAWA Hirofumi wrote:
> OGAWA Hirofumi <hirofumi at mail.parknet.co.jp> writes:
> 
> > Daniel Phillips <phillips at phunq.net> writes:
> >
> >>> -struct ileaf { u16 magic, count; inum_t ibase; char table[]; };
> >>> +struct ileaf { u16 magic, count; u32 pad; inum_t ibase; char table[]; };
> >>>  
> >>>  /*
> >>>   * inode leaf format
> >>
> >> Good catch.  A better way to fix this is using gcc attribute packed,
> >> which is done by the Tux3 macro PACKED:
> >
> > But, I think the result of it is aliment fault on some archs.
> 
> if we accessed ->ibase. Or we should use get_unaligned()?

I think we do want to pad it just as you have done.  We do need to get
unaligned in other code, the inode attributes specifically, and make
sure that always works.  We also do an endian conversion every time we
do this, so it is always going to be wrapped in a macro.  But I am not
sure that the endian macros can handle unaligned accesses on all
architectures.

Regards,

Daniel

_______________________________________________
Tux3 mailing list
Tux3 at tux3.org
http://tux3.org/cgi-bin/mailman/listinfo/tux3



More information about the Tux3 mailing list