annotate doc/TIFFS-old-description @ 873:3be5a1b4c91a

rvinterf/Makefile: asyncshell added
author Space Falcon <falcon@ivan.Harhan.ORG>
date Sat, 30 May 2015 06:45:21 +0000
parents 4eeab025b502
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
254
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
1 The description of TIFFS that follows was originally written in the summer of
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
2 SE52 (A.D. 2013), before the major TI source discoveries which happened later
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
3 that year. The text following the dividing line below has not been edited in
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
4 content since it was written; for a newer write-up based on the current source-
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
5 enabled understanding and reflecting the current FreeCalypso plans with respect
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
6 to this FFS, see TIFFS-Overview.
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
7
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
8 -------------------------------------------------------------------------------
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
9
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
10 This is a description, based on reverse engineering, of the flash file system
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
11 (FFS) implemented in Pirelli's original firmware for the DP-L10 GSM/WiFi dual
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
12 mode mobile phone, and in the Closedmoko GTA0x modem firmware. Not knowing the
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
13 "proper" name for this FFS, and needing _some_ identifier to refer to it, I
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
14 have named it Mokopir-FFS, from "Moko" and "Pirelli" - sometimes abbreviated
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
15 further to MPFFS.
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
16
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
17 (I have previously called the FFS in question MysteryFFS; but now that I've
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
18 successfully reverse-engineered it, it isn't as much of a mystery any more :-)
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
19
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
20 At a high functional level, Mokopir-FFS presents the following features:
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
21
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
22 * Has a directory tree structure like UNIX file systems;
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
23
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
24 * The file system API that must be implemented inside the proprietary firmware
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
25 appears to use UNIX-style pathnames; doing strings on firmware images reveals
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
26 pathname strings like these:
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
27
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
28 /var/dbg/dar
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
29 /gsm/l3/rr_white_list
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
30 /gsm/l3/rr_medium_rxlev_thr
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
31 /gsm/l3/rr_upper_rxlev_thr
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
32 /gsm/l3/shield
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
33
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
34 Parsing the corresponding FFS image with tools included in the present
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
35 package has confirmed that the directory structure implied by these pathnames
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
36 does indeed exist in the FFS.
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
37
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
38 * Absolutely no DOS-ish semantics seen anywhere: no 8.3 filenames and no
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
39 colon-separated device names (seen in the TSM30 file system source, for
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
40 example) are visible in the Closedmoko/Pirelli FFS.
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
41
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
42 * File contents are stored uncompressed, but not necessarily contiguous: one
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
43 could probably store a file in FFS which is bigger than the flash sector
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
44 size, it which case it can never be contiguous in a writable FFS (see below),
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
45 and the firmware implementation seems to limit chunk sizes to a fairly small
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
46 number: on the Pirelli phones all largish files are divided into chunks of
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
47 8 KiB each, and on my GTA02 the largest observed chunk size is only 2 KiB.
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
48
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
49 The smaller files, like the IMEI and the firmware ID strings in my GTA02 FFS,
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
50 are contiguous.
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
51
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
52 * The FFS structure is such that the length of "user" payload data stored in
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
53 each chunk (and consequently, in each file) can be known exactly in bytes,
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
54 with the files/chunks able to contain arbitrary binary data. (This property
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
55 may seem obvious or trivial, as all familiar UNIX and DOS file systems have
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
56 it, but contrast with RT-11 for example.)
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
57
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
58 * The flash file system is a writable one: the running firmware can create,
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
59 delete and overwrite files (and possibly directories too) in the live FFS;
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
60 thus the FFS design is such that allows these operations to be performed
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
61 within the physical constraints of NOR flash write operations.
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
62
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
63 I have reverse-engineered this Mokopir-FFS on a read-only level. What it means
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
64 is that I, or anyone else who can read this document and the accompanying
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
65 source for the listing/extraction utilities, can take a Mokopir-FFS image read
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
66 out of a device and see/extract its full content: the complete directory tree
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
67 and the exact binary byte content of all files contained therein.
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
68
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
69 However, the knowledge possessed by the present hacker (and conveyed in this
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
70 document and the accompanying source code) is NOT sufficient for constructing a
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
71 valid Mokopir-FFS image "in vitro" given a tree of directories and files, or
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
72 for making modifications to the file or directory content of an existing image
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
73 and producing a content-modified image that is also valid; valid as in suitable
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
74 for the original proprietary firmware to make its normal read and write
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
75 operations without noticing anything amiss.
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
76
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
77 Constructing "de novo" Mokopir-FFS images or modifying existing images in such
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
78 a way that they remain 100% valid for all read and write operations of the
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
79 original proprietary firmware would, at the very minimum, require an
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
80 understanding of the meaning of *all* fields of the on-media FFS format. Some
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
81 of these fields are still left as "non-understood" for now though: a read-only
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
82 implementation can get away with simply ignoring them, but a writer/generator
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
83 would have to put *something* in those fields.
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
84
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
85 As you read the "read-only" description of the Mokopir-FFS on-media format in
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
86 the remainder of this document, it should become fairly obvious which pieces
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
87 are missing before our understanding of this FFS can be elevated to a
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
88 "writable" level.
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
89
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
90 However, when it comes to writing new code to run on the two Calypso phones in
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
91 question (Closedmoko and Pirelli), it seems, at least to the present hacker,
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
92 that a read-only understanding of Mokopir-FFS should be sufficient:
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
93
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
94 * In the case of Closedmoko GTA0x modems, the FFS is seen to contain the IMEI
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
95 and the RF calibration data. The format of the former is obvious; the latter
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
96 not so much - but in any case, the information of interest is clearly of a
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
97 read-only nature. It's difficult to tell (or rather, I haven't bothered to
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
98 experiment enough) whether the Closedmoko firmware does any writes to FFS or
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
99 if the FFS is treated as read-only outside of the production line environment,
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
100 but in any case, it seems to me that for any 3rd party replacement firmware,
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
101 the best strategy would be to treat the FFS as a read-only source of IMEI and
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
102 RF calibration data, and nothing more.
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
103
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
104 * In the case of Pirelli phones, the FFS is used to store user data: sent and
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
105 received SMS (and MMS/email/whatever), call history, UI settings, pictures
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
106 taken with the camera, and whatever else. It also stores a ton of files
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
107 which I can only presume were meant to be immutable except at the time of
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
108 firmware updates: graphics for the UI, ringtones, i18n UI strings, and even
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
109 "helper" firmware images for the WiFi and VoIP processors. However, no IMEI
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
110 or RF calibration data are anywhere to be found in the FFS - instead this
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
111 information appears to be stored in the "factory block" at the end of the
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
112 flash (in its own sector) outside of the FFS.
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
113
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
114 Being able to parse FFS images extracted out of Pirelli phones "in vitro"
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
115 allows us to steal some of these helper files (UI artwork, ringtones,
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
116 WiFi/VoIP helpers), and some of these might even come useful to firmware
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
117 replacement projects, but it seems to me that a replacement firmware would
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
118 be better off using its own FFS design for storing user data, and as to
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
119 retrieving the original IMEI and RF calibration data, the original FFS isn't
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
120 of any use for that anyway.
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
121
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
122 =======================
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
123 Moko/Pirelli FFS format
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
124 =======================
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
125
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
126 OK, now that I'm done with the introduction, we can get to the actual
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
127 Mokopir-FFS format.
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
128
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
129 * On the GTA0x modem (or at least on my GTA02; my sample size is 1) the FFS
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
130 occupies 7 flash sectors of 64 KiB each at offsets 0x380000 through 0x3E0000,
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
131 inclusive.
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
132
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
133 (The 4 MiB NOR flash chip used by Closedmoko has an independent R/W bank
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
134 division between the first 3 MiB and the last 1 MiB. The first 3 MiB are used
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
135 to hold the field-flashable closed firmware images distributed as *.m0 files;
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
136 the independent last megabyte holds the FFS, and thus the FW could be
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
137 implemented to do FFS writes while running from flash in the main bank.
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
138 Less than half of that last megabyte appears to be used for the FFS though;
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
139 the rest appears to be unused - blank flash observed.)
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
140
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
141 * On the Pirelli the FFS occupies 18 sectors of 256 KiB each at offsets 0
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
142 through 0x440000 (inclusive) of the 2nd flash chip select, the one wired to
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
143 nCS3 on the Calypso.
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
144
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
145 Each flash sector allocated to FFS begins with the following signature:
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
146
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
147 00000000: 46 66 73 23 10 02 xx yy zz FF FF FF FF FF FF FF Ffs#............
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
148
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
149 The bytes shown as xx and yy above serve a non-understood purpose; as a guess,
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
150 they may hold some info for the flash wear leveling algorithm: in a "virgin"
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
151 FFS image like that found in my GTA02 (which never had a SIM card in it and
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
152 never made or received a call) or read out of a "virgin" Pirelli phone that
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
153 hasn't seen any active use yet, both of these bytes are FFs, but when I look at
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
154 FFS images read out of the Pirelli which I currently use as my everyday-use
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
155 cellphone, I see other values in sectors which must have been erased and
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
156 rewritten. A read-only implementation can ignore these bytes, as mine does.
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
157
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
158 The byte shown as zz is more important though, even to a read-only
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
159 implementation. The 3 values I've encountered in this byte so far are AB, BD
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
160 and BF. Per my current understanding, in a "healthy" FFS exactly one sector
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
161 will have AB in its header, exactly one will have BF, and the rest will have
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
162 BD. The meanings are (or appear to be):
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
163
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
164 AB: the sector holds a vital data structure which I have called the active
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
165 index block;
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
166 BD: the sector holds regular data;
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
167 BF: the sector is blank except for the header, can be turned into a new AB or
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
168 BD.
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
169
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
170 (Note that a flash program operation, which can turn 1s into 0s but not the
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
171 other way around, can turn BF into either AB or BD - but neither AB nor BD can
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
172 be turned into any other valid value.)
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
173
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
174 In a "virgin" FFS image (as explained above) the first FFS sector is AB, the
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
175 last one is BF, and the ones in between are BDs.
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
176
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
177 An FFS read operation (a search for a given pathname, or a listing of all
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
178 present directories and files) needs to start with locating the active index
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
179 block - the FFS sector with AB in the header. Following this header, which is
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
180 treated as being 16 bytes long (almost everything in Mokopir-FFS is aligned on
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
181 16-byte boundaries), the active index block contains a linear array of 16-byte
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
182 records, each record describing an FFS object: directory, file or file
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
183 continuation chunk.
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
184
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
185 Here is my current understanding of the 16-byte index block record structure:
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
186
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
187 2 bytes: Length of the described chunk in bytes
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
188 1 byte: Purpose/meaning not understood, ignored by my current code
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
189 1 byte: Object type
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
190 2 bytes: Descendant pointer
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
191 2 bytes: Sibling pointer
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
192 4 bytes: Data pointer
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
193 4 bytes: Purpose/meaning not understood, ignored by my current code
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
194
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
195 (On the Calypso phones of interest, all multibyte fields are in the native
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
196 little-endian byte order of the ARM7TDMI processor.)
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
197
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
198 The active index block gets filled with these records as objects are created;
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
199 the first record goes right after the 'Ffs#'...AB header (padded to 16 bytes);
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
200 the last record (at any given moment) is followed by blank flash for the
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
201 remainder of the sector. Records thus appear in the order in which they are
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
202 created, which bears no direct relation to the directory tree structure.
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
203
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
204 The objects, each described by a record in the index block, are organized into
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
205 a tree structure by the descendant and sibling pointers, plus the object type
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
206 indicator byte. Let's start with the latter; the following objtype byte values
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
207 have been observed:
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
208
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
209 00: deleted object - a read-only implementation should ignore everything except
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
210 the descendant and sibling pointers. (A write-capable implementation would
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
211 need more care - it would need a way of reclaiming dirty flash space taken
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
212 up by deleted/overwritten files.)
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
213
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
214 E1: a special file - see the description of the /.journal file further down
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
215 F1: a regular file (head chunk thereof)
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
216 F2: a directory
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
217 F4: file continuation chunk (explained below)
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
218
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
219 Each record in the index block has an associated chunk in one of the data
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
220 sectors; the index record contains fields giving the address and length of this
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
221 chunk. The length of a chunk is always a nonzero multiple of 16 bytes, and is
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
222 stored (as a number in bytes) in the first 16-bit field of the 16-byte index
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
223 entry. The address of each chunk is given by the data pointer field of the
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
224 index record, and it is reckoned in 16-byte units (thereby 16-byte alignment is
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
225 required) from the beginning of the FFS sector group in the flash address space.
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
226
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
227 For objects of type F1 and F2 (regular files and directories) the just-described
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
228 chunk begins with the name of the file or subdirectory as a NUL-terminated ASCII
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
229 string. This name is just for the current level of the directory tree, just
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
230 like in UNIX directories, thus one will have chunk names like gsm, l3, eplmn
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
231 etc, rather than /gsm/l3/eplmn. One practical effect is that one can't readily
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
232 see pathnames or any of the directory structure by looking at an FFS image as a
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
233 raw hex dump; the structure is only revealed when one uses a parsing program
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
234 like those which accompany this document.
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
235
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
236 In the case of directories, the "chunk" part of the object contains only the
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
237 name of the directory itself, padded with FFs to a 16-byte boundary. For
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
238 example, an FFS directory named /gsm would be represented by an object
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
239 consisting of two flash writes: a 16-byte entry in the active index block, with
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
240 the object type byte set to F2, and a corresponding 16-byte chunk in one of the
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
241 data sectors, with the 16 bytes containing "gsm", a terminating NUL byte, and
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
242 12 FF bytes to pad up to 16. In the case of files, this name may be followed
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
243 by the first chunk of file data content, as explained further down.
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
244
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
245 In order to parse the FFS directory tree (whether the objective is to dump the
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
246 whole thing recursively or to find a specific file given a pathname), one needs
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
247 to first (well, after finding the active AB block) find the root directory node.
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
248 The root directory object is similar to other directory objects: it has a type
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
249 of F2, and an associated chunk of 16 bytes in one of the data sectors. The
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
250 latter contains the name of the root node: on the Pirelli it is "/", whereas on
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
251 my GTA02 it is "/ffs-root".
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
252
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
253 The astute reader should notice that it really makes no sense to store a name
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
254 for the root node, and indeed, this name plays no part in the traversal of the
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
255 directory tree given an absolute pathname. But instead this name, or rather
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
256 its first character, appears to be used for the purpose of locating the root
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
257 node itself. At first I had assumed that the index record for the root node is
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
258 always the first record in the active index block right after the signature
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
259 header - that is how it is in "virgin" FFS images, and also in some quite non-
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
260 virgin ones I have pulled from my daily-use Pirelli. Naturally my first version
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
261 of the Mokopir-FFS (then called MysteryFFS) extraction utility expected the root
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
262 node to always be at index #1. But then I got some additional Pirelli phones,
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
263 and discovered that in certain cases, index record #1 is a deleted object (the
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
264 original root node which has been deleted), and the new active root node is
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
265 somewhere in the middle of the index!
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
266
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
267 Thus it appears that in order to find the active root node, one needs to scan
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
268 the active index block linearly from the beginning (disregarding the tree
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
269 structure pointers in this initial pass), looking for a non-deleted object of
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
270 type F2 (a directory) whose corresponding name chunk sports a name beginning
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
271 with the '/' character. (Anyone who's been raised in UNIX will immediately
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
272 know that the path separator character '/' is the only character other than NUL
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
273 that's absolutely forbidden in the individual filenames - so this special
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
274 "root node name" is the only case of a '/' character appearing in what would
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
275 otherwise be a regular filename.)
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
276
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
277 [What causes the root node to be somewhere other than at index #1? I assume it
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
278 has to do with the dirty space reclamation / data movement algorithm. In a
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
279 "virgin" FFS image the very first sector is the active index block, and the
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
280 following sector is the first to hold chunks, beginning with the name chunk of
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
281 the root node. Now what happens if all data in that sector aside from the
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
282 root node name and some other mostly-static directory names becomes dirty,
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
283 i.e., belonging to deleted or overwritten files? How would that flash space
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
284 get reclaimed? I assume that the FFS firmware algorithm moves all still-active
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
285 chunks to a new flash sector, invalidating the old copies - turning the latter
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
286 into deleted objects. The root node will be among them. Then at some point
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
287 the active index block is going to fill up too, and will need to be rewritten
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
288 into a new sector - at which point the previously-deleted index entries are
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
289 omitted and the root node becomes #1 again...]
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
290
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
291 Tree structure
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
292
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
293 Once the root node has been found, the descendant and sibling pointers are used
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
294 to traverse the tree structure. For each directory object, including the root
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
295 node, the descendant pointer points to the first child object of this directory:
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
296 the first file or subdirectory contained therein. (Descendant and sibling
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
297 pointers take the form of index numbers in the active index block. A "nil"
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
298 pointer is indicated by all 1s (FFFF) - the usual all-0s NULL pointer convention
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
299 couldn't be used because it's flash, where the blank state is all 1s.) If the
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
300 descendant pointer of a directory object is nil, that means an empty directory.
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
301 The sibling pointer of each file or directory points to its next sibling, i.e.,
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
302 the next member of the same parent directory. The sibling pointer of the root
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
303 node is nil.
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
304
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
305 Data content of files
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
306
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
307 Objects of type F1 are the head chunks of files. Each file has a head chunk,
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
308 and may or may not have continuation chunks. More precisely, the head chunk
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
309 may contain only the name (or viewed alternatively, 0 bytes of data), or it may
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
310 contain a nonzero number of payload bytes; orthogonally to this variability,
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
311 there may or may not be continuation chunk(s) present.
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
312
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
313 Continuation chunks
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
314
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
315 The descendant pointer of each file head object (the object of type F1, the one
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
316 reached by traversing the directory tree) indicates whether or not there are
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
317 any continuation chunks present. If this descendant pointer is nil, there are
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
318 no continuation chunks; otherwise it points to the first continuation chunk
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
319 object. File continuation objects have type F4, don't have any siblings (the
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
320 sibling pointer is nil - but see below regarding relocated chunks), and the
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
321 descendant pointer of each continuation object points to the next continuation
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
322 object, if there is one - nil otherwise.
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
323
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
324 Payload data delineation
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
325
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
326 Each chunk, whether head or continuation, always has a length that is a nonzero
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
327 multiple of 16 bytes. The length of the chunk here means the amount of flash
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
328 space it occupies in its data sector - which is NOT equal to the payload data
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
329 length.
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
330
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
331 The head chunk of each file begins with the filename, terminated by a NUL byte.
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
332 If there are any payload data bytes present in this head chunk (I'll explain
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
333 momentarily how you would tell), the byte immediately after the NUL that
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
334 terminates the filename is the first byte of the payload. In the case of a
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
335 continuation chunk, there is no filename and the first byte of the chunk is the
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
336 first byte of that chunk's portion of the user data payload.
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
337
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
338 Each data-containing chunk (head or continuation) has the following termination
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
339 after the last byte of that chunk's payload data: one byte of 00, followed by
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
340 however many bytes are needed ([0,15] range) of FFs to pad to a 16-byte
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
341 boundary. A file head chunk that has no payload data has the same format as a
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
342 directory name chunk: filename followed by its terminating NUL followed by
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
343 [0,15] bytes of FFs to pad to the next 16-byte boundary.
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
344
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
345 When working with a head chunk, find the beginning of possible payload data (1
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
346 byte after the filename terminating NUL) and find the end per the standard
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
347 termination logic: scanning from the end of the chunk, skip FFs until 00 is
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
348 found (encountering anything else is an error). If the head chunk has no data,
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
349 the effective data length (end_pointer - start_pointer) will be 0 or -1. (The
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
350 latter possibility is the most likely, as there will normally be a "shared" 00
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
351 byte, serving as both the filename terminator and the 00 before the padding
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
352 FF bytes.)
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
353
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
354 Relocated chunks
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
355
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
356 Let's go back to the scenario in which a particular data sector is full (no more
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
357 usable free space left) and contains a mixture of active and dirty (deleted or
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
358 invalidated) data. How does the dirty flash space get reclaimed, so that the
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
359 amount of available space (blank flash ready to hold new data) becomes equal to
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
360 the total FFS size minus the total size of active files and overhead? It can
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
361 only be done by relocating the still-active objects from the full sector to a
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
362 new one, invalidating the old copies, and once the old sector consists of
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
363 nothing but invalidated data, subjecting it to flash erasure.
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
364
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
365 So how do the active FFS objects get relocated from a "condemned" sector to a
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
366 new one? If the object is a directory, a new index entry is created, pointing
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
367 to the newly relocated name chunk, but it is then made to fit into the old tree
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
368 structure without disrupting the latter: the new index entry is added at the
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
369 tail of the sibling-chain of the parent directory's descendants, the old index
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
370 entry for the same directory is invalidated (as if the directory were rmdir'ed),
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
371 and the descendant pointer of the newly written index entry is set to a copy of
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
372 the descendant pointer from the old index entry for the same directory. The
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
373 same approach is used when the head chunk of a file needs to be relocated; in
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
374 both cases a read-only FFS implementation doesn't need to do anything special to
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
375 support reading file and directory objects that have been relocated in this
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
376 manner.
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
377
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
378 However, if the relocated object is a file continuation chunk, then the manner
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
379 in which such objects get relocated does affect file reading code. What if a
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
380 chunk in the middle of a chain linked by "descend" pointers needs to be moved?
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
381 What happens in this case is that the old copy of the chunk gets invalidated
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
382 (the object type byte turned to 00) like in the other object relocating cases,
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
383 and the sibling pointer of that old index entry (which was originally FFFF as
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
384 continuation objects have no siblings) is set to point to the new index entry
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
385 for the same chunk. The "descend" pointer in the new index entry is a copy of
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
386 that pointer from the old index entry.
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
387
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
388 The manner of chunk relocation just described has been observed in the FFS
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
389 images read out of my most recent batch of Pirelli phones - the same ones in
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
390 which the root directory object is not at index #1. Thinking about it as I
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
391 write this, I've realized that the way in which continuation objects get
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
392 relocated is exactly the same as for other object types - thus the compaction
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
393 code in the firmware doesn't need to examine what object type it is moving.
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
394 However, the case of continuation chunk relocation deserves special attention
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
395 because it affects a read-only implementation like ours - the utilities whose
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
396 source accompanies this document used to fail on these FFS images until I
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
397 implemented the following additional handling:
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
398
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
399 When following the chunk chain of a file, normally the only object type that's
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
400 expected is F4 - any other object type is an error. However, as a result of
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
401 chunk relocation, one can also encounter deleted objects, i.e., type == 00.
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
402 If such a deleted object is encountered, follow its sibling pointer, which must
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
403 be non-nil.
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
404
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
405 Journal file
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
406
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
407 Every Mokopir-FFS image I've seen so far contains a special file named
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
408 /.journal; this file is special in the following ways:
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
409
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
410 * The object type byte is E1 instead of F1;
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
411 * Unlike regular files, this special file is internally-writable.
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
412
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
413 What I mean by the above is that regular files are mostly immutable: once a
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
414 file has been created with some data content in the head chunk, it can only be
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
415 either appended to (one or more continuation chunks added), or overwritten by
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
416 creating a new file with the same name at the same level in the tree hierarchy
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
417 and invalidating the old one. But the special /.journal file is different: I
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
418 have never observed it to consist of more than the head chunk, and this head
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
419 chunk is pre-allocated with some largish and apparently fixed length (4 KiB on
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
420 my GTA02, 16 KiB on the Pirelli). This pre-allocated chunk contains what look
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
421 like 16-byte records at the beginning (on the first 4-byte boundary after the
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
422 NUL terminating the ".journal" name), followed by blank flash for the remainder
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
423 of the pre-allocated chunk - so it surely looks like new flash writes happen
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
424 within this chunk.
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
425
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
426 I do not currently know the purpose of this /.journal file or the meaning of the
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
427 records it seems to contain. This understanding would surely be needed if one
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
428 wanted to create FFS images from scratch or to implement FFS write operations,
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
429 but I reason that a read-only implementation can get away with simply ignoring
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
430 this file. I reason that this file can't be necessary in order to parse an FFS
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
431 image for reading because one needs to parse the tree structure first in order
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
432 to locate this journal file itself.
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
433
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
434 -------------------------------------------------------------------------------
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
435
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
436 That's all I can think of right now. If anything is unclear, see the
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
437 accompanying source code for the listing/extraction utilities: with the general
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
438 explanation given by this document, it should be clear what my code does and
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
439 why. And if a given piece of knowledge is found neither in this document nor
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
440 in my source code, then I don't know it myself either, and my read-only
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
441 Mokopir-FFS implementation makes do without it.
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
442
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
443 All knowledge contained herein has been recovered by reverse engineering.
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
444 Believe it or not, I have figured it out by staring at the hex dump of FFS
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
445 sectors, reasoning about how one could possibly implement an FFS given the
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
446 requirement of dynamic writability and the physical constraints of flash memory,
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
447 and writing listing/extraction test code iteratively until I got something that
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
448 appears to correctly parse all FFS images available to me - the result is the
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
449 code in this package.
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
450
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
451 I never got as far as attempting to locate the FFS implementation routines
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
452 within the proprietary firmware binary code images, and I haven't found an
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
453 implementation of this particular FFS in any of the leaked sources yet either.
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
454 The TSM30 code doesn't seem to be of any use as its FFS appears to be totally
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
455 different. As to the more recently found LoCosto code leak, I found that one a
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
456 few days *after* I got the Moko/Pirelli "MysteryFFS" reverse-engineered on my
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
457 own, and when I did look at the FFS in the LoCosto code later, I saw what seems
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
458 to be a different FFS as well.
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
459
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
460 Michael Spacefalcon
4eeab025b502 doc/TIFFS-old-description: the original description from SE 52 Mes 16
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
461 SE 52 Mes 16