~ubuntu-branches/ubuntu/gutsy/ntfsdoc/gutsy

« back to all changes in this revision

Viewing changes to concepts/fixup.html

  • Committer: Bazaar Package Importer
  • Author(s): David Martínez Moreno
  • Date: 2002-01-12 03:35:17 UTC
  • Revision ID: james.westby@ubuntu.com-20020112033517-tspnkaz5z9o0y6b2
Tags: upstream-0.4
Import upstream version 0.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 
2
<!-- http://linux-ntfs.sourceforge.net/ntfs/concepts/fixup.html -->
 
3
 
 
4
<html lang="en">
 
5
  <head>
 
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>
 
11
  </head>
 
12
 
 
13
  <body>
 
14
    <table border="0" class="toolbar" summary="" cellspacing="0">
 
15
      <tr>
 
16
        <td class="toolbar"><a accesskey="1" class="toolbar" href="../index.html">Home</a></td>
 
17
        <td class="toolbar">&nbsp;</td>
 
18
        <td class="toolbar"><a accesskey="2" class="toolbar" href="../files/index.html">Files</a></td>
 
19
        <td class="toolbar">&nbsp;</td>
 
20
        <td class="toolbar"><a accesskey="3" class="toolbar" href="../attributes/index.html">Attributes</a></td>
 
21
        <td class="toolbar">&nbsp;</td>
 
22
        <td class="toolbar"><a accesskey="4" class="toolbar" href="../concepts/index.html">Concepts</a></td>
 
23
        <td class="toolbar">&nbsp;</td>
 
24
        <td class="toolbar"><a accesskey="5" class="toolbar" href="../help/glossary.html">Glossary</a></td>
 
25
        <td class="toolbar">&nbsp;</td>
 
26
        <td class="toolbar"><a accesskey="6" class="toolbar" href="../help/index.html">Help</a></td>
 
27
      </tr>
 
28
    </table>
 
29
 
 
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>
 
33
 
 
34
    <h2>Overview</h2>
 
35
 
 
36
    <p>
 
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
 
41
    sector and
 
42
    <a href="../help/glossary.html#cluster">Cluster</a>.
 
43
    sizes declared in
 
44
    <a href="../files/boot.html">$Boot</a>.
 
45
    </p>
 
46
 
 
47
    <p>
 
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
 
51
    Sequence Array</q>.
 
52
    </p>
 
53
 
 
54
    <p>
 
55
    Many important Metadata Records use fixups to protect data integrity
 
56
    </p>
 
57
 
 
58
    <ul>
 
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>
 
63
    </ul>
 
64
 
 
65
    <h2>What Does It Do?</h2>
 
66
 
 
67
    <p>
 
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.
 
72
    </p>
 
73
 
 
74
    <p>
 
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.
 
79
    </p>
 
80
 
 
81
    <h2>Example</h2>
 
82
 
 
83
    <p>
 
84
    Here's an example before the fixup is applied,
 
85
    with a cluster size of 2KB (4 Sectors).
 
86
    </p>
 
87
 
 
88
    <table border="1" summary="" cellspacing="0">
 
89
      <tr>
 
90
        <th class="numeric">Offset</th>
 
91
        <th colspan="8">Data</th>
 
92
        <th>Description</th>
 
93
      </tr>
 
94
      <tr>
 
95
        <td class="numeric">0x0000</td>
 
96
        <td colspan="8">...</td>
 
97
        <td>Header</td>
 
98
      </tr>
 
99
      <tr>
 
100
        <td class="numeric">0x0028</td>
 
101
        <td class="numeric">CD</td>
 
102
        <td class="numeric">AB</td>
 
103
        <td class="numeric" colspan="6">&nbsp;</td>
 
104
        <td>Update Sequence Number</td>
 
105
      </tr>
 
106
      <tr>
 
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>
 
117
      </tr>
 
118
      <tr>
 
119
        <td>...</td>
 
120
        <td colspan="8">...</td>
 
121
        <td>&nbsp;</td>
 
122
      </tr>
 
123
      <tr>
 
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>
 
134
      </tr>
 
135
      <tr>
 
136
        <td>...</td>
 
137
        <td colspan="8">...</td>
 
138
        <td>&nbsp;</td>
 
139
      </tr>
 
140
      <tr>
 
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>
 
151
      </tr>
 
152
      <tr>
 
153
        <td>...</td>
 
154
        <td colspan="8">...</td>
 
155
        <td>&nbsp;</td>
 
156
      </tr>
 
157
      <tr>
 
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>
 
168
      </tr>
 
169
      <tr>
 
170
        <td>...</td>
 
171
        <td colspan="8">...</td>
 
172
        <td>&nbsp;</td>
 
173
      </tr>
 
174
      <tr>
 
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>
 
185
      </tr>
 
186
    </table>
 
187
 
 
188
    <p>
 
189
    Here the Update Sequence Number is 0xABCD and the
 
190
    Update Sequence Array is still empty.
 
191
    </p>
 
192
 
 
193
    <table border="1" summary="" cellspacing="0">
 
194
      <tr>
 
195
        <th class="numeric">Offset</th>
 
196
        <th colspan="8">Data</th>
 
197
        <th>Description</th>
 
198
      </tr>
 
199
      <tr>
 
200
        <td class="numeric">0x0000</td>
 
201
        <td colspan="8">...</td>
 
202
        <td>Header</td>
 
203
      </tr>
 
204
      <tr>
 
205
        <td class="numeric">0x0028</td>
 
206
        <td class="numeric">CD</td>
 
207
        <td class="numeric">AB</td>
 
208
        <td class="numeric" colspan="6">&nbsp;</td>
 
209
        <td>Update Sequence Number</td>
 
210
      </tr>
 
211
      <tr>
 
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>
 
222
      </tr>
 
223
      <tr>
 
224
        <td>...</td>
 
225
        <td colspan="8">...</td>
 
226
        <td>&nbsp;</td>
 
227
      </tr>
 
228
      <tr>
 
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>
 
239
      </tr>
 
240
      <tr>
 
241
        <td>...</td>
 
242
        <td colspan="8">...</td>
 
243
        <td>&nbsp;</td>
 
244
      </tr>
 
245
      <tr>
 
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>
 
256
      </tr>
 
257
      <tr>
 
258
        <td>...</td>
 
259
        <td colspan="8">...</td>
 
260
        <td>&nbsp;</td>
 
261
      </tr>
 
262
      <tr>
 
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>
 
273
      </tr>
 
274
      <tr>
 
275
        <td>...</td>
 
276
        <td colspan="8">...</td>
 
277
        <td>&nbsp;</td>
 
278
      </tr>
 
279
      <tr>
 
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>
 
290
      </tr>
 
291
    </table>
 
292
 
 
293
    <p>
 
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.
 
297
    </p>
 
298
 
 
299
    <h2>The Details</h2>
 
300
 
 
301
    <h3>Writing</h3>
 
302
 
 
303
    <p>
 
304
    Before writing a fixup-protected record:
 
305
    </p>
 
306
 
 
307
    <ol>
 
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>
 
312
    </ol>
 
313
 
 
314
    <h3>Reading</h3>
 
315
 
 
316
    <p>
 
317
    When reading a fixup-protected record:
 
318
    </p>
 
319
 
 
320
    <ol>
 
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>
 
326
    </ol>
 
327
 
 
328
    <p>
 
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.
 
331
    </p>
 
332
 
 
333
    <br>
 
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>
 
339
  </body>
 
340
</html>
 
341