Codebase list dosfstools / 9fdcef6
Imported Upstream version 3.0.26 Andreas Bombe 9 years ago
50 changed file(s) with 12230 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 *.o
1 /fatlabel
2 /fsck.fat
3 /mkfs.fat
0 GNU GENERAL PUBLIC LICENSE
1 Version 3, 29 June 2007
2
3 Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
4 Everyone is permitted to copy and distribute verbatim copies
5 of this license document, but changing it is not allowed.
6
7 Preamble
8
9 The GNU General Public License is a free, copyleft license for
10 software and other kinds of works.
11
12 The licenses for most software and other practical works are designed
13 to take away your freedom to share and change the works. By contrast,
14 the GNU General Public License is intended to guarantee your freedom to
15 share and change all versions of a program--to make sure it remains free
16 software for all its users. We, the Free Software Foundation, use the
17 GNU General Public License for most of our software; it applies also to
18 any other work released this way by its authors. You can apply it to
19 your programs, too.
20
21 When we speak of free software, we are referring to freedom, not
22 price. Our General Public Licenses are designed to make sure that you
23 have the freedom to distribute copies of free software (and charge for
24 them if you wish), that you receive source code or can get it if you
25 want it, that you can change the software or use pieces of it in new
26 free programs, and that you know you can do these things.
27
28 To protect your rights, we need to prevent others from denying you
29 these rights or asking you to surrender the rights. Therefore, you have
30 certain responsibilities if you distribute copies of the software, or if
31 you modify it: responsibilities to respect the freedom of others.
32
33 For example, if you distribute copies of such a program, whether
34 gratis or for a fee, you must pass on to the recipients the same
35 freedoms that you received. You must make sure that they, too, receive
36 or can get the source code. And you must show them these terms so they
37 know their rights.
38
39 Developers that use the GNU GPL protect your rights with two steps:
40 (1) assert copyright on the software, and (2) offer you this License
41 giving you legal permission to copy, distribute and/or modify it.
42
43 For the developers' and authors' protection, the GPL clearly explains
44 that there is no warranty for this free software. For both users' and
45 authors' sake, the GPL requires that modified versions be marked as
46 changed, so that their problems will not be attributed erroneously to
47 authors of previous versions.
48
49 Some devices are designed to deny users access to install or run
50 modified versions of the software inside them, although the manufacturer
51 can do so. This is fundamentally incompatible with the aim of
52 protecting users' freedom to change the software. The systematic
53 pattern of such abuse occurs in the area of products for individuals to
54 use, which is precisely where it is most unacceptable. Therefore, we
55 have designed this version of the GPL to prohibit the practice for those
56 products. If such problems arise substantially in other domains, we
57 stand ready to extend this provision to those domains in future versions
58 of the GPL, as needed to protect the freedom of users.
59
60 Finally, every program is threatened constantly by software patents.
61 States should not allow patents to restrict development and use of
62 software on general-purpose computers, but in those that do, we wish to
63 avoid the special danger that patents applied to a free program could
64 make it effectively proprietary. To prevent this, the GPL assures that
65 patents cannot be used to render the program non-free.
66
67 The precise terms and conditions for copying, distribution and
68 modification follow.
69
70 TERMS AND CONDITIONS
71
72 0. Definitions.
73
74 "This License" refers to version 3 of the GNU General Public License.
75
76 "Copyright" also means copyright-like laws that apply to other kinds of
77 works, such as semiconductor masks.
78
79 "The Program" refers to any copyrightable work licensed under this
80 License. Each licensee is addressed as "you". "Licensees" and
81 "recipients" may be individuals or organizations.
82
83 To "modify" a work means to copy from or adapt all or part of the work
84 in a fashion requiring copyright permission, other than the making of an
85 exact copy. The resulting work is called a "modified version" of the
86 earlier work or a work "based on" the earlier work.
87
88 A "covered work" means either the unmodified Program or a work based
89 on the Program.
90
91 To "propagate" a work means to do anything with it that, without
92 permission, would make you directly or secondarily liable for
93 infringement under applicable copyright law, except executing it on a
94 computer or modifying a private copy. Propagation includes copying,
95 distribution (with or without modification), making available to the
96 public, and in some countries other activities as well.
97
98 To "convey" a work means any kind of propagation that enables other
99 parties to make or receive copies. Mere interaction with a user through
100 a computer network, with no transfer of a copy, is not conveying.
101
102 An interactive user interface displays "Appropriate Legal Notices"
103 to the extent that it includes a convenient and prominently visible
104 feature that (1) displays an appropriate copyright notice, and (2)
105 tells the user that there is no warranty for the work (except to the
106 extent that warranties are provided), that licensees may convey the
107 work under this License, and how to view a copy of this License. If
108 the interface presents a list of user commands or options, such as a
109 menu, a prominent item in the list meets this criterion.
110
111 1. Source Code.
112
113 The "source code" for a work means the preferred form of the work
114 for making modifications to it. "Object code" means any non-source
115 form of a work.
116
117 A "Standard Interface" means an interface that either is an official
118 standard defined by a recognized standards body, or, in the case of
119 interfaces specified for a particular programming language, one that
120 is widely used among developers working in that language.
121
122 The "System Libraries" of an executable work include anything, other
123 than the work as a whole, that (a) is included in the normal form of
124 packaging a Major Component, but which is not part of that Major
125 Component, and (b) serves only to enable use of the work with that
126 Major Component, or to implement a Standard Interface for which an
127 implementation is available to the public in source code form. A
128 "Major Component", in this context, means a major essential component
129 (kernel, window system, and so on) of the specific operating system
130 (if any) on which the executable work runs, or a compiler used to
131 produce the work, or an object code interpreter used to run it.
132
133 The "Corresponding Source" for a work in object code form means all
134 the source code needed to generate, install, and (for an executable
135 work) run the object code and to modify the work, including scripts to
136 control those activities. However, it does not include the work's
137 System Libraries, or general-purpose tools or generally available free
138 programs which are used unmodified in performing those activities but
139 which are not part of the work. For example, Corresponding Source
140 includes interface definition files associated with source files for
141 the work, and the source code for shared libraries and dynamically
142 linked subprograms that the work is specifically designed to require,
143 such as by intimate data communication or control flow between those
144 subprograms and other parts of the work.
145
146 The Corresponding Source need not include anything that users
147 can regenerate automatically from other parts of the Corresponding
148 Source.
149
150 The Corresponding Source for a work in source code form is that
151 same work.
152
153 2. Basic Permissions.
154
155 All rights granted under this License are granted for the term of
156 copyright on the Program, and are irrevocable provided the stated
157 conditions are met. This License explicitly affirms your unlimited
158 permission to run the unmodified Program. The output from running a
159 covered work is covered by this License only if the output, given its
160 content, constitutes a covered work. This License acknowledges your
161 rights of fair use or other equivalent, as provided by copyright law.
162
163 You may make, run and propagate covered works that you do not
164 convey, without conditions so long as your license otherwise remains
165 in force. You may convey covered works to others for the sole purpose
166 of having them make modifications exclusively for you, or provide you
167 with facilities for running those works, provided that you comply with
168 the terms of this License in conveying all material for which you do
169 not control copyright. Those thus making or running the covered works
170 for you must do so exclusively on your behalf, under your direction
171 and control, on terms that prohibit them from making any copies of
172 your copyrighted material outside their relationship with you.
173
174 Conveying under any other circumstances is permitted solely under
175 the conditions stated below. Sublicensing is not allowed; section 10
176 makes it unnecessary.
177
178 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
179
180 No covered work shall be deemed part of an effective technological
181 measure under any applicable law fulfilling obligations under article
182 11 of the WIPO copyright treaty adopted on 20 December 1996, or
183 similar laws prohibiting or restricting circumvention of such
184 measures.
185
186 When you convey a covered work, you waive any legal power to forbid
187 circumvention of technological measures to the extent such circumvention
188 is effected by exercising rights under this License with respect to
189 the covered work, and you disclaim any intention to limit operation or
190 modification of the work as a means of enforcing, against the work's
191 users, your or third parties' legal rights to forbid circumvention of
192 technological measures.
193
194 4. Conveying Verbatim Copies.
195
196 You may convey verbatim copies of the Program's source code as you
197 receive it, in any medium, provided that you conspicuously and
198 appropriately publish on each copy an appropriate copyright notice;
199 keep intact all notices stating that this License and any
200 non-permissive terms added in accord with section 7 apply to the code;
201 keep intact all notices of the absence of any warranty; and give all
202 recipients a copy of this License along with the Program.
203
204 You may charge any price or no price for each copy that you convey,
205 and you may offer support or warranty protection for a fee.
206
207 5. Conveying Modified Source Versions.
208
209 You may convey a work based on the Program, or the modifications to
210 produce it from the Program, in the form of source code under the
211 terms of section 4, provided that you also meet all of these conditions:
212
213 a) The work must carry prominent notices stating that you modified
214 it, and giving a relevant date.
215
216 b) The work must carry prominent notices stating that it is
217 released under this License and any conditions added under section
218 7. This requirement modifies the requirement in section 4 to
219 "keep intact all notices".
220
221 c) You must license the entire work, as a whole, under this
222 License to anyone who comes into possession of a copy. This
223 License will therefore apply, along with any applicable section 7
224 additional terms, to the whole of the work, and all its parts,
225 regardless of how they are packaged. This License gives no
226 permission to license the work in any other way, but it does not
227 invalidate such permission if you have separately received it.
228
229 d) If the work has interactive user interfaces, each must display
230 Appropriate Legal Notices; however, if the Program has interactive
231 interfaces that do not display Appropriate Legal Notices, your
232 work need not make them do so.
233
234 A compilation of a covered work with other separate and independent
235 works, which are not by their nature extensions of the covered work,
236 and which are not combined with it such as to form a larger program,
237 in or on a volume of a storage or distribution medium, is called an
238 "aggregate" if the compilation and its resulting copyright are not
239 used to limit the access or legal rights of the compilation's users
240 beyond what the individual works permit. Inclusion of a covered work
241 in an aggregate does not cause this License to apply to the other
242 parts of the aggregate.
243
244 6. Conveying Non-Source Forms.
245
246 You may convey a covered work in object code form under the terms
247 of sections 4 and 5, provided that you also convey the
248 machine-readable Corresponding Source under the terms of this License,
249 in one of these ways:
250
251 a) Convey the object code in, or embodied in, a physical product
252 (including a physical distribution medium), accompanied by the
253 Corresponding Source fixed on a durable physical medium
254 customarily used for software interchange.
255
256 b) Convey the object code in, or embodied in, a physical product
257 (including a physical distribution medium), accompanied by a
258 written offer, valid for at least three years and valid for as
259 long as you offer spare parts or customer support for that product
260 model, to give anyone who possesses the object code either (1) a
261 copy of the Corresponding Source for all the software in the
262 product that is covered by this License, on a durable physical
263 medium customarily used for software interchange, for a price no
264 more than your reasonable cost of physically performing this
265 conveying of source, or (2) access to copy the
266 Corresponding Source from a network server at no charge.
267
268 c) Convey individual copies of the object code with a copy of the
269 written offer to provide the Corresponding Source. This
270 alternative is allowed only occasionally and noncommercially, and
271 only if you received the object code with such an offer, in accord
272 with subsection 6b.
273
274 d) Convey the object code by offering access from a designated
275 place (gratis or for a charge), and offer equivalent access to the
276 Corresponding Source in the same way through the same place at no
277 further charge. You need not require recipients to copy the
278 Corresponding Source along with the object code. If the place to
279 copy the object code is a network server, the Corresponding Source
280 may be on a different server (operated by you or a third party)
281 that supports equivalent copying facilities, provided you maintain
282 clear directions next to the object code saying where to find the
283 Corresponding Source. Regardless of what server hosts the
284 Corresponding Source, you remain obligated to ensure that it is
285 available for as long as needed to satisfy these requirements.
286
287 e) Convey the object code using peer-to-peer transmission, provided
288 you inform other peers where the object code and Corresponding
289 Source of the work are being offered to the general public at no
290 charge under subsection 6d.
291
292 A separable portion of the object code, whose source code is excluded
293 from the Corresponding Source as a System Library, need not be
294 included in conveying the object code work.
295
296 A "User Product" is either (1) a "consumer product", which means any
297 tangible personal property which is normally used for personal, family,
298 or household purposes, or (2) anything designed or sold for incorporation
299 into a dwelling. In determining whether a product is a consumer product,
300 doubtful cases shall be resolved in favor of coverage. For a particular
301 product received by a particular user, "normally used" refers to a
302 typical or common use of that class of product, regardless of the status
303 of the particular user or of the way in which the particular user
304 actually uses, or expects or is expected to use, the product. A product
305 is a consumer product regardless of whether the product has substantial
306 commercial, industrial or non-consumer uses, unless such uses represent
307 the only significant mode of use of the product.
308
309 "Installation Information" for a User Product means any methods,
310 procedures, authorization keys, or other information required to install
311 and execute modified versions of a covered work in that User Product from
312 a modified version of its Corresponding Source. The information must
313 suffice to ensure that the continued functioning of the modified object
314 code is in no case prevented or interfered with solely because
315 modification has been made.
316
317 If you convey an object code work under this section in, or with, or
318 specifically for use in, a User Product, and the conveying occurs as
319 part of a transaction in which the right of possession and use of the
320 User Product is transferred to the recipient in perpetuity or for a
321 fixed term (regardless of how the transaction is characterized), the
322 Corresponding Source conveyed under this section must be accompanied
323 by the Installation Information. But this requirement does not apply
324 if neither you nor any third party retains the ability to install
325 modified object code on the User Product (for example, the work has
326 been installed in ROM).
327
328 The requirement to provide Installation Information does not include a
329 requirement to continue to provide support service, warranty, or updates
330 for a work that has been modified or installed by the recipient, or for
331 the User Product in which it has been modified or installed. Access to a
332 network may be denied when the modification itself materially and
333 adversely affects the operation of the network or violates the rules and
334 protocols for communication across the network.
335
336 Corresponding Source conveyed, and Installation Information provided,
337 in accord with this section must be in a format that is publicly
338 documented (and with an implementation available to the public in
339 source code form), and must require no special password or key for
340 unpacking, reading or copying.
341
342 7. Additional Terms.
343
344 "Additional permissions" are terms that supplement the terms of this
345 License by making exceptions from one or more of its conditions.
346 Additional permissions that are applicable to the entire Program shall
347 be treated as though they were included in this License, to the extent
348 that they are valid under applicable law. If additional permissions
349 apply only to part of the Program, that part may be used separately
350 under those permissions, but the entire Program remains governed by
351 this License without regard to the additional permissions.
352
353 When you convey a copy of a covered work, you may at your option
354 remove any additional permissions from that copy, or from any part of
355 it. (Additional permissions may be written to require their own
356 removal in certain cases when you modify the work.) You may place
357 additional permissions on material, added by you to a covered work,
358 for which you have or can give appropriate copyright permission.
359
360 Notwithstanding any other provision of this License, for material you
361 add to a covered work, you may (if authorized by the copyright holders of
362 that material) supplement the terms of this License with terms:
363
364 a) Disclaiming warranty or limiting liability differently from the
365 terms of sections 15 and 16 of this License; or
366
367 b) Requiring preservation of specified reasonable legal notices or
368 author attributions in that material or in the Appropriate Legal
369 Notices displayed by works containing it; or
370
371 c) Prohibiting misrepresentation of the origin of that material, or
372 requiring that modified versions of such material be marked in
373 reasonable ways as different from the original version; or
374
375 d) Limiting the use for publicity purposes of names of licensors or
376 authors of the material; or
377
378 e) Declining to grant rights under trademark law for use of some
379 trade names, trademarks, or service marks; or
380
381 f) Requiring indemnification of licensors and authors of that
382 material by anyone who conveys the material (or modified versions of
383 it) with contractual assumptions of liability to the recipient, for
384 any liability that these contractual assumptions directly impose on
385 those licensors and authors.
386
387 All other non-permissive additional terms are considered "further
388 restrictions" within the meaning of section 10. If the Program as you
389 received it, or any part of it, contains a notice stating that it is
390 governed by this License along with a term that is a further
391 restriction, you may remove that term. If a license document contains
392 a further restriction but permits relicensing or conveying under this
393 License, you may add to a covered work material governed by the terms
394 of that license document, provided that the further restriction does
395 not survive such relicensing or conveying.
396
397 If you add terms to a covered work in accord with this section, you
398 must place, in the relevant source files, a statement of the
399 additional terms that apply to those files, or a notice indicating
400 where to find the applicable terms.
401
402 Additional terms, permissive or non-permissive, may be stated in the
403 form of a separately written license, or stated as exceptions;
404 the above requirements apply either way.
405
406 8. Termination.
407
408 You may not propagate or modify a covered work except as expressly
409 provided under this License. Any attempt otherwise to propagate or
410 modify it is void, and will automatically terminate your rights under
411 this License (including any patent licenses granted under the third
412 paragraph of section 11).
413
414 However, if you cease all violation of this License, then your
415 license from a particular copyright holder is reinstated (a)
416 provisionally, unless and until the copyright holder explicitly and
417 finally terminates your license, and (b) permanently, if the copyright
418 holder fails to notify you of the violation by some reasonable means
419 prior to 60 days after the cessation.
420
421 Moreover, your license from a particular copyright holder is
422 reinstated permanently if the copyright holder notifies you of the
423 violation by some reasonable means, this is the first time you have
424 received notice of violation of this License (for any work) from that
425 copyright holder, and you cure the violation prior to 30 days after
426 your receipt of the notice.
427
428 Termination of your rights under this section does not terminate the
429 licenses of parties who have received copies or rights from you under
430 this License. If your rights have been terminated and not permanently
431 reinstated, you do not qualify to receive new licenses for the same
432 material under section 10.
433
434 9. Acceptance Not Required for Having Copies.
435
436 You are not required to accept this License in order to receive or
437 run a copy of the Program. Ancillary propagation of a covered work
438 occurring solely as a consequence of using peer-to-peer transmission
439 to receive a copy likewise does not require acceptance. However,
440 nothing other than this License grants you permission to propagate or
441 modify any covered work. These actions infringe copyright if you do
442 not accept this License. Therefore, by modifying or propagating a
443 covered work, you indicate your acceptance of this License to do so.
444
445 10. Automatic Licensing of Downstream Recipients.
446
447 Each time you convey a covered work, the recipient automatically
448 receives a license from the original licensors, to run, modify and
449 propagate that work, subject to this License. You are not responsible
450 for enforcing compliance by third parties with this License.
451
452 An "entity transaction" is a transaction transferring control of an
453 organization, or substantially all assets of one, or subdividing an
454 organization, or merging organizations. If propagation of a covered
455 work results from an entity transaction, each party to that
456 transaction who receives a copy of the work also receives whatever
457 licenses to the work the party's predecessor in interest had or could
458 give under the previous paragraph, plus a right to possession of the
459 Corresponding Source of the work from the predecessor in interest, if
460 the predecessor has it or can get it with reasonable efforts.
461
462 You may not impose any further restrictions on the exercise of the
463 rights granted or affirmed under this License. For example, you may
464 not impose a license fee, royalty, or other charge for exercise of
465 rights granted under this License, and you may not initiate litigation
466 (including a cross-claim or counterclaim in a lawsuit) alleging that
467 any patent claim is infringed by making, using, selling, offering for
468 sale, or importing the Program or any portion of it.
469
470 11. Patents.
471
472 A "contributor" is a copyright holder who authorizes use under this
473 License of the Program or a work on which the Program is based. The
474 work thus licensed is called the contributor's "contributor version".
475
476 A contributor's "essential patent claims" are all patent claims
477 owned or controlled by the contributor, whether already acquired or
478 hereafter acquired, that would be infringed by some manner, permitted
479 by this License, of making, using, or selling its contributor version,
480 but do not include claims that would be infringed only as a
481 consequence of further modification of the contributor version. For
482 purposes of this definition, "control" includes the right to grant
483 patent sublicenses in a manner consistent with the requirements of
484 this License.
485
486 Each contributor grants you a non-exclusive, worldwide, royalty-free
487 patent license under the contributor's essential patent claims, to
488 make, use, sell, offer for sale, import and otherwise run, modify and
489 propagate the contents of its contributor version.
490
491 In the following three paragraphs, a "patent license" is any express
492 agreement or commitment, however denominated, not to enforce a patent
493 (such as an express permission to practice a patent or covenant not to
494 sue for patent infringement). To "grant" such a patent license to a
495 party means to make such an agreement or commitment not to enforce a
496 patent against the party.
497
498 If you convey a covered work, knowingly relying on a patent license,
499 and the Corresponding Source of the work is not available for anyone
500 to copy, free of charge and under the terms of this License, through a
501 publicly available network server or other readily accessible means,
502 then you must either (1) cause the Corresponding Source to be so
503 available, or (2) arrange to deprive yourself of the benefit of the
504 patent license for this particular work, or (3) arrange, in a manner
505 consistent with the requirements of this License, to extend the patent
506 license to downstream recipients. "Knowingly relying" means you have
507 actual knowledge that, but for the patent license, your conveying the
508 covered work in a country, or your recipient's use of the covered work
509 in a country, would infringe one or more identifiable patents in that
510 country that you have reason to believe are valid.
511
512 If, pursuant to or in connection with a single transaction or
513 arrangement, you convey, or propagate by procuring conveyance of, a
514 covered work, and grant a patent license to some of the parties
515 receiving the covered work authorizing them to use, propagate, modify
516 or convey a specific copy of the covered work, then the patent license
517 you grant is automatically extended to all recipients of the covered
518 work and works based on it.
519
520 A patent license is "discriminatory" if it does not include within
521 the scope of its coverage, prohibits the exercise of, or is
522 conditioned on the non-exercise of one or more of the rights that are
523 specifically granted under this License. You may not convey a covered
524 work if you are a party to an arrangement with a third party that is
525 in the business of distributing software, under which you make payment
526 to the third party based on the extent of your activity of conveying
527 the work, and under which the third party grants, to any of the
528 parties who would receive the covered work from you, a discriminatory
529 patent license (a) in connection with copies of the covered work
530 conveyed by you (or copies made from those copies), or (b) primarily
531 for and in connection with specific products or compilations that
532 contain the covered work, unless you entered into that arrangement,
533 or that patent license was granted, prior to 28 March 2007.
534
535 Nothing in this License shall be construed as excluding or limiting
536 any implied license or other defenses to infringement that may
537 otherwise be available to you under applicable patent law.
538
539 12. No Surrender of Others' Freedom.
540
541 If conditions are imposed on you (whether by court order, agreement or
542 otherwise) that contradict the conditions of this License, they do not
543 excuse you from the conditions of this License. If you cannot convey a
544 covered work so as to satisfy simultaneously your obligations under this
545 License and any other pertinent obligations, then as a consequence you may
546 not convey it at all. For example, if you agree to terms that obligate you
547 to collect a royalty for further conveying from those to whom you convey
548 the Program, the only way you could satisfy both those terms and this
549 License would be to refrain entirely from conveying the Program.
550
551 13. Use with the GNU Affero General Public License.
552
553 Notwithstanding any other provision of this License, you have
554 permission to link or combine any covered work with a work licensed
555 under version 3 of the GNU Affero General Public License into a single
556 combined work, and to convey the resulting work. The terms of this
557 License will continue to apply to the part which is the covered work,
558 but the special requirements of the GNU Affero General Public License,
559 section 13, concerning interaction through a network will apply to the
560 combination as such.
561
562 14. Revised Versions of this License.
563
564 The Free Software Foundation may publish revised and/or new versions of
565 the GNU General Public License from time to time. Such new versions will
566 be similar in spirit to the present version, but may differ in detail to
567 address new problems or concerns.
568
569 Each version is given a distinguishing version number. If the
570 Program specifies that a certain numbered version of the GNU General
571 Public License "or any later version" applies to it, you have the
572 option of following the terms and conditions either of that numbered
573 version or of any later version published by the Free Software
574 Foundation. If the Program does not specify a version number of the
575 GNU General Public License, you may choose any version ever published
576 by the Free Software Foundation.
577
578 If the Program specifies that a proxy can decide which future
579 versions of the GNU General Public License can be used, that proxy's
580 public statement of acceptance of a version permanently authorizes you
581 to choose that version for the Program.
582
583 Later license versions may give you additional or different
584 permissions. However, no additional obligations are imposed on any
585 author or copyright holder as a result of your choosing to follow a
586 later version.
587
588 15. Disclaimer of Warranty.
589
590 THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
591 APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
592 HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
593 OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
594 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
595 PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
596 IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
597 ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
598
599 16. Limitation of Liability.
600
601 IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
602 WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
603 THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
604 GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
605 USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
606 DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
607 PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
608 EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
609 SUCH DAMAGES.
610
611 17. Interpretation of Sections 15 and 16.
612
613 If the disclaimer of warranty and limitation of liability provided
614 above cannot be given local legal effect according to their terms,
615 reviewing courts shall apply local law that most closely approximates
616 an absolute waiver of all civil liability in connection with the
617 Program, unless a warranty or assumption of liability accompanies a
618 copy of the Program in return for a fee.
619
620 END OF TERMS AND CONDITIONS
621
622 How to Apply These Terms to Your New Programs
623
624 If you develop a new program, and you want it to be of the greatest
625 possible use to the public, the best way to achieve this is to make it
626 free software which everyone can redistribute and change under these terms.
627
628 To do so, attach the following notices to the program. It is safest
629 to attach them to the start of each source file to most effectively
630 state the exclusion of warranty; and each file should have at least
631 the "copyright" line and a pointer to where the full notice is found.
632
633 <one line to give the program's name and a brief idea of what it does.>
634 Copyright (C) <year> <name of author>
635
636 This program is free software: you can redistribute it and/or modify
637 it under the terms of the GNU General Public License as published by
638 the Free Software Foundation, either version 3 of the License, or
639 (at your option) any later version.
640
641 This program is distributed in the hope that it will be useful,
642 but WITHOUT ANY WARRANTY; without even the implied warranty of
643 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
644 GNU General Public License for more details.
645
646 You should have received a copy of the GNU General Public License
647 along with this program. If not, see <http://www.gnu.org/licenses/>.
648
649 Also add information on how to contact you by electronic and paper mail.
650
651 If the program does terminal interaction, make it output a short
652 notice like this when it starts in an interactive mode:
653
654 <program> Copyright (C) <year> <name of author>
655 This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
656 This is free software, and you are welcome to redistribute it
657 under certain conditions; type `show c' for details.
658
659 The hypothetical commands `show w' and `show c' should show the appropriate
660 parts of the General Public License. Of course, your program's commands
661 might be different; for a GUI interface, you would use an "about box".
662
663 You should also get your employer (if you work as a programmer) or school,
664 if any, to sign a "copyright disclaimer" for the program, if necessary.
665 For more information on this, and how to apply and follow the GNU GPL, see
666 <http://www.gnu.org/licenses/>.
667
668 The GNU General Public License does not permit incorporating your program
669 into proprietary programs. If your program is a subroutine library, you
670 may consider it more useful to permit linking proprietary applications with
671 the library. If this is what you want to do, use the GNU Lesser General
672 Public License instead of this License. But first, please read
673 <http://www.gnu.org/philosophy/why-not-lgpl.html>.
0 commit 6893c45 (HEAD, origin/master, origin/HEAD, master)
1 Author: Dir Lotter <dirk.lotter@siemens.com>
2 Date: Fri Mar 7 18:25:39 2014 +0100
3
4 Fix "odd" files created by frequent power-loss.
5
6 After running many power losses the filesystem can degrate, containing "odd"
7 files making the filesystem corrupt that could not be solved by fsck:
8
9 * file was not visible in a ls -l
10 * ls -i reported a "invalid file name" on the console
11 * a test program with diropen/dirread showed the file, a stat on this file
12 failed
13 * file was not accessible and could not be deleted
14
15 After digging into the code we found why fsck didn't repair the file system:
16 One thing was we don't have short filenames. Another issue was that the LFN
17 pointer was set to NULL and so it looked like we didn't have short and long
18 filenames.
19
20 Our patch of check.c includes:
21
22 * returns 1 from function bad_name() in case no short and no long filename
23 exist
24 * auto_rename() and rename_file() got a special handling for the case no short
25 file name exist:
26 - it enables the short file name (we think here was a weakness of the old
27 code: it changed the short filename but didn't enabled it in the
28 file->dir_ent.lcase entry)
29 - it reset all attributes except ATTR_DIR and ATTR_VOLUME
30
31 This solved our problem pretty well.
32
33 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
34
35 commit 621e11f
36 Author: Natanael Copa <ncopa@alpinelinux.org>
37 Date: Sat Feb 8 18:53:30 2014 +0100
38
39 Build fixes for musl libc.
40
41 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
42
43 commit 52588b7 (tag: v3.0.25)
44 Author: Daniel Baumann <mail@daniel-baumann.ch>
45 Date: Fri Jan 17 07:11:11 2014 +0100
46
47 Releasing version 3.0.25.
48
49 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
50
51 commit acf64ae
52 Author: Daniel Baumann <mail@daniel-baumann.ch>
53 Date: Fri Jan 17 07:09:54 2014 +0100
54
55 Updating copyright headers for 2014.
56
57 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
58
59 commit 21fe921
60 Author: Andrew Tridgell <tridge@samba.org>
61 Date: Tue Jan 14 09:37:51 2014 +1100
62
63 Fixed remaining 64 bit build warnings.
64
65 Some of these may be real bugs.
66
67 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
68
69 commit 9e3a2b1
70 Author: Andrew Tridgell <tridge@samba.org>
71 Date: Tue Jan 14 09:25:28 2014 +1100
72
73 Prevent corruption of FAT during fsck on 64 bit platforms.
74
75 unsigned long is 64 bit on x86-64, which means set_fat was writing two
76 entries, which corrupts the next entry. This can cause loss of data in
77 another file.
78
79 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
80
81 commit 0d2c9bc (tag: v3.0.24)
82 Author: Daniel Baumann <mail@daniel-baumann.ch>
83 Date: Sat Nov 23 10:36:55 2013 +0100
84
85 Releasing version 3.0.24.
86
87 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
88
89 commit 55bd7b7
90 Author: Jaroslav Skarvada <jskarvad@redhat.com>
91 Date: Sat Nov 23 10:34:48 2013 +0100
92
93 Fixed dosfsck on big endian platforms (Resolves: rhbz#1029695).
94
95 It seems there is problem in the double conversion on big endians.
96 The first conversion is done by the explicit conversion to __u16
97 in the GET_UNALIGNED_W macro, so the secondary conversion by le16toh
98 seems to be redundant (and wrong).
99
100 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
101
102 commit 6debb4a (tag: v3.0.23)
103 Author: Daniel Baumann <mail@daniel-baumann.ch>
104 Date: Tue Oct 15 08:05:46 2013 +0200
105
106 Releasing version 3.0.23.
107
108 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
109
110 commit 07d85ff
111 Author: Daniel Baumann <mail@daniel-baumann.ch>
112 Date: Tue Oct 15 08:04:11 2013 +0200
113
114 Reformating mkfs.fat manpage.
115
116 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
117
118 commit 137552f
119 Author: Michael Shigorin <mike@altlinux.org>
120 Date: Tue Oct 15 01:29:33 2013 +0400
121
122 Fixing "Fixing default sectors per cluster for FAT32" for UEFI.
123
124 FAT32 "EFI System Partition" is basically required for UEFI boot;
125 commit ge048a8d broke that for me with both virtualbox-4.2 and
126 real hardware (ASUS C60M1-I to be exact) given ~250Mb filesystem.
127
128 This commit amends that one by reverting its effects for these
129 small sizes by restoring 512b cluster size for <= 260Mb FAT32.
130
131 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
132
133 commit 2000696
134 Author: Daniel Baumann <mail@daniel-baumann.ch>
135 Date: Fri Aug 9 09:38:13 2013 +0200
136
137 Also allowing lowercase labels in mkfs (with warning message) consistent with the recent fsck change, thanks to Michael Baum <mbaum@devonit.com>.
138
139 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
140
141 commit 9b04807
142 Author: Tim Harder <radhermit@gentoo.org>
143 Date: Fri Jul 19 18:15:21 2013 +0200
144
145 Add install-man dependency to install-symlinks Makefile target.
146
147 This fixes a race condition during parallel installs where man page
148 symlinks won't be installed because install-man hasn't been run yet.
149
150 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
151
152 commit 651f91c (tag: v3.0.22)
153 Author: Daniel Baumann <mail@daniel-baumann.ch>
154 Date: Fri Jul 19 07:01:19 2013 +0200
155
156 Releasing version 3.0.22.
157
158 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
159
160 commit 3dc5560
161 Author: Daniel Baumann <mail@daniel-baumann.ch>
162 Date: Fri Jul 19 06:55:24 2013 +0200
163
164 Addding install-symlinks target to phony targets in Makefile.
165
166 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
167
168 commit c6c0581
169 Author: Daniel Baumann <mail@daniel-baumann.ch>
170 Date: Fri Jul 19 06:55:00 2013 +0200
171
172 Adding uninstall-symlinks target in Makefile.
173
174 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
175
176 commit 465dd8c
177 Author: Daniel Baumann <mail@daniel-baumann.ch>
178 Date: Fri Jul 19 06:45:40 2013 +0200
179
180 Allowing fatlabel to write labels in all lowercase but give a warning about DOS/Windows (Closes: #714971).
181
182 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
183
184 commit 3621b30
185 Author: John S Gruber <JohnSGruber@gmail.com>
186 Date: Fri Jul 19 06:40:21 2013 +0200
187
188 Add options and make dos boot sector more compatible with reference system (Closes: #552673).
189
190 Unless overridden by the user sets the DOS boot sector's
191 hidden-sectors field to match the start of a hard disk's
192 partition.
193
194 Initialize DOS boot sector drive_number according to FAT media type
195 Addresses LP: #398241 and Debian #552673
196
197 Adds options to override the DOS boot sector device_number and
198 the FAT media type.
199
200 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
201
202 commit be1eed5
203 Author: Daniel Baumann <mail@daniel-baumann.ch>
204 Date: Wed Jul 17 12:52:20 2013 +0200
205
206 Correcting wrong check preventing installation of fatlabel legacy manpage symlink.
207
208 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
209
210 commit d0065d3 (tag: v3.0.21)
211 Author: Daniel Baumann <mail@daniel-baumann.ch>
212 Date: Tue Jul 16 08:34:28 2013 +0200
213
214 Releasing version 3.0.21.
215
216 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
217
218 commit a74c12c
219 Author: Jaroslav Skarvada <jskarvad@redhat.com>
220 Date: Tue Jun 25 14:53:14 2013 +0200
221
222 Adding the missing -p option to the fsck manpage (to be consistent with the output of the tool).
223
224 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
225
226 commit 25e03c9
227 Author: Patrick J. Volkerding <volkerdi@slackware.com>
228 Date: Mon Jun 24 14:23:00 2013 +0200
229
230 Using $MANDIR instead of hardcoded ${PREFIX}/share/man in the Makefile.
231
232 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
233
234 commit 7fd9cf7
235 Author: Daniel Baumann <mail@daniel-baumann.ch>
236 Date: Fri Jun 14 18:50:31 2013 +0200
237
238 Making install-symlinks Makefile target depend on install-bin to not break when using make in parallel, thanks to David Walser <luigiwalser@yahoo.com>.
239
240 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
241
242 commit a76bbcd
243 Author: Daniel Baumann <mail@daniel-baumann.ch>
244 Date: Wed Jun 12 13:00:10 2013 +0200
245
246 Using US digit date format in version date, rather than name abbrev.
247
248 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
249
250 commit a64195f (tag: v3.0.20)
251 Author: Daniel Baumann <mail@daniel-baumann.ch>
252 Date: Wed Jun 12 12:25:32 2013 +0200
253
254 Releasing version 3.0.20.
255
256 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
257
258 commit 1a5d99f
259 Author: Daniel Baumann <mail@daniel-baumann.ch>
260 Date: Wed Jun 12 12:07:58 2013 +0200
261
262 Softening message about different boot sectors a bit (Closes: #704198).
263
264 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
265
266 commit 4727286
267 Author: Daniel Baumann <mail@daniel-baumann.ch>
268 Date: Wed Jun 12 11:42:52 2013 +0200
269
270 Harmonizing program name output.
271
272 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
273
274 commit 17c956c
275 Author: Martin Wilck <mwilck@arcor.de>
276 Date: Wed Jun 12 11:38:00 2013 +0200
277
278 Don't align FAT to cluster size.
279
280 See previous patch for explanation.
281
282 With this patch and the previous two, the
283 mkdosfs generated FAT32 file systems work well in my extremely
284 picky TechniSat device. Of course, they're also detected cleanly
285 by Linux and Windows.
286
287 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
288
289 commit d63e0d6
290 Author: Martin Wilck <mwilck@arcor.de>
291 Date: Wed Jun 12 11:36:08 2013 +0200
292
293 Don't align FAT32 reserved sectors to cluster size.
294
295 For certain file system sizes (in particular, exact GB sizes -
296 don't ask me why) a Technisat HD S2 Plus DVB receiver will still
297 choke on mkdosfs generated file systems, even if the sectors per
298 cluster problem is fixed.
299
300 By comparing the properties of generated FAT32 FS with results
301 of the Windows tool "h2format" (www.heise.de/download/h2format.html),
302 I found that the remaining problems were caused by rounding of the
303 reserved sectors and FAT space to cluster size (the h2format tool
304 doesn't do this).
305
306 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
307
308 commit e048a8d
309 Author: Martin Wilck <mwilck@arcor.de>
310 Date: Wed Jun 12 11:33:33 2013 +0200
311
312 Fixing default sectors per cluster for FAT32 (Closes: #690062).
313
314 The default sectors per cluster calculated by mkdosfs are outdated,
315 see http://technet.microsoft.com/en-us/library/cc938438.aspx.
316
317 The deviations may cause some 3rd party devices (e.g. TechniSat DVB
318 receivers) to hang when reading mkdosfs generated file systems.
319
320 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
321
322 commit 86509aa
323 Author: Daniel Baumann <mail@daniel-baumann.ch>
324 Date: Tue Jun 11 20:19:09 2013 +0200
325
326 Splitting out legacy symlink creation in toplevel Makefile to own target.
327
328 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
329
330 commit da37dd1
331 Author: Daniel Baumann <mail@daniel-baumann.ch>
332 Date: Wed Jun 12 11:29:12 2013 +0200
333
334 Correcting wrong toolname in fsck.fat.
335
336 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
337
338 commit b29a722
339 Author: Daniel Baumann <mail@daniel-baumann.ch>
340 Date: Tue Jun 11 19:51:47 2013 +0200
341
342 Consistently spelling filesystem as filesystem, and not file system.
343
344 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
345
346 commit 977d7aa
347 Author: Daniel Baumann <mail@daniel-baumann.ch>
348 Date: Tue Jun 11 19:30:19 2013 +0200
349
350 Removing Debian reference in GPL license headers.
351
352 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
353
354 commit 5505cc2 (tag: v3.0.19)
355 Author: Daniel Baumann <mail@daniel-baumann.ch>
356 Date: Tue Jun 11 18:46:03 2013 +0200
357
358 Releasing version 3.0.19.
359
360 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
361
362 commit 2c88f35
363 Author: Daniel Baumann <mail@daniel-baumann.ch>
364 Date: Tue Jun 11 18:44:50 2013 +0200
365
366 Running indent on source files.
367
368 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
369
370 commit d495d43
371 Author: Daniel Baumann <mail@daniel-baumann.ch>
372 Date: Tue Jun 11 18:41:41 2013 +0200
373
374 Using memcpy instead of strcpy to fix segfault with fortify, thanks to Dave Reisner <falconindy@jabber.org>.
375
376 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
377
378 commit 9fb4ffc
379 Author: Daniel Baumann <mail@daniel-baumann.ch>
380 Date: Sun Jun 9 13:17:16 2013 +0200
381
382 Correcting fsck.fat spelling error in manpages, thanks to E.J.M. Hartman <E.J.M.Hartman@tudelft.nl>.
383
384 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
385
386 commit 2d8ef9b (tag: v3.0.18)
387 Author: Daniel Baumann <mail@daniel-baumann.ch>
388 Date: Thu Jun 6 09:49:00 2013 +0200
389
390 Releasing version 3.0.18.
391
392 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
393
394 commit d4e1180
395 Author: Daniel Baumann <mail@daniel-baumann.ch>
396 Date: Thu Jun 6 09:38:45 2013 +0200
397
398 Adding initial i18n support for manpages with po4a.
399
400 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
401
402 commit ea8f712
403 Author: Daniel Baumann <mail@daniel-baumann.ch>
404 Date: Thu Jun 6 09:17:13 2013 +0200
405
406 Renaming tools to sane namespace and keeping legacy symlinks in place.
407
408 dosfslabel becomes fatlabel,
409 dosfsck becomes fsck.fat,
410 and mkdosfs becomes mkfs.fat.
411
412 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
413
414 commit a42b127
415 Author: Daniel Baumann <mail@daniel-baumann.ch>
416 Date: Wed Jun 5 07:12:03 2013 +0200
417
418 Correcting wrong spelling of Debian in mkdosfs manpage.
419
420 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
421
422 commit 2749084
423 Author: Daniel Baumann <mail@daniel-baumann.ch>
424 Date: Wed Jun 5 07:10:50 2013 +0200
425
426 Correcting spelling typo in boot.c.
427
428 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
429
430 commit 6461c83
431 Author: Martin Pitt <martinpitt@gnome.org>
432 Date: Fri May 24 09:35:44 2013 +0200
433
434 dosfslabel: Do not read beyond string length (Closes: #709587).
435
436 When checking whether the label contains any lower-case characters, do not read
437 beyond the end of the string.
438
439 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
440
441 commit 4203a90 (tag: v3.0.17)
442 Author: Daniel Baumann <mail@daniel-baumann.ch>
443 Date: Wed May 29 10:14:09 2013 +0200
444
445 Releasing version 3.0.17.
446
447 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
448
449 commit 3aa88ed
450 Author: Daniel Baumann <mail@daniel-baumann.ch>
451 Date: Wed May 29 09:48:24 2013 +0200
452
453 Updating maximal lenght of a label in manpage to talk about bytes instead of characters, thanks to Francois Wendling <frwendling@gmail.com> (Closes: #655953).
454
455 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
456
457 commit 0916f8a
458 Author: Jaroslav Skarvada <jskarvad@redhat.com>
459 Date: Wed May 29 09:56:08 2013 +0200
460
461 Fixing segfault in dosfslabel.
462
463 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
464
465 commit 4a265c6
466 Author: James Byrne <jbyrne@aminocom.com>
467 Date: Mon Apr 22 12:29:51 2013 +0100
468
469 Allow operation on SH4 CPUs and remove compiler warnings.
470
471 Simplify the GET_UNALIGNED_W macro and use it in all cases instead of making it
472 conditional on CPU types. This missed some CPUs that needed it (e.g. SH4), and
473 in any case the implementation caused "dereferencing type-punned pointer will
474 break strict-aliasing rules" warnings.
475
476 Enable extra warnings, but disable signed comparison and missing field
477 initializer warnings as these are not helpful.
478
479 Update write_boot_label() so that the boot_sector_16 and boot_sector cases are
480 handled separately instead of using an aliased pointer, as that causes
481 "dereferencing type-punned pointer will break strict-aliasing rules" warnings.
482
483 Make date_dos2unix(), usage() and cdiv() static functions as they are only used
484 in the files in which they are declared.
485
486 Update bad_name() and lfn_get() so that the extension is processed separately
487 instead of by indexing past the end of the name field as that causes "array
488 subscript is above array bounds" warnings.
489
490 Update the dosfsck() main function to avoid a warning that free_clusters may
491 be used uninitialized. Do not print the final count of files and clusters when
492 dosfsck is run with the "-b" option because the used files and clusters have
493 not been counted in this case.
494
495 Alter the setup_tables() function so that it does not cause an "array subscript
496 is below array bounds" warning.
497
498 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
499
500 commit eb68a14
501 Author: James Byrne <jbyrne@aminocom.com>
502 Date: Mon Apr 22 13:32:01 2013 +0100
503
504 Add a .gitignore file.
505
506 Add a .gitignore file so that the results of compilation do not appear as
507 changes.
508
509 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
510
511 commit 336e8f1
512 Author: James Byrne <jbyrne@aminocom.com>
513 Date: Mon Apr 22 12:38:52 2013 +0100
514
515 Finish cleanup of byteswap code.
516
517 Commit 9ba8992 left three references to the old CT_LE_W macro.
518 Remove these since no conversion was needed as the value being
519 converted was zero.
520
521 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
522
523 commit 64b6227
524 Author: Daniel Baumann <mail@daniel-baumann.ch>
525 Date: Thu Apr 4 08:08:00 2013 +0200
526
527 Shortening links to upstream homepage.
528
529 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
530
531 commit 76304be
532 Author: Cristian Rodríguez <crrodriguez@opensuse.org>
533 Date: Fri Mar 1 08:23:34 2013 +0100
534
535 Fix offsetof definition.
536
537 * include stddef.h to get the correct offsetof definition.
538 * remove local offsetof definition, systems not having it on stddef.h
539 are in violation of C89, C99, POSIX.1-2001.
540
541 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
542
543 commit 9ba8992
544 Author: Cristian Rodríguez <crrodriguez@opensuse.org>
545 Date: Fri Mar 1 08:58:36 2013 +0100
546
547 Cleanup byteswap code.
548
549 Remove all duplicate macro definitions for byteswapping routines
550 and replace them for proper usage of userspace endian(3).
551
552 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
553
554 commit 8733e12 (tag: v3.0.16)
555 Author: Daniel Baumann <mail@daniel-baumann.ch>
556 Date: Wed May 29 10:06:01 2013 +0200
557
558 Releasing version 3.0.16.
559
560 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
561
562 commit a9fa87e
563 Author: Petr Gajdos <pgajdos@suse.cz>
564 Date: Fri Mar 1 08:34:12 2013 +0100
565
566 Create rootdir entry volume label with mkdosfs, create it when
567 it doesn't exist with dosfslabel.
568
569 See https://bugzilla.novell.com/show_bug.cgi?id=657011#c4
570 for more information.
571
572 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
573
574 commit 92057f1
575 Author: Petr Gajdos <pgajdos@suse.cz>
576 Date: Fri Mar 1 08:33:18 2013 +0100
577
578 Forbid lowercase letters in label.
579
580 See https://bugzilla.novell.com/show_bug.cgi?id=657011#c4 and
581 http://support.microsoft.com/kb/71715/en-us for more information.
582
583 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
584
585 commit 5e265c4
586 Author: Petr Gajdos <pgajdos@suse.cz>
587 Date: Fri Mar 1 08:32:02 2013 +0100
588
589 Read label also from rootdir entry.
590
591 See https://bugzilla.novell.com/show_bug.cgi?id=657011#c4
592 for more information.
593
594 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
595
596 commit 5cec53c
597 Author: Petr Gajdos <pgajdos@suse.cz>
598 Date: Fri Mar 1 08:30:21 2013 +0100
599
600 alloc_rootdir_entry() is intended to be called with pattern == "FSCK%04dREC",
601 the old code (probably c&p from auto_rename()) doesn't reflect this.
602
603 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
604
605 commit 63938f0
606 Author: Petr Gajdos <pgajdos@suse.cz>
607 Date: Fri Mar 1 08:29:00 2013 +0100
608
609 Instead of eleven blanks, fill in "NO NAME " as specification tells.
610
611 See https://bugzilla.novell.com/show_bug.cgi?id=657011#c4 and
612 http://www.win.tue.nl/~aeb/linux/fs/fat/fat-1.html for more information.
613
614 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
615
616 commit 10c1c41
617 Author: Petr Gajdos <pgajdos@suse.cz>
618 Date: Fri Mar 1 08:58:15 2013 +0100
619
620 Write uppercase letters in label.
621
622 See https://bugzilla.novell.com/show_bug.cgi?id=657011#c4 and
623 http://support.microsoft.com/kb/71715/en-us for more information.
624
625 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
626
627 commit a75fb1c (tag: v3.0.15)
628 Author: Daniel Baumann <mail@daniel-baumann.ch>
629 Date: Thu Feb 21 15:06:52 2013 +0100
630
631 Releasing version 3.0.15.
632
633 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
634
635 commit c8f84fd
636 Author: Alexander Korolkov <alexander.korolkov@gmail.com>
637 Date: Mon Feb 4 00:22:34 2013 +0400
638
639 Using wcstombs() to convert LFN unicode characters to printable text.
640
641 This closes Debian bug #596336.
642
643 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
644
645 commit 1546545
646 Author: Alexander Korolkov <alexander.korolkov@gmail.com>
647 Date: Sun Sep 5 18:59:47 2010 +0400
648
649 Recode short filenames from DOS codepage (default 437).
650
651 Recode short filenames from DOS codepage (default 437) to the current
652 character encoding. This makes messages of dosfsck more readable.
653 Partially closes Debian bug #596336.
654
655 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
656
657 commit ad76cae
658 Author: Jaroslav Skarvada <jskarvad@redhat.com>
659 Date: Thu Feb 21 14:40:52 2013 +0100
660
661 Fixing root directory allocation.
662
663 See https://bugzilla.redhat.com/show_bug.cgi?id=674095 for more information.
664
665 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
666
667 commit b8201b3
668 Author: Jaroslav Skarvada <jskarvad@redhat.com>
669 Date: Thu Feb 21 14:40:25 2013 +0100
670
671 Fixing device detection.
672
673 See https://bugzilla.redhat.com/show_bug.cgi?id=710480 for more information.
674
675 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
676
677 commit 7a75638 (tag: v3.0.14)
678 Author: Daniel Baumann <mail@daniel-baumann.ch>
679 Date: Wed Jan 23 13:22:01 2013 +0100
680
681 Releasing version 3.0.14.
682
683 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
684
685 commit 5bdd7ef
686 Author: Daniel Baumann <mail@daniel-baumann.ch>
687 Date: Wed Jan 23 13:16:20 2013 +0100
688
689 Documenting dosfsck -b in its manpage.
690
691 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
692
693 commit a307be2
694 Author: Oleksij Rempel <bug-track@fisher-privat.net>
695 Date: Wed Jan 23 12:36:56 2013 +0100
696
697 Adding option for bootsector read-only check.
698
699 Most boot sectors may contains marker for filesystem state. We can this
700 bit on every mount and warn user if some thing wrong, without checking
701 complete filesystem.
702
703 Signed-off-by: Oleksij Rempel <bug-track@fisher-privat.net>
704 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
705
706 commit ce2f8dc
707 Author: Oleksij Rempel <bug-track@fisher-privat.net>
708 Date: Wed Jan 23 12:35:13 2013 +0100
709
710 Checking boot sector for dirty bit.
711
712 Some OSos use reseved byte of boot sector to set state of the file
713 system. If first bit set, then filesystem is proably damaged - write
714 operation was not finished/cache not snycted/...
715
716 Signed-off-by: Oleksij Rempel <bug-track@fisher-privat.net>
717 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
718
719 commit f33ee8c
720 Author: Daniel Baumann <mail@daniel-baumann.ch>
721 Date: Wed Jan 23 12:25:59 2013 +0100
722
723 Completing and updating all copyright headers for 2013.
724
725 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
726
727 commit bfe6d25
728 Author: Daniel Baumann <mail@daniel-baumann.ch>
729 Date: Wed Jan 23 12:17:20 2013 +0100
730
731 Updating my email address.
732
733 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
734
735 commit 13cdb4d (tag: v3.0.13)
736 Author: Daniel Baumann <mail@daniel-baumann.ch>
737 Date: Sat Jun 30 19:10:44 2012 +0200
738
739 Releasing version 3.0.13.
740
741 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
742
743 commit d039482
744 Author: Jaroslav Å karvada <jskarvad@redhat.com>
745 Date: Sat Jun 30 19:09:11 2012 +0200
746
747 Fix 'dosfslabel throws "Seek to 114116076544:Invalid argument" error when labeling'.
748
749 See https://bugzilla.redhat.com/show_bug.cgi?id=693662 for more information.
750
751 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
752
753 commit e243612 (tag: v3.0.12)
754 Author: Daniel Baumann <mail@daniel-baumann.ch>
755 Date: Sat Oct 29 08:40:53 2011 +0200
756
757 Releasing version 3.0.12.
758
759 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
760
761 commit 025b4f0
762 Author: Michael Casadevall <mcasadevall@ubuntu.com>
763 Date: Tue Jun 7 19:19:30 2011 +0200
764
765 Correcting miscalculation of sector number in some cases.
766
767 mkdosfs will incorrectly calculate the number of sectors of a
768 given FAT partition if the number sectors are odd due to
769 count_blocks incorrectly handling the remainder of a division
770 operation. This miscalculation causes the OMAP4 bootloader to
771 fail to boot.
772
773 This bug can be observed by comparing the total sector size in
774 fdisk expert more to fsck.msdos; this discrepancy only shows up
775 when the number of sectors are odd.
776
777 See https://bugs.launchpad.net/ubuntu/+source/dosfstools/+bug/794043
778 for more information.
779
780 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
781
782 commit 91a1fb9
783 Author: Daniel Baumann <mail@daniel-baumann.ch>
784 Date: Sat Jan 8 23:38:59 2011 +0100
785
786 Re-running Nindent.
787
788 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
789
790 commit 0390c4c
791 Author: Sergey Gusarov <laborer2008@gmail.com>
792 Date: Sat Jan 8 23:36:11 2011 +0100
793
794 Fixing compiler warnings related to the mismatch of types "char *" / "unsigned
795 char *".
796
797 These warnings appear when you compile the project with the option "-Wall", what
798 is done with the current default Makefile.
799
800 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
801
802 commit 4a8f8a6
803 Author: Jaroslav Skarvada <jskarvad@redhat.com>
804 Date: Thu Jan 6 22:35:00 2011 +0100
805
806 Fixing overflow bug in reclaim_file function, see
807 https://bugzilla.redhat.com/show_bug.cgi?id=660154 for more information.
808
809 The problem is that alloc_rootdir_entry counts with 10000 files at max, but the
810 filename buffer is only 8 chars long. Due to pattern mask used it results to
811 only 10 files at max (FSCK0-9REC). If there is more than 10 files, it overflows
812 and hangs.
813
814 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
815
816 commit e0366da
817 Author: Sergey Gusarov <laborer2008@gmail.com>
818 Date: Thu Jan 6 22:31:39 2011 +0100
819
820 Fixing conversion specifiers in accordance with the type of expressions.
821
822 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
823
824 commit 2d8be9c
825 Author: Daniel Baumann <mail@daniel-baumann.ch>
826 Date: Sun Jan 2 15:41:44 2011 +0100
827
828 Indenting source files.
829
830 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
831
832 commit 697af85
833 Author: Daniel Baumann <mail@daniel-baumann.ch>
834 Date: Sun Jan 2 15:39:03 2011 +0100
835
836 Adding Nindent script from syslinux.
837
838 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
839
840 commit 66d55cd (tag: v3.0.11)
841 Author: Daniel Baumann <mail@daniel-baumann.ch>
842 Date: Fri Dec 24 17:58:29 2010 +0100
843
844 Releasing version 3.0.11.
845
846 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
847
848 commit d579802
849 Author: Michael Stapelberg <michael@stapelberg.de>
850 Date: Fri Nov 19 14:09:36 2010 +0100
851
852 Add better error message when the device cannot be opened.
853
854 This is helpful for SD cards or other removable media which have an enabled
855 write lock -- without the "Permission denied" message, the user has to strace
856 mkdosfs to find out what's going on.
857
858 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
859
860 commit bb6000f
861 Author: Jaroslav Skarvada <jskarvad@redhat.com>
862 Date: Fri Oct 8 13:38:16 2010 +0200
863
864 Unalign on s390x, see http://bugzilla.redhat.com/show_bug.cgi?id=624596 for
865 more information.
866
867 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
868
869 commit 5ef7f1f (tag: v3.0.10)
870 Author: Daniel Baumann <mail@daniel-baumann.ch>
871 Date: Sun Sep 12 09:35:47 2010 +0200
872
873 Releasing version 3.0.10.
874
875 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
876
877 commit ea41797
878 Author: Alexander Korolkov <alexander.korolkov@gmail.com>
879 Date: Sun Sep 12 09:29:12 2010 +0200
880
881 Modify LFN direntries when file is renamed or deleted, see
882 Debian bug #596329.
883
884 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
885
886 commit e56ff72
887 Author: Alexander Korolkov <alexander.korolkov@gmail.com>
888 Date: Sun Sep 12 09:27:07 2010 +0200
889
890 If the test of short filename fails, dosfsck could complain about
891 bad long filename, see Debian bug #596327.
892
893 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
894
895 commit f0a42d0
896 Author: Alexander Korolkov <alexander.korolkov@gmail.com>
897 Date: Sun Sep 12 09:24:47 2010 +0200
898
899 dosfsck: don't complain about bad filenames when short filename
900 contains 7 or more characters with codes 128-255, see Debian
901 bug #596327.
902
903 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
904
905 commit 0113c5b
906 Author: Mitch Rybczynski <mrybczynski@miovision.com>
907 Date: Mon Jul 5 14:45:54 2010 +0200
908
909 Adding __arm__ define check for some crosscompile toolchains.
910
911 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
912
913 commit 88cb84f
914 Author: Daniel Baumann <mail@daniel-baumann.ch>
915 Date: Sun Mar 14 16:42:32 2010 +0100
916
917 Modernizing dosfslabel manpage.
918
919 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
920
921 commit 5aa7ec4
922 Author: Daniel Baumann <mail@daniel-baumann.ch>
923 Date: Sun Mar 14 16:33:47 2010 +0100
924
925 Modernizing dosfsck manpage.
926
927 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
928
929 commit 807ed80
930 Author: Daniel Baumann <mail@daniel-baumann.ch>
931 Date: Sun Mar 14 16:05:32 2010 +0100
932
933 Fixing spelling error in boot.c.
934
935 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
936
937 commit 5b6849d (tag: v3.0.9)
938 Author: Daniel Baumann <mail@daniel-baumann.ch>
939 Date: Sun Jan 31 08:31:32 2010 +0100
940
941 Releasing version 3.0.9.
942
943 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
944
945 commit 33bca7d
946 Author: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
947 Date: Sun Jan 31 00:11:41 2010 -0500
948
949 Be sure to store the updated reserved_sector count in the boot sector,
950 see Debian bug #567337.
951
952 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
953
954 commit 2a3bef8 (tag: v3.0.8)
955 Author: Daniel Baumann <mail@daniel-baumann.ch>
956 Date: Sat Jan 23 10:16:18 2010 +0100
957
958 Releasing version 3.0.8.
959
960 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
961
962 commit 726c02d
963 Author: Daniel Baumann <mail@daniel-baumann.ch>
964 Date: Sat Jan 23 10:15:01 2010 +0100
965
966 Removing some cruft in end-comments.
967
968 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
969
970 commit a5961d7
971 Author: Steven J. Magnani <steve@digidescorp.com>
972 Date: Thu Jan 21 16:58:11 2010 +0100
973
974 When compiling a 32-bit version of dosfstools on an x86_64 machine,
975 the resulting applications report strange errors on "large" (> 2 GiB)
976 partitions:
977
978 Seek to -2118967808:Invalid argument
979
980 Warning: Filesystem is FAT32 according to fat_length and fat32_length fields,
981 but has only 8613 clusters, less than the required minimum of 65525.
982 This may lead to problems on some systems.
983
984 This appears to be due to compilation with a 32-bit off_t and lseek() library
985 function.
986
987 Use lseek64 for positioning, and change some suspect uses of off_t to loff_t.
988
989 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
990
991 commit bbb25bf
992 Author: Steven J. Magnani <steve@digidescorp.com>
993 Date: Thu Jan 21 16:56:26 2010 +0100
994
995 If dosfsck is run in read-only mode (-n), exit with code 0
996 if the only issue found is an uninitialized free cluster summary.
997
998 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
999
1000 commit 1cae726
1001 Author: Steven J. Magnani <steve@digidescorp.com>
1002 Date: Thu Jan 21 16:55:30 2010 +0100
1003
1004 On x86_64, dosfsck incorrectly claims that a free_cluster summary of
1005 0xFFFFFFFF, defined by Microsoft to be "uninitialized," is wrong.
1006
1007 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
1008
1009 commit 62f806a
1010 Author: H. Peter Anvin <hpa@zytor.com>
1011 Date: Fri Jan 8 09:16:38 2010 +0100
1012
1013 mkdosfs: correct alignment of the root directory.
1014
1015 Correct the code to align the root directory; it was broken before
1016 since bs.dir_entries had already been set at the point of alignment.
1017 This patch removes the dual use of bs.dir_entries and root_dir_entries
1018 to carry the same information: the information is carried in
1019 root_dir_entires exclusively, and then bs.dir_entries is set inside
1020 setup_tables() at a late point.
1021
1022 The code to align the root directory is also wrapped in
1023 if (align_structures); this avoids rounding the number of root
1024 directory entries up to a whole sector when used with -a
1025 (i.e. preserves the previous behavior.)
1026
1027 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
1028
1029 commit 8825bda
1030 Author: H. Peter Anvin <hpa@zytor.com>
1031 Date: Wed Jan 6 20:55:36 2010 +0100
1032
1033 mkdosfs: improve wording in the man page for the -a option.
1034
1035 Improve the English language used in the man page for the -a (no
1036 align) option to mkdosfs.
1037
1038 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
1039
1040 commit 21d3f81
1041 Author: Daniel Baumann <mail@daniel-baumann.ch>
1042 Date: Wed Jan 6 11:27:25 2010 +0100
1043
1044 Adding reference to dosfslable in mkdosfs manpage.
1045
1046 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
1047
1048 commit 247ba06
1049 Author: H. Peter Anvin <hpa@zytor.com>
1050 Date: Wed Jan 6 11:18:55 2010 +0100
1051
1052 mkdosfs: by default align all structures to cluster boundaries
1053
1054 Align all data structures (reserved sectors, FATs, root directory for
1055 FAT12/16) to an even multiple of the cluster size. This means that if
1056 the partition is aligned, so will all clusters be. This adds
1057 significant performance for anything where the physical sector size is
1058 larger than the logical sector size, e.g. flash media or large-sector
1059 hard disks.
1060
1061 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
1062
1063 commit 171bc07 (tag: v3.0.7)
1064 Author: Daniel Baumann <mail@daniel-baumann.ch>
1065 Date: Thu Dec 24 10:53:36 2009 +0100
1066
1067 Releasing version 3.0.7.
1068
1069 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
1070
1071 commit 28708fc
1072 Author: Ben Hutchings <ben@decadent.org.uk>
1073 Date: Thu Dec 24 09:55:52 2009 +0100
1074
1075 Fixing dosfslabel to set volume label in the right place,
1076 see Debian bug #559985.
1077
1078 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
1079
1080 commit 2c405dd
1081 Author: Lubomir Rintel <lkundrak@v3.sk>
1082 Date: Thu Dec 24 09:39:39 2009 +0100
1083
1084 Fixing out-of bound writes.
1085
1086 Firstly, packed attribute is added to the structure so that extension
1087 is guarranteed to immediately follow name for the cross-name-extension
1088 reads to succeed.
1089
1090 Secondly, writes into dir_entry->name that span through the extension as
1091 well are split into two, so that FORTIFY_SOURCE's bound checking does
1092 not abort dosfsck. There also was an off-by-one error in auto_rename()'s
1093 sprintf().
1094
1095 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
1096
1097 commit b8f3efe
1098 Author: San Mehat <san@google.com>
1099 Date: Thu Dec 24 09:31:41 2009 +0100
1100
1101 Adding custom exit code in dosfsck for the case where the FS is read only.
1102
1103 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
1104
1105 commit 0657e01 (tag: v3.0.6)
1106 Author: Daniel Baumann <mail@daniel-baumann.ch>
1107 Date: Sun Oct 4 10:59:33 2009 +0200
1108
1109 Releasing version 3.0.6.
1110
1111 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
1112
1113 commit bc84254
1114 Author: Steven J. Magnani <steve@digidescorp.com>
1115 Date: Sun Oct 4 10:58:43 2009 +0200
1116
1117 Attempt to improve clarity of the orphan cluster reclaim code.
1118 Minor optimization - remove some unnecessary checking.
1119
1120 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
1121
1122 commit 8054b4a
1123 Author: Steven J. Magnani <steve@digidescorp.com>
1124 Date: Sun Oct 4 08:37:19 2009 +0200
1125
1126 Close hole that permitted clusters to link to (invalid) cluster 1.
1127
1128 If an orphan chain that linked to cluster 1 was reclaimed to a file,
1129 deletion of the file would result in a filesystem panic.
1130
1131 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
1132
1133 commit e51af88
1134 Author: Steven J. Magnani <steve@digidescorp.com>
1135 Date: Sun Oct 4 08:32:30 2009 +0200
1136
1137 Fix erroneous report of huge number of clusters in use on big-endian
1138 systems when the FSINFO free cluster count is reset.
1139
1140 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
1141
1142 commit 16ba63f (tag: v3.0.5)
1143 Author: Daniel Baumann <mail@daniel-baumann.ch>
1144 Date: Mon Jul 27 14:26:11 2009 +0200
1145
1146 Releasing version 3.0.5.
1147
1148 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
1149
1150 commit 28ff9d9
1151 Author: Piotr Kaczuba <pepe@attika.ath.cx>
1152 Date: Sun Jul 26 22:21:25 2009 +0200
1153
1154 Signed/unsigned char mismatch in check.c causes false positives
1155 in bad_name() and can result in data loss, see Debian bug #538758.
1156
1157 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
1158
1159 commit d42a273
1160 Author: Andrew Tridgell <tridge@samba.org>
1161 Date: Sun Jul 26 22:12:06 2009 +0200
1162
1163 Update to new kernel patches that add FAT_NO_83NAME flag.
1164
1165 See http://lkml.org/lkml/2009/7/20/425 and
1166 http://lkml.org/lkml/2009/7/20/424 for more information.
1167
1168 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
1169
1170 commit dd0f0b5 (tag: v3.0.4)
1171 Author: Daniel Baumann <mail@daniel-baumann.ch>
1172 Date: Tue Jul 21 08:10:52 2009 +0200
1173
1174 Releasing version 3.0.4.
1175
1176 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
1177
1178 commit b9f37a6
1179 Author: Andrew Tridgell <tridge@samba.org>
1180 Date: Tue Jul 21 07:59:22 2009 +0200
1181
1182 Modify dosfstools to support the dummy 8.3 short filename values
1183 used by Linux systems with the VFAT_FS_DUALNAMES option disabled.
1184
1185 See http://lkml.org/lkml/2009/6/26/313 and
1186 http://lkml.org/lkml/2009/6/26/314 for more information.
1187
1188 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
1189
1190 commit ecd15e8
1191 Author: Paul Rupe <prupe@nc.rr.com>
1192 Date: Tue May 19 10:37:52 2009 +0200
1193
1194 Fixing "Too many files need repair" error during fsck.
1195
1196 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
1197
1198 commit 7c16098 (tag: v3.0.3)
1199 Author: Daniel Baumann <mail@daniel-baumann.ch>
1200 Date: Mon May 18 15:12:04 2009 +0200
1201
1202 Releasing version 3.0.3.
1203
1204 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
1205
1206 commit b396dcf
1207 Author: Daniel Baumann <mail@daniel-baumann.ch>
1208 Date: Mon May 18 15:10:55 2009 +0200
1209
1210 Also declaring arm as an unaligned architecture, see Debian bug #502961.
1211
1212 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
1213
1214 commit ff1b24e
1215 Author: Steven J. Magnani <steve@digidescorp.com>
1216 Date: Mon May 18 15:01:49 2009 +0200
1217
1218 Adding support for limited-memory embedded systems.
1219
1220 This patch reorganizes heap memory usage by dosfsck and mkdosfs
1221 to support limited-memory embedded systems - in particular, those
1222 based on Xilinx's Microblaze processor. It also adds a few comments.
1223
1224 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
1225
1226 commit 89f0b72
1227 Author: Mike Frysinger <vapier@gentoo.org>
1228 Date: Thu Mar 5 07:03:36 2009 +0100
1229
1230 Declaring Blackfin as an unaligned architecture.
1231
1232 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
1233
1234 commit b54a8a4 (tag: v3.0.2)
1235 Author: Daniel Baumann <mail@daniel-baumann.ch>
1236 Date: Sat Feb 28 09:48:04 2009 +0100
1237
1238 Releasing version 3.0.2.
1239
1240 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
1241
1242 commit 9500529
1243 Author: Hiroaki Ishizawa <hiroaki.ishizawa@gmail.com>
1244 Date: Fri Feb 13 10:00:46 2009 +0100
1245
1246 dosfsck corrupts root directory when fs->nfats is 1.
1247
1248 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
1249
1250 commit 043f8a8
1251 Author: Stepan Kasal <skasal@redhat.com>
1252 Date: Fri Jan 30 14:56:33 2009 +0100
1253
1254 src/dosfslabel.c (main): After writing the label, exit code should be 0.
1255
1256 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
1257
1258 commit 017da27
1259 Author: Daniel Baumann <mail@daniel-baumann.ch>
1260 Date: Fri Jan 30 14:06:01 2009 +0100
1261
1262 Also installing ChangeLog in install-doc target of Makefile.
1263
1264 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
1265
1266 commit 1c76f0f
1267 Author: Stepan Kasal <skasal@redhat.com>
1268 Date: Fri Jan 30 14:05:12 2009 +0100
1269
1270 Makefile: Do not clobber time stamps of doc files.
1271
1272 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
1273
1274 commit df2d2f1 (tag: v3.0.1)
1275 Author: Daniel Baumann <mail@daniel-baumann.ch>
1276 Date: Sun Nov 23 22:45:45 2008 +0100
1277
1278 Releasing version 3.0.1.
1279
1280 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
1281
1282 commit 17b269b
1283 Author: Daniel Baumann <mail@daniel-baumann.ch>
1284 Date: Sun Nov 23 18:41:01 2008 +0100
1285
1286 Applying Fedoras dosfstools-vfat-timingfix.diff from Bill Nottingham
1287 <notting@redhat.com> to fix vfat timing issue. See
1288 https://bugzilla.redhat.com/show_bug.cgi?id=448247 for more information.
1289
1290 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
1291
1292 commit e597caf
1293 Author: Ulrich Mueller <ulm@gentoo.org>
1294 Date: Tue Oct 7 07:55:37 2008 +0200
1295
1296 Patch to check for bad number of clusters in dosfsck:
1297
1298 * FAT16 filesystems with 65525 clusters or more will be rejected
1299 (Before, this was not tested for. Up to 65535 clusters were accepted
1300 as good).
1301
1302 * For FAT32 filesystems with less than 65525 a warning message will be
1303 output.
1304
1305 Macro MSDOS_FAT12 is now replaced by FAT12_THRESHOLD to make it
1306 consistent with the definition in mkdosfs and to remove the dependency
1307 on the kernel version.
1308
1309 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
1310
1311 commit 90102bc
1312 Author: Dann Frazier <dannf@hp.com>
1313 Date: Tue Sep 30 07:25:19 2008 +0200
1314
1315 Changing some wording to make the indended meaning of "full-disk device"
1316 more obvious.
1317
1318 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
1319
1320 commit 21e9ba0 (tag: v3.0.0)
1321 Author: Daniel Baumann <mail@daniel-baumann.ch>
1322 Date: Sun Sep 28 11:43:19 2008 +0200
1323
1324 Releasing version 3.0.0.
1325
1326 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
1327
1328 commit eaf145d
1329 Author: Daniel Baumann <mail@daniel-baumann.ch>
1330 Date: Sun Sep 28 11:29:01 2008 +0200
1331
1332 Adding GPL headers to all files.
1333
1334 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
1335
1336 commit 0826117
1337 Author: Daniel Baumann <mail@daniel-baumann.ch>
1338 Date: Sun Sep 28 10:51:55 2008 +0200
1339
1340 Adding new GPL license file.
1341
1342 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
1343
1344 commit f8d6127
1345 Author: Daniel Baumann <mail@daniel-baumann.ch>
1346 Date: Fri Sep 26 23:31:12 2008 +0200
1347
1348 Redoing Makefile from scratch.
1349
1350 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
1351
1352 commit b4feb73
1353 Author: Daniel Baumann <mail@daniel-baumann.ch>
1354 Date: Sat Sep 27 00:17:38 2008 +0200
1355
1356 Removing whitespaces in all files at EOL and EOF.
1357
1358 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
1359
1360 commit 1410138
1361 Author: Daniel Baumann <mail@daniel-baumann.ch>
1362 Date: Fri Sep 26 23:48:56 2008 +0200
1363
1364 Adding Debians dosfslabel.8 manpage from Francois Wendling
1365 <frwendling@free.fr>.
1366
1367 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
1368
1369 commit f62e7f2
1370 Author: Daniel Baumann <mail@daniel-baumann.ch>
1371 Date: Fri Sep 26 18:36:04 2008 +0200
1372
1373 Updating version.h includes to new location of version.h file.
1374
1375 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
1376
1377 commit 32e5952
1378 Author: Daniel Baumann <mail@daniel-baumann.ch>
1379 Date: Fri Sep 26 18:19:36 2008 +0200
1380
1381 Removing old lsm file.
1382
1383 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
1384
1385 commit 25a433b
1386 Author: Daniel Baumann <mail@daniel-baumann.ch>
1387 Date: Fri Sep 26 18:07:47 2008 +0200
1388
1389 Removing old cvsignore files.
1390
1391 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
1392
1393 commit acac13f
1394 Author: Daniel Baumann <mail@daniel-baumann.ch>
1395 Date: Fri Sep 26 18:18:39 2008 +0200
1396
1397 Removing old build file.
1398
1399 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
1400
1401 commit 3ecdd21
1402 Author: Daniel Baumann <mail@daniel-baumann.ch>
1403 Date: Fri Sep 26 18:19:16 2008 +0200
1404
1405 Removing old GPL license files.
1406
1407 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
1408
1409 commit f183d0e
1410 Author: Daniel Baumann <mail@daniel-baumann.ch>
1411 Date: Fri Sep 26 18:21:57 2008 +0200
1412
1413 Unifying dosfsck and mkdosfs Makefiles in common src/Makefile.
1414
1415 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
1416
1417 commit 61e7466
1418 Author: Daniel Baumann <mail@daniel-baumann.ch>
1419 Date: Fri Sep 26 18:04:02 2008 +0200
1420
1421 Unifying dosfsck and mkdosfs sources in common src directory.
1422
1423 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
1424
1425 commit 7552d57
1426 Author: Daniel Baumann <mail@daniel-baumann.ch>
1427 Date: Fri Sep 26 18:05:27 2008 +0200
1428
1429 Unifying dosfsck and mkdosfs manpages in common man directory.
1430
1431 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
1432
1433 commit 124598b
1434 Author: Daniel Baumann <mail@daniel-baumann.ch>
1435 Date: Fri Sep 26 18:12:29 2008 +0200
1436
1437 Unifying dosfsck and mkdosfs documents in common doc directory.
1438
1439 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
1440
1441 commit fb9c46b
1442 Author: Daniel Baumann <mail@daniel-baumann.ch>
1443 Date: Fri Sep 26 15:39:51 2008 +0200
1444
1445 Applying Gentoos dosfstools-2.11-preen.patch from Roy Marples
1446 <uberlord@gentoo.org> to alias dosfsck -p to -a:
1447
1448 * Map -p to -a for baselayout-2, #177514.
1449
1450 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
1451
1452 commit aaa40a9
1453 Author: Daniel Baumann <mail@daniel-baumann.ch>
1454 Date: Fri Sep 26 15:49:43 2008 +0200
1455
1456 Applying Gentoos dosfstools-2.11-build.patch from Mike Frysinger
1457 <vapier@gentoo.org> to improve Makefile:
1458
1459 * Respect user settings #157785/#157786 by Diego Petteno.
1460
1461 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
1462
1463 commit 251626d
1464 Author: Daniel Baumann <mail@daniel-baumann.ch>
1465 Date: Fri Sep 26 15:37:34 2008 +0200
1466
1467 Applying Gentoos dosfstools-2.11-verify-double-count-fix.patch from
1468 Robin H. Johnson <robbat2@gentoo.org> to fix double count of files
1469 during verification:
1470
1471 * Don't double-count n_files during a verification pass.
1472 Bugzilla: http://bugs.gentoo.org/show_bug.cgi?id=99845
1473
1474 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
1475
1476 commit e670ea8
1477 Author: Daniel Baumann <mail@daniel-baumann.ch>
1478 Date: Fri Sep 26 15:33:36 2008 +0200
1479
1480 Applying Gentoos dosfstools-2.11-fat32size.patch from Mike Frysinger
1481 <vapier@gentoo.org> to fix generation of filesystems on 256meg devices:
1482
1483 * Fix generation of FAT filesystems on devices that are 256meg in size
1484 Patch by Ulrich Mueller and accepted upstream
1485 http://bugs.gentoo.org/112504
1486
1487 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
1488
1489 commit a6dc6a4
1490 Author: Daniel Baumann <mail@daniel-baumann.ch>
1491 Date: Fri Sep 26 15:22:06 2008 +0200
1492
1493 Applying Suses dosfstools-2.11-unsupported-sector-size.patch from Petr
1494 Gajdos <pgajdos@suse.cz> to add sector size warning:
1495
1496 * added warning for creation msdos on filesystem with sector size
1497 greater than 4096 [fate#303325]
1498
1499 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
1500
1501 commit f746956
1502 Author: Daniel Baumann <mail@daniel-baumann.ch>
1503 Date: Fri Sep 26 15:18:35 2008 +0200
1504
1505 Applying Suses dosfstools-2.11-mkdosfs-geo0.diff from Ludwig Nussel
1506 <lnussel@suse.de> to fix handling of zero heads and sectors:
1507
1508 * the HDIO_GETGEO ioctl works on device mapper devices but returns
1509 zero heads and sectors. Therefore let's a) assume dummy values in
1510 that case in mkdosfs and b) don't consider such fat file systems as
1511 invalid in dosfsck. The Linux kernel accepts them anyways.
1512
1513 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
1514
1515 commit cf243e4
1516 Author: Daniel Baumann <mail@daniel-baumann.ch>
1517 Date: Fri Sep 26 15:15:40 2008 +0200
1518
1519 Applying Suses dosfstools-2.11-linuxfs.patch from Ruediger Oertel
1520 <ro@suse.de> to not include linux/fs.h.
1521
1522 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
1523
1524 commit 2d4f184
1525 Author: Daniel Baumann <mail@daniel-baumann.ch>
1526 Date: Fri Sep 26 15:11:50 2008 +0200
1527
1528 Applying Fedoras dosfstools-2.11-assumeKernel26.patch from Peter Vrabec
1529 <pvrabec@redhat.com> to remove linux 2.6 conditionals:
1530
1531 * LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0) does not work with
1532 glibc-kernheaders-2.4-9.1.94
1533
1534 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
1535
1536 commit 739a6fb
1537 Author: Daniel Baumann <mail@daniel-baumann.ch>
1538 Date: Fri Sep 26 15:05:00 2008 +0200
1539
1540 Applying Debians 99-conglomeration.dpatch (no other information
1541 available).
1542
1543 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
1544
1545 commit 3b5ed8a
1546 Author: Daniel Baumann <mail@daniel-baumann.ch>
1547 Date: Fri Sep 26 14:26:41 2008 +0200
1548
1549 Applying Debians 15-manpage-files.dpatch from Daniel Baumann
1550 <daniel@debian.org> to improve dosfsck manpage:
1551
1552 * Lists fsckNNNN.rec files in FILES section (Closes: #444596).
1553
1554 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
1555
1556 commit 3b6a863
1557 Author: Daniel Baumann <mail@daniel-baumann.ch>
1558 Date: Fri Sep 26 14:34:42 2008 +0200
1559
1560 Applying Debians 13-getopt.dpatch from Adonikam Virgo
1561 <adonikam@virgonet.org> to fix mkdosfs getopt:
1562
1563 * Fixes backup sector getopt (Closes: #232387, #479794).
1564
1565 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
1566
1567 commit 1b2c8ca
1568 Author: Daniel Baumann <mail@daniel-baumann.ch>
1569 Date: Fri Sep 26 14:34:17 2008 +0200
1570
1571 Applying Debians 12-zero-slot.dpatch by Karl Tomlinson
1572 <karlt@karlt.net> to fix dosfsck zero slot crashes:
1573
1574 * Fixes crashes due to zero slot numbers causing a negative offset in
1575 the call to copy_lfn_part in lfn_add_slot. On amd64 this results in
1576 a SIGSEGV in copy_lfn_part. On x86 the result is heap corruption and
1577 thus sometimes a SIGSEGV or double free abort later. (Closes:
1578 #152550, #353198, #356377, #401798).
1579
1580 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
1581
1582 commit eec8585
1583 Author: Daniel Baumann <mail@daniel-baumann.ch>
1584 Date: Fri Sep 26 14:33:54 2008 +0200
1585
1586 Applying Debians 11-memory-efficiency.dpatch from Eero Tamminen
1587 <eero.tamminen@nokia.com> to improve dosfsck memory efficiency:
1588
1589 * Improves memory efficiency when checking filesystems.
1590
1591 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
1592
1593 commit 06bd669
1594 Author: Daniel Baumann <mail@daniel-baumann.ch>
1595 Date: Fri Sep 26 14:33:28 2008 +0200
1596
1597 Applying Debians 10-manpage-synopsis.dpatch from Daniel Baumann
1598 <daniel@debian.org> to fix manpage synopsis:
1599
1600 * List alternative binary names in manpage synopsis (Closes: #284983).
1601
1602 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
1603
1604 commit 42d340d
1605 Author: Daniel Baumann <mail@daniel-baumann.ch>
1606 Date: Fri Sep 26 14:32:46 2008 +0200
1607
1608 Applying Debians 09-manpage-fat32.dpatch from Daniel Baumann
1609 <daniel@debian.org> to improve mkdosfs manpage:
1610
1611 * Don't claim that FAT32 is not choosed automatically (Closes:
1612 #414183).
1613
1614 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
1615
1616 commit 0f5ce0d
1617 Author: Daniel Baumann <mail@daniel-baumann.ch>
1618 Date: Fri Sep 26 14:32:23 2008 +0200
1619
1620 Applying Debians 08-manpage-drop.dpatch from Daniel Baumann
1621 <daniel@debian.org> to improve dosfsck manpage:
1622
1623 * Don't use confusing word 'drop' when 'delete' is meant (Closes:
1624 #134100).
1625
1626 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
1627
1628 commit 8ec54dd
1629 Author: Daniel Baumann <mail@daniel-baumann.ch>
1630 Date: Fri Sep 26 14:31:50 2008 +0200
1631
1632 Applying Debians 07-manpage-spelling.dpatch from Justin Pryzby
1633 <justinpryzby@users.sourceforge.net> to fix mkdosfs manpage typos.
1634
1635 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
1636
1637 commit 4371588
1638 Author: Daniel Baumann <mail@daniel-baumann.ch>
1639 Date: Fri Sep 26 14:30:31 2008 +0200
1640
1641 Applying Suses dosfstools-2.11_determine-sector-size.patch from Petr
1642 Gajdos <pgajdos@suse.cz> to determine mkdosfs sector size automatically:
1643
1644 * determine sector size of device automatically or if -S parameter
1645 present, verify, that it's not under physical sector size
1646
1647 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
1648
1649 commit fc92e19
1650 Author: Daniel Baumann <mail@daniel-baumann.ch>
1651 Date: Fri Sep 26 14:30:03 2008 +0200
1652
1653 Applying Suses dosfstools-2.11-o_excl.patch from Pavol Rusnak
1654 <prusnak@suse.cz> to use O_EXCL in mkdosfs:
1655
1656 * mkdosfs now opens device with O_EXCL [#238687]
1657
1658 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
1659
1660 commit 3084697
1661 Author: Daniel Baumann <mail@daniel-baumann.ch>
1662 Date: Fri Sep 26 14:29:36 2008 +0200
1663
1664 Applying Debians 04-unaligned-memory.dpatch from Khalid Aziz
1665 <khalid_aziz@hp.com> to fix dosfsck unaligned memory accesses:
1666
1667 * Fix unaligned memory accesses which cause warnings to appear
1668 everytime the elilo bootloader script runs. This has led a number of
1669 users to believe their install has failed (Closes: #258839).
1670
1671 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
1672
1673 commit 6d5c091
1674 Author: Daniel Baumann <mail@daniel-baumann.ch>
1675 Date: Fri Sep 26 13:47:40 2008 +0200
1676
1677 Applying Fedoras dosfstools-2.11-label.patch from Jeremy Katz
1678 <katzj@redhat.com> to add dosfslabel (originally by Peter Jones).
1679
1680 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
1681
1682 commit 07ef487
1683 Author: Daniel Baumann <mail@daniel-baumann.ch>
1684 Date: Fri Sep 26 13:41:14 2008 +0200
1685
1686 Applying Fedoras dosfstools-2.11-fortify.patch from Jakub Jelinek
1687 <jakub@redhat.com> to make it build with -D_FORTIFY_SOURCE=2:
1688
1689 * This violates -D_FORTIFY_SOURCE=2 (which is stricter than C
1690 standard), but isn't actually any buffer overflow. But using memcpy
1691 is more efficient anyway.
1692
1693 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
1694
1695 commit 78f9dca
1696 Author: Daniel Baumann <mail@daniel-baumann.ch>
1697 Date: Fri Sep 26 13:40:47 2008 +0200
1698
1699 Applying Fedoras dosfstools-2.7-argfix.patch (no other information
1700 available).
1701
1702 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
1703
1704 commit ba6774a (tag: v2.11)
1705 Author: Daniel Baumann <mail@daniel-baumann.ch>
1706 Date: Thu Jun 26 12:45:36 2008 +0200
1707
1708 Adding version 2.11.
1709
1710 Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
0 # Makefile
1 #
2 # Copyright (C) 2008-2014 Daniel Baumann <mail@daniel-baumann.ch>
3 #
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 #
17 # The complete text of the GNU General Public License
18 # can be found in /usr/share/common-licenses/GPL-3 file.
19
20 SHELL := sh -e
21 LANGUAGES = $(shell cd manpages/po && ls)
22
23 DESTDIR =
24 PREFIX = /usr/local
25 SBINDIR = $(PREFIX)/sbin
26 DOCDIR = $(PREFIX)/share/doc
27 MANDIR = $(PREFIX)/share/man
28
29 #OPTFLAGS = -O2 -fomit-frame-pointer -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
30 OPTFLAGS = -O2 -fomit-frame-pointer -D_GNU_SOURCE $(shell getconf LFS_CFLAGS)
31 #WARNFLAGS = -Wall -pedantic -std=c99
32 WARNFLAGS = -Wall -Wextra -Wno-sign-compare -Wno-missing-field-initializers -Wmissing-prototypes -Wstrict-prototypes
33 DEBUGFLAGS = -g
34 CFLAGS += $(OPTFLAGS) $(WARNFLAGS) $(DEBUGFLAGS)
35
36 VPATH = src
37
38 all: build
39
40 build: fatlabel fsck.fat mkfs.fat
41
42 fatlabel: boot.o check.o common.o fat.o file.o io.o lfn.o charconv.o fatlabel.o
43
44 fsck.fat: boot.o check.o common.o fat.o file.o io.o lfn.o charconv.o fsck.fat.o
45
46 mkfs.fat: mkfs.fat.o
47
48 rebuild: distclean build
49
50 install: install-bin install-doc install-man install-symlinks
51
52 install-bin: build
53 install -d -m 0755 $(DESTDIR)/$(SBINDIR)
54 install -m 0755 fatlabel fsck.fat mkfs.fat $(DESTDIR)/$(SBINDIR)
55
56 install-doc:
57 install -d -m 0755 $(DESTDIR)/$(DOCDIR)/dosfstools
58 install -p -m 0644 ChangeLog doc/* $(DESTDIR)/$(DOCDIR)/dosfstools
59
60 install-man:
61 for MANPAGE in manpages/en/*; \
62 do \
63 SECTION="8"; \
64 install -D -m 0644 $${MANPAGE} $(DESTDIR)/$(MANDIR)/man$${SECTION}/$$(basename $${MANPAGE}); \
65 done
66
67 for LANGUAGE in $(LANGUAGES); \
68 do \
69 for MANPAGE in manpages/$${LANGUAGE}/*; \
70 do \
71 SECTION="8"; \
72 install -D -m 0644 $${MANPAGE} $(DESTDIR)/$(MANDIR)/$${LANGUAGE}/man$${SECTION}/$$(basename $${MANPAGE} .$${LANGUAGE}.$${SECTION}).$${SECTION}; \
73 done; \
74 done
75 install-symlinks: install-bin install-man
76 if [ -e $(DESTDIR)/$(SBINDIR)/fatlabel ]; \
77 then \
78 ln -sf fatlabel $(DESTDIR)/$(SBINDIR)/dosfslabel; \
79 if [ -e $(DESTDIR)/$(MANDIR)/man8/fatlabel.8 ]; \
80 then \
81 ln -sf fatlabel.8 $(DESTDIR)/$(MANDIR)/man8/dosfslabel.8; \
82 fi; \
83 fi
84
85 if [ -e $(DESTDIR)/$(SBINDIR)/fsck.fat ]; \
86 then \
87 ln -sf fsck.fat $(DESTDIR)/$(SBINDIR)/dosfsck; \
88 ln -sf fsck.fat $(DESTDIR)/$(SBINDIR)/fsck.msdos; \
89 ln -sf fsck.fat $(DESTDIR)/$(SBINDIR)/fsck.vfat; \
90 if [ -e $(DESTDIR)/$(MANDIR)/man8/fsck.fat.8 ]; \
91 then \
92 ln -sf fsck.fat.8 $(DESTDIR)/$(MANDIR)/man8/dosfsck.8; \
93 ln -sf fsck.fat.8 $(DESTDIR)/$(MANDIR)/man8/fsck.msdos.8; \
94 ln -sf fsck.fat.8 $(DESTDIR)/$(MANDIR)/man8/fsck.vfat.8; \
95 fi; \
96 fi
97
98 if [ -e $(DESTDIR)/$(SBINDIR)/mkfs.fat ]; \
99 then \
100 ln -sf mkfs.fat $(DESTDIR)/$(SBINDIR)/mkdosfs; \
101 ln -sf mkfs.fat $(DESTDIR)/$(SBINDIR)/mkfs.msdos; \
102 ln -sf mkfs.fat $(DESTDIR)/$(SBINDIR)/mkfs.vfat; \
103 if [ -e $(DESTDIR)/$(MANDIR)/man8/mkfs.fat.8 ]; \
104 then \
105 ln -sf mkfs.fat.8 $(DESTDIR)/$(MANDIR)/man8/mkdosfs.8; \
106 ln -sf mkfs.fat.8 $(DESTDIR)/$(MANDIR)/man8/mkfs.msdos.8; \
107 ln -sf mkfs.fat.8 $(DESTDIR)/$(MANDIR)/man8/mkfs.vfat.8; \
108 fi; \
109 fi
110
111 uninstall: uninstall-symlinks uninstall-man uninstall-doc uninstall-bin
112
113 uninstall-bin:
114 rm -f $(DESTDIR)/$(SBINDIR)/fatlabel
115 rm -f $(DESTDIR)/$(SBINDIR)/fsck.fat
116 rm -f $(DESTDIR)/$(SBINDIR)/mkfs.fat
117
118 rmdir --ignore-fail-on-non-empty $(DESTDIR)/$(SBINDIR)
119
120 uninstall-doc:
121 rm -rf $(DESTDIR)/$(DOCDIR)/dosfstools
122
123 rmdir --ignore-fail-on-non-empty $(DESTDIR)/$(DOCDIR)
124
125 uninstall-man:
126 for MANPAGE in manpages/en/*; \
127 do \
128 SECTION="8"; \
129 rm -f $(DESTDIR)/$(MANDIR}/man$${SECTION}/$$(basename $${MANPAGE} .en.$${SECTION}).$${SECTION}; \
130 done
131
132 for LANGUAGE in $(LANGUAGES); \
133 do \
134 for MANPAGE in manpages/$${LANGUAGE}/*; \
135 do \
136 SECTION="8"; \
137 rm -f $(DESTDIR)/$(MANDIR)/$${LANGUAGE}/man$${SECTION}/$$(basename $${MANPAGE} .$${LANGUAGE}.$${SECTION}).$${SECTION}; \
138 done; \
139 done
140
141 uninstall-symlinks:
142 rm -f $(DESTDIR)/$(SBINDIR)/dosfslabel
143 rm -f $(DESTDIR)/$(MANDIR)/man8/dosfslabel.8
144
145 rm -f $(DESTDIR)/$(SBINDIR)/dosfsck
146 rm -f $(DESTDIR)/$(MANDIR)/man8/dosfsck.8
147 rm -f $(DESTDIR)/$(SBINDIR)/fsck.msdos
148 rm -f $(DESTDIR)/$(MANDIR)/man8/fsck.msdos.8
149 rm -f $(DESTDIR)/$(SBINDIR)/fsck.vfat
150 rm -f $(DESTDIR)/$(MANDIR)/man8/fsck.vfat.8
151
152 rm -f $(DESTDIR)/$(SBINDIR)/mkdosfs
153 rm -f $(DESTDIR)/$(MANDIR)/man8/mkdosfs.8
154 rm -f $(DESTDIR)/$(SBINDIR)/mkfs.msdos
155 rm -f $(DESTDIR)/$(MANDIR)/man8/mkfs.msdos.8
156 rm -f $(DESTDIR)/$(SBINDIR)/mkfs.vfat
157 rm -f $(DESTDIR)/$(MANDIR)/man8/mkfs.vfat.8
158
159 reinstall: distclean install
160
161 clean:
162 rm -f *.o
163
164 distclean: clean
165 rm -f fatlabel fsck.fat mkfs.fat
166
167 .PHONY: build rebuild install install-bin install-doc install-man install-symlinks uninstall uninstall-bin uninstall-doc uninstall-man uninstall-symlinks reinstall clean distclean
0 3.0.26
0 #!/bin/sh
1 PARAM="-npro -kr -i4 -ts8 -sob -l80 -ss -ncs -cp1"
2 RES=`indent --version`
3 V1=`echo $RES | cut -d' ' -f3 | cut -d'.' -f1`
4 V2=`echo $RES | cut -d' ' -f3 | cut -d'.' -f2`
5 V3=`echo $RES | cut -d' ' -f3 | cut -d'.' -f3`
6 if [ $V1 -gt 2 ]; then
7 PARAM="$PARAM -il0"
8 elif [ $V1 -eq 2 ]; then
9 if [ $V2 -gt 2 ]; then
10 PARAM="$PARAM -il0";
11 elif [ $V2 -eq 2 ]; then
12 if [ $V3 -ge 10 ]; then
13 PARAM="$PARAM -il0"
14 fi
15 fi
16 fi
17 exec indent $PARAM "$@"
0 Announcing the release of mkdosfs version 0.3b (Yggdrasil)
1
2 It seems I didn't get the bug completely fixed in 0.3a. Some
3 borderline cases would still allocate too many sectors for the FAT.
4 Again, nothing to worry about, just a nitpick -- this one would only
5 in certain cases add one sector per FAT.
6
7 Announcing the release of mkdosfs version 0.3a (Yggdrasil)
8
9 Fixed a bug which would cause too many sectors to be reserved for the
10 FAT (filesystem will still work fine, but have slightly less space
11 available).
12
13 Announcing the release of mkdosfs version 0.3 (Yggdrasil)
14
15 This version correctly handles even very large filesystems, and
16 properly supports the modern (3.3+) DOS bootsector format, including a
17 message printed on boot attempts.
18
19 Peter Anvin
20 Yggdrasil Computing, Inc.
21 hpa@yggdrasil.com
22
23 --------------
24
25 Announcing the release of mkdosfs version 0.2
26
27
28 I've just uploaded mkdosfs to sunsite.unc.edu. It works in a similar way
29 to Remy Card's mke2fs, but creates an MS-DOS filesystem.
30
31 The filename is mkdosfs-0.2.tar.gz.
32
33 This second release should fix a small bug that could lead to FAT sizes that
34 Linux's dosfs would accept but MS-DOS wouldn't.
35
36 The archive contains a manual page, binary and source versions.
37
38
39 Dave Hudson
40 dave@humbug.demon.co.uk
0 Changes from version 0 to 1
1 ===========================
2
3 - fixed an off-by-two error in check.c:check_file
4 - fixed marking clusters bad in fat.c:set_fat
5 - fat.c:reclaim_free was also reclaiming bad clusters.
6 - fixed many incorrect byte sex conversions in check.c and fat.c
7 - -t and -w now require -a or -r
8 - added option -d to drop files.
9 - added option -u to try to "undelete" non-directory files.
0 version 2.11
1 ============
2
3 - all: don't use own llseek() anymore, glibc lseek() does everything we need
4 - dosfsck: lfn.c: avoid segfault
5 - dosfsck: check.c, lfn.c: check for orphaned LFN slots
6 - dosfsck: check.c alloc_rootdir_entry(): set owner of newly alloced clusters
7 - dosfsck: dosfsck.h: better use <byteswap.h> for byte swapping
8 - dosfsck: io.c: added code for real DOS
9 - mkdosfs: raised FAT12_THRESHOLD from 4078 to 4085, introduced MIN_CLUST_32
10 - mkdosfs: fix loop device size
11 - mkdosfs: by default, use FAT32 on devices >= 512MB
12 - mkdosfs: fix a memory leak (blank_sector)
13 - mkdosfs: fix parsing of number of blocks on command line, so that numbers
14 >2G can be used
15 - mkdosfs: add 'b' to getopt() string so this option can be used :)
16 - mkdosfs: fix parsing of -i arg (should be unsigned)
17 - mkdosfs: change default permissions of created images (-C) to 0666 & ~umask
18 - mkdosfs: relax geometry check: if HDIO_GETGEO fails, print a warning and
19 default to H=255,S=63
20 - dosfsck: new option -n (no-op): just check non-interactively, but
21 don't write anything to filesystem
22 - A few #include changes to support compilation with linux 2.6
23 headers (thanks to Jim Gifford <jim@jg555.com>)
24 - dosfsck: remove directory entries pointing to start cluster 0, if they're
25 not "." or ".." entries that should actually point to the root dir
26 (pointed out by Thomas Winkler <twinkler@sysgo.de>)
27 - mkdosfs: new option -h to set number of hidden sectors
28 (thanks to Godwin Stewart <gstewart@spamcop.net>)
29 - all: updated my mail address everywhere...
30
31 version 2.10
32 ============
33
34 - dosfsck: various 64-bit fixes and removed some warnings by Michal
35 Cihar <mcihar@suse.cz>
36 - mkdosfs: better error message if called without parameters (also
37 suggested by Michal)
38
39 version 2.9
40 ===========
41
42 - dosfsck: if EOF from stdin, exit with error code
43 - dosfsck: Fix potential for "Internal error: next_cluster on bad cluster".
44 - dosfsck: When clearing long file names, don't overwrite the dir
45 entries with all zeros, but put 0xe5 into the first byte.
46 Otherwise, some OSes stop reading the directory at that point...
47 - dosfsck: in statistics printed by -v, fix 32bit overflow in number
48 of data bytes.
49 - dosfsck: fix an potential overflow in "too many clusters" check
50 - dosfsck: fix 64bit problem in fat.c (Debian bug #152769)
51 - dosfsck: allow FAT size > 32MB.
52 - dosfsck: allow for only one FAT
53 - dosfsck: with -v, also check that last sector of the filesystem can
54 be read (in case a partition is smaller than the fs thinks)
55 - mkdosfs: add note in manpage that creating bootable filesystems is
56 not supported.
57 - mkdosfs: better error message with pointer to -I if target is a
58 full-disk device.
59
60 version 2.8
61 ===========
62
63 - dosfsck: Fixed endless loop whenever a volume label was present.
64
65 version 2.7
66 ===========
67
68 - dosfsck: Don't check volume label for bad characters, everything
69 seems to be allowed there... Also ignore duplicate names where one of
70 them is a volume label.
71
72 version 2.6
73 ===========
74
75 - mkdosfs: Added correct heads definition for 2.88M floppies if not
76 created via loopback.
77 - dosfsck: If boot sector and its backup are different (FAT32), offer
78 to write the backup to sector 0. (tnx to Pavel Roskin for this)
79 - For 64 bit alpha, struct bootsector in dosfsck.h must be defined
80 with __attribute__((packed)).
81 - mkdosfs now actually accepts -R option. (tnx to David Kerrawn)
82 - Fixed typo in dosfsck boot.c (recognition of boot signature in FSINFO)
83 - Various compilation fixes for 2.4 kernel headers and for ia64.
84
85 version 2.5
86 ===========
87
88 - The llseek() implementation for alpha didn't really work; fixed it.
89
90 version 2.4
91 ===========
92
93 - Fix compiling problem on alpha (made a silly typo...)
94
95 version 2.3
96 ===========
97
98 - mkdosfs: Fixed usage message (printed only "bad address").
99 - both: made man pages and usage statements more consistent.
100 - both: fix llseek function for alpha.
101 - dosfsck: fix reading of unaligned fields in boot sector for alpha.
102 - dosfsck: fixed renaming of files (extension wasn't really written).
103
104 version 2.2
105 ===========
106
107 - Added dosfsck/COPYING, putting dosfsck officially under GPL (Werner
108 and I agree that it should be GPL).
109 - mkdosfs: Allow creation of a 16 bit FAT on filesystems that are too
110 small for it if the user explicitly selected FAT16 (but a warning
111 is printed). Formerly, you got the misleading error message "make
112 the fs a bit smaller".
113 - dosfsck: new option -y as synonym for -y; for compability with
114 other fs checkers, which also accept this option.
115 - dosfsck: Now prints messages similar to e2fsck: at start version
116 and feature list; at end number of files (and directories) and
117 number of used/total clusters. This makes the printouts of *fsck at
118 boot time nicer.
119 - dosfsck: -a (auto repair) now turns on -f (salvage files), too. -a
120 should act as non-destructive as possible, so lost clusters should
121 be assigned to files. Otherwise the data in them might be
122 overwritten later.
123 - dosfsck: Don't drop a directory with lots of bad entries in
124 auto-repair mode for the same reason as above.
125 - dosfsck: avoid deleting the whole FAT32 root dir if something is
126 wrong with it (bad start cluster or the like).
127 - general: also create symlinks {mkfs,fsck}.vfat.8 to the respective
128 real man pages.
129
130 version 2.1
131 ===========
132
133 - Fix some forgotten loff_t's for filesystems > 4GB. (Thanks to
134 <ki@kretz.co.at>).
135 - Fix typo in mkdosfs manpage.
136 - Removed inclusion of <linux/loop.h> from mkdosfs.c; it's unnecessary and
137 caused problems in some environments.
138 - Fix condition when to expect . and .. entries in a directory. (Was
139 wrong for non-FAT32 if first entry in root dir was a directory also.)
140 - Also create mkfs.vfat and fsck.vfat symlinks, so that also
141 filesystems listed with type "vfat" in /etc/fstab can be
142 automatically checked.
143
144 version 2.0
145 ===========
146
147 - merge of mkdosfs and dosfstools in one package
148 - new maintainer: Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de>
149 - FAT32 support in both mkdosfs and dosfsck
150 - VFAT (long filename) support in dosfsck
151 - Support for Atari variant of MS-DOS filesystem in both tools
152 - Working support for big-endian systems in both tools
153 - Better support for loop devices in mkdosfs: usual floppy sizes are
154 detected and media byte etc. set accordingly; if loop fs has no
155 standard floppy size, use hd params
156 (mainly by Giuliano Procida <gpp10@cus.cam.ac.uk>)
157 - Removed lots of gcc warnings
158 - Fixed some minor calculation bugs in mkdosfs.
159
160 For change logs previous to 2.0, see the CHANGES files in the subdirectories.
0 28th January 1995 H. Peter Anvin (hpa@yggdrasil.com)
1
2 Better algorithm to select cluster sizes on large filesystems.
3 Added bogus boot sector code that on attempts to boot prints a
4 message (which can be chosen at mkdosfs time) and lets the user
5 press any key and try again. Corrected support for 1.2 Mb
6 floppies. mkdosfs now generates the extended bootsector
7 (superblock) format of DOS 3.3+, with support for volume ID's and
8 volume labels (volume labels are also written to the root
9 directory, as they should).
10
11 18th February 1994 Dave Hudson (dave@humbug.demon.co.uk)
12
13 Released version 0.2 - clears a bug in the FAT sizing code.
14
15 1st September 1993 Dave Hudson (dave@humbug.demon.co.uk)
16
17 Released version 0.1 - ALPHA release of mkdosfs
0 dosfsck, version 1
1 ==================
2
3 WARNING: This is ALPHA test software. Use at your own risk.
4
5 dosfsck is the Linux equivalent of PC/MS-DOS' CHKDSK. It checks the
6 consistency of PC/MS-DOS filesystems and optionally tries to repair
7 them. The tests dosfsck performs are described in the man page.
8
9 dosfsck needs header files from dosfs.9 (or later) to compile.
10
11 Before using dosfsck to repair a filesystem that contains data of any
12 value, you should verify that dosfsck is able to correct all reported
13 errors. (Except fatal errors and those reported as unfixable, of
14 course.) In order to do this, run it with the -V option, e.g.
15
16 dosfsck -V /dev/sda1 (automatic check)
17 or dosfsck -V -r /dev/sda1 (interactive check and repair)
18
19 dosfsck will perform two passes: in the first pass, inconsistencies are
20 detected and a list of changes to correct the problems is generated. In
21 the second pass, those changes are applied whenever dosfsck reads data
22 from disk. Hence no fixable errors should be reported in the second
23 pass if the first pass was successful.
24
25 Please notify the author if fixable errors are reported in the second
26 pass.
27
28 After verifying that dosfsck appears to be able to perform the desired
29 operations, either confirm that you want the changes to be performed
30 (if dosfsck was started with -r) or re-run dosfsck with the -a option
31 (if it was started without -r).
32
33 Please send bug reports, comments, flames, etc. to
34 almesber@nessie.cs.id.ethz.ch or almesber@bernina.ethz.ch
35
36 - Werner
37
38 FAT32 and LFN support
39 =====================
40
41 I've finally implemented some of the new features of MS-DOS
42 filesystems: FAT32 and long filenames.
43
44 FAT32 is automatically detected and of course the different FAT
45 structure is handled. (Internally many changes were needed, so 32 bit
46 variables for all cluster numbers and 64 bit vars for offsets inside
47 the filesystem.) New checks for FAT32 are most notably on the backup
48 boot sector and the new info sector. Also the possibility that the
49 root directory resides in a cluster chain (instead of in a static
50 area) on FAT32 is handled.
51
52 dosfscheck also knows about VFAT long filenames now. It parses those
53 names and uses them in listings etc. when available. There are also
54 some checks on the (cruel) structure of how LFNs are stored and some
55 attempts to fix problems.
56
57 - Roman <roman@hodek.net>
58
59 BTW, version 2 isn't ALPHA anymore :-)
0
1 Atari format support
2 ====================
3
4 Both mkdosfs and dosfsck now can also handle the Atari variation of
5 the MS-DOS filesystem format. The Atari format has some minor
6 differences, some caused by the different machine architecture (m68k),
7 some being "historic" (Atari didn't change some things that M$
8 changed).
9
10 Both tools automatically select Atari format if they run on an Atari.
11 Additionally the -A switch toggles between Atari and MS-DOS format.
12 I.e., on an Atari it selects plain DOS format, on any other machine it
13 switches to Atari format.
14
15 The differences are in detail:
16
17 - Atari TOS doesn't like cluster sizes != 2, so the usual solution
18 for bigger partitions was to increase the logical sector size. So
19 mkdosfs can handle sector sizes != 512 now, you can also manually
20 select it with the -S option. On filesystems larger than approx. 32
21 MB, the sector size is automatically increased (stead of the
22 cluster size) to make the filesystem fit. mkdosfs will always use 2
23 sectors per cluster (also with the floppy standard configurations),
24 except when directed otherwise on the command line.
25
26 - From the docs, all values between 0xfff8 and 0xffff in the FAT mark
27 an end-of-file. However, DOS usually uses 0xfff8 and Atari 0xffff.
28 This seems to be only an consmetic difference. At least TOS doesn't
29 complain about 0xffff EOF marks. Don't know what DOS thinks of
30 0xfff8 :-) Anyway, both tools use the EOF mark common to the
31 system (DOS/Atari).
32
33 - Something similar of the bad cluster marks: On Atari the FAT values
34 0xfff0 to 0xfff7 are used for this, under DOS only 0xfff7 (the
35 others can be normal cluster numbers, allowing 7 more clusters :-)
36 However, both systems usually mark with 0xfff7. Just dosfsck has to
37 interpret 0xfff0...0xfff7 differently.
38
39 - Some fields in the boot sector are interpreted differently. For
40 example, Atari has a disk serial number (used to aid disk change
41 detection) where DOS stores the system name; the 'hidden' field is
42 32 bit for DOS, but 16 bit for Atari, and there's no 'total_sect'
43 field; the 12/16 bit FAT decision is different: it's not based on
44 the number of clusters, but always FAT12 on floppies and FAT16 on
45 hard disks. mkdosfs nows about these differences and constructs the
46 boot sector accordingly.
47
48 - In dosfsck, the boot sector differences also have to known, to not
49 warn about things that are no error on Atari. In addition, most
50 Atari formatting tools fill the 'tracks' and 'heads' fields with 0
51 for hard disks, because they're meaningless on SCSI disks (Atari
52 has/had no IDE). Due to this, the check that they should be
53 non-zero is switched off.
54
55 - Under Atari TOS, some other characters are illegal in filenames:
56 '<', '>', '|', '"', and ':' are allowed, but all non-ASCII chars
57 (codes >= 128) are forbidden.
58
59 - Roman <Roman.Hodek@informatik.uni-erlangen.de>
0 mkdosfs - Make DOS filesystem utilty.
1
2
3 I wrote this, partially to complement the dosfsck utility written by Werner
4 Almesberger (who graciously gave me some pointers when I asked for some
5 advice about writing this code), and also to avoid me having to boot DOS
6 just to create data partitions (I use Linux to back up DOS :-) ).
7
8 The code is really derived from Remy Card's mke2fs utility - I used this as a
9 framework, although all of the filesystem specific stuff was removed and the
10 DOS stuff inserted. I believe originally mke2fs was based on Linus' mkfs
11 code, hence the acknowledgements in the source code.
12
13 Neither Remy nor Linus have had any involvement with mkdosfs, so if there are
14 any bugs they're almost certainly "all my own work".
15
16 The code has been available for ftp since 1st September 1993, and I have yet
17 to receive any bug reports from users. I don't know of any bugs, but if you
18 do find a bug or have any constructive comments, please mail me!
19
20 The only bug I found with version 0.1 was an obscure fault that could lead
21 to an invalid (for MS-DOS, not Linux's dos fs) number of sectors used in the
22 file allocation table(s).
23
24
25 Dave Hudson
26 dave@humbug.demon.co.uk
27
28
29 FAT32 support
30 =============
31
32 mkdosfs now can also create filesystems in the new FAT32 format. To do
33 this, give mkdosfs a "-F 32" option. FAT32 isn't selected
34 automatically (yet), even if very large clusters are needed with
35 FAT16. With FAT32 you have two additional options, -R to select the
36 number of reserved sectors (usually 32), and -b to select the location
37 of the backup boot sector (default 6). Of course such a backup is
38 created, as well as the new info sector. On FAT32, the root directory
39 is always created as a cluster chain. Sorry, there's no switch to
40 generate an old static root dir.
41
42 One bigger bug fix besides FAT32 was to reject filesystems that need a
43 16 bit FAT to fit all possible clusters, but the bigger FAT needs some
44 more sectors, so the total number of clusters drop below the border
45 where MS-DOS expects a 12 bit FAT. So such filesystems would be FAT16,
46 but interpreted as FAT32 by DOS. The fix is to reduce filesystem size
47 a bit.
48
49 - Roman <roman@hodek.net>
0 -*- mode: indented-text -*-
1
2 - dosfsck: Better checking of file times: ctime <= mtime <= atime
3
4 - mkdosfs: If /etc/bootsect.dos (or similar) exists, use it as a
5 template for generating boot sectors. This way, you can, e.g., make
6 bootable DOS disks.
7
8 Addendum: Don't know if that's so wise... There are really many
9 variants of DOS/Windows bootcode out in the wild, and the code is
10 proprietary, too.
11
12 - dosfsck: read-only sector test (-t without -a or -r); just print
13 out errors.
0 # Makefile
1
2 ## dosfstools(7)
3 ## Copyright (C) 2006-2014 Daniel Baumann <mail@daniel-baumann.ch>
4 ##
5 ## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
6 ## This is free software, and you are welcome to redistribute it
7 ## under certain conditions; see COPYING for details.
8
9
10 SHELL := sh -e
11
12 LANGUAGES = $(shell cd po && ls)
13
14 all: build
15
16 po4a.cfg:
17 echo "[po4a_langs] $(LANGUAGES)" > po4a.cfg
18 echo "[po4a_paths] pot/\$$master.pot \$$lang:po/\$$lang/\$$master.po" >> po4a.cfg
19
20 for MANPAGE in en/*; \
21 do \
22 SECTION="$$(basename $${MANPAGE} | sed -e 's|\.|\n|g' | tail -n1)"; \
23 echo "[type: man] $${MANPAGE} \$$lang:\$$lang/$$(basename $${MANPAGE} .$${SECTION}).\$$lang.$${SECTION}" >> po4a.cfg; \
24 done
25
26 update:
27 ./bin/update-version.sh
28
29 build: po4a.cfg
30 @if [ ! -x "$$(which po4a 2>/dev/null)" ]; \
31 then \
32 echo "E: po4a - command not found"; \
33 echo "I: po4a can be obtained from:"; \
34 echo "I: http://po4a.alioth.debian.org/"; \
35 echo "I: On Debian based systems, po4a can be installed with:"; \
36 echo "I: apt-get install po4a"; \
37 exit 1; \
38 fi
39
40 po4a --keep 0 --no-backups --package-name dosfstools po4a.cfg
41
42 clean:
43 rm -rf $(LANGUAGES)
44
45 distclean: clean
46 rm -f po4a.cfg
47
48 rebuild: distclean update build
0 #!/bin/sh
1
2 ## dosfstools(7)
3 ## Copyright (C) 2006-2014 Daniel Baumann <mail@daniel-baumann.ch>
4 ##
5 ## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
6 ## This is free software, and you are welcome to redistribute it
7 ## under certain conditions; see COPYING for details.
8
9
10 set -e
11
12 PROJECT="dosfstools"
13 VERSION="$(cat ../VERSION)"
14
15 DATE="$(LC_ALL=C date +%Y\\\\-%m\\\\-%d)"
16
17 DAY="$(LC_ALL=C date +%d)"
18 MONTH="$(LC_ALL=C date +%m)"
19 YEAR="$(LC_ALL=C date +%Y)"
20
21 echo "Updating version headers..."
22
23 for MANPAGE in en/*
24 do
25 PROGRAM="$(basename ${MANPAGE} | sed -e 's|\(.*\).[0-9]$|\1|' | tr [a-z] [A-Z])"
26 SECTION="$(basename ${MANPAGE} | sed -e 's|.*.\([0-9]\)$|\1|')"
27
28 sed -i -e "s|^.TH.*$|.TH ${PROGRAM} ${SECTION} ${DATE} ${VERSION} \"${PROJECT}\"|" ${MANPAGE}
29 done
30
31 # European date format
32 for _LANGUAGE in de es fr it
33 do
34 if ls po/${_LANGUAGE}/*.po > /dev/null 2>&1
35 then
36 for _FILE in po/${_LANGUAGE}/*.po
37 do
38 sed -i -e "s|^msgstr .*.2014-.*$|msgstr \"${DAY}.${MONTH}.${YEAR}\"|g" \
39 -e "s|^msgstr .*.2014\"$|msgstr \"${DAY}.${MONTH}.${YEAR}\"|g" \
40 "${_FILE}"
41 done
42 fi
43 done
44
45 # Brazilian date format
46 if ls po/pt_BR/*.po > /dev/null 2>&1
47 then
48 for _FILE in po/pt_BR/*.po
49 do
50 sed -i -e "s|^msgstr .*.2014-.*$|msgstr \"${DAY}-${MONTH}-${YEAR}\"|g" \
51 -e "s|^msgstr .*-2014\"$|msgstr \"${DAY}-${MONTH}-${YEAR}\"|g" \
52 "${_FILE}"
53 done
54 fi
0 .\" fatlabel.8 - manpage for fatlabel
1 .\"
2 .\" Copyright (C) 2006-2014 Daniel Baumann <daniel@debian.org>
3 .\"
4 .\" This program is free software: you can redistribute it and/or modify
5 .\" it under the terms of the GNU General Public License as published by
6 .\" the Free Software Foundation, either version 3 of the License, or
7 .\" (at your option) any later version.
8 .\"
9 .\" This program is distributed in the hope that it will be useful,
10 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
11 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 .\" GNU General Public License for more details.
13 .\"
14 .\" You should have received a copy of the GNU General Public License
15 .\" along with this program. If not, see <http://www.gnu.org/licenses/>.
16 .\"
17 .\" The complete text of the GNU General Public License
18 .\" can be found in /usr/share/common-licenses/GPL-3 file.
19 .\"
20 .\"
21 .\"*******************************************************************
22 .\"
23 .\" This file was generated with po4a. Translate the source file.
24 .\"
25 .\"*******************************************************************
26 .TH FATLABEL 8 2014\-03\-07 3.0.26 dosfstools
27
28 .SH NAME
29 \fBfatlabel\fP \- set or get MS\-DOS filesystem label
30
31 .SH SYNOPSIS
32 \fBfatlabel\fP \fIDEVICE\fP [\fILABEL\fP]
33
34 .SH DESCRIPTION
35 \fBfatlabel\fP set or gets a MS\-DOS filesystem label from a given device.
36 .PP
37 If the label is omitted, then the label name of the specified device is
38 written on the standard output. A label can't be longer than 11 bytes.
39
40 .SH OPTIONS
41 .IP "\fB\-h\fP, \fB\-\-help\fP" 4
42 Displays a help message.
43 .IP "\fB\-V\fP, \fB\-\-version\fP" 4
44 Shows version.
45
46 .SH "SEE ALSO"
47 \fBfsck.fat\fP(8)
48 .br
49 \fBmkfs.fat\fP(8)
50
51 .SH HOMEPAGE
52 More information about \fBfatlabel\fP and \fBdosfstools\fP can be found at
53 <\fIhttp://daniel\-baumann.ch/software/dosfstools/\fP>.
54
55 .SH AUTHORS
56 \fBdosfstools\fP were written by Werner Almesberger
57 <\fIwerner.almesberger@lrc.di.epfl.ch\fP>, Roman Hodek
58 <\fIRoman.Hodek@informatik.uni\-erlangen.de\fP>, and others. The current
59 maintainer is Daniel Baumann <\fImail@daniel\-baumann.ch\fP>.
0 .\" fsck.fat.8 - manpage for fsck.fat
1 .\"
2 .\" Copyright (C) 2006-2014 Daniel Baumann <daniel@debian.org>
3 .\"
4 .\" This program is free software: you can redistribute it and/or modify
5 .\" it under the terms of the GNU General Public License as published by
6 .\" the Free Software Foundation, either version 3 of the License, or
7 .\" (at your option) any later version.
8 .\"
9 .\" This program is distributed in the hope that it will be useful,
10 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
11 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 .\" GNU General Public License for more details.
13 .\"
14 .\" You should have received a copy of the GNU General Public License
15 .\" along with this program. If not, see <http://www.gnu.org/licenses/>.
16 .\"
17 .\" The complete text of the GNU General Public License
18 .\" can be found in /usr/share/common-licenses/GPL-3 file.
19 .\"
20 .\"
21 .\"*******************************************************************
22 .\"
23 .\" This file was generated with po4a. Translate the source file.
24 .\"
25 .\"*******************************************************************
26 .TH FSCK.FAT 8 2014\-03\-07 3.0.26 dosfstools
27
28 .SH NAME
29 \fBfsck.fat\fP \- check and repair MS\-DOS filesystems
30
31 .SH SYNOPSIS
32 \fBfsck.fat\fP|\fBfsck.msdos\fP|\fBfsck.vfat\fP [\-aAflnprtvVwy] [\-d \fIPATH\fP \-d\ \&\fI...\fP] [\-u\ \fIPATH\fP \-u \fI...\fP] \fIDEVICE\fP
33
34 .SH DESCRIPTION
35 \fBfsck.fat\fP verifies the consistency of MS\-DOS filesystems and optionally
36 tries to repair them.
37 .PP
38 The following filesystem problems can be corrected (in this order):
39 .IP * 4
40 FAT contains invalid cluster numbers. Cluster is changed to EOF.
41 .IP * 4
42 File's cluster chain contains a loop. The loop is broken.
43 .IP * 4
44 Bad clusters (read errors). The clusters are marked bad and they are removed
45 from files owning them. This check is optional.
46 .IP * 4
47 Directories with a large number of bad entries (probably corrupt). The
48 directory can be deleted.
49 .IP * 4
50 Files . and .. are non\-directories. They can be deleted or renamed.
51 .IP * 4
52 Directories . and .. in root directory. They are deleted.
53 .IP * 4
54 Bad filenames. They can be renamed.
55 .IP * 4
56 Duplicate directory entries. They can be deleted or renamed.
57 .IP * 4
58 Directories with non\-zero size field. Size is set to zero.
59 .IP * 4
60 Directory . does not point to parent directory. The start pointer is
61 adjusted.
62 .IP * 4
63 Directory .. does not point to parent of parent directory. The start pointer
64 is adjusted.
65 .IP * 4
66 Start cluster number of a file is invalid. The file is truncated.
67 .IP * 4
68 File contains bad or free clusters. The file is truncated.
69 .IP * 4
70 File's cluster chain is longer than indicated by the size fields. The file
71 is truncated.
72 .IP * 4
73 Two or more files share the same cluster(s). All but one of the files are
74 truncated. If the file being truncated is a directory file that has already
75 been read, the filesystem check is restarted after truncation.
76 .IP * 4
77 File's cluster chain is shorter than indicated by the size fields. The file
78 is truncated.
79 .IP * 4
80 Clusters are marked as used but are not owned by a file. They are marked as
81 free.
82 .PP
83 Additionally, the following problems are detected, but not repaired:
84 .IP * 4
85 Invalid parameters in boot sector.
86 .IP * 4
87 Absence of . and .. entries in non\-root directories
88 .PP
89 When \fBfsck.fat\fP checks a filesystem, it accumulates all changes in memory
90 and performs them only after all checks are complete. This can be disabled
91 with the \fB\-w\fP option.
92
93 .SH OPTIONS
94 .IP \fB\-a\fP 4
95 Automatically repair the filesystem. No user intervention is
96 necessary. Whenever there is more than one method to solve a problem, the
97 least destructive approach is used.
98 .IP \fB\-A\fP 4
99 Use Atari variation of the MS\-DOS filesystem. This is default if \fBfsck.fat\fP
100 is run on an Atari, then this option turns off Atari format. There are some
101 minor differences in Atari format: Some boot sector fields are interpreted
102 slightly different, and the special FAT entries for end\-of\-file and bad
103 cluster can be different. Under MS\-DOS 0xfff8 is used for EOF and Atari
104 employs 0xffff by default, but both systems recognize all values from
105 0xfff8...0xffff as end\-of\-file. MS\-DOS uses only 0xfff7 for bad clusters,
106 where on Atari values 0xfff0...0xfff7 are for this purpose (but the standard
107 value is still 0xfff7).
108 .IP \fB\-b\fP 4
109 Make read\-only boot sector check.
110 .IP \fB\-d\fP 4
111 Delete the specified file. If more that one file with that name exists, the
112 first one is deleted.
113 .IP \fB\-f\fP 4
114 Salvage unused cluster chains to files. By default, unused clusters are
115 added to the free disk space except in auto mode (\fB\-a\fP).
116 .IP \fB\-l\fP 4
117 List path names of files being processed.
118 .IP \fB\-n\fP 4
119 No\-operation mode: non\-interactively check for errors, but don't write
120 anything to the filesystem.
121 .IP \fB\-p\fP 4
122 Same as (\fB\-a\fP), for compatibility with other *fsck.
123 .IP \fB\-r\fP 4
124 Interactively repair the filesystem. The user is asked for advice whenever
125 there is more than one approach to fix an inconsistency.
126 .IP \fB\-t\fP 4
127 Mark unreadable clusters as bad.
128 .IP \fB\-u\fP 4
129 Try to undelete the specified file. \fBfsck.fat\fP tries to allocate a chain of
130 contiguous unallocated clusters beginning with the start cluster of the
131 undeleted file.
132 .IP \fB\-v\fP 4
133 Verbose mode. Generates slightly more output.
134 .IP \fB\-V\fP 4
135 Perform a verification pass. The filesystem check is repeated after the
136 first run. The second pass should never report any fixable errors. It may
137 take considerably longer than the first pass, because the first pass may
138 have generated long list of modifications that have to be scanned for each
139 disk read.
140 .IP \fB\-w\fP 4
141 Write changes to disk immediately.
142 .IP \fB\-y\fP 4
143 Same as \fB\-a\fP (automatically repair filesystem) for compatibility with other
144 fsck tools.
145 .PP
146 \fBNote:\fP If \fB\-a\fP and \fB\-r\fP are absent, the filesystem is only checked, but
147 not repaired.
148
149 .SH "EXIT STATUS"
150 .IP 0 4
151 No recoverable errors have been detected.
152 .IP 1 4
153 Recoverable errors have been detected or \fBfsck.fat\fP has discovered an
154 internal inconsistency.
155 .IP 2 4
156 Usage error. \fBfsck.fat\fP did not access the filesystem.
157
158 .SH FILES
159 .IP "fsck0000.rec, fsck0001.rec, ..." 4
160 When recovering from a corrupted filesystem, \fBfsck.fat\fP dumps recovered
161 data into files named 'fsckNNNN.rec' in the top level directory of the
162 filesystem.
163
164 .SH BUGS
165 Does not create . and .. files where necessary. Does not remove entirely
166 empty directories. Should give more diagnostic messages. Undeleting files
167 should use a more sophisticated algorithm.
168
169 .SH "SEE ALSO"
170 \fBfatlabel\fP(8)
171 .br
172 \fBmkfs.fat\fP(8)
173
174 .SH HOMEPAGE
175 More information about \fBfsck.fat\fP and \fBdosfstools\fP can be found at
176 <\fIhttp://daniel\-baumann.ch/software/dosfstools/\fP>.
177
178 .SH AUTHORS
179 \fBdosfstools\fP were written by Werner Almesberger
180 <\fIwerner.almesberger@lrc.di.epfl.ch\fP>, Roman Hodek
181 <\fIRoman.Hodek@informatik.uni\-erlangen.de\fP>, and others. The current
182 maintainer is Daniel Baumann <\fImail@daniel\-baumann.ch\fP>.
0 .\" mkfs.fat.8 - manpage for fs.fatck
1 .\"
2 .\" Copyright (C) 2006-2014 Daniel Baumann <daniel@debian.org>
3 .\"
4 .\" This program is free software: you can redistribute it and/or modify
5 .\" it under the terms of the GNU General Public License as published by
6 .\" the Free Software Foundation, either version 3 of the License, or
7 .\" (at your option) any later version.
8 .\"
9 .\" This program is distributed in the hope that it will be useful,
10 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
11 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 .\" GNU General Public License for more details.
13 .\"
14 .\" You should have received a copy of the GNU General Public License
15 .\" along with this program. If not, see <http://www.gnu.org/licenses/>.
16 .\"
17 .\" The complete text of the GNU General Public License
18 .\" can be found in /usr/share/common-licenses/GPL-3 file.
19 .\"
20 .\"
21 .\"*******************************************************************
22 .\"
23 .\" This file was generated with po4a. Translate the source file.
24 .\"
25 .\"*******************************************************************
26 .TH MKFS.FAT 8 2014\-03\-07 3.0.26 dosfstools
27
28 .SH NAME
29 \fBmkfs.fat\fP \- create an MS\-DOS filesystem under Linux
30
31 .SH SYNOPSIS
32 \fBmkfs.fat\fP [\fB\-a\fP] [\fB\-A\fP] [\fB\-b\fP \fIsector\-of\-backup\fP] [\fB\-c\fP] [\fB\-l\fP
33 \fIfilename\fP] [\fB\-C\fP] [\fB\-f\fP \fInumber\-of\-FATs\fP] [\fB\-F\fP \fIFAT\-size] [\fP\fB\-h\fP
34 \fInumber\-of\-hidden\-sectors\fP] [\fB\-i\fP \fIvolume\-id\fP] [\fB\-I\fP] [\fB\-m\fP
35 \fImessage\-file\fP] [\fB\-n\fP \fIvolume\-name\fP] [\fB\-r\fP \fIroot\-dir\-entries\fP] [\fB\-R\fP
36 \fInumber\-of\-reserved\-sectors\fP] [\fB\-s\fP \fIsectors\-per\-cluster\fP] [\fB\-S
37 \fP\fIlogical\-sector\-size\fP] [\fB\-D\fP \fIdrive\-number\fP] [\fB\-M \fP\fIFAT\-media\-type\fP]
38 [\fB\-v\fP] \fIdevice\fP [\fIblock\-count\fP]
39
40 .SH DESCRIPTION
41 \fBmkfs.fat\fP is used to create an MS\-DOS filesystem under Linux on a device
42 (usually a disk partition). \fIdevice\fP is the special file corresponding to
43 the device (e.g /dev/sdXX). \fIblock\-count\fP is the number of blocks on the
44 device. If omitted, \fBmkfs.fat\fP automatically determines the filesystem
45 size.
46
47 .SH OPTIONS
48 .IP \fB\-a\fP 4
49 Normally, for any filesystem except very small ones, \fBmkfs.fat\fP will align
50 all the data structures to cluster size, to make sure that as long as the
51 partition is properly aligned, so will all the data structures in the
52 filesystem. This option disables alignment; this may provide a handful of
53 additional clusters of storage at the expense of a significant performance
54 degradation on RAIDs, flash media or large\-sector hard disks.
55 .IP "\fB \-A\fP" 4
56 Use Atari variation of the MS\-DOS filesystem. This is default if \fBmkfs.fat\fP
57 is run on an Atari, then this option turns off Atari format. There are some
58 differences when using Atari format: If not directed otherwise by the user,
59 \fBmkfs.fat\fP will always use 2 sectors per cluster, since GEMDOS doesn't like
60 other values very much. It will also obey the maximum number of sectors
61 GEMDOS can handle. Larger filesystems are managed by raising the logical
62 sector size. Under Atari format, an Atari\-compatible serial number for the
63 filesystem is generated, and a 12 bit FAT is used only for filesystems that
64 have one of the usual floppy sizes (720k, 1.2M, 1.44M, 2.88M), a 16 bit FAT
65 otherwise. This can be overridden with the \fB\-F\fP option. Some PC\-specific
66 boot sector fields aren't written, and a boot message (option \fB\-m\fP) is
67 ignored.
68 .IP "\fB\-b\fP \fIsector\-of\-backup\fP" 4
69 Selects the location of the backup boot sector for FAT32. Default depends on
70 number of reserved sectors, but usually is sector 6. The backup must be
71 within the range of reserved sectors.
72 .IP \fB\-c\fP 4
73 Check the device for bad blocks before creating the filesystem.
74 .IP \fB\-C\fP 4
75 Create the file given as \fIdevice\fP on the command line, and write the
76 to\-be\-created filesystem to it. This can be used to create the new
77 filesystem in a file instead of on a real device, and to avoid using \fBdd\fP
78 in advance to create a file of appropriate size. With this option, the
79 \fIblock\-count\fP must be given, because otherwise the intended size of the
80 filesystem wouldn't be known. The file created is a sparse file, which
81 actually only contains the meta\-data areas (boot sector, FATs, and root
82 directory). The data portions won't be stored on the disk, but the file
83 nevertheless will have the correct size. The resulting file can be copied
84 later to a floppy disk or other device, or mounted through a loop device.
85 .IP "\fB\-D\fP \fIdrive\-number\fP" 4
86 Specify the BIOS drive number to be stored in the FAT boot sector. This
87 value is usually 0x80 for hard disks and 0x00 for floppy devices or
88 partitions to be used for floppy emulation.
89 .IP "\fB\-f\fP \fInumber\-of\-FATs\fP" 4
90 Specify the number of file allocation tables in the filesystem. The default
91 is 2. Currently the Linux MS\-DOS filesystem does not support more than 2
92 FATs.
93 .IP "\fB\-F\fP \fIFAT\-size\fP" 4
94 Specifies the type of file allocation tables used (12, 16 or 32 bit). If
95 nothing is specified, \fBmkfs.fat\fP will automatically select between 12, 16
96 and 32 bit, whatever fits better for the filesystem size.
97 .IP "\fB\-h\fP \fInumber\-of\-hidden\-sectors\fP" 4
98 Select the number of hidden sectors in the volume. Apparently some digital
99 cameras get indigestion if you feed them a CF card without such hidden
100 sectors, this option allows you to satisfy them.
101 .IP "\fB\-i\fP \fIvolume\-id\fP" 4
102 Sets the volume ID of the newly created filesystem; \fIvolume\-id\fP is a 32\-bit
103 hexadecimal number (for example, 2e24ec82). The default is a number which
104 depends on the filesystem creation time.
105 .IP \fB\-I\fP 4
106 It is typical for fixed disk devices to be partitioned so, by default, you
107 are not permitted to create a filesystem across the entire
108 device. \fBmkfs.fat\fP will complain and tell you that it refuses to work. This
109 is different when using MO disks. One doesn't always need partitions on MO
110 disks. The filesystem can go directly to the whole disk. Under other OSes
111 this is known as the 'superfloppy' format. This switch will force
112 \fBmkfs.fat\fP to work properly.
113 .IP "\fB\-l\fP \fIfilename\fP" 4
114 Read the bad blocks list from \fIfilename\fP.
115 .IP "\fB\-m\fP \fImessage\-file\fP" 4
116 Sets the message the user receives on attempts to boot this filesystem
117 without having properly installed an operating system. The message file must
118 not exceed 418 bytes once line feeds have been converted to carriage
119 return\-line feed combinations, and tabs have been expanded. If the filename
120 is a hyphen (\-), the text is taken from standard input.
121 .IP "\fB\-M\fP \fIFAT\-media\-type\fP" 4
122 Specify the media type to be stored in the FAT boot sector. This value is
123 usually 0xF8 for hard disks and has a value from 0xF9 to 0xFF for floppies
124 or partitions to be used for floppy emulation.
125 .IP "\fB\-n\fP \fIvolume\-name\fP" 4
126 Sets the volume name (label) of the filesystem. The volume name can be up to
127 11 characters long. The default is no label.
128 .IP "\fB\-r\fP \fIroot\-dir\-entries\fP" 4
129 Select the number of entries available in the root directory. The default is
130 112 or 224 for floppies and 512 for hard disks.
131 .IP "\fB\-R\fP \fInumber\-of\-reserved\-sectors\fP" 4
132 Select the number of reserved sectors. With FAT32 format at least 2 reserved
133 sectors are needed, the default is 32. Otherwise the default is 1 (only the
134 boot sector).
135 .IP "\fB\-s\fP \fIsectors\-per\-cluster\fP" 4
136 Specify the number of disk sectors per cluster. Must be a power of 2,
137 i.e. 1, 2, 4, 8, ... 128.
138 .IP "\fB\-S\fP \fIlogical\-sector\-size\fP" 4
139 Specify the number of bytes per logical sector. Must be a power of 2 and
140 greater than or equal to 512, i.e. 512, 1024, 2048, 4096, 8192, 16384, or
141 32768.
142 .IP \fB\-v\fP 4
143 Verbose execution.
144
145 .SH BUGS
146 \fBmkfs.fat\fP can not create boot\-able filesystems. This isn't as easy as you
147 might think at first glance for various reasons and has been discussed a lot
148 already. \fBmkfs.fat\fP simply will not support it ;)
149
150 .SH "SEE ALSO"
151 \fBfatlabel\fP(8)
152 .br
153 \fBfsck.fat\fP(8)
154
155 .SH HOMEPAGE
156 More information about \fBfsck.fat\fP and \fBdosfstools\fP can be found at
157 <\fIhttp://daniel\-baumann.ch/software/dosfstools/\fP>.
158
159 .SH AUTHORS
160 \fBdosfstools\fP were written by Werner Almesberger
161 <\fIwerner.almesberger@lrc.di.epfl.ch\fP>, Roman Hodek
162 <\fIRoman.Hodek@informatik.uni\-erlangen.de\fP>, and others. The current
163 maintainer is Daniel Baumann <\fImail@daniel\-baumann.ch\fP>.
0 .\" fatlabel.8 - manpage for fatlabel
1 .\"
2 .\" Copyright (C) 2006-2014 Daniel Baumann <daniel@debian.org>
3 .\"
4 .\" This program is free software: you can redistribute it and/or modify
5 .\" it under the terms of the GNU General Public License as published by
6 .\" the Free Software Foundation, either version 3 of the License, or
7 .\" (at your option) any later version.
8 .\"
9 .\" This program is distributed in the hope that it will be useful,
10 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
11 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 .\" GNU General Public License for more details.
13 .\"
14 .\" You should have received a copy of the GNU General Public License
15 .\" along with this program. If not, see <http://www.gnu.org/licenses/>.
16 .\"
17 .\" The complete text of the GNU General Public License
18 .\" can be found in /usr/share/common-licenses/GPL-3 file.
19 .\"
20 .\"
21 .TH FATLABEL 8 2014\-03\-07 3.0.26 "dosfstools"
22
23 .SH NAME
24 \fBfatlabel\fR \- set or get MS\-DOS filesystem label
25
26 .SH SYNOPSIS
27 \fBfatlabel\fR \fIDEVICE\fR [\fILABEL\fR]
28
29 .SH DESCRIPTION
30 \fBfatlabel\fR set or gets a MS\-DOS filesystem label from a given device.
31 .PP
32 If the label is omitted, then the label name of the specified device is written on the standard output. A label can't be longer than 11 bytes.
33
34 .SH OPTIONS
35 .IP "\fB\-h\fR, \fB\-\-help\fR" 4
36 Displays a help message.
37 .IP "\fB\-V\fR, \fB\-\-version\fR" 4
38 Shows version.
39
40 .SH SEE ALSO
41 \fBfsck.fat\fR(8)
42 .br
43 \fBmkfs.fat\fR(8)
44
45 .SH HOMEPAGE
46 More information about \fBfatlabel\fR and \fBdosfstools\fR can be found at <\fIhttp://daniel\-baumann.ch/software/dosfstools/\fR>.
47
48 .SH AUTHORS
49 \fBdosfstools\fR were written by Werner Almesberger <\fIwerner.almesberger@lrc.di.epfl.ch\fR>, Roman Hodek <\fIRoman.Hodek@informatik.uni-erlangen.de\fR>, and others. The current maintainer is Daniel Baumann <\fImail@daniel-baumann.ch\fR>.
0 .\" fsck.fat.8 - manpage for fsck.fat
1 .\"
2 .\" Copyright (C) 2006-2014 Daniel Baumann <daniel@debian.org>
3 .\"
4 .\" This program is free software: you can redistribute it and/or modify
5 .\" it under the terms of the GNU General Public License as published by
6 .\" the Free Software Foundation, either version 3 of the License, or
7 .\" (at your option) any later version.
8 .\"
9 .\" This program is distributed in the hope that it will be useful,
10 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
11 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 .\" GNU General Public License for more details.
13 .\"
14 .\" You should have received a copy of the GNU General Public License
15 .\" along with this program. If not, see <http://www.gnu.org/licenses/>.
16 .\"
17 .\" The complete text of the GNU General Public License
18 .\" can be found in /usr/share/common-licenses/GPL-3 file.
19 .\"
20 .\"
21 .TH FSCK.FAT 8 2014\-03\-07 3.0.26 "dosfstools"
22
23 .SH NAME
24 \fBfsck.fat\fR \- check and repair MS\-DOS filesystems
25
26 .SH SYNOPSIS
27 \fBfsck.fat\fR|\fBfsck.msdos\fR|\fBfsck.vfat\fR [\-aAflnprtvVwy] [\-d \fIPATH\fR \-d\ \fI...\fR] [\-u\ \fIPATH\fR \-u \fI...\fR] \fIDEVICE\fR
28
29 .SH DESCRIPTION
30 \fBfsck.fat\fR verifies the consistency of MS\-DOS filesystems and optionally tries to repair them.
31 .PP
32 The following filesystem problems can be corrected (in this order):
33 .IP "*" 4
34 FAT contains invalid cluster numbers. Cluster is changed to EOF.
35 .IP "*" 4
36 File's cluster chain contains a loop. The loop is broken.
37 .IP "*" 4
38 Bad clusters (read errors). The clusters are marked bad and they are removed from files owning them. This check is optional.
39 .IP "*" 4
40 Directories with a large number of bad entries (probably corrupt). The directory can be deleted.
41 .IP "*" 4
42 Files . and .. are non\-directories. They can be deleted or renamed.
43 .IP "*" 4
44 Directories . and .. in root directory. They are deleted.
45 .IP "*" 4
46 Bad filenames. They can be renamed.
47 .IP "*" 4
48 Duplicate directory entries. They can be deleted or renamed.
49 .IP "*" 4
50 Directories with non\-zero size field. Size is set to zero.
51 .IP "*" 4
52 Directory . does not point to parent directory. The start pointer is adjusted.
53 .IP "*" 4
54 Directory .. does not point to parent of parent directory. The start pointer is adjusted.
55 .IP "*" 4
56 Start cluster number of a file is invalid. The file is truncated.
57 .IP "*" 4
58 File contains bad or free clusters. The file is truncated.
59 .IP "*" 4
60 File's cluster chain is longer than indicated by the size fields. The file is truncated.
61 .IP "*" 4
62 Two or more files share the same cluster(s). All but one of the files are truncated. If the file being truncated is a directory file that has already been read, the filesystem check is restarted after truncation.
63 .IP "*" 4
64 File's cluster chain is shorter than indicated by the size fields. The file is truncated.
65 .IP "*" 4
66 Clusters are marked as used but are not owned by a file. They are marked as free.
67 .PP
68 Additionally, the following problems are detected, but not repaired:
69 .IP "*" 4
70 Invalid parameters in boot sector.
71 .IP "*" 4
72 Absence of . and .. entries in non\-root directories
73 .PP
74 When \fBfsck.fat\fR checks a filesystem, it accumulates all changes in memory and performs them only after all checks are complete. This can be disabled with the \fB\-w\fR option.
75
76 .SH OPTIONS
77 .IP "\fB\-a\fR" 4
78 Automatically repair the filesystem. No user intervention is necessary. Whenever there is more than one method to solve a problem, the least destructive approach is used.
79 .IP "\fB\-A\fR" 4
80 Use Atari variation of the MS\-DOS filesystem. This is default if \fBfsck.fat\fR is run on an Atari, then this option turns off Atari format. There are some minor differences in Atari format: Some boot sector fields are interpreted slightly different, and the special FAT entries for end\-of\-file and bad cluster can be different. Under MS\-DOS 0xfff8 is used for EOF and Atari employs 0xffff by default, but both systems recognize all values from 0xfff8...0xffff as end\-of\-file. MS\-DOS uses only 0xfff7 for bad clusters, where on Atari values 0xfff0...0xfff7 are for this purpose (but the standard value is still 0xfff7).
81 .IP "\fB-b\fR" 4
82 Make read-only boot sector check.
83 .IP "\fB\-d\fR" 4
84 Delete the specified file. If more that one file with that name exists, the first one is deleted.
85 .IP "\fB\-f\fR" 4
86 Salvage unused cluster chains to files. By default, unused clusters are added to the free disk space except in auto mode (\fB\-a\fR).
87 .IP "\fB\-l\fR" 4
88 List path names of files being processed.
89 .IP "\fB\-n\fR" 4
90 No\-operation mode: non\-interactively check for errors, but don't write
91 anything to the filesystem.
92 .IP "\fB\-p\fR" 4
93 Same as (\fB\-a\fR), for compatibility with other *fsck.
94 .IP "\fB\-r\fR" 4
95 Interactively repair the filesystem. The user is asked for advice whenever
96 there is more than one approach to fix an inconsistency.
97 .IP "\fB\-t\fR" 4
98 Mark unreadable clusters as bad.
99 .IP "\fB\-u\fR" 4
100 Try to undelete the specified file. \fBfsck.fat\fR tries to allocate a chain of contiguous unallocated clusters beginning with the start cluster of the undeleted file.
101 .IP "\fB\-v\fR" 4
102 Verbose mode. Generates slightly more output.
103 .IP "\fB\-V\fR" 4
104 Perform a verification pass. The filesystem check is repeated after the first run. The second pass should never report any fixable errors. It may take considerably longer than the first pass, because the first pass may have generated long list of modifications that have to be scanned for each disk read.
105 .IP "\fB\-w\fR" 4
106 Write changes to disk immediately.
107 .IP "\fB\-y\fR" 4
108 Same as \fB\-a\fR (automatically repair filesystem) for compatibility with other fsck tools.
109 .PP
110 \fBNote:\fR If \fB\-a\fR and \fB\-r\fR are absent, the filesystem is only checked, but not repaired.
111
112 .SH "EXIT STATUS"
113 .IP "0" 4
114 No recoverable errors have been detected.
115 .IP "1" 4
116 Recoverable errors have been detected or \fBfsck.fat\fR has discovered an internal inconsistency.
117 .IP "2" 4
118 Usage error. \fBfsck.fat\fR did not access the filesystem.
119
120 .SH FILES
121 .IP "fsck0000.rec, fsck0001.rec, ..." 4
122 When recovering from a corrupted filesystem, \fBfsck.fat\fR dumps recovered data into files named 'fsckNNNN.rec' in the top level directory of the filesystem.
123
124 .SH BUGS
125 Does not create . and .. files where necessary. Does not remove entirely empty directories. Should give more diagnostic messages. Undeleting files should use a more sophisticated algorithm.
126
127 .SH SEE ALSO
128 \fBfatlabel\fR(8)
129 .br
130 \fBmkfs.fat\fR(8)
131
132 .SH HOMEPAGE
133 More information about \fBfsck.fat\fR and \fBdosfstools\fR can be found at <\fIhttp://daniel\-baumann.ch/software/dosfstools/\fR>.
134
135 .SH AUTHORS
136 \fBdosfstools\fR were written by Werner Almesberger <\fIwerner.almesberger@lrc.di.epfl.ch\fR>, Roman Hodek <\fIRoman.Hodek@informatik.uni-erlangen.de\fR>, and others. The current maintainer is Daniel Baumann <\fImail@daniel-baumann.ch\fR>.
0 .\" mkfs.fat.8 - manpage for fs.fatck
1 .\"
2 .\" Copyright (C) 2006-2014 Daniel Baumann <daniel@debian.org>
3 .\"
4 .\" This program is free software: you can redistribute it and/or modify
5 .\" it under the terms of the GNU General Public License as published by
6 .\" the Free Software Foundation, either version 3 of the License, or
7 .\" (at your option) any later version.
8 .\"
9 .\" This program is distributed in the hope that it will be useful,
10 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
11 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 .\" GNU General Public License for more details.
13 .\"
14 .\" You should have received a copy of the GNU General Public License
15 .\" along with this program. If not, see <http://www.gnu.org/licenses/>.
16 .\"
17 .\" The complete text of the GNU General Public License
18 .\" can be found in /usr/share/common-licenses/GPL-3 file.
19 .\"
20 .\"
21 .TH MKFS.FAT 8 2014\-03\-07 3.0.26 "dosfstools"
22
23 .SH NAME
24 \fBmkfs.fat\fR \- create an MS-DOS filesystem under Linux
25
26 .SH SYNOPSIS
27 \fBmkfs.fat\fR [\fB\-a\fR] [\fB\-A\fR] [\fB\-b\fR \fIsector-of-backup\fR] [\fB\-c\fR] [\fB\-l\fR \fIfilename\fR] [\fB\-C\fR] [\fB\-f\fR \fInumber-of-FATs\fR] [\fB\-F\fR \fIFAT-size] [\fB\-h\fR \fInumber-of-hidden-sectors\fR] [\fB\-i\fR \fIvolume-id\fR] [\fB\-I\fR] [\fB\-m\fR \fImessage-file\fR] [\fB\-n\fR \fIvolume-name\fR] [\fB\-r\fR \fIroot-dir-entries\fR] [\fB\-R\fR \fInumber-of-reserved-sectors\fR] [\fB\-s\fR \fIsectors-per-cluster\fR] [\fB\-S \fIlogical-sector-size\fR] [\fB\-D\fR \fIdrive-number\fR] [\fB\-M \fIFAT-media-type\fR] [\fB\-v\fR] \fIdevice\fR [\fIblock-count\fR]
28
29 .SH DESCRIPTION
30 \fBmkfs.fat\fR is used to create an MS-DOS filesystem under Linux on a device (usually a disk partition). \fIdevice\fR is the special file corresponding to the device (e.g /dev/sdXX). \fIblock-count\fR is the number of blocks on the device. If omitted, \fBmkfs.fat\fR automatically determines the filesystem size.
31
32 .SH OPTIONS
33 .IP "\fB\-a\fR" 4
34 Normally, for any filesystem except very small ones, \fBmkfs.fat\fR will align all the data structures to cluster size, to make sure that as long as the partition is properly aligned, so will all the data structures in the filesystem. This option disables alignment; this may provide a handful of additional clusters of storage at the expense of a significant performance degradation on RAIDs, flash media or large-sector hard disks.
35 .IP "\fB \-A\fR" 4
36 Use Atari variation of the MS-DOS filesystem. This is default if \fBmkfs.fat\fR is run on an Atari, then this option turns off Atari format. There are some differences when using Atari format: If not directed otherwise by the user, \fBmkfs.fat\fR will always use 2 sectors per cluster, since GEMDOS doesn't like other values very much. It will also obey the maximum number of sectors GEMDOS can handle. Larger filesystems are managed by raising the logical sector size. Under Atari format, an Atari-compatible serial number for the filesystem is generated, and a 12 bit FAT is used only for filesystems that have one of the usual floppy sizes (720k, 1.2M, 1.44M, 2.88M), a 16 bit FAT otherwise. This can be overridden with the \fB\-F\fR option. Some PC-specific boot sector fields aren't written, and a boot message (option \fB\-m\fR) is ignored.
37 .IP "\fB\-b\fR \fIsector-of-backup\fR" 4
38 Selects the location of the backup boot sector for FAT32. Default depends on number of reserved sectors, but usually is sector 6. The backup must be within the range of reserved sectors.
39 .IP "\fB\-c" 4
40 Check the device for bad blocks before creating the filesystem.
41 .IP "\fB\-C\fR" 4
42 Create the file given as \fIdevice\fR on the command line, and write the to-be-created filesystem to it. This can be used to create the new filesystem in a file instead of on a real device, and to avoid using \fBdd\fR in advance to create a file of appropriate size. With this option, the \fIblock-count\fR must be given, because otherwise the intended size of the filesystem wouldn't be known. The file created is a sparse file, which actually only contains the meta-data areas (boot sector, FATs, and root directory). The data portions won't be stored on the disk, but the file nevertheless will have the correct size. The resulting file can be copied later to a floppy disk or other device, or mounted through a loop device.
43 .IP "\fB\-D\fR \fIdrive-number\fR" 4
44 Specify the BIOS drive number to be stored in the FAT boot sector. This value is usually 0x80 for hard disks and 0x00 for floppy devices or partitions to be used for floppy emulation.
45 .IP "\fB\-f\fR \fInumber-of-FATs\fR" 4
46 Specify the number of file allocation tables in the filesystem. The default is 2. Currently the Linux MS-DOS filesystem does not support more than 2 FATs.
47 .IP "\fB\-F\fR \fIFAT-size\fR" 4
48 Specifies the type of file allocation tables used (12, 16 or 32 bit). If nothing is specified, \fBmkfs.fat\fR will automatically select between 12, 16 and 32 bit, whatever fits better for the filesystem size.
49 .IP "\fB\-h\fR \fInumber-of-hidden-sectors\fR" 4
50 Select the number of hidden sectors in the volume. Apparently some digital cameras get indigestion if you feed them a CF card without such hidden sectors, this option allows you to satisfy them.
51 .IP "\fB\-i\fR \fIvolume-id\fR" 4
52 Sets the volume ID of the newly created filesystem; \fIvolume-id\fR is a 32-bit hexadecimal number (for example, 2e24ec82). The default is a number which depends on the filesystem creation time.
53 .IP "\fB\-I\fR" 4
54 It is typical for fixed disk devices to be partitioned so, by default, you are not permitted to create a filesystem across the entire device. \fBmkfs.fat\fR will complain and tell you that it refuses to work. This is different when using MO disks. One doesn't always need partitions on MO disks. The filesystem can go directly to the whole disk. Under other OSes this is known as the 'superfloppy' format. This switch will force \fBmkfs.fat\fR to work properly.
55 .IP "\fB\-l\fR \fIfilename\fR" 4
56 Read the bad blocks list from \fIfilename\fR.
57 .IP "\fB\-m\fR \fImessage-file\fR" 4
58 Sets the message the user receives on attempts to boot this filesystem without having properly installed an operating system. The message file must not exceed 418 bytes once line feeds have been converted to carriage return-line feed combinations, and tabs have been expanded. If the filename is a hyphen (-), the text is taken from standard input.
59 .IP "\fB\-M\fR \fIFAT-media-type\fR" 4
60 Specify the media type to be stored in the FAT boot sector. This value is usually 0xF8 for hard disks and has a value from 0xF9 to 0xFF for floppies or partitions to be used for floppy emulation.
61 .IP "\fB\-n\fR \fIvolume-name\fR" 4
62 Sets the volume name (label) of the filesystem. The volume name can be up to 11 characters long. The default is no label.
63 .IP "\fB\-r\fR \fIroot-dir-entries\fR" 4
64 Select the number of entries available in the root directory. The default is 112 or 224 for floppies and 512 for hard disks.
65 .IP "\fB\-R\fR \fInumber-of-reserved-sectors\fR" 4
66 Select the number of reserved sectors. With FAT32 format at least 2 reserved sectors are needed, the default is 32. Otherwise the default is 1 (only the boot sector).
67 .IP "\fB\-s\fR \fIsectors-per-cluster\fR" 4
68 Specify the number of disk sectors per cluster. Must be a power of 2, i.e. 1, 2, 4, 8, ... 128.
69 .IP "\fB\-S\fR \fIlogical-sector-size\fR" 4
70 Specify the number of bytes per logical sector. Must be a power of 2 and greater than or equal to 512, i.e. 512, 1024, 2048, 4096, 8192, 16384, or 32768.
71 .IP "\fB\-v\fR" 4
72 Verbose execution.
73
74 .SH BUGS
75 \fBmkfs.fat\fR can not create boot-able filesystems. This isn't as easy as you might think at first glance for various reasons and has been discussed a lot already. \fBmkfs.fat\fR simply will not support it ;)
76
77 .SH SEE ALSO
78 \fBfatlabel\fR(8)
79 .br
80 \fBfsck.fat\fR(8)
81
82 .SH HOMEPAGE
83 More information about \fBfsck.fat\fR and \fBdosfstools\fR can be found at <\fIhttp://daniel\-baumann.ch/software/dosfstools/\fR>.
84
85 .SH AUTHORS
86 \fBdosfstools\fR were written by Werner Almesberger <\fIwerner.almesberger@lrc.di.epfl.ch\fR>, Roman Hodek <\fIRoman.Hodek@informatik.uni-erlangen.de\fR>, and others. The current maintainer is Daniel Baumann <\fImail@daniel-baumann.ch\fR>.
0 # German translations for dosfstools package
1 #
2 msgid ""
3 msgstr ""
4 "Project-Id-Version: dosfstools VERSION\n"
5 "POT-Creation-Date: 2014-03-07 18:39+0100\n"
6 "PO-Revision-Date: 2013-06-06 09:34+0300\n"
7 "Last-Translator: Automatically generated\n"
8 "Language-Team: none\n"
9 "Language: de\n"
10 "MIME-Version: 1.0\n"
11 "Content-Type: text/plain; charset=ASCII\n"
12 "Content-Transfer-Encoding: 8bit\n"
13 "Plural-Forms: nplurals=2; plural=(n != 1);\n"
14
15 #. type: TH
16 #: en/fatlabel.8:22
17 #, no-wrap
18 msgid "FATLABEL"
19 msgstr ""
20
21 #. type: TH
22 #: en/fatlabel.8:22 en/fsck.fat.8:22 en/mkfs.fat.8:22
23 #, no-wrap
24 msgid "2014-03-07"
25 msgstr ""
26
27 #. type: TH
28 #: en/fatlabel.8:22 en/fsck.fat.8:22 en/mkfs.fat.8:22
29 #, no-wrap
30 msgid "3.0.26"
31 msgstr ""
32
33 #. type: TH
34 #: en/fatlabel.8:22 en/fsck.fat.8:22 en/mkfs.fat.8:22
35 #, no-wrap
36 msgid "dosfstools"
37 msgstr ""
38
39 #. type: SH
40 #: en/fatlabel.8:24 en/fsck.fat.8:24 en/mkfs.fat.8:24
41 #, no-wrap
42 msgid "NAME"
43 msgstr ""
44
45 #. type: Plain text
46 #: en/fatlabel.8:26
47 msgid "B<fatlabel> - set or get MS-DOS filesystem label"
48 msgstr ""
49
50 #. type: SH
51 #: en/fatlabel.8:27 en/fsck.fat.8:27 en/mkfs.fat.8:27
52 #, no-wrap
53 msgid "SYNOPSIS"
54 msgstr ""
55
56 #. type: Plain text
57 #: en/fatlabel.8:29
58 msgid "B<fatlabel> I<DEVICE> [I<LABEL>]"
59 msgstr ""
60
61 #. type: SH
62 #: en/fatlabel.8:30 en/fsck.fat.8:30 en/mkfs.fat.8:30
63 #, no-wrap
64 msgid "DESCRIPTION"
65 msgstr ""
66
67 #. type: Plain text
68 #: en/fatlabel.8:32
69 msgid "B<fatlabel> set or gets a MS-DOS filesystem label from a given device."
70 msgstr ""
71
72 #. type: Plain text
73 #: en/fatlabel.8:34
74 msgid ""
75 "If the label is omitted, then the label name of the specified device is "
76 "written on the standard output. A label can't be longer than 11 bytes."
77 msgstr ""
78
79 #. type: SH
80 #: en/fatlabel.8:35 en/fsck.fat.8:77 en/mkfs.fat.8:33
81 #, no-wrap
82 msgid "OPTIONS"
83 msgstr ""
84
85 #. type: IP
86 #: en/fatlabel.8:36
87 #, no-wrap
88 msgid "B<-h>, B<--help>"
89 msgstr ""
90
91 #. type: Plain text
92 #: en/fatlabel.8:38
93 msgid "Displays a help message."
94 msgstr ""
95
96 #. type: IP
97 #: en/fatlabel.8:38
98 #, no-wrap
99 msgid "B<-V>, B<--version>"
100 msgstr ""
101
102 #. type: Plain text
103 #: en/fatlabel.8:40
104 msgid "Shows version."
105 msgstr ""
106
107 #. type: SH
108 #: en/fatlabel.8:41 en/fsck.fat.8:128 en/mkfs.fat.8:78
109 #, no-wrap
110 msgid "SEE ALSO"
111 msgstr ""
112
113 #. type: Plain text
114 #: en/fatlabel.8:43 en/mkfs.fat.8:82
115 msgid "B<fsck.fat>(8)"
116 msgstr ""
117
118 #. type: Plain text
119 #: en/fatlabel.8:45 en/fsck.fat.8:132
120 msgid "B<mkfs.fat>(8)"
121 msgstr ""
122
123 #. type: SH
124 #: en/fatlabel.8:46 en/fsck.fat.8:133 en/mkfs.fat.8:83
125 #, no-wrap
126 msgid "HOMEPAGE"
127 msgstr ""
128
129 #. type: Plain text
130 #: en/fatlabel.8:48
131 msgid ""
132 "More information about B<fatlabel> and B<dosfstools> can be found at "
133 "E<lt>I<http://daniel-baumann.ch/software/dosfstools/>E<gt>."
134 msgstr ""
135
136 #. type: SH
137 #: en/fatlabel.8:49 en/fsck.fat.8:136 en/mkfs.fat.8:86
138 #, no-wrap
139 msgid "AUTHORS"
140 msgstr ""
141
142 #. type: Plain text
143 #: en/fatlabel.8:50 en/fsck.fat.8:137 en/mkfs.fat.8:87
144 msgid ""
145 "B<dosfstools> were written by Werner Almesberger E<lt>I<werner."
146 "almesberger@lrc.di.epfl.ch>E<gt>, Roman Hodek E<lt>I<Roman.Hodek@informatik."
147 "uni-erlangen.de>E<gt>, and others. The current maintainer is Daniel Baumann "
148 "E<lt>I<mail@daniel-baumann.ch>E<gt>."
149 msgstr ""
0 # German translations for dosfstools package
1 #
2 msgid ""
3 msgstr ""
4 "Project-Id-Version: dosfstools VERSION\n"
5 "POT-Creation-Date: 2014-03-07 18:39+0100\n"
6 "PO-Revision-Date: 2013-06-06 09:34+0300\n"
7 "Last-Translator: Automatically generated\n"
8 "Language-Team: none\n"
9 "Language: de\n"
10 "MIME-Version: 1.0\n"
11 "Content-Type: text/plain; charset=ASCII\n"
12 "Content-Transfer-Encoding: 8bit\n"
13 "Plural-Forms: nplurals=2; plural=(n != 1);\n"
14
15 #. type: TH
16 #: en/fatlabel.8:22 en/fsck.fat.8:22 en/mkfs.fat.8:22
17 #, no-wrap
18 msgid "2014-03-07"
19 msgstr ""
20
21 #. type: TH
22 #: en/fatlabel.8:22 en/fsck.fat.8:22 en/mkfs.fat.8:22
23 #, no-wrap
24 msgid "3.0.26"
25 msgstr ""
26
27 #. type: TH
28 #: en/fatlabel.8:22 en/fsck.fat.8:22 en/mkfs.fat.8:22
29 #, no-wrap
30 msgid "dosfstools"
31 msgstr ""
32
33 #. type: SH
34 #: en/fatlabel.8:24 en/fsck.fat.8:24 en/mkfs.fat.8:24
35 #, no-wrap
36 msgid "NAME"
37 msgstr ""
38
39 #. type: SH
40 #: en/fatlabel.8:27 en/fsck.fat.8:27 en/mkfs.fat.8:27
41 #, no-wrap
42 msgid "SYNOPSIS"
43 msgstr ""
44
45 #. type: SH
46 #: en/fatlabel.8:30 en/fsck.fat.8:30 en/mkfs.fat.8:30
47 #, no-wrap
48 msgid "DESCRIPTION"
49 msgstr ""
50
51 #. type: SH
52 #: en/fatlabel.8:35 en/fsck.fat.8:77 en/mkfs.fat.8:33
53 #, no-wrap
54 msgid "OPTIONS"
55 msgstr ""
56
57 #. type: SH
58 #: en/fatlabel.8:41 en/fsck.fat.8:128 en/mkfs.fat.8:78
59 #, no-wrap
60 msgid "SEE ALSO"
61 msgstr ""
62
63 #. type: Plain text
64 #: en/fatlabel.8:45 en/fsck.fat.8:132
65 msgid "B<mkfs.fat>(8)"
66 msgstr ""
67
68 #. type: SH
69 #: en/fatlabel.8:46 en/fsck.fat.8:133 en/mkfs.fat.8:83
70 #, no-wrap
71 msgid "HOMEPAGE"
72 msgstr ""
73
74 #. type: SH
75 #: en/fatlabel.8:49 en/fsck.fat.8:136 en/mkfs.fat.8:86
76 #, no-wrap
77 msgid "AUTHORS"
78 msgstr ""
79
80 #. type: Plain text
81 #: en/fatlabel.8:50 en/fsck.fat.8:137 en/mkfs.fat.8:87
82 msgid ""
83 "B<dosfstools> were written by Werner Almesberger E<lt>I<werner."
84 "almesberger@lrc.di.epfl.ch>E<gt>, Roman Hodek E<lt>I<Roman.Hodek@informatik."
85 "uni-erlangen.de>E<gt>, and others. The current maintainer is Daniel Baumann "
86 "E<lt>I<mail@daniel-baumann.ch>E<gt>."
87 msgstr ""
88
89 #. type: TH
90 #: en/fsck.fat.8:22
91 #, no-wrap
92 msgid "FSCK.FAT"
93 msgstr ""
94
95 #. type: Plain text
96 #: en/fsck.fat.8:26
97 msgid "B<fsck.fat> - check and repair MS-DOS filesystems"
98 msgstr ""
99
100 #. type: Plain text
101 #: en/fsck.fat.8:29
102 msgid ""
103 "B<fsck.fat>|B<fsck.msdos>|B<fsck.vfat> [-aAflnprtvVwy] [-d I<PATH> -d\\ I<..."
104 ">] [-u\\ I<PATH> -u I<...>] I<DEVICE>"
105 msgstr ""
106
107 #. type: Plain text
108 #: en/fsck.fat.8:32
109 msgid ""
110 "B<fsck.fat> verifies the consistency of MS-DOS filesystems and optionally "
111 "tries to repair them."
112 msgstr ""
113
114 #. type: Plain text
115 #: en/fsck.fat.8:34
116 msgid "The following filesystem problems can be corrected (in this order):"
117 msgstr ""
118
119 #. type: IP
120 #: en/fsck.fat.8:34 en/fsck.fat.8:36 en/fsck.fat.8:38 en/fsck.fat.8:40
121 #: en/fsck.fat.8:42 en/fsck.fat.8:44 en/fsck.fat.8:46 en/fsck.fat.8:48
122 #: en/fsck.fat.8:50 en/fsck.fat.8:52 en/fsck.fat.8:54 en/fsck.fat.8:56
123 #: en/fsck.fat.8:58 en/fsck.fat.8:60 en/fsck.fat.8:62 en/fsck.fat.8:64
124 #: en/fsck.fat.8:66 en/fsck.fat.8:70 en/fsck.fat.8:72
125 #, no-wrap
126 msgid "*"
127 msgstr ""
128
129 #. type: Plain text
130 #: en/fsck.fat.8:36
131 msgid "FAT contains invalid cluster numbers. Cluster is changed to EOF."
132 msgstr ""
133
134 #. type: Plain text
135 #: en/fsck.fat.8:38
136 msgid "File's cluster chain contains a loop. The loop is broken."
137 msgstr ""
138
139 #. type: Plain text
140 #: en/fsck.fat.8:40
141 msgid ""
142 "Bad clusters (read errors). The clusters are marked bad and they are removed "
143 "from files owning them. This check is optional."
144 msgstr ""
145
146 #. type: Plain text
147 #: en/fsck.fat.8:42
148 msgid ""
149 "Directories with a large number of bad entries (probably corrupt). The "
150 "directory can be deleted."
151 msgstr ""
152
153 #. type: Plain text
154 #: en/fsck.fat.8:44
155 msgid "Files . and .. are non-directories. They can be deleted or renamed."
156 msgstr ""
157
158 #. type: Plain text
159 #: en/fsck.fat.8:46
160 msgid "Directories . and .. in root directory. They are deleted."
161 msgstr ""
162
163 #. type: Plain text
164 #: en/fsck.fat.8:48
165 msgid "Bad filenames. They can be renamed."
166 msgstr ""
167
168 #. type: Plain text
169 #: en/fsck.fat.8:50
170 msgid "Duplicate directory entries. They can be deleted or renamed."
171 msgstr ""
172
173 #. type: Plain text
174 #: en/fsck.fat.8:52
175 msgid "Directories with non-zero size field. Size is set to zero."
176 msgstr ""
177
178 #. type: Plain text
179 #: en/fsck.fat.8:54
180 msgid ""
181 "Directory . does not point to parent directory. The start pointer is "
182 "adjusted."
183 msgstr ""
184
185 #. type: Plain text
186 #: en/fsck.fat.8:56
187 msgid ""
188 "Directory .. does not point to parent of parent directory. The start pointer "
189 "is adjusted."
190 msgstr ""
191
192 #. type: Plain text
193 #: en/fsck.fat.8:58
194 msgid "Start cluster number of a file is invalid. The file is truncated."
195 msgstr ""
196
197 #. type: Plain text
198 #: en/fsck.fat.8:60
199 msgid "File contains bad or free clusters. The file is truncated."
200 msgstr ""
201
202 #. type: Plain text
203 #: en/fsck.fat.8:62
204 msgid ""
205 "File's cluster chain is longer than indicated by the size fields. The file "
206 "is truncated."
207 msgstr ""
208
209 #. type: Plain text
210 #: en/fsck.fat.8:64
211 msgid ""
212 "Two or more files share the same cluster(s). All but one of the files are "
213 "truncated. If the file being truncated is a directory file that has already "
214 "been read, the filesystem check is restarted after truncation."
215 msgstr ""
216
217 #. type: Plain text
218 #: en/fsck.fat.8:66
219 msgid ""
220 "File's cluster chain is shorter than indicated by the size fields. The file "
221 "is truncated."
222 msgstr ""
223
224 #. type: Plain text
225 #: en/fsck.fat.8:68
226 msgid ""
227 "Clusters are marked as used but are not owned by a file. They are marked as "
228 "free."
229 msgstr ""
230
231 #. type: Plain text
232 #: en/fsck.fat.8:70
233 msgid "Additionally, the following problems are detected, but not repaired:"
234 msgstr ""
235
236 #. type: Plain text
237 #: en/fsck.fat.8:72
238 msgid "Invalid parameters in boot sector."
239 msgstr ""
240
241 #. type: Plain text
242 #: en/fsck.fat.8:74
243 msgid "Absence of . and .. entries in non-root directories"
244 msgstr ""
245
246 #. type: Plain text
247 #: en/fsck.fat.8:76
248 msgid ""
249 "When B<fsck.fat> checks a filesystem, it accumulates all changes in memory "
250 "and performs them only after all checks are complete. This can be disabled "
251 "with the B<-w> option."
252 msgstr ""
253
254 #. type: IP
255 #: en/fsck.fat.8:78 en/mkfs.fat.8:34
256 #, no-wrap
257 msgid "B<-a>"
258 msgstr ""
259
260 #. type: Plain text
261 #: en/fsck.fat.8:80
262 msgid ""
263 "Automatically repair the filesystem. No user intervention is necessary. "
264 "Whenever there is more than one method to solve a problem, the least "
265 "destructive approach is used."
266 msgstr ""
267
268 #. type: IP
269 #: en/fsck.fat.8:80
270 #, no-wrap
271 msgid "B<-A>"
272 msgstr ""
273
274 #. type: Plain text
275 #: en/fsck.fat.8:82
276 msgid ""
277 "Use Atari variation of the MS-DOS filesystem. This is default if B<fsck.fat> "
278 "is run on an Atari, then this option turns off Atari format. There are some "
279 "minor differences in Atari format: Some boot sector fields are interpreted "
280 "slightly different, and the special FAT entries for end-of-file and bad "
281 "cluster can be different. Under MS-DOS 0xfff8 is used for EOF and Atari "
282 "employs 0xffff by default, but both systems recognize all values from "
283 "0xfff8...0xffff as end-of-file. MS-DOS uses only 0xfff7 for bad clusters, "
284 "where on Atari values 0xfff0...0xfff7 are for this purpose (but the standard "
285 "value is still 0xfff7)."
286 msgstr ""
287
288 #. type: IP
289 #: en/fsck.fat.8:82
290 #, no-wrap
291 msgid "B<-b>"
292 msgstr ""
293
294 #. type: Plain text
295 #: en/fsck.fat.8:84
296 msgid "Make read-only boot sector check."
297 msgstr ""
298
299 #. type: IP
300 #: en/fsck.fat.8:84
301 #, no-wrap
302 msgid "B<-d>"
303 msgstr ""
304
305 #. type: Plain text
306 #: en/fsck.fat.8:86
307 msgid ""
308 "Delete the specified file. If more that one file with that name exists, the "
309 "first one is deleted."
310 msgstr ""
311
312 #. type: IP
313 #: en/fsck.fat.8:86
314 #, no-wrap
315 msgid "B<-f>"
316 msgstr ""
317
318 #. type: Plain text
319 #: en/fsck.fat.8:88
320 msgid ""
321 "Salvage unused cluster chains to files. By default, unused clusters are "
322 "added to the free disk space except in auto mode (B<-a>)."
323 msgstr ""
324
325 #. type: IP
326 #: en/fsck.fat.8:88
327 #, no-wrap
328 msgid "B<-l>"
329 msgstr ""
330
331 #. type: Plain text
332 #: en/fsck.fat.8:90
333 msgid "List path names of files being processed."
334 msgstr ""
335
336 #. type: IP
337 #: en/fsck.fat.8:90
338 #, no-wrap
339 msgid "B<-n>"
340 msgstr ""
341
342 #. type: Plain text
343 #: en/fsck.fat.8:93
344 msgid ""
345 "No-operation mode: non-interactively check for errors, but don't write "
346 "anything to the filesystem."
347 msgstr ""
348
349 #. type: IP
350 #: en/fsck.fat.8:93
351 #, no-wrap
352 msgid "B<-p>"
353 msgstr ""
354
355 #. type: Plain text
356 #: en/fsck.fat.8:95
357 msgid "Same as (B<-a>), for compatibility with other *fsck."
358 msgstr ""
359
360 #. type: IP
361 #: en/fsck.fat.8:95
362 #, no-wrap
363 msgid "B<-r>"
364 msgstr ""
365
366 #. type: Plain text
367 #: en/fsck.fat.8:98
368 msgid ""
369 "Interactively repair the filesystem. The user is asked for advice whenever "
370 "there is more than one approach to fix an inconsistency."
371 msgstr ""
372
373 #. type: IP
374 #: en/fsck.fat.8:98
375 #, no-wrap
376 msgid "B<-t>"
377 msgstr ""
378
379 #. type: Plain text
380 #: en/fsck.fat.8:100
381 msgid "Mark unreadable clusters as bad."
382 msgstr ""
383
384 #. type: IP
385 #: en/fsck.fat.8:100
386 #, no-wrap
387 msgid "B<-u>"
388 msgstr ""
389
390 #. type: Plain text
391 #: en/fsck.fat.8:102
392 msgid ""
393 "Try to undelete the specified file. B<fsck.fat> tries to allocate a chain of "
394 "contiguous unallocated clusters beginning with the start cluster of the "
395 "undeleted file."
396 msgstr ""
397
398 #. type: IP
399 #: en/fsck.fat.8:102 en/mkfs.fat.8:72
400 #, no-wrap
401 msgid "B<-v>"
402 msgstr ""
403
404 #. type: Plain text
405 #: en/fsck.fat.8:104
406 msgid "Verbose mode. Generates slightly more output."
407 msgstr ""
408
409 #. type: IP
410 #: en/fsck.fat.8:104
411 #, no-wrap
412 msgid "B<-V>"
413 msgstr ""
414
415 #. type: Plain text
416 #: en/fsck.fat.8:106
417 msgid ""
418 "Perform a verification pass. The filesystem check is repeated after the "
419 "first run. The second pass should never report any fixable errors. It may "
420 "take considerably longer than the first pass, because the first pass may "
421 "have generated long list of modifications that have to be scanned for each "
422 "disk read."
423 msgstr ""
424
425 #. type: IP
426 #: en/fsck.fat.8:106
427 #, no-wrap
428 msgid "B<-w>"
429 msgstr ""
430
431 #. type: Plain text
432 #: en/fsck.fat.8:108
433 msgid "Write changes to disk immediately."
434 msgstr ""
435
436 #. type: IP
437 #: en/fsck.fat.8:108
438 #, no-wrap
439 msgid "B<-y>"
440 msgstr ""
441
442 #. type: Plain text
443 #: en/fsck.fat.8:110
444 msgid ""
445 "Same as B<-a> (automatically repair filesystem) for compatibility with other "
446 "fsck tools."
447 msgstr ""
448
449 #. type: Plain text
450 #: en/fsck.fat.8:112
451 msgid ""
452 "B<Note:> If B<-a> and B<-r> are absent, the filesystem is only checked, but "
453 "not repaired."
454 msgstr ""
455
456 #. type: SH
457 #: en/fsck.fat.8:113
458 #, no-wrap
459 msgid "EXIT STATUS"
460 msgstr ""
461
462 #. type: IP
463 #: en/fsck.fat.8:114
464 #, no-wrap
465 msgid "0"
466 msgstr ""
467
468 #. type: Plain text
469 #: en/fsck.fat.8:116
470 msgid "No recoverable errors have been detected."
471 msgstr ""
472
473 #. type: IP
474 #: en/fsck.fat.8:116
475 #, no-wrap
476 msgid "1"
477 msgstr ""
478
479 #. type: Plain text
480 #: en/fsck.fat.8:118
481 msgid ""
482 "Recoverable errors have been detected or B<fsck.fat> has discovered an "
483 "internal inconsistency."
484 msgstr ""
485
486 #. type: IP
487 #: en/fsck.fat.8:118
488 #, no-wrap
489 msgid "2"
490 msgstr ""
491
492 #. type: Plain text
493 #: en/fsck.fat.8:120
494 msgid "Usage error. B<fsck.fat> did not access the filesystem."
495 msgstr ""
496
497 #. type: SH
498 #: en/fsck.fat.8:121
499 #, no-wrap
500 msgid "FILES"
501 msgstr ""
502
503 #. type: IP
504 #: en/fsck.fat.8:122
505 #, no-wrap
506 msgid "fsck0000.rec, fsck0001.rec, ..."
507 msgstr ""
508
509 #. type: Plain text
510 #: en/fsck.fat.8:124
511 msgid ""
512 "When recovering from a corrupted filesystem, B<fsck.fat> dumps recovered "
513 "data into files named 'fsckNNNN.rec' in the top level directory of the "
514 "filesystem."
515 msgstr ""
516
517 #. type: SH
518 #: en/fsck.fat.8:125 en/mkfs.fat.8:75
519 #, no-wrap
520 msgid "BUGS"
521 msgstr ""
522
523 #. type: Plain text
524 #: en/fsck.fat.8:127
525 msgid ""
526 "Does not create . and .. files where necessary. Does not remove entirely "
527 "empty directories. Should give more diagnostic messages. Undeleting files "
528 "should use a more sophisticated algorithm."
529 msgstr ""
530
531 #. type: Plain text
532 #: en/fsck.fat.8:130 en/mkfs.fat.8:80
533 msgid "B<fatlabel>(8)"
534 msgstr ""
535
536 #. type: Plain text
537 #: en/fsck.fat.8:135 en/mkfs.fat.8:85
538 msgid ""
539 "More information about B<fsck.fat> and B<dosfstools> can be found at "
540 "E<lt>I<http://daniel-baumann.ch/software/dosfstools/>E<gt>."
541 msgstr ""
0 # German translations for dosfstools package
1 #
2 msgid ""
3 msgstr ""
4 "Project-Id-Version: dosfstools VERSION\n"
5 "POT-Creation-Date: 2014-03-07 18:39+0100\n"
6 "PO-Revision-Date: 2013-06-06 09:34+0300\n"
7 "Last-Translator: Automatically generated\n"
8 "Language-Team: none\n"
9 "Language: de\n"
10 "MIME-Version: 1.0\n"
11 "Content-Type: text/plain; charset=ASCII\n"
12 "Content-Transfer-Encoding: 8bit\n"
13 "Plural-Forms: nplurals=2; plural=(n != 1);\n"
14
15 #. type: TH
16 #: en/fatlabel.8:22 en/fsck.fat.8:22 en/mkfs.fat.8:22
17 #, no-wrap
18 msgid "2014-03-07"
19 msgstr ""
20
21 #. type: TH
22 #: en/fatlabel.8:22 en/fsck.fat.8:22 en/mkfs.fat.8:22
23 #, no-wrap
24 msgid "3.0.26"
25 msgstr ""
26
27 #. type: TH
28 #: en/fatlabel.8:22 en/fsck.fat.8:22 en/mkfs.fat.8:22
29 #, no-wrap
30 msgid "dosfstools"
31 msgstr ""
32
33 #. type: SH
34 #: en/fatlabel.8:24 en/fsck.fat.8:24 en/mkfs.fat.8:24
35 #, no-wrap
36 msgid "NAME"
37 msgstr ""
38
39 #. type: SH
40 #: en/fatlabel.8:27 en/fsck.fat.8:27 en/mkfs.fat.8:27
41 #, no-wrap
42 msgid "SYNOPSIS"
43 msgstr ""
44
45 #. type: SH
46 #: en/fatlabel.8:30 en/fsck.fat.8:30 en/mkfs.fat.8:30
47 #, no-wrap
48 msgid "DESCRIPTION"
49 msgstr ""
50
51 #. type: SH
52 #: en/fatlabel.8:35 en/fsck.fat.8:77 en/mkfs.fat.8:33
53 #, no-wrap
54 msgid "OPTIONS"
55 msgstr ""
56
57 #. type: SH
58 #: en/fatlabel.8:41 en/fsck.fat.8:128 en/mkfs.fat.8:78
59 #, no-wrap
60 msgid "SEE ALSO"
61 msgstr ""
62
63 #. type: Plain text
64 #: en/fatlabel.8:43 en/mkfs.fat.8:82
65 msgid "B<fsck.fat>(8)"
66 msgstr ""
67
68 #. type: SH
69 #: en/fatlabel.8:46 en/fsck.fat.8:133 en/mkfs.fat.8:83
70 #, no-wrap
71 msgid "HOMEPAGE"
72 msgstr ""
73
74 #. type: SH
75 #: en/fatlabel.8:49 en/fsck.fat.8:136 en/mkfs.fat.8:86
76 #, no-wrap
77 msgid "AUTHORS"
78 msgstr ""
79
80 #. type: Plain text
81 #: en/fatlabel.8:50 en/fsck.fat.8:137 en/mkfs.fat.8:87
82 msgid ""
83 "B<dosfstools> were written by Werner Almesberger E<lt>I<werner."
84 "almesberger@lrc.di.epfl.ch>E<gt>, Roman Hodek E<lt>I<Roman.Hodek@informatik."
85 "uni-erlangen.de>E<gt>, and others. The current maintainer is Daniel Baumann "
86 "E<lt>I<mail@daniel-baumann.ch>E<gt>."
87 msgstr ""
88
89 #. type: IP
90 #: en/fsck.fat.8:78 en/mkfs.fat.8:34
91 #, no-wrap
92 msgid "B<-a>"
93 msgstr ""
94
95 #. type: IP
96 #: en/fsck.fat.8:102 en/mkfs.fat.8:72
97 #, no-wrap
98 msgid "B<-v>"
99 msgstr ""
100
101 #. type: SH
102 #: en/fsck.fat.8:125 en/mkfs.fat.8:75
103 #, no-wrap
104 msgid "BUGS"
105 msgstr ""
106
107 #. type: Plain text
108 #: en/fsck.fat.8:130 en/mkfs.fat.8:80
109 msgid "B<fatlabel>(8)"
110 msgstr ""
111
112 #. type: Plain text
113 #: en/fsck.fat.8:135 en/mkfs.fat.8:85
114 msgid ""
115 "More information about B<fsck.fat> and B<dosfstools> can be found at "
116 "E<lt>I<http://daniel-baumann.ch/software/dosfstools/>E<gt>."
117 msgstr ""
118
119 #. type: TH
120 #: en/mkfs.fat.8:22
121 #, no-wrap
122 msgid "MKFS.FAT"
123 msgstr ""
124
125 #. type: Plain text
126 #: en/mkfs.fat.8:26
127 msgid "B<mkfs.fat> - create an MS-DOS filesystem under Linux"
128 msgstr ""
129
130 #. type: Plain text
131 #: en/mkfs.fat.8:29
132 msgid ""
133 "B<mkfs.fat> [B<-a>] [B<-A>] [B<-b> I<sector-of-backup>] [B<-c>] [B<-l> "
134 "I<filename>] [B<-C>] [B<-f> I<number-of-FATs>] [B<-F> I<FAT-size] [>B<-h> "
135 "I<number-of-hidden-sectors>] [B<-i> I<volume-id>] [B<-I>] [B<-m> I<message-"
136 "file>] [B<-n> I<volume-name>] [B<-r> I<root-dir-entries>] [B<-R> I<number-of-"
137 "reserved-sectors>] [B<-s> I<sectors-per-cluster>] [B<-S >I<logical-sector-"
138 "size>] [B<-D> I<drive-number>] [B<-M >I<FAT-media-type>] [B<-v>] I<device> "
139 "[I<block-count>]"
140 msgstr ""
141
142 #. type: Plain text
143 #: en/mkfs.fat.8:32
144 msgid ""
145 "B<mkfs.fat> is used to create an MS-DOS filesystem under Linux on a device "
146 "(usually a disk partition). I<device> is the special file corresponding to "
147 "the device (e.g /dev/sdXX). I<block-count> is the number of blocks on the "
148 "device. If omitted, B<mkfs.fat> automatically determines the filesystem size."
149 msgstr ""
150
151 #. type: Plain text
152 #: en/mkfs.fat.8:36
153 msgid ""
154 "Normally, for any filesystem except very small ones, B<mkfs.fat> will align "
155 "all the data structures to cluster size, to make sure that as long as the "
156 "partition is properly aligned, so will all the data structures in the "
157 "filesystem. This option disables alignment; this may provide a handful of "
158 "additional clusters of storage at the expense of a significant performance "
159 "degradation on RAIDs, flash media or large-sector hard disks."
160 msgstr ""
161
162 #. type: IP
163 #: en/mkfs.fat.8:36
164 #, no-wrap
165 msgid "B< -A>"
166 msgstr ""
167
168 #. type: Plain text
169 #: en/mkfs.fat.8:38
170 msgid ""
171 "Use Atari variation of the MS-DOS filesystem. This is default if B<mkfs.fat> "
172 "is run on an Atari, then this option turns off Atari format. There are some "
173 "differences when using Atari format: If not directed otherwise by the user, "
174 "B<mkfs.fat> will always use 2 sectors per cluster, since GEMDOS doesn't like "
175 "other values very much. It will also obey the maximum number of sectors "
176 "GEMDOS can handle. Larger filesystems are managed by raising the logical "
177 "sector size. Under Atari format, an Atari-compatible serial number for the "
178 "filesystem is generated, and a 12 bit FAT is used only for filesystems that "
179 "have one of the usual floppy sizes (720k, 1.2M, 1.44M, 2.88M), a 16 bit FAT "
180 "otherwise. This can be overridden with the B<-F> option. Some PC-specific "
181 "boot sector fields aren't written, and a boot message (option B<-m>) is "
182 "ignored."
183 msgstr ""
184
185 #. type: IP
186 #: en/mkfs.fat.8:38
187 #, no-wrap
188 msgid "B<-b> I<sector-of-backup>"
189 msgstr ""
190
191 #. type: Plain text
192 #: en/mkfs.fat.8:40
193 msgid ""
194 "Selects the location of the backup boot sector for FAT32. Default depends on "
195 "number of reserved sectors, but usually is sector 6. The backup must be "
196 "within the range of reserved sectors."
197 msgstr ""
198
199 #. type: IP
200 #: en/mkfs.fat.8:40
201 #, no-wrap
202 msgid "B<-c>"
203 msgstr ""
204
205 #. type: Plain text
206 #: en/mkfs.fat.8:42
207 msgid "Check the device for bad blocks before creating the filesystem."
208 msgstr ""
209
210 #. type: IP
211 #: en/mkfs.fat.8:42
212 #, no-wrap
213 msgid "B<-C>"
214 msgstr ""
215
216 #. type: Plain text
217 #: en/mkfs.fat.8:44
218 msgid ""
219 "Create the file given as I<device> on the command line, and write the to-be-"
220 "created filesystem to it. This can be used to create the new filesystem in a "
221 "file instead of on a real device, and to avoid using B<dd> in advance to "
222 "create a file of appropriate size. With this option, the I<block-count> must "
223 "be given, because otherwise the intended size of the filesystem wouldn't be "
224 "known. The file created is a sparse file, which actually only contains the "
225 "meta-data areas (boot sector, FATs, and root directory). The data portions "
226 "won't be stored on the disk, but the file nevertheless will have the correct "
227 "size. The resulting file can be copied later to a floppy disk or other "
228 "device, or mounted through a loop device."
229 msgstr ""
230
231 #. type: IP
232 #: en/mkfs.fat.8:44
233 #, no-wrap
234 msgid "B<-D> I<drive-number>"
235 msgstr ""
236
237 #. type: Plain text
238 #: en/mkfs.fat.8:46
239 msgid ""
240 "Specify the BIOS drive number to be stored in the FAT boot sector. This "
241 "value is usually 0x80 for hard disks and 0x00 for floppy devices or "
242 "partitions to be used for floppy emulation."
243 msgstr ""
244
245 #. type: IP
246 #: en/mkfs.fat.8:46
247 #, no-wrap
248 msgid "B<-f> I<number-of-FATs>"
249 msgstr ""
250
251 #. type: Plain text
252 #: en/mkfs.fat.8:48
253 msgid ""
254 "Specify the number of file allocation tables in the filesystem. The default "
255 "is 2. Currently the Linux MS-DOS filesystem does not support more than 2 "
256 "FATs."
257 msgstr ""
258
259 #. type: IP
260 #: en/mkfs.fat.8:48
261 #, no-wrap
262 msgid "B<-F> I<FAT-size>"
263 msgstr ""
264
265 #. type: Plain text
266 #: en/mkfs.fat.8:50
267 msgid ""
268 "Specifies the type of file allocation tables used (12, 16 or 32 bit). If "
269 "nothing is specified, B<mkfs.fat> will automatically select between 12, 16 "
270 "and 32 bit, whatever fits better for the filesystem size."
271 msgstr ""
272
273 #. type: IP
274 #: en/mkfs.fat.8:50
275 #, no-wrap
276 msgid "B<-h> I<number-of-hidden-sectors>"
277 msgstr ""
278
279 #. type: Plain text
280 #: en/mkfs.fat.8:52
281 msgid ""
282 "Select the number of hidden sectors in the volume. Apparently some digital "
283 "cameras get indigestion if you feed them a CF card without such hidden "
284 "sectors, this option allows you to satisfy them."
285 msgstr ""
286
287 #. type: IP
288 #: en/mkfs.fat.8:52
289 #, no-wrap
290 msgid "B<-i> I<volume-id>"
291 msgstr ""
292
293 #. type: Plain text
294 #: en/mkfs.fat.8:54
295 msgid ""
296 "Sets the volume ID of the newly created filesystem; I<volume-id> is a 32-bit "
297 "hexadecimal number (for example, 2e24ec82). The default is a number which "
298 "depends on the filesystem creation time."
299 msgstr ""
300
301 #. type: IP
302 #: en/mkfs.fat.8:54
303 #, no-wrap
304 msgid "B<-I>"
305 msgstr ""
306
307 #. type: Plain text
308 #: en/mkfs.fat.8:56
309 msgid ""
310 "It is typical for fixed disk devices to be partitioned so, by default, you "
311 "are not permitted to create a filesystem across the entire device. B<mkfs."
312 "fat> will complain and tell you that it refuses to work. This is different "
313 "when using MO disks. One doesn't always need partitions on MO disks. The "
314 "filesystem can go directly to the whole disk. Under other OSes this is known "
315 "as the 'superfloppy' format. This switch will force B<mkfs.fat> to work "
316 "properly."
317 msgstr ""
318
319 #. type: IP
320 #: en/mkfs.fat.8:56
321 #, no-wrap
322 msgid "B<-l> I<filename>"
323 msgstr ""
324
325 #. type: Plain text
326 #: en/mkfs.fat.8:58
327 msgid "Read the bad blocks list from I<filename>."
328 msgstr ""
329
330 #. type: IP
331 #: en/mkfs.fat.8:58
332 #, no-wrap
333 msgid "B<-m> I<message-file>"
334 msgstr ""
335
336 #. type: Plain text
337 #: en/mkfs.fat.8:60
338 msgid ""
339 "Sets the message the user receives on attempts to boot this filesystem "
340 "without having properly installed an operating system. The message file must "
341 "not exceed 418 bytes once line feeds have been converted to carriage return-"
342 "line feed combinations, and tabs have been expanded. If the filename is a "
343 "hyphen (-), the text is taken from standard input."
344 msgstr ""
345
346 #. type: IP
347 #: en/mkfs.fat.8:60
348 #, no-wrap
349 msgid "B<-M> I<FAT-media-type>"
350 msgstr ""
351
352 #. type: Plain text
353 #: en/mkfs.fat.8:62
354 msgid ""
355 "Specify the media type to be stored in the FAT boot sector. This value is "
356 "usually 0xF8 for hard disks and has a value from 0xF9 to 0xFF for floppies "
357 "or partitions to be used for floppy emulation."
358 msgstr ""
359
360 #. type: IP
361 #: en/mkfs.fat.8:62
362 #, no-wrap
363 msgid "B<-n> I<volume-name>"
364 msgstr ""
365
366 #. type: Plain text
367 #: en/mkfs.fat.8:64
368 msgid ""
369 "Sets the volume name (label) of the filesystem. The volume name can be up to "
370 "11 characters long. The default is no label."
371 msgstr ""
372
373 #. type: IP
374 #: en/mkfs.fat.8:64
375 #, no-wrap
376 msgid "B<-r> I<root-dir-entries>"
377 msgstr ""
378
379 #. type: Plain text
380 #: en/mkfs.fat.8:66
381 msgid ""
382 "Select the number of entries available in the root directory. The default is "
383 "112 or 224 for floppies and 512 for hard disks."
384 msgstr ""
385
386 #. type: IP
387 #: en/mkfs.fat.8:66
388 #, no-wrap
389 msgid "B<-R> I<number-of-reserved-sectors>"
390 msgstr ""
391
392 #. type: Plain text
393 #: en/mkfs.fat.8:68
394 msgid ""
395 "Select the number of reserved sectors. With FAT32 format at least 2 reserved "
396 "sectors are needed, the default is 32. Otherwise the default is 1 (only the "
397 "boot sector)."
398 msgstr ""
399
400 #. type: IP
401 #: en/mkfs.fat.8:68
402 #, no-wrap
403 msgid "B<-s> I<sectors-per-cluster>"
404 msgstr ""
405
406 #. type: Plain text
407 #: en/mkfs.fat.8:70
408 msgid ""
409 "Specify the number of disk sectors per cluster. Must be a power of 2, i.e. "
410 "1, 2, 4, 8, ... 128."
411 msgstr ""
412
413 #. type: IP
414 #: en/mkfs.fat.8:70
415 #, no-wrap
416 msgid "B<-S> I<logical-sector-size>"
417 msgstr ""
418
419 #. type: Plain text
420 #: en/mkfs.fat.8:72
421 msgid ""
422 "Specify the number of bytes per logical sector. Must be a power of 2 and "
423 "greater than or equal to 512, i.e. 512, 1024, 2048, 4096, 8192, 16384, or "
424 "32768."
425 msgstr ""
426
427 #. type: Plain text
428 #: en/mkfs.fat.8:74
429 msgid "Verbose execution."
430 msgstr ""
431
432 #. type: Plain text
433 #: en/mkfs.fat.8:77
434 msgid ""
435 "B<mkfs.fat> can not create boot-able filesystems. This isn't as easy as you "
436 "might think at first glance for various reasons and has been discussed a lot "
437 "already. B<mkfs.fat> simply will not support it ;)"
438 msgstr ""
0 [po4a_langs] de
1 [po4a_paths] pot/$master.pot $lang:po/$lang/$master.po
2 [type: man] en/fatlabel.8 $lang:$lang/fatlabel.$lang.8
3 [type: man] en/fsck.fat.8 $lang:$lang/fsck.fat.$lang.8
4 [type: man] en/mkfs.fat.8 $lang:$lang/mkfs.fat.$lang.8
0 # SOME DESCRIPTIVE TITLE
1 # Copyright (C) YEAR Free Software Foundation, Inc.
2 # This file is distributed under the same license as the dosfstools package.
3 # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
4 #
5 #, fuzzy
6 msgid ""
7 msgstr ""
8 "Project-Id-Version: dosfstools VERSION\n"
9 "POT-Creation-Date: 2014-03-07 18:39+0100\n"
10 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
11 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
12 "Language-Team: LANGUAGE <LL@li.org>\n"
13 "Language: \n"
14 "MIME-Version: 1.0\n"
15 "Content-Type: text/plain; charset=CHARSET\n"
16 "Content-Transfer-Encoding: 8bit\n"
17
18 #. type: TH
19 #: en/fatlabel.8:22
20 #, no-wrap
21 msgid "FATLABEL"
22 msgstr ""
23
24 #. type: TH
25 #: en/fatlabel.8:22 en/fsck.fat.8:22 en/mkfs.fat.8:22
26 #, no-wrap
27 msgid "2014-03-07"
28 msgstr ""
29
30 #. type: TH
31 #: en/fatlabel.8:22 en/fsck.fat.8:22 en/mkfs.fat.8:22
32 #, no-wrap
33 msgid "3.0.26"
34 msgstr ""
35
36 #. type: TH
37 #: en/fatlabel.8:22 en/fsck.fat.8:22 en/mkfs.fat.8:22
38 #, no-wrap
39 msgid "dosfstools"
40 msgstr ""
41
42 #. type: SH
43 #: en/fatlabel.8:24 en/fsck.fat.8:24 en/mkfs.fat.8:24
44 #, no-wrap
45 msgid "NAME"
46 msgstr ""
47
48 #. type: Plain text
49 #: en/fatlabel.8:26
50 msgid "B<fatlabel> - set or get MS-DOS filesystem label"
51 msgstr ""
52
53 #. type: SH
54 #: en/fatlabel.8:27 en/fsck.fat.8:27 en/mkfs.fat.8:27
55 #, no-wrap
56 msgid "SYNOPSIS"
57 msgstr ""
58
59 #. type: Plain text
60 #: en/fatlabel.8:29
61 msgid "B<fatlabel> I<DEVICE> [I<LABEL>]"
62 msgstr ""
63
64 #. type: SH
65 #: en/fatlabel.8:30 en/fsck.fat.8:30 en/mkfs.fat.8:30
66 #, no-wrap
67 msgid "DESCRIPTION"
68 msgstr ""
69
70 #. type: Plain text
71 #: en/fatlabel.8:32
72 msgid "B<fatlabel> set or gets a MS-DOS filesystem label from a given device."
73 msgstr ""
74
75 #. type: Plain text
76 #: en/fatlabel.8:34
77 msgid ""
78 "If the label is omitted, then the label name of the specified device is "
79 "written on the standard output. A label can't be longer than 11 bytes."
80 msgstr ""
81
82 #. type: SH
83 #: en/fatlabel.8:35 en/fsck.fat.8:77 en/mkfs.fat.8:33
84 #, no-wrap
85 msgid "OPTIONS"
86 msgstr ""
87
88 #. type: IP
89 #: en/fatlabel.8:36
90 #, no-wrap
91 msgid "B<-h>, B<--help>"
92 msgstr ""
93
94 #. type: Plain text
95 #: en/fatlabel.8:38
96 msgid "Displays a help message."
97 msgstr ""
98
99 #. type: IP
100 #: en/fatlabel.8:38
101 #, no-wrap
102 msgid "B<-V>, B<--version>"
103 msgstr ""
104
105 #. type: Plain text
106 #: en/fatlabel.8:40
107 msgid "Shows version."
108 msgstr ""
109
110 #. type: SH
111 #: en/fatlabel.8:41 en/fsck.fat.8:128 en/mkfs.fat.8:78
112 #, no-wrap
113 msgid "SEE ALSO"
114 msgstr ""
115
116 #. type: Plain text
117 #: en/fatlabel.8:43 en/mkfs.fat.8:82
118 msgid "B<fsck.fat>(8)"
119 msgstr ""
120
121 #. type: Plain text
122 #: en/fatlabel.8:45 en/fsck.fat.8:132
123 msgid "B<mkfs.fat>(8)"
124 msgstr ""
125
126 #. type: SH
127 #: en/fatlabel.8:46 en/fsck.fat.8:133 en/mkfs.fat.8:83
128 #, no-wrap
129 msgid "HOMEPAGE"
130 msgstr ""
131
132 #. type: Plain text
133 #: en/fatlabel.8:48
134 msgid ""
135 "More information about B<fatlabel> and B<dosfstools> can be found at "
136 "E<lt>I<http://daniel-baumann.ch/software/dosfstools/>E<gt>."
137 msgstr ""
138
139 #. type: SH
140 #: en/fatlabel.8:49 en/fsck.fat.8:136 en/mkfs.fat.8:86
141 #, no-wrap
142 msgid "AUTHORS"
143 msgstr ""
144
145 #. type: Plain text
146 #: en/fatlabel.8:50 en/fsck.fat.8:137 en/mkfs.fat.8:87
147 msgid ""
148 "B<dosfstools> were written by Werner Almesberger E<lt>I<werner."
149 "almesberger@lrc.di.epfl.ch>E<gt>, Roman Hodek E<lt>I<Roman.Hodek@informatik."
150 "uni-erlangen.de>E<gt>, and others. The current maintainer is Daniel Baumann "
151 "E<lt>I<mail@daniel-baumann.ch>E<gt>."
152 msgstr ""
0 # SOME DESCRIPTIVE TITLE
1 # Copyright (C) YEAR Free Software Foundation, Inc.
2 # This file is distributed under the same license as the dosfstools package.
3 # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
4 #
5 #, fuzzy
6 msgid ""
7 msgstr ""
8 "Project-Id-Version: dosfstools VERSION\n"
9 "POT-Creation-Date: 2014-03-07 18:39+0100\n"
10 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
11 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
12 "Language-Team: LANGUAGE <LL@li.org>\n"
13 "Language: \n"
14 "MIME-Version: 1.0\n"
15 "Content-Type: text/plain; charset=CHARSET\n"
16 "Content-Transfer-Encoding: 8bit\n"
17
18 #. type: TH
19 #: en/fatlabel.8:22 en/fsck.fat.8:22 en/mkfs.fat.8:22
20 #, no-wrap
21 msgid "2014-03-07"
22 msgstr ""
23
24 #. type: TH
25 #: en/fatlabel.8:22 en/fsck.fat.8:22 en/mkfs.fat.8:22
26 #, no-wrap
27 msgid "3.0.26"
28 msgstr ""
29
30 #. type: TH
31 #: en/fatlabel.8:22 en/fsck.fat.8:22 en/mkfs.fat.8:22
32 #, no-wrap
33 msgid "dosfstools"
34 msgstr ""
35
36 #. type: SH
37 #: en/fatlabel.8:24 en/fsck.fat.8:24 en/mkfs.fat.8:24
38 #, no-wrap
39 msgid "NAME"
40 msgstr ""
41
42 #. type: SH
43 #: en/fatlabel.8:27 en/fsck.fat.8:27 en/mkfs.fat.8:27
44 #, no-wrap
45 msgid "SYNOPSIS"
46 msgstr ""
47
48 #. type: SH
49 #: en/fatlabel.8:30 en/fsck.fat.8:30 en/mkfs.fat.8:30
50 #, no-wrap
51 msgid "DESCRIPTION"
52 msgstr ""
53
54 #. type: SH
55 #: en/fatlabel.8:35 en/fsck.fat.8:77 en/mkfs.fat.8:33
56 #, no-wrap
57 msgid "OPTIONS"
58 msgstr ""
59
60 #. type: SH
61 #: en/fatlabel.8:41 en/fsck.fat.8:128 en/mkfs.fat.8:78
62 #, no-wrap
63 msgid "SEE ALSO"
64 msgstr ""
65
66 #. type: Plain text
67 #: en/fatlabel.8:45 en/fsck.fat.8:132
68 msgid "B<mkfs.fat>(8)"
69 msgstr ""
70
71 #. type: SH
72 #: en/fatlabel.8:46 en/fsck.fat.8:133 en/mkfs.fat.8:83
73 #, no-wrap
74 msgid "HOMEPAGE"
75 msgstr ""
76
77 #. type: SH
78 #: en/fatlabel.8:49 en/fsck.fat.8:136 en/mkfs.fat.8:86
79 #, no-wrap
80 msgid "AUTHORS"
81 msgstr ""
82
83 #. type: Plain text
84 #: en/fatlabel.8:50 en/fsck.fat.8:137 en/mkfs.fat.8:87
85 msgid ""
86 "B<dosfstools> were written by Werner Almesberger E<lt>I<werner."
87 "almesberger@lrc.di.epfl.ch>E<gt>, Roman Hodek E<lt>I<Roman.Hodek@informatik."
88 "uni-erlangen.de>E<gt>, and others. The current maintainer is Daniel Baumann "
89 "E<lt>I<mail@daniel-baumann.ch>E<gt>."
90 msgstr ""
91
92 #. type: TH
93 #: en/fsck.fat.8:22
94 #, no-wrap
95 msgid "FSCK.FAT"
96 msgstr ""
97
98 #. type: Plain text
99 #: en/fsck.fat.8:26
100 msgid "B<fsck.fat> - check and repair MS-DOS filesystems"
101 msgstr ""
102
103 #. type: Plain text
104 #: en/fsck.fat.8:29
105 msgid ""
106 "B<fsck.fat>|B<fsck.msdos>|B<fsck.vfat> [-aAflnprtvVwy] [-d I<PATH> -d\\ I<..."
107 ">] [-u\\ I<PATH> -u I<...>] I<DEVICE>"
108 msgstr ""
109
110 #. type: Plain text
111 #: en/fsck.fat.8:32
112 msgid ""
113 "B<fsck.fat> verifies the consistency of MS-DOS filesystems and optionally "
114 "tries to repair them."
115 msgstr ""
116
117 #. type: Plain text
118 #: en/fsck.fat.8:34
119 msgid "The following filesystem problems can be corrected (in this order):"
120 msgstr ""
121
122 #. type: IP
123 #: en/fsck.fat.8:34 en/fsck.fat.8:36 en/fsck.fat.8:38 en/fsck.fat.8:40
124 #: en/fsck.fat.8:42 en/fsck.fat.8:44 en/fsck.fat.8:46 en/fsck.fat.8:48
125 #: en/fsck.fat.8:50 en/fsck.fat.8:52 en/fsck.fat.8:54 en/fsck.fat.8:56
126 #: en/fsck.fat.8:58 en/fsck.fat.8:60 en/fsck.fat.8:62 en/fsck.fat.8:64
127 #: en/fsck.fat.8:66 en/fsck.fat.8:70 en/fsck.fat.8:72
128 #, no-wrap
129 msgid "*"
130 msgstr ""
131
132 #. type: Plain text
133 #: en/fsck.fat.8:36
134 msgid "FAT contains invalid cluster numbers. Cluster is changed to EOF."
135 msgstr ""
136
137 #. type: Plain text
138 #: en/fsck.fat.8:38
139 msgid "File's cluster chain contains a loop. The loop is broken."
140 msgstr ""
141
142 #. type: Plain text
143 #: en/fsck.fat.8:40
144 msgid ""
145 "Bad clusters (read errors). The clusters are marked bad and they are removed "
146 "from files owning them. This check is optional."
147 msgstr ""
148
149 #. type: Plain text
150 #: en/fsck.fat.8:42
151 msgid ""
152 "Directories with a large number of bad entries (probably corrupt). The "
153 "directory can be deleted."
154 msgstr ""
155
156 #. type: Plain text
157 #: en/fsck.fat.8:44
158 msgid "Files . and .. are non-directories. They can be deleted or renamed."
159 msgstr ""
160
161 #. type: Plain text
162 #: en/fsck.fat.8:46
163 msgid "Directories . and .. in root directory. They are deleted."
164 msgstr ""
165
166 #. type: Plain text
167 #: en/fsck.fat.8:48
168 msgid "Bad filenames. They can be renamed."
169 msgstr ""
170
171 #. type: Plain text
172 #: en/fsck.fat.8:50
173 msgid "Duplicate directory entries. They can be deleted or renamed."
174 msgstr ""
175
176 #. type: Plain text
177 #: en/fsck.fat.8:52
178 msgid "Directories with non-zero size field. Size is set to zero."
179 msgstr ""
180
181 #. type: Plain text
182 #: en/fsck.fat.8:54
183 msgid ""
184 "Directory . does not point to parent directory. The start pointer is "
185 "adjusted."
186 msgstr ""
187
188 #. type: Plain text
189 #: en/fsck.fat.8:56
190 msgid ""
191 "Directory .. does not point to parent of parent directory. The start pointer "
192 "is adjusted."
193 msgstr ""
194
195 #. type: Plain text
196 #: en/fsck.fat.8:58
197 msgid "Start cluster number of a file is invalid. The file is truncated."
198 msgstr ""
199
200 #. type: Plain text
201 #: en/fsck.fat.8:60
202 msgid "File contains bad or free clusters. The file is truncated."
203 msgstr ""
204
205 #. type: Plain text
206 #: en/fsck.fat.8:62
207 msgid ""
208 "File's cluster chain is longer than indicated by the size fields. The file "
209 "is truncated."
210 msgstr ""
211
212 #. type: Plain text
213 #: en/fsck.fat.8:64
214 msgid ""
215 "Two or more files share the same cluster(s). All but one of the files are "
216 "truncated. If the file being truncated is a directory file that has already "
217 "been read, the filesystem check is restarted after truncation."
218 msgstr ""
219
220 #. type: Plain text
221 #: en/fsck.fat.8:66
222 msgid ""
223 "File's cluster chain is shorter than indicated by the size fields. The file "
224 "is truncated."
225 msgstr ""
226
227 #. type: Plain text
228 #: en/fsck.fat.8:68
229 msgid ""
230 "Clusters are marked as used but are not owned by a file. They are marked as "
231 "free."
232 msgstr ""
233
234 #. type: Plain text
235 #: en/fsck.fat.8:70
236 msgid "Additionally, the following problems are detected, but not repaired:"
237 msgstr ""
238
239 #. type: Plain text
240 #: en/fsck.fat.8:72
241 msgid "Invalid parameters in boot sector."
242 msgstr ""
243
244 #. type: Plain text
245 #: en/fsck.fat.8:74
246 msgid "Absence of . and .. entries in non-root directories"
247 msgstr ""
248
249 #. type: Plain text
250 #: en/fsck.fat.8:76
251 msgid ""
252 "When B<fsck.fat> checks a filesystem, it accumulates all changes in memory "
253 "and performs them only after all checks are complete. This can be disabled "
254 "with the B<-w> option."
255 msgstr ""
256
257 #. type: IP
258 #: en/fsck.fat.8:78 en/mkfs.fat.8:34
259 #, no-wrap
260 msgid "B<-a>"
261 msgstr ""
262
263 #. type: Plain text
264 #: en/fsck.fat.8:80
265 msgid ""
266 "Automatically repair the filesystem. No user intervention is necessary. "
267 "Whenever there is more than one method to solve a problem, the least "
268 "destructive approach is used."
269 msgstr ""
270
271 #. type: IP
272 #: en/fsck.fat.8:80
273 #, no-wrap
274 msgid "B<-A>"
275 msgstr ""
276
277 #. type: Plain text
278 #: en/fsck.fat.8:82
279 msgid ""
280 "Use Atari variation of the MS-DOS filesystem. This is default if B<fsck.fat> "
281 "is run on an Atari, then this option turns off Atari format. There are some "
282 "minor differences in Atari format: Some boot sector fields are interpreted "
283 "slightly different, and the special FAT entries for end-of-file and bad "
284 "cluster can be different. Under MS-DOS 0xfff8 is used for EOF and Atari "
285 "employs 0xffff by default, but both systems recognize all values from "
286 "0xfff8...0xffff as end-of-file. MS-DOS uses only 0xfff7 for bad clusters, "
287 "where on Atari values 0xfff0...0xfff7 are for this purpose (but the standard "
288 "value is still 0xfff7)."
289 msgstr ""
290
291 #. type: IP
292 #: en/fsck.fat.8:82
293 #, no-wrap
294 msgid "B<-b>"
295 msgstr ""
296
297 #. type: Plain text
298 #: en/fsck.fat.8:84
299 msgid "Make read-only boot sector check."
300 msgstr ""
301
302 #. type: IP
303 #: en/fsck.fat.8:84
304 #, no-wrap
305 msgid "B<-d>"
306 msgstr ""
307
308 #. type: Plain text
309 #: en/fsck.fat.8:86
310 msgid ""
311 "Delete the specified file. If more that one file with that name exists, the "
312 "first one is deleted."
313 msgstr ""
314
315 #. type: IP
316 #: en/fsck.fat.8:86
317 #, no-wrap
318 msgid "B<-f>"
319 msgstr ""
320
321 #. type: Plain text
322 #: en/fsck.fat.8:88
323 msgid ""
324 "Salvage unused cluster chains to files. By default, unused clusters are "
325 "added to the free disk space except in auto mode (B<-a>)."
326 msgstr ""
327
328 #. type: IP
329 #: en/fsck.fat.8:88
330 #, no-wrap
331 msgid "B<-l>"
332 msgstr ""
333
334 #. type: Plain text
335 #: en/fsck.fat.8:90
336 msgid "List path names of files being processed."
337 msgstr ""
338
339 #. type: IP
340 #: en/fsck.fat.8:90
341 #, no-wrap
342 msgid "B<-n>"
343 msgstr ""
344
345 #. type: Plain text
346 #: en/fsck.fat.8:93
347 msgid ""
348 "No-operation mode: non-interactively check for errors, but don't write "
349 "anything to the filesystem."
350 msgstr ""
351
352 #. type: IP
353 #: en/fsck.fat.8:93
354 #, no-wrap
355 msgid "B<-p>"
356 msgstr ""
357
358 #. type: Plain text
359 #: en/fsck.fat.8:95
360 msgid "Same as (B<-a>), for compatibility with other *fsck."
361 msgstr ""
362
363 #. type: IP
364 #: en/fsck.fat.8:95
365 #, no-wrap
366 msgid "B<-r>"
367 msgstr ""
368
369 #. type: Plain text
370 #: en/fsck.fat.8:98
371 msgid ""
372 "Interactively repair the filesystem. The user is asked for advice whenever "
373 "there is more than one approach to fix an inconsistency."
374 msgstr ""
375
376 #. type: IP
377 #: en/fsck.fat.8:98
378 #, no-wrap
379 msgid "B<-t>"
380 msgstr ""
381
382 #. type: Plain text
383 #: en/fsck.fat.8:100
384 msgid "Mark unreadable clusters as bad."
385 msgstr ""
386
387 #. type: IP
388 #: en/fsck.fat.8:100
389 #, no-wrap
390 msgid "B<-u>"
391 msgstr ""
392
393 #. type: Plain text
394 #: en/fsck.fat.8:102
395 msgid ""
396 "Try to undelete the specified file. B<fsck.fat> tries to allocate a chain of "
397 "contiguous unallocated clusters beginning with the start cluster of the "
398 "undeleted file."
399 msgstr ""
400
401 #. type: IP
402 #: en/fsck.fat.8:102 en/mkfs.fat.8:72
403 #, no-wrap
404 msgid "B<-v>"
405 msgstr ""
406
407 #. type: Plain text
408 #: en/fsck.fat.8:104
409 msgid "Verbose mode. Generates slightly more output."
410 msgstr ""
411
412 #. type: IP
413 #: en/fsck.fat.8:104
414 #, no-wrap
415 msgid "B<-V>"
416 msgstr ""
417
418 #. type: Plain text
419 #: en/fsck.fat.8:106
420 msgid ""
421 "Perform a verification pass. The filesystem check is repeated after the "
422 "first run. The second pass should never report any fixable errors. It may "
423 "take considerably longer than the first pass, because the first pass may "
424 "have generated long list of modifications that have to be scanned for each "
425 "disk read."
426 msgstr ""
427
428 #. type: IP
429 #: en/fsck.fat.8:106
430 #, no-wrap
431 msgid "B<-w>"
432 msgstr ""
433
434 #. type: Plain text
435 #: en/fsck.fat.8:108
436 msgid "Write changes to disk immediately."
437 msgstr ""
438
439 #. type: IP
440 #: en/fsck.fat.8:108
441 #, no-wrap
442 msgid "B<-y>"
443 msgstr ""
444
445 #. type: Plain text
446 #: en/fsck.fat.8:110
447 msgid ""
448 "Same as B<-a> (automatically repair filesystem) for compatibility with other "
449 "fsck tools."
450 msgstr ""
451
452 #. type: Plain text
453 #: en/fsck.fat.8:112
454 msgid ""
455 "B<Note:> If B<-a> and B<-r> are absent, the filesystem is only checked, but "
456 "not repaired."
457 msgstr ""
458
459 #. type: SH
460 #: en/fsck.fat.8:113
461 #, no-wrap
462 msgid "EXIT STATUS"
463 msgstr ""
464
465 #. type: IP
466 #: en/fsck.fat.8:114
467 #, no-wrap
468 msgid "0"
469 msgstr ""
470
471 #. type: Plain text
472 #: en/fsck.fat.8:116
473 msgid "No recoverable errors have been detected."
474 msgstr ""
475
476 #. type: IP
477 #: en/fsck.fat.8:116
478 #, no-wrap
479 msgid "1"
480 msgstr ""
481
482 #. type: Plain text
483 #: en/fsck.fat.8:118
484 msgid ""
485 "Recoverable errors have been detected or B<fsck.fat> has discovered an "
486 "internal inconsistency."
487 msgstr ""
488
489 #. type: IP
490 #: en/fsck.fat.8:118
491 #, no-wrap
492 msgid "2"
493 msgstr ""
494
495 #. type: Plain text
496 #: en/fsck.fat.8:120
497 msgid "Usage error. B<fsck.fat> did not access the filesystem."
498 msgstr ""
499
500 #. type: SH
501 #: en/fsck.fat.8:121
502 #, no-wrap
503 msgid "FILES"
504 msgstr ""
505
506 #. type: IP
507 #: en/fsck.fat.8:122
508 #, no-wrap
509 msgid "fsck0000.rec, fsck0001.rec, ..."
510 msgstr ""
511
512 #. type: Plain text
513 #: en/fsck.fat.8:124
514 msgid ""
515 "When recovering from a corrupted filesystem, B<fsck.fat> dumps recovered "
516 "data into files named 'fsckNNNN.rec' in the top level directory of the "
517 "filesystem."
518 msgstr ""
519
520 #. type: SH
521 #: en/fsck.fat.8:125 en/mkfs.fat.8:75
522 #, no-wrap
523 msgid "BUGS"
524 msgstr ""
525
526 #. type: Plain text
527 #: en/fsck.fat.8:127
528 msgid ""
529 "Does not create . and .. files where necessary. Does not remove entirely "
530 "empty directories. Should give more diagnostic messages. Undeleting files "
531 "should use a more sophisticated algorithm."
532 msgstr ""
533
534 #. type: Plain text
535 #: en/fsck.fat.8:130 en/mkfs.fat.8:80
536 msgid "B<fatlabel>(8)"
537 msgstr ""
538
539 #. type: Plain text
540 #: en/fsck.fat.8:135 en/mkfs.fat.8:85
541 msgid ""
542 "More information about B<fsck.fat> and B<dosfstools> can be found at "
543 "E<lt>I<http://daniel-baumann.ch/software/dosfstools/>E<gt>."
544 msgstr ""
0 # SOME DESCRIPTIVE TITLE
1 # Copyright (C) YEAR Free Software Foundation, Inc.
2 # This file is distributed under the same license as the dosfstools package.
3 # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
4 #
5 #, fuzzy
6 msgid ""
7 msgstr ""
8 "Project-Id-Version: dosfstools VERSION\n"
9 "POT-Creation-Date: 2014-03-07 18:39+0100\n"
10 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
11 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
12 "Language-Team: LANGUAGE <LL@li.org>\n"
13 "Language: \n"
14 "MIME-Version: 1.0\n"
15 "Content-Type: text/plain; charset=CHARSET\n"
16 "Content-Transfer-Encoding: 8bit\n"
17
18 #. type: TH
19 #: en/fatlabel.8:22 en/fsck.fat.8:22 en/mkfs.fat.8:22
20 #, no-wrap
21 msgid "2014-03-07"
22 msgstr ""
23
24 #. type: TH
25 #: en/fatlabel.8:22 en/fsck.fat.8:22 en/mkfs.fat.8:22
26 #, no-wrap
27 msgid "3.0.26"
28 msgstr ""
29
30 #. type: TH
31 #: en/fatlabel.8:22 en/fsck.fat.8:22 en/mkfs.fat.8:22
32 #, no-wrap
33 msgid "dosfstools"
34 msgstr ""
35
36 #. type: SH
37 #: en/fatlabel.8:24 en/fsck.fat.8:24 en/mkfs.fat.8:24
38 #, no-wrap
39 msgid "NAME"
40 msgstr ""
41
42 #. type: SH
43 #: en/fatlabel.8:27 en/fsck.fat.8:27 en/mkfs.fat.8:27
44 #, no-wrap
45 msgid "SYNOPSIS"
46 msgstr ""
47
48 #. type: SH
49 #: en/fatlabel.8:30 en/fsck.fat.8:30 en/mkfs.fat.8:30
50 #, no-wrap
51 msgid "DESCRIPTION"
52 msgstr ""
53
54 #. type: SH
55 #: en/fatlabel.8:35 en/fsck.fat.8:77 en/mkfs.fat.8:33
56 #, no-wrap
57 msgid "OPTIONS"
58 msgstr ""
59
60 #. type: SH
61 #: en/fatlabel.8:41 en/fsck.fat.8:128 en/mkfs.fat.8:78
62 #, no-wrap
63 msgid "SEE ALSO"
64 msgstr ""
65
66 #. type: Plain text
67 #: en/fatlabel.8:43 en/mkfs.fat.8:82
68 msgid "B<fsck.fat>(8)"
69 msgstr ""
70
71 #. type: SH
72 #: en/fatlabel.8:46 en/fsck.fat.8:133 en/mkfs.fat.8:83
73 #, no-wrap
74 msgid "HOMEPAGE"
75 msgstr ""
76
77 #. type: SH
78 #: en/fatlabel.8:49 en/fsck.fat.8:136 en/mkfs.fat.8:86
79 #, no-wrap
80 msgid "AUTHORS"
81 msgstr ""
82
83 #. type: Plain text
84 #: en/fatlabel.8:50 en/fsck.fat.8:137 en/mkfs.fat.8:87
85 msgid ""
86 "B<dosfstools> were written by Werner Almesberger E<lt>I<werner."
87 "almesberger@lrc.di.epfl.ch>E<gt>, Roman Hodek E<lt>I<Roman.Hodek@informatik."
88 "uni-erlangen.de>E<gt>, and others. The current maintainer is Daniel Baumann "
89 "E<lt>I<mail@daniel-baumann.ch>E<gt>."
90 msgstr ""
91
92 #. type: IP
93 #: en/fsck.fat.8:78 en/mkfs.fat.8:34
94 #, no-wrap
95 msgid "B<-a>"
96 msgstr ""
97
98 #. type: IP
99 #: en/fsck.fat.8:102 en/mkfs.fat.8:72
100 #, no-wrap
101 msgid "B<-v>"
102 msgstr ""
103
104 #. type: SH
105 #: en/fsck.fat.8:125 en/mkfs.fat.8:75
106 #, no-wrap
107 msgid "BUGS"
108 msgstr ""
109
110 #. type: Plain text
111 #: en/fsck.fat.8:130 en/mkfs.fat.8:80
112 msgid "B<fatlabel>(8)"
113 msgstr ""
114
115 #. type: Plain text
116 #: en/fsck.fat.8:135 en/mkfs.fat.8:85
117 msgid ""
118 "More information about B<fsck.fat> and B<dosfstools> can be found at "
119 "E<lt>I<http://daniel-baumann.ch/software/dosfstools/>E<gt>."
120 msgstr ""
121
122 #. type: TH
123 #: en/mkfs.fat.8:22
124 #, no-wrap
125 msgid "MKFS.FAT"
126 msgstr ""
127
128 #. type: Plain text
129 #: en/mkfs.fat.8:26
130 msgid "B<mkfs.fat> - create an MS-DOS filesystem under Linux"
131 msgstr ""
132
133 #. type: Plain text
134 #: en/mkfs.fat.8:29
135 msgid ""
136 "B<mkfs.fat> [B<-a>] [B<-A>] [B<-b> I<sector-of-backup>] [B<-c>] [B<-l> "
137 "I<filename>] [B<-C>] [B<-f> I<number-of-FATs>] [B<-F> I<FAT-size] [>B<-h> "
138 "I<number-of-hidden-sectors>] [B<-i> I<volume-id>] [B<-I>] [B<-m> I<message-"
139 "file>] [B<-n> I<volume-name>] [B<-r> I<root-dir-entries>] [B<-R> I<number-of-"
140 "reserved-sectors>] [B<-s> I<sectors-per-cluster>] [B<-S >I<logical-sector-"
141 "size>] [B<-D> I<drive-number>] [B<-M >I<FAT-media-type>] [B<-v>] I<device> "
142 "[I<block-count>]"
143 msgstr ""
144
145 #. type: Plain text
146 #: en/mkfs.fat.8:32
147 msgid ""
148 "B<mkfs.fat> is used to create an MS-DOS filesystem under Linux on a device "
149 "(usually a disk partition). I<device> is the special file corresponding to "
150 "the device (e.g /dev/sdXX). I<block-count> is the number of blocks on the "
151 "device. If omitted, B<mkfs.fat> automatically determines the filesystem size."
152 msgstr ""
153
154 #. type: Plain text
155 #: en/mkfs.fat.8:36
156 msgid ""
157 "Normally, for any filesystem except very small ones, B<mkfs.fat> will align "
158 "all the data structures to cluster size, to make sure that as long as the "
159 "partition is properly aligned, so will all the data structures in the "
160 "filesystem. This option disables alignment; this may provide a handful of "
161 "additional clusters of storage at the expense of a significant performance "
162 "degradation on RAIDs, flash media or large-sector hard disks."
163 msgstr ""
164
165 #. type: IP
166 #: en/mkfs.fat.8:36
167 #, no-wrap
168 msgid "B< -A>"
169 msgstr ""
170
171 #. type: Plain text
172 #: en/mkfs.fat.8:38
173 msgid ""
174 "Use Atari variation of the MS-DOS filesystem. This is default if B<mkfs.fat> "
175 "is run on an Atari, then this option turns off Atari format. There are some "
176 "differences when using Atari format: If not directed otherwise by the user, "
177 "B<mkfs.fat> will always use 2 sectors per cluster, since GEMDOS doesn't like "
178 "other values very much. It will also obey the maximum number of sectors "
179 "GEMDOS can handle. Larger filesystems are managed by raising the logical "
180 "sector size. Under Atari format, an Atari-compatible serial number for the "
181 "filesystem is generated, and a 12 bit FAT is used only for filesystems that "
182 "have one of the usual floppy sizes (720k, 1.2M, 1.44M, 2.88M), a 16 bit FAT "
183 "otherwise. This can be overridden with the B<-F> option. Some PC-specific "
184 "boot sector fields aren't written, and a boot message (option B<-m>) is "
185 "ignored."
186 msgstr ""
187
188 #. type: IP
189 #: en/mkfs.fat.8:38
190 #, no-wrap
191 msgid "B<-b> I<sector-of-backup>"
192 msgstr ""
193
194 #. type: Plain text
195 #: en/mkfs.fat.8:40
196 msgid ""
197 "Selects the location of the backup boot sector for FAT32. Default depends on "
198 "number of reserved sectors, but usually is sector 6. The backup must be "
199 "within the range of reserved sectors."
200 msgstr ""
201
202 #. type: IP
203 #: en/mkfs.fat.8:40
204 #, no-wrap
205 msgid "B<-c>"
206 msgstr ""
207
208 #. type: Plain text
209 #: en/mkfs.fat.8:42
210 msgid "Check the device for bad blocks before creating the filesystem."
211 msgstr ""
212
213 #. type: IP
214 #: en/mkfs.fat.8:42
215 #, no-wrap
216 msgid "B<-C>"
217 msgstr ""
218
219 #. type: Plain text
220 #: en/mkfs.fat.8:44
221 msgid ""
222 "Create the file given as I<device> on the command line, and write the to-be-"
223 "created filesystem to it. This can be used to create the new filesystem in a "
224 "file instead of on a real device, and to avoid using B<dd> in advance to "
225 "create a file of appropriate size. With this option, the I<block-count> must "
226 "be given, because otherwise the intended size of the filesystem wouldn't be "
227 "known. The file created is a sparse file, which actually only contains the "
228 "meta-data areas (boot sector, FATs, and root directory). The data portions "
229 "won't be stored on the disk, but the file nevertheless will have the correct "
230 "size. The resulting file can be copied later to a floppy disk or other "
231 "device, or mounted through a loop device."
232 msgstr ""
233
234 #. type: IP
235 #: en/mkfs.fat.8:44
236 #, no-wrap
237 msgid "B<-D> I<drive-number>"
238 msgstr ""
239
240 #. type: Plain text
241 #: en/mkfs.fat.8:46
242 msgid ""
243 "Specify the BIOS drive number to be stored in the FAT boot sector. This "
244 "value is usually 0x80 for hard disks and 0x00 for floppy devices or "
245 "partitions to be used for floppy emulation."
246 msgstr ""
247
248 #. type: IP
249 #: en/mkfs.fat.8:46
250 #, no-wrap
251 msgid "B<-f> I<number-of-FATs>"
252 msgstr ""
253
254 #. type: Plain text
255 #: en/mkfs.fat.8:48
256 msgid ""
257 "Specify the number of file allocation tables in the filesystem. The default "
258 "is 2. Currently the Linux MS-DOS filesystem does not support more than 2 "
259 "FATs."
260 msgstr ""
261
262 #. type: IP
263 #: en/mkfs.fat.8:48
264 #, no-wrap
265 msgid "B<-F> I<FAT-size>"
266 msgstr ""
267
268 #. type: Plain text
269 #: en/mkfs.fat.8:50
270 msgid ""
271 "Specifies the type of file allocation tables used (12, 16 or 32 bit). If "
272 "nothing is specified, B<mkfs.fat> will automatically select between 12, 16 "
273 "and 32 bit, whatever fits better for the filesystem size."
274 msgstr ""
275
276 #. type: IP
277 #: en/mkfs.fat.8:50
278 #, no-wrap
279 msgid "B<-h> I<number-of-hidden-sectors>"
280 msgstr ""
281
282 #. type: Plain text
283 #: en/mkfs.fat.8:52
284 msgid ""
285 "Select the number of hidden sectors in the volume. Apparently some digital "
286 "cameras get indigestion if you feed them a CF card without such hidden "
287 "sectors, this option allows you to satisfy them."
288 msgstr ""
289
290 #. type: IP
291 #: en/mkfs.fat.8:52
292 #, no-wrap
293 msgid "B<-i> I<volume-id>"
294 msgstr ""
295
296 #. type: Plain text
297 #: en/mkfs.fat.8:54
298 msgid ""
299 "Sets the volume ID of the newly created filesystem; I<volume-id> is a 32-bit "
300 "hexadecimal number (for example, 2e24ec82). The default is a number which "
301 "depends on the filesystem creation time."
302 msgstr ""
303
304 #. type: IP
305 #: en/mkfs.fat.8:54
306 #, no-wrap
307 msgid "B<-I>"
308 msgstr ""
309
310 #. type: Plain text
311 #: en/mkfs.fat.8:56
312 msgid ""
313 "It is typical for fixed disk devices to be partitioned so, by default, you "
314 "are not permitted to create a filesystem across the entire device. B<mkfs."
315 "fat> will complain and tell you that it refuses to work. This is different "
316 "when using MO disks. One doesn't always need partitions on MO disks. The "
317 "filesystem can go directly to the whole disk. Under other OSes this is known "
318 "as the 'superfloppy' format. This switch will force B<mkfs.fat> to work "
319 "properly."
320 msgstr ""
321
322 #. type: IP
323 #: en/mkfs.fat.8:56
324 #, no-wrap
325 msgid "B<-l> I<filename>"
326 msgstr ""
327
328 #. type: Plain text
329 #: en/mkfs.fat.8:58
330 msgid "Read the bad blocks list from I<filename>."
331 msgstr ""
332
333 #. type: IP
334 #: en/mkfs.fat.8:58
335 #, no-wrap
336 msgid "B<-m> I<message-file>"
337 msgstr ""
338
339 #. type: Plain text
340 #: en/mkfs.fat.8:60
341 msgid ""
342 "Sets the message the user receives on attempts to boot this filesystem "
343 "without having properly installed an operating system. The message file must "
344 "not exceed 418 bytes once line feeds have been converted to carriage return-"
345 "line feed combinations, and tabs have been expanded. If the filename is a "
346 "hyphen (-), the text is taken from standard input."
347 msgstr ""
348
349 #. type: IP
350 #: en/mkfs.fat.8:60
351 #, no-wrap
352 msgid "B<-M> I<FAT-media-type>"
353 msgstr ""
354
355 #. type: Plain text
356 #: en/mkfs.fat.8:62
357 msgid ""
358 "Specify the media type to be stored in the FAT boot sector. This value is "
359 "usually 0xF8 for hard disks and has a value from 0xF9 to 0xFF for floppies "
360 "or partitions to be used for floppy emulation."
361 msgstr ""
362
363 #. type: IP
364 #: en/mkfs.fat.8:62
365 #, no-wrap
366 msgid "B<-n> I<volume-name>"
367 msgstr ""
368
369 #. type: Plain text
370 #: en/mkfs.fat.8:64
371 msgid ""
372 "Sets the volume name (label) of the filesystem. The volume name can be up to "
373 "11 characters long. The default is no label."
374 msgstr ""
375
376 #. type: IP
377 #: en/mkfs.fat.8:64
378 #, no-wrap
379 msgid "B<-r> I<root-dir-entries>"
380 msgstr ""
381
382 #. type: Plain text
383 #: en/mkfs.fat.8:66
384 msgid ""
385 "Select the number of entries available in the root directory. The default is "
386 "112 or 224 for floppies and 512 for hard disks."
387 msgstr ""
388
389 #. type: IP
390 #: en/mkfs.fat.8:66
391 #, no-wrap
392 msgid "B<-R> I<number-of-reserved-sectors>"
393 msgstr ""
394
395 #. type: Plain text
396 #: en/mkfs.fat.8:68
397 msgid ""
398 "Select the number of reserved sectors. With FAT32 format at least 2 reserved "
399 "sectors are needed, the default is 32. Otherwise the default is 1 (only the "
400 "boot sector)."
401 msgstr ""
402
403 #. type: IP
404 #: en/mkfs.fat.8:68
405 #, no-wrap
406 msgid "B<-s> I<sectors-per-cluster>"
407 msgstr ""
408
409 #. type: Plain text
410 #: en/mkfs.fat.8:70
411 msgid ""
412 "Specify the number of disk sectors per cluster. Must be a power of 2, i.e. "
413 "1, 2, 4, 8, ... 128."
414 msgstr ""
415
416 #. type: IP
417 #: en/mkfs.fat.8:70
418 #, no-wrap
419 msgid "B<-S> I<logical-sector-size>"
420 msgstr ""
421
422 #. type: Plain text
423 #: en/mkfs.fat.8:72
424 msgid ""
425 "Specify the number of bytes per logical sector. Must be a power of 2 and "
426 "greater than or equal to 512, i.e. 512, 1024, 2048, 4096, 8192, 16384, or "
427 "32768."
428 msgstr ""
429
430 #. type: Plain text
431 #: en/mkfs.fat.8:74
432 msgid "Verbose execution."
433 msgstr ""
434
435 #. type: Plain text
436 #: en/mkfs.fat.8:77
437 msgid ""
438 "B<mkfs.fat> can not create boot-able filesystems. This isn't as easy as you "
439 "might think at first glance for various reasons and has been discussed a lot "
440 "already. B<mkfs.fat> simply will not support it ;)"
441 msgstr ""
0 /* boot.c - Read and analyze ia PC/MS-DOS boot sector
1
2 Copyright (C) 1993 Werner Almesberger <werner.almesberger@lrc.di.epfl.ch>
3 Copyright (C) 1998 Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de>
4 Copyright (C) 2008-2014 Daniel Baumann <mail@daniel-baumann.ch>
5
6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
18
19 The complete text of the GNU General Public License
20 can be found in /usr/share/common-licenses/GPL-3 file.
21 */
22
23 /* FAT32, VFAT, Atari format support, and various fixes additions May 1998
24 * by Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de> */
25
26 #include <stdio.h>
27 #include <string.h>
28 #include <sys/types.h>
29 #include <stdlib.h>
30 #include <time.h>
31
32 #include "common.h"
33 #include "fsck.fat.h"
34 #include "fat.h"
35 #include "io.h"
36 #include "boot.h"
37 #include "check.h"
38
39 #define ROUND_TO_MULTIPLE(n,m) ((n) && (m) ? (n)+(m)-1-((n)-1)%(m) : 0)
40 /* don't divide by zero */
41
42 /* cut-over cluster counts for FAT12 and FAT16 */
43 #define FAT12_THRESHOLD 4085
44 #define FAT16_THRESHOLD 65525
45
46 static struct {
47 __u8 media;
48 char *descr;
49 } mediabytes[] = {
50 {
51 0xf0, "5.25\" or 3.5\" HD floppy"}, {
52 0xf8, "hard disk"}, {
53 0xf9, "3,5\" 720k floppy 2s/80tr/9sec or "
54 "5.25\" 1.2M floppy 2s/80tr/15sec"}, {
55 0xfa, "5.25\" 320k floppy 1s/80tr/8sec"}, {
56 0xfb, "3.5\" 640k floppy 2s/80tr/8sec"}, {
57 0xfc, "5.25\" 180k floppy 1s/40tr/9sec"}, {
58 0xfd, "5.25\" 360k floppy 2s/40tr/9sec"}, {
59 0xfe, "5.25\" 160k floppy 1s/40tr/8sec"}, {
60 0xff, "5.25\" 320k floppy 2s/40tr/8sec"},};
61
62 /* Unaligned fields must first be accessed byte-wise */
63 #define GET_UNALIGNED_W(f) \
64 ( (__u16)f[0] | ((__u16)f[1]<<8) )
65
66 static char *get_media_descr(unsigned char media)
67 {
68 int i;
69
70 for (i = 0; i < sizeof(mediabytes) / sizeof(*mediabytes); ++i) {
71 if (mediabytes[i].media == media)
72 return (mediabytes[i].descr);
73 }
74 return ("undefined");
75 }
76
77 static void dump_boot(DOS_FS * fs, struct boot_sector *b, unsigned lss)
78 {
79 unsigned short sectors;
80
81 printf("Boot sector contents:\n");
82 if (!atari_format) {
83 char id[9];
84 strncpy(id, (const char *)b->system_id, 8);
85 id[8] = 0;
86 printf("System ID \"%s\"\n", id);
87 } else {
88 /* On Atari, a 24 bit serial number is stored at offset 8 of the boot
89 * sector */
90 printf("Serial number 0x%x\n",
91 b->system_id[5] | (b->system_id[6] << 8) | (b->
92 system_id[7] << 16));
93 }
94 printf("Media byte 0x%02x (%s)\n", b->media, get_media_descr(b->media));
95 printf("%10d bytes per logical sector\n", GET_UNALIGNED_W(b->sector_size));
96 printf("%10d bytes per cluster\n", fs->cluster_size);
97 printf("%10d reserved sector%s\n", le16toh(b->reserved),
98 le16toh(b->reserved) == 1 ? "" : "s");
99 printf("First FAT starts at byte %llu (sector %llu)\n",
100 (unsigned long long)fs->fat_start,
101 (unsigned long long)fs->fat_start / lss);
102 printf("%10d FATs, %d bit entries\n", b->fats, fs->fat_bits);
103 printf("%10d bytes per FAT (= %u sectors)\n", fs->fat_size,
104 fs->fat_size / lss);
105 if (!fs->root_cluster) {
106 printf("Root directory starts at byte %llu (sector %llu)\n",
107 (unsigned long long)fs->root_start,
108 (unsigned long long)fs->root_start / lss);
109 printf("%10d root directory entries\n", fs->root_entries);
110 } else {
111 printf("Root directory start at cluster %lu (arbitrary size)\n",
112 (unsigned long)fs->root_cluster);
113 }
114 printf("Data area starts at byte %llu (sector %llu)\n",
115 (unsigned long long)fs->data_start,
116 (unsigned long long)fs->data_start / lss);
117 printf("%10lu data clusters (%llu bytes)\n", (unsigned long)fs->clusters,
118 (unsigned long long)fs->clusters * fs->cluster_size);
119 printf("%u sectors/track, %u heads\n", le16toh(b->secs_track),
120 le16toh(b->heads));
121 printf("%10u hidden sectors\n", atari_format ?
122 /* On Atari, the hidden field is only 16 bit wide and unused */
123 (((unsigned char *)&b->hidden)[0] |
124 ((unsigned char *)&b->hidden)[1] << 8) : le32toh(b->hidden));
125 sectors = GET_UNALIGNED_W(b->sectors);
126 printf("%10u sectors total\n", sectors ? sectors : le32toh(b->total_sect));
127 }
128
129 static void check_backup_boot(DOS_FS * fs, struct boot_sector *b, int lss)
130 {
131 struct boot_sector b2;
132
133 if (!fs->backupboot_start) {
134 printf("There is no backup boot sector.\n");
135 if (le16toh(b->reserved) < 3) {
136 printf("And there is no space for creating one!\n");
137 return;
138 }
139 if (interactive)
140 printf("1) Create one\n2) Do without a backup\n");
141 else
142 printf(" Auto-creating backup boot block.\n");
143 if (!interactive || get_key("12", "?") == '1') {
144 int bbs;
145 /* The usual place for the backup boot sector is sector 6. Choose
146 * that or the last reserved sector. */
147 if (le16toh(b->reserved) >= 7 && le16toh(b->info_sector) != 6)
148 bbs = 6;
149 else {
150 bbs = le16toh(b->reserved) - 1;
151 if (bbs == le16toh(b->info_sector))
152 --bbs; /* this is never 0, as we checked reserved >= 3! */
153 }
154 fs->backupboot_start = bbs * lss;
155 b->backup_boot = htole16(bbs);
156 fs_write(fs->backupboot_start, sizeof(*b), b);
157 fs_write((loff_t) offsetof(struct boot_sector, backup_boot),
158 sizeof(b->backup_boot), &b->backup_boot);
159 printf("Created backup of boot sector in sector %d\n", bbs);
160 return;
161 } else
162 return;
163 }
164
165 fs_read(fs->backupboot_start, sizeof(b2), &b2);
166 if (memcmp(b, &b2, sizeof(b2)) != 0) {
167 /* there are any differences */
168 __u8 *p, *q;
169 int i, pos, first = 1;
170 char buf[20];
171
172 printf("There are differences between boot sector and its backup.\n");
173 printf("This is mostly harmless. Differences: (offset:original/backup)\n ");
174 pos = 2;
175 for (p = (__u8 *) b, q = (__u8 *) & b2, i = 0; i < sizeof(b2);
176 ++p, ++q, ++i) {
177 if (*p != *q) {
178 sprintf(buf, "%s%u:%02x/%02x", first ? "" : ", ",
179 (unsigned)(p - (__u8 *) b), *p, *q);
180 if (pos + strlen(buf) > 78)
181 printf("\n "), pos = 2;
182 printf("%s", buf);
183 pos += strlen(buf);
184 first = 0;
185 }
186 }
187 printf("\n");
188
189 if (interactive)
190 printf("1) Copy original to backup\n"
191 "2) Copy backup to original\n" "3) No action\n");
192 else
193 printf(" Not automatically fixing this.\n");
194 switch (interactive ? get_key("123", "?") : '3') {
195 case '1':
196 fs_write(fs->backupboot_start, sizeof(*b), b);
197 break;
198 case '2':
199 fs_write(0, sizeof(b2), &b2);
200 break;
201 default:
202 break;
203 }
204 }
205 }
206
207 static void init_fsinfo(struct info_sector *i)
208 {
209 i->magic = htole32(0x41615252);
210 i->signature = htole32(0x61417272);
211 i->free_clusters = htole32(-1);
212 i->next_cluster = htole32(2);
213 i->boot_sign = htole16(0xaa55);
214 }
215
216 static void read_fsinfo(DOS_FS * fs, struct boot_sector *b, int lss)
217 {
218 struct info_sector i;
219
220 if (!b->info_sector) {
221 printf("No FSINFO sector\n");
222 if (interactive)
223 printf("1) Create one\n2) Do without FSINFO\n");
224 else
225 printf(" Not automatically creating it.\n");
226 if (interactive && get_key("12", "?") == '1') {
227 /* search for a free reserved sector (not boot sector and not
228 * backup boot sector) */
229 __u32 s;
230 for (s = 1; s < le16toh(b->reserved); ++s)
231 if (s != le16toh(b->backup_boot))
232 break;
233 if (s > 0 && s < le16toh(b->reserved)) {
234 init_fsinfo(&i);
235 fs_write((loff_t) s * lss, sizeof(i), &i);
236 b->info_sector = htole16(s);
237 fs_write((loff_t) offsetof(struct boot_sector, info_sector),
238 sizeof(b->info_sector), &b->info_sector);
239 if (fs->backupboot_start)
240 fs_write(fs->backupboot_start +
241 offsetof(struct boot_sector, info_sector),
242 sizeof(b->info_sector), &b->info_sector);
243 } else {
244 printf("No free reserved sector found -- "
245 "no space for FSINFO sector!\n");
246 return;
247 }
248 } else
249 return;
250 }
251
252 fs->fsinfo_start = le16toh(b->info_sector) * lss;
253 fs_read(fs->fsinfo_start, sizeof(i), &i);
254
255 if (i.magic != htole32(0x41615252) ||
256 i.signature != htole32(0x61417272) || i.boot_sign != htole16(0xaa55)) {
257 printf("FSINFO sector has bad magic number(s):\n");
258 if (i.magic != htole32(0x41615252))
259 printf(" Offset %llu: 0x%08x != expected 0x%08x\n",
260 (unsigned long long)offsetof(struct info_sector, magic),
261 le32toh(i.magic), 0x41615252);
262 if (i.signature != htole32(0x61417272))
263 printf(" Offset %llu: 0x%08x != expected 0x%08x\n",
264 (unsigned long long)offsetof(struct info_sector, signature),
265 le32toh(i.signature), 0x61417272);
266 if (i.boot_sign != htole16(0xaa55))
267 printf(" Offset %llu: 0x%04x != expected 0x%04x\n",
268 (unsigned long long)offsetof(struct info_sector, boot_sign),
269 le16toh(i.boot_sign), 0xaa55);
270 if (interactive)
271 printf("1) Correct\n2) Don't correct (FSINFO invalid then)\n");
272 else
273 printf(" Auto-correcting it.\n");
274 if (!interactive || get_key("12", "?") == '1') {
275 init_fsinfo(&i);
276 fs_write(fs->fsinfo_start, sizeof(i), &i);
277 } else
278 fs->fsinfo_start = 0;
279 }
280
281 if (fs->fsinfo_start)
282 fs->free_clusters = le32toh(i.free_clusters);
283 }
284
285 static char print_fat_dirty_state(void)
286 {
287 printf("Dirty bit is set. Fs was not properly unmounted and"
288 " some data may be corrupt.\n");
289
290 if (interactive) {
291 printf("1) Remove dirty bit\n" "2) No action\n");
292 return get_key("12", "?");
293 } else
294 printf(" Automatically removing dirty bit.\n");
295 return '1';
296 }
297
298 static void check_fat_state_bit(DOS_FS * fs, void *b)
299 {
300 if (fs->fat_bits == 32) {
301 struct boot_sector *b32 = b;
302
303 if (b32->reserved3 & FAT_STATE_DIRTY) {
304 printf("0x41: ");
305 if (print_fat_dirty_state() == '1') {
306 b32->reserved3 &= ~FAT_STATE_DIRTY;
307 fs_write(0, sizeof(*b32), b32);
308 }
309 }
310 } else {
311 struct boot_sector_16 *b16 = b;
312
313 if (b16->reserved2 & FAT_STATE_DIRTY) {
314 printf("0x25: ");
315 if (print_fat_dirty_state() == '1') {
316 b16->reserved2 &= ~FAT_STATE_DIRTY;
317 fs_write(0, sizeof(*b16), b16);
318 }
319 }
320 }
321 }
322
323 void read_boot(DOS_FS * fs)
324 {
325 struct boot_sector b;
326 unsigned total_sectors;
327 unsigned short logical_sector_size, sectors;
328 unsigned fat_length;
329 loff_t data_size;
330
331 fs_read(0, sizeof(b), &b);
332 logical_sector_size = GET_UNALIGNED_W(b.sector_size);
333 if (!logical_sector_size)
334 die("Logical sector size is zero.");
335
336 /* This was moved up because it's the first thing that will fail */
337 /* if the platform needs special handling of unaligned multibyte accesses */
338 /* but such handling isn't being provided. See GET_UNALIGNED_W() above. */
339 if (logical_sector_size & (SECTOR_SIZE - 1))
340 die("Logical sector size (%d bytes) is not a multiple of the physical "
341 "sector size.", logical_sector_size);
342
343 fs->cluster_size = b.cluster_size * logical_sector_size;
344 if (!fs->cluster_size)
345 die("Cluster size is zero.");
346 if (b.fats != 2 && b.fats != 1)
347 die("Currently, only 1 or 2 FATs are supported, not %d.\n", b.fats);
348 fs->nfats = b.fats;
349 sectors = GET_UNALIGNED_W(b.sectors);
350 total_sectors = sectors ? sectors : le32toh(b.total_sect);
351 if (verbose)
352 printf("Checking we can access the last sector of the filesystem\n");
353 /* Can't access last odd sector anyway, so round down */
354 fs_test((loff_t) ((total_sectors & ~1) - 1) * (loff_t) logical_sector_size,
355 logical_sector_size);
356 fat_length = le16toh(b.fat_length) ?
357 le16toh(b.fat_length) : le32toh(b.fat32_length);
358 fs->fat_start = (loff_t) le16toh(b.reserved) * logical_sector_size;
359 fs->root_start = ((loff_t) le16toh(b.reserved) + b.fats * fat_length) *
360 logical_sector_size;
361 fs->root_entries = GET_UNALIGNED_W(b.dir_entries);
362 fs->data_start = fs->root_start + ROUND_TO_MULTIPLE(fs->root_entries <<
363 MSDOS_DIR_BITS,
364 logical_sector_size);
365 data_size = (loff_t) total_sectors *logical_sector_size - fs->data_start;
366 fs->clusters = data_size / fs->cluster_size;
367 fs->root_cluster = 0; /* indicates standard, pre-FAT32 root dir */
368 fs->fsinfo_start = 0; /* no FSINFO structure */
369 fs->free_clusters = -1; /* unknown */
370 if (!b.fat_length && b.fat32_length) {
371 fs->fat_bits = 32;
372 fs->root_cluster = le32toh(b.root_cluster);
373 if (!fs->root_cluster && fs->root_entries)
374 /* M$ hasn't specified this, but it looks reasonable: If
375 * root_cluster is 0 but there is a separate root dir
376 * (root_entries != 0), we handle the root dir the old way. Give a
377 * warning, but convertig to a root dir in a cluster chain seems
378 * to complex for now... */
379 printf("Warning: FAT32 root dir not in cluster chain! "
380 "Compatibility mode...\n");
381 else if (!fs->root_cluster && !fs->root_entries)
382 die("No root directory!");
383 else if (fs->root_cluster && fs->root_entries)
384 printf("Warning: FAT32 root dir is in a cluster chain, but "
385 "a separate root dir\n"
386 " area is defined. Cannot fix this easily.\n");
387 if (fs->clusters < FAT16_THRESHOLD)
388 printf("Warning: Filesystem is FAT32 according to fat_length "
389 "and fat32_length fields,\n"
390 " but has only %lu clusters, less than the required "
391 "minimum of %d.\n"
392 " This may lead to problems on some systems.\n",
393 (unsigned long)fs->clusters, FAT16_THRESHOLD);
394
395 check_fat_state_bit(fs, &b);
396 fs->backupboot_start = le16toh(b.backup_boot) * logical_sector_size;
397 check_backup_boot(fs, &b, logical_sector_size);
398
399 read_fsinfo(fs, &b, logical_sector_size);
400 } else if (!atari_format) {
401 /* On real MS-DOS, a 16 bit FAT is used whenever there would be too
402 * much clusers otherwise. */
403 fs->fat_bits = (fs->clusters >= FAT12_THRESHOLD) ? 16 : 12;
404 if (fs->clusters >= FAT16_THRESHOLD)
405 die("Too many clusters (%lu) for FAT16 filesystem.", fs->clusters);
406 check_fat_state_bit(fs, &b);
407 } else {
408 /* On Atari, things are more difficult: GEMDOS always uses 12bit FATs
409 * on floppies, and always 16 bit on harddisks. */
410 fs->fat_bits = 16; /* assume 16 bit FAT for now */
411 /* If more clusters than fat entries in 16-bit fat, we assume
412 * it's a real MSDOS FS with 12-bit fat. */
413 if (fs->clusters + 2 > fat_length * logical_sector_size * 8 / 16 ||
414 /* if it's a floppy disk --> 12bit fat */
415 device_no == 2 ||
416 /* if it's a ramdisk or loopback device and has one of the usual
417 * floppy sizes -> 12bit FAT */
418 ((device_no == 1 || device_no == 7) &&
419 (total_sectors == 720 || total_sectors == 1440 ||
420 total_sectors == 2880)))
421 fs->fat_bits = 12;
422 }
423 /* On FAT32, the high 4 bits of a FAT entry are reserved */
424 fs->eff_fat_bits = (fs->fat_bits == 32) ? 28 : fs->fat_bits;
425 fs->fat_size = fat_length * logical_sector_size;
426
427 fs->label = calloc(12, sizeof(__u8));
428 if (fs->fat_bits == 12 || fs->fat_bits == 16) {
429 struct boot_sector_16 *b16 = (struct boot_sector_16 *)&b;
430 if (b16->extended_sig == 0x29)
431 memmove(fs->label, b16->label, 11);
432 else
433 fs->label = NULL;
434 } else if (fs->fat_bits == 32) {
435 if (b.extended_sig == 0x29)
436 memmove(fs->label, &b.label, 11);
437 else
438 fs->label = NULL;
439 }
440
441 if (fs->clusters >
442 ((uint64_t)fs->fat_size * 8 / fs->fat_bits) - 2)
443 die("Filesystem has %d clusters but only space for %d FAT entries.",
444 fs->clusters,
445 ((unsigned long long)fs->fat_size * 8 / fs->fat_bits) - 2);
446 if (!fs->root_entries && !fs->root_cluster)
447 die("Root directory has zero size.");
448 if (fs->root_entries & (MSDOS_DPS - 1))
449 die("Root directory (%d entries) doesn't span an integral number of "
450 "sectors.", fs->root_entries);
451 if (logical_sector_size & (SECTOR_SIZE - 1))
452 die("Logical sector size (%d bytes) is not a multiple of the physical "
453 "sector size.", logical_sector_size);
454 #if 0 /* linux kernel doesn't check that either */
455 /* ++roman: On Atari, these two fields are often left uninitialized */
456 if (!atari_format && (!b.secs_track || !b.heads))
457 die("Invalid disk format in boot sector.");
458 #endif
459 if (verbose)
460 dump_boot(fs, &b, logical_sector_size);
461 }
462
463 static void write_boot_label(DOS_FS * fs, char *label)
464 {
465 if (fs->fat_bits == 12 || fs->fat_bits == 16) {
466 struct boot_sector_16 b16;
467
468 fs_read(0, sizeof(b16), &b16);
469 if (b16.extended_sig != 0x29) {
470 b16.extended_sig = 0x29;
471 b16.serial = 0;
472 memmove(b16.fs_type, fs->fat_bits == 12 ? "FAT12 " : "FAT16 ",
473 8);
474 }
475 memmove(b16.label, label, 11);
476 fs_write(0, sizeof(b16), &b16);
477 } else if (fs->fat_bits == 32) {
478 struct boot_sector b;
479
480 fs_read(0, sizeof(b), &b);
481 if (b.extended_sig != 0x29) {
482 b.extended_sig = 0x29;
483 b.serial = 0;
484 memmove(b.fs_type, "FAT32 ", 8);
485 }
486 memmove(b.label, label, 11);
487 fs_write(0, sizeof(b), &b);
488 if (fs->backupboot_start)
489 fs_write(fs->backupboot_start, sizeof(b), &b);
490 }
491 }
492
493 loff_t find_volume_de(DOS_FS * fs, DIR_ENT * de)
494 {
495 uint32_t cluster;
496 loff_t offset;
497 int i;
498
499 if (fs->root_cluster) {
500 for (cluster = fs->root_cluster;
501 cluster != 0 && cluster != -1;
502 cluster = next_cluster(fs, cluster)) {
503 offset = cluster_start(fs, cluster);
504 for (i = 0; i * sizeof(DIR_ENT) < fs->cluster_size; i++) {
505 fs_read(offset, sizeof(DIR_ENT), de);
506 if (de->attr & ATTR_VOLUME)
507 return offset;
508 offset += sizeof(DIR_ENT);
509 }
510 }
511 } else {
512 for (i = 0; i < fs->root_entries; i++) {
513 offset = fs->root_start + i * sizeof(DIR_ENT);
514 fs_read(offset, sizeof(DIR_ENT), de);
515 if (de->attr & ATTR_VOLUME)
516 return offset;
517 }
518 }
519
520 return 0;
521 }
522
523 static void write_volume_label(DOS_FS * fs, char *label)
524 {
525 time_t now = time(NULL);
526 struct tm *mtime = localtime(&now);
527 loff_t offset;
528 int created;
529 DIR_ENT de;
530
531 created = 0;
532 offset = find_volume_de(fs, &de);
533 if (offset == 0) {
534 created = 1;
535 offset = alloc_rootdir_entry(fs, &de, label);
536 }
537 memcpy(de.name, label, 11);
538 de.time = htole16((unsigned short)((mtime->tm_sec >> 1) +
539 (mtime->tm_min << 5) +
540 (mtime->tm_hour << 11)));
541 de.date = htole16((unsigned short)(mtime->tm_mday +
542 ((mtime->tm_mon + 1) << 5) +
543 ((mtime->tm_year - 80) << 9)));
544 if (created) {
545 de.attr = ATTR_VOLUME;
546 de.ctime_ms = 0;
547 de.ctime = de.time;
548 de.cdate = de.date;
549 de.adate = de.date;
550 de.starthi = 0;
551 de.start = 0;
552 de.size = 0;
553 }
554
555 fs_write(offset, sizeof(DIR_ENT), &de);
556 }
557
558 void write_label(DOS_FS * fs, char *label)
559 {
560 int l = strlen(label);
561
562 while (l < 11)
563 label[l++] = ' ';
564
565 write_boot_label(fs, label);
566 write_volume_label(fs, label);
567 }
0 /* boot.h - Read and analyze ia PC/MS-DOS boot sector
1
2 Copyright (C) 1993 Werner Almesberger <werner.almesberger@lrc.di.epfl.ch>
3 Copyright (C) 2008-2014 Daniel Baumann <mail@daniel-baumann.ch>
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 The complete text of the GNU General Public License
19 can be found in /usr/share/common-licenses/GPL-3 file.
20 */
21
22 #ifndef _BOOT_H
23 #define _BOOT_H
24
25 void read_boot(DOS_FS * fs);
26 void write_label(DOS_FS * fs, char *label);
27 loff_t find_volume_de(DOS_FS * fs, DIR_ENT * de);
28
29 /* Reads the boot sector from the currently open device and initializes *FS */
30
31 #endif
0 #include "charconv.h"
1 #include <iconv.h>
2 #include <langinfo.h>
3 #include <locale.h>
4 #include <stdio.h>
5
6 static iconv_t iconv_init_codepage(int codepage)
7 {
8 iconv_t result;
9 char codepage_name[16];
10 snprintf(codepage_name, sizeof(codepage_name), "CP%d", codepage);
11 result = iconv_open(nl_langinfo(CODESET), codepage_name);
12 if (result == (iconv_t) - 1)
13 perror(codepage_name);
14 return result;
15 }
16
17 static iconv_t dos_to_local;
18
19 /*
20 * Initialize conversion from codepage.
21 * codepage = -1 means default codepage.
22 * Returns 0 on success, non-zero on failure
23 */
24 static int init_conversion(int codepage)
25 {
26 static int initialized = -1;
27 if (initialized < 0) {
28 initialized = 1;
29 if (codepage < 0)
30 codepage = DEFAULT_DOS_CODEPAGE;
31 setlocale(LC_ALL, ""); /* initialize locale */
32 dos_to_local = iconv_init_codepage(codepage);
33 if (dos_to_local == (iconv_t) - 1 && codepage != DEFAULT_DOS_CODEPAGE) {
34 printf("Trying to set fallback DOS codepage %d\n",
35 DEFAULT_DOS_CODEPAGE);
36 dos_to_local = iconv_init_codepage(DEFAULT_DOS_CODEPAGE);
37 if (dos_to_local == (iconv_t) - 1)
38 initialized = 0; /* no conversion available */
39 }
40 }
41 return initialized;
42 }
43
44 int set_dos_codepage(int codepage)
45 {
46 return init_conversion(codepage);
47 }
48
49 int dos_char_to_printable(char **p, unsigned char c)
50 {
51 char in[1] = { c };
52 char *pin = in;
53 size_t bytes_in = 1;
54 size_t bytes_out = 4;
55 if (!init_conversion(-1))
56 return 0;
57 return iconv(dos_to_local, &pin, &bytes_in, p, &bytes_out) != -1;
58 }
0 #ifndef _CHARCONV_H
1 #define _CHARCONV_H
2
3 #define DEFAULT_DOS_CODEPAGE 437
4
5 int set_dos_codepage(int codepage);
6 int dos_char_to_printable(char **p, unsigned char c);
7
8 #endif
0 /* check.c - Check and repair a PC/MS-DOS filesystem
1
2 Copyright (C) 1993 Werner Almesberger <werner.almesberger@lrc.di.epfl.ch>
3 Copyright (C) 1998 Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de>
4 Copyright (C) 2008-2014 Daniel Baumann <mail@daniel-baumann.ch>
5
6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
18
19 The complete text of the GNU General Public License
20 can be found in /usr/share/common-licenses/GPL-3 file.
21 */
22
23 /* FAT32, VFAT, Atari format support, and various fixes additions May 1998
24 * by Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de> */
25
26 #include <stdio.h>
27 #include <stdlib.h>
28 #include <string.h>
29 #include <limits.h>
30 #include <time.h>
31
32 #include "common.h"
33 #include "fsck.fat.h"
34 #include "io.h"
35 #include "fat.h"
36 #include "file.h"
37 #include "lfn.h"
38 #include "check.h"
39
40 static DOS_FILE *root;
41
42 /* get start field of a dir entry */
43 #define FSTART(p,fs) \
44 ((uint32_t)le16toh(p->dir_ent.start) | \
45 (fs->fat_bits == 32 ? le16toh(p->dir_ent.starthi) << 16 : 0))
46
47 #define MODIFY(p,i,v) \
48 do { \
49 if (p->offset) { \
50 p->dir_ent.i = v; \
51 fs_write(p->offset+offsetof(DIR_ENT,i), \
52 sizeof(p->dir_ent.i),&p->dir_ent.i); \
53 } \
54 } while(0)
55
56 #define MODIFY_START(p,v,fs) \
57 do { \
58 uint32_t __v = (v); \
59 if (!p->offset) { \
60 /* writing to fake entry for FAT32 root dir */ \
61 if (!__v) die("Oops, deleting FAT32 root dir!"); \
62 fs->root_cluster = __v; \
63 p->dir_ent.start = htole16(__v&0xffff); \
64 p->dir_ent.starthi = htole16(__v>>16); \
65 __v = htole32(__v); \
66 fs_write((loff_t)offsetof(struct boot_sector,root_cluster), \
67 sizeof(((struct boot_sector *)0)->root_cluster), \
68 &__v); \
69 } \
70 else { \
71 MODIFY(p,start,htole16((__v)&0xffff)); \
72 if (fs->fat_bits == 32) \
73 MODIFY(p,starthi,htole16((__v)>>16)); \
74 } \
75 } while(0)
76
77 loff_t alloc_rootdir_entry(DOS_FS * fs, DIR_ENT * de, const char *pattern)
78 {
79 static int curr_num = 0;
80 loff_t offset;
81
82 if (fs->root_cluster) {
83 DIR_ENT d2;
84 int i = 0, got = 0;
85 uint32_t clu_num, prev = 0;
86 loff_t offset2;
87
88 clu_num = fs->root_cluster;
89 offset = cluster_start(fs, clu_num);
90 while (clu_num > 0 && clu_num != -1) {
91 fs_read(offset, sizeof(DIR_ENT), &d2);
92 if (IS_FREE(d2.name) && d2.attr != VFAT_LN_ATTR) {
93 got = 1;
94 break;
95 }
96 i += sizeof(DIR_ENT);
97 offset += sizeof(DIR_ENT);
98 if ((i % fs->cluster_size) == 0) {
99 prev = clu_num;
100 if ((clu_num = next_cluster(fs, clu_num)) == 0 || clu_num == -1)
101 break;
102 offset = cluster_start(fs, clu_num);
103 }
104 }
105 if (!got) {
106 /* no free slot, need to extend root dir: alloc next free cluster
107 * after previous one */
108 if (!prev)
109 die("Root directory has no cluster allocated!");
110 for (clu_num = prev + 1; clu_num != prev; clu_num++) {
111 FAT_ENTRY entry;
112
113 if (clu_num >= fs->clusters + 2)
114 clu_num = 2;
115 get_fat(&entry, fs->fat, clu_num, fs);
116 if (!entry.value)
117 break;
118 }
119 if (clu_num == prev)
120 die("Root directory full and no free cluster");
121 set_fat(fs, prev, clu_num);
122 set_fat(fs, clu_num, -1);
123 set_owner(fs, clu_num, get_owner(fs, fs->root_cluster));
124 /* clear new cluster */
125 memset(&d2, 0, sizeof(d2));
126 offset = cluster_start(fs, clu_num);
127 for (i = 0; i < fs->cluster_size; i += sizeof(DIR_ENT))
128 fs_write(offset + i, sizeof(d2), &d2);
129 }
130 memset(de, 0, sizeof(DIR_ENT));
131 while (1) {
132 char expanded[12];
133 sprintf(expanded, pattern, curr_num);
134 memcpy(de->name, expanded, 8);
135 memcpy(de->ext, expanded + 8, 3);
136 clu_num = fs->root_cluster;
137 i = 0;
138 offset2 = cluster_start(fs, clu_num);
139 while (clu_num > 0 && clu_num != -1) {
140 fs_read(offset2, sizeof(DIR_ENT), &d2);
141 if (offset2 != offset &&
142 !strncmp((const char *)d2.name, (const char *)de->name,
143 MSDOS_NAME))
144 break;
145 i += sizeof(DIR_ENT);
146 offset2 += sizeof(DIR_ENT);
147 if ((i % fs->cluster_size) == 0) {
148 if ((clu_num = next_cluster(fs, clu_num)) == 0 ||
149 clu_num == -1)
150 break;
151 offset2 = cluster_start(fs, clu_num);
152 }
153 }
154 if (clu_num == 0 || clu_num == -1)
155 break;
156 if (++curr_num >= 10000)
157 die("Unable to create unique name");
158 }
159 } else {
160 DIR_ENT *root;
161 int next_free = 0, scan;
162
163 root = alloc(fs->root_entries * sizeof(DIR_ENT));
164 fs_read(fs->root_start, fs->root_entries * sizeof(DIR_ENT), root);
165
166 while (next_free < fs->root_entries)
167 if (IS_FREE(root[next_free].name) &&
168 root[next_free].attr != VFAT_LN_ATTR)
169 break;
170 else
171 next_free++;
172 if (next_free == fs->root_entries)
173 die("Root directory is full.");
174 offset = fs->root_start + next_free * sizeof(DIR_ENT);
175 memset(de, 0, sizeof(DIR_ENT));
176 while (1) {
177 char expanded[12];
178 sprintf(expanded, pattern, curr_num);
179 memcpy(de->name, expanded, 8);
180 memcpy(de->ext, expanded + 8, 3);
181 for (scan = 0; scan < fs->root_entries; scan++)
182 if (scan != next_free &&
183 !strncmp((const char *)root[scan].name,
184 (const char *)de->name, MSDOS_NAME))
185 break;
186 if (scan == fs->root_entries)
187 break;
188 if (++curr_num >= 10000)
189 die("Unable to create unique name");
190 }
191 free(root);
192 }
193 ++n_files;
194 return offset;
195 }
196
197 /**
198 * Construct a full path (starting with '/') for the specified dentry,
199 * relative to the partition. All components are "long" names where possible.
200 *
201 * @param[in] file Information about dentry (file or directory) of interest
202 *
203 * return Pointer to static string containing file's full path
204 */
205 static char *path_name(DOS_FILE * file)
206 {
207 static char path[PATH_MAX * 2];
208
209 if (!file)
210 *path = 0; /* Reached the root directory */
211 else {
212 if (strlen(path_name(file->parent)) > PATH_MAX)
213 die("Path name too long.");
214 if (strcmp(path, "/") != 0)
215 strcat(path, "/");
216
217 /* Append the long name to the path,
218 * or the short name if there isn't a long one
219 */
220 strcpy(strrchr(path, 0),
221 file->lfn ? file->lfn : file_name(file->dir_ent.name));
222 }
223 return path;
224 }
225
226 static int day_n[] =
227 { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 0, 0, 0, 0 };
228 /* JanFebMarApr May Jun Jul Aug Sep Oct Nov Dec */
229
230 /* Convert a MS-DOS time/date pair to a UNIX date (seconds since 1 1 70). */
231
232 static time_t date_dos2unix(unsigned short time, unsigned short date)
233 {
234 int month, year;
235 time_t secs;
236
237 month = ((date >> 5) & 15) - 1;
238 year = date >> 9;
239 secs =
240 (time & 31) * 2 + 60 * ((time >> 5) & 63) + (time >> 11) * 3600 +
241 86400 * ((date & 31) - 1 + day_n[month] + (year / 4) + year * 365 -
242 ((year & 3) == 0 && month < 2 ? 1 : 0) + 3653);
243 /* days since 1.1.70 plus 80's leap day */
244 return secs;
245 }
246
247 static char *file_stat(DOS_FILE * file)
248 {
249 static char temp[100];
250 struct tm *tm;
251 char tmp[100];
252 time_t date;
253
254 date =
255 date_dos2unix(le16toh(file->dir_ent.time), le16toh(file->dir_ent.date));
256 tm = localtime(&date);
257 strftime(tmp, 99, "%H:%M:%S %b %d %Y", tm);
258 sprintf(temp, " Size %u bytes, date %s", le32toh(file->dir_ent.size), tmp);
259 return temp;
260 }
261
262 static int bad_name(DOS_FILE * file)
263 {
264 int i, spc, suspicious = 0;
265 const char *bad_chars = atari_format ? "*?\\/:" : "*?<>|\"\\/:";
266 const unsigned char *name = file->dir_ent.name;
267 const unsigned char *ext = file->dir_ent.ext;
268
269 /* Do not complain about (and auto-correct) the extended attribute files
270 * of OS/2. */
271 if (strncmp((const char *)name, "EA DATA SF", 11) == 0 ||
272 strncmp((const char *)name, "WP ROOT SF", 11) == 0)
273 return 0;
274
275 /* PATCH ED+DL */
276 /* check if we have neither a long filename nor a short name */
277 if ((file->lfn == NULL) && (file->dir_ent.lcase & FAT_NO_83NAME)) {
278 return 1;
279 }
280
281 /* don't complain about the dummy 11 bytes used by patched Linux
282 kernels */
283 if (file->dir_ent.lcase & FAT_NO_83NAME)
284 return 0;
285
286 for (i = 0; i < 8; i++) {
287 if (name[i] < ' ' || name[i] == 0x7f)
288 return 1;
289 if (name[i] > 0x7f)
290 ++suspicious;
291 if (strchr(bad_chars, name[i]))
292 return 1;
293 }
294
295 for (i = 0; i < 3; i++) {
296 if (ext[i] < ' ' || ext[i] == 0x7f)
297 return 1;
298 if (ext[i] > 0x7f)
299 ++suspicious;
300 if (strchr(bad_chars, ext[i]))
301 return 1;
302 }
303
304 spc = 0;
305 for (i = 0; i < 8; i++) {
306 if (name[i] == ' ')
307 spc = 1;
308 else if (spc)
309 /* non-space after a space not allowed, space terminates the name
310 * part */
311 return 1;
312 }
313
314 spc = 0;
315 for (i = 0; i < 3; i++) {
316 if (ext[i] == ' ')
317 spc = 1;
318 else if (spc)
319 /* non-space after a space not allowed, space terminates the ext
320 * part */
321 return 1;
322 }
323
324 /* Under GEMDOS, chars >= 128 are never allowed. */
325 if (atari_format && suspicious)
326 return 1;
327
328 /* Under MS-DOS and Windows, chars >= 128 in short names are valid
329 * (but these characters can be visualised differently depending on
330 * local codepage: CP437, CP866, etc). The chars are all basically ok,
331 * so we shouldn't auto-correct such names. */
332 return 0;
333 }
334
335 static void lfn_remove(loff_t from, loff_t to)
336 {
337 DIR_ENT empty;
338
339 /* New dir entry is zeroed except first byte, which is set to 0xe5.
340 * This is to avoid that some FAT-reading OSes (not Linux! ;) stop reading
341 * a directory at the first zero entry...
342 */
343 memset(&empty, 0, sizeof(empty));
344 empty.name[0] = DELETED_FLAG;
345
346 for (; from < to; from += sizeof(empty)) {
347 fs_write(from, sizeof(DIR_ENT), &empty);
348 }
349 }
350
351 static void drop_file(DOS_FS * fs, DOS_FILE * file)
352 {
353 uint32_t cluster;
354
355 MODIFY(file, name[0], DELETED_FLAG);
356 if (file->lfn)
357 lfn_remove(file->lfn_offset, file->offset);
358 for (cluster = FSTART(file, fs); cluster > 0 && cluster <
359 fs->clusters + 2; cluster = next_cluster(fs, cluster))
360 set_owner(fs, cluster, NULL);
361 --n_files;
362 }
363
364 static void truncate_file(DOS_FS * fs, DOS_FILE * file, uint32_t clusters)
365 {
366 int deleting;
367 uint32_t walk, next;
368
369 walk = FSTART(file, fs);
370 if ((deleting = !clusters))
371 MODIFY_START(file, 0, fs);
372 while (walk > 0 && walk != -1) {
373 next = next_cluster(fs, walk);
374 if (deleting)
375 set_fat(fs, walk, 0);
376 else if ((deleting = !--clusters))
377 set_fat(fs, walk, -1);
378 walk = next;
379 }
380 }
381
382 static void auto_rename(DOS_FILE * file)
383 {
384 DOS_FILE *first, *walk;
385 uint32_t number;
386
387 if (!file->offset)
388 return; /* cannot rename FAT32 root dir */
389 first = file->parent ? file->parent->first : root;
390 number = 0;
391 while (1) {
392 char num[8];
393 sprintf(num, "%07lu", (unsigned long)number);
394 memcpy(file->dir_ent.name, "FSCK", 4);
395 memcpy(file->dir_ent.name + 4, num, 4);
396 memcpy(file->dir_ent.ext, num + 4, 3);
397 for (walk = first; walk; walk = walk->next)
398 if (walk != file
399 && !strncmp((const char *)walk->dir_ent.name,
400 (const char *)file->dir_ent.name, MSDOS_NAME))
401 break;
402 if (!walk) {
403 /* PATCH ED+DL */
404 if(file->dir_ent.lcase & FAT_NO_83NAME)
405 {
406 /* as we only assign a new 8.3 filename, reset flag that 8.3 name is not
407 present */
408 file->dir_ent.lcase &= ~FAT_NO_83NAME;
409 /* reset the attributes */
410 file->dir_ent.attr &= ~(ATTR_DIR | ATTR_VOLUME); /* only keep the DIR and VOLUME attributes */
411 fs_write(file->offset, MSDOS_NAME+2, file->dir_ent.name);
412 }
413 else
414 {
415 fs_write(file->offset, MSDOS_NAME, file->dir_ent.name);
416 }
417 if (file->lfn)
418 lfn_fix_checksum(file->lfn_offset, file->offset,
419 (const char *)file->dir_ent.name);
420 return;
421 }
422 number++;
423 if (number > 9999999) {
424 die("Too many files need repair.");
425 }
426 }
427 die("Can't generate a unique name.");
428 }
429
430 static void rename_file(DOS_FILE * file)
431 {
432 unsigned char name[46];
433 unsigned char *walk, *here;
434
435 if (!file->offset) {
436 printf("Cannot rename FAT32 root dir\n");
437 return; /* cannot rename FAT32 root dir */
438 }
439 while (1) {
440 printf("New name: ");
441 fflush(stdout);
442 if (fgets((char *)name, 45, stdin)) {
443 if ((here = (unsigned char *)strchr((const char *)name, '\n')))
444 *here = 0;
445 for (walk = (unsigned char *)strrchr((const char *)name, 0);
446 walk >= name && (*walk == ' ' || *walk == '\t'); walk--) ;
447 walk[1] = 0;
448 for (walk = name; *walk == ' ' || *walk == '\t'; walk++) ;
449 if (file_cvt(walk, file->dir_ent.name)) {
450 /* PATCH ED+DL */
451 if(file->dir_ent.lcase & FAT_NO_83NAME)
452 {
453 /* as we only assign a new 8.3 filename, reset flag that 8.3 name is not
454 present */
455 file->dir_ent.lcase &= ~FAT_NO_83NAME;
456 /* reset the attributes */
457 file->dir_ent.attr &= ~(ATTR_DIR | ATTR_VOLUME); /* only keep the DIR and VOLUME attributes */
458 fs_write(file->offset, MSDOS_NAME+2, file->dir_ent.name);
459 }
460 else
461 {
462 fs_write(file->offset, MSDOS_NAME, file->dir_ent.name);
463 }
464 if (file->lfn)
465 lfn_fix_checksum(file->lfn_offset, file->offset,
466 (const char *)file->dir_ent.name);
467 return;
468 }
469 }
470 }
471 }
472
473 static int handle_dot(DOS_FS * fs, DOS_FILE * file, int dots)
474 {
475 char *name;
476
477 name =
478 strncmp((const char *)file->dir_ent.name, MSDOS_DOT,
479 MSDOS_NAME) ? ".." : ".";
480 if (!(file->dir_ent.attr & ATTR_DIR)) {
481 printf("%s\n Is a non-directory.\n", path_name(file));
482 if (interactive)
483 printf("1) Drop it\n2) Auto-rename\n3) Rename\n"
484 "4) Convert to directory\n");
485 else
486 printf(" Auto-renaming it.\n");
487 switch (interactive ? get_key("1234", "?") : '2') {
488 case '1':
489 drop_file(fs, file);
490 return 1;
491 case '2':
492 auto_rename(file);
493 printf(" Renamed to %s\n", file_name(file->dir_ent.name));
494 return 0;
495 case '3':
496 rename_file(file);
497 return 0;
498 case '4':
499 MODIFY(file, size, htole32(0));
500 MODIFY(file, attr, file->dir_ent.attr | ATTR_DIR);
501 break;
502 }
503 }
504 if (!dots) {
505 printf("Root contains directory \"%s\". Dropping it.\n", name);
506 drop_file(fs, file);
507 return 1;
508 }
509 return 0;
510 }
511
512 static int check_file(DOS_FS * fs, DOS_FILE * file)
513 {
514 DOS_FILE *owner;
515 int restart;
516 uint32_t expect, curr, this, clusters, prev, walk, clusters2;
517
518 if (file->dir_ent.attr & ATTR_DIR) {
519 if (le32toh(file->dir_ent.size)) {
520 printf("%s\n Directory has non-zero size. Fixing it.\n",
521 path_name(file));
522 MODIFY(file, size, htole32(0));
523 }
524 if (file->parent
525 && !strncmp((const char *)file->dir_ent.name, MSDOS_DOT,
526 MSDOS_NAME)) {
527 expect = FSTART(file->parent, fs);
528 if (FSTART(file, fs) != expect) {
529 printf("%s\n Start (%lu) does not point to parent (%lu)\n",
530 path_name(file), (unsigned long)FSTART(file, fs), (long)expect);
531 MODIFY_START(file, expect, fs);
532 }
533 return 0;
534 }
535 if (file->parent
536 && !strncmp((const char *)file->dir_ent.name, MSDOS_DOTDOT,
537 MSDOS_NAME)) {
538 expect =
539 file->parent->parent ? FSTART(file->parent->parent, fs) : 0;
540 if (fs->root_cluster && expect == fs->root_cluster)
541 expect = 0;
542 if (FSTART(file, fs) != expect) {
543 printf("%s\n Start (%lu) does not point to .. (%lu)\n",
544 path_name(file), (unsigned long)FSTART(file, fs), (unsigned long)expect);
545 MODIFY_START(file, expect, fs);
546 }
547 return 0;
548 }
549 if (FSTART(file, fs) == 0) {
550 printf("%s\n Start does point to root directory. Deleting dir. \n",
551 path_name(file));
552 MODIFY(file, name[0], DELETED_FLAG);
553 return 0;
554 }
555 }
556 if (FSTART(file, fs) >= fs->clusters + 2) {
557 printf
558 ("%s\n Start cluster beyond limit (%lu > %lu). Truncating file.\n",
559 path_name(file), (unsigned long)FSTART(file, fs), (unsigned long)(fs->clusters + 1));
560 if (!file->offset)
561 die("Bad FAT32 root directory! (bad start cluster)\n");
562 MODIFY_START(file, 0, fs);
563 }
564 clusters = prev = 0;
565 for (curr = FSTART(file, fs) ? FSTART(file, fs) :
566 -1; curr != -1; curr = next_cluster(fs, curr)) {
567 FAT_ENTRY curEntry;
568 get_fat(&curEntry, fs->fat, curr, fs);
569
570 if (!curEntry.value || bad_cluster(fs, curr)) {
571 printf("%s\n Contains a %s cluster (%lu). Assuming EOF.\n",
572 path_name(file), curEntry.value ? "bad" : "free", (unsigned long)curr);
573 if (prev)
574 set_fat(fs, prev, -1);
575 else if (!file->offset)
576 die("FAT32 root dir starts with a bad cluster!");
577 else
578 MODIFY_START(file, 0, fs);
579 break;
580 }
581 if (!(file->dir_ent.attr & ATTR_DIR) && le32toh(file->dir_ent.size) <=
582 (uint64_t)clusters * fs->cluster_size) {
583 printf
584 ("%s\n File size is %u bytes, cluster chain length is > %lu "
585 "bytes.\n Truncating file to %u bytes.\n", path_name(file),
586 le32toh(file->dir_ent.size),
587 (uint64_t)clusters * fs->cluster_size,
588 le32toh(file->dir_ent.size));
589 truncate_file(fs, file, clusters);
590 break;
591 }
592 if ((owner = get_owner(fs, curr))) {
593 int do_trunc = 0;
594 printf("%s and\n", path_name(owner));
595 printf("%s\n share clusters.\n", path_name(file));
596 clusters2 = 0;
597 for (walk = FSTART(owner, fs); walk > 0 && walk != -1; walk =
598 next_cluster(fs, walk))
599 if (walk == curr)
600 break;
601 else
602 clusters2++;
603 restart = file->dir_ent.attr & ATTR_DIR;
604 if (!owner->offset) {
605 printf(" Truncating second to %llu bytes because first "
606 "is FAT32 root dir.\n",
607 (unsigned long long)clusters2 * fs->cluster_size);
608 do_trunc = 2;
609 } else if (!file->offset) {
610 printf(" Truncating first to %llu bytes because second "
611 "is FAT32 root dir.\n",
612 (unsigned long long)clusters * fs->cluster_size);
613 do_trunc = 1;
614 } else if (interactive)
615 printf("1) Truncate first to %llu bytes%s\n"
616 "2) Truncate second to %llu bytes\n",
617 (unsigned long long)clusters * fs->cluster_size,
618 restart ? " and restart" : "",
619 (unsigned long long)clusters2 * fs->cluster_size);
620 else
621 printf(" Truncating second to %llu bytes.\n",
622 (unsigned long long)clusters2 * fs->cluster_size);
623 if (do_trunc != 2
624 && (do_trunc == 1
625 || (interactive && get_key("12", "?") == '1'))) {
626 prev = 0;
627 clusters = 0;
628 for (this = FSTART(owner, fs); this > 0 && this != -1; this =
629 next_cluster(fs, this)) {
630 if (this == curr) {
631 if (prev)
632 set_fat(fs, prev, -1);
633 else
634 MODIFY_START(owner, 0, fs);
635 MODIFY(owner, size,
636 htole32((uint64_t)clusters *
637 fs->cluster_size));
638 if (restart)
639 return 1;
640 while (this > 0 && this != -1) {
641 set_owner(fs, this, NULL);
642 this = next_cluster(fs, this);
643 }
644 this = curr;
645 break;
646 }
647 clusters++;
648 prev = this;
649 }
650 if (this != curr)
651 die("Internal error: didn't find cluster %d in chain"
652 " starting at %d", curr, FSTART(owner, fs));
653 } else {
654 if (prev)
655 set_fat(fs, prev, -1);
656 else
657 MODIFY_START(file, 0, fs);
658 break;
659 }
660 }
661 set_owner(fs, curr, file);
662 clusters++;
663 prev = curr;
664 }
665 if (!(file->dir_ent.attr & ATTR_DIR) && le32toh(file->dir_ent.size) >
666 (uint64_t)clusters * fs->cluster_size) {
667 printf
668 ("%s\n File size is %u bytes, cluster chain length is %llu bytes."
669 "\n Truncating file to %llu bytes.\n", path_name(file),
670 le32toh(file->dir_ent.size),
671 (unsigned long long)clusters * fs->cluster_size,
672 (unsigned long long)clusters * fs->cluster_size);
673 MODIFY(file, size,
674 htole32((uint64_t)clusters * fs->cluster_size));
675 }
676 return 0;
677 }
678
679 static int check_files(DOS_FS * fs, DOS_FILE * start)
680 {
681 while (start) {
682 if (check_file(fs, start))
683 return 1;
684 start = start->next;
685 }
686 return 0;
687 }
688
689 static int check_dir(DOS_FS * fs, DOS_FILE ** root, int dots)
690 {
691 DOS_FILE *parent, **walk, **scan;
692 int dot, dotdot, skip, redo;
693 int good, bad;
694
695 if (!*root)
696 return 0;
697 parent = (*root)->parent;
698 good = bad = 0;
699 for (walk = root; *walk; walk = &(*walk)->next)
700 if (bad_name(*walk))
701 bad++;
702 else
703 good++;
704 if (*root && parent && good + bad > 4 && bad > good / 2) {
705 printf("%s\n Has a large number of bad entries. (%d/%d)\n",
706 path_name(parent), bad, good + bad);
707 if (!dots)
708 printf(" Not dropping root directory.\n");
709 else if (!interactive)
710 printf(" Not dropping it in auto-mode.\n");
711 else if (get_key("yn", "Drop directory ? (y/n)") == 'y') {
712 truncate_file(fs, parent, 0);
713 MODIFY(parent, name[0], DELETED_FLAG);
714 /* buglet: deleted directory stays in the list. */
715 return 1;
716 }
717 }
718 dot = dotdot = redo = 0;
719 walk = root;
720 while (*walk) {
721 if (!strncmp
722 ((const char *)((*walk)->dir_ent.name), MSDOS_DOT, MSDOS_NAME)
723 || !strncmp((const char *)((*walk)->dir_ent.name), MSDOS_DOTDOT,
724 MSDOS_NAME)) {
725 if (handle_dot(fs, *walk, dots)) {
726 *walk = (*walk)->next;
727 continue;
728 }
729 if (!strncmp
730 ((const char *)((*walk)->dir_ent.name), MSDOS_DOT, MSDOS_NAME))
731 dot++;
732 else
733 dotdot++;
734 }
735 if (!((*walk)->dir_ent.attr & ATTR_VOLUME) && bad_name(*walk)) {
736 puts(path_name(*walk));
737 printf(" Bad short file name (%s).\n",
738 file_name((*walk)->dir_ent.name));
739 if (interactive)
740 printf("1) Drop file\n2) Rename file\n3) Auto-rename\n"
741 "4) Keep it\n");
742 else
743 printf(" Auto-renaming it.\n");
744 switch (interactive ? get_key("1234", "?") : '3') {
745 case '1':
746 drop_file(fs, *walk);
747 walk = &(*walk)->next;
748 continue;
749 case '2':
750 rename_file(*walk);
751 redo = 1;
752 break;
753 case '3':
754 auto_rename(*walk);
755 printf(" Renamed to %s\n", file_name((*walk)->dir_ent.name));
756 break;
757 case '4':
758 break;
759 }
760 }
761 /* don't check for duplicates of the volume label */
762 if (!((*walk)->dir_ent.attr & ATTR_VOLUME)) {
763 scan = &(*walk)->next;
764 skip = 0;
765 while (*scan && !skip) {
766 if (!((*scan)->dir_ent.attr & ATTR_VOLUME) &&
767 !memcmp((*walk)->dir_ent.name, (*scan)->dir_ent.name,
768 MSDOS_NAME)) {
769 printf("%s\n Duplicate directory entry.\n First %s\n",
770 path_name(*walk), file_stat(*walk));
771 printf(" Second %s\n", file_stat(*scan));
772 if (interactive)
773 printf
774 ("1) Drop first\n2) Drop second\n3) Rename first\n"
775 "4) Rename second\n5) Auto-rename first\n"
776 "6) Auto-rename second\n");
777 else
778 printf(" Auto-renaming second.\n");
779 switch (interactive ? get_key("123456", "?") : '6') {
780 case '1':
781 drop_file(fs, *walk);
782 *walk = (*walk)->next;
783 skip = 1;
784 break;
785 case '2':
786 drop_file(fs, *scan);
787 *scan = (*scan)->next;
788 continue;
789 case '3':
790 rename_file(*walk);
791 printf(" Renamed to %s\n", path_name(*walk));
792 redo = 1;
793 break;
794 case '4':
795 rename_file(*scan);
796 printf(" Renamed to %s\n", path_name(*walk));
797 redo = 1;
798 break;
799 case '5':
800 auto_rename(*walk);
801 printf(" Renamed to %s\n",
802 file_name((*walk)->dir_ent.name));
803 break;
804 case '6':
805 auto_rename(*scan);
806 printf(" Renamed to %s\n",
807 file_name((*scan)->dir_ent.name));
808 break;
809 }
810 }
811 scan = &(*scan)->next;
812 }
813 if (skip)
814 continue;
815 }
816 if (!redo)
817 walk = &(*walk)->next;
818 else {
819 walk = root;
820 dot = dotdot = redo = 0;
821 }
822 }
823 if (dots && !dot)
824 printf("%s\n \".\" is missing. Can't fix this yet.\n",
825 path_name(parent));
826 if (dots && !dotdot)
827 printf("%s\n \"..\" is missing. Can't fix this yet.\n",
828 path_name(parent));
829 return 0;
830 }
831
832 /**
833 * Check a dentry's cluster chain for bad clusters.
834 * If requested, we verify readability and mark unreadable clusters as bad.
835 *
836 * @param[inout] fs Information about the filesystem
837 * @param[in] file dentry to check
838 * @param[in] read_test Nonzero == verify that dentry's clusters can
839 * be read
840 */
841 static void test_file(DOS_FS * fs, DOS_FILE * file, int read_test)
842 {
843 DOS_FILE *owner;
844 uint32_t walk, prev, clusters, next_clu;
845
846 prev = clusters = 0;
847 for (walk = FSTART(file, fs); walk > 0 && walk < fs->clusters + 2;
848 walk = next_clu) {
849 next_clu = next_cluster(fs, walk);
850
851 /* In this stage we are checking only for a loop within our own
852 * cluster chain.
853 * Cross-linking of clusters is handled in check_file()
854 */
855 if ((owner = get_owner(fs, walk))) {
856 if (owner == file) {
857 printf("%s\n Circular cluster chain. Truncating to %lu "
858 "cluster%s.\n", path_name(file), (unsigned long)clusters,
859 clusters == 1 ? "" : "s");
860 if (prev)
861 set_fat(fs, prev, -1);
862 else if (!file->offset)
863 die("Bad FAT32 root directory! (bad start cluster)\n");
864 else
865 MODIFY_START(file, 0, fs);
866 }
867 break;
868 }
869 if (bad_cluster(fs, walk))
870 break;
871 if (read_test) {
872 if (fs_test(cluster_start(fs, walk), fs->cluster_size)) {
873 prev = walk;
874 clusters++;
875 } else {
876 printf("%s\n Cluster %lu (%lu) is unreadable. Skipping it.\n",
877 path_name(file), (unsigned long)clusters, (unsigned long)walk);
878 if (prev)
879 set_fat(fs, prev, next_cluster(fs, walk));
880 else
881 MODIFY_START(file, next_cluster(fs, walk), fs);
882 set_fat(fs, walk, -2);
883 }
884 }
885 set_owner(fs, walk, file);
886 }
887 /* Revert ownership (for now) */
888 for (walk = FSTART(file, fs); walk > 0 && walk < fs->clusters + 2;
889 walk = next_cluster(fs, walk))
890 if (bad_cluster(fs, walk))
891 break;
892 else if (get_owner(fs, walk) == file)
893 set_owner(fs, walk, NULL);
894 else
895 break;
896 }
897
898 static void undelete(DOS_FS * fs, DOS_FILE * file)
899 {
900 uint32_t clusters, left, prev, walk;
901
902 clusters = left = (le32toh(file->dir_ent.size) + fs->cluster_size - 1) /
903 fs->cluster_size;
904 prev = 0;
905
906 walk = FSTART(file, fs);
907
908 while (left && (walk >= 2) && (walk < fs->clusters + 2)) {
909
910 FAT_ENTRY curEntry;
911 get_fat(&curEntry, fs->fat, walk, fs);
912
913 if (!curEntry.value)
914 break;
915
916 left--;
917 if (prev)
918 set_fat(fs, prev, walk);
919 prev = walk;
920 walk++;
921 }
922 if (prev)
923 set_fat(fs, prev, -1);
924 else
925 MODIFY_START(file, 0, fs);
926 if (left)
927 printf("Warning: Did only undelete %lu of %lu cluster%s.\n",
928 (unsigned long)clusters - left, (unsigned long)clusters, clusters == 1 ? "" : "s");
929
930 }
931
932 static void new_dir(void)
933 {
934 lfn_reset();
935 }
936
937 /**
938 * Create a description for a referenced dentry and insert it in our dentry
939 * tree. Then, go check the dentry's cluster chain for bad clusters and
940 * cluster loops.
941 *
942 * @param[inout] fs Information about the filesystem
943 * @param[out] chain
944 * @param[in] parent Information about parent directory of this file
945 * NULL == no parent ('file' is root directory)
946 * @param[in] offset Partition-relative byte offset of directory entry of interest
947 * 0 == Root directory
948 * @param cp
949 */
950 static void add_file(DOS_FS * fs, DOS_FILE *** chain, DOS_FILE * parent,
951 loff_t offset, FDSC ** cp)
952 {
953 DOS_FILE *new;
954 DIR_ENT de;
955 FD_TYPE type;
956
957 if (offset)
958 fs_read(offset, sizeof(DIR_ENT), &de);
959 else {
960 /* Construct a DIR_ENT for the root directory */
961 memcpy(de.name, " ", MSDOS_NAME);
962 de.attr = ATTR_DIR;
963 de.size = de.time = de.date = 0;
964 de.start = htole16(fs->root_cluster & 0xffff);
965 de.starthi = htole16((fs->root_cluster >> 16) & 0xffff);
966 }
967 if ((type = file_type(cp, (char *)de.name)) != fdt_none) {
968 if (type == fdt_undelete && (de.attr & ATTR_DIR))
969 die("Can't undelete directories.");
970 file_modify(cp, (char *)de.name);
971 fs_write(offset, 1, &de);
972 }
973 if (IS_FREE(de.name)) {
974 lfn_check_orphaned();
975 return;
976 }
977 if (de.attr == VFAT_LN_ATTR) {
978 lfn_add_slot(&de, offset);
979 return;
980 }
981 new = qalloc(&mem_queue, sizeof(DOS_FILE));
982 new->lfn = lfn_get(&de, &new->lfn_offset);
983 new->offset = offset;
984 memcpy(&new->dir_ent, &de, sizeof(de));
985 new->next = new->first = NULL;
986 new->parent = parent;
987 if (type == fdt_undelete)
988 undelete(fs, new);
989 **chain = new;
990 *chain = &new->next;
991 if (list) {
992 printf("Checking file %s", path_name(new));
993 if (new->lfn)
994 printf(" (%s)", file_name(new->dir_ent.name)); /* (8.3) */
995 printf("\n");
996 }
997 /* Don't include root directory, '.', or '..' in the total file count */
998 if (offset &&
999 strncmp((const char *)de.name, MSDOS_DOT, MSDOS_NAME) != 0 &&
1000 strncmp((const char *)de.name, MSDOS_DOTDOT, MSDOS_NAME) != 0)
1001 ++n_files;
1002 test_file(fs, new, test); /* Bad cluster check */
1003 }
1004
1005 static int subdirs(DOS_FS * fs, DOS_FILE * parent, FDSC ** cp);
1006
1007 static int scan_dir(DOS_FS * fs, DOS_FILE * this, FDSC ** cp)
1008 {
1009 DOS_FILE **chain;
1010 int i;
1011 uint32_t clu_num;
1012
1013 chain = &this->first;
1014 i = 0;
1015 clu_num = FSTART(this, fs);
1016 new_dir();
1017 while (clu_num > 0 && clu_num != -1) {
1018 add_file(fs, &chain, this,
1019 cluster_start(fs, clu_num) + (i % fs->cluster_size), cp);
1020 i += sizeof(DIR_ENT);
1021 if (!(i % fs->cluster_size))
1022 if ((clu_num = next_cluster(fs, clu_num)) == 0 || clu_num == -1)
1023 break;
1024 }
1025 lfn_check_orphaned();
1026 if (check_dir(fs, &this->first, this->offset))
1027 return 0;
1028 if (check_files(fs, this->first))
1029 return 1;
1030 return subdirs(fs, this, cp);
1031 }
1032
1033 /**
1034 * Recursively scan subdirectories of the specified parent directory.
1035 *
1036 * @param[inout] fs Information about the filesystem
1037 * @param[in] parent Identifies the directory to scan
1038 * @param[in] cp
1039 *
1040 * @return 0 Success
1041 * @return 1 Error
1042 */
1043 static int subdirs(DOS_FS * fs, DOS_FILE * parent, FDSC ** cp)
1044 {
1045 DOS_FILE *walk;
1046
1047 for (walk = parent ? parent->first : root; walk; walk = walk->next)
1048 if (walk->dir_ent.attr & ATTR_DIR)
1049 if (strncmp((const char *)walk->dir_ent.name, MSDOS_DOT, MSDOS_NAME)
1050 && strncmp((const char *)walk->dir_ent.name, MSDOS_DOTDOT,
1051 MSDOS_NAME))
1052 if (scan_dir(fs, walk, file_cd(cp, (char *)walk->dir_ent.name)))
1053 return 1;
1054 return 0;
1055 }
1056
1057 /**
1058 * Scan all directory and file information for errors.
1059 *
1060 * @param[inout] fs Information about the filesystem
1061 *
1062 * @return 0 Success
1063 * @return 1 Error
1064 */
1065 int scan_root(DOS_FS * fs)
1066 {
1067 DOS_FILE **chain;
1068 int i;
1069
1070 root = NULL;
1071 chain = &root;
1072 new_dir();
1073 if (fs->root_cluster) {
1074 add_file(fs, &chain, NULL, 0, &fp_root);
1075 } else {
1076 for (i = 0; i < fs->root_entries; i++)
1077 add_file(fs, &chain, NULL, fs->root_start + i * sizeof(DIR_ENT),
1078 &fp_root);
1079 }
1080 lfn_check_orphaned();
1081 (void)check_dir(fs, &root, 0);
1082 if (check_files(fs, root))
1083 return 1;
1084 return subdirs(fs, NULL, &fp_root);
1085 }
0 /* check.h - Check and repair a PC/MS-DOS filesystem
1
2 Copyright (C) 1993 Werner Almesberger <werner.almesberger@lrc.di.epfl.ch>
3 Copyright (C) 2008-2014 Daniel Baumann <mail@daniel-baumann.ch>
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 The complete text of the GNU General Public License
19 can be found in /usr/share/common-licenses/GPL-3 file.
20 */
21
22 #ifndef _CHECK_H
23 #define _CHECK_H
24
25 loff_t alloc_rootdir_entry(DOS_FS * fs, DIR_ENT * de, const char *pattern);
26
27 /* Allocate a free slot in the root directory for a new file. The file name is
28 constructed after 'pattern', which must include a %d type format for printf
29 and expand to exactly 11 characters. The name actually used is written into
30 the 'de' structure, the rest of *de is cleared. The offset returned is to
31 where in the filesystem the entry belongs. */
32
33 int scan_root(DOS_FS * fs);
34
35 /* Scans the root directory and recurses into all subdirectories. See check.c
36 for all the details. Returns a non-zero integer if the filesystem has to
37 be checked again. */
38
39 #endif
0 /* common.c - Common functions
1
2 Copyright (C) 1993 Werner Almesberger <werner.almesberger@lrc.di.epfl.ch>
3 Copyright (C) 1998 Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de>
4 Copyright (C) 2008-2014 Daniel Baumann <mail@daniel-baumann.ch>
5
6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
18
19 The complete text of the GNU General Public License
20 can be found in /usr/share/common-licenses/GPL-3 file.
21 */
22
23 /* FAT32, VFAT, Atari format support, and various fixes additions May 1998
24 * by Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de> */
25
26 #include <stdlib.h>
27 #include <stdio.h>
28 #include <string.h>
29 #include <stdarg.h>
30 #include <errno.h>
31
32 #include "common.h"
33
34 typedef struct _link {
35 void *data;
36 struct _link *next;
37 } LINK;
38
39 void die(char *msg, ...)
40 {
41 va_list args;
42
43 va_start(args, msg);
44 vfprintf(stderr, msg, args);
45 va_end(args);
46 fprintf(stderr, "\n");
47 exit(1);
48 }
49
50 void pdie(char *msg, ...)
51 {
52 va_list args;
53
54 va_start(args, msg);
55 vfprintf(stderr, msg, args);
56 va_end(args);
57 fprintf(stderr, ":%s\n", strerror(errno));
58 exit(1);
59 }
60
61 void *alloc(int size)
62 {
63 void *this;
64
65 if ((this = malloc(size)))
66 return this;
67 pdie("malloc");
68 return NULL; /* for GCC */
69 }
70
71 void *qalloc(void **root, int size)
72 {
73 LINK *link;
74
75 link = alloc(sizeof(LINK));
76 link->next = *root;
77 *root = link;
78 return link->data = alloc(size);
79 }
80
81 void qfree(void **root)
82 {
83 LINK *this;
84
85 while (*root) {
86 this = (LINK *) * root;
87 *root = this->next;
88 free(this->data);
89 free(this);
90 }
91 }
92
93 int min(int a, int b)
94 {
95 return a < b ? a : b;
96 }
97
98 char get_key(char *valid, char *prompt)
99 {
100 int ch, okay;
101
102 while (1) {
103 if (prompt)
104 printf("%s ", prompt);
105 fflush(stdout);
106 while (ch = getchar(), ch == ' ' || ch == '\t') ;
107 if (ch == EOF)
108 exit(1);
109 if (!strchr(valid, okay = ch))
110 okay = 0;
111 while (ch = getchar(), ch != '\n' && ch != EOF) ;
112 if (ch == EOF)
113 exit(1);
114 if (okay)
115 return okay;
116 printf("Invalid input.\n");
117 }
118 }
0 /* common.h - Common functions
1
2 Copyright (C) 1993 Werner Almesberger <werner.almesberger@lrc.di.epfl.ch>
3 Copyright (C) 2008-2014 Daniel Baumann <mail@daniel-baumann.ch>
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 The complete text of the GNU General Public License
19 can be found in /usr/share/common-licenses/GPL-3 file.
20 */
21
22 #include <asm/types.h>
23
24 #ifndef _COMMON_H
25 #define _COMMON_H
26
27 void die(char *msg, ...) __attribute((noreturn));
28
29 /* Displays a prinf-style message and terminates the program. */
30
31 void pdie(char *msg, ...) __attribute((noreturn));
32
33 /* Like die, but appends an error message according to the state of errno. */
34
35 void *alloc(int size);
36
37 /* mallocs SIZE bytes and returns a pointer to the data. Terminates the program
38 if malloc fails. */
39
40 void *qalloc(void **root, int size);
41
42 /* Like alloc, but registers the data area in a list described by ROOT. */
43
44 void qfree(void **root);
45
46 /* Deallocates all qalloc'ed data areas described by ROOT. */
47
48 int min(int a, int b);
49
50 /* Returns the smaller integer value of a and b. */
51
52 char get_key(char *valid, char *prompt);
53
54 /* Displays PROMPT and waits for user input. Only characters in VALID are
55 accepted. Terminates the program on EOF. Returns the character. */
56
57 #endif
0 /* fat.c - Read/write access to the FAT
1
2 Copyright (C) 1993 Werner Almesberger <werner.almesberger@lrc.di.epfl.ch>
3 Copyright (C) 1998 Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de>
4 Copyright (C) 2008-2014 Daniel Baumann <mail@daniel-baumann.ch>
5
6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
18
19 The complete text of the GNU General Public License
20 can be found in /usr/share/common-licenses/GPL-3 file.
21 */
22
23 /* FAT32, VFAT, Atari format support, and various fixes additions May 1998
24 * by Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de> */
25
26 #include <stdio.h>
27 #include <stdlib.h>
28 #include <string.h>
29 #include <unistd.h>
30
31 #include "common.h"
32 #include "fsck.fat.h"
33 #include "io.h"
34 #include "check.h"
35 #include "fat.h"
36
37 /**
38 * Fetch the FAT entry for a specified cluster.
39 *
40 * @param[out] entry Cluster to which cluster of interest is linked
41 * @param[in] fat FAT table for the partition
42 * @param[in] cluster Cluster of interest
43 * @param[in] fs Information from the FAT boot sectors (bits per FAT entry)
44 */
45 void get_fat(FAT_ENTRY * entry, void *fat, uint32_t cluster, DOS_FS * fs)
46 {
47 unsigned char *ptr;
48
49 switch (fs->fat_bits) {
50 case 12:
51 ptr = &((unsigned char *)fat)[cluster * 3 / 2];
52 entry->value = 0xfff & (cluster & 1 ? (ptr[0] >> 4) | (ptr[1] << 4) :
53 (ptr[0] | ptr[1] << 8));
54 break;
55 case 16:
56 entry->value = le16toh(((unsigned short *)fat)[cluster]);
57 break;
58 case 32:
59 /* According to M$, the high 4 bits of a FAT32 entry are reserved and
60 * are not part of the cluster number. So we cut them off. */
61 {
62 uint32_t e = le32toh(((unsigned int *)fat)[cluster]);
63 entry->value = e & 0xfffffff;
64 entry->reserved = e >> 28;
65 }
66 break;
67 default:
68 die("Bad FAT entry size: %d bits.", fs->fat_bits);
69 }
70 }
71
72 /**
73 * Build a bookkeeping structure from the partition's FAT table.
74 * If the partition has multiple FATs and they don't agree, try to pick a winner,
75 * and queue a command to overwrite the loser.
76 * One error that is fixed here is a cluster that links to something out of range.
77 *
78 * @param[inout] fs Information about the filesystem
79 */
80 void read_fat(DOS_FS * fs)
81 {
82 int eff_size;
83 uint32_t i;
84 void *first, *second = NULL;
85 int first_ok, second_ok;
86 uint32_t total_num_clusters;
87
88 /* Clean up from previous pass */
89 if (fs->fat)
90 free(fs->fat);
91 if (fs->cluster_owner)
92 free(fs->cluster_owner);
93 fs->fat = NULL;
94 fs->cluster_owner = NULL;
95
96 total_num_clusters = fs->clusters + 2UL;
97 eff_size = (total_num_clusters * fs->fat_bits + 7) / 8ULL;
98 first = alloc(eff_size);
99 fs_read(fs->fat_start, eff_size, first);
100 if (fs->nfats > 1) {
101 second = alloc(eff_size);
102 fs_read(fs->fat_start + fs->fat_size, eff_size, second);
103 }
104 if (second && memcmp(first, second, eff_size) != 0) {
105 FAT_ENTRY first_media, second_media;
106 get_fat(&first_media, first, 0, fs);
107 get_fat(&second_media, second, 0, fs);
108 first_ok = (first_media.value & FAT_EXTD(fs)) == FAT_EXTD(fs);
109 second_ok = (second_media.value & FAT_EXTD(fs)) == FAT_EXTD(fs);
110 if (first_ok && !second_ok) {
111 printf("FATs differ - using first FAT.\n");
112 fs_write(fs->fat_start + fs->fat_size, eff_size, first);
113 }
114 if (!first_ok && second_ok) {
115 printf("FATs differ - using second FAT.\n");
116 fs_write(fs->fat_start, eff_size, second);
117 memcpy(first, second, eff_size);
118 }
119 if (first_ok && second_ok) {
120 if (interactive) {
121 printf("FATs differ but appear to be intact. Use which FAT ?\n"
122 "1) Use first FAT\n2) Use second FAT\n");
123 if (get_key("12", "?") == '1') {
124 fs_write(fs->fat_start + fs->fat_size, eff_size, first);
125 } else {
126 fs_write(fs->fat_start, eff_size, second);
127 memcpy(first, second, eff_size);
128 }
129 } else {
130 printf("FATs differ but appear to be intact. Using first "
131 "FAT.\n");
132 fs_write(fs->fat_start + fs->fat_size, eff_size, first);
133 }
134 }
135 if (!first_ok && !second_ok) {
136 printf("Both FATs appear to be corrupt. Giving up.\n");
137 exit(1);
138 }
139 }
140 if (second) {
141 free(second);
142 }
143 fs->fat = (unsigned char *)first;
144
145 fs->cluster_owner = alloc(total_num_clusters * sizeof(DOS_FILE *));
146 memset(fs->cluster_owner, 0, (total_num_clusters * sizeof(DOS_FILE *)));
147
148 /* Truncate any cluster chains that link to something out of range */
149 for (i = 2; i < fs->clusters + 2; i++) {
150 FAT_ENTRY curEntry;
151 get_fat(&curEntry, fs->fat, i, fs);
152 if (curEntry.value == 1) {
153 printf("Cluster %ld out of range (1). Setting to EOF.\n", (long)(i - 2));
154 set_fat(fs, i, -1);
155 }
156 if (curEntry.value >= fs->clusters + 2 &&
157 (curEntry.value < FAT_MIN_BAD(fs))) {
158 printf("Cluster %ld out of range (%ld > %ld). Setting to EOF.\n",
159 (long)(i - 2), (long)curEntry.value, (long)(fs->clusters + 2 - 1));
160 set_fat(fs, i, -1);
161 }
162 }
163 }
164
165 /**
166 * Update the FAT entry for a specified cluster
167 * (i.e., change the cluster it links to).
168 * Queue a command to write out this change.
169 *
170 * @param[in,out] fs Information about the filesystem
171 * @param[in] cluster Cluster to change
172 * @param[in] new Cluster to link to
173 * Special values:
174 * 0 == free cluster
175 * -1 == end-of-chain
176 * -2 == bad cluster
177 */
178 void set_fat(DOS_FS * fs, uint32_t cluster, int32_t new)
179 {
180 unsigned char *data = NULL;
181 int size;
182 loff_t offs;
183
184 if (new == -1)
185 new = FAT_EOF(fs);
186 else if ((long)new == -2)
187 new = FAT_BAD(fs);
188 switch (fs->fat_bits) {
189 case 12:
190 data = fs->fat + cluster * 3 / 2;
191 offs = fs->fat_start + cluster * 3 / 2;
192 if (cluster & 1) {
193 FAT_ENTRY prevEntry;
194 get_fat(&prevEntry, fs->fat, cluster - 1, fs);
195 data[0] = ((new & 0xf) << 4) | (prevEntry.value >> 8);
196 data[1] = new >> 4;
197 } else {
198 FAT_ENTRY subseqEntry;
199 get_fat(&subseqEntry, fs->fat, cluster + 1, fs);
200 data[0] = new & 0xff;
201 data[1] = (new >> 8) | (cluster == fs->clusters - 1 ? 0 :
202 (0xff & subseqEntry.value) << 4);
203 }
204 size = 2;
205 break;
206 case 16:
207 data = fs->fat + cluster * 2;
208 offs = fs->fat_start + cluster * 2;
209 *(unsigned short *)data = htole16(new);
210 size = 2;
211 break;
212 case 32:
213 {
214 FAT_ENTRY curEntry;
215 get_fat(&curEntry, fs->fat, cluster, fs);
216
217 data = fs->fat + cluster * 4;
218 offs = fs->fat_start + cluster * 4;
219 /* According to M$, the high 4 bits of a FAT32 entry are reserved and
220 * are not part of the cluster number. So we never touch them. */
221 *(uint32_t *)data = htole32((new & 0xfffffff) |
222 (curEntry.reserved << 28));
223 size = 4;
224 }
225 break;
226 default:
227 die("Bad FAT entry size: %d bits.", fs->fat_bits);
228 }
229 fs_write(offs, size, data);
230 if (fs->nfats > 1) {
231 fs_write(offs + fs->fat_size, size, data);
232 }
233 }
234
235 int bad_cluster(DOS_FS * fs, uint32_t cluster)
236 {
237 FAT_ENTRY curEntry;
238 get_fat(&curEntry, fs->fat, cluster, fs);
239
240 return FAT_IS_BAD(fs, curEntry.value);
241 }
242
243 /**
244 * Get the cluster to which the specified cluster is linked.
245 * If the linked cluster is marked bad, abort.
246 *
247 * @param[in] fs Information about the filesystem
248 * @param[in] cluster Cluster to follow
249 *
250 * @return -1 'cluster' is at the end of the chain
251 * @return Other values Next cluster in this chain
252 */
253 uint32_t next_cluster(DOS_FS * fs, uint32_t cluster)
254 {
255 uint32_t value;
256 FAT_ENTRY curEntry;
257
258 get_fat(&curEntry, fs->fat, cluster, fs);
259
260 value = curEntry.value;
261 if (FAT_IS_BAD(fs, value))
262 die("Internal error: next_cluster on bad cluster");
263 return FAT_IS_EOF(fs, value) ? -1 : value;
264 }
265
266 loff_t cluster_start(DOS_FS * fs, uint32_t cluster)
267 {
268 return fs->data_start + ((loff_t) cluster -
269 2) * (uint64_t)fs->cluster_size;
270 }
271
272 /**
273 * Update internal bookkeeping to show that the specified cluster belongs
274 * to the specified dentry.
275 *
276 * @param[in,out] fs Information about the filesystem
277 * @param[in] cluster Cluster being assigned
278 * @param[in] owner Information on dentry that owns this cluster
279 * (may be NULL)
280 */
281 void set_owner(DOS_FS * fs, uint32_t cluster, DOS_FILE * owner)
282 {
283 if (fs->cluster_owner == NULL)
284 die("Internal error: attempt to set owner in non-existent table");
285
286 if (owner && fs->cluster_owner[cluster]
287 && (fs->cluster_owner[cluster] != owner))
288 die("Internal error: attempt to change file owner");
289 fs->cluster_owner[cluster] = owner;
290 }
291
292 DOS_FILE *get_owner(DOS_FS * fs, uint32_t cluster)
293 {
294 if (fs->cluster_owner == NULL)
295 return NULL;
296 else
297 return fs->cluster_owner[cluster];
298 }
299
300 void fix_bad(DOS_FS * fs)
301 {
302 uint32_t i;
303
304 if (verbose)
305 printf("Checking for bad clusters.\n");
306 for (i = 2; i < fs->clusters + 2; i++) {
307 FAT_ENTRY curEntry;
308 get_fat(&curEntry, fs->fat, i, fs);
309
310 if (!get_owner(fs, i) && !FAT_IS_BAD(fs, curEntry.value))
311 if (!fs_test(cluster_start(fs, i), fs->cluster_size)) {
312 printf("Cluster %lu is unreadable.\n", (unsigned long)i);
313 set_fat(fs, i, -2);
314 }
315 }
316 }
317
318 void reclaim_free(DOS_FS * fs)
319 {
320 int reclaimed;
321 uint32_t i;
322
323 if (verbose)
324 printf("Checking for unused clusters.\n");
325 reclaimed = 0;
326 for (i = 2; i < fs->clusters + 2; i++) {
327 FAT_ENTRY curEntry;
328 get_fat(&curEntry, fs->fat, i, fs);
329
330 if (!get_owner(fs, i) && curEntry.value &&
331 !FAT_IS_BAD(fs, curEntry.value)) {
332 set_fat(fs, i, 0);
333 reclaimed++;
334 }
335 }
336 if (reclaimed)
337 printf("Reclaimed %d unused cluster%s (%llu bytes).\n", (int)reclaimed,
338 reclaimed == 1 ? "" : "s",
339 (unsigned long long)reclaimed * fs->cluster_size);
340 }
341
342 /**
343 * Assign the specified owner to all orphan chains (except cycles).
344 * Break cross-links between orphan chains.
345 *
346 * @param[in,out] fs Information about the filesystem
347 * @param[in] owner dentry to be assigned ownership of orphans
348 * @param[in,out] num_refs For each orphan cluster [index], how many
349 * clusters link to it.
350 * @param[in] start_cluster Where to start scanning for orphans
351 */
352 static void tag_free(DOS_FS * fs, DOS_FILE * owner, uint32_t *num_refs,
353 uint32_t start_cluster)
354 {
355 int prev;
356 uint32_t i, walk;
357
358 if (start_cluster == 0)
359 start_cluster = 2;
360
361 for (i = start_cluster; i < fs->clusters + 2; i++) {
362 FAT_ENTRY curEntry;
363 get_fat(&curEntry, fs->fat, i, fs);
364
365 /* If the current entry is the head of an un-owned chain... */
366 if (curEntry.value && !FAT_IS_BAD(fs, curEntry.value) &&
367 !get_owner(fs, i) && !num_refs[i]) {
368 prev = 0;
369 /* Walk the chain, claiming ownership as we go */
370 for (walk = i; walk != -1; walk = next_cluster(fs, walk)) {
371 if (!get_owner(fs, walk)) {
372 set_owner(fs, walk, owner);
373 } else {
374 /* We've run into cross-links between orphaned chains,
375 * or a cycle with a tail.
376 * Terminate this orphan chain (break the link)
377 */
378 set_fat(fs, prev, -1);
379
380 /* This is not necessary because 'walk' is owned and thus
381 * will never become the head of a chain (the only case
382 * that would matter during reclaim to files).
383 * It's easier to decrement than to prove that it's
384 * unnecessary.
385 */
386 num_refs[walk]--;
387 break;
388 }
389 prev = walk;
390 }
391 }
392 }
393 }
394
395 /**
396 * Recover orphan chains to files, handling any cycles or cross-links.
397 *
398 * @param[in,out] fs Information about the filesystem
399 */
400 void reclaim_file(DOS_FS * fs)
401 {
402 DOS_FILE orphan;
403 int reclaimed, files;
404 int changed = 0;
405 uint32_t i, next, walk;
406 uint32_t *num_refs = NULL; /* Only for orphaned clusters */
407 uint32_t total_num_clusters;
408
409 if (verbose)
410 printf("Reclaiming unconnected clusters.\n");
411
412 total_num_clusters = fs->clusters + 2UL;
413 num_refs = alloc(total_num_clusters * sizeof(uint32_t));
414 memset(num_refs, 0, (total_num_clusters * sizeof(uint32_t)));
415
416 /* Guarantee that all orphan chains (except cycles) end cleanly
417 * with an end-of-chain mark.
418 */
419
420 for (i = 2; i < total_num_clusters; i++) {
421 FAT_ENTRY curEntry;
422 get_fat(&curEntry, fs->fat, i, fs);
423
424 next = curEntry.value;
425 if (!get_owner(fs, i) && next && next < fs->clusters + 2) {
426 /* Cluster is linked, but not owned (orphan) */
427 FAT_ENTRY nextEntry;
428 get_fat(&nextEntry, fs->fat, next, fs);
429
430 /* Mark it end-of-chain if it links into an owned cluster,
431 * a free cluster, or a bad cluster.
432 */
433 if (get_owner(fs, next) || !nextEntry.value ||
434 FAT_IS_BAD(fs, nextEntry.value))
435 set_fat(fs, i, -1);
436 else
437 num_refs[next]++;
438 }
439 }
440
441 /* Scan until all the orphans are accounted for,
442 * and all cycles and cross-links are broken
443 */
444 do {
445 tag_free(fs, &orphan, num_refs, changed);
446 changed = 0;
447
448 /* Any unaccounted-for orphans must be part of a cycle */
449 for (i = 2; i < total_num_clusters; i++) {
450 FAT_ENTRY curEntry;
451 get_fat(&curEntry, fs->fat, i, fs);
452
453 if (curEntry.value && !FAT_IS_BAD(fs, curEntry.value) &&
454 !get_owner(fs, i)) {
455 if (!num_refs[curEntry.value]--)
456 die("Internal error: num_refs going below zero");
457 set_fat(fs, i, -1);
458 changed = curEntry.value;
459 printf("Broke cycle at cluster %lu in free chain.\n", (unsigned long)i);
460
461 /* If we've created a new chain head,
462 * tag_free() can claim it
463 */
464 if (num_refs[curEntry.value] == 0)
465 break;
466 }
467 }
468 }
469 while (changed);
470
471 /* Now we can start recovery */
472 files = reclaimed = 0;
473 for (i = 2; i < total_num_clusters; i++)
474 /* If this cluster is the head of an orphan chain... */
475 if (get_owner(fs, i) == &orphan && !num_refs[i]) {
476 DIR_ENT de;
477 loff_t offset;
478 files++;
479 offset = alloc_rootdir_entry(fs, &de, "FSCK%04dREC");
480 de.start = htole16(i & 0xffff);
481 if (fs->fat_bits == 32)
482 de.starthi = htole16(i >> 16);
483 for (walk = i; walk > 0 && walk != -1;
484 walk = next_cluster(fs, walk)) {
485 de.size = htole32(le32toh(de.size) + fs->cluster_size);
486 reclaimed++;
487 }
488 fs_write(offset, sizeof(DIR_ENT), &de);
489 }
490 if (reclaimed)
491 printf("Reclaimed %d unused cluster%s (%llu bytes) in %d chain%s.\n",
492 reclaimed, reclaimed == 1 ? "" : "s",
493 (unsigned long long)reclaimed * fs->cluster_size, files,
494 files == 1 ? "" : "s");
495
496 free(num_refs);
497 }
498
499 uint32_t update_free(DOS_FS * fs)
500 {
501 uint32_t i;
502 uint32_t free = 0;
503 int do_set = 0;
504
505 for (i = 2; i < fs->clusters + 2; i++) {
506 FAT_ENTRY curEntry;
507 get_fat(&curEntry, fs->fat, i, fs);
508
509 if (!get_owner(fs, i) && !FAT_IS_BAD(fs, curEntry.value))
510 ++free;
511 }
512
513 if (!fs->fsinfo_start)
514 return free;
515
516 if (verbose)
517 printf("Checking free cluster summary.\n");
518 if (fs->free_clusters != 0xFFFFFFFF) {
519 if (free != fs->free_clusters) {
520 printf("Free cluster summary wrong (%ld vs. really %ld)\n",
521 (long)fs->free_clusters, (long)free);
522 if (interactive)
523 printf("1) Correct\n2) Don't correct\n");
524 else
525 printf(" Auto-correcting.\n");
526 if (!interactive || get_key("12", "?") == '1')
527 do_set = 1;
528 }
529 } else {
530 printf("Free cluster summary uninitialized (should be %ld)\n", (long)free);
531 if (rw) {
532 if (interactive)
533 printf("1) Set it\n2) Leave it uninitialized\n");
534 else
535 printf(" Auto-setting.\n");
536 if (!interactive || get_key("12", "?") == '1')
537 do_set = 1;
538 }
539 }
540
541 if (do_set) {
542 uint32_t le_free = htole32(free);
543 fs->free_clusters = free;
544 fs_write(fs->fsinfo_start + offsetof(struct info_sector, free_clusters),
545 sizeof(le_free), &le_free);
546 }
547
548 return free;
549 }
0 /* fat.h - Read/write access to the FAT
1
2 Copyright (C) 1993 Werner Almesberger <werner.almesberger@lrc.di.epfl.ch>
3 Copyright (C) 2008-2014 Daniel Baumann <mail@daniel-baumann.ch>
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 THe complete text of the GNU General Public License
19 can be found in /usr/share/common-licenses/GPL-3 file.
20 */
21
22 #ifndef _FAT_H
23 #define _FAT_H
24
25 void read_fat(DOS_FS * fs);
26
27 /* Loads the FAT of the filesystem described by FS. Initializes the FAT,
28 replaces broken FATs and rejects invalid cluster entries. */
29
30 void get_fat(FAT_ENTRY * entry, void *fat, uint32_t cluster, DOS_FS * fs);
31
32 /* Retrieve the FAT entry (next chained cluster) for CLUSTER. */
33
34 void set_fat(DOS_FS * fs, uint32_t cluster, int32_t new);
35
36 /* Changes the value of the CLUSTERth cluster of the FAT of FS to NEW. Special
37 values of NEW are -1 (EOF, 0xff8 or 0xfff8) and -2 (bad sector, 0xff7 or
38 0xfff7) */
39
40 int bad_cluster(DOS_FS * fs, uint32_t cluster);
41
42 /* Returns a non-zero integer if the CLUSTERth cluster is marked as bad or zero
43 otherwise. */
44
45 uint32_t next_cluster(DOS_FS * fs, uint32_t cluster);
46
47 /* Returns the number of the cluster following CLUSTER, or -1 if this is the
48 last cluster of the respective cluster chain. CLUSTER must not be a bad
49 cluster. */
50
51 loff_t cluster_start(DOS_FS * fs, uint32_t cluster);
52
53 /* Returns the byte offset of CLUSTER, relative to the respective device. */
54
55 void set_owner(DOS_FS * fs, uint32_t cluster, DOS_FILE * owner);
56
57 /* Sets the owner pointer of the respective cluster to OWNER. If OWNER was NULL
58 before, it can be set to NULL or any non-NULL value. Otherwise, only NULL is
59 accepted as the new value. */
60
61 DOS_FILE *get_owner(DOS_FS * fs, uint32_t cluster);
62
63 /* Returns the owner of the repective cluster or NULL if the cluster has no
64 owner. */
65
66 void fix_bad(DOS_FS * fs);
67
68 /* Scans the disk for currently unused bad clusters and marks them as bad. */
69
70 void reclaim_free(DOS_FS * fs);
71
72 /* Marks all allocated, but unused clusters as free. */
73
74 void reclaim_file(DOS_FS * fs);
75
76 /* Scans the FAT for chains of allocated, but unused clusters and creates files
77 for them in the root directory. Also tries to fix all inconsistencies (e.g.
78 loops, shared clusters, etc.) in the process. */
79
80 uint32_t update_free(DOS_FS * fs);
81
82 /* Updates free cluster count in FSINFO sector. */
83
84 #endif
0 /* fatlabel.c - User interface
1
2 Copyright (C) 1993 Werner Almesberger <werner.almesberger@lrc.di.epfl.ch>
3 Copyright (C) 1998 Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de>
4 Copyright (C) 2007 Red Hat, Inc.
5 Copyright (C) 2008-2014 Daniel Baumann <mail@daniel-baumann.ch>
6
7 This program is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
19
20 The complete text of the GNU General Public License
21 can be found in /usr/share/common-licenses/GPL-3 file.
22 */
23
24 #include "version.h"
25
26 #include <stdio.h>
27 #include <stdlib.h>
28 #include <string.h>
29 #include <stdlib.h>
30 #include <unistd.h>
31 #include <getopt.h>
32 #include <ctype.h>
33
34 #include "common.h"
35 #include "fsck.fat.h"
36 #include "io.h"
37 #include "boot.h"
38 #include "fat.h"
39 #include "file.h"
40 #include "check.h"
41
42 int interactive = 0, rw = 0, list = 0, test = 0, verbose = 0, write_immed = 0;
43 int atari_format = 0;
44 unsigned n_files = 0;
45 void *mem_queue = NULL;
46
47 static void usage(int error)
48 {
49 FILE *f = error ? stderr : stdout;
50 int status = error ? 1 : 0;
51
52 fprintf(f, "usage: fatlabel device [label]\n");
53 exit(status);
54 }
55
56 /*
57 * ++roman: On m68k, check if this is an Atari; if yes, turn on Atari variant
58 * of MS-DOS filesystem by default.
59 */
60 static void check_atari(void)
61 {
62 #ifdef __mc68000__
63 FILE *f;
64 char line[128], *p;
65
66 if (!(f = fopen("/proc/hardware", "r"))) {
67 perror("/proc/hardware");
68 return;
69 }
70
71 while (fgets(line, sizeof(line), f)) {
72 if (strncmp(line, "Model:", 6) == 0) {
73 p = line + 6;
74 p += strspn(p, " \t");
75 if (strncmp(p, "Atari ", 6) == 0)
76 atari_format = 1;
77 break;
78 }
79 }
80 fclose(f);
81 #endif
82 }
83
84 int main(int argc, char *argv[])
85 {
86 DOS_FS fs = { 0 };
87 rw = 0;
88
89 int i;
90
91 char *device = NULL;
92 char label[12] = { 0 };
93
94 loff_t offset;
95 DIR_ENT de;
96
97 check_atari();
98
99 if (argc < 2 || argc > 3)
100 usage(1);
101
102 if (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help"))
103 usage(0);
104 else if (!strcmp(argv[1], "-V") || !strcmp(argv[1], "--version")) {
105 printf("fatlabel " VERSION " (" VERSION_DATE ")\n");
106 exit(0);
107 }
108
109 device = argv[1];
110 if (argc == 3) {
111 strncpy(label, argv[2], 11);
112 if (strlen(argv[2]) > 11) {
113 fprintf(stderr,
114 "fatlabel: labels can be no longer than 11 characters\n");
115 exit(1);
116 }
117 for (i = 0; label[i] && i < 11; i++)
118 /* don't know if here should be more strict !uppercase(label[i]) */
119 if (islower(label[i])) {
120 fprintf(stderr,
121 "fatlabel: warning - lowercase labels might not work properly with DOS or Windows\n");
122 break;
123 }
124 rw = 1;
125 }
126
127 fs_open(device, rw);
128 read_boot(&fs);
129 if (fs.fat_bits == 32)
130 read_fat(&fs);
131 if (!rw) {
132 offset = find_volume_de(&fs, &de);
133 if (offset == 0)
134 fprintf(stdout, "%s\n", fs.label);
135 else
136 fprintf(stdout, "%.8s%.3s\n", de.name, de.ext);
137 exit(0);
138 }
139
140 write_label(&fs, label);
141 fs_close(rw);
142 return 0;
143 }
0 /* file.c - Additional file attributes
1
2 Copyright (C) 1993 Werner Almesberger <werner.almesberger@lrc.di.epfl.ch>
3 Copyright (C) 1998 Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de>
4 Copyright (C) 2008-2014 Daniel Baumann <mail@daniel-baumann.ch>
5
6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
18
19 The complete text of the GNU General Public License
20 can be found in /usr/share/common-licenses/GPL-3 file.
21 */
22
23 /* FAT32, VFAT, Atari format support, and various fixes additions May 1998
24 * by Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de> */
25
26 #include <stdlib.h>
27 #include <stdio.h>
28 #include <string.h>
29 #include <ctype.h>
30 #include <unistd.h>
31
32 #define _LINUX_STAT_H /* hack to avoid inclusion of <linux/stat.h> */
33 #define _LINUX_STRING_H_ /* hack to avoid inclusion of <linux/string.h> */
34 #define _LINUX_FS_H /* hack to avoid inclusion of <linux/fs.h> */
35
36 #include <asm/types.h>
37
38 #include <linux/msdos_fs.h>
39
40 #include "common.h"
41 #include "file.h"
42 #include "charconv.h"
43
44 FDSC *fp_root = NULL;
45
46 static void put_char(char **p, unsigned char c)
47 {
48 if (dos_char_to_printable(p, c))
49 return;
50 if ((c >= ' ' && c < 0x7f) || c >= 0xa0)
51 *(*p)++ = c;
52 else {
53 *(*p)++ = '\\';
54 *(*p)++ = '0' + (c >> 6);
55 *(*p)++ = '0' + ((c >> 3) & 7);
56 *(*p)++ = '0' + (c & 7);
57 }
58 }
59
60 /**
61 * Construct the "pretty-printed" representation of the name in a short directory entry.
62 *
63 * @param[in] fixed Pointer to name[0] of a DIR_ENT
64 *
65 * @return Pointer to static string containing pretty "8.3" equivalent of the
66 * name in the directory entry.
67 */
68 char *file_name(unsigned char *fixed)
69 {
70 static char path[MSDOS_NAME * 4 + 2];
71 char *p;
72 int i, j;
73
74 p = path;
75 for (i = j = 0; i < 8; i++)
76 if (fixed[i] != ' ') {
77 while (j++ < i)
78 *p++ = ' ';
79 put_char(&p, fixed[i]);
80 }
81 if (strncmp((const char *)(fixed + 8), " ", 3)) {
82 *p++ = '.';
83 for (i = j = 0; i < 3; i++)
84 if (fixed[i + 8] != ' ') {
85 while (j++ < i)
86 *p++ = ' ';
87 put_char(&p, fixed[i + 8]);
88 }
89 }
90 *p = 0;
91 return path;
92 }
93
94 int file_cvt(unsigned char *name, unsigned char *fixed)
95 {
96 unsigned char c;
97 int size, ext, cnt;
98
99 size = 8;
100 ext = 0;
101 while (*name) {
102 c = *name;
103 if (c < ' ' || c > 0x7e || strchr("*?<>|\"/", c)) {
104 printf("Invalid character in name. Use \\ooo for special "
105 "characters.\n");
106 return 0;
107 }
108 if (c == '.') {
109 if (ext) {
110 printf("Duplicate dots in name.\n");
111 return 0;
112 }
113 while (size--)
114 *fixed++ = ' ';
115 size = 3;
116 ext = 1;
117 name++;
118 continue;
119 }
120 if (c == '\\') {
121 c = 0;
122 for (cnt = 3; cnt; cnt--) {
123 if (*name < '0' || *name > '7') {
124 printf("Invalid octal character.\n");
125 return 0;
126 }
127 c = c * 8 + *name++ - '0';
128 }
129 if (cnt < 4) {
130 printf("Expected three octal digits.\n");
131 return 0;
132 }
133 name += 3;
134 }
135 if (islower(c))
136 c = toupper(c);
137 if (size) {
138 *fixed++ = c;
139 size--;
140 }
141 name++;
142 }
143 if (*name || size == 8)
144 return 0;
145 if (!ext) {
146 while (size--)
147 *fixed++ = ' ';
148 size = 3;
149 }
150 while (size--)
151 *fixed++ = ' ';
152 return 1;
153 }
154
155 void file_add(char *path, FD_TYPE type)
156 {
157 FDSC **current, *walk;
158 char name[MSDOS_NAME];
159 char *here;
160
161 current = &fp_root;
162 if (*path != '/')
163 die("%s: Absolute path required.", path);
164 path++;
165 while (1) {
166 if ((here = strchr(path, '/')))
167 *here = 0;
168 if (!file_cvt((unsigned char *)path, (unsigned char *)name))
169 exit(2);
170 for (walk = *current; walk; walk = walk->next)
171 if (!here && (!strncmp(name, walk->name, MSDOS_NAME) || (type ==
172 fdt_undelete
173 &&
174 !strncmp
175 (name + 1,
176 walk->name
177 + 1,
178 MSDOS_NAME
179 - 1))))
180 die("Ambiguous name: \"%s\"", path);
181 else if (here && !strncmp(name, walk->name, MSDOS_NAME))
182 break;
183 if (!walk) {
184 walk = alloc(sizeof(FDSC));
185 strncpy(walk->name, name, MSDOS_NAME);
186 walk->type = here ? fdt_none : type;
187 walk->first = NULL;
188 walk->next = *current;
189 *current = walk;
190 }
191 current = &walk->first;
192 if (!here)
193 break;
194 *here = '/';
195 path = here + 1;
196 }
197 }
198
199 FDSC **file_cd(FDSC ** curr, char *fixed)
200 {
201 FDSC **walk;
202
203 if (!curr || !*curr)
204 return NULL;
205 for (walk = curr; *walk; walk = &(*walk)->next)
206 if (!strncmp((*walk)->name, fixed, MSDOS_NAME) && (*walk)->first)
207 return &(*walk)->first;
208 return NULL;
209 }
210
211 static FDSC **file_find(FDSC ** dir, char *fixed)
212 {
213 if (!dir || !*dir)
214 return NULL;
215 if (*(unsigned char *)fixed == DELETED_FLAG) {
216 while (*dir) {
217 if (!strncmp((*dir)->name + 1, fixed + 1, MSDOS_NAME - 1)
218 && !(*dir)->first)
219 return dir;
220 dir = &(*dir)->next;
221 }
222 return NULL;
223 }
224 while (*dir) {
225 if (!strncmp((*dir)->name, fixed, MSDOS_NAME) && !(*dir)->first)
226 return dir;
227 dir = &(*dir)->next;
228 }
229 return NULL;
230 }
231
232 /* Returns the attribute of the file FIXED in directory CURR or FDT_NONE if no
233 such file exists or if CURR is NULL. */
234 FD_TYPE file_type(FDSC ** curr, char *fixed)
235 {
236 FDSC **this;
237
238 if ((this = file_find(curr, fixed)))
239 return (*this)->type;
240 return fdt_none;
241 }
242
243 void file_modify(FDSC ** curr, char *fixed)
244 {
245 FDSC **this, *next;
246
247 if (!(this = file_find(curr, fixed)))
248 die("Internal error: file_find failed");
249 switch ((*this)->type) {
250 case fdt_drop:
251 printf("Dropping %s\n", file_name((unsigned char *)fixed));
252 *(unsigned char *)fixed = DELETED_FLAG;
253 break;
254 case fdt_undelete:
255 *fixed = *(*this)->name;
256 printf("Undeleting %s\n", file_name((unsigned char *)fixed));
257 break;
258 default:
259 die("Internal error: file_modify");
260 }
261 next = (*this)->next;
262 free(*this);
263 *this = next;
264 }
265
266 static void report_unused(FDSC * this)
267 {
268 FDSC *next;
269
270 while (this) {
271 next = this->next;
272 if (this->first)
273 report_unused(this->first);
274 else if (this->type != fdt_none)
275 printf("Warning: did not %s file %s\n", this->type == fdt_drop ?
276 "drop" : "undelete", file_name((unsigned char *)this->name));
277 free(this);
278 this = next;
279 }
280 }
281
282 void file_unused(void)
283 {
284 report_unused(fp_root);
285 }
0 /* file.h - Additional file attributes
1
2 Copyright (C) 1993 Werner Almesberger <werner.almesberger@lrc.di.epfl.ch>
3 Copyright (C) 2008-2014 Daniel Baumann <mail@daniel-baumann.ch>
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 The complete text of the GNU General Public License
19 can be found in /usr/share/common-licenses/GPL-3 file.
20 */
21
22 #ifndef _FILE_H
23 #define _FILE_H
24
25 typedef enum { fdt_none, fdt_drop, fdt_undelete } FD_TYPE;
26
27 typedef struct _fptr {
28 char name[MSDOS_NAME];
29 FD_TYPE type;
30 struct _fptr *first; /* first entry */
31 struct _fptr *next; /* next file in directory */
32 } FDSC;
33
34 extern FDSC *fp_root;
35
36 char *file_name(unsigned char *fixed);
37
38 /* Returns a pointer to a pretty-printed representation of a fixed MS-DOS file
39 name. */
40
41 int file_cvt(unsigned char *name, unsigned char *fixed);
42
43 /* Converts a pretty-printed file name to the fixed MS-DOS format. Returns a
44 non-zero integer on success, zero on failure. */
45
46 void file_add(char *path, FD_TYPE type);
47
48 /* Define special attributes for a path. TYPE can be either FDT_DROP or
49 FDT_UNDELETE. */
50
51 FDSC **file_cd(FDSC ** curr, char *fixed);
52
53 /* Returns a pointer to the directory descriptor of the subdirectory FIXED of
54 CURR, or NULL if no such subdirectory exists. */
55
56 FD_TYPE file_type(FDSC ** curr, char *fixed);
57
58 /* Returns the attribute of the file FIXED in directory CURR or FDT_NONE if no
59 such file exists or if CURR is NULL. */
60
61 void file_modify(FDSC ** curr, char *fixed);
62
63 /* Performs the necessary operation on the entry of CURR that is named FIXED. */
64
65 void file_unused(void);
66
67 /* Displays warnings for all unused file attributes. */
68
69 #endif
0 /* fsck.fat.c - User interface
1
2 Copyright (C) 1993 Werner Almesberger <werner.almesberger@lrc.di.epfl.ch>
3 Copyright (C) 1998 Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de>
4 Copyright (C) 2008-2014 Daniel Baumann <mail@daniel-baumann.ch>
5
6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
18
19 The complete text of the GNU General Public License
20 can be found in /usr/share/common-licenses/GPL-3 file.
21 */
22
23 /* FAT32, VFAT, Atari format support, and various fixes additions May 1998
24 * by Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de> */
25
26 #include "version.h"
27
28 #include <stdio.h>
29 #include <stdlib.h>
30 #include <string.h>
31 #include <stdlib.h>
32 #include <unistd.h>
33 #include <getopt.h>
34
35 #include "common.h"
36 #include "fsck.fat.h"
37 #include "io.h"
38 #include "boot.h"
39 #include "fat.h"
40 #include "file.h"
41 #include "check.h"
42 #include "charconv.h"
43
44 int interactive = 0, rw = 0, list = 0, test = 0, verbose = 0, write_immed = 0;
45 int atari_format = 0, boot_only = 0;
46 unsigned n_files = 0;
47 void *mem_queue = NULL;
48
49 static void usage(char *name)
50 {
51 fprintf(stderr, "usage: %s [-aAbflrtvVwy] [-d path -d ...] "
52 "[-u path -u ...]\n%15sdevice\n", name, "");
53 fprintf(stderr, " -a automatically repair the filesystem\n");
54 fprintf(stderr, " -A toggle Atari filesystem format\n");
55 fprintf(stderr, " -b make read-only boot sector check\n");
56 fprintf(stderr,
57 " -c N use DOS codepage N to decode short file names (default: %d)\n",
58 DEFAULT_DOS_CODEPAGE);
59 fprintf(stderr, " -d path drop that file\n");
60 fprintf(stderr, " -f salvage unused chains to files\n");
61 fprintf(stderr, " -l list path names\n");
62 fprintf(stderr,
63 " -n no-op, check non-interactively without changing\n");
64 fprintf(stderr, " -p same as -a, for compat with other *fsck\n");
65 fprintf(stderr, " -r interactively repair the filesystem\n");
66 fprintf(stderr, " -t test for bad clusters\n");
67 fprintf(stderr, " -u path try to undelete that (non-directory) file\n");
68 fprintf(stderr, " -v verbose mode\n");
69 fprintf(stderr, " -V perform a verification pass\n");
70 fprintf(stderr, " -w write changes to disk immediately\n");
71 fprintf(stderr, " -y same as -a, for compat with other *fsck\n");
72 exit(2);
73 }
74
75 /*
76 * ++roman: On m68k, check if this is an Atari; if yes, turn on Atari variant
77 * of MS-DOS filesystem by default.
78 */
79 static void check_atari(void)
80 {
81 #ifdef __mc68000__
82 FILE *f;
83 char line[128], *p;
84
85 if (!(f = fopen("/proc/hardware", "r"))) {
86 perror("/proc/hardware");
87 return;
88 }
89
90 while (fgets(line, sizeof(line), f)) {
91 if (strncmp(line, "Model:", 6) == 0) {
92 p = line + 6;
93 p += strspn(p, " \t");
94 if (strncmp(p, "Atari ", 6) == 0)
95 atari_format = 1;
96 break;
97 }
98 }
99 fclose(f);
100 #endif
101 }
102
103 int main(int argc, char **argv)
104 {
105 DOS_FS fs;
106 int salvage_files, verify, c;
107 uint32_t free_clusters = 0;
108
109 memset(&fs, 0, sizeof(fs));
110 rw = salvage_files = verify = 0;
111 interactive = 1;
112 check_atari();
113
114 while ((c = getopt(argc, argv, "Aac:d:bflnprtu:vVwy")) != EOF)
115 switch (c) {
116 case 'A': /* toggle Atari format */
117 atari_format = !atari_format;
118 break;
119 case 'a':
120 case 'p':
121 case 'y':
122 rw = 1;
123 interactive = 0;
124 salvage_files = 1;
125 break;
126 case 'b':
127 rw = 0;
128 interactive = 0;
129 boot_only = 1;
130 break;
131 case 'c':
132 set_dos_codepage(atoi(optarg));
133 break;
134 case 'd':
135 file_add(optarg, fdt_drop);
136 break;
137 case 'f':
138 salvage_files = 1;
139 break;
140 case 'l':
141 list = 1;
142 break;
143 case 'n':
144 rw = 0;
145 interactive = 0;
146 break;
147 case 'r':
148 rw = 1;
149 interactive = 1;
150 break;
151 case 't':
152 test = 1;
153 break;
154 case 'u':
155 file_add(optarg, fdt_undelete);
156 break;
157 case 'v':
158 verbose = 1;
159 printf("fsck.fat " VERSION " (" VERSION_DATE ")\n");
160 break;
161 case 'V':
162 verify = 1;
163 break;
164 case 'w':
165 write_immed = 1;
166 break;
167 default:
168 usage(argv[0]);
169 }
170 set_dos_codepage(-1); /* set default codepage if none was given in command line */
171 if ((test || write_immed) && !rw) {
172 fprintf(stderr, "-t and -w require -a or -r\n");
173 exit(2);
174 }
175 if (optind != argc - 1)
176 usage(argv[0]);
177
178 printf("fsck.fat " VERSION " (" VERSION_DATE ")\n");
179 fs_open(argv[optind], rw);
180
181 read_boot(&fs);
182 if (boot_only)
183 goto exit;
184
185 if (verify)
186 printf("Starting check/repair pass.\n");
187 while (read_fat(&fs), scan_root(&fs))
188 qfree(&mem_queue);
189 if (test)
190 fix_bad(&fs);
191 if (salvage_files)
192 reclaim_file(&fs);
193 else
194 reclaim_free(&fs);
195 free_clusters = update_free(&fs);
196 file_unused();
197 qfree(&mem_queue);
198 if (verify) {
199 n_files = 0;
200 printf("Starting verification pass.\n");
201 read_fat(&fs);
202 scan_root(&fs);
203 reclaim_free(&fs);
204 qfree(&mem_queue);
205 }
206
207 exit:
208 if (fs_changed()) {
209 if (rw) {
210 if (interactive)
211 rw = get_key("yn", "Perform changes ? (y/n)") == 'y';
212 else
213 printf("Performing changes.\n");
214 } else
215 printf("Leaving filesystem unchanged.\n");
216 }
217
218 if (!boot_only)
219 printf("%s: %u files, %lu/%lu clusters\n", argv[optind],
220 n_files, (unsigned long)fs.clusters - free_clusters, (unsigned long)fs.clusters);
221
222 return fs_close(rw) ? 1 : 0;
223 }
0 /* fsck.fat.h - Common data structures and global variables
1
2 Copyright (C) 1993 Werner Almesberger <werner.almesberger@lrc.di.epfl.ch>
3 Copyright (C) 1998 Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de>
4 Copyright (C) 2008-2014 Daniel Baumann <mail@daniel-baumann.ch>
5
6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
18
19 The complete text of the GNU General Public License
20 can be found in /usr/share/common-licenses/GPL-3 file.
21 */
22
23 /* FAT32, VFAT, Atari format support, and various fixes additions May 1998
24 * by Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de> */
25
26 #ifndef _DOSFSCK_H
27 #define _DOSFSCK_H
28
29 #include <fcntl.h>
30 #include <sys/types.h>
31 #define _LINUX_STAT_H /* hack to avoid inclusion of <linux/stat.h> */
32 #define _LINUX_STRING_H_ /* hack to avoid inclusion of <linux/string.h> */
33 #define _LINUX_FS_H /* hack to avoid inclusion of <linux/fs.h> */
34
35 #include <asm/types.h>
36 #include <asm/byteorder.h>
37
38 #include <linux/msdos_fs.h>
39
40 #include <stddef.h>
41 #include <stdint.h>
42 #include <endian.h>
43
44 #define VFAT_LN_ATTR (ATTR_RO | ATTR_HIDDEN | ATTR_SYS | ATTR_VOLUME)
45
46 #define FAT_STATE_DIRTY 0x01
47
48 /* ++roman: Use own definition of boot sector structure -- the kernel headers'
49 * name for it is msdos_boot_sector in 2.0 and fat_boot_sector in 2.1 ... */
50 struct boot_sector {
51 __u8 ignored[3]; /* Boot strap short or near jump */
52 __u8 system_id[8]; /* Name - can be used to special case
53 partition manager volumes */
54 __u8 sector_size[2]; /* bytes per logical sector */
55 __u8 cluster_size; /* sectors/cluster */
56 __u16 reserved; /* reserved sectors */
57 __u8 fats; /* number of FATs */
58 __u8 dir_entries[2]; /* root directory entries */
59 __u8 sectors[2]; /* number of sectors */
60 __u8 media; /* media code (unused) */
61 __u16 fat_length; /* sectors/FAT */
62 __u16 secs_track; /* sectors per track */
63 __u16 heads; /* number of heads */
64 __u32 hidden; /* hidden sectors (unused) */
65 __u32 total_sect; /* number of sectors (if sectors == 0) */
66
67 /* The following fields are only used by FAT32 */
68 __u32 fat32_length; /* sectors/FAT */
69 __u16 flags; /* bit 8: fat mirroring, low 4: active fat */
70 __u8 version[2]; /* major, minor filesystem version */
71 __u32 root_cluster; /* first cluster in root directory */
72 __u16 info_sector; /* filesystem info sector */
73 __u16 backup_boot; /* backup boot sector */
74 __u8 reserved2[12]; /* Unused */
75
76 __u8 drive_number; /* Logical Drive Number */
77 __u8 reserved3; /* Unused */
78
79 __u8 extended_sig; /* Extended Signature (0x29) */
80 __u32 serial; /* Serial number */
81 __u8 label[11]; /* FS label */
82 __u8 fs_type[8]; /* FS Type */
83
84 /* fill up to 512 bytes */
85 __u8 junk[422];
86 } __attribute__ ((packed));
87
88 struct boot_sector_16 {
89 __u8 ignored[3]; /* Boot strap short or near jump */
90 __u8 system_id[8]; /* Name - can be used to special case
91 partition manager volumes */
92 __u8 sector_size[2]; /* bytes per logical sector */
93 __u8 cluster_size; /* sectors/cluster */
94 __u16 reserved; /* reserved sectors */
95 __u8 fats; /* number of FATs */
96 __u8 dir_entries[2]; /* root directory entries */
97 __u8 sectors[2]; /* number of sectors */
98 __u8 media; /* media code (unused) */
99 __u16 fat_length; /* sectors/FAT */
100 __u16 secs_track; /* sectors per track */
101 __u16 heads; /* number of heads */
102 __u32 hidden; /* hidden sectors (unused) */
103 __u32 total_sect; /* number of sectors (if sectors == 0) */
104
105 __u8 drive_number; /* Logical Drive Number */
106 __u8 reserved2; /* Unused */
107
108 __u8 extended_sig; /* Extended Signature (0x29) */
109 __u32 serial; /* Serial number */
110 __u8 label[11]; /* FS label */
111 __u8 fs_type[8]; /* FS Type */
112
113 /* fill up to 512 bytes */
114 __u8 junk[450];
115 } __attribute__ ((packed));
116
117 struct info_sector {
118 __u32 magic; /* Magic for info sector ('RRaA') */
119 __u8 junk[0x1dc];
120 __u32 reserved1; /* Nothing as far as I can tell */
121 __u32 signature; /* 0x61417272 ('rrAa') */
122 __u32 free_clusters; /* Free cluster count. -1 if unknown */
123 __u32 next_cluster; /* Most recently allocated cluster. */
124 __u32 reserved2[3];
125 __u16 reserved3;
126 __u16 boot_sign;
127 };
128
129 typedef struct {
130 __u8 name[8], ext[3]; /* name and extension */
131 __u8 attr; /* attribute bits */
132 __u8 lcase; /* Case for base and extension */
133 __u8 ctime_ms; /* Creation time, milliseconds */
134 __u16 ctime; /* Creation time */
135 __u16 cdate; /* Creation date */
136 __u16 adate; /* Last access date */
137 __u16 starthi; /* High 16 bits of cluster in FAT32 */
138 __u16 time, date, start; /* time, date and first cluster */
139 __u32 size; /* file size (in bytes) */
140 } __attribute__ ((packed)) DIR_ENT;
141
142 typedef struct _dos_file {
143 DIR_ENT dir_ent;
144 char *lfn;
145 loff_t offset;
146 loff_t lfn_offset;
147 struct _dos_file *parent; /* parent directory */
148 struct _dos_file *next; /* next entry */
149 struct _dos_file *first; /* first entry (directory only) */
150 } DOS_FILE;
151
152 typedef struct {
153 uint32_t value;
154 uint32_t reserved;
155 } FAT_ENTRY;
156
157 typedef struct {
158 int nfats;
159 loff_t fat_start;
160 unsigned int fat_size; /* unit is bytes */
161 unsigned int fat_bits; /* size of a FAT entry */
162 unsigned int eff_fat_bits; /* # of used bits in a FAT entry */
163 uint32_t root_cluster; /* 0 for old-style root dir */
164 loff_t root_start;
165 unsigned int root_entries;
166 loff_t data_start;
167 unsigned int cluster_size;
168 uint32_t clusters;
169 loff_t fsinfo_start; /* 0 if not present */
170 long free_clusters;
171 loff_t backupboot_start; /* 0 if not present */
172 unsigned char *fat;
173 DOS_FILE **cluster_owner;
174 char *label;
175 } DOS_FS;
176
177 extern int interactive, rw, list, verbose, test, write_immed;
178 extern int atari_format;
179 extern unsigned n_files;
180 extern void *mem_queue;
181
182 /* value to use as end-of-file marker */
183 #define FAT_EOF(fs) ((atari_format ? 0xfff : 0xff8) | FAT_EXTD(fs))
184 #define FAT_IS_EOF(fs,v) ((uint32_t)(v) >= (0xff8|FAT_EXTD(fs)))
185 /* value to mark bad clusters */
186 #define FAT_BAD(fs) (0xff7 | FAT_EXTD(fs))
187 /* range of values used for bad clusters */
188 #define FAT_MIN_BAD(fs) ((atari_format ? 0xff0 : 0xff7) | FAT_EXTD(fs))
189 #define FAT_MAX_BAD(fs) ((atari_format ? 0xff7 : 0xff7) | FAT_EXTD(fs))
190 #define FAT_IS_BAD(fs,v) ((v) >= FAT_MIN_BAD(fs) && (v) <= FAT_MAX_BAD(fs))
191
192 /* return -16 as a number with fs->fat_bits bits */
193 #define FAT_EXTD(fs) (((1 << fs->eff_fat_bits)-1) & ~0xf)
194
195 /* marker for files with no 8.3 name */
196 #define FAT_NO_83NAME 32
197
198 #endif
0 /* io.c - Virtual disk input/output
1
2 Copyright (C) 1993 Werner Almesberger <werner.almesberger@lrc.di.epfl.ch>
3 Copyright (C) 1998 Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de>
4 Copyright (C) 2008-2014 Daniel Baumann <mail@daniel-baumann.ch>
5
6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
18
19 The complete text of the GNU General Public License
20 can be found in /usr/share/common-licenses/GPL-3 file.
21 */
22
23 /*
24 * Thu Feb 26 01:15:36 CET 1998: Martin Schulze <joey@infodrom.north.de>
25 * Fixed nasty bug that caused every file with a name like
26 * xxxxxxxx.xxx to be treated as bad name that needed to be fixed.
27 */
28
29 /* FAT32, VFAT, Atari format support, and various fixes additions May 1998
30 * by Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de> */
31
32 #define _LARGEFILE64_SOURCE
33 #include <sys/types.h>
34 #include <stdlib.h>
35 #include <stdio.h>
36 #include <string.h>
37 #include <unistd.h>
38 #include <sys/stat.h>
39 #include <sys/ioctl.h>
40 #include <errno.h>
41 #include <fcntl.h>
42 #include <linux/fd.h>
43
44 #include "fsck.fat.h"
45 #include "common.h"
46 #include "io.h"
47
48 typedef struct _change {
49 void *data;
50 loff_t pos;
51 int size;
52 struct _change *next;
53 } CHANGE;
54
55 static CHANGE *changes, *last;
56 static int fd, did_change = 0;
57
58 unsigned device_no;
59
60 #ifdef __DJGPP__
61 #include "volume.h" /* DOS lowlevel disk access functions */
62 loff_t llseek(int fd, loff_t offset, int whence)
63 {
64 if ((whence != SEEK_SET) || (fd == 4711))
65 return -1; /* only those supported */
66 return VolumeSeek(offset);
67 }
68
69 #define open OpenVolume
70 #define close CloseVolume
71 #define read(a,b,c) ReadVolume(b,c)
72 #define write(a,b,c) WriteVolume(b,c)
73 #else
74 loff_t llseek(int fd, loff_t offset, int whence)
75 {
76 return (loff_t) lseek64(fd, (off64_t) offset, whence);
77 }
78 #endif
79
80 void fs_open(char *path, int rw)
81 {
82 struct stat stbuf;
83
84 if ((fd = open(path, rw ? O_RDWR : O_RDONLY)) < 0) {
85 perror("open");
86 exit(6);
87 }
88 changes = last = NULL;
89 did_change = 0;
90
91 #ifndef _DJGPP_
92 if (fstat(fd, &stbuf) < 0)
93 pdie("fstat %s", path);
94 device_no = S_ISBLK(stbuf.st_mode) ? (stbuf.st_rdev >> 8) & 0xff : 0;
95 #else
96 if (IsWorkingOnImageFile()) {
97 if (fstat(GetVolumeHandle(), &stbuf) < 0)
98 pdie("fstat image %s", path);
99 device_no = 0;
100 } else {
101 /* return 2 for floppy, 1 for ramdisk, 7 for loopback */
102 /* used by boot.c in Atari mode: floppy always FAT12, */
103 /* loopback / ramdisk only FAT12 if usual floppy size, */
104 /* harddisk always FAT16 on Atari... */
105 device_no = (GetVolumeHandle() < 2) ? 2 : 1;
106 /* telling "floppy" for A:/B:, "ramdisk" for the rest */
107 }
108 #endif
109 }
110
111 /**
112 * Read data from the partition, accounting for any pending updates that are
113 * queued for writing.
114 *
115 * @param[in] pos Byte offset, relative to the beginning of the partition,
116 * at which to read
117 * @param[in] size Number of bytes to read
118 * @param[out] data Where to put the data read
119 */
120 void fs_read(loff_t pos, int size, void *data)
121 {
122 CHANGE *walk;
123 int got;
124
125 if (llseek(fd, pos, 0) != pos)
126 pdie("Seek to %lld", pos);
127 if ((got = read(fd, data, size)) < 0)
128 pdie("Read %d bytes at %lld", size, pos);
129 if (got != size)
130 die("Got %d bytes instead of %d at %lld", got, size, pos);
131 for (walk = changes; walk; walk = walk->next) {
132 if (walk->pos < pos + size && walk->pos + walk->size > pos) {
133 if (walk->pos < pos)
134 memcpy(data, (char *)walk->data + pos - walk->pos, min(size,
135 walk->
136 size -
137 pos +
138 walk->
139 pos));
140 else
141 memcpy((char *)data + walk->pos - pos, walk->data,
142 min(walk->size, size + pos - walk->pos));
143 }
144 }
145 }
146
147 int fs_test(loff_t pos, int size)
148 {
149 void *scratch;
150 int okay;
151
152 if (llseek(fd, pos, 0) != pos)
153 pdie("Seek to %lld", pos);
154 scratch = alloc(size);
155 okay = read(fd, scratch, size) == size;
156 free(scratch);
157 return okay;
158 }
159
160 void fs_write(loff_t pos, int size, void *data)
161 {
162 CHANGE *new;
163 int did;
164
165 if (write_immed) {
166 did_change = 1;
167 if (llseek(fd, pos, 0) != pos)
168 pdie("Seek to %lld", pos);
169 if ((did = write(fd, data, size)) == size)
170 return;
171 if (did < 0)
172 pdie("Write %d bytes at %lld", size, pos);
173 die("Wrote %d bytes instead of %d at %lld", did, size, pos);
174 }
175 new = alloc(sizeof(CHANGE));
176 new->pos = pos;
177 memcpy(new->data = alloc(new->size = size), data, size);
178 new->next = NULL;
179 if (last)
180 last->next = new;
181 else
182 changes = new;
183 last = new;
184 }
185
186 static void fs_flush(void)
187 {
188 CHANGE *this;
189 int size;
190
191 while (changes) {
192 this = changes;
193 changes = changes->next;
194 if (llseek(fd, this->pos, 0) != this->pos)
195 fprintf(stderr,
196 "Seek to %lld failed: %s\n Did not write %d bytes.\n",
197 (long long)this->pos, strerror(errno), this->size);
198 else if ((size = write(fd, this->data, this->size)) < 0)
199 fprintf(stderr, "Writing %d bytes at %lld failed: %s\n", this->size,
200 (long long)this->pos, strerror(errno));
201 else if (size != this->size)
202 fprintf(stderr, "Wrote %d bytes instead of %d bytes at %lld."
203 "\n", size, this->size, (long long)this->pos);
204 free(this->data);
205 free(this);
206 }
207 }
208
209 int fs_close(int write)
210 {
211 CHANGE *next;
212 int changed;
213
214 changed = ! !changes;
215 if (write)
216 fs_flush();
217 else
218 while (changes) {
219 next = changes->next;
220 free(changes->data);
221 free(changes);
222 changes = next;
223 }
224 if (close(fd) < 0)
225 pdie("closing filesystem");
226 return changed || did_change;
227 }
228
229 int fs_changed(void)
230 {
231 return ! !changes || did_change;
232 }
0 /* io.h - Virtual disk input/output
1
2 Copyright (C) 1993 Werner Almesberger <werner.almesberger@lrc.di.epfl.ch>
3 Copyright (C) 1998 Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de>
4 Copyright (C) 2008-2014 Daniel Baumann <mail@daniel-baumann.ch>
5
6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
18
19 The complete text of the GNU General Public License
20 can be found in /usr/share/common-licenses/GPL-3 file.
21 */
22
23 /* FAT32, VFAT, Atari format support, and various fixes additions May 1998
24 * by Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de> */
25
26 #ifndef _IO_H
27 #define _IO_H
28
29 #include <fcntl.h> /* for loff_t */
30
31 loff_t llseek(int fd, loff_t offset, int whence);
32
33 /* lseek() analogue for large offsets. */
34
35 void fs_open(char *path, int rw);
36
37 /* Opens the filesystem PATH. If RW is zero, the filesystem is opened
38 read-only, otherwise, it is opened read-write. */
39
40 void fs_read(loff_t pos, int size, void *data);
41
42 /* Reads SIZE bytes starting at POS into DATA. Performs all applicable
43 changes. */
44
45 int fs_test(loff_t pos, int size);
46
47 /* Returns a non-zero integer if SIZE bytes starting at POS can be read without
48 errors. Otherwise, it returns zero. */
49
50 void fs_write(loff_t pos, int size, void *data);
51
52 /* If write_immed is non-zero, SIZE bytes are written from DATA to the disk,
53 starting at POS. If write_immed is zero, the change is added to a list in
54 memory. */
55
56 int fs_close(int write);
57
58 /* Closes the filesystem, performs all pending changes if WRITE is non-zero
59 and removes the list of changes. Returns a non-zero integer if the file
60 system has been changed since the last fs_open, zero otherwise. */
61
62 int fs_changed(void);
63
64 /* Determines whether the filesystem has changed. See fs_close. */
65
66 extern unsigned device_no;
67
68 /* Major number of device (0 if file) and size (in 512 byte sectors) */
69
70 #endif
0 /* lfn.c - Functions for handling VFAT long filenames
1
2 Copyright (C) 1998 Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de>
3 Copyright (C) 2008-2014 Daniel Baumann <mail@daniel-baumann.ch>
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 The complete text of the GNU General Public License
19 can be found in /usr/share/common-licenses/GPL-3 file.
20 */
21
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <string.h>
25 #include <limits.h>
26 #include <time.h>
27
28 #include "common.h"
29 #include "io.h"
30 #include "fsck.fat.h"
31 #include "lfn.h"
32 #include "file.h"
33
34 typedef struct {
35 __u8 id; /* sequence number for slot */
36 __u8 name0_4[10]; /* first 5 characters in name */
37 __u8 attr; /* attribute byte */
38 __u8 reserved; /* always 0 */
39 __u8 alias_checksum; /* checksum for 8.3 alias */
40 __u8 name5_10[12]; /* 6 more characters in name */
41 __u16 start; /* starting cluster number, 0 in long slots */
42 __u8 name11_12[4]; /* last 2 characters in name */
43 } LFN_ENT;
44
45 #define LFN_ID_START 0x40
46 #define LFN_ID_SLOTMASK 0x1f
47
48 #define CHARS_PER_LFN 13
49
50 /* These modul-global vars represent the state of the LFN parser */
51 unsigned char *lfn_unicode = NULL;
52 unsigned char lfn_checksum;
53 int lfn_slot = -1;
54 loff_t *lfn_offsets = NULL;
55 int lfn_parts = 0;
56
57 static unsigned char fat_uni2esc[64] = {
58 '0', '1', '2', '3', '4', '5', '6', '7',
59 '8', '9', 'A', 'B', 'C', 'D', 'E', 'F',
60 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
61 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V',
62 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd',
63 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l',
64 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
65 'u', 'v', 'w', 'x', 'y', 'z', '+', '-'
66 };
67
68 /* This defines which unicode chars are directly convertable to ISO-8859-1 */
69 #define UNICODE_CONVERTABLE(cl,ch) (ch == 0 && (cl < 0x80 || cl >= 0xa0))
70
71 /* for maxlen param */
72 #define UNTIL_0 INT_MAX
73
74 /* Convert name part in 'lfn' from unicode to ASCII */
75 #define CNV_THIS_PART(lfn) \
76 ({ \
77 unsigned char __part_uni[CHARS_PER_LFN*2]; \
78 copy_lfn_part( __part_uni, lfn ); \
79 cnv_unicode( __part_uni, CHARS_PER_LFN, 0 ); \
80 })
81
82 /* Convert name parts collected so far (from previous slots) from unicode to
83 * ASCII */
84 #define CNV_PARTS_SO_FAR() \
85 (cnv_unicode( lfn_unicode+(lfn_slot*CHARS_PER_LFN*2), \
86 lfn_parts*CHARS_PER_LFN, 0 ))
87
88 #define BYTES_TO_WCHAR(cl,ch) ((wchar_t)((unsigned)(cl) + ((unsigned)(ch) << 8)))
89 static size_t mbslen(wchar_t x)
90 {
91 wchar_t wstr[] = { x, 0 };
92 return wcstombs(NULL, wstr, 0);
93 }
94
95 static size_t wctombs(char *dest, wchar_t x)
96 {
97 wchar_t wstr[] = { x, 0 };
98 size_t size = wcstombs(NULL, wstr, 0);
99 if (size != (size_t) - 1)
100 size = wcstombs(dest, wstr, size + 1);
101 return size;
102 }
103
104 /* This function converts an unicode string to a normal ASCII string, assuming
105 * ISO-8859-1 charset. Characters not in 8859-1 are converted to the same
106 * escape notation as used by the kernel, i.e. the uuencode-like ":xxx" */
107 static char *cnv_unicode(const unsigned char *uni, int maxlen, int use_q)
108 {
109 const unsigned char *up;
110 unsigned char *out, *cp;
111 int len, val;
112 size_t x;
113
114 for (len = 0, up = uni; (up - uni) / 2 < maxlen && (up[0] || up[1]);
115 up += 2) {
116 if ((x = mbslen(BYTES_TO_WCHAR(up[0], up[1]))) != (size_t) - 1)
117 len += x;
118 else if (UNICODE_CONVERTABLE(up[0], up[1]))
119 ++len;
120 else
121 len += 4;
122 }
123 cp = out = use_q ? qalloc(&mem_queue, len + 1) : alloc(len + 1);
124
125 for (up = uni; (up - uni) / 2 < maxlen && (up[0] || up[1]); up += 2) {
126 if ((x =
127 wctombs((char *)cp, BYTES_TO_WCHAR(up[0], up[1]))) != (size_t) - 1)
128 cp += x;
129 else if (UNICODE_CONVERTABLE(up[0], up[1]))
130 *cp++ = up[0];
131 else {
132 /* here the same escape notation is used as in the Linux kernel */
133 *cp++ = ':';
134 val = (up[1] << 8) + up[0];
135 cp[2] = fat_uni2esc[val & 0x3f];
136 val >>= 6;
137 cp[1] = fat_uni2esc[val & 0x3f];
138 val >>= 6;
139 cp[0] = fat_uni2esc[val & 0x3f];
140 cp += 3;
141 }
142 }
143 *cp = 0;
144
145 return (char *)out;
146 }
147
148 static void copy_lfn_part(unsigned char *dst, LFN_ENT * lfn)
149 {
150 memcpy(dst, lfn->name0_4, 10);
151 memcpy(dst + 10, lfn->name5_10, 12);
152 memcpy(dst + 22, lfn->name11_12, 4);
153 }
154
155 static void clear_lfn_slots(int start, int end)
156 {
157 int i;
158 LFN_ENT empty;
159
160 /* New dir entry is zeroed except first byte, which is set to 0xe5.
161 * This is to avoid that some FAT-reading OSes (not Linux! ;) stop reading
162 * a directory at the first zero entry...
163 */
164 memset(&empty, 0, sizeof(empty));
165 empty.id = DELETED_FLAG;
166
167 for (i = start; i <= end; ++i) {
168 fs_write(lfn_offsets[i], sizeof(LFN_ENT), &empty);
169 }
170 }
171
172 void lfn_fix_checksum(loff_t from, loff_t to, const char *short_name)
173 {
174 int i;
175 __u8 sum;
176 for (sum = 0, i = 0; i < 11; i++)
177 sum = (((sum & 1) << 7) | ((sum & 0xfe) >> 1)) + short_name[i];
178
179 for (; from < to; from += sizeof(LFN_ENT)) {
180 fs_write(from + offsetof(LFN_ENT, alias_checksum), sizeof(sum), &sum);
181 }
182 }
183
184 void lfn_reset(void)
185 {
186 if (lfn_unicode)
187 free(lfn_unicode);
188 lfn_unicode = NULL;
189 if (lfn_offsets)
190 free(lfn_offsets);
191 lfn_offsets = NULL;
192 lfn_slot = -1;
193 }
194
195 /* This function is only called with de->attr == VFAT_LN_ATTR. It stores part
196 * of the long name. */
197 void lfn_add_slot(DIR_ENT * de, loff_t dir_offset)
198 {
199 LFN_ENT *lfn = (LFN_ENT *) de;
200 int slot = lfn->id & LFN_ID_SLOTMASK;
201 unsigned offset;
202
203 if (lfn_slot == 0)
204 lfn_check_orphaned();
205
206 if (de->attr != VFAT_LN_ATTR)
207 die("lfn_add_slot called with non-LFN directory entry");
208
209 if (lfn->id & LFN_ID_START && slot != 0) {
210 if (lfn_slot != -1) {
211 int can_clear = 0;
212 /* There is already a LFN "in progess", so it is an error that a
213 * new start entry is here. */
214 /* Causes: 1) if slot# == expected: start bit set mysteriously, 2)
215 * old LFN overwritten by new one */
216 /* Fixes: 1) delete previous LFN 2) if slot# == expected and
217 * checksum ok: clear start bit */
218 /* XXX: Should delay that until next LFN known (then can better
219 * display the name) */
220 printf("A new long file name starts within an old one.\n");
221 if (slot == lfn_slot && lfn->alias_checksum == lfn_checksum) {
222 char *part1 = CNV_THIS_PART(lfn);
223 char *part2 = CNV_PARTS_SO_FAR();
224 printf(" It could be that the LFN start bit is wrong here\n"
225 " if \"%s\" seems to match \"%s\".\n", part1, part2);
226 free(part1);
227 free(part2);
228 can_clear = 1;
229 }
230 if (interactive) {
231 printf("1: Delete previous LFN\n2: Leave it as it is.\n");
232 if (can_clear)
233 printf("3: Clear start bit and concatenate LFNs\n");
234 } else
235 printf(" Not auto-correcting this.\n");
236 if (interactive) {
237 switch (get_key(can_clear ? "123" : "12", "?")) {
238 case '1':
239 clear_lfn_slots(0, lfn_parts - 1);
240 lfn_reset();
241 break;
242 case '2':
243 break;
244 case '3':
245 lfn->id &= ~LFN_ID_START;
246 fs_write(dir_offset + offsetof(LFN_ENT, id),
247 sizeof(lfn->id), &lfn->id);
248 break;
249 }
250 }
251 }
252 lfn_slot = slot;
253 lfn_checksum = lfn->alias_checksum;
254 lfn_unicode = alloc((lfn_slot * CHARS_PER_LFN + 1) * 2);
255 lfn_offsets = alloc(lfn_slot * sizeof(loff_t));
256 lfn_parts = 0;
257 } else if (lfn_slot == -1 && slot != 0) {
258 /* No LFN in progress, but slot found; start bit missing */
259 /* Causes: 1) start bit got lost, 2) Previous slot with start bit got
260 * lost */
261 /* Fixes: 1) delete LFN, 2) set start bit */
262 char *part = CNV_THIS_PART(lfn);
263 printf("Long filename fragment \"%s\" found outside a LFN "
264 "sequence.\n (Maybe the start bit is missing on the "
265 "last fragment)\n", part);
266 if (interactive) {
267 printf("1: Delete fragment\n2: Leave it as it is.\n"
268 "3: Set start bit\n");
269 } else
270 printf(" Not auto-correcting this.\n");
271 switch (interactive ? get_key("123", "?") : '2') {
272 case '1':
273 if (!lfn_offsets)
274 lfn_offsets = alloc(sizeof(loff_t));
275 lfn_offsets[0] = dir_offset;
276 clear_lfn_slots(0, 0);
277 lfn_reset();
278 return;
279 case '2':
280 lfn_reset();
281 return;
282 case '3':
283 lfn->id |= LFN_ID_START;
284 fs_write(dir_offset + offsetof(LFN_ENT, id),
285 sizeof(lfn->id), &lfn->id);
286 lfn_slot = slot;
287 lfn_checksum = lfn->alias_checksum;
288 lfn_unicode = alloc((lfn_slot * CHARS_PER_LFN + 1) * 2);
289 lfn_offsets = alloc(lfn_slot * sizeof(loff_t));
290 lfn_parts = 0;
291 break;
292 }
293 } else if (slot != lfn_slot) {
294 /* wrong sequence number */
295 /* Causes: 1) seq-no destroyed */
296 /* Fixes: 1) delete LFN, 2) fix number (maybe only if following parts
297 * are ok?, maybe only if checksum is ok?) (Attention: space
298 * for name was allocated before!) */
299 int can_fix = 0;
300 printf("Unexpected long filename sequence number "
301 "(%d vs. expected %d).\n", slot, lfn_slot);
302 if (lfn->alias_checksum == lfn_checksum && lfn_slot > 0) {
303 char *part1 = CNV_THIS_PART(lfn);
304 char *part2 = CNV_PARTS_SO_FAR();
305 printf(" It could be that just the number is wrong\n"
306 " if \"%s\" seems to match \"%s\".\n", part1, part2);
307 free(part1);
308 free(part2);
309 can_fix = 1;
310 }
311 if (interactive) {
312 printf
313 ("1: Delete LFN\n2: Leave it as it is (and ignore LFN so far)\n");
314 if (can_fix)
315 printf("3: Correct sequence number\n");
316 } else
317 printf(" Not auto-correcting this.\n");
318 switch (interactive ? get_key(can_fix ? "123" : "12", "?") : '2') {
319 case '1':
320 if (!lfn_offsets) {
321 lfn_offsets = alloc(sizeof(loff_t));
322 lfn_parts = 0;
323 }
324 lfn_offsets[lfn_parts++] = dir_offset;
325 clear_lfn_slots(0, lfn_parts - 1);
326 lfn_reset();
327 return;
328 case '2':
329 lfn_reset();
330 return;
331 case '3':
332 lfn->id = (lfn->id & ~LFN_ID_SLOTMASK) | lfn_slot;
333 fs_write(dir_offset + offsetof(LFN_ENT, id),
334 sizeof(lfn->id), &lfn->id);
335 break;
336 }
337 }
338
339 if (lfn->alias_checksum != lfn_checksum) {
340 /* checksum mismatch */
341 /* Causes: 1) checksum field here destroyed */
342 /* Fixes: 1) delete LFN, 2) fix checksum */
343 printf("Checksum in long filename part wrong "
344 "(%02x vs. expected %02x).\n",
345 lfn->alias_checksum, lfn_checksum);
346 if (interactive) {
347 printf("1: Delete LFN\n2: Leave it as it is.\n"
348 "3: Correct checksum\n");
349 } else
350 printf(" Not auto-correcting this.\n");
351 if (interactive) {
352 switch (get_key("123", "?")) {
353 case '1':
354 lfn_offsets[lfn_parts++] = dir_offset;
355 clear_lfn_slots(0, lfn_parts - 1);
356 lfn_reset();
357 return;
358 case '2':
359 break;
360 case '3':
361 lfn->alias_checksum = lfn_checksum;
362 fs_write(dir_offset + offsetof(LFN_ENT, alias_checksum),
363 sizeof(lfn->alias_checksum), &lfn->alias_checksum);
364 break;
365 }
366 }
367 }
368
369 if (lfn_slot != -1) {
370 lfn_slot--;
371 offset = lfn_slot * CHARS_PER_LFN * 2;
372 copy_lfn_part(lfn_unicode + offset, lfn);
373 if (lfn->id & LFN_ID_START)
374 lfn_unicode[offset + 26] = lfn_unicode[offset + 27] = 0;
375 lfn_offsets[lfn_parts++] = dir_offset;
376 }
377
378 if (lfn->reserved != 0) {
379 printf("Reserved field in VFAT long filename slot is not 0 "
380 "(but 0x%02x).\n", lfn->reserved);
381 if (interactive)
382 printf("1: Fix.\n2: Leave it.\n");
383 else
384 printf("Auto-setting to 0.\n");
385 if (!interactive || get_key("12", "?") == '1') {
386 lfn->reserved = 0;
387 fs_write(dir_offset + offsetof(LFN_ENT, reserved),
388 sizeof(lfn->reserved), &lfn->reserved);
389 }
390 }
391 if (lfn->start != htole16(0)) {
392 printf("Start cluster field in VFAT long filename slot is not 0 "
393 "(but 0x%04x).\n", lfn->start);
394 if (interactive)
395 printf("1: Fix.\n2: Leave it.\n");
396 else
397 printf("Auto-setting to 0.\n");
398 if (!interactive || get_key("12", "?") == '1') {
399 lfn->start = htole16(0);
400 fs_write(dir_offset + offsetof(LFN_ENT, start),
401 sizeof(lfn->start), &lfn->start);
402 }
403 }
404 }
405
406 /* This function is always called when de->attr != VFAT_LN_ATTR is found, to
407 * retrieve the previously constructed LFN. */
408 char *lfn_get(DIR_ENT * de, loff_t * lfn_offset)
409 {
410 char *lfn;
411 __u8 sum;
412 int i;
413
414 *lfn_offset = 0;
415 if (de->attr == VFAT_LN_ATTR)
416 die("lfn_get called with LFN directory entry");
417
418 #if 0
419 if (de->lcase)
420 printf("lcase=%02x\n", de->lcase);
421 #endif
422
423 if (lfn_slot == -1)
424 /* no long name for this file */
425 return NULL;
426
427 if (lfn_slot != 0) {
428 /* The long name isn't finished yet. */
429 /* Causes: 1) LFN slot overwritten by non-VFAT aware tool */
430 /* Fixes: 1) delete LFN 2) move overwriting entry to somewhere else
431 * and let user enter missing part of LFN (hard to do :-()
432 * 3) renumber entries and truncate name */
433 char *long_name = CNV_PARTS_SO_FAR();
434 char *short_name = file_name(de->name);
435 printf("Unfinished long file name \"%s\".\n"
436 " (Start may have been overwritten by %s)\n",
437 long_name, short_name);
438 free(long_name);
439 if (interactive) {
440 printf("1: Delete LFN\n2: Leave it as it is.\n"
441 "3: Fix numbering (truncates long name and attaches "
442 "it to short name %s)\n", short_name);
443 } else
444 printf(" Not auto-correcting this.\n");
445 switch (interactive ? get_key("123", "?") : '2') {
446 case '1':
447 clear_lfn_slots(0, lfn_parts - 1);
448 lfn_reset();
449 return NULL;
450 case '2':
451 lfn_reset();
452 return NULL;
453 case '3':
454 for (i = 0; i < lfn_parts; ++i) {
455 __u8 id = (lfn_parts - i) | (i == 0 ? LFN_ID_START : 0);
456 fs_write(lfn_offsets[i] + offsetof(LFN_ENT, id),
457 sizeof(id), &id);
458 }
459 memmove(lfn_unicode, lfn_unicode + lfn_slot * CHARS_PER_LFN * 2,
460 lfn_parts * CHARS_PER_LFN * 2);
461 break;
462 }
463 }
464
465 for (sum = 0, i = 0; i < 8; i++)
466 sum = (((sum & 1) << 7) | ((sum & 0xfe) >> 1)) + de->name[i];
467 for (i = 0; i < 3; i++)
468 sum = (((sum & 1) << 7) | ((sum & 0xfe) >> 1)) + de->ext[i];
469 if (sum != lfn_checksum) {
470 /* checksum doesn't match, long name doesn't apply to this alias */
471 /* Causes: 1) alias renamed */
472 /* Fixes: 1) Fix checksum in LFN entries */
473 char *long_name = CNV_PARTS_SO_FAR();
474 char *short_name = file_name(de->name);
475 printf("Wrong checksum for long file name \"%s\".\n"
476 " (Short name %s may have changed without updating the long name)\n",
477 long_name, short_name);
478 free(long_name);
479 if (interactive) {
480 printf("1: Delete LFN\n2: Leave it as it is.\n"
481 "3: Fix checksum (attaches to short name %s)\n", short_name);
482 } else
483 printf(" Not auto-correcting this.\n");
484 if (interactive) {
485 switch (get_key("123", "?")) {
486 case '1':
487 clear_lfn_slots(0, lfn_parts - 1);
488 lfn_reset();
489 return NULL;
490 case '2':
491 lfn_reset();
492 return NULL;
493 case '3':
494 for (i = 0; i < lfn_parts; ++i) {
495 fs_write(lfn_offsets[i] + offsetof(LFN_ENT, alias_checksum),
496 sizeof(sum), &sum);
497 }
498 break;
499 }
500 }
501 }
502
503 *lfn_offset = lfn_offsets[0];
504 lfn = cnv_unicode(lfn_unicode, UNTIL_0, 1);
505 lfn_reset();
506 return (lfn);
507 }
508
509 void lfn_check_orphaned(void)
510 {
511 char *long_name;
512
513 if (lfn_slot == -1)
514 return;
515
516 long_name = CNV_PARTS_SO_FAR();
517 printf("Orphaned long file name part \"%s\"\n", long_name);
518 if (interactive)
519 printf("1: Delete.\n2: Leave it.\n");
520 else
521 printf(" Auto-deleting.\n");
522 if (!interactive || get_key("12", "?") == '1') {
523 clear_lfn_slots(0, lfn_parts - 1);
524 }
525 lfn_reset();
526 }
0 /* lfn.h - Functions for handling VFAT long filenames
1
2 Copyright (C) 1998 Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de>
3 Copyright (C) 2008-2014 Daniel Baumann <mail@daniel-baumann.ch>
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 The complete text of the GNU General Public License
19 can be found in /usr/share/common-licenses/GPL-3 file.
20 */
21
22 #ifndef _LFN_H
23 #define _LFN_H
24
25 void lfn_reset(void);
26 /* Reset the state of the LFN parser. */
27
28 void lfn_add_slot(DIR_ENT * de, loff_t dir_offset);
29 /* Process a dir slot that is a VFAT LFN entry. */
30
31 char *lfn_get(DIR_ENT * de, loff_t * lfn_offset);
32 /* Retrieve the long name for the proper dir entry. */
33
34 void lfn_check_orphaned(void);
35
36 void lfn_fix_checksum(loff_t from, loff_t to, const char *short_name);
37
38 #endif
0 /* mkfs.fat.c - utility to create FAT/MS-DOS filesystems
1
2 Copyright (C) 1991 Linus Torvalds <torvalds@klaava.helsinki.fi>
3 Copyright (C) 1992-1993 Remy Card <card@masi.ibp.fr>
4 Copyright (C) 1993-1994 David Hudson <dave@humbug.demon.co.uk>
5 Copyright (C) 1998 H. Peter Anvin <hpa@zytor.com>
6 Copyright (C) 1998-2005 Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de>
7 Copyright (C) 2008-2014 Daniel Baumann <mail@daniel-baumann.ch>
8
9 This program is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>.
21
22 The complete text of the GNU General Public License
23 can be found in /usr/share/common-licenses/GPL-3 file.
24 */
25
26 /* Description: Utility to allow an MS-DOS filesystem to be created
27 under Linux. A lot of the basic structure of this program has been
28 borrowed from Remy Card's "mke2fs" code.
29
30 As far as possible the aim here is to make the "mkfs.fat" command
31 look almost identical to the other Linux filesystem make utilties,
32 eg bad blocks are still specified as blocks, not sectors, but when
33 it comes down to it, DOS is tied to the idea of a sector (512 bytes
34 as a rule), and not the block. For example the boot block does not
35 occupy a full cluster.
36
37 Fixes/additions May 1998 by Roman Hodek
38 <Roman.Hodek@informatik.uni-erlangen.de>:
39 - Atari format support
40 - New options -A, -S, -C
41 - Support for filesystems > 2GB
42 - FAT32 support */
43
44 /* Include the header files */
45
46 #include "version.h"
47
48 #include <fcntl.h>
49 #include <linux/hdreg.h>
50 #include <sys/mount.h>
51 #include <linux/fs.h>
52 #include <linux/fd.h>
53 #include <endian.h>
54 #include <mntent.h>
55 #include <signal.h>
56 #include <string.h>
57 #include <stdio.h>
58 #include <stdlib.h>
59 #include <sys/ioctl.h>
60 #include <sys/stat.h>
61 #include <sys/time.h>
62 #include <sys/types.h>
63 #include <unistd.h>
64 #include <time.h>
65 #include <errno.h>
66 #include <ctype.h>
67 #include <stdint.h>
68 #include <endian.h>
69
70 #include <asm/types.h>
71
72 /* In earlier versions, an own llseek() was used, but glibc lseek() is
73 * sufficient (or even better :) for 64 bit offsets in the meantime */
74 #define llseek lseek
75
76 /* Constant definitions */
77
78 #define TRUE 1 /* Boolean constants */
79 #define FALSE 0
80
81 #define TEST_BUFFER_BLOCKS 16
82 #define HARD_SECTOR_SIZE 512
83 #define SECTORS_PER_BLOCK ( BLOCK_SIZE / HARD_SECTOR_SIZE )
84
85 #define NO_NAME "NO NAME "
86
87 /* Macro definitions */
88
89 /* Report a failure message and return a failure error code */
90
91 #define die( str ) fatal_error( "%s: " str "\n" )
92
93 /* Mark a cluster in the FAT as bad */
94
95 #define mark_sector_bad( sector ) mark_FAT_sector( sector, FAT_BAD )
96
97 /* Compute ceil(a/b) */
98
99 static inline int cdiv(int a, int b)
100 {
101 return (a + b - 1) / b;
102 }
103
104 /* MS-DOS filesystem structures -- I included them here instead of
105 including linux/msdos_fs.h since that doesn't include some fields we
106 need */
107
108 #define ATTR_RO 1 /* read-only */
109 #define ATTR_HIDDEN 2 /* hidden */
110 #define ATTR_SYS 4 /* system */
111 #define ATTR_VOLUME 8 /* volume label */
112 #define ATTR_DIR 16 /* directory */
113 #define ATTR_ARCH 32 /* archived */
114
115 #define ATTR_NONE 0 /* no attribute bits */
116 #define ATTR_UNUSED (ATTR_VOLUME | ATTR_ARCH | ATTR_SYS | ATTR_HIDDEN)
117 /* attribute bits that are copied "as is" */
118
119 /* FAT values */
120 #define FAT_EOF (atari_format ? 0x0fffffff : 0x0ffffff8)
121 #define FAT_BAD 0x0ffffff7
122
123 #define MSDOS_EXT_SIGN 0x29 /* extended boot sector signature */
124 #define MSDOS_FAT12_SIGN "FAT12 " /* FAT12 filesystem signature */
125 #define MSDOS_FAT16_SIGN "FAT16 " /* FAT16 filesystem signature */
126 #define MSDOS_FAT32_SIGN "FAT32 " /* FAT32 filesystem signature */
127
128 #define BOOT_SIGN 0xAA55 /* Boot sector magic number */
129
130 #define MAX_CLUST_12 ((1 << 12) - 16)
131 #define MAX_CLUST_16 ((1 << 16) - 16)
132 #define MIN_CLUST_32 65529
133 /* M$ says the high 4 bits of a FAT32 FAT entry are reserved and don't belong
134 * to the cluster number. So the max. cluster# is based on 2^28 */
135 #define MAX_CLUST_32 ((1 << 28) - 16)
136
137 #define FAT12_THRESHOLD 4085
138
139 #define OLDGEMDOS_MAX_SECTORS 32765
140 #define GEMDOS_MAX_SECTORS 65531
141 #define GEMDOS_MAX_SECTOR_SIZE (16*1024)
142
143 #define BOOTCODE_SIZE 448
144 #define BOOTCODE_FAT32_SIZE 420
145
146 /* __attribute__ ((packed)) is used on all structures to make gcc ignore any
147 * alignments */
148
149 struct msdos_volume_info {
150 __u8 drive_number; /* BIOS drive number */
151 __u8 RESERVED; /* Unused */
152 __u8 ext_boot_sign; /* 0x29 if fields below exist (DOS 3.3+) */
153 __u8 volume_id[4]; /* Volume ID number */
154 __u8 volume_label[11]; /* Volume label */
155 __u8 fs_type[8]; /* Typically FAT12 or FAT16 */
156 } __attribute__ ((packed));
157
158 struct msdos_boot_sector {
159 __u8 boot_jump[3]; /* Boot strap short or near jump */
160 __u8 system_id[8]; /* Name - can be used to special case
161 partition manager volumes */
162 __u8 sector_size[2]; /* bytes per logical sector */
163 __u8 cluster_size; /* sectors/cluster */
164 __u16 reserved; /* reserved sectors */
165 __u8 fats; /* number of FATs */
166 __u8 dir_entries[2]; /* root directory entries */
167 __u8 sectors[2]; /* number of sectors */
168 __u8 media; /* media code (unused) */
169 __u16 fat_length; /* sectors/FAT */
170 __u16 secs_track; /* sectors per track */
171 __u16 heads; /* number of heads */
172 __u32 hidden; /* hidden sectors (unused) */
173 __u32 total_sect; /* number of sectors (if sectors == 0) */
174 union {
175 struct {
176 struct msdos_volume_info vi;
177 __u8 boot_code[BOOTCODE_SIZE];
178 } __attribute__ ((packed)) _oldfat;
179 struct {
180 __u32 fat32_length; /* sectors/FAT */
181 __u16 flags; /* bit 8: fat mirroring, low 4: active fat */
182 __u8 version[2]; /* major, minor filesystem version */
183 __u32 root_cluster; /* first cluster in root directory */
184 __u16 info_sector; /* filesystem info sector */
185 __u16 backup_boot; /* backup boot sector */
186 __u16 reserved2[6]; /* Unused */
187 struct msdos_volume_info vi;
188 __u8 boot_code[BOOTCODE_FAT32_SIZE];
189 } __attribute__ ((packed)) _fat32;
190 } __attribute__ ((packed)) fstype;
191 __u16 boot_sign;
192 } __attribute__ ((packed));
193 #define fat32 fstype._fat32
194 #define oldfat fstype._oldfat
195
196 struct fat32_fsinfo {
197 __u32 reserved1; /* Nothing as far as I can tell */
198 __u32 signature; /* 0x61417272L */
199 __u32 free_clusters; /* Free cluster count. -1 if unknown */
200 __u32 next_cluster; /* Most recently allocated cluster.
201 * Unused under Linux. */
202 __u32 reserved2[4];
203 };
204
205 struct msdos_dir_entry {
206 char name[8], ext[3]; /* name and extension */
207 __u8 attr; /* attribute bits */
208 __u8 lcase; /* Case for base and extension */
209 __u8 ctime_ms; /* Creation time, milliseconds */
210 __u16 ctime; /* Creation time */
211 __u16 cdate; /* Creation date */
212 __u16 adate; /* Last access date */
213 __u16 starthi; /* high 16 bits of first cl. (FAT32) */
214 __u16 time, date, start; /* time, date and first cluster */
215 __u32 size; /* file size (in bytes) */
216 } __attribute__ ((packed));
217
218 /* The "boot code" we put into the filesystem... it writes a message and
219 tells the user to try again */
220
221 char dummy_boot_jump[3] = { 0xeb, 0x3c, 0x90 };
222
223 char dummy_boot_jump_m68k[2] = { 0x60, 0x1c };
224
225 #define MSG_OFFSET_OFFSET 3
226 char dummy_boot_code[BOOTCODE_SIZE] = "\x0e" /* push cs */
227 "\x1f" /* pop ds */
228 "\xbe\x5b\x7c" /* mov si, offset message_txt */
229 /* write_msg: */
230 "\xac" /* lodsb */
231 "\x22\xc0" /* and al, al */
232 "\x74\x0b" /* jz key_press */
233 "\x56" /* push si */
234 "\xb4\x0e" /* mov ah, 0eh */
235 "\xbb\x07\x00" /* mov bx, 0007h */
236 "\xcd\x10" /* int 10h */
237 "\x5e" /* pop si */
238 "\xeb\xf0" /* jmp write_msg */
239 /* key_press: */
240 "\x32\xe4" /* xor ah, ah */
241 "\xcd\x16" /* int 16h */
242 "\xcd\x19" /* int 19h */
243 "\xeb\xfe" /* foo: jmp foo */
244 /* message_txt: */
245 "This is not a bootable disk. Please insert a bootable floppy and\r\n"
246 "press any key to try again ... \r\n";
247
248 #define MESSAGE_OFFSET 29 /* Offset of message in above code */
249
250 /* Global variables - the root of all evil :-) - see these and weep! */
251
252 static char *program_name = "mkfs.fat"; /* Name of the program */
253 static char *device_name = NULL; /* Name of the device on which to create the filesystem */
254 static int atari_format = 0; /* Use Atari variation of MS-DOS FS format */
255 static int check = FALSE; /* Default to no readablity checking */
256 static int verbose = 0; /* Default to verbose mode off */
257 static long volume_id; /* Volume ID number */
258 static time_t create_time; /* Creation time */
259 static struct timeval create_timeval; /* Creation time */
260 static char volume_name[] = NO_NAME; /* Volume name */
261 static uint64_t blocks; /* Number of blocks in filesystem */
262 static int sector_size = 512; /* Size of a logical sector */
263 static int sector_size_set = 0; /* User selected sector size */
264 static int backup_boot = 0; /* Sector# of backup boot sector */
265 static int reserved_sectors = 0; /* Number of reserved sectors */
266 static int badblocks = 0; /* Number of bad blocks in the filesystem */
267 static int nr_fats = 2; /* Default number of FATs to produce */
268 static int size_fat = 0; /* Size in bits of FAT entries */
269 static int size_fat_by_user = 0; /* 1 if FAT size user selected */
270 static int dev = -1; /* FS block device file handle */
271 static int ignore_full_disk = 0; /* Ignore warning about 'full' disk devices */
272 static off_t currently_testing = 0; /* Block currently being tested (if autodetect bad blocks) */
273 static struct msdos_boot_sector bs; /* Boot sector data */
274 static int start_data_sector; /* Sector number for the start of the data area */
275 static int start_data_block; /* Block number for the start of the data area */
276 static unsigned char *fat; /* File allocation table */
277 static unsigned alloced_fat_length; /* # of FAT sectors we can keep in memory */
278 static unsigned char *info_sector; /* FAT32 info sector */
279 static struct msdos_dir_entry *root_dir; /* Root directory */
280 static int size_root_dir; /* Size of the root directory in bytes */
281 static int sectors_per_cluster = 0; /* Number of sectors per disk cluster */
282 static int root_dir_entries = 0; /* Number of root directory entries */
283 static char *blank_sector; /* Blank sector - all zeros */
284 static int hidden_sectors = 0; /* Number of hidden sectors */
285 static int hidden_sectors_by_user = 0; /* -h option invoked */
286 static int drive_number_option = 0; /* drive number */
287 static int drive_number_by_user = 0; /* drive number option invoked */
288 static int fat_media_byte = 0; /* media byte in header and starting FAT */
289 static int malloc_entire_fat = FALSE; /* Whether we should malloc() the entire FAT or not */
290 static int align_structures = TRUE; /* Whether to enforce alignment */
291 static int orphaned_sectors = 0; /* Sectors that exist in the last block of filesystem */
292
293 /* Function prototype definitions */
294
295 static void fatal_error(const char *fmt_string) __attribute__ ((noreturn));
296 static void mark_FAT_cluster(int cluster, unsigned int value);
297 static void mark_FAT_sector(int sector, unsigned int value);
298 static long do_check(char *buffer, int try, off_t current_block);
299 static void alarm_intr(int alnum);
300 static void check_blocks(void);
301 static void get_list_blocks(char *filename);
302 static int valid_offset(int fd, loff_t offset);
303 static uint64_t count_blocks(char *filename, int *remainder);
304 static void check_mount(char *device_name);
305 static void establish_params(int device_num, int size);
306 static void setup_tables(void);
307 static void write_tables(void);
308
309 /* The function implementations */
310
311 /* Handle the reporting of fatal errors. Volatile to let gcc know that this doesn't return */
312
313 static void fatal_error(const char *fmt_string)
314 {
315 fprintf(stderr, fmt_string, program_name, device_name);
316 exit(1); /* The error exit code is 1! */
317 }
318
319 /* Mark the specified cluster as having a particular value */
320
321 static void mark_FAT_cluster(int cluster, unsigned int value)
322 {
323 switch (size_fat) {
324 case 12:
325 value &= 0x0fff;
326 if (((cluster * 3) & 0x1) == 0) {
327 fat[3 * cluster / 2] = (unsigned char)(value & 0x00ff);
328 fat[(3 * cluster / 2) + 1] =
329 (unsigned char)((fat[(3 * cluster / 2) + 1] & 0x00f0)
330 | ((value & 0x0f00) >> 8));
331 } else {
332 fat[3 * cluster / 2] =
333 (unsigned char)((fat[3 * cluster / 2] & 0x000f) |
334 ((value & 0x000f) << 4));
335 fat[(3 * cluster / 2) + 1] = (unsigned char)((value & 0x0ff0) >> 4);
336 }
337 break;
338
339 case 16:
340 value &= 0xffff;
341 fat[2 * cluster] = (unsigned char)(value & 0x00ff);
342 fat[(2 * cluster) + 1] = (unsigned char)(value >> 8);
343 break;
344
345 case 32:
346 value &= 0xfffffff;
347 fat[4 * cluster] = (unsigned char)(value & 0x000000ff);
348 fat[(4 * cluster) + 1] = (unsigned char)((value & 0x0000ff00) >> 8);
349 fat[(4 * cluster) + 2] = (unsigned char)((value & 0x00ff0000) >> 16);
350 fat[(4 * cluster) + 3] = (unsigned char)((value & 0xff000000) >> 24);
351 break;
352
353 default:
354 die("Bad FAT size (not 12, 16, or 32)");
355 }
356 }
357
358 /* Mark a specified sector as having a particular value in it's FAT entry */
359
360 static void mark_FAT_sector(int sector, unsigned int value)
361 {
362 int cluster;
363
364 cluster = (sector - start_data_sector) / (int)(bs.cluster_size) /
365 (sector_size / HARD_SECTOR_SIZE);
366 if (cluster < 0)
367 die("Invalid cluster number in mark_FAT_sector: probably bug!");
368
369 mark_FAT_cluster(cluster, value);
370 }
371
372 /* Perform a test on a block. Return the number of blocks that could be read successfully */
373
374 static long do_check(char *buffer, int try, off_t current_block)
375 {
376 long got;
377
378 if (llseek(dev, current_block * BLOCK_SIZE, SEEK_SET) /* Seek to the correct location */
379 !=current_block * BLOCK_SIZE)
380 die("seek failed during testing for blocks");
381
382 got = read(dev, buffer, try * BLOCK_SIZE); /* Try reading! */
383 if (got < 0)
384 got = 0;
385
386 if (got & (BLOCK_SIZE - 1))
387 printf("Unexpected values in do_check: probably bugs\n");
388 got /= BLOCK_SIZE;
389
390 return got;
391 }
392
393 /* Alarm clock handler - display the status of the quest for bad blocks! Then retrigger the alarm for five senconds
394 later (so we can come here again) */
395
396 static void alarm_intr(int alnum)
397 {
398 (void)alnum;
399
400 if (currently_testing >= blocks)
401 return;
402
403 signal(SIGALRM, alarm_intr);
404 alarm(5);
405 if (!currently_testing)
406 return;
407
408 printf("%lld... ", (unsigned long long)currently_testing);
409 fflush(stdout);
410 }
411
412 static void check_blocks(void)
413 {
414 int try, got;
415 int i;
416 static char blkbuf[BLOCK_SIZE * TEST_BUFFER_BLOCKS];
417
418 if (verbose) {
419 printf("Searching for bad blocks ");
420 fflush(stdout);
421 }
422 currently_testing = 0;
423 if (verbose) {
424 signal(SIGALRM, alarm_intr);
425 alarm(5);
426 }
427 try = TEST_BUFFER_BLOCKS;
428 while (currently_testing < blocks) {
429 if (currently_testing + try > blocks)
430 try = blocks - currently_testing;
431 got = do_check(blkbuf, try, currently_testing);
432 currently_testing += got;
433 if (got == try) {
434 try = TEST_BUFFER_BLOCKS;
435 continue;
436 } else
437 try = 1;
438 if (currently_testing < start_data_block)
439 die("bad blocks before data-area: cannot make fs");
440
441 for (i = 0; i < SECTORS_PER_BLOCK; i++) /* Mark all of the sectors in the block as bad */
442 mark_sector_bad(currently_testing * SECTORS_PER_BLOCK + i);
443 badblocks++;
444 currently_testing++;
445 }
446
447 if (verbose)
448 printf("\n");
449
450 if (badblocks)
451 printf("%d bad block%s\n", badblocks, (badblocks > 1) ? "s" : "");
452 }
453
454 static void get_list_blocks(char *filename)
455 {
456 int i;
457 FILE *listfile;
458 long blockno;
459
460 listfile = fopen(filename, "r");
461 if (listfile == (FILE *) NULL)
462 die("Can't open file of bad blocks");
463
464 while (!feof(listfile)) {
465 fscanf(listfile, "%ld\n", &blockno);
466 for (i = 0; i < SECTORS_PER_BLOCK; i++) /* Mark all of the sectors in the block as bad */
467 mark_sector_bad(blockno * SECTORS_PER_BLOCK + i);
468 badblocks++;
469 }
470 fclose(listfile);
471
472 if (badblocks)
473 printf("%d bad block%s\n", badblocks, (badblocks > 1) ? "s" : "");
474 }
475
476 /* Given a file descriptor and an offset, check whether the offset is a valid offset for the file - return FALSE if it
477 isn't valid or TRUE if it is */
478
479 static int valid_offset(int fd, loff_t offset)
480 {
481 char ch;
482
483 if (llseek(fd, offset, SEEK_SET) < 0)
484 return FALSE;
485 if (read(fd, &ch, 1) < 1)
486 return FALSE;
487 return TRUE;
488 }
489
490 /* Given a filename, look to see how many blocks of BLOCK_SIZE are present, returning the answer */
491
492 static uint64_t count_blocks(char *filename, int *remainder)
493 {
494 loff_t high, low;
495 int fd;
496
497 if ((fd = open(filename, O_RDONLY)) < 0) {
498 perror(filename);
499 exit(1);
500 }
501
502 /* first try SEEK_END, which should work on most devices nowadays */
503 if ((low = llseek(fd, 0, SEEK_END)) <= 0) {
504 low = 0;
505 for (high = 1; valid_offset(fd, high); high *= 2)
506 low = high;
507 while (low < high - 1) {
508 const loff_t mid = (low + high) / 2;
509 if (valid_offset(fd, mid))
510 low = mid;
511 else
512 high = mid;
513 }
514 ++low;
515 }
516
517 close(fd);
518 *remainder = (low % BLOCK_SIZE) / sector_size;
519 return (low / BLOCK_SIZE);
520 }
521
522 /* Check to see if the specified device is currently mounted - abort if it is */
523
524 static void check_mount(char *device_name)
525 {
526 FILE *f;
527 struct mntent *mnt;
528
529 if ((f = setmntent(MOUNTED, "r")) == NULL)
530 return;
531 while ((mnt = getmntent(f)) != NULL)
532 if (strcmp(device_name, mnt->mnt_fsname) == 0)
533 die("%s contains a mounted filesystem.");
534 endmntent(f);
535 }
536
537 /* Establish the geometry and media parameters for the device */
538
539 static void establish_params(int device_num, int size)
540 {
541 long loop_size;
542 struct hd_geometry geometry;
543 struct floppy_struct param;
544 int def_root_dir_entries = 512;
545
546 if ((0 == device_num) || ((device_num & 0xff00) == 0x0200))
547 /* file image or floppy disk */
548 {
549 if (0 == device_num) {
550 param.size = size / 512;
551 switch (param.size) {
552 case 720:
553 param.sect = 9;
554 param.head = 2;
555 break;
556 case 1440:
557 param.sect = 9;
558 param.head = 2;
559 break;
560 case 2400:
561 param.sect = 15;
562 param.head = 2;
563 break;
564 case 2880:
565 param.sect = 18;
566 param.head = 2;
567 break;
568 case 5760:
569 param.sect = 36;
570 param.head = 2;
571 break;
572 default:
573 /* fake values */
574 param.sect = 32;
575 param.head = 64;
576 break;
577 }
578
579 } else { /* is a floppy diskette */
580
581 if (ioctl(dev, FDGETPRM, &param)) /* Can we get the diskette geometry? */
582 die("unable to get diskette geometry for '%s'");
583 }
584 bs.secs_track = htole16(param.sect); /* Set up the geometry information */
585 bs.heads = htole16(param.head);
586 switch (param.size) { /* Set up the media descriptor byte */
587 case 720: /* 5.25", 2, 9, 40 - 360K */
588 bs.media = (char)0xfd;
589 bs.cluster_size = (char)2;
590 def_root_dir_entries = 112;
591 break;
592
593 case 1440: /* 3.5", 2, 9, 80 - 720K */
594 bs.media = (char)0xf9;
595 bs.cluster_size = (char)2;
596 def_root_dir_entries = 112;
597 break;
598
599 case 2400: /* 5.25", 2, 15, 80 - 1200K */
600 bs.media = (char)0xf9;
601 bs.cluster_size = (char)(atari_format ? 2 : 1);
602 def_root_dir_entries = 224;
603 break;
604
605 case 5760: /* 3.5", 2, 36, 80 - 2880K */
606 bs.media = (char)0xf0;
607 bs.cluster_size = (char)2;
608 def_root_dir_entries = 224;
609 break;
610
611 case 2880: /* 3.5", 2, 18, 80 - 1440K */
612 floppy_default:
613 bs.media = (char)0xf0;
614 bs.cluster_size = (char)(atari_format ? 2 : 1);
615 def_root_dir_entries = 224;
616 break;
617
618 default: /* Anything else */
619 if (0 == device_num)
620 goto def_hd_params;
621 else
622 goto floppy_default;
623 }
624 } else if ((device_num & 0xff00) == 0x0700) { /* This is a loop device */
625 if (ioctl(dev, BLKGETSIZE, &loop_size))
626 die("unable to get loop device size");
627
628 switch (loop_size) { /* Assuming the loop device -> floppy later */
629 case 720: /* 5.25", 2, 9, 40 - 360K */
630 bs.secs_track = le16toh(9);
631 bs.heads = le16toh(2);
632 bs.media = (char)0xfd;
633 bs.cluster_size = (char)2;
634 def_root_dir_entries = 112;
635 break;
636
637 case 1440: /* 3.5", 2, 9, 80 - 720K */
638 bs.secs_track = le16toh(9);
639 bs.heads = le16toh(2);
640 bs.media = (char)0xf9;
641 bs.cluster_size = (char)2;
642 def_root_dir_entries = 112;
643 break;
644
645 case 2400: /* 5.25", 2, 15, 80 - 1200K */
646 bs.secs_track = le16toh(15);
647 bs.heads = le16toh(2);
648 bs.media = (char)0xf9;
649 bs.cluster_size = (char)(atari_format ? 2 : 1);
650 def_root_dir_entries = 224;
651 break;
652
653 case 5760: /* 3.5", 2, 36, 80 - 2880K */
654 bs.secs_track = le16toh(36);
655 bs.heads = le16toh(2);
656 bs.media = (char)0xf0;
657 bs.cluster_size = (char)2;
658 bs.dir_entries[0] = (char)224;
659 bs.dir_entries[1] = (char)0;
660 break;
661
662 case 2880: /* 3.5", 2, 18, 80 - 1440K */
663 bs.secs_track = le16toh(18);
664 bs.heads = le16toh(2);
665 bs.media = (char)0xf0;
666 bs.cluster_size = (char)(atari_format ? 2 : 1);
667 def_root_dir_entries = 224;
668 break;
669
670 default: /* Anything else: default hd setup */
671 printf("Loop device does not match a floppy size, using "
672 "default hd params\n");
673 bs.secs_track = htole16(32); /* these are fake values... */
674 bs.heads = htole16(64);
675 goto def_hd_params;
676 }
677 } else
678 /* Must be a hard disk then! */
679 {
680 /* Can we get the drive geometry? (Note I'm not too sure about */
681 /* whether to use HDIO_GETGEO or HDIO_REQ) */
682 if (ioctl(dev, HDIO_GETGEO, &geometry) || geometry.sectors == 0
683 || geometry.heads == 0) {
684 printf("unable to get drive geometry, using default 255/63\n");
685 bs.secs_track = htole16(63);
686 bs.heads = htole16(255);
687 } else {
688 bs.secs_track = htole16(geometry.sectors); /* Set up the geometry information */
689 bs.heads = htole16(geometry.heads);
690 if (!hidden_sectors_by_user)
691 hidden_sectors = htole32(geometry.start);
692 }
693 def_hd_params:
694 bs.media = (char)0xf8; /* Set up the media descriptor for a hard drive */
695 if (!size_fat && blocks * SECTORS_PER_BLOCK > 1064960) {
696 if (verbose)
697 printf("Auto-selecting FAT32 for large filesystem\n");
698 size_fat = 32;
699 }
700 if (size_fat == 32) {
701 /* For FAT32, try to do the same as M$'s format command
702 * (http://technet.microsoft.com/en-us/library/cc938438.aspx):
703 * fs size < 8G: 4k clusters
704 * fs size < 16G: 8k clusters
705 * fs size < 32G: 16k clusters
706 * fs size >= 32G: 32k clusters
707 */
708 uint32_t sz_mb =
709 (blocks + (1 << (20 - BLOCK_SIZE_BITS)) - 1) >> (20 -
710 BLOCK_SIZE_BITS);
711 bs.cluster_size =
712 sz_mb >= 32 * 1024 ? 64 : sz_mb >= 16 * 1024 ? 32 : sz_mb >=
713 8 * 1024 ? 16 : sz_mb > 260 ? 8 : 1;
714 } else {
715 /* FAT12 and FAT16: start at 4 sectors per cluster */
716 bs.cluster_size = (char)4;
717 }
718 }
719
720 if (!root_dir_entries)
721 root_dir_entries = def_root_dir_entries;
722 }
723
724 /*
725 * If alignment is enabled, round the first argument up to the second; the
726 * latter must be a power of two.
727 */
728 static unsigned int align_object(unsigned int sectors, unsigned int clustsize)
729 {
730 if (align_structures)
731 return (sectors + clustsize - 1) & ~(clustsize - 1);
732 else
733 return sectors;
734 }
735
736 /* Create the filesystem data tables */
737
738 static void setup_tables(void)
739 {
740 unsigned num_sectors;
741 unsigned cluster_count = 0, fat_length;
742 struct tm *ctime;
743 struct msdos_volume_info *vi =
744 (size_fat == 32 ? &bs.fat32.vi : &bs.oldfat.vi);
745
746 if (atari_format) {
747 /* On Atari, the first few bytes of the boot sector are assigned
748 * differently: The jump code is only 2 bytes (and m68k machine code
749 * :-), then 6 bytes filler (ignored), then 3 byte serial number. */
750 bs.boot_jump[2] = 'm';
751 memcpy((char *)bs.system_id, "kdosf", strlen("kdosf"));
752 } else
753 memcpy((char *)bs.system_id, "mkfs.fat", strlen("mkfs.fat"));
754 if (sectors_per_cluster)
755 bs.cluster_size = (char)sectors_per_cluster;
756
757 if (fat_media_byte)
758 bs.media = (char) fat_media_byte;
759
760 if (bs.media == 0xf8)
761 vi->drive_number=0x80;
762 else
763 vi->drive_number=0x00;
764
765 if (drive_number_by_user)
766 vi->drive_number= (char) drive_number_option;
767
768 if (size_fat == 32) {
769 /* Under FAT32, the root dir is in a cluster chain, and this is
770 * signalled by bs.dir_entries being 0. */
771 root_dir_entries = 0;
772 }
773
774 if (atari_format) {
775 bs.system_id[5] = (unsigned char)(volume_id & 0x000000ff);
776 bs.system_id[6] = (unsigned char)((volume_id & 0x0000ff00) >> 8);
777 bs.system_id[7] = (unsigned char)((volume_id & 0x00ff0000) >> 16);
778 } else {
779 vi->volume_id[0] = (unsigned char)(volume_id & 0x000000ff);
780 vi->volume_id[1] = (unsigned char)((volume_id & 0x0000ff00) >> 8);
781 vi->volume_id[2] = (unsigned char)((volume_id & 0x00ff0000) >> 16);
782 vi->volume_id[3] = (unsigned char)(volume_id >> 24);
783 }
784
785 if (!atari_format) {
786 memcpy(vi->volume_label, volume_name, 11);
787
788 memcpy(bs.boot_jump, dummy_boot_jump, 3);
789 /* Patch in the correct offset to the boot code */
790 bs.boot_jump[1] = ((size_fat == 32 ?
791 (char *)&bs.fat32.boot_code :
792 (char *)&bs.oldfat.boot_code) - (char *)&bs) - 2;
793
794 if (size_fat == 32) {
795 int offset = (char *)&bs.fat32.boot_code -
796 (char *)&bs + MESSAGE_OFFSET + 0x7c00;
797 if (dummy_boot_code[BOOTCODE_FAT32_SIZE - 1])
798 printf("Warning: message too long; truncated\n");
799 dummy_boot_code[BOOTCODE_FAT32_SIZE - 1] = 0;
800 memcpy(bs.fat32.boot_code, dummy_boot_code, BOOTCODE_FAT32_SIZE);
801 bs.fat32.boot_code[MSG_OFFSET_OFFSET] = offset & 0xff;
802 bs.fat32.boot_code[MSG_OFFSET_OFFSET + 1] = offset >> 8;
803 } else {
804 memcpy(bs.oldfat.boot_code, dummy_boot_code, BOOTCODE_SIZE);
805 }
806 bs.boot_sign = htole16(BOOT_SIGN);
807 } else {
808 memcpy(bs.boot_jump, dummy_boot_jump_m68k, 2);
809 }
810 if (verbose >= 2)
811 printf("Boot jump code is %02x %02x\n",
812 bs.boot_jump[0], bs.boot_jump[1]);
813
814 if (!reserved_sectors)
815 reserved_sectors = (size_fat == 32) ? 32 : 1;
816 else {
817 if (size_fat == 32 && reserved_sectors < 2)
818 die("On FAT32 at least 2 reserved sectors are needed.");
819 }
820 bs.reserved = htole16(reserved_sectors);
821 if (verbose >= 2)
822 printf("Using %d reserved sectors\n", reserved_sectors);
823 bs.fats = (char)nr_fats;
824 if (!atari_format || size_fat == 32)
825 bs.hidden = htole32(hidden_sectors);
826 else {
827 /* In Atari format, hidden is a 16 bit field */
828 __u16 hidden = htole16(hidden_sectors);
829 if (hidden_sectors & ~0xffff)
830 die("#hidden doesn't fit in 16bit field of Atari format\n");
831 memcpy(&bs.hidden, &hidden, 2);
832 }
833
834 num_sectors =
835 (long long)(blocks * BLOCK_SIZE / sector_size) + orphaned_sectors;
836
837 if (!atari_format) {
838 unsigned fatdata1216; /* Sectors for FATs + data area (FAT12/16) */
839 unsigned fatdata32; /* Sectors for FATs + data area (FAT32) */
840 unsigned fatlength12, fatlength16, fatlength32;
841 unsigned maxclust12, maxclust16, maxclust32;
842 unsigned clust12, clust16, clust32;
843 int maxclustsize;
844 unsigned root_dir_sectors = cdiv(root_dir_entries * 32, sector_size);
845
846 /*
847 * If the filesystem is 8192 sectors or less (4 MB with 512-byte
848 * sectors, i.e. floppy size), don't align the data structures.
849 */
850 if (num_sectors <= 8192) {
851 if (align_structures && verbose >= 2)
852 printf("Disabling alignment due to tiny filesystem\n");
853
854 align_structures = FALSE;
855 }
856
857 if (sectors_per_cluster)
858 bs.cluster_size = maxclustsize = sectors_per_cluster;
859 else
860 /* An initial guess for bs.cluster_size should already be set */
861 maxclustsize = 128;
862
863 do {
864 fatdata32 = num_sectors - reserved_sectors;
865 fatdata1216 = fatdata32
866 - align_object(root_dir_sectors, bs.cluster_size);
867
868 if (verbose >= 2)
869 printf("Trying with %d sectors/cluster:\n", bs.cluster_size);
870
871 /* The factor 2 below avoids cut-off errors for nr_fats == 1.
872 * The "nr_fats*3" is for the reserved first two FAT entries */
873 clust12 = 2 * ((long long)fatdata1216 * sector_size + nr_fats * 3) /
874 (2 * (int)bs.cluster_size * sector_size + nr_fats * 3);
875 fatlength12 = cdiv(((clust12 + 2) * 3 + 1) >> 1, sector_size);
876 fatlength12 = align_object(fatlength12, bs.cluster_size);
877 /* Need to recalculate number of clusters, since the unused parts of the
878 * FATS and data area together could make up space for an additional,
879 * not really present cluster. */
880 clust12 = (fatdata1216 - nr_fats * fatlength12) / bs.cluster_size;
881 maxclust12 = (fatlength12 * 2 * sector_size) / 3;
882 if (maxclust12 > MAX_CLUST_12)
883 maxclust12 = MAX_CLUST_12;
884 if (verbose >= 2)
885 printf("FAT12: #clu=%u, fatlen=%u, maxclu=%u, limit=%u\n",
886 clust12, fatlength12, maxclust12, MAX_CLUST_12);
887 if (clust12 > maxclust12 - 2) {
888 clust12 = 0;
889 if (verbose >= 2)
890 printf("FAT12: too much clusters\n");
891 }
892
893 clust16 = ((long long)fatdata1216 * sector_size + nr_fats * 4) /
894 ((int)bs.cluster_size * sector_size + nr_fats * 2);
895 fatlength16 = cdiv((clust16 + 2) * 2, sector_size);
896 fatlength16 = align_object(fatlength16, bs.cluster_size);
897 /* Need to recalculate number of clusters, since the unused parts of the
898 * FATS and data area together could make up space for an additional,
899 * not really present cluster. */
900 clust16 = (fatdata1216 - nr_fats * fatlength16) / bs.cluster_size;
901 maxclust16 = (fatlength16 * sector_size) / 2;
902 if (maxclust16 > MAX_CLUST_16)
903 maxclust16 = MAX_CLUST_16;
904 if (verbose >= 2)
905 printf("FAT16: #clu=%u, fatlen=%u, maxclu=%u, limit=%u\n",
906 clust16, fatlength16, maxclust16, MAX_CLUST_16);
907 if (clust16 > maxclust16 - 2) {
908 if (verbose >= 2)
909 printf("FAT16: too much clusters\n");
910 clust16 = 0;
911 }
912 /* The < 4078 avoids that the filesystem will be misdetected as having a
913 * 12 bit FAT. */
914 if (clust16 < FAT12_THRESHOLD
915 && !(size_fat_by_user && size_fat == 16)) {
916 if (verbose >= 2)
917 printf(clust16 < FAT12_THRESHOLD ?
918 "FAT16: would be misdetected as FAT12\n" :
919 "FAT16: too much clusters\n");
920 clust16 = 0;
921 }
922
923 clust32 = ((long long)fatdata32 * sector_size + nr_fats * 8) /
924 ((int)bs.cluster_size * sector_size + nr_fats * 4);
925 fatlength32 = cdiv((clust32 + 2) * 4, sector_size);
926 /* Need to recalculate number of clusters, since the unused parts of the
927 * FATS and data area together could make up space for an additional,
928 * not really present cluster. */
929 clust32 = (fatdata32 - nr_fats * fatlength32) / bs.cluster_size;
930 maxclust32 = (fatlength32 * sector_size) / 4;
931 if (maxclust32 > MAX_CLUST_32)
932 maxclust32 = MAX_CLUST_32;
933 if (clust32 && clust32 < MIN_CLUST_32
934 && !(size_fat_by_user && size_fat == 32)) {
935 clust32 = 0;
936 if (verbose >= 2)
937 printf("FAT32: not enough clusters (%d)\n", MIN_CLUST_32);
938 }
939 if (verbose >= 2)
940 printf("FAT32: #clu=%u, fatlen=%u, maxclu=%u, limit=%u\n",
941 clust32, fatlength32, maxclust32, MAX_CLUST_32);
942 if (clust32 > maxclust32) {
943 clust32 = 0;
944 if (verbose >= 2)
945 printf("FAT32: too much clusters\n");
946 }
947
948 if ((clust12 && (size_fat == 0 || size_fat == 12)) ||
949 (clust16 && (size_fat == 0 || size_fat == 16)) ||
950 (clust32 && size_fat == 32))
951 break;
952
953 bs.cluster_size <<= 1;
954 } while (bs.cluster_size && bs.cluster_size <= maxclustsize);
955
956 /* Use the optimal FAT size if not specified;
957 * FAT32 is (not yet) choosen automatically */
958 if (!size_fat) {
959 size_fat = (clust16 > clust12) ? 16 : 12;
960 if (verbose >= 2)
961 printf("Choosing %d bits for FAT\n", size_fat);
962 }
963
964 switch (size_fat) {
965 case 12:
966 cluster_count = clust12;
967 fat_length = fatlength12;
968 bs.fat_length = htole16(fatlength12);
969 memcpy(vi->fs_type, MSDOS_FAT12_SIGN, 8);
970 break;
971
972 case 16:
973 if (clust16 < FAT12_THRESHOLD) {
974 if (size_fat_by_user) {
975 fprintf(stderr, "WARNING: Not enough clusters for a "
976 "16 bit FAT! The filesystem will be\n"
977 "misinterpreted as having a 12 bit FAT without "
978 "mount option \"fat=16\".\n");
979 } else {
980 fprintf(stderr, "This filesystem has an unfortunate size. "
981 "A 12 bit FAT cannot provide\n"
982 "enough clusters, but a 16 bit FAT takes up a little "
983 "bit more space so that\n"
984 "the total number of clusters becomes less than the "
985 "threshold value for\n"
986 "distinction between 12 and 16 bit FATs.\n");
987 die("Make the filesystem a bit smaller manually.");
988 }
989 }
990 cluster_count = clust16;
991 fat_length = fatlength16;
992 bs.fat_length = htole16(fatlength16);
993 memcpy(vi->fs_type, MSDOS_FAT16_SIGN, 8);
994 break;
995
996 case 32:
997 if (clust32 < MIN_CLUST_32)
998 fprintf(stderr,
999 "WARNING: Not enough clusters for a 32 bit FAT!\n");
1000 cluster_count = clust32;
1001 fat_length = fatlength32;
1002 bs.fat_length = htole16(0);
1003 bs.fat32.fat32_length = htole32(fatlength32);
1004 memcpy(vi->fs_type, MSDOS_FAT32_SIGN, 8);
1005 root_dir_entries = 0;
1006 break;
1007
1008 default:
1009 die("FAT not 12, 16 or 32 bits");
1010 }
1011
1012 /* Adjust the number of root directory entries to help enforce alignment */
1013 if (align_structures) {
1014 root_dir_entries = align_object(root_dir_sectors, bs.cluster_size)
1015 * (sector_size >> 5);
1016 }
1017 } else {
1018 unsigned clusters, maxclust, fatdata;
1019
1020 /* GEMDOS always uses a 12 bit FAT on floppies, and always a 16 bit FAT on
1021 * hard disks. So use 12 bit if the size of the filesystem suggests that
1022 * this fs is for a floppy disk, if the user hasn't explicitly requested a
1023 * size.
1024 */
1025 if (!size_fat)
1026 size_fat = (num_sectors == 1440 || num_sectors == 2400 ||
1027 num_sectors == 2880 || num_sectors == 5760) ? 12 : 16;
1028 if (verbose >= 2)
1029 printf("Choosing %d bits for FAT\n", size_fat);
1030
1031 /* Atari format: cluster size should be 2, except explicitly requested by
1032 * the user, since GEMDOS doesn't like other cluster sizes very much.
1033 * Instead, tune the sector size for the FS to fit.
1034 */
1035 bs.cluster_size = sectors_per_cluster ? sectors_per_cluster : 2;
1036 if (!sector_size_set) {
1037 while (num_sectors > GEMDOS_MAX_SECTORS) {
1038 num_sectors >>= 1;
1039 sector_size <<= 1;
1040 }
1041 }
1042 if (verbose >= 2)
1043 printf("Sector size must be %d to have less than %d log. sectors\n",
1044 sector_size, GEMDOS_MAX_SECTORS);
1045
1046 /* Check if there are enough FAT indices for how much clusters we have */
1047 do {
1048 fatdata = num_sectors - cdiv(root_dir_entries * 32, sector_size) -
1049 reserved_sectors;
1050 /* The factor 2 below avoids cut-off errors for nr_fats == 1 and
1051 * size_fat == 12
1052 * The "2*nr_fats*size_fat/8" is for the reserved first two FAT entries
1053 */
1054 clusters =
1055 (2 *
1056 ((long long)fatdata * sector_size -
1057 2 * nr_fats * size_fat / 8)) / (2 * ((int)bs.cluster_size *
1058 sector_size +
1059 nr_fats * size_fat / 8));
1060 fat_length = cdiv((clusters + 2) * size_fat / 8, sector_size);
1061 /* Need to recalculate number of clusters, since the unused parts of the
1062 * FATS and data area together could make up space for an additional,
1063 * not really present cluster. */
1064 clusters = (fatdata - nr_fats * fat_length) / bs.cluster_size;
1065 maxclust = (fat_length * sector_size * 8) / size_fat;
1066 if (verbose >= 2)
1067 printf("ss=%d: #clu=%d, fat_len=%d, maxclu=%d\n",
1068 sector_size, clusters, fat_length, maxclust);
1069
1070 /* last 10 cluster numbers are special (except FAT32: 4 high bits rsvd);
1071 * first two numbers are reserved */
1072 if (maxclust <=
1073 (size_fat == 32 ? MAX_CLUST_32 : (1 << size_fat) - 0x10)
1074 && clusters <= maxclust - 2)
1075 break;
1076 if (verbose >= 2)
1077 printf(clusters > maxclust - 2 ?
1078 "Too many clusters\n" : "FAT too big\n");
1079
1080 /* need to increment sector_size once more to */
1081 if (sector_size_set)
1082 die("With this sector size, the maximum number of FAT entries "
1083 "would be exceeded.");
1084 num_sectors >>= 1;
1085 sector_size <<= 1;
1086 } while (sector_size <= GEMDOS_MAX_SECTOR_SIZE);
1087
1088 if (sector_size > GEMDOS_MAX_SECTOR_SIZE)
1089 die("Would need a sector size > 16k, which GEMDOS can't work with");
1090
1091 cluster_count = clusters;
1092 if (size_fat != 32)
1093 bs.fat_length = htole16(fat_length);
1094 else {
1095 bs.fat_length = 0;
1096 bs.fat32.fat32_length = htole32(fat_length);
1097 }
1098 }
1099
1100 bs.sector_size[0] = (char)(sector_size & 0x00ff);
1101 bs.sector_size[1] = (char)((sector_size & 0xff00) >> 8);
1102
1103 bs.dir_entries[0] = (char)(root_dir_entries & 0x00ff);
1104 bs.dir_entries[1] = (char)((root_dir_entries & 0xff00) >> 8);
1105
1106 if (size_fat == 32) {
1107 /* set up additional FAT32 fields */
1108 bs.fat32.flags = htole16(0);
1109 bs.fat32.version[0] = 0;
1110 bs.fat32.version[1] = 0;
1111 bs.fat32.root_cluster = htole32(2);
1112 bs.fat32.info_sector = htole16(1);
1113 if (!backup_boot)
1114 backup_boot = (reserved_sectors >= 7) ? 6 :
1115 (reserved_sectors >= 2) ? reserved_sectors - 1 : 0;
1116 else {
1117 if (backup_boot == 1)
1118 die("Backup boot sector must be after sector 1");
1119 else if (backup_boot >= reserved_sectors)
1120 die("Backup boot sector must be a reserved sector");
1121 }
1122 if (verbose >= 2)
1123 printf("Using sector %d as backup boot sector (0 = none)\n",
1124 backup_boot);
1125 bs.fat32.backup_boot = htole16(backup_boot);
1126 memset(&bs.fat32.reserved2, 0, sizeof(bs.fat32.reserved2));
1127 }
1128
1129 if (atari_format) {
1130 /* Just some consistency checks */
1131 if (num_sectors >= GEMDOS_MAX_SECTORS)
1132 die("GEMDOS can't handle more than 65531 sectors");
1133 else if (num_sectors >= OLDGEMDOS_MAX_SECTORS)
1134 printf("Warning: More than 32765 sector need TOS 1.04 "
1135 "or higher.\n");
1136 }
1137 if (num_sectors >= 65536) {
1138 bs.sectors[0] = (char)0;
1139 bs.sectors[1] = (char)0;
1140 bs.total_sect = htole32(num_sectors);
1141 } else {
1142 bs.sectors[0] = (char)(num_sectors & 0x00ff);
1143 bs.sectors[1] = (char)((num_sectors & 0xff00) >> 8);
1144 if (!atari_format)
1145 bs.total_sect = htole32(0);
1146 }
1147
1148 if (!atari_format)
1149 vi->ext_boot_sign = MSDOS_EXT_SIGN;
1150
1151 if (!cluster_count) {
1152 if (sectors_per_cluster) /* If yes, die if we'd spec'd sectors per cluster */
1153 die("Too many clusters for filesystem - try more sectors per cluster");
1154 else
1155 die("Attempting to create a too large filesystem");
1156 }
1157
1158 /* The two following vars are in hard sectors, i.e. 512 byte sectors! */
1159 start_data_sector = (reserved_sectors + nr_fats * fat_length) *
1160 (sector_size / HARD_SECTOR_SIZE);
1161 start_data_block = (start_data_sector + SECTORS_PER_BLOCK - 1) /
1162 SECTORS_PER_BLOCK;
1163
1164 if (blocks < start_data_block + 32) /* Arbitrary undersize filesystem! */
1165 die("Too few blocks for viable filesystem");
1166
1167 if (verbose) {
1168 printf("%s has %d head%s and %d sector%s per track,\n",
1169 device_name, le16toh(bs.heads),
1170 (le16toh(bs.heads) != 1) ? "s" : "", le16toh(bs.secs_track),
1171 (le16toh(bs.secs_track) != 1) ? "s" : "");
1172 printf("hidden sectors 0x%04x;\n", hidden_sectors);
1173 printf("logical sector size is %d,\n", sector_size);
1174 printf("using 0x%02x media descriptor, with %d sectors;\n",
1175 (int)(bs.media), num_sectors);
1176 printf("drive number 0x%02x;\n", (int) (vi->drive_number));
1177 printf("filesystem has %d %d-bit FAT%s and %d sector%s per cluster.\n",
1178 (int)(bs.fats), size_fat, (bs.fats != 1) ? "s" : "",
1179 (int)(bs.cluster_size), (bs.cluster_size != 1) ? "s" : "");
1180 printf("FAT size is %d sector%s, and provides %d cluster%s.\n",
1181 fat_length, (fat_length != 1) ? "s" : "",
1182 cluster_count, (cluster_count != 1) ? "s" : "");
1183 printf("There %s %u reserved sector%s.\n",
1184 (reserved_sectors != 1) ? "are" : "is",
1185 reserved_sectors, (reserved_sectors != 1) ? "s" : "");
1186
1187 if (size_fat != 32) {
1188 unsigned root_dir_entries =
1189 bs.dir_entries[0] + ((bs.dir_entries[1]) * 256);
1190 unsigned root_dir_sectors =
1191 cdiv(root_dir_entries * 32, sector_size);
1192 printf("Root directory contains %u slots and uses %u sectors.\n",
1193 root_dir_entries, root_dir_sectors);
1194 }
1195 printf("Volume ID is %08lx, ", volume_id &
1196 (atari_format ? 0x00ffffff : 0xffffffff));
1197 if (strcmp(volume_name, NO_NAME))
1198 printf("volume label %s.\n", volume_name);
1199 else
1200 printf("no volume label.\n");
1201 }
1202
1203 /* Make the file allocation tables! */
1204
1205 if (malloc_entire_fat)
1206 alloced_fat_length = fat_length;
1207 else
1208 alloced_fat_length = 1;
1209
1210 if ((fat =
1211 (unsigned char *)malloc(alloced_fat_length * sector_size)) == NULL)
1212 die("unable to allocate space for FAT image in memory");
1213
1214 memset(fat, 0, alloced_fat_length * sector_size);
1215
1216 mark_FAT_cluster(0, 0xffffffff); /* Initial fat entries */
1217 mark_FAT_cluster(1, 0xffffffff);
1218 fat[0] = (unsigned char)bs.media; /* Put media type in first byte! */
1219 if (size_fat == 32) {
1220 /* Mark cluster 2 as EOF (used for root dir) */
1221 mark_FAT_cluster(2, FAT_EOF);
1222 }
1223
1224 /* Make the root directory entries */
1225
1226 size_root_dir = (size_fat == 32) ?
1227 bs.cluster_size * sector_size :
1228 (((int)bs.dir_entries[1] * 256 + (int)bs.dir_entries[0]) *
1229 sizeof(struct msdos_dir_entry));
1230 if ((root_dir = (struct msdos_dir_entry *)malloc(size_root_dir)) == NULL) {
1231 free(fat); /* Tidy up before we die! */
1232 die("unable to allocate space for root directory in memory");
1233 }
1234
1235 memset(root_dir, 0, size_root_dir);
1236 if (memcmp(volume_name, NO_NAME, 11)) {
1237 struct msdos_dir_entry *de = &root_dir[0];
1238 memcpy(de->name, volume_name, 8);
1239 memcpy(de->ext, volume_name + 8, 3);
1240 de->attr = ATTR_VOLUME;
1241 ctime = localtime(&create_time);
1242 de->time = htole16((unsigned short)((ctime->tm_sec >> 1) +
1243 (ctime->tm_min << 5) +
1244 (ctime->tm_hour << 11)));
1245 de->date =
1246 htole16((unsigned short)(ctime->tm_mday +
1247 ((ctime->tm_mon + 1) << 5) +
1248 ((ctime->tm_year - 80) << 9)));
1249 de->ctime_ms = 0;
1250 de->ctime = de->time;
1251 de->cdate = de->date;
1252 de->adate = de->date;
1253 de->starthi = htole16(0);
1254 de->start = htole16(0);
1255 de->size = htole32(0);
1256 }
1257
1258 if (size_fat == 32) {
1259 /* For FAT32, create an info sector */
1260 struct fat32_fsinfo *info;
1261
1262 if (!(info_sector = malloc(sector_size)))
1263 die("Out of memory");
1264 memset(info_sector, 0, sector_size);
1265 /* fsinfo structure is at offset 0x1e0 in info sector by observation */
1266 info = (struct fat32_fsinfo *)(info_sector + 0x1e0);
1267
1268 /* Info sector magic */
1269 info_sector[0] = 'R';
1270 info_sector[1] = 'R';
1271 info_sector[2] = 'a';
1272 info_sector[3] = 'A';
1273
1274 /* Magic for fsinfo structure */
1275 info->signature = htole32(0x61417272);
1276 /* We've allocated cluster 2 for the root dir. */
1277 info->free_clusters = htole32(cluster_count - 1);
1278 info->next_cluster = htole32(2);
1279
1280 /* Info sector also must have boot sign */
1281 *(__u16 *) (info_sector + 0x1fe) = htole16(BOOT_SIGN);
1282 }
1283
1284 if (!(blank_sector = malloc(sector_size)))
1285 die("Out of memory");
1286 memset(blank_sector, 0, sector_size);
1287 }
1288
1289 /* Write the new filesystem's data tables to wherever they're going to end up! */
1290
1291 #define error(str) \
1292 do { \
1293 free (fat); \
1294 if (info_sector) free (info_sector); \
1295 free (root_dir); \
1296 die (str); \
1297 } while(0)
1298
1299 #define seekto(pos,errstr) \
1300 do { \
1301 loff_t __pos = (pos); \
1302 if (llseek (dev, __pos, SEEK_SET) != __pos) \
1303 error ("seek to " errstr " failed whilst writing tables"); \
1304 } while(0)
1305
1306 #define writebuf(buf,size,errstr) \
1307 do { \
1308 int __size = (size); \
1309 if (write (dev, buf, __size) != __size) \
1310 error ("failed whilst writing " errstr); \
1311 } while(0)
1312
1313 static void write_tables(void)
1314 {
1315 int x;
1316 int fat_length;
1317
1318 fat_length = (size_fat == 32) ?
1319 le32toh(bs.fat32.fat32_length) : le16toh(bs.fat_length);
1320
1321 seekto(0, "start of device");
1322 /* clear all reserved sectors */
1323 for (x = 0; x < reserved_sectors; ++x)
1324 writebuf(blank_sector, sector_size, "reserved sector");
1325 /* seek back to sector 0 and write the boot sector */
1326 seekto(0, "boot sector");
1327 writebuf((char *)&bs, sizeof(struct msdos_boot_sector), "boot sector");
1328 /* on FAT32, write the info sector and backup boot sector */
1329 if (size_fat == 32) {
1330 seekto(le16toh(bs.fat32.info_sector) * sector_size, "info sector");
1331 writebuf(info_sector, 512, "info sector");
1332 if (backup_boot != 0) {
1333 seekto(backup_boot * sector_size, "backup boot sector");
1334 writebuf((char *)&bs, sizeof(struct msdos_boot_sector),
1335 "backup boot sector");
1336 }
1337 }
1338 /* seek to start of FATS and write them all */
1339 seekto(reserved_sectors * sector_size, "first FAT");
1340 for (x = 1; x <= nr_fats; x++) {
1341 int y;
1342 int blank_fat_length = fat_length - alloced_fat_length;
1343 writebuf(fat, alloced_fat_length * sector_size, "FAT");
1344 for (y = 0; y < blank_fat_length; y++)
1345 writebuf(blank_sector, sector_size, "FAT");
1346 }
1347 /* Write the root directory directly after the last FAT. This is the root
1348 * dir area on FAT12/16, and the first cluster on FAT32. */
1349 writebuf((char *)root_dir, size_root_dir, "root directory");
1350
1351 if (blank_sector)
1352 free(blank_sector);
1353 if (info_sector)
1354 free(info_sector);
1355 free(root_dir); /* Free up the root directory space from setup_tables */
1356 free(fat); /* Free up the fat table space reserved during setup_tables */
1357 }
1358
1359 /* Report the command usage and return a failure error code */
1360
1361 static void usage(void)
1362 {
1363 fatal_error("\
1364 Usage: mkfs.fat [-a][-A][-c][-C][-v][-I][-l bad-block-file][-b backup-boot-sector]\n\
1365 [-m boot-msg-file][-n volume-name][-i volume-id]\n\
1366 [-s sectors-per-cluster][-S logical-sector-size][-f number-of-FATs]\n\
1367 [-h hidden-sectors][-F fat-size][-r root-dir-entries][-R reserved-sectors]\n\
1368 [-M FAT-media-byte][-D drive_number]\n\
1369 /dev/name [blocks]\n");
1370 }
1371
1372 /*
1373 * ++roman: On m68k, check if this is an Atari; if yes, turn on Atari variant
1374 * of MS-DOS filesystem by default.
1375 */
1376 static void check_atari(void)
1377 {
1378 #ifdef __mc68000__
1379 FILE *f;
1380 char line[128], *p;
1381
1382 if (!(f = fopen("/proc/hardware", "r"))) {
1383 perror("/proc/hardware");
1384 return;
1385 }
1386
1387 while (fgets(line, sizeof(line), f)) {
1388 if (strncmp(line, "Model:", 6) == 0) {
1389 p = line + 6;
1390 p += strspn(p, " \t");
1391 if (strncmp(p, "Atari ", 6) == 0)
1392 atari_format = 1;
1393 break;
1394 }
1395 }
1396 fclose(f);
1397 #endif
1398 }
1399
1400 /* The "main" entry point into the utility - we pick up the options and attempt to process them in some sort of sensible
1401 way. In the event that some/all of the options are invalid we need to tell the user so that something can be done! */
1402
1403 int main(int argc, char **argv)
1404 {
1405 int c;
1406 char *tmp;
1407 char *listfile = NULL;
1408 FILE *msgfile;
1409 struct stat statbuf;
1410 int i = 0, pos, ch;
1411 int create = 0;
1412 uint64_t cblocks = 0;
1413 int min_sector_size;
1414
1415 if (argc && *argv) { /* What's the program name? */
1416 char *p;
1417 program_name = *argv;
1418 if ((p = strrchr(program_name, '/')))
1419 program_name = p + 1;
1420 }
1421
1422 gettimeofday(&create_timeval, NULL);
1423 create_time = create_timeval.tv_sec;
1424 volume_id = (u_int32_t) ((create_timeval.tv_sec << 20) | create_timeval.tv_usec); /* Default volume ID = creation time, fudged for more uniqueness */
1425 check_atari();
1426
1427 printf("mkfs.fat " VERSION " (" VERSION_DATE ")\n");
1428
1429 while ((c = getopt(argc, argv, "aAb:cCf:D:F:Ii:l:m:M:n:r:R:s:S:h:v")) != EOF)
1430 /* Scan the command line for options */
1431 switch (c) {
1432 case 'A': /* toggle Atari format */
1433 atari_format = !atari_format;
1434 break;
1435
1436 case 'a': /* a : skip alignment */
1437 align_structures = FALSE;
1438 break;
1439
1440 case 'b': /* b : location of backup boot sector */
1441 backup_boot = (int)strtol(optarg, &tmp, 0);
1442 if (*tmp || backup_boot < 2 || backup_boot > 0xffff) {
1443 printf("Bad location for backup boot sector : %s\n", optarg);
1444 usage();
1445 }
1446 break;
1447
1448 case 'c': /* c : Check FS as we build it */
1449 check = TRUE;
1450 malloc_entire_fat = TRUE; /* Need to be able to mark clusters bad */
1451 break;
1452
1453 case 'C': /* C : Create a new file */
1454 create = TRUE;
1455 break;
1456
1457 case 'D': /* D : Choose Drive Number */
1458 drive_number_option = (int) strtol (optarg, &tmp, 0);
1459 if (*tmp || (drive_number_option != 0 && drive_number_option != 0x80)) {
1460 printf ("Drive number must be 0 or 0x80: %s\n", optarg);
1461 usage ();
1462 }
1463 drive_number_by_user=1;
1464 break;
1465
1466 case 'f': /* f : Choose number of FATs */
1467 nr_fats = (int)strtol(optarg, &tmp, 0);
1468 if (*tmp || nr_fats < 1 || nr_fats > 4) {
1469 printf("Bad number of FATs : %s\n", optarg);
1470 usage();
1471 }
1472 break;
1473
1474 case 'F': /* F : Choose FAT size */
1475 size_fat = (int)strtol(optarg, &tmp, 0);
1476 if (*tmp || (size_fat != 12 && size_fat != 16 && size_fat != 32)) {
1477 printf("Bad FAT type : %s\n", optarg);
1478 usage();
1479 }
1480 size_fat_by_user = 1;
1481 break;
1482
1483 case 'h': /* h : number of hidden sectors */
1484 hidden_sectors = (int)strtol(optarg, &tmp, 0);
1485 if (*tmp || hidden_sectors < 0) {
1486 printf("Bad number of hidden sectors : %s\n", optarg);
1487 usage();
1488 }
1489 hidden_sectors_by_user = 1;
1490 break;
1491
1492 case 'I':
1493 ignore_full_disk = 1;
1494 break;
1495
1496 case 'i': /* i : specify volume ID */
1497 volume_id = strtoul(optarg, &tmp, 16);
1498 if (*tmp) {
1499 printf("Volume ID must be a hexadecimal number\n");
1500 usage();
1501 }
1502 break;
1503
1504 case 'l': /* l : Bad block filename */
1505 listfile = optarg;
1506 malloc_entire_fat = TRUE; /* Need to be able to mark clusters bad */
1507 break;
1508
1509 case 'm': /* m : Set boot message */
1510 if (strcmp(optarg, "-")) {
1511 msgfile = fopen(optarg, "r");
1512 if (!msgfile)
1513 perror(optarg);
1514 } else
1515 msgfile = stdin;
1516
1517 if (msgfile) {
1518 /* The boot code ends at offset 448 and needs a null terminator */
1519 i = MESSAGE_OFFSET;
1520 pos = 0; /* We are at beginning of line */
1521 do {
1522 ch = getc(msgfile);
1523 switch (ch) {
1524 case '\r': /* Ignore CRs */
1525 case '\0': /* and nulls */
1526 break;
1527
1528 case '\n': /* LF -> CR+LF if necessary */
1529 if (pos) { /* If not at beginning of line */
1530 dummy_boot_code[i++] = '\r';
1531 pos = 0;
1532 }
1533 dummy_boot_code[i++] = '\n';
1534 break;
1535
1536 case '\t': /* Expand tabs */
1537 do {
1538 dummy_boot_code[i++] = ' ';
1539 pos++;
1540 }
1541 while (pos % 8 && i < BOOTCODE_SIZE - 1);
1542 break;
1543
1544 case EOF:
1545 dummy_boot_code[i++] = '\0'; /* Null terminator */
1546 break;
1547
1548 default:
1549 dummy_boot_code[i++] = ch; /* Store character */
1550 pos++; /* Advance position */
1551 break;
1552 }
1553 }
1554 while (ch != EOF && i < BOOTCODE_SIZE - 1);
1555
1556 /* Fill up with zeros */
1557 while (i < BOOTCODE_SIZE - 1)
1558 dummy_boot_code[i++] = '\0';
1559 dummy_boot_code[BOOTCODE_SIZE - 1] = '\0'; /* Just in case */
1560
1561 if (ch != EOF)
1562 printf("Warning: message too long; truncated\n");
1563
1564 if (msgfile != stdin)
1565 fclose(msgfile);
1566 }
1567 break;
1568
1569 case 'M': /* M : FAT Media byte */
1570 fat_media_byte = (int) strtol (optarg, &tmp, 0);
1571 if (*tmp || fat_media_byte < 248 || fat_media_byte > 255) {
1572 printf ("FAT Media byte must be between 0xF8 and 0xFF : %s\n", optarg);
1573 usage ();
1574 }
1575 break;
1576
1577 case 'n': /* n : Volume name */
1578 sprintf(volume_name, "%-11.11s", optarg);
1579 for (i = 0; volume_name[i] && i < 11; i++)
1580 /* don't know if here should be more strict !uppercase(label[i]) */
1581 if (islower(volume_name[i])) {
1582 fprintf(stderr,
1583 "mkfs.fat: warning - lowercase labels might not work properly with DOS or Windows\n");
1584 break;
1585 }
1586
1587 break;
1588
1589 case 'r': /* r : Root directory entries */
1590 root_dir_entries = (int)strtol(optarg, &tmp, 0);
1591 if (*tmp || root_dir_entries < 16 || root_dir_entries > 32768) {
1592 printf("Bad number of root directory entries : %s\n", optarg);
1593 usage();
1594 }
1595 break;
1596
1597 case 'R': /* R : number of reserved sectors */
1598 reserved_sectors = (int)strtol(optarg, &tmp, 0);
1599 if (*tmp || reserved_sectors < 1 || reserved_sectors > 0xffff) {
1600 printf("Bad number of reserved sectors : %s\n", optarg);
1601 usage();
1602 }
1603 break;
1604
1605 case 's': /* s : Sectors per cluster */
1606 sectors_per_cluster = (int)strtol(optarg, &tmp, 0);
1607 if (*tmp || (sectors_per_cluster != 1 && sectors_per_cluster != 2
1608 && sectors_per_cluster != 4 && sectors_per_cluster != 8
1609 && sectors_per_cluster != 16
1610 && sectors_per_cluster != 32
1611 && sectors_per_cluster != 64
1612 && sectors_per_cluster != 128)) {
1613 printf("Bad number of sectors per cluster : %s\n", optarg);
1614 usage();
1615 }
1616 break;
1617
1618 case 'S': /* S : Sector size */
1619 sector_size = (int)strtol(optarg, &tmp, 0);
1620 if (*tmp || (sector_size != 512 && sector_size != 1024 &&
1621 sector_size != 2048 && sector_size != 4096 &&
1622 sector_size != 8192 && sector_size != 16384 &&
1623 sector_size != 32768)) {
1624 printf("Bad logical sector size : %s\n", optarg);
1625 usage();
1626 }
1627 sector_size_set = 1;
1628 break;
1629
1630 case 'v': /* v : Verbose execution */
1631 ++verbose;
1632 break;
1633
1634 default:
1635 printf("Unknown option: %c\n", c);
1636 usage();
1637 }
1638 if (optind < argc) {
1639 device_name = argv[optind]; /* Determine the number of blocks in the FS */
1640
1641 if (!device_name) {
1642 printf("No device specified.\n");
1643 usage();
1644 }
1645
1646 if (!create)
1647 cblocks = count_blocks(device_name, &orphaned_sectors); /* Have a look and see! */
1648 }
1649 if (optind == argc - 2) { /* Either check the user specified number */
1650 blocks = strtoull(argv[optind + 1], &tmp, 0);
1651 if (!create && blocks != cblocks) {
1652 fprintf(stderr, "Warning: block count mismatch: ");
1653 fprintf(stderr, "found %llu but assuming %llu.\n", (unsigned long long)cblocks, (unsigned long long)blocks);
1654 }
1655 } else if (optind == argc - 1) { /* Or use value found */
1656 if (create)
1657 die("Need intended size with -C.");
1658 blocks = cblocks;
1659 tmp = "";
1660 } else {
1661 fprintf(stderr, "No device specified!\n");
1662 usage();
1663 }
1664 if (*tmp) {
1665 printf("Bad block count : %s\n", argv[optind + 1]);
1666 usage();
1667 }
1668
1669 if (check && listfile) /* Auto and specified bad block handling are mutually */
1670 die("-c and -l are incompatible"); /* exclusive of each other! */
1671
1672 if (!create) {
1673 check_mount(device_name); /* Is the device already mounted? */
1674 dev = open(device_name, O_EXCL | O_RDWR); /* Is it a suitable device to build the FS on? */
1675 if (dev < 0) {
1676 fprintf(stderr, "%s: unable to open %s: %s\n", program_name,
1677 device_name, strerror(errno));
1678 exit(1); /* The error exit code is 1! */
1679 }
1680 } else {
1681 loff_t offset = blocks * BLOCK_SIZE - 1;
1682 char null = 0;
1683 /* create the file */
1684 dev = open(device_name, O_EXCL | O_RDWR | O_CREAT | O_TRUNC, 0666);
1685 if (dev < 0)
1686 die("unable to create %s");
1687 /* seek to the intended end-1, and write one byte. this creates a
1688 * sparse-as-possible file of appropriate size. */
1689 if (llseek(dev, offset, SEEK_SET) != offset)
1690 die("seek failed");
1691 if (write(dev, &null, 1) < 0)
1692 die("write failed");
1693 if (llseek(dev, 0, SEEK_SET) != 0)
1694 die("seek failed");
1695 }
1696
1697 if (fstat(dev, &statbuf) < 0)
1698 die("unable to stat %s");
1699 if (!S_ISBLK(statbuf.st_mode)) {
1700 statbuf.st_rdev = 0;
1701 check = 0;
1702 } else
1703 /*
1704 * Ignore any 'full' fixed disk devices, if -I is not given.
1705 * On a MO-disk one doesn't need partitions. The filesytem can go
1706 * directly to the whole disk. Under other OSes this is known as
1707 * the 'superfloppy' format. As I don't know how to find out if
1708 * this is a MO disk I introduce a -I (ignore) switch. -Joey
1709 */
1710 if (!ignore_full_disk && ((statbuf.st_rdev & 0xffffff3f) == 0x0300 || /* hda, hdb */
1711 (statbuf.st_rdev & 0xffffff0f) == 0x0800 || /* sd */
1712 (statbuf.st_rdev & 0xffffff3f) == 0x0d00 || /* xd */
1713 (statbuf.st_rdev & 0xffffff3f) == 0x1600) /* hdc, hdd */
1714 )
1715 die("Device partition expected, not making filesystem on entire device '%s' (use -I to override)");
1716
1717 if (sector_size_set) {
1718 if (ioctl(dev, BLKSSZGET, &min_sector_size) >= 0)
1719 if (sector_size < min_sector_size) {
1720 sector_size = min_sector_size;
1721 fprintf(stderr,
1722 "Warning: sector size was set to %d (minimal for this device)\n",
1723 sector_size);
1724 }
1725 } else {
1726 if (ioctl(dev, BLKSSZGET, &min_sector_size) >= 0) {
1727 sector_size = min_sector_size;
1728 sector_size_set = 1;
1729 }
1730 }
1731
1732 if (sector_size > 4096)
1733 fprintf(stderr,
1734 "Warning: sector size is set to %d > 4096, such filesystem will not propably mount\n",
1735 sector_size);
1736
1737 establish_params(statbuf.st_rdev, statbuf.st_size);
1738 /* Establish the media parameters */
1739
1740 setup_tables(); /* Establish the filesystem tables */
1741
1742 if (check) /* Determine any bad block locations and mark them */
1743 check_blocks();
1744 else if (listfile)
1745 get_list_blocks(listfile);
1746
1747 write_tables(); /* Write the filesystem tables away! */
1748
1749 exit(0); /* Terminate with no errors! */
1750 }
0 /* version.h
1
2 Copyright (C) 1998-2005 Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de>
3 Copyright (C) 2008-2014 Daniel Baumann <mail@daniel-baumann.ch>
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 The complete text of the GNU General Public License
19 can be found in /usr/share/common-licenses/GPL-3 file.
20 */
21
22 #ifndef _version_h
23 #define _version_h
24
25 #define VERSION "3.0.26"
26 #define VERSION_DATE "2014-03-07"
27
28 #endif