124 lines · plain
1.. SPDX-License-Identifier: GPL-2.02 3===========================================4Cramfs - cram a filesystem onto a small ROM5===========================================6 7cramfs is designed to be simple and small, and to compress things well.8 9It uses the zlib routines to compress a file one page at a time, and10allows random page access. The meta-data is not compressed, but is11expressed in a very terse representation to make it use much less12diskspace than traditional filesystems.13 14You can't write to a cramfs filesystem (making it compressible and15compact also makes it _very_ hard to update on-the-fly), so you have to16create the disk image with the "mkcramfs" utility.17 18 19Usage Notes20-----------21 22File sizes are limited to less than 16MB.23 24Maximum filesystem size is a little over 256MB. (The last file on the25filesystem is allowed to extend past 256MB.)26 27Only the low 8 bits of gid are stored. The current version of28mkcramfs simply truncates to 8 bits, which is a potential security29issue.30 31Hard links are supported, but hard linked files32will still have a link count of 1 in the cramfs image.33 34Cramfs directories have no ``.`` or ``..`` entries. Directories (like35every other file on cramfs) always have a link count of 1. (There's36no need to use -noleaf in ``find``, btw.)37 38No timestamps are stored in a cramfs, so these default to the epoch39(1970 GMT). Recently-accessed files may have updated timestamps, but40the update lasts only as long as the inode is cached in memory, after41which the timestamp reverts to 1970, i.e. moves backwards in time.42 43Currently, cramfs must be written and read with architectures of the44same endianness, and can be read only by kernels with PAGE_SIZE45== 4096. At least the latter of these is a bug, but it hasn't been46decided what the best fix is. For the moment if you have larger pages47you can just change the #define in mkcramfs.c, so long as you don't48mind the filesystem becoming unreadable to future kernels.49 50 51Memory Mapped cramfs image52--------------------------53 54The CRAMFS_MTD Kconfig option adds support for loading data directly from55a physical linear memory range (usually non volatile memory like Flash)56instead of going through the block device layer. This saves some memory57since no intermediate buffering is necessary to hold the data before58decompressing.59 60And when data blocks are kept uncompressed and properly aligned, they will61automatically be mapped directly into user space whenever possible providing62eXecute-In-Place (XIP) from ROM of read-only segments. Data segments mapped63read-write (hence they have to be copied to RAM) may still be compressed in64the cramfs image in the same file along with non compressed read-only65segments. Both MMU and no-MMU systems are supported. This is particularly66handy for tiny embedded systems with very tight memory constraints.67 68The location of the cramfs image in memory is system dependent. You must69know the proper physical address where the cramfs image is located and70configure an MTD device for it. Also, that MTD device must be supported71by a map driver that implements the "point" method. Examples of such72MTD drivers are cfi_cmdset_0001 (Intel/Sharp CFI flash) or physmap73(Flash device in physical memory map). MTD partitions based on such devices74are fine too. Then that device should be specified with the "mtd:" prefix75as the mount device argument. For example, to mount the MTD device named76"fs_partition" on the /mnt directory::77 78 $ mount -t cramfs mtd:fs_partition /mnt79 80To boot a kernel with this as root filesystem, suffice to specify81something like "root=mtd:fs_partition" on the kernel command line.82 83 84Tools85-----86 87A version of mkcramfs that can take advantage of the latest capabilities88described above can be found here:89 90https://github.com/npitre/cramfs-tools91 92 93For /usr/share/magic94--------------------95 96===== ======================= =======================970 ulelong 0x28cd3d45 Linux cramfs offset 098>4 ulelong x size %d99>8 ulelong x flags 0x%x100>12 ulelong x future 0x%x101>16 string >\0 signature "%.16s"102>32 ulelong x fsid.crc 0x%x103>36 ulelong x fsid.edition %d104>40 ulelong x fsid.blocks %d105>44 ulelong x fsid.files %d106>48 string >\0 name "%.16s"107512 ulelong 0x28cd3d45 Linux cramfs offset 512108>516 ulelong x size %d109>520 ulelong x flags 0x%x110>524 ulelong x future 0x%x111>528 string >\0 signature "%.16s"112>544 ulelong x fsid.crc 0x%x113>548 ulelong x fsid.edition %d114>552 ulelong x fsid.blocks %d115>556 ulelong x fsid.files %d116>560 string >\0 name "%.16s"117===== ======================= =======================118 119 120Hacker Notes121------------122 123See fs/cramfs/README for filesystem layout and implementation notes.124