Skip to content

Commit cbda1b2

Browse files
committed
Merge branch 'work.cramfs' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull cramfs updates from Al Viro: "Nicolas Pitre's cramfs work" * 'work.cramfs' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: cramfs: rehabilitate it cramfs: add mmap support cramfs: implement uncompressed and arbitrary data block positioning cramfs: direct memory access support
2 parents ca5b857 + 8d59598 commit cbda1b2

6 files changed

Lines changed: 584 additions & 69 deletions

File tree

‎Documentation/filesystems/cramfs.txt‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,48 @@ you can just change the #define in mkcramfs.c, so long as you don't
4545
mind the filesystem becoming unreadable to future kernels.
4646

4747

48+
Memory Mapped cramfs image
49+
--------------------------
50+
51+
The CRAMFS_MTD Kconfig option adds support for loading data directly from
52+
a physical linear memory range (usually non volatile memory like Flash)
53+
instead of going through the block device layer. This saves some memory
54+
since no intermediate buffering is necessary to hold the data before
55+
decompressing.
56+
57+
And when data blocks are kept uncompressed and properly aligned, they will
58+
automatically be mapped directly into user space whenever possible providing
59+
eXecute-In-Place (XIP) from ROM of read-only segments. Data segments mapped
60+
read-write (hence they have to be copied to RAM) may still be compressed in
61+
the cramfs image in the same file along with non compressed read-only
62+
segments. Both MMU and no-MMU systems are supported. This is particularly
63+
handy for tiny embedded systems with very tight memory constraints.
64+
65+
The location of the cramfs image in memory is system dependent. You must
66+
know the proper physical address where the cramfs image is located and
67+
configure an MTD device for it. Also, that MTD device must be supported
68+
by a map driver that implements the "point" method. Examples of such
69+
MTD drivers are cfi_cmdset_0001 (Intel/Sharp CFI flash) or physmap
70+
(Flash device in physical memory map). MTD partitions based on such devices
71+
are fine too. Then that device should be specified with the "mtd:" prefix
72+
as the mount device argument. For example, to mount the MTD device named
73+
"fs_partition" on the /mnt directory:
74+
75+
$ mount -t cramfs mtd:fs_partition /mnt
76+
77+
To boot a kernel with this as root filesystem, suffice to specify
78+
something like "root=mtd:fs_partition" on the kernel command line.
79+
80+
81+
Tools
82+
-----
83+
84+
A version of mkcramfs that can take advantage of the latest capabilities
85+
described above can be found here:
86+
87+
https://github.com/npitre/cramfs-tools
88+
89+
4890
For /usr/share/magic
4991
--------------------
5092

‎MAINTAINERS‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3720,8 +3720,8 @@ F: drivers/cpuidle/*
37203720
F: include/linux/cpuidle.h
37213721

37223722
CRAMFS FILESYSTEM
3723-
W: http://sourceforge.net/projects/cramfs/
3724-
S: Orphan / Obsolete
3723+
M: Nicolas Pitre <nico@linaro.org>
3724+
S: Maintained
37253725
F: Documentation/filesystems/cramfs.txt
37263726
F: fs/cramfs/
37273727

‎fs/cramfs/Kconfig‎

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
config CRAMFS
2-
tristate "Compressed ROM file system support (cramfs) (OBSOLETE)"
3-
depends on BLOCK
2+
tristate "Compressed ROM file system support (cramfs)"
43
select ZLIB_INFLATE
54
help
65
Saying Y here includes support for CramFs (Compressed ROM File
@@ -16,7 +15,39 @@ config CRAMFS
1615
cramfs. Note that the root file system (the one containing the
1716
directory /) cannot be compiled as a module.
1817

19-
This filesystem is obsoleted by SquashFS, which is much better
20-
in terms of performance and features.
18+
This filesystem is limited in capabilities and performance on
19+
purpose to remain small and low on RAM usage. It is most suitable
20+
for small embedded systems. If you have ample RAM to spare, you may
21+
consider a more capable compressed filesystem such as SquashFS
22+
which is much better in terms of performance and features.
23+
24+
If unsure, say N.
25+
26+
config CRAMFS_BLOCKDEV
27+
bool "Support CramFs image over a regular block device" if EXPERT
28+
depends on CRAMFS && BLOCK
29+
default y
30+
help
31+
This option allows the CramFs driver to load data from a regular
32+
block device such a disk partition or a ramdisk.
33+
34+
config CRAMFS_MTD
35+
bool "Support CramFs image directly mapped in physical memory"
36+
depends on CRAMFS && MTD
37+
default y if !CRAMFS_BLOCKDEV
38+
help
39+
This option allows the CramFs driver to load data directly from
40+
a linear adressed memory range (usually non volatile memory
41+
like flash) instead of going through the block device layer.
42+
This saves some memory since no intermediate buffering is
43+
necessary.
44+
45+
The location of the CramFs image is determined by a
46+
MTD device capable of direct memory mapping e.g. from
47+
the 'physmap' map driver or a resulting MTD partition.
48+
For example, this would mount the cramfs image stored in
49+
the MTD partition named "xip_fs" on the /mnt mountpoint:
50+
51+
mount -t cramfs mtd:xip_fs /mnt
2152

2253
If unsure, say N.

‎fs/cramfs/README‎

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,46 @@ same as the start of the (i+1)'th <block> if there is one). The first
4949
<block> immediately follows the last <block_pointer> for the file.
5050
<block_pointer>s are each 32 bits long.
5151

52+
When the CRAMFS_FLAG_EXT_BLOCK_POINTERS capability bit is set, each
53+
<block_pointer>'s top bits may contain special flags as follows:
54+
55+
CRAMFS_BLK_FLAG_UNCOMPRESSED (bit 31):
56+
The block data is not compressed and should be copied verbatim.
57+
58+
CRAMFS_BLK_FLAG_DIRECT_PTR (bit 30):
59+
The <block_pointer> stores the actual block start offset and not
60+
its end, shifted right by 2 bits. The block must therefore be
61+
aligned to a 4-byte boundary. The block size is either blksize
62+
if CRAMFS_BLK_FLAG_UNCOMPRESSED is also specified, otherwise
63+
the compressed data length is included in the first 2 bytes of
64+
the block data. This is used to allow discontiguous data layout
65+
and specific data block alignments e.g. for XIP applications.
66+
67+
5268
The order of <file_data>'s is a depth-first descent of the directory
5369
tree, i.e. the same order as `find -size +0 \( -type f -o -type l \)
5470
-print'.
5571

5672

5773
<block>: The i'th <block> is the output of zlib's compress function
58-
applied to the i'th blksize-sized chunk of the input data.
74+
applied to the i'th blksize-sized chunk of the input data if the
75+
corresponding CRAMFS_BLK_FLAG_UNCOMPRESSED <block_ptr> bit is not set,
76+
otherwise it is the input data directly.
5977
(For the last <block> of the file, the input may of course be smaller.)
6078
Each <block> may be a different size. (See <block_pointer> above.)
79+
6180
<block>s are merely byte-aligned, not generally u32-aligned.
6281

82+
When CRAMFS_BLK_FLAG_DIRECT_PTR is specified then the corresponding
83+
<block> may be located anywhere and not necessarily contiguous with
84+
the previous/next blocks. In that case it is minimally u32-aligned.
85+
If CRAMFS_BLK_FLAG_UNCOMPRESSED is also specified then the size is always
86+
blksize except for the last block which is limited by the file length.
87+
If CRAMFS_BLK_FLAG_DIRECT_PTR is set and CRAMFS_BLK_FLAG_UNCOMPRESSED
88+
is not set then the first 2 bytes of the block contains the size of the
89+
remaining block data as this cannot be determined from the placement of
90+
logically adjacent blocks.
91+
6392

6493
Holes
6594
-----

0 commit comments

Comments
 (0)