Skip to content
Brendan G Bohannon edited this page Dec 6, 2015 · 4 revisions

Thoughts for a new VFS.

ZPack3

ZPack3 will be a compressed VFS.

It will exist in terms of 256 byte device blocks.

Data will be compressed in terms of larger "logical blocks", which will each be stored in terms of a number of a span of consecutive device blocks. By default, logical blocks will be 256kB (for BTLZH), or 64kB for Deflate.

Image Header:

 struct ZPack3_Header_s {
 byte unused[4096];           //4kB of unused space.
 EIGHTCC magic;               //'ZPACK300'
 ZPack3_FileStorage root;     //root directory
 };

File Storage defines a stored block of data:

 struct ZPack3_FileStorage_s {
 u32 blkAddr;    //0, block address in device blocks
 u32 blkCSize;   //4, size of compressed block
 u32 lSize;      //8, logical file size (4GB)
 u16 nlblocks;   //12, number of logical blocks in file
 byte lblksz;    //14, logical block-size (log2)
 byte method;    //15, compression method
 };

If nlblocks is 0, the file is represented as a single compressed block. Otherwise, this gives the number of logical blocks in the file, and the data holds a compressed index instead.

Method:

  • 0=Store
  • 8=Deflate
  • 9=Deflate64
  • 10=BTLZH10
Stored data will be raw data. Deflate, Deflate64, and BTLZH will use the Zlib format.

The file for a multi-block file is represented as a number of BlockSpan entries:

 struct ZPack3_BlockSpan_s {
 u32 blkAddr;    //0, block address in device blocks
 u32 blkCSizeM;  //4, low 24=size of compressed block, high 8=method
 };

The root directory will consist of a number of DirEnt entries:

 struct ZPack3_DirEnt_s {
 char name[64];             //  0, file or directory name (up to 64 chars)
 ZPack3_FileStorage file;   // 64, file data
 u32 dirNext;               // 80, next in current directory
 u32 dirFirst;              // 84, first in child directory (directories)
 u32 dirParent;             // 88, parent directory entry (id for current directory)
 u32 flags;                 // 92, file flags
 u32 access;                // 96, access mode
 s32 mtime;                 //100, modified time
 u32 syncVerId;             //104, synchronization version ID
 u32 pad[5];
 };

Access Mode:

 bits 30..31: 0=UID/GID Mode
 bits 27..29: reserved
 bits 18..26: Urwx Grwx Orwx
 bits  9..17: GID
 bits  0.. 8: UID

mtime:

 bits 0..17: Time in units of 330ms
 bits 18..31: Days from the date of volume creation.
Clone this wiki locally