linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* cramfs in big endian
@ 2007-11-06 21:16 Andi Drebes
  2007-11-07 13:52 ` Tomas M
  0 siblings, 1 reply; 11+ messages in thread
From: Andi Drebes @ 2007-11-06 21:16 UTC (permalink / raw)
  To: linux-fsdevel

Hi!
I'm currently trying to enable the cramfs to mount filesystems with a 
different endianness. All I have is an intel compatible machine that produces 
cramfs images in little endian format. I found a modified version of mkcramfs 
that is able to produce images in big endian mode. Unfortunately it seems to 
use a different compression algorithm (LZO) than the standard implementation 
(zlib).

I would be very glad if somebody could send me an image in big endian mode 
using the zlib deflate compression algorithm. I have uploaded a bz2 archive 
containing some testfiles. You can find it at [1].


Regards,
	Andi

[1] http://drebesium.org/~hackbert/cramfs-testfiles.tar.bz2

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: cramfs in big endian
  2007-11-06 21:16 cramfs in big endian Andi Drebes
@ 2007-11-07 13:52 ` Tomas M
  2007-11-07 20:51   ` Andi Drebes
  0 siblings, 1 reply; 11+ messages in thread
From: Tomas M @ 2007-11-07 13:52 UTC (permalink / raw)
  To: Andi Drebes; +Cc: linux-fsdevel

> I'm currently trying to enable the cramfs to mount filesystems with a 
> different endianness. 

I would suggest you to use squashfs instead of cramfs.

First, it's newer, it's better, it's actively developed, it doesn't have any limits like the bad cramfs.
Moreover, it currently supports both endians. 

(hurry up, as kernel people said in the past that squashfs should NEVER EVER support multiple endians, so the feature will be dropped from squashfs, in order to get it into mainline kernel more easily; if my informations are correct).



Tomas M


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: cramfs in big endian
  2007-11-07 13:52 ` Tomas M
@ 2007-11-07 20:51   ` Andi Drebes
  2007-11-07 22:49     ` Christoph Hellwig
  0 siblings, 1 reply; 11+ messages in thread
From: Andi Drebes @ 2007-11-07 20:51 UTC (permalink / raw)
  To: Tomas M; +Cc: linux-fsdevel

Hi!

> I would suggest you to use squashfs instead of cramfs.
> First, it's newer, it's better, it's actively developed, it doesn't have any
> limits like the bad cramfs. 
I'm developing a new linux based firmware for my router which uses cramfs. 
Switching to squashfs still needs some time. Meanwhile, I have to work with 
cramfs. As the router uses the big endian format and as my machine works with 
the little endian format, I'm unable to mount the router's filesystem images.


	Andi

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: cramfs in big endian
  2007-11-07 20:51   ` Andi Drebes
@ 2007-11-07 22:49     ` Christoph Hellwig
  2007-11-08 18:10       ` Andi Drebes
  2007-11-10  1:03       ` H. Peter Anvin
  0 siblings, 2 replies; 11+ messages in thread
From: Christoph Hellwig @ 2007-11-07 22:49 UTC (permalink / raw)
  To: Andi Drebes; +Cc: Tomas M, linux-fsdevel

On Wed, Nov 07, 2007 at 09:51:48PM +0100, Andi Drebes wrote:
> Hi!
> 
> > I would suggest you to use squashfs instead of cramfs.
> > First, it's newer, it's better, it's actively developed, it doesn't have any
> > limits like the bad cramfs. 
> I'm developing a new linux based firmware for my router which uses cramfs. 
> Switching to squashfs still needs some time. Meanwhile, I have to work with 
> cramfs. As the router uses the big endian format and as my machine works with 
> the little endian format, I'm unable to mount the router's filesystem images.

Making cramfs endianess-independent shouldn't be much work.  Take a look
at the helpers in fs/ufs/swab.h and use them for every ondisk access in
cramfs.  Drop me a not if you need some help.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: cramfs in big endian
  2007-11-07 22:49     ` Christoph Hellwig
@ 2007-11-08 18:10       ` Andi Drebes
  2007-11-10  1:03       ` H. Peter Anvin
  1 sibling, 0 replies; 11+ messages in thread
From: Andi Drebes @ 2007-11-08 18:10 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: Tomas M, linux-fsdevel

Hi!

> Making cramfs endianess-independent shouldn't be much work.  Take a look
> at the helpers in fs/ufs/swab.h and use them for every ondisk access in
> cramfs.  Drop me a not if you need some help.
I already started working on this feature some time ago. I think I am able to 
mount cramfs images with another endianness. But all I have to test this are 
images that use LZO compression istead of deflate.

In the original post I was just asking somebody possessing a big endian 
machine to create an image in big endian / deflate format. This would help me 
a lot. Later, I want to add support for multiple compression algorithms.

Thanks so far,
	Andi

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: cramfs in big endian
  2007-11-07 22:49     ` Christoph Hellwig
  2007-11-08 18:10       ` Andi Drebes
@ 2007-11-10  1:03       ` H. Peter Anvin
  2007-11-10 15:13         ` Christoph Hellwig
  1 sibling, 1 reply; 11+ messages in thread
From: H. Peter Anvin @ 2007-11-10  1:03 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: Andi Drebes, Tomas M, linux-fsdevel

Christoph Hellwig wrote:
> On Wed, Nov 07, 2007 at 09:51:48PM +0100, Andi Drebes wrote:
>> Hi!
>>
>>> I would suggest you to use squashfs instead of cramfs.
>>> First, it's newer, it's better, it's actively developed, it doesn't have any
>>> limits like the bad cramfs. 
>> I'm developing a new linux based firmware for my router which uses cramfs. 
>> Switching to squashfs still needs some time. Meanwhile, I have to work with 
>> cramfs. As the router uses the big endian format and as my machine works with 
>> the little endian format, I'm unable to mount the router's filesystem images.
> 
> Making cramfs endianess-independent shouldn't be much work.  Take a look
> at the helpers in fs/ufs/swab.h and use them for every ondisk access in
> cramfs.  Drop me a not if you need some help.

And it would suck.  Hard.

Endian-independent code is slower than wrong-endian code, because of the 
necessary conditionals.  Thus, you DO NOT WANT this(*).

The only way to not make it totally suck is to compile the code twice 
and do switching at a VERY high level -- in effect, creating two 
separate filesystem drivers.

	-hpa

(*) Readonly filesystems like iso9660 have attempted to be 
*both*-endian, by having its datastructures in both forms at all times. 
    That is inefficient with space, but would be CPU-efficient in 
theory.  Unfortunately it causes output validation problems; apparently 
many iso9660 mastering programs output invalid bigendian information as 
it is never tested; consequently, many bigendian platforms read the 
littleendian information anyway.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: cramfs in big endian
  2007-11-10  1:03       ` H. Peter Anvin
@ 2007-11-10 15:13         ` Christoph Hellwig
  2007-11-10 20:19           ` H. Peter Anvin
  2007-11-10 20:26           ` Andi Drebes
  0 siblings, 2 replies; 11+ messages in thread
From: Christoph Hellwig @ 2007-11-10 15:13 UTC (permalink / raw)
  To: H. Peter Anvin; +Cc: Christoph Hellwig, Andi Drebes, Tomas M, linux-fsdevel

On Fri, Nov 09, 2007 at 05:03:01PM -0800, H. Peter Anvin wrote:
> Endian-independent code is slower than wrong-endian code, because of the 
> necessary conditionals.  Thus, you DO NOT WANT this(*).

I'd prefer not to have it either.  But a someone (pinhead) was smart
enough not to define an endianess for cramfs from the beginning we're
stuck with it.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: cramfs in big endian
  2007-11-10 15:13         ` Christoph Hellwig
@ 2007-11-10 20:19           ` H. Peter Anvin
  2007-11-10 20:26           ` Andi Drebes
  1 sibling, 0 replies; 11+ messages in thread
From: H. Peter Anvin @ 2007-11-10 20:19 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: Andi Drebes, Tomas M, linux-fsdevel

Christoph Hellwig wrote:
> On Fri, Nov 09, 2007 at 05:03:01PM -0800, H. Peter Anvin wrote:
>> Endian-independent code is slower than wrong-endian code, because of the 
>> necessary conditionals.  Thus, you DO NOT WANT this(*).
> 
> I'd prefer not to have it either.  But a someone (pinhead) was smart
> enough not to define an endianess for cramfs from the beginning we're
> stuck with it.
> 

I thought cramfs was "always" defined as littleendian?

Either way... I thought the primary discussion was about squashfs.

	-hpa

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: cramfs in big endian
  2007-11-10 15:13         ` Christoph Hellwig
  2007-11-10 20:19           ` H. Peter Anvin
@ 2007-11-10 20:26           ` Andi Drebes
  2007-11-10 20:30             ` H. Peter Anvin
  1 sibling, 1 reply; 11+ messages in thread
From: Andi Drebes @ 2007-11-10 20:26 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: H. Peter Anvin, Tomas M, Christoph Hellwig

> > Endian-independent code is slower than wrong-endian code, because of the 
> > necessary conditionals.  Thus, you DO NOT WANT this(*).
> 
> I'd prefer not to have it either.  But a someone (pinhead) was smart
> enough not to define an endianess for cramfs from the beginning we're
> stuck with it.

Indeed, this is the problem. The readme file fs/cramfs/README states:

"One part of that is addressing endianness.  The two options here are
`always use little-endian' (like ext2fs) or `writer chooses
endianness; kernel adapts at runtime'.  Little-endian wins because of
code simplicity and little CPU overhead even on big-endian machines."

Unfortunately, the better idea was never implemented. Further, there's no 
information about the endianness stored in the filesystem. Guessing it and 
mounting the filesystem isn't a clean solution. Even worse, there's no 
information about which compression algorithm was used to create the 
filesystem. Guessing the compression method may lead to serious problems.

So here is my proposal for future development of cramfs:
The should tell cramfs how to mount a filesystem. Therefore, the endianness 
and the compression method both have to be specified manually. If none is 
specified, cramfs will assume host endianness and that deflate can be used in 
order to decompress the contents. If something seems to be wrong with the 
filesystem (e.g. wrong magic), cramfs will guess the endianness and inform 
the user about the guess, but it won't mount the filesystem if it doesn't 
match the endianness specified or the host's one.

	Andi

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: cramfs in big endian
  2007-11-10 20:26           ` Andi Drebes
@ 2007-11-10 20:30             ` H. Peter Anvin
  2007-11-11 10:20               ` Andi Drebes
  0 siblings, 1 reply; 11+ messages in thread
From: H. Peter Anvin @ 2007-11-10 20:30 UTC (permalink / raw)
  To: Andi Drebes; +Cc: linux-fsdevel, Tomas M, Christoph Hellwig

Andi Drebes wrote:
> 
> Indeed, this is the problem. The readme file fs/cramfs/README states:
> 
> "One part of that is addressing endianness.  The two options here are
> `always use little-endian' (like ext2fs) or `writer chooses
> endianness; kernel adapts at runtime'.  Little-endian wins because of
> code simplicity and little CPU overhead even on big-endian machines."
> 
> Unfortunately, the better idea was never implemented. Further, there's no 
> information about the endianness stored in the filesystem. Guessing it and 
> mounting the filesystem isn't a clean solution. Even worse, there's no 
> information about which compression algorithm was used to create the 
> filesystem. Guessing the compression method may lead to serious problems.
> 
> So here is my proposal for future development of cramfs:
> The should tell cramfs how to mount a filesystem. Therefore, the endianness 
> and the compression method both have to be specified manually. If none is 
> specified, cramfs will assume host endianness and that deflate can be used in 
> order to decompress the contents. If something seems to be wrong with the 
> filesystem (e.g. wrong magic), cramfs will guess the endianness and inform 
> the user about the guess, but it won't mount the filesystem if it doesn't 
> match the endianness specified or the host's one.
> 

What about simply deep-sixing cramfs and replacing it with squashfs or 
something else?

	-hpa

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: cramfs in big endian
  2007-11-10 20:30             ` H. Peter Anvin
@ 2007-11-11 10:20               ` Andi Drebes
  0 siblings, 0 replies; 11+ messages in thread
From: Andi Drebes @ 2007-11-11 10:20 UTC (permalink / raw)
  To: H. Peter Anvin; +Cc: linux-fsdevel, Tomas M, Christoph Hellwig

> What about simply deep-sixing cramfs and replacing it with squashfs or 
> something else?
I think this is the long term solution. Cramfs isn't a very beautiful 
filesystem. It's a good candidate for removal. However, there are still some 
distributions that use cramfs for initrds. So removing it immediately isn't a 
good idea.

	Andi

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2007-11-11 10:20 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-06 21:16 cramfs in big endian Andi Drebes
2007-11-07 13:52 ` Tomas M
2007-11-07 20:51   ` Andi Drebes
2007-11-07 22:49     ` Christoph Hellwig
2007-11-08 18:10       ` Andi Drebes
2007-11-10  1:03       ` H. Peter Anvin
2007-11-10 15:13         ` Christoph Hellwig
2007-11-10 20:19           ` H. Peter Anvin
2007-11-10 20:26           ` Andi Drebes
2007-11-10 20:30             ` H. Peter Anvin
2007-11-11 10:20               ` Andi Drebes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).