romfs的一个特别应用

转载时请注明出处和作者联系方式:http://blog.csdn.net/mimepp
作者联系方式:YU TAO <yut616 at sohu dot com>

在嵌入式系统中,大家都在使用romfs,这里对其做个分析笔记。

[ROMFS 定义]
ROM FILE SYSTEM

[资源]
http://sourceforge.net/projects/romfs/
其中的 romfs.txt 有对romfs做详细的解释。

[特点]
1、size 小
romfs被编译成module时,只需要不到一个 page 的大小,约 4000 bytes,而其他一些file system 就要大很多了。
name size(bytes)
minix <20K
msdos 30K
nfs 57K







2、结构简单

[格式分析]
The layout of the filesystem is the following:
offset        content
    +---+---+---+---+
  0    | - | r | o | m |  /
    +---+---+---+---+    The ASCII representation of those bytes
  4    | 1 | f | s | - |  /    (i.e. "-rom1fs-")
    +---+---+---+---+
  8    |   full size    |    The number of accessible bytes in this fs.
    +---+---+---+---+
 12    |    checksum    |    The checksum of the FIRST 512 BYTES.
    +---+---+---+---+
 16    | volume name    |    The zero terminated name of the volume,
    :               :    padded to 16 byte boundary.
    +---+---+---+---+
 xx    |     file    |
    :    headers    :

file
offset        content
    +---+---+---+---+
  0    | next filehdr|X|    The offset of the next file header
    +---+---+---+---+      (zero if no more files)
  4    |   spec.info    |    Info for directories/hard links/devices
    +---+---+---+---+
  8    |     size      |    The size of this file in bytes
    +---+---+---+---+
 12    |   checksum    |    Covering the meta data, including the file
    +---+---+---+---+      name, and padding
 16    | file name     |    The zero terminated name of the file,
    :               :    padded to 16 byte boundary
    +---+---+---+---+
 xx    | file data    |
    :        :

[一个应用]
可以将编译好的 linux kernel 也制作到romfs中,这样在启动bootloader时,直接使用romfs的格式信息,在其中找到 linux kernel 所在的位置,将其读出,并在后续解压,执行。这样做的好处是不用单独做一个linux kernel分区,而且也便于firmware upgrade。

你可能感兴趣的:(romfs的一个特别应用)