cramfs big-endian kernel patch
Subsystems (2)
PATCH 1/1 cramfs big-endian kernel patch
This patch is against 2.4.19-pre1. A second message follows with the patch for the user-space tools. The original version of these changes were written by Bradley Bozarth <[email protected]>.
The kernel patch allows big-endian machines to mount and read cramfs filesystems (which are little-endian). The user-space tools patch does the same for mkcramfs and cramfsck. One note: there's a temporary #warning macro in cramfs_fs.h that should print out the (hopefully correct) byte order of your machine during compilation.
On little-endian systems, the object code is essentially unmodified from the original (I think it's a few bytes longer since a constant is added in one place).
Please let me know if you run into any problems.
- Dan
Documentation/filesystems/cramfs.txt +5 -6
@@ -37,12 +37,11 @@ the update lasts only as long as the inode is cached in memory, after which the timestamp reverts to 1970, i.e. moves backwards in time. -Currently, cramfs must be written and read with architectures of the -same endianness, and can be read only by kernels with PAGE_CACHE_SIZE -== 4096. At least the latter of these is a bug, but it hasn't been -decided what the best fix is. For the moment if you have larger pages -you can just change the #define in mkcramfs.c, so long as you don't -mind the filesystem becoming unreadable to future kernels. +Currently, cramfs can be read only by kernels with PAGE_CACHE_SIZE == +4096. This is a bug, but it hasn't been decided what the best fix is. +For the moment if you have larger pages you can just change the +#define in mkcramfs.c, so long as you don't mind the filesystem +becoming unreadable to future kernels. For /usr/share/magic
fs/cramfs/README +25 -14
@@ -6,8 +6,8 @@ swapped around (though it does care that directory entries (inodes) in a given directory are contiguous, as this is used by readdir). -All data is currently in host-endian format; neither mkcramfs nor the -kernel ever do swabbing. (See section `Block Size' below.) +All data is in little-endian format; user-space tools and the kernel do +swabbing on big-endian systems. (See section `Byte Order' below.) <filesystem>: <superblock>
@@ -71,6 +71,27 @@ with -z if you want it to create files that can have holes in them. +Byte Order +---------- + +When defining the cramfs filesystem, the two options for byte order were +`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. + +While cramfs has always been defined to be little-endian, this +implementation originally required that cramfs filesystems be written +and read with architectures of the same endianness; big-endian machines +would write and read cramfs filesystems with big-endian byte order (the +"incorrect" byte order for cramfs filesystems). + +Now, only little-endian cramfs filesystems are supported for both +little-endian and big-endian machines. If you need to support +big-endian cramfs filesystems for a legacy application on a big-endian +machine, you could remove the byte-swapping, but it would probably be +better to write a one-time byte order conversion program. + + Tools -----
@@ -108,17 +129,8 @@ PAGE_CACHE_SIZE is subject to change between kernel versions (currently possible with arm and ia64). -The remaining options try to make cramfs more sharable. - -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. - -The cost of swabbing is changing the code to use the le32_to_cpu -etc. macros as used by ext2fs. We don't need to swab the compressed -data, only the superblock, inodes and block pointers. - +The remaining options try to make cramfs more sharable by choosing a +block size. The options are: The other part of making cramfs more sharable is choosing a block size. The options are:
@@ -152,7 +164,6 @@ cost is greater complexity. Probably not worth it, but I hope someone will disagree. (If it is implemented, then I'll re-use that code in e2compr.) - Another cost of 2 and 3 over 1 is making mkcramfs use a different block size, but that just means adding and parsing a -b option.
fs/cramfs/inode.c +27 -24
123 lines not on this page · raw message
include/linux/cramfs_fs.h +61 -8
83 lines not on this page · raw message
In article <[email protected]> of linux.dev.kernel, you write:
Documentation/filesystems/cramfs.txt line 44
Quoted 7 lines
Documentation/filesystems/cramfs.txt +5
-0+Currently, cramfs can be read only by kernels with PAGE_CACHE_SIZE == +4096. This is a bug, but it hasn't been decided what the best fix is. +For the moment if you have larger pages you can just change the +#define in mkcramfs.c, so long as you don't mind the filesystem +becoming unreadable to future kernels.
For the binary format to be compatible, there is only one solution: if PAGE_CACHE_SIZE > 4096, you decompress more than one cramfs chunk into the same page.
If the binary format can change, then you could implement the same solution used in zisofs.
FWIW, currently on Linux I believe:
4096 <= PAGE_CACHE_SIZE <= 32768 -hpa
Signature · 3 lines
<[email protected]> at work, <[email protected]> in private! "Unix gives you enough rope to shoot yourself in the foot." http://www.zytor.com/~hpa/puzzle.txt <[email protected]>