1
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2
<!-- http://linux-ntfs.sourceforge.net/ntfs/concepts/fixup.html -->
6
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
7
<meta name="description" content="NTFS Documentation">
8
<link rel="stylesheet" type="text/css" href="../style/ntfsdoc.css">
9
<link rel="start" type="text/html" href="../index.html" title="NTFS Documentation">
10
<title>Fixup - Concept - NTFS Documentation</title>
14
<table border="0" class="toolbar" summary="" cellspacing="0">
16
<td class="toolbar"><a accesskey="1" class="toolbar" href="../index.html">Home</a></td>
17
<td class="toolbar"> </td>
18
<td class="toolbar"><a accesskey="2" class="toolbar" href="../files/index.html">Files</a></td>
19
<td class="toolbar"> </td>
20
<td class="toolbar"><a accesskey="3" class="toolbar" href="../attributes/index.html">Attributes</a></td>
21
<td class="toolbar"> </td>
22
<td class="toolbar"><a accesskey="4" class="toolbar" href="../concepts/index.html">Concepts</a></td>
23
<td class="toolbar"> </td>
24
<td class="toolbar"><a accesskey="5" class="toolbar" href="../help/glossary.html">Glossary</a></td>
25
<td class="toolbar"> </td>
26
<td class="toolbar"><a accesskey="6" class="toolbar" href="../help/index.html">Help</a></td>
30
<h1>Concept - Fixup</h1>
31
<a class="prevnext" accesskey="," href="filename_namespace.html">Previous</a>
32
<a class="prevnext" accesskey="." href="index_header.html">Next</a>
37
The smallest unit of disk space that NTFS uses is a
38
<a href="../help/glossary.html#cluster">Cluster</a>.
39
This can vary from one sector to 128 sectors, the usual
40
number is 8 (4KB). Naturally this is dependent on the
42
<a href="../help/glossary.html#cluster">Cluster</a>.
44
<a href="../files/boot.html">$Boot</a>.
48
Because a single sector could fail, it's important for NTFS
49
to be able to detect errors in a cluster. For this purpose
50
the sectors have <q>Fixups</q>, which are kept in an <q>Update
55
Many important Metadata Records use fixups to protect data integrity
59
<li><a href="file_record.html">FILE Records in the $MFT</a></li>
60
<li><a href="index_header.html">INDX Records in directories and other indexes</a></li>
61
<li><a href="../files/logfile.html">RCRD Records in the $LogFile</a></li>
62
<li><a href="restart.html">RSTR Records in the $LogFile</a></li>
65
<h2>What Does It Do?</h2>
68
The header of each of these records contains a Update Sequence
69
Number and a buffer. The last two bytes of each sector of the
70
record are copied into the buffer and the Update Sequence Number
71
is written in their place.
75
When the record is read, the Update Sequence Number is read from
76
the header and compared against the last two bytes of each sector.
77
If it succeeds, then it copies the bytes in the buffer back to
78
their original places.
84
Here's an example before the fixup is applied,
85
with a cluster size of 2KB (4 Sectors).
88
<table border="1" summary="" cellspacing="0">
90
<th class="numeric">Offset</th>
91
<th colspan="8">Data</th>
95
<td class="numeric">0x0000</td>
96
<td colspan="8">...</td>
100
<td class="numeric">0x0028</td>
101
<td class="numeric">CD</td>
102
<td class="numeric">AB</td>
103
<td class="numeric" colspan="6"> </td>
104
<td>Update Sequence Number</td>
107
<td class="numeric">0x002A</td>
108
<td class="numeric">00</td>
109
<td class="numeric">00</td>
110
<td class="numeric">00</td>
111
<td class="numeric">00</td>
112
<td class="numeric">00</td>
113
<td class="numeric">00</td>
114
<td class="numeric">00</td>
115
<td class="numeric">00</td>
116
<td>Update Sequence Array</td>
120
<td colspan="8">...</td>
124
<td class="numeric">0x01F8</td>
125
<td class="numeric">11</td>
126
<td class="numeric">12</td>
127
<td class="numeric">13</td>
128
<td class="numeric">14</td>
129
<td class="numeric">15</td>
130
<td class="numeric">16</td>
131
<td class="numeric">17</td>
132
<td class="numeric">18</td>
133
<td>End of Sector 1</td>
137
<td colspan="8">...</td>
141
<td class="numeric">0x03F8</td>
142
<td class="numeric">21</td>
143
<td class="numeric">22</td>
144
<td class="numeric">23</td>
145
<td class="numeric">24</td>
146
<td class="numeric">25</td>
147
<td class="numeric">26</td>
148
<td class="numeric">27</td>
149
<td class="numeric">28</td>
150
<td>End of Sector 2</td>
154
<td colspan="8">...</td>
158
<td class="numeric">0x05F8</td>
159
<td class="numeric">31</td>
160
<td class="numeric">32</td>
161
<td class="numeric">33</td>
162
<td class="numeric">34</td>
163
<td class="numeric">35</td>
164
<td class="numeric">36</td>
165
<td class="numeric">37</td>
166
<td class="numeric">38</td>
167
<td>End of Sector 3</td>
171
<td colspan="8">...</td>
175
<td class="numeric">0x07F8</td>
176
<td class="numeric">41</td>
177
<td class="numeric">42</td>
178
<td class="numeric">43</td>
179
<td class="numeric">44</td>
180
<td class="numeric">45</td>
181
<td class="numeric">46</td>
182
<td class="numeric">47</td>
183
<td class="numeric">48</td>
184
<td>End of Sector 4</td>
189
Here the Update Sequence Number is 0xABCD and the
190
Update Sequence Array is still empty.
193
<table border="1" summary="" cellspacing="0">
195
<th class="numeric">Offset</th>
196
<th colspan="8">Data</th>
200
<td class="numeric">0x0000</td>
201
<td colspan="8">...</td>
205
<td class="numeric">0x0028</td>
206
<td class="numeric">CD</td>
207
<td class="numeric">AB</td>
208
<td class="numeric" colspan="6"> </td>
209
<td>Update Sequence Number</td>
212
<td class="numeric">0x002A</td>
213
<td class="numeric">17</td>
214
<td class="numeric">18</td>
215
<td class="numeric">27</td>
216
<td class="numeric">28</td>
217
<td class="numeric">37</td>
218
<td class="numeric">38</td>
219
<td class="numeric">47</td>
220
<td class="numeric">48</td>
221
<td>Update Sequence Array</td>
225
<td colspan="8">...</td>
229
<td class="numeric">0x01F8</td>
230
<td class="numeric">11</td>
231
<td class="numeric">12</td>
232
<td class="numeric">13</td>
233
<td class="numeric">14</td>
234
<td class="numeric">15</td>
235
<td class="numeric">16</td>
236
<td class="numeric">CD</td>
237
<td class="numeric">AB</td>
238
<td>End of Sector 1</td>
242
<td colspan="8">...</td>
246
<td class="numeric">0x03F8</td>
247
<td class="numeric">21</td>
248
<td class="numeric">22</td>
249
<td class="numeric">23</td>
250
<td class="numeric">24</td>
251
<td class="numeric">25</td>
252
<td class="numeric">26</td>
253
<td class="numeric">CD</td>
254
<td class="numeric">AB</td>
255
<td>End of Sector 2</td>
259
<td colspan="8">...</td>
263
<td class="numeric">0x05F8</td>
264
<td class="numeric">31</td>
265
<td class="numeric">32</td>
266
<td class="numeric">33</td>
267
<td class="numeric">34</td>
268
<td class="numeric">35</td>
269
<td class="numeric">36</td>
270
<td class="numeric">CD</td>
271
<td class="numeric">AB</td>
272
<td>End of Sector 3</td>
276
<td colspan="8">...</td>
280
<td class="numeric">0x07F8</td>
281
<td class="numeric">41</td>
282
<td class="numeric">42</td>
283
<td class="numeric">43</td>
284
<td class="numeric">44</td>
285
<td class="numeric">45</td>
286
<td class="numeric">46</td>
287
<td class="numeric">CD</td>
288
<td class="numeric">AB</td>
289
<td>End of Sector 4</td>
294
The last two bytes of each sector have been copied into
295
the Update Sequence Array, and the Update Sequence Number
296
has been written over the last two bytes of each sector.
304
Before writing a fixup-protected record:
308
<li>Add one to the Update Sequence Number (0x0000 must be skipped)</li>
309
<li>For each sector, copy the last two bytes into the Update Sequence Array</li>
310
<li>Write the new Update Sequence Number to the end of each sector</li>
311
<li>Write the record to disk</li>
317
When reading a fixup-protected record:
321
<li>Read the record from disk</li>
322
<li>Check the magic number is correct</li>
323
<li>Read the Update Sequence Number</li>
324
<li>Compare it against the last two bytes of every sector</li>
325
<li>Copy the contents of the Update Sequence Array to the correct places</li>
329
If any of the checks fail when reading, it could mean there is:
330
a bad sector, disk corruption or a fault in the driver.
334
<a class="contact" href="http://linux-ntfs.sourceforge.net/ntfs/concepts/fixup.html">Online</a>
335
<!-- The two validators will only work if this page is visible on the web -->
336
<a class="contact" href="http://validator.w3.org/check/referer">Validate HTML</a>
337
<a class="contact" href="http://jigsaw.w3.org/css-validator/check/referer">Validate CSS</a>
338
<a class="contact" href="mailto:webmaster@flatcap.org">$Id: fixup.html,v 1.11 2001/07/11 17:09:23 flatcap Exp $</a>