cramfs updates for 2.4.17
Subsystems (2)
PATCH 1/1 cramfs updates for 2.4.17
Various cramfs updates for 2.4.17. It only touches cramfs stuff. Your feedback is appreciated.
Note: This is not integrated with the big-endian patches yet, but that's what I'm currently looking at.
------------------------------------------------------------------------
summary: cramfs updates
Documentation/filesystems/cramfs.txt
- remove comment about ROM size limit
- fix up magic
fs/cramfs/README
- add note about sorted directory entries
- mkcramfs compile-time DO_HOLES option replaced by run-time -z option
- update tools section
- add note about PAGE_CACHE_SIZE possibly changing on arm and ia64
cramfs_fs.h
- add CRAMFS_MAXPATHLEN (252)
- clarify CRAMFS_SUPPORTED_FLAGS definition
cramfsck.c
- some new tests (several based on tests in Peter Moulder's cramfsck)
- large-scale code cleanup, check more return codes, standardized errors/warnings, etc.
- always try to mmap for crc test, fallback to read/write
mkcramfs.c
- bug fix: use CRAMFS_MAXPATHLEN not 255 as maximum pathname length (mkcramfs generated invalid cramfs images if pathnames of length 253-255 were included, but cramfsck was able to detect the problem)
- medium-scale code cleanup, check more return codes, standardized errors/warnings, etc.
- truncate UTF-8 filenames on character boundary (a longstanding TODO)
- use Z_BEST_COMPRESSION instead of default compression level
Documentation/filesystems/cramfs.txt +20 -12
@@ -19,9 +19,7 @@ File sizes are limited to less than 16MB. Maximum filesystem size is a little over 256MB. (The last file on the -filesystem is allowed to extend past 256MB.) (Comments in mkcramfs.c -suggest that ROM sizes may be limited to 64MB, though that's not a -limitation in cramfs code.) +filesystem is allowed to extend past 256MB.) Only the low 8 bits of gid are stored. The current version of mkcramfs simply truncates to 8 bits, which is a potential security
@@ -48,18 +46,28 @@ For /usr/share/magic ------------------- +-------------------- -0 long 0x28cd3d45 Linux cramfs ->4 long x size %d ->8 long x flags 0x%x ->12 long x future 0x%x +0 ulelong 0x28cd3d45 Linux cramfs offset 0 +>4 ulelong x size %d +>8 ulelong x flags 0x%x +>12 ulelong x future 0x%x >16 string >\0 signature "%.16s" ->32 long x fsid.crc 0x%x ->36 long x fsid.edition %d ->40 long x fsid.blocks %d ->44 long x fsid.files %d +>32 ulelong x fsid.crc 0x%x +>36 ulelong x fsid.edition %d +>40 ulelong x fsid.blocks %d +>44 ulelong x fsid.files %d >48 string >\0 name "%.16s" +512 ulelong 0x28cd3d45 Linux cramfs offset 512 +>516 ulelong x size %d +>520 ulelong x flags 0x%x +>524 ulelong x future 0x%x +>528 string >\0 signature "%.16s" +>544 ulelong x fsid.crc 0x%x +>548 ulelong x fsid.edition %d +>552 ulelong x fsid.blocks %d +>556 ulelong x fsid.files %d +>560 string >\0 name "%.16s" Hacker Notes
fs/cramfs/README +16 -7
@@ -29,6 +29,10 @@ lines); put another way, the same order as `find -type d -exec ls -AU1 {} \;'. +Beginning in 2.4.7, directory entries are sorted. This optimization +allows cramfs_lookup to return more quickly when a filename does not +exist, speeds up user-space directory sorts, etc. + <data>: One <file_data> for each file that's either a symlink or a regular file of non-zero st_size.
@@ -63,17 +67,22 @@ This kernel supports cramfs holes (i.e. [efficient representation of] blocks in uncompressed data consisting entirely of NUL bytes), but by default mkcramfs doesn't test for & create holes, since cramfs in -kernels up to at least 2.3.39 didn't support holes. Compile mkcramfs -with -DDO_HOLES if you want it to create files that can have holes in -them. +kernels up to at least 2.3.39 didn't support holes. Run mkcramfs +with -z if you want it to create files that can have holes in them. Tools ----- +The cramfsck program included in the scripts/cramfs directory can (and +perhaps even should) be used to test cramfs filesystems, although it +does not try to fix errors since cramfs is a read-only filesystem and +you can just re-run mkcramfs after fixing any bugs. cramfsck can also +extract cramfs filesystems without mounting them. + If you're hacking on cramfs, you might find useful some tools for -testing cramfs at <http://cvs.bofh.asn.au/cramfs/>, including a -rudimentary fsck for cramfs. +testing cramfs at <http://cvs.bofh.asn.au/cramfs/>. Note: the +cramfsck located there is superseded by the one in scripts/cramfs. Future Development
@@ -103,8 +112,8 @@ PAGE_CACHE_SIZE (4096)' to `#include <asm/page.h>'. The disadvantage is that the generated cramfs cannot always be shared between different kernels, not even necessarily kernels of the same architecture if -PAGE_CACHE_SIZE is subject to change between kernel versions. - +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.
include/linux/cramfs_fs.h +17 -8
@@ -24,6 +24,12 @@#define CRAMFS_OFFSET_WIDTH 26/* +* Since inode.namelen is a unsigned 6-bit number, the maximum cramfs +* path length is 63 << 2 = 252. +*/ +#define CRAMFS_MAXPATHLEN (((1 << CRAMFS_NAMELEN_WIDTH) - 1) << 2) + +/* * Reasonably terse representation of the inode data. */ struct cramfs_inode {
@@ -52,14 +58,14 @@* Superblock information at the beginning of the FS. */ struct cramfs_super { -u32 magic;/* 0x28cd3d45 - random number */ -u32 size;/* length in bytes */ -u32 flags;/* 0 */ -u32 future;/* 0 */ -u8 signature[16 ];/* "Compressed ROMFS" */ +u32 magic;/* 0x28cd3d45 - random number */ +u32 size;/* length in bytes */ +u32 flags;/* feature flags */ +u32 future;/* reserved for future use */ +u8 signature[16 ];/* "Compressed ROMFS" */ struct cramfs_info fsid;/* unique filesystem info */ -u8 name[16 ];/* user-defined name */ -struct cramfs_inode root;/* Root inode data */ +u8 name[16 ];/* user-defined name */ +struct cramfs_inode root;/* root inode data */ };/*
@@ -79,7 +85,10 @@* if (flags & ~CRAMFS_SUPPORTED_FLAGS). Maybe that should be * changed to test super.future instead. */ -#define CRAMFS_SUPPORTED_FLAGS (0x7ff) +#define CRAMFS_SUPPORTED_FLAGS ( 0x000000ff \ + | CRAMFS_FLAG_HOLES \ + | CRAMFS_FLAG_WRONG_SIGNATURE \ + | CRAMFS_FLAG_SHIFTED_ROOT_OFFSET )/* Uncompression interfaces to the underlying zlib */ int cramfs_uncompress_block (void *dst,int dstlen,void *src,int srclen);
scripts/cramfs/cramfsck.c +426 -307
920 lines not on this page · raw message
scripts/cramfs/mkcramfs.c +289 -212
839 lines not on this page · raw message
Signature · 2 lines
Daniel Quinlan (at work) [email protected]
On Wed, 16 Jan 2002, Daniel Quinlan wrote:
[..]
Quoted 1 line
mkcramfs.c
[..]
Why not move this tool to util-linux ?
kloczek
Signature · 4 lines
----------------------------------------------------------- *Ludzie nie mają problemów, tylko sobie sami je stwarzają* ----------------------------------------------------------- Tomasz Kłoczko, sys adm @zie.pg.gda.pl|*e-mail: [email protected]*
Quoted 6 lines · =?ISO-8859-2?Q?Tomasz=5FK=B3oczko?= writes:
On Wed, 16 Jan 2002, Daniel Quinlan wrote:
[..]Quoted 1 line
mkcramfs.c[..]
Why not move this tool to util-linux ?
I'm actually ready to move the tools to sourceforge (the cramfs tools CVS tree is there).
http://sourceforge.net/projects/cramfs/
Assuming it's okay with Linus and Marcelo, I'll remove scripts/cramfs in the next version of the patch (which should be fine for 2.5 too).
Dan
Quoted 13 lines
Quoted 6 lines · =?ISO-8859-2?Q?Tomasz=5FK=B3oczko?= writes:
On Wed, 16 Jan 2002, Daniel Quinlan wrote:
[..]Quoted 1 line
mkcramfs.c[..]
Why not move this tool to util-linux ?
I'm actually ready to move the tools to sourceforge (the cramfs tools CVS tree is there).
Quoted 6 lines
http://sourceforge.net/projects/cramfs/
Assuming it's okay with Linus and Marcelo, I'll remove
scripts/cramfsin the next version of the patch (which should be fine for 2.5 too).Dan
Why move it?
Having it in the tree makes it nice and easy to use it,
and easy keeping it in sync.
BTW: I have an improvement wish for cramfs:
Add the date of filesystemgeneration to the image header somewhere and use that to update the time info in the inode, that way you could get a cheap way of having some valid time stamp for the files without it taking a lot of space (helps if you have a webserver and the browser caches stuff)
/Johan
Quoted 5 lines · Johan Adolfsson
Quoted 2 lines · Daniel Quinlan
Assuming it's okay with Linus and Marcelo, I'll remove
scripts/cramfsin the next version of the patch (which should be fine for 2.5 too).Why move it?
Because leaving it in the kernel tree would be an invitation to move mke2fs, mkreiserfs, mkxfsfs, etc. into the kernel source tree as well.
Erik
Signature · 5 lines
J.A.K. (Erik) Mouw, Information and Communication Theory Group, Faculty of Information Technology and Systems, Delft University of Technology, PO BOX 5031, 2600 GA Delft, The Netherlands Phone: +31-15-2783635 Fax: +31-15-2781843 Email: [email protected] WWW: http://www-ict.its.tudelft.nl/~erik/
Daniel Quinlan <[email protected]> said:
[...]
Quoted 3 lines
fs/cramfs/README
- add note about sorted directory entries
- mkcramfs compile-timeDO_HOLESoption replaced by run-time -z option
I'd do it the other way around: No-holes is for backward compatibility, and should someday go away. Let the legacy uses pay the price...
Signature · 1 line
Horst von Brand http://counter.li.org # 22616