1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
//! # sfs
//!
//! Implementation of the Simple File System (sfs).
//!
//! See [its official specification](https://web.archive.org/web/20170315134201/https://www.d-rift.nl/combuster/vdisk/sfs.html),
//! [FYSOS specification](https://www.fysnet.net/blog/files/sfs.pdf) for the version 1.10 and [its OSDev page](https://wiki.osdev.org/SFS).
//!
//! Two versions of SFS are available, with huge breaking changes between them: version 1.0 and version 1.10 (also
//! called version 1.A). Currently, only the version 1.0 is supported.
//!
//! ## Description
//!
//! The SFS structure is such like this:
//!
//! ```txt
//! +-----------------------------------------------------------+
//! | |
//! | Super-block | Fixed-size
//! | |
//! +-----------------------------------------------------------+
//! | |
//! | Reserved Area | Fixed-size
//! | |
//! +-----------------------------+-----------------------------+
//! | | |
//! | Data Area | |
//! | | v
//! +-----------------------------+-----------------------------+
//! | |
//! | Free Area |
//! | |
//! +-----------------------------+-----------------------------+
//! | | ^
//! | Index Area | |
//! | | |
//! +-----------------------------+-----------------------------+
//! ```
//!
//! ## SFS structures
//!
//! - The [`Device`] is splitted in contiguous blocks that have all the same size in bytes. This is **NOT** the block as
//! in block device, here "block" always refers to ext2's blocks. They start at 0, so the `n`th block will start at
//! the adress `n * block_size`.
//!
//! - The [`SuperBlock`] contains important metadata about the filesystem (size of blocks, size of areas, ...).
//!
//! - The Data Block Area is where all of the file data is stored. Each file starts at a specified block indicated in
//! the Index Data Area and is sequentially stored toward the end of the volume, block by block. Each file starts on a
//! block boundary.
//!
//! - The Index Area is where all of the file metadata is stored. This area holds a count of 64-byte entries holding
//! various formats of data for the file system.
//!
//! - The Free Area is the blocks between the Data Block Area and the Index Data Area. These blocks are free for use to
//! resize the Data Block Area, by adding blocks toward the end of the volume, or to resize the Index Data Area by
//! adding blocks toward the start of the volume.
//!
//! ## Formats
//!
//! ### Name strings
//!
//! All name strings used as part of the Simple File System use [UTF-8 format](https://www.rfc-editor.org/rfc/rfc3629),
//! according to the Unicode Specification published by the [Unicode Consortium](https://home.unicode.org).
//!
//! Contrary to POSIX paths (implemented in the [`path`](crate::path) module), some non-`\0` characters are forbidden in
//! SFS names. The exhaustive list of forbidden characters is the following:
//!
//! - Characters whose code is strictly below `0x20`
//!
//! - Characters whose code is included between `0x80` and `0x9F` (inclusive).
//!
//! - The following special characters: `"` (double quote, `0x22`), `*` (asterix, `0x2A`), `:` (colon, `0x3A`), `<`
//! (less than sign, `0x3C`), `>` (greater than sign, `0x3E`), `?` (question mark, `0x3F`), `\` (backward slash,
//! `0x5C`), `<DEL>` (delete, `0x7F`) and `<NBSP>` (no-break space, `0xA0`).
//!
//! In particular, the `/` character **is allowed** and is expected to be present in volume names as a directory
//! separator only. Thus, it is not allowed within a volume label.
//!
//! Moreover, all name strings are C-like, meaning they must be `\0`-terminating.
//!
//! ### Time stamps
//!
//! All time stamps are signed 64 bit values that represent the number of 1/65536ths of a second since the beginning of
//! the 1st of January 1970. For example, the value `0x00000000003C0000` would represent one minute past midnight on the
//! 1st of January 1970, while the value `0x0000000000000001` would represent roughly 15259 ns past midnight on the 1st
//! of January 1970. All time stamps are in UTC (Universal Co-ordinated Time) so that problems with time zones and
//! daylight savings are avoided.
use ;
use SfsError;
use Directory;
use ;
use ROOT_NAME_STRING;
use SuperBlock;
use FilesystemRead;
use FsError;
use crateCelled;
use crateDevice;
use crateError;
/// Interface to manipulate devices containing an SFS filesystem.
/// Main interface to manipulate a SFS filesystem.
;