bun - bun file format
A bun file is a cdb file. cdb provides indexed and sequential access methods to records; refer to the cdb documentation for details of how the database is organized on disk.
The bun file format assumes ASCII throughout.
A valid bun file contains an index record with a null key (the key of length 0). The data associated with the index is the concatenation of each pathname that appears in the bun file, in netstring format.
Here is an example of a complete index, in cdbmake format.
+0,19:->3:foo,3:bar,4:quux,
This index contains three pathnames: foo, bar, and quux.
A valid bun file contains a head record for each
pathname. The head key is H
(the capital letter
aitch), followed by the pathname. The head data is the
concatenation of:
The file type character is one of the following.
Here are some example head records.
+4,2:Hfoo->0_ +4,2:Hbar->1_GZ +5,6:Hquux->2/AMOP
The first says that foo is a regular file; its
reference number is 0
, and there are no
metadata records associated with it. bar is also a
regular file, its reference number is 1
, and it
has two metadata records associated with it. quux
is a directory; its reference number is 2
, and
there are four metadata records associated with it.
All file types, except directory and pipe, require a content
record. The content key is D
(the capital
letter dee), followed by the relevant reference number.
For a file, the content data is the (possibly compressed) contents of the file.
For a link or symbolic link, the content data is the name of the file linked to.
For a device, whether character or block, the content data is the
value of st_rdev
stored as 8 bytes, big-endian.
Here is a trivial content record; the item with reference
number 0 (the regular file foo in this example) contains the
words bar
and baz
on separate lines.
+2,8:D0->bar baz
Each head record contains a (possibly empty) string of metadata characters. For each character, there is a corresponding metadata record: the key is the metadata character followed by the reference number.
The following metadata characters are defined.
Here are some example metadata records.
+2,6:Z1->gunzip +2,18:O2->4:Utjg,4:g312,1:O, +2,16:P2->3:RWS,2:RS,2:RS,
These say that file bar can be uncompressed with
gunzip
; directory quux is owned by
tjg
, has a numeric group ID of 312
, and the
permissions are rwxr-xr-x
.
The following file permission codes are defined for use in G and P metadata records.
Tim Goodwin; cdb by Dan Bernstein.