1 Storage format is simple: Zstandard-compressed list of records:
3 * 16-bit BE size of the following name
4 * entity (file, directory, symbolic link, etc) name itself.
5 Directory has trailing "/"
6 * single byte indicating current file's depth
7 * 64-bit BE mtime seconds
8 * 64-bit BE file or directory (sum of all files and directories) size
12 * traverse over all filesystem hierarchy in a *sorted* order. All
13 records are written to temporary file, without directory sizes,
14 because they are not known in advance during the walk
15 * during the walk, remember in memory each directory's total size
16 * read all records from that temporary file, writing to another one,
17 replacing directory sizes with ones remembered
21 * searching is performed on each record streamed from the database
22 * if -root is specified, then search will stop after that hierarchy
24 * by default all elements are printed, unless you provide a single
25 argument that becomes "*X*" pattern matched on case-lowered path
30 * read all [-+MR] actions from "zfs diff -FH", validating the whole
32 * each "R" for the file becomes "-" and "+" actions
33 * if there are "R"s for directories, then stream current database and
34 get each file entity for those directories, making "-" and "+"
35 actions correspondingly
36 * each "+" also adds an entry to the list of "M"s
37 * sort all "-", "+" and "M" filenames in ascending order
38 * get entity's information for each "M" (remembering its size and mtime)
39 * stream current database records, writing them to temporary file,
40 taking into account, that:
41 * if record exists in "-"-list, then skip it
42 * if any "+" exists in the *sorted* list, that has precedence over
43 the record from database, then insert it into the stream, taking
44 size and mtime information from "M"-list
45 * if any "M" exists for the read record, then use it to alter it
46 * all that time, directory size calculating algorithm, same used during
47 the index procedure, also works in parallel
48 * create another temporary file to copy the records with actualized