partt partition table parser

Jörn Engel joern at wohnheim.fh-wedel.de
Tue Oct 9 09:22:39 EDT 2001


Hi!

> In general, it looks relatively sane. Can you justify the use of 
> CONFIG_MTD_PARTT_INDIRECT? 

During development, this makes it easier to move the partition table
around without recompiling the kernel. I might get rid of it if i
find/someone shows me a better solution. But work is still in
progress, even if the parser is already useable (and used).

> > +++ mtd/util/mkpartt.c	Tue Sep 25 20:15:58 2001
> > +#include "/usr/src/linux/include/linux/mtd/ibmpartt.h"
> 
> No. Pull the definitions into the C file or take a copy. Don't look too 
> hard at the mkfs.jffs2 code - do as I say, not as I do :)

That was a relic I missed. Fixed it now.

> > +void x_order_32 (__u32 *old32)
> > +{
> > +	__u32 new32;
> > +	__u8 *new8 = (__u8*)&new32;
> > +	__u8 *old8 = (__u8*)old32;
> > +	new8[0] = old8[3];
> > +	new8[1] = old8[2];
> > +	new8[2] = old8[1];
> > +	new8[3] = old8[0];
> > +	*old32 = new32;
> > +}
> 
> That's going to break. In the kernel, we compile with -fno-strict-aliasing 
> just because we've always had evil code there and nobody's yet looked too 
> hard at cleaning it up. For userspace, we need to write real C code.

True. I was still unaware of the correct way to handle endianness. Now
the partition table is big endian. Always. It feel good to reduce
error possibilities. :)

> > +		columns = sscanf (buf, " %20s %x %x %x", /* FIXME: Replace 20 with NAME_MAX_LEN */
> 
>  "%" #NAME_MAX_LEN "s %x %x %x"

It was a little more complicated than that. See the c faq.
http://www.eskimo.com/~scs/C-faq/q11.17.html

> How about making big-endian and little-endian options too, instead of just 
> cross-endian?

I chose a different approach (see above) that will cost some
nanoseconds on little endian machines but saves some people minutes
and hours by not messing up endianness again. Any objections?

The new patch can be found here:
http://wh.fh-wedel.de/~joern/software/kernel/partt.patch

Jörn

-- 
ticks = jiffies;
while (ticks == jiffies);
ticks = jiffies;
-- /usr/src/linux/init/main.c




More information about the linux-mtd mailing list