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
//! ReFS checkpoint (`CHKP`) — the level-1 metadata block the superblock points
//! at, which in turn carries the pointers to the system tables (object table,
//! allocator/container tables).
//!
//! # The superblock → checkpoint chain
//!
//! The superblock (`SUPB`, level 0) sits at a fixed cluster and holds, after its
//! 80-byte metadata-block header, a 48-byte superblock structure whose
//! **checkpoint references data** names the checkpoint block(s). Byte-verified
//! against the real v3.14 volume:
//!
//! ```text
//! block+0x50 superblock struct (48 bytes):
//! +0x20 4 checkpoint references data offset (relative to the block)
//! +0x24 4 number of checkpoint block numbers
//! +0x28 4 self reference data offset
//! +0x2c 4 self reference data size
//! checkpoint references data @ block+<offset>: number-of-entries × u64
//! ```
//!
//! On the real minted volume the two checkpoint block numbers are
//! `[157156, 1885500]` — **virtual addresses** (they lie far beyond the
//! physical partition, which is sparse). Resolving a virtual block number to a
//! physical one requires the container table (a later phase); parsing the CHKP
//! block itself and extracting the object-table pointer is likewise deferred to
//! a later phase because the checkpoint block was not physically resident in the
//! available oracle slice. P1 provides the located checkpoint block numbers so
//! that resolution has an anchor.
use cratele_u32;
use cratele_u64;
use crateRefsError;
/// Length of the v3 metadata-block header preceding the superblock struct.
const V3_HEADER_LEN: usize = 80;
/// Offset of the superblock's "checkpoint references data offset" field, within
/// the superblock struct (which starts at `block + 0x50`).
const CHECKPOINT_REFS_OFFSET_FIELD: usize = V3_HEADER_LEN + 0x20;
/// Offset of the superblock's "number of checkpoint block numbers" field.
const CHECKPOINT_COUNT_FIELD: usize = V3_HEADER_LEN + 0x24;
/// A hard cap on the checkpoint-block-number count: even a maximal ReFS keeps a
/// tiny handful of checkpoints; a count beyond this is a hostile lie and is
/// clamped so a malformed superblock cannot drive an unbounded read.
const MAX_CHECKPOINTS: usize = 64;
/// The ReFS checkpoint.
///
/// P1 exposes the checkpoint *locations* named by the superblock; parsing the
/// `CHKP` block body (system-table pointers) is a later phase (the checkpoint
/// block is not physically resident in the current oracle slice).
;