summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjk7744.park <jk7744.park@samsung.com>2015-09-08 21:50:04 +0900
committerjk7744.park <jk7744.park@samsung.com>2015-09-08 21:50:04 +0900
commitbae3b8c863967c8bfc437bfacc1df110300f6b92 (patch)
tree6deee8437036a123e49d02b0e5aaa9561130aed4
parent3961104593f79a24617eb6f08e0c62b455667df8 (diff)
downloaddosfstools-accepted/tizen_2.4_mobile.tar.gz
dosfstools-accepted/tizen_2.4_mobile.tar.bz2
dosfstools-accepted/tizen_2.4_mobile.zip
-rw-r--r--CHANGES (renamed from doc/ChangeLog.dosfstools-2.x)0
-rw-r--r--COPYING674
-rw-r--r--ChangeLog666
-rw-r--r--Makefile192
-rw-r--r--README.Atari (renamed from doc/README.dosfstools-2.x)0
-rw-r--r--TODO (renamed from doc/TODO.dosfstools-2.x)1
-rw-r--r--build0
-rw-r--r--dosfsck/.cvsignore1
-rw-r--r--dosfsck/CHANGES (renamed from doc/ChangeLog.dosfsck)0
-rw-r--r--dosfsck/COPYING345
-rw-r--r--dosfsck/Makefile44
-rw-r--r--dosfsck/README (renamed from doc/README.dosfsck)0
-rw-r--r--dosfsck/boot.c (renamed from src/boot.c)190
-rw-r--r--dosfsck/boot.h13
-rw-r--r--dosfsck/check.c (renamed from src/check.c)224
-rw-r--r--dosfsck/check.h23
-rw-r--r--dosfsck/common.c (renamed from src/common.c)26
-rw-r--r--dosfsck/common.h (renamed from src/common.h)27
-rw-r--r--dosfsck/dosfsck.8143
-rw-r--r--dosfsck/dosfsck.c (renamed from src/dosfsck.c)53
-rw-r--r--dosfsck/dosfsck.h (renamed from src/dosfsck.h)88
-rw-r--r--dosfsck/fat.c361
-rw-r--r--dosfsck/fat.h (renamed from src/fat.h)25
-rw-r--r--dosfsck/file.c (renamed from src/file.c)41
-rw-r--r--dosfsck/file.h (renamed from src/file.h)21
-rw-r--r--dosfsck/io.c (renamed from src/io.c)53
-rw-r--r--dosfsck/io.h (renamed from src/io.h)28
-rw-r--r--dosfsck/lfn.c (renamed from src/lfn.c)176
-rw-r--r--dosfsck/lfn.h20
-rw-r--r--man/dosfsck.8112
-rw-r--r--man/dosfslabel.829
-rw-r--r--mkdosfs/.cvsignore1
-rw-r--r--mkdosfs/ANNOUNCE (renamed from doc/ANNOUNCE.mkdosfs)0
-rw-r--r--mkdosfs/COPYING347
-rw-r--r--mkdosfs/ChangeLog (renamed from doc/ChangeLog.mkdosfs)2
-rw-r--r--mkdosfs/Makefile31
-rw-r--r--mkdosfs/README (renamed from doc/README.mkdosfs)0
-rw-r--r--mkdosfs/mkdosfs-ygg-0.3b.lsm19
-rw-r--r--mkdosfs/mkdosfs.8 (renamed from man/mkdosfs.8)58
-rw-r--r--mkdosfs/mkdosfs.c (renamed from src/mkdosfs.c)373
-rw-r--r--packaging/dosfstools-2.11-buffer.patch11
-rw-r--r--packaging/dosfstools-2.11-linuxfs.patch10
-rw-r--r--packaging/dosfstools-2.11-mkdosfs-geo0.diff35
-rw-r--r--packaging/dosfstools-2.11-o_excl.patch20
-rw-r--r--packaging/dosfstools-2.11-unaligned.patch145
-rw-r--r--packaging/dosfstools-2.11-unsupported-sector-size.patch14
-rw-r--r--packaging/dosfstools-2.11_determine-sector-size.patch35
-rw-r--r--packaging/dosfstools.changes299
-rw-r--r--packaging/dosfstools.manifest11
-rw-r--r--packaging/dosfstools.spec88
-rw-r--r--src/boot.h31
-rw-r--r--src/check.h40
-rw-r--r--src/dosfslabel.c127
-rw-r--r--src/fat.c558
-rw-r--r--src/lfn.h38
-rw-r--r--src/version.h28
-rw-r--r--version.h8
57 files changed, 2380 insertions, 3525 deletions
diff --git a/doc/ChangeLog.dosfstools-2.x b/CHANGES
index 7ed9efe..7ed9efe 100644
--- a/doc/ChangeLog.dosfstools-2.x
+++ b/CHANGES
diff --git a/COPYING b/COPYING
deleted file mode 100644
index 94a9ed0..0000000
--- a/COPYING
+++ /dev/null
@@ -1,674 +0,0 @@
- GNU GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The GNU General Public License is a free, copyleft license for
-software and other kinds of works.
-
- The licenses for most software and other practical works are designed
-to take away your freedom to share and change the works. By contrast,
-the GNU General Public License is intended to guarantee your freedom to
-share and change all versions of a program--to make sure it remains free
-software for all its users. We, the Free Software Foundation, use the
-GNU General Public License for most of our software; it applies also to
-any other work released this way by its authors. You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-them if you wish), that you receive source code or can get it if you
-want it, that you can change the software or use pieces of it in new
-free programs, and that you know you can do these things.
-
- To protect your rights, we need to prevent others from denying you
-these rights or asking you to surrender the rights. Therefore, you have
-certain responsibilities if you distribute copies of the software, or if
-you modify it: responsibilities to respect the freedom of others.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must pass on to the recipients the same
-freedoms that you received. You must make sure that they, too, receive
-or can get the source code. And you must show them these terms so they
-know their rights.
-
- Developers that use the GNU GPL protect your rights with two steps:
-(1) assert copyright on the software, and (2) offer you this License
-giving you legal permission to copy, distribute and/or modify it.
-
- For the developers' and authors' protection, the GPL clearly explains
-that there is no warranty for this free software. For both users' and
-authors' sake, the GPL requires that modified versions be marked as
-changed, so that their problems will not be attributed erroneously to
-authors of previous versions.
-
- Some devices are designed to deny users access to install or run
-modified versions of the software inside them, although the manufacturer
-can do so. This is fundamentally incompatible with the aim of
-protecting users' freedom to change the software. The systematic
-pattern of such abuse occurs in the area of products for individuals to
-use, which is precisely where it is most unacceptable. Therefore, we
-have designed this version of the GPL to prohibit the practice for those
-products. If such problems arise substantially in other domains, we
-stand ready to extend this provision to those domains in future versions
-of the GPL, as needed to protect the freedom of users.
-
- Finally, every program is threatened constantly by software patents.
-States should not allow patents to restrict development and use of
-software on general-purpose computers, but in those that do, we wish to
-avoid the special danger that patents applied to a free program could
-make it effectively proprietary. To prevent this, the GPL assures that
-patents cannot be used to render the program non-free.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- TERMS AND CONDITIONS
-
- 0. Definitions.
-
- "This License" refers to version 3 of the GNU General Public License.
-
- "Copyright" also means copyright-like laws that apply to other kinds of
-works, such as semiconductor masks.
-
- "The Program" refers to any copyrightable work licensed under this
-License. Each licensee is addressed as "you". "Licensees" and
-"recipients" may be individuals or organizations.
-
- To "modify" a work means to copy from or adapt all or part of the work
-in a fashion requiring copyright permission, other than the making of an
-exact copy. The resulting work is called a "modified version" of the
-earlier work or a work "based on" the earlier work.
-
- A "covered work" means either the unmodified Program or a work based
-on the Program.
-
- To "propagate" a work means to do anything with it that, without
-permission, would make you directly or secondarily liable for
-infringement under applicable copyright law, except executing it on a
-computer or modifying a private copy. Propagation includes copying,
-distribution (with or without modification), making available to the
-public, and in some countries other activities as well.
-
- To "convey" a work means any kind of propagation that enables other
-parties to make or receive copies. Mere interaction with a user through
-a computer network, with no transfer of a copy, is not conveying.
-
- An interactive user interface displays "Appropriate Legal Notices"
-to the extent that it includes a convenient and prominently visible
-feature that (1) displays an appropriate copyright notice, and (2)
-tells the user that there is no warranty for the work (except to the
-extent that warranties are provided), that licensees may convey the
-work under this License, and how to view a copy of this License. If
-the interface presents a list of user commands or options, such as a
-menu, a prominent item in the list meets this criterion.
-
- 1. Source Code.
-
- The "source code" for a work means the preferred form of the work
-for making modifications to it. "Object code" means any non-source
-form of a work.
-
- A "Standard Interface" means an interface that either is an official
-standard defined by a recognized standards body, or, in the case of
-interfaces specified for a particular programming language, one that
-is widely used among developers working in that language.
-
- The "System Libraries" of an executable work include anything, other
-than the work as a whole, that (a) is included in the normal form of
-packaging a Major Component, but which is not part of that Major
-Component, and (b) serves only to enable use of the work with that
-Major Component, or to implement a Standard Interface for which an
-implementation is available to the public in source code form. A
-"Major Component", in this context, means a major essential component
-(kernel, window system, and so on) of the specific operating system
-(if any) on which the executable work runs, or a compiler used to
-produce the work, or an object code interpreter used to run it.
-
- The "Corresponding Source" for a work in object code form means all
-the source code needed to generate, install, and (for an executable
-work) run the object code and to modify the work, including scripts to
-control those activities. However, it does not include the work's
-System Libraries, or general-purpose tools or generally available free
-programs which are used unmodified in performing those activities but
-which are not part of the work. For example, Corresponding Source
-includes interface definition files associated with source files for
-the work, and the source code for shared libraries and dynamically
-linked subprograms that the work is specifically designed to require,
-such as by intimate data communication or control flow between those
-subprograms and other parts of the work.
-
- The Corresponding Source need not include anything that users
-can regenerate automatically from other parts of the Corresponding
-Source.
-
- The Corresponding Source for a work in source code form is that
-same work.
-
- 2. Basic Permissions.
-
- All rights granted under this License are granted for the term of
-copyright on the Program, and are irrevocable provided the stated
-conditions are met. This License explicitly affirms your unlimited
-permission to run the unmodified Program. The output from running a
-covered work is covered by this License only if the output, given its
-content, constitutes a covered work. This License acknowledges your
-rights of fair use or other equivalent, as provided by copyright law.
-
- You may make, run and propagate covered works that you do not
-convey, without conditions so long as your license otherwise remains
-in force. You may convey covered works to others for the sole purpose
-of having them make modifications exclusively for you, or provide you
-with facilities for running those works, provided that you comply with
-the terms of this License in conveying all material for which you do
-not control copyright. Those thus making or running the covered works
-for you must do so exclusively on your behalf, under your direction
-and control, on terms that prohibit them from making any copies of
-your copyrighted material outside their relationship with you.
-
- Conveying under any other circumstances is permitted solely under
-the conditions stated below. Sublicensing is not allowed; section 10
-makes it unnecessary.
-
- 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
-
- No covered work shall be deemed part of an effective technological
-measure under any applicable law fulfilling obligations under article
-11 of the WIPO copyright treaty adopted on 20 December 1996, or
-similar laws prohibiting or restricting circumvention of such
-measures.
-
- When you convey a covered work, you waive any legal power to forbid
-circumvention of technological measures to the extent such circumvention
-is effected by exercising rights under this License with respect to
-the covered work, and you disclaim any intention to limit operation or
-modification of the work as a means of enforcing, against the work's
-users, your or third parties' legal rights to forbid circumvention of
-technological measures.
-
- 4. Conveying Verbatim Copies.
-
- You may convey verbatim copies of the Program's source code as you
-receive it, in any medium, provided that you conspicuously and
-appropriately publish on each copy an appropriate copyright notice;
-keep intact all notices stating that this License and any
-non-permissive terms added in accord with section 7 apply to the code;
-keep intact all notices of the absence of any warranty; and give all
-recipients a copy of this License along with the Program.
-
- You may charge any price or no price for each copy that you convey,
-and you may offer support or warranty protection for a fee.
-
- 5. Conveying Modified Source Versions.
-
- You may convey a work based on the Program, or the modifications to
-produce it from the Program, in the form of source code under the
-terms of section 4, provided that you also meet all of these conditions:
-
- a) The work must carry prominent notices stating that you modified
- it, and giving a relevant date.
-
- b) The work must carry prominent notices stating that it is
- released under this License and any conditions added under section
- 7. This requirement modifies the requirement in section 4 to
- "keep intact all notices".
-
- c) You must license the entire work, as a whole, under this
- License to anyone who comes into possession of a copy. This
- License will therefore apply, along with any applicable section 7
- additional terms, to the whole of the work, and all its parts,
- regardless of how they are packaged. This License gives no
- permission to license the work in any other way, but it does not
- invalidate such permission if you have separately received it.
-
- d) If the work has interactive user interfaces, each must display
- Appropriate Legal Notices; however, if the Program has interactive
- interfaces that do not display Appropriate Legal Notices, your
- work need not make them do so.
-
- A compilation of a covered work with other separate and independent
-works, which are not by their nature extensions of the covered work,
-and which are not combined with it such as to form a larger program,
-in or on a volume of a storage or distribution medium, is called an
-"aggregate" if the compilation and its resulting copyright are not
-used to limit the access or legal rights of the compilation's users
-beyond what the individual works permit. Inclusion of a covered work
-in an aggregate does not cause this License to apply to the other
-parts of the aggregate.
-
- 6. Conveying Non-Source Forms.
-
- You may convey a covered work in object code form under the terms
-of sections 4 and 5, provided that you also convey the
-machine-readable Corresponding Source under the terms of this License,
-in one of these ways:
-
- a) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by the
- Corresponding Source fixed on a durable physical medium
- customarily used for software interchange.
-
- b) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by a
- written offer, valid for at least three years and valid for as
- long as you offer spare parts or customer support for that product
- model, to give anyone who possesses the object code either (1) a
- copy of the Corresponding Source for all the software in the
- product that is covered by this License, on a durable physical
- medium customarily used for software interchange, for a price no
- more than your reasonable cost of physically performing this
- conveying of source, or (2) access to copy the
- Corresponding Source from a network server at no charge.
-
- c) Convey individual copies of the object code with a copy of the
- written offer to provide the Corresponding Source. This
- alternative is allowed only occasionally and noncommercially, and
- only if you received the object code with such an offer, in accord
- with subsection 6b.
-
- d) Convey the object code by offering access from a designated
- place (gratis or for a charge), and offer equivalent access to the
- Corresponding Source in the same way through the same place at no
- further charge. You need not require recipients to copy the
- Corresponding Source along with the object code. If the place to
- copy the object code is a network server, the Corresponding Source
- may be on a different server (operated by you or a third party)
- that supports equivalent copying facilities, provided you maintain
- clear directions next to the object code saying where to find the
- Corresponding Source. Regardless of what server hosts the
- Corresponding Source, you remain obligated to ensure that it is
- available for as long as needed to satisfy these requirements.
-
- e) Convey the object code using peer-to-peer transmission, provided
- you inform other peers where the object code and Corresponding
- Source of the work are being offered to the general public at no
- charge under subsection 6d.
-
- A separable portion of the object code, whose source code is excluded
-from the Corresponding Source as a System Library, need not be
-included in conveying the object code work.
-
- A "User Product" is either (1) a "consumer product", which means any
-tangible personal property which is normally used for personal, family,
-or household purposes, or (2) anything designed or sold for incorporation
-into a dwelling. In determining whether a product is a consumer product,
-doubtful cases shall be resolved in favor of coverage. For a particular
-product received by a particular user, "normally used" refers to a
-typical or common use of that class of product, regardless of the status
-of the particular user or of the way in which the particular user
-actually uses, or expects or is expected to use, the product. A product
-is a consumer product regardless of whether the product has substantial
-commercial, industrial or non-consumer uses, unless such uses represent
-the only significant mode of use of the product.
-
- "Installation Information" for a User Product means any methods,
-procedures, authorization keys, or other information required to install
-and execute modified versions of a covered work in that User Product from
-a modified version of its Corresponding Source. The information must
-suffice to ensure that the continued functioning of the modified object
-code is in no case prevented or interfered with solely because
-modification has been made.
-
- If you convey an object code work under this section in, or with, or
-specifically for use in, a User Product, and the conveying occurs as
-part of a transaction in which the right of possession and use of the
-User Product is transferred to the recipient in perpetuity or for a
-fixed term (regardless of how the transaction is characterized), the
-Corresponding Source conveyed under this section must be accompanied
-by the Installation Information. But this requirement does not apply
-if neither you nor any third party retains the ability to install
-modified object code on the User Product (for example, the work has
-been installed in ROM).
-
- The requirement to provide Installation Information does not include a
-requirement to continue to provide support service, warranty, or updates
-for a work that has been modified or installed by the recipient, or for
-the User Product in which it has been modified or installed. Access to a
-network may be denied when the modification itself materially and
-adversely affects the operation of the network or violates the rules and
-protocols for communication across the network.
-
- Corresponding Source conveyed, and Installation Information provided,
-in accord with this section must be in a format that is publicly
-documented (and with an implementation available to the public in
-source code form), and must require no special password or key for
-unpacking, reading or copying.
-
- 7. Additional Terms.
-
- "Additional permissions" are terms that supplement the terms of this
-License by making exceptions from one or more of its conditions.
-Additional permissions that are applicable to the entire Program shall
-be treated as though they were included in this License, to the extent
-that they are valid under applicable law. If additional permissions
-apply only to part of the Program, that part may be used separately
-under those permissions, but the entire Program remains governed by
-this License without regard to the additional permissions.
-
- When you convey a copy of a covered work, you may at your option
-remove any additional permissions from that copy, or from any part of
-it. (Additional permissions may be written to require their own
-removal in certain cases when you modify the work.) You may place
-additional permissions on material, added by you to a covered work,
-for which you have or can give appropriate copyright permission.
-
- Notwithstanding any other provision of this License, for material you
-add to a covered work, you may (if authorized by the copyright holders of
-that material) supplement the terms of this License with terms:
-
- a) Disclaiming warranty or limiting liability differently from the
- terms of sections 15 and 16 of this License; or
-
- b) Requiring preservation of specified reasonable legal notices or
- author attributions in that material or in the Appropriate Legal
- Notices displayed by works containing it; or
-
- c) Prohibiting misrepresentation of the origin of that material, or
- requiring that modified versions of such material be marked in
- reasonable ways as different from the original version; or
-
- d) Limiting the use for publicity purposes of names of licensors or
- authors of the material; or
-
- e) Declining to grant rights under trademark law for use of some
- trade names, trademarks, or service marks; or
-
- f) Requiring indemnification of licensors and authors of that
- material by anyone who conveys the material (or modified versions of
- it) with contractual assumptions of liability to the recipient, for
- any liability that these contractual assumptions directly impose on
- those licensors and authors.
-
- All other non-permissive additional terms are considered "further
-restrictions" within the meaning of section 10. If the Program as you
-received it, or any part of it, contains a notice stating that it is
-governed by this License along with a term that is a further
-restriction, you may remove that term. If a license document contains
-a further restriction but permits relicensing or conveying under this
-License, you may add to a covered work material governed by the terms
-of that license document, provided that the further restriction does
-not survive such relicensing or conveying.
-
- If you add terms to a covered work in accord with this section, you
-must place, in the relevant source files, a statement of the
-additional terms that apply to those files, or a notice indicating
-where to find the applicable terms.
-
- Additional terms, permissive or non-permissive, may be stated in the
-form of a separately written license, or stated as exceptions;
-the above requirements apply either way.
-
- 8. Termination.
-
- You may not propagate or modify a covered work except as expressly
-provided under this License. Any attempt otherwise to propagate or
-modify it is void, and will automatically terminate your rights under
-this License (including any patent licenses granted under the third
-paragraph of section 11).
-
- However, if you cease all violation of this License, then your
-license from a particular copyright holder is reinstated (a)
-provisionally, unless and until the copyright holder explicitly and
-finally terminates your license, and (b) permanently, if the copyright
-holder fails to notify you of the violation by some reasonable means
-prior to 60 days after the cessation.
-
- Moreover, your license from a particular copyright holder is
-reinstated permanently if the copyright holder notifies you of the
-violation by some reasonable means, this is the first time you have
-received notice of violation of this License (for any work) from that
-copyright holder, and you cure the violation prior to 30 days after
-your receipt of the notice.
-
- Termination of your rights under this section does not terminate the
-licenses of parties who have received copies or rights from you under
-this License. If your rights have been terminated and not permanently
-reinstated, you do not qualify to receive new licenses for the same
-material under section 10.
-
- 9. Acceptance Not Required for Having Copies.
-
- You are not required to accept this License in order to receive or
-run a copy of the Program. Ancillary propagation of a covered work
-occurring solely as a consequence of using peer-to-peer transmission
-to receive a copy likewise does not require acceptance. However,
-nothing other than this License grants you permission to propagate or
-modify any covered work. These actions infringe copyright if you do
-not accept this License. Therefore, by modifying or propagating a
-covered work, you indicate your acceptance of this License to do so.
-
- 10. Automatic Licensing of Downstream Recipients.
-
- Each time you convey a covered work, the recipient automatically
-receives a license from the original licensors, to run, modify and
-propagate that work, subject to this License. You are not responsible
-for enforcing compliance by third parties with this License.
-
- An "entity transaction" is a transaction transferring control of an
-organization, or substantially all assets of one, or subdividing an
-organization, or merging organizations. If propagation of a covered
-work results from an entity transaction, each party to that
-transaction who receives a copy of the work also receives whatever
-licenses to the work the party's predecessor in interest had or could
-give under the previous paragraph, plus a right to possession of the
-Corresponding Source of the work from the predecessor in interest, if
-the predecessor has it or can get it with reasonable efforts.
-
- You may not impose any further restrictions on the exercise of the
-rights granted or affirmed under this License. For example, you may
-not impose a license fee, royalty, or other charge for exercise of
-rights granted under this License, and you may not initiate litigation
-(including a cross-claim or counterclaim in a lawsuit) alleging that
-any patent claim is infringed by making, using, selling, offering for
-sale, or importing the Program or any portion of it.
-
- 11. Patents.
-
- A "contributor" is a copyright holder who authorizes use under this
-License of the Program or a work on which the Program is based. The
-work thus licensed is called the contributor's "contributor version".
-
- A contributor's "essential patent claims" are all patent claims
-owned or controlled by the contributor, whether already acquired or
-hereafter acquired, that would be infringed by some manner, permitted
-by this License, of making, using, or selling its contributor version,
-but do not include claims that would be infringed only as a
-consequence of further modification of the contributor version. For
-purposes of this definition, "control" includes the right to grant
-patent sublicenses in a manner consistent with the requirements of
-this License.
-
- Each contributor grants you a non-exclusive, worldwide, royalty-free
-patent license under the contributor's essential patent claims, to
-make, use, sell, offer for sale, import and otherwise run, modify and
-propagate the contents of its contributor version.
-
- In the following three paragraphs, a "patent license" is any express
-agreement or commitment, however denominated, not to enforce a patent
-(such as an express permission to practice a patent or covenant not to
-sue for patent infringement). To "grant" such a patent license to a
-party means to make such an agreement or commitment not to enforce a
-patent against the party.
-
- If you convey a covered work, knowingly relying on a patent license,
-and the Corresponding Source of the work is not available for anyone
-to copy, free of charge and under the terms of this License, through a
-publicly available network server or other readily accessible means,
-then you must either (1) cause the Corresponding Source to be so
-available, or (2) arrange to deprive yourself of the benefit of the
-patent license for this particular work, or (3) arrange, in a manner
-consistent with the requirements of this License, to extend the patent
-license to downstream recipients. "Knowingly relying" means you have
-actual knowledge that, but for the patent license, your conveying the
-covered work in a country, or your recipient's use of the covered work
-in a country, would infringe one or more identifiable patents in that
-country that you have reason to believe are valid.
-
- If, pursuant to or in connection with a single transaction or
-arrangement, you convey, or propagate by procuring conveyance of, a
-covered work, and grant a patent license to some of the parties
-receiving the covered work authorizing them to use, propagate, modify
-or convey a specific copy of the covered work, then the patent license
-you grant is automatically extended to all recipients of the covered
-work and works based on it.
-
- A patent license is "discriminatory" if it does not include within
-the scope of its coverage, prohibits the exercise of, or is
-conditioned on the non-exercise of one or more of the rights that are
-specifically granted under this License. You may not convey a covered
-work if you are a party to an arrangement with a third party that is
-in the business of distributing software, under which you make payment
-to the third party based on the extent of your activity of conveying
-the work, and under which the third party grants, to any of the
-parties who would receive the covered work from you, a discriminatory
-patent license (a) in connection with copies of the covered work
-conveyed by you (or copies made from those copies), or (b) primarily
-for and in connection with specific products or compilations that
-contain the covered work, unless you entered into that arrangement,
-or that patent license was granted, prior to 28 March 2007.
-
- Nothing in this License shall be construed as excluding or limiting
-any implied license or other defenses to infringement that may
-otherwise be available to you under applicable patent law.
-
- 12. No Surrender of Others' Freedom.
-
- If conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot convey a
-covered work so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you may
-not convey it at all. For example, if you agree to terms that obligate you
-to collect a royalty for further conveying from those to whom you convey
-the Program, the only way you could satisfy both those terms and this
-License would be to refrain entirely from conveying the Program.
-
- 13. Use with the GNU Affero General Public License.
-
- Notwithstanding any other provision of this License, you have
-permission to link or combine any covered work with a work licensed
-under version 3 of the GNU Affero General Public License into a single
-combined work, and to convey the resulting work. The terms of this
-License will continue to apply to the part which is the covered work,
-but the special requirements of the GNU Affero General Public License,
-section 13, concerning interaction through a network will apply to the
-combination as such.
-
- 14. Revised Versions of this License.
-
- The Free Software Foundation may publish revised and/or new versions of
-the GNU General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
- Each version is given a distinguishing version number. If the
-Program specifies that a certain numbered version of the GNU General
-Public License "or any later version" applies to it, you have the
-option of following the terms and conditions either of that numbered
-version or of any later version published by the Free Software
-Foundation. If the Program does not specify a version number of the
-GNU General Public License, you may choose any version ever published
-by the Free Software Foundation.
-
- If the Program specifies that a proxy can decide which future
-versions of the GNU General Public License can be used, that proxy's
-public statement of acceptance of a version permanently authorizes you
-to choose that version for the Program.
-
- Later license versions may give you additional or different
-permissions. However, no additional obligations are imposed on any
-author or copyright holder as a result of your choosing to follow a
-later version.
-
- 15. Disclaimer of Warranty.
-
- THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
-APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
-HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
-OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
-IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
-ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. Limitation of Liability.
-
- IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
-THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
-GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
-USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
-DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
-PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
-EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGES.
-
- 17. Interpretation of Sections 15 and 16.
-
- If the disclaimer of warranty and limitation of liability provided
-above cannot be given local legal effect according to their terms,
-reviewing courts shall apply local law that most closely approximates
-an absolute waiver of all civil liability in connection with the
-Program, unless a warranty or assumption of liability accompanies a
-copy of the Program in return for a fee.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-state the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-Also add information on how to contact you by electronic and paper mail.
-
- If the program does terminal interaction, make it output a short
-notice like this when it starts in an interactive mode:
-
- <program> Copyright (C) <year> <name of author>
- This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, your program's commands
-might be different; for a GUI interface, you would use an "about box".
-
- You should also get your employer (if you work as a programmer) or school,
-if any, to sign a "copyright disclaimer" for the program, if necessary.
-For more information on this, and how to apply and follow the GNU GPL, see
-<http://www.gnu.org/licenses/>.
-
- The GNU General Public License does not permit incorporating your program
-into proprietary programs. If your program is a subroutine library, you
-may consider it more useful to permit linking proprietary applications with
-the library. If this is what you want to do, use the GNU Lesser General
-Public License instead of this License. But first, please read
-<http://www.gnu.org/philosophy/why-not-lgpl.html>.
diff --git a/ChangeLog b/ChangeLog
deleted file mode 100644
index c134525..0000000
--- a/ChangeLog
+++ /dev/null
@@ -1,666 +0,0 @@
-commit 8b7c9d94a4571142a77a587138bc26b39f8e2863
-Author: Alexander Korolkov <alexander.korolkov@gmail.com>
-Date: Sun Sep 12 09:29:12 2010 +0200
-
- Modify LFN direntries when file is renamed or deleted, see
- Debian bug #596329.
-
-commit 761b798f3bf2b4a87f2d454f555e18758791c864
-Author: Alexander Korolkov <alexander.korolkov@gmail.com>
-Date: Sun Sep 12 09:27:07 2010 +0200
-
- If the test of short filename fails, dosfsck could complain about
- bad long filename, see Debian bug #596327.
-
-commit 8fa3587a946614cd43d813052e0e31e595e6d63d
-Author: Alexander Korolkov <alexander.korolkov@gmail.com>
-Date: Sun Sep 12 09:24:47 2010 +0200
-
- dosfsck: don't complain about bad filenames when short filename
- contains 7 or more characters with codes 128-255, see Debian
- bug #596327.
-
-commit 3893857b841096de6a422ef5bed1b2618a7037d5
-Author: Mitch Rybczynski <mrybczynski@miovision.com>
-Date: Mon Jul 5 14:45:54 2010 +0200
-
- Adding __arm__ define check for some crosscompile toolchains.
-
-commit 7d03b3cc96b83b67638b463610a29abfd6f51f77
-Author: Daniel Baumann <daniel@debian.org>
-Date: Sun Mar 14 16:42:32 2010 +0100
-
- Modernizing dosfslabel manpage.
-
-commit 258049911c5df476fb434e0d87e0ece01b9ba137
-Author: Daniel Baumann <daniel@debian.org>
-Date: Sun Mar 14 16:33:47 2010 +0100
-
- Modernizing dosfsck manpage.
-
-commit 50d1d96b9666913a90e16904a63e29925675859c
-Author: Daniel Baumann <daniel@debian.org>
-Date: Sun Mar 14 16:05:32 2010 +0100
-
- Fixing spelling error in boot.c.
-
-commit 0e87c7890b598d78c6aa3d2a06b2306980e75a3d
-Author: Daniel Baumann <daniel@debian.org>
-Date: Sun Jan 31 08:31:32 2010 +0100
-
- Releasing upstream version 3.0.9.
-
-commit 9415707c2c9ad22b48660593915667dd228722fa
-Author: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
-Date: Sun Jan 31 00:11:41 2010 -0500
-
- Be sure to store the updated reserved_sector count in the boot sector,
- see Debian bug #567337.
-
-commit 68b3f00471f60a692fe021d65289bbaf2dc990d5
-Author: Daniel Baumann <daniel@debian.org>
-Date: Sat Jan 23 10:16:18 2010 +0100
-
- Releasing upstream version 3.0.8.
-
-commit 69dbf2e002f0cb3f0781256dec7258b66ffae3b6
-Author: Daniel Baumann <daniel@debian.org>
-Date: Sat Jan 23 10:15:01 2010 +0100
-
- Removing some cruft in end-comments.
-
-commit eef306657f3152bbf913a8a45c514f11b2dc2494
-Author: Steven J. Magnani <steve@digidescorp.com>
-Date: Thu Jan 21 16:58:11 2010 +0100
-
- When compiling a 32-bit version of dosfstools on an x86_64 machine,
- the resulting applications report strange errors on "large" (> 2 GiB)
- partitions:
-
- Seek to -2118967808:Invalid argument
-
- Warning: Filesystem is FAT32 according to fat_length and fat32_length fields,
- but has only 8613 clusters, less than the required minimum of 65525.
- This may lead to problems on some systems.
-
- This appears to be due to compilation with a 32-bit off_t and lseek() library
- function.
-
- Use lseek64 for positioning, and change some suspect uses of off_t to loff_t.
-
-commit e69f49dd1fe52780071cb3f024d1a8246125915a
-Author: Steven J. Magnani <steve@digidescorp.com>
-Date: Thu Jan 21 16:56:26 2010 +0100
-
- If dosfsck is run in read-only mode (-n), exit with code 0
- if the only issue found is an uninitialized free cluster summary.
-
-commit e52a16d488cf680117e4d476400bdd7915ef2f7a
-Author: Steven J. Magnani <steve@digidescorp.com>
-Date: Thu Jan 21 16:55:30 2010 +0100
-
- On x86_64, dosfsck incorrectly claims that a free_cluster summary of
- 0xFFFFFFFF, defined by Microsoft to be "uninitialized," is wrong.
-
-commit 32db02998ed7882df355fa4077009e8d363df3ab
-Author: H. Peter Anvin <hpa@zytor.com>
-Date: Fri Jan 8 09:16:38 2010 +0100
-
- mkdosfs: correct alignment of the root directory.
-
- Correct the code to align the root directory; it was broken before
- since bs.dir_entries had already been set at the point of alignment.
- This patch removes the dual use of bs.dir_entries and root_dir_entries
- to carry the same information: the information is carried in
- root_dir_entires exclusively, and then bs.dir_entries is set inside
- setup_tables() at a late point.
-
- The code to align the root directory is also wrapped in
- if (align_structures); this avoids rounding the number of root
- directory entries up to a whole sector when used with -a
- (i.e. preserves the previous behavior.)
-
-commit e462ac31a1d5d235b8a31a9e392e44e2dbc3783c
-Author: H. Peter Anvin <hpa@zytor.com>
-Date: Wed Jan 6 20:55:36 2010 +0100
-
- mkdosfs: improve wording in the man page for the -a option.
-
- Improve the English language used in the man page for the -a (no
- align) option to mkdosfs.
-
-commit 680d71d167f30a823f88dd66473fc664cd887ab0
-Author: Daniel Baumann <daniel@debian.org>
-Date: Wed Jan 6 11:27:25 2010 +0100
-
- Adding reference to dosfslable in mkdosfs manpage.
-
-commit 60fc9f853c1045e615b34a193738f88021678d30
-Author: H. Peter Anvin <hpa@zytor.com>
-Date: Wed Jan 6 11:18:55 2010 +0100
-
- mkdosfs: by default align all structures to cluster boundaries
-
- Align all data structures (reserved sectors, FATs, root directory for
- FAT12/16) to an even multiple of the cluster size. This means that if
- the partition is aligned, so will all clusters be. This adds
- significant performance for anything where the physical sector size is
- larger than the logical sector size, e.g. flash media or large-sector
- hard disks.
-
-commit 312b05fc47107f695483994375a1f6f429069708
-Author: Daniel Baumann <daniel@debian.org>
-Date: Thu Dec 24 10:53:36 2009 +0100
-
- Releasing upstream version 3.0.7.
-
-commit 844307669208608a3464157ddb5e789bd9556f34
-Author: Ben Hutchings <ben@decadent.org.uk>
-Date: Thu Dec 24 09:55:52 2009 +0100
-
- Fixing dosfslabel to set volume label in the right place,
- see Debian bug #559985.
-
-commit 1bae0e2037717d65b3283db9da51ae7686a7a9be
-Author: Lubomir Rintel <lkundrak@v3.sk>
-Date: Thu Dec 24 09:39:39 2009 +0100
-
- Fixing out-of bound writes.
-
- Firstly, packed attribute is added to the structure so that extension
- is guarranteed to immediately follow name for the cross-name-extension
- reads to succeed.
-
- Secondly, writes into dir_entry->name that span through the extension as
- well are split into two, so that FORTIFY_SOURCE's bound checking does
- not abort dosfsck. There also was an off-by-one error in auto_rename()'s
- sprintf().
-
-commit eb297071adfca1ed7af85ca111f20ab41db8ac59
-Author: San Mehat <san@google.com>
-Date: Thu Dec 24 09:31:41 2009 +0100
-
- Adding custom exit code in dosfsck for the case where the FS is read only.
-
-commit b3864d0939c960d0e0f15e4e3b1d626639b64681
-Author: Daniel Baumann <daniel@debian.org>
-Date: Sun Oct 4 10:59:33 2009 +0200
-
- Releasing upstream version 3.0.6.
-
-commit 144f8fcfc3f7982e8f460f8379a753b7a5941783
-Author: Steven J. Magnani <steve@digidescorp.com>
-Date: Sun Oct 4 10:58:43 2009 +0200
-
- Attempt to improve clarity of the orphan cluster reclaim code.
- Minor optimization - remove some unnecessary checking.
-
-commit 343fe6d5e7135efadc498fd91e19ba8da499d0c9
-Author: Steven J. Magnani <steve@digidescorp.com>
-Date: Sun Oct 4 08:37:19 2009 +0200
-
- Close hole that permitted clusters to link to (invalid) cluster 1.
-
- If an orphan chain that linked to cluster 1 was reclaimed to a file,
- deletion of the file would result in a filesystem panic.
-
-commit db079a02059d7f7296fbe9f87624623a43816c5f
-Author: Steven J. Magnani <steve@digidescorp.com>
-Date: Sun Oct 4 08:32:30 2009 +0200
-
- Fix erroneous report of huge number of clusters in use on big-endian
- systems when the FSINFO free cluster count is reset.
-
-commit 7d5320b8a374b8da1a16b09b3b9b0713828d6755
-Author: Daniel Baumann <daniel@debian.org>
-Date: Mon Jul 27 14:26:11 2009 +0200
-
- Releasing upstream version 3.0.5.
-
-commit e80ede4dd3c2058fe32e29ff82244ecb1c7c5514
-Author: Piotr Kaczuba <pepe@attika.ath.cx>
-Date: Sun Jul 26 22:21:25 2009 +0200
-
- Signed/unsigned char mismatch in check.c causes false positives
- in bad_name() and can result in data loss, see Debian bug #538758.
-
-commit 9e15ddf6d52dd166efcb59f91f16fb9d695c86c5
-Author: Andrew Tridgell <tridge@samba.org>
-Date: Sun Jul 26 22:12:06 2009 +0200
-
- Update to new kernel patches that add FAT_NO_83NAME flag.
-
- See http://lkml.org/lkml/2009/7/20/425 and
- http://lkml.org/lkml/2009/7/20/424 for more information.
-
-commit 6c68b94008157c444954d2f90a7f9ec8ffc2ec87
-Author: Daniel Baumann <daniel@debian.org>
-Date: Tue Jul 21 08:10:52 2009 +0200
-
- Releasing upstream version 3.0.4.
-
-commit 3ce6422e93f3de746be092e324253a8722917a86
-Author: Andrew Tridgell <tridge@samba.org>
-Date: Tue Jul 21 07:59:22 2009 +0200
-
- Modify dosfstools to support the dummy 8.3 short filename values
- used by Linux systems with the VFAT_FS_DUALNAMES option disabled.
-
- See http://lkml.org/lkml/2009/6/26/313 and
- http://lkml.org/lkml/2009/6/26/314 for more information.
-
-commit 94f8769aeddf0d0d3f0be54361514a464907a4a1
-Author: Paul Rupe <prupe@nc.rr.com>
-Date: Tue May 19 10:37:52 2009 +0200
-
- Fixing "Too many files need repair" error during fsck.
-
-commit 89566399e407e54eb14d275770106ad42b3ac87c
-Author: Daniel Baumann <daniel@debian.org>
-Date: Mon May 18 15:12:04 2009 +0200
-
- Releasing upstream version 3.0.3.
-
-commit 8147c98a542b714ccab34b57c84ed842bb6b50f2
-Author: Daniel Baumann <daniel@debian.org>
-Date: Mon May 18 15:10:55 2009 +0200
-
- Also declaring arm as an unaligned architecture, see Debian bug #502961.
-
-commit 18e27fa5c0f811e7edc10bca771acc7c04b19146
-Author: Steven J. Magnani <steve@digidescorp.com>
-Date: Mon May 18 15:01:49 2009 +0200
-
- Adding support for limited-memory embedded systems.
-
- This patch reorganizes heap memory usage by dosfsck and mkdosfs
- to support limited-memory embedded systems - in particular, those
- based on Xilinx's Microblaze processor. It also adds a few comments.
-
-commit 180b68e652df7bfeb7f336e0247aee8873edea7f
-Author: Mike Frysinger <vapier@gentoo.org>
-Date: Thu Mar 5 07:03:36 2009 +0100
-
- Declaring Blackfin as an unaligned architecture.
-
-commit 71ac75353d9158aed663f0a3a9d1a1a67ee4ff4f
-Author: Daniel Baumann <daniel@debian.org>
-Date: Sat Feb 28 09:48:04 2009 +0100
-
- Releasing upstream version 3.0.2.
-
-commit a75924b8ff629fe7ca5ba9c58ac75f66290242ee
-Author: Hiroaki Ishizawa <hiroaki.ishizawa@gmail.com>
-Date: Fri Feb 13 10:00:46 2009 +0100
-
- dosfsck corrupts root directory when fs->nfats is 1.
-
-commit 161a5e1fdd019732e0a304beceaeeb606eb128d6
-Author: Stepan Kasal <skasal@redhat.com>
-Date: Fri Jan 30 14:56:33 2009 +0100
-
- src/dosfslabel.c (main): After writing the label, exit code should be 0.
-
-commit 26ffa1fb565c2b3284b846ca2733118808c85cb5
-Author: Daniel Baumann <daniel@debian.org>
-Date: Fri Jan 30 14:06:01 2009 +0100
-
- Also installing ChangeLog in install-doc target of Makefile.
-
-commit abad38ee561b02ec47be7e861780bf5fa2a05d0b
-Author: Stepan Kasal <skasal@redhat.com>
-Date: Fri Jan 30 14:05:12 2009 +0100
-
- Makefile: Do not clobber time stamps of doc files.
-
-commit 81882d20ec6bd4bf4914d39636cecc8c8e57dd67
-Author: Daniel Baumann <daniel@debian.org>
-Date: Sun Nov 23 22:45:45 2008 +0100
-
- Releasing upstream version 3.0.1.
-
-commit 41574812a2586f0b6aa1d4f6e2276e557e9cbbcf
-Author: Daniel Baumann <daniel@debian.org>
-Date: Sun Nov 23 18:41:01 2008 +0100
-
- Applying Fedoras dosfstools-vfat-timingfix.diff from Bill Nottingham
- <notting@redhat.com> to fix vfat timing issue. See
- https://bugzilla.redhat.com/show_bug.cgi?id=448247 for more information.
-
-commit b80656109cc5cffdefd626c2ec9d45e3cf63a03e
-Author: Ulrich Mueller <ulm@gentoo.org>
-Date: Tue Oct 7 07:55:37 2008 +0200
-
- Patch to check for bad number of clusters in dosfsck:
-
- * FAT16 filesystems with 65525 clusters or more will be rejected
- (Before, this was not tested for. Up to 65535 clusters were accepted
- as good).
-
- * For FAT32 filesystems with less than 65525 a warning message will be
- output.
-
- Macro MSDOS_FAT12 is now replaced by FAT12_THRESHOLD to make it
- consistent with the definition in mkdosfs and to remove the dependency
- on the kernel version.
-
-commit b9c13d143c420a3ec6e1dcb652cafa407621e9c7
-Author: Dann Frazier <dannf@hp.com>
-Date: Tue Sep 30 07:25:19 2008 +0200
-
- Changing some wording to make the indended meaning of "full-disk device"
- more obvious.
-
-commit 4df18ad463f41ae368c3c51bfb5a033072605663
-Author: Daniel Baumann <daniel@debian.org>
-Date: Sun Sep 28 11:43:19 2008 +0200
-
- Releasing upstream version 3.0.0.
-
-commit 17fbf2a6dc9255a6bb832472ae7cda674b55e961
-Author: Daniel Baumann <daniel@debian.org>
-Date: Sun Sep 28 11:29:01 2008 +0200
-
- Adding GPL headers to all files.
-
-commit d2039e12c8d53472411c91eb8e7a7c0544e13d6d
-Author: Daniel Baumann <daniel@debian.org>
-Date: Sun Sep 28 10:51:55 2008 +0200
-
- Adding new GPL license file.
-
-commit e4e457f4b57090ecf0539f48dc682ab9afd14ab8
-Author: Daniel Baumann <daniel@debian.org>
-Date: Fri Sep 26 23:31:12 2008 +0200
-
- Redoing Makefile from scratch.
-
-commit 216568ca3a01ed38962b22c7bf838d15d5a4d98d
-Author: Daniel Baumann <daniel@debian.org>
-Date: Sat Sep 27 00:17:38 2008 +0200
-
- Removing whitespaces in all files at EOL and EOF.
-
-commit f59157e06561c525605279145057361afa721042
-Author: Daniel Baumann <daniel@debian.org>
-Date: Fri Sep 26 23:48:56 2008 +0200
-
- Adding Debians dosfslabel.8 manpage from Francois Wendling
- <frwendling@free.fr>.
-
-commit c1bacab212d2b7f6ea93914976cb60056ff8276d
-Author: Daniel Baumann <daniel@debian.org>
-Date: Fri Sep 26 18:36:04 2008 +0200
-
- Updating version.h includes to new location of version.h file.
-
-commit 1dae9f522062037d3539cadf344e0359c644171f
-Author: Daniel Baumann <daniel@debian.org>
-Date: Fri Sep 26 18:19:36 2008 +0200
-
- Removing old lsm file.
-
-commit d843bec0b987f5582fe048f70e42df18c34d3ae4
-Author: Daniel Baumann <daniel@debian.org>
-Date: Fri Sep 26 18:07:47 2008 +0200
-
- Removing old cvsignore files.
-
-commit 77fddbc03016752286b26913c62b98f86ee63211
-Author: Daniel Baumann <daniel@debian.org>
-Date: Fri Sep 26 18:18:39 2008 +0200
-
- Removing old build file.
-
-commit f3e7168fc9eb6f32a6c85021186d84944cefeba8
-Author: Daniel Baumann <daniel@debian.org>
-Date: Fri Sep 26 18:19:16 2008 +0200
-
- Removing old GPL license files.
-
-commit 68089477036e97911791516ee2167286f26ff819
-Author: Daniel Baumann <daniel@debian.org>
-Date: Fri Sep 26 18:21:57 2008 +0200
-
- Unifying dosfsck and mkdosfs Makefiles in common src/Makefile.
-
-commit 9432a02d6e7c38872d7b1042f1b8be1b24a57427
-Author: Daniel Baumann <daniel@debian.org>
-Date: Fri Sep 26 18:04:02 2008 +0200
-
- Unifying dosfsck and mkdosfs sources in common src directory.
-
-commit 0c179b9ee47174d0f34d9fc796d540012740ac01
-Author: Daniel Baumann <daniel@debian.org>
-Date: Fri Sep 26 18:05:27 2008 +0200
-
- Unifying dosfsck and mkdosfs manpages in common man directory.
-
-commit 2d246c28ba6cfd43be2e44b11283891d922f352b
-Author: Daniel Baumann <daniel@debian.org>
-Date: Fri Sep 26 18:12:29 2008 +0200
-
- Unifying dosfsck and mkdosfs documents in common doc directory.
-
-commit e5b16990515d0214fd103dd8aa22ff6a3cda4b64
-Author: Daniel Baumann <daniel@debian.org>
-Date: Fri Sep 26 15:39:51 2008 +0200
-
- Applying Gentoos dosfstools-2.11-preen.patch from Roy Marples
- <uberlord@gentoo.org> to alias dosfsck -p to -a:
-
- * Map -p to -a for baselayout-2, #177514.
-
-commit 6a1d974251a9f9a142775ace3a8048149abfa90c
-Author: Daniel Baumann <daniel@debian.org>
-Date: Fri Sep 26 15:49:43 2008 +0200
-
- Applying Gentoos dosfstools-2.11-build.patch from Mike Frysinger
- <vapier@gentoo.org> to improve Makefile:
-
- * Respect user settings #157785/#157786 by Diego Petteno.
-
-commit 1ea49f00e61b554dc833d44e1a3617e923be667e
-Author: Daniel Baumann <daniel@debian.org>
-Date: Fri Sep 26 15:37:34 2008 +0200
-
- Applying Gentoos dosfstools-2.11-verify-double-count-fix.patch from
- Robin H. Johnson <robbat2@gentoo.org> to fix double count of files
- during verification:
-
- * Don't double-count n_files during a verification pass.
- Bugzilla: http://bugs.gentoo.org/show_bug.cgi?id=99845
-
-commit 2d2f20b2c495fa620c7bb3ec5a0838b08f65ab05
-Author: Daniel Baumann <daniel@debian.org>
-Date: Fri Sep 26 15:33:36 2008 +0200
-
- Applying Gentoos dosfstools-2.11-fat32size.patch from Mike Frysinger
- <vapier@gentoo.org> to fix generation of filesystems on 256meg devices:
-
- * Fix generation of FAT filesystems on devices that are 256meg in size
- Patch by Ulrich Mueller and accepted upstream
- http://bugs.gentoo.org/112504
-
-commit a86564a9317b2bf9f7734feacdce794f20af74a7
-Author: Daniel Baumann <daniel@debian.org>
-Date: Fri Sep 26 15:22:06 2008 +0200
-
- Applying Suses dosfstools-2.11-unsupported-sector-size.patch from Petr
- Gajdos <pgajdos@suse.cz> to add sector size warning:
-
- * added warning for creation msdos on filesystem with sector size
- greater than 4096 [fate#303325]
-
-commit 8171e51f4e02bd9f92bb515ca7896d3cb1b564b5
-Author: Daniel Baumann <daniel@debian.org>
-Date: Fri Sep 26 15:18:35 2008 +0200
-
- Applying Suses dosfstools-2.11-mkdosfs-geo0.diff from Ludwig Nussel
- <lnussel@suse.de> to fix handling of zero heads and sectors:
-
- * the HDIO_GETGEO ioctl works on device mapper devices but returns
- zero heads and sectors. Therefore let's a) assume dummy values in
- that case in mkdosfs and b) don't consider such fat file systems as
- invalid in dosfsck. The Linux kernel accepts them anyways.
-
-commit db887df619f4e995db0ab112334f31464a03fa0e
-Author: Daniel Baumann <daniel@debian.org>
-Date: Fri Sep 26 15:15:40 2008 +0200
-
- Applying Suses dosfstools-2.11-linuxfs.patch from Ruediger Oertel
- <ro@suse.de> to not include linux/fs.h.
-
-commit 7fe3fa643494b26962d542fac38d988ac60f8c09
-Author: Daniel Baumann <daniel@debian.org>
-Date: Fri Sep 26 15:11:50 2008 +0200
-
- Applying Fedoras dosfstools-2.11-assumeKernel26.patch from Peter Vrabec
- <pvrabec@redhat.com> to remove linux 2.6 conditionals:
-
- * LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0) does not work with
- glibc-kernheaders-2.4-9.1.94
-
-commit 90c1c93c100722a03e48be51b1312fe65c1cb156
-Author: Daniel Baumann <daniel@debian.org>
-Date: Fri Sep 26 15:05:00 2008 +0200
-
- Applying Debians 99-conglomeration.dpatch (no other information
- available).
-
-commit bb6541bf4735e3a7f1c71b4722c6d03bb4549eea
-Author: Daniel Baumann <daniel@debian.org>
-Date: Fri Sep 26 14:26:41 2008 +0200
-
- Applying Debians 15-manpage-files.dpatch from Daniel Baumann
- <daniel@debian.org> to improve dosfsck manpage:
-
- * Lists fsckNNNN.rec files in FILES section (Closes: #444596).
-
-commit 49282165866be19d3bc54a3f4bdee2cf3a63ba6c
-Author: Daniel Baumann <daniel@debian.org>
-Date: Fri Sep 26 14:34:42 2008 +0200
-
- Applying Debians 13-getopt.dpatch from Adonikam Virgo
- <adonikam@virgonet.org> to fix mkdosfs getopt:
-
- * Fixes backup sector getopt (Closes: #232387, #479794).
-
-commit c32e44b85f4eac6f6a94bd620eea4abba257042a
-Author: Daniel Baumann <daniel@debian.org>
-Date: Fri Sep 26 14:34:17 2008 +0200
-
- Applying Debians 12-zero-slot.dpatch by Karl Tomlinson
- <karlt@karlt.net> to fix dosfsck zero slot crashes:
-
- * Fixes crashes due to zero slot numbers causing a negative offset in
- the call to copy_lfn_part in lfn_add_slot. On amd64 this results in
- a SIGSEGV in copy_lfn_part. On x86 the result is heap corruption
- and thus sometimes a SIGSEGV or double free abort later. (Closes:
- #152550, #353198, #356377, #401798).
-
-commit 370847af533e628aa9e38710e6d50af09f2b71ba
-Author: Daniel Baumann <daniel@debian.org>
-Date: Fri Sep 26 14:33:54 2008 +0200
-
- Applying Debians 11-memory-efficiency.dpatch from Eero Tamminen
- <eero.tamminen@nokia.com> to improve dosfsck memory efficiency:
-
- * Improves memory efficiency when checking filesystems.
-
-commit 28da9f286a52acec7df7ad06cb0679e5f828e7f3
-Author: Daniel Baumann <daniel@debian.org>
-Date: Fri Sep 26 14:33:28 2008 +0200
-
- Applying Debians 10-manpage-synopsis.dpatch from Daniel Baumann
- <daniel@debian.org> to fix manpage synopsis:
-
- * List alternative binary names in manpage synopsis (Closes: #284983).
-
-commit f253073021551c9b58d0f2ac262deb3c1b950b06
-Author: Daniel Baumann <daniel@debian.org>
-Date: Fri Sep 26 14:32:46 2008 +0200
-
- Applying Debians 09-manpage-fat32.dpatch from Daniel Baumann
- <daniel@debian.org> to improve mkdosfs manpage:
-
- * Don't claim that FAT32 is not choosed automatically (Closes:
- #414183).
-
-commit f37c07aec3972cfc0db374d544ee3b27c0b4b20b
-Author: Daniel Baumann <daniel@debian.org>
-Date: Fri Sep 26 14:32:23 2008 +0200
-
- Applying Debians 08-manpage-drop.dpatch from Daniel Baumann
- <daniel@debian.org> to improve dosfsck manpage:
-
- * Don't use confusing word 'drop' when 'delete' is meant (Closes:
- #134100).
-
-commit 3f970c65586da2f44d2a49b639e89341bbaf1fba
-Author: Daniel Baumann <daniel@debian.org>
-Date: Fri Sep 26 14:31:50 2008 +0200
-
- Applying Debians 07-manpage-spelling.dpatch from Justin Pryzby
- <justinpryzby@users.sourceforge.net> to fix mkdosfs manpage typos.
-
-commit 18678ba5f3a10c2a54ffee735651d7a265ae7d54
-Author: Daniel Baumann <daniel@debian.org>
-Date: Fri Sep 26 14:30:31 2008 +0200
-
- Applying Suses dosfstools-2.11_determine-sector-size.patch from Petr
- Gajdos <pgajdos@suse.cz> to determine mkdosfs sector size automatically:
-
- * determine sector size of device automatically or if -S parameter
- present, verify, that it's not under physical sector size
-
-commit 29753931b078856d78f473cfb6273e111a26891e
-Author: Daniel Baumann <daniel@debian.org>
-Date: Fri Sep 26 14:30:03 2008 +0200
-
- Applying Suses dosfstools-2.11-o_excl.patch from Pavol Rusnak
- <prusnak@suse.cz> to use O_EXCL in mkdosfs:
-
- * mkdosfs now opens device with O_EXCL [#238687]
-
-commit 16bb7b09ad9eaf0fe37a732cabcdbdf975b77d3e
-Author: Daniel Baumann <daniel@debian.org>
-Date: Fri Sep 26 14:29:36 2008 +0200
-
- Applying Debians 04-unaligned-memory.dpatch from Khalid Aziz
- <khalid_aziz@hp.com> to fix dosfsck unaligned memory accesses:
-
- * Fix unaligned memory accesses which cause warnings to appear
- everytime the elilo bootloader script runs. This has led a number
- of users to believe their install has failed (Closes: #258839).
-
-commit 1298cc8f37eaa27ca542b8b7186ea5a47a63cd7e
-Author: Daniel Baumann <daniel@debian.org>
-Date: Fri Sep 26 13:47:40 2008 +0200
-
- Applying Fedoras dosfstools-2.11-label.patch from Jeremy Katz
- <katzj@redhat.com> to add dosfslabel (originally by Peter Jones).
-
-commit d23890e1d89770d6d2ba58362c2fc4ebafbde15c
-Author: Daniel Baumann <daniel@debian.org>
-Date: Fri Sep 26 13:41:14 2008 +0200
-
- Applying Fedoras dosfstools-2.11-fortify.patch from Jakub Jelinek
- <jakub@redhat.com> to make it build with -D_FORTIFY_SOURCE=2:
-
- * This violates -D_FORTIFY_SOURCE=2 (which is stricter than C
- standard), but isn't actually any buffer overflow. But using memcpy
- is more efficient anyway.
-
-commit 7dbd82000e59246c1c2f8c280c4491259e10a767
-Author: Daniel Baumann <daniel@debian.org>
-Date: Fri Sep 26 13:40:47 2008 +0200
-
- Applying Fedoras dosfstools-2.7-argfix.patch (no other information
- available).
-
-commit 88f3b3139c72ac11cb3dd3f5afa8dbb2198a8de5
-Author: Daniel Baumann <daniel@debian.org>
-Date: Thu Jun 26 12:45:36 2008 +0200
-
- Adding upstream version 2.11.
diff --git a/Makefile b/Makefile
index 050b750..2b13818 100644
--- a/Makefile
+++ b/Makefile
@@ -1,112 +1,92 @@
-# Makefile
#
-# Copyright (C) 2008 Daniel Baumann <daniel@debian.org>
+# Makefile for dosfstools (mkdosfs and dosfsck)
#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-#
-# On Debian systems, the complete text of the GNU General Public License
-# can be found in /usr/share/common-licenses/GPL-3 file.
-
-DESTDIR =
-PREFIX = /usr/local
-SBINDIR = $(PREFIX)/sbin
-DOCDIR = $(PREFIX)/share/doc
-MANDIR = $(PREFIX)/share/man
-#OPTFLAGS = -O2 -fomit-frame-pointer -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
-OPTFLAGS = -O2 -fomit-frame-pointer $(shell getconf LFS_CFLAGS)
-#WARNFLAGS = -Wall -pedantic -std=c99
+CC = gcc
+CPP = $(CC) -E
+OPTFLAGS = -O2 -fomit-frame-pointer -D_FILE_OFFSET_BITS=64
WARNFLAGS = -Wall
-DEBUGFLAGS = -g
-CFLAGS += $(OPTFLAGS) $(WARNFLAGS) $(DEBUGFLAGS)
-
-VPATH = src
-
-all: build
-
-build: dosfsck dosfslabel mkdosfs
-
-dosfsck: boot.o check.o common.o fat.o file.o io.o lfn.o dosfsck.o
-
-dosfslabel: boot.o check.o common.o fat.o file.o io.o lfn.o dosfslabel.o
-
-mkdosfs: mkdosfs.o
-
-rebuild: distclean build
-
-install: install-bin install-doc install-man
-
-install-bin: build
- install -d -m 0755 $(DESTDIR)/$(SBINDIR)
- install -m 0755 dosfsck dosfslabel mkdosfs $(DESTDIR)/$(SBINDIR)
-
- ln -sf dosfsck $(DESTDIR)/$(SBINDIR)/fsck.msdos
- ln -sf dosfsck $(DESTDIR)/$(SBINDIR)/fsck.vfat
- ln -sf mkdosfs $(DESTDIR)/$(SBINDIR)/mkfs.msdos
- ln -sf mkdosfs $(DESTDIR)/$(SBINDIR)/mkfs.vfat
+DEBUGFLAGS =
+CFLAGS = $(OPTFLAGS) $(WARNFLAGS) $(DEBUGFLAGS)
+LDFLAGS =
-install-doc:
- install -d -m 0755 $(DESTDIR)/$(DOCDIR)/dosfstools
- install -p -m 0644 ChangeLog doc/* $(DESTDIR)/$(DOCDIR)/dosfstools
-
-install-man:
- install -d -m 0755 $(DESTDIR)/$(MANDIR)/man8
- install -p -m 0644 man/*.8 $(DESTDIR)/$(MANDIR)/man8
-
- ln -sf dosfsck.8 $(DESTDIR)/$(MANDIR)/man8/fsck.msdos.8
- ln -sf dosfsck.8 $(DESTDIR)/$(MANDIR)/man8/fsck.vfat.8
- ln -sf mkdosfs.8 $(DESTDIR)/$(MANDIR)/man8/mkfs.msdos.8
- ln -sf mkdosfs.8 $(DESTDIR)/$(MANDIR)/man8/mkfs.vfat.8
-
-uninstall: uninstall-bin uninstall-doc uninstall-man
-
-uninstall-bin:
- rm -f $(DESTDIR)/$(SBINDIR)/dosfsck
- rm -f $(DESTDIR)/$(SBINDIR)/dosfslabel
- rm -f $(DESTDIR)/$(SBINDIR)/mkdosfs
-
- rm -f $(DESTDIR)/$(SBINDIR)/fsck.msdos
- rm -f $(DESTDIR)/$(SBINDIR)/fsck.vfat
- rm -f $(DESTDIR)/$(SBINDIR)/mkfs.msdos
- rm -f $(DESTDIR)/$(SBINDIR)/mkfs.vfat
-
- rmdir --ignore-fail-on-non-empty $(DESTDIR)/$(SBINDIR)
-
-uninstall-doc:
- rm -rf $(DESTDIR)/$(DOCDIR)/dosfstools
-
- rmdir --ignore-fail-on-non-empty $(DESTDIR)/$(DOCDIR)
-
-uninstall-man:
- rm -f $(DESTDIR)/$(MANDIR)/man8/dosfsck.8
- rm -f $(DESTDIR)/$(MANDIR)/man8/dosfslabel.8
- rm -f $(DESTDIR)/$(MANDIR)/man8/mkdosfs.8
-
- rm -f $(DESTDIR)/$(MANDIR)/man8/fsck.msdos.8
- rm -f $(DESTDIR)/$(MANDIR)/man8/fsck.vfat.8
- rm -f $(DESTDIR)/$(MANDIR)/man8/mkfs.msdos.8
- rm -f $(DESTDIR)/$(MANDIR)/man8/mkfs.vfat.8
-
- rmdir --ignore-fail-on-non-empty $(DESTDIR)/$(MANDIR)/man8
- rmdir --ignore-fail-on-non-empty $(DESTDIR)/$(MANDIR)
-
-reinstall: distclean install
-
-clean:
- rm -f *.o
-
-distclean: clean
- rm -f dosfsck dosfslabel mkdosfs
+PREFIX =
+SBINDIR = $(PREFIX)/sbin
+MANDIR = $(PREFIX)/usr/man/man8
+
+.PHONY: clean distclean install depend
+.EXPORT_ALL_VARIABLES:
+
+all dep clean install:
+ $(MAKE) -C mkdosfs $@
+ $(MAKE) -C dosfsck $@
+
+distclean:
+ $(MAKE) -C mkdosfs $@
+ $(MAKE) -C dosfsck $@
+ rm -f TAGS .#* .new* \#*# *~
+
+TAGS:
+ etags -d -T `find . -name '*.[ch]'`
+
+dist: binary tar
+
+tar: distclean
+ cd ..; \
+ name="$(notdir $(shell pwd))"; \
+ namev="$$name-$(shell perl -ne 'print "$$1\n" if /VERSION.*"(\S+)"/;' version.h)"; \
+ mv $$name $$namev; \
+ tar cf $$namev.src.tar `find $$namev \( -name CVS -o -path $$namev/debian \) -prune -o ! -type d -print`; \
+ gzip -9f $$namev.src.tar; \
+ mv $$namev $$name
+
+binary: all
+ doit=""; [ root = "`whoami`" ] || doit=sudo; $$doit $(MAKE) binary-sub
+ cd tmp; \
+ name="$(notdir $(shell pwd))"; \
+ namev="$$name-$(shell perl -ne 'print "$$1\n" if /VERSION.*"(\S+)"/;' version.h)"; \
+ arch=`uname -m | sed 's/i.86/i386/'`; \
+ nameva=$$namev.$$arch.tar; \
+ tar cf ../../$$nameva * ; \
+ gzip -9f ../../$$nameva
+ doit=""; [ root = "`whoami`" ] || doit=sudo; $$doit rm -rf tmp
+
+binary-sub:
+ @[ root = "`whoami`" ] || (echo "Must be root for this!"; exit 1)
+ mkdir -p tmp/$(SBINDIR) tmp/$(MANDIR)
+ $(MAKE) install PREFIX=$(shell pwd)/tmp
+
+# usage: make diff OLDVER=<last-release-number>
+diff:
+ @if [ "x$(OLDVER)" = "x" ]; then \
+ echo "Usage: make diff OLDVER=<last-release-number>"; \
+ exit 1; \
+ fi; \
+ name="$(notdir $(shell pwd))"; \
+ namev="$$name-$(shell perl -ne 'print "$$1\n" if /VERSION.*"(\S+)"/;' version.h)"; \
+ cvs diff -u -rRELEASE-$(OLDVER) >../$$namev.diff; \
+ gzip -9f ../$$namev.diff
+
+
+# usage: make release VER=<release-number>
+release:
+ @if [ "x$(VER)" = "x" ]; then \
+ echo "Usage: make release VER=<release-number>"; \
+ exit 1; \
+ fi
+ if [ -d CVS ]; then \
+ modified=`cvs status 2>/dev/null | awk '/Status:/ { if ($$4 != "Up-to-date") print $$2 }'`; \
+ if [ "x$$modified" != "x" ]; then \
+ echo "There are modified files: $$modified"; \
+ echo "Commit first"; \
+ exit 1; \
+ fi; \
+ fi
+ sed "/VERSION/s/\".*\"/\"$(VER)\"/" <version.h >version.h.tmp
+ date="`date +'%d %b %Y'`"; sed "/VERSION_DATE/s/\".*\"/\"$$date\"/" <version.h.tmp >version.h
+ rm version.h.tmp
+ if [ -d CVS ]; then \
+ cvs commit -m"Raised version to $(VER)" version.h; \
+ cvs tag -c -F RELEASE-`echo $(VER) | sed 's/\./-/g'`; \
+ fi
-.PHONY: build rebuild install install-bin install-doc install-man uninstall uninstall-bin uninstall-doc uninstall-man reinstall clean distclean
diff --git a/doc/README.dosfstools-2.x b/README.Atari
index 5fb00ed..5fb00ed 100644
--- a/doc/README.dosfstools-2.x
+++ b/README.Atari
diff --git a/doc/TODO.dosfstools-2.x b/TODO
index dbc2de0..819a1ed 100644
--- a/doc/TODO.dosfstools-2.x
+++ b/TODO
@@ -12,3 +12,4 @@
- dosfsck: read-only sector test (-t without -a or -r); just print
out errors.
+
diff --git a/build b/build
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/build
diff --git a/dosfsck/.cvsignore b/dosfsck/.cvsignore
new file mode 100644
index 0000000..d921321
--- /dev/null
+++ b/dosfsck/.cvsignore
@@ -0,0 +1 @@
+dosfsck
diff --git a/doc/ChangeLog.dosfsck b/dosfsck/CHANGES
index f628ac2..f628ac2 100644
--- a/doc/ChangeLog.dosfsck
+++ b/dosfsck/CHANGES
diff --git a/dosfsck/COPYING b/dosfsck/COPYING
new file mode 100644
index 0000000..2ac1825
--- /dev/null
+++ b/dosfsck/COPYING
@@ -0,0 +1,345 @@
+The license below applies to dosfsck, which is copyrighted by
+Werner Almesberger <almesber@lrc.di.epfl.ch> and Roman Hodek
+<Roman.Hodek@informatik.uni-erlangen.de>.
+
+
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) 19yy <name of author>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) 19yy name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Library General
+Public License instead of this License.
diff --git a/dosfsck/Makefile b/dosfsck/Makefile
new file mode 100644
index 0000000..1fe06be
--- /dev/null
+++ b/dosfsck/Makefile
@@ -0,0 +1,44 @@
+
+OBJECTS = boot.o check.o common.o dosfsck.o fat.o file.o io.o lfn.o
+
+all: dosfsck
+
+dosfsck: $(OBJECTS)
+ $(CC) -o $@ $(LDFLAGS) $^
+
+.c.o:
+ $(CC) -c $(CFLAGS) $*.c
+
+install: dosfsck
+ mkdir -p $(SBINDIR) $(MANDIR)
+ install -m 755 dosfsck $(SBINDIR)
+ install -m 644 dosfsck.8 $(MANDIR)
+ rm -f $(SBINDIR)/fsck.msdos
+ rm -f $(SBINDIR)/fsck.vfat
+ ln -s dosfsck $(SBINDIR)/fsck.msdos
+ ln -s dosfsck $(SBINDIR)/fsck.vfat
+ rm -f $(MANDIR)/fsck.msdos.8
+ ln -s dosfsck.8 $(MANDIR)/fsck.msdos.8
+ ln -s dosfsck.8 $(MANDIR)/fsck.vfat.8
+
+clean:
+ rm -f *.o *.s *.i *~ \#*# tmp_make .#* .new*
+
+distclean: clean
+ rm -f *.a dosfsck
+
+dep:
+ sed '/\#\#\# Dependencies/q' <Makefile >tmp_make
+ $(CPP) $(CFLAGS) -MM *.c >>tmp_make
+ mv tmp_make Makefile
+
+### Dependencies
+boot.o: boot.c common.h dosfsck.h io.h boot.h
+check.o: check.c common.h dosfsck.h io.h fat.h file.h lfn.h check.h
+common.o: common.c common.h
+dosfsck.o: dosfsck.c common.h dosfsck.h io.h boot.h fat.h file.h \
+ check.h
+fat.o: fat.c common.h dosfsck.h io.h check.h fat.h
+file.o: file.c common.h file.h
+io.o: io.c dosfsck.h common.h io.h
+lfn.o: lfn.c common.h io.h dosfsck.h lfn.h file.h
diff --git a/doc/README.dosfsck b/dosfsck/README
index 7b351aa..7b351aa 100644
--- a/doc/README.dosfsck
+++ b/dosfsck/README
diff --git a/src/boot.c b/dosfsck/boot.c
index f5113e9..704b64d 100644
--- a/src/boot.c
+++ b/dosfsck/boot.c
@@ -1,24 +1,6 @@
-/* boot.c - Read and analyze ia PC/MS-DOS boot sector
+/* boot.c - Read and analyze ia PC/MS-DOS boot sector */
- Copyright (C) 1993 Werner Almesberger <werner.almesberger@lrc.di.epfl.ch>
- Copyright (C) 1998 Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de>
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- On Debian systems, the complete text of the GNU General Public License
- can be found in /usr/share/common-licenses/GPL-3 file.
-*/
+/* Written 1993 by Werner Almesberger */
/* FAT32, VFAT, Atari format support, and various fixes additions May 1998
* by Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de> */
@@ -26,12 +8,9 @@
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
-#include <stdlib.h>
-#include <time.h>
#include "common.h"
#include "dosfsck.h"
-#include "fat.h"
#include "io.h"
#include "boot.h"
@@ -39,10 +18,6 @@
#define ROUND_TO_MULTIPLE(n,m) ((n) && (m) ? (n)+(m)-1-((n)-1)%(m) : 0)
/* don't divide by zero */
-/* cut-over cluster counts for FAT12 and FAT16 */
-#define FAT12_THRESHOLD 4085
-#define FAT16_THRESHOLD 65525
-
static struct {
__u8 media;
char *descr;
@@ -59,15 +34,13 @@ static struct {
{ 0xff, "5.25\" 320k floppy 2s/40tr/8sec" },
};
-#if defined __alpha || defined __arm || defined __arm__ || defined __ia64__ || defined __s390x__ \
- || defined __x86_64__ || defined __ppc64__ || defined __bfin__ \
- || defined __MICROBLAZE__
+#if defined __alpha || defined __ia64__ || defined __s390x__ || defined __x86_64__ || defined __ppc64__
/* Unaligned fields must first be copied byte-wise */
#define GET_UNALIGNED_W(f) \
({ \
unsigned short __v; \
memcpy( &__v, &f, sizeof(__v) ); \
- CF_LE_W( *(unsigned short *)&__v ); \
+ CF_LE_W( *(unsigned short *)&f ); \
})
#else
#define GET_UNALIGNED_W(f) CF_LE_W( *(unsigned short *)&f )
@@ -88,7 +61,7 @@ static char *get_media_descr( unsigned char media )
static void dump_boot(DOS_FS *fs,struct boot_sector *b,unsigned lss)
{
unsigned short sectors;
-
+
printf("Boot sector contents:\n");
if (!atari_format) {
char id[9];
@@ -167,14 +140,14 @@ static void check_backup_boot(DOS_FS *fs, struct boot_sector *b, int lss)
fs->backupboot_start = bbs*lss;
b->backup_boot = CT_LE_W(bbs);
fs_write(fs->backupboot_start,sizeof(*b),b);
- fs_write((loff_t)offsetof(struct boot_sector,backup_boot),
+ fs_write((off_t)offsetof(struct boot_sector,backup_boot),
sizeof(b->backup_boot),&b->backup_boot);
printf( "Created backup of boot sector in sector %d\n", bbs );
return;
}
else return;
}
-
+
fs_read(fs->backupboot_start,sizeof(b2),&b2);
if (memcmp(b,&b2,sizeof(b2)) != 0) {
/* there are any differences */
@@ -242,9 +215,9 @@ static void read_fsinfo(DOS_FS *fs, struct boot_sector *b,int lss)
if (s != CF_LE_W(b->backup_boot)) break;
if (s > 0 && s < CF_LE_W(b->reserved)) {
init_fsinfo(&i);
- fs_write((loff_t)s*lss,sizeof(i),&i);
+ fs_write((off_t)s*lss,sizeof(i),&i);
b->info_sector = CT_LE_W(s);
- fs_write((loff_t)offsetof(struct boot_sector,info_sector),
+ fs_write((off_t)offsetof(struct boot_sector,info_sector),
sizeof(b->info_sector),&b->info_sector);
if (fs->backupboot_start)
fs_write(fs->backupboot_start+
@@ -259,10 +232,10 @@ static void read_fsinfo(DOS_FS *fs, struct boot_sector *b,int lss)
}
else return;
}
-
+
fs->fsinfo_start = CF_LE_W(b->info_sector)*lss;
fs_read(fs->fsinfo_start,sizeof(i),&i);
-
+
if (i.magic != CT_LE_L(0x41615252) ||
i.signature != CT_LE_L(0x61417272) ||
i.boot_sign != CT_LE_W(0xaa55)) {
@@ -299,19 +272,11 @@ void read_boot(DOS_FS *fs)
unsigned total_sectors;
unsigned short logical_sector_size, sectors;
unsigned fat_length;
- loff_t data_size;
+ off_t data_size;
fs_read(0,sizeof(b),&b);
logical_sector_size = GET_UNALIGNED_W(b.sector_size);
if (!logical_sector_size) die("Logical sector size is zero.");
-
- /* This was moved up because it's the first thing that will fail */
- /* if the platform needs special handling of unaligned multibyte accesses */
- /* but such handling isn't being provided. See GET_UNALIGNED_W() above. */
- if (logical_sector_size & (SECTOR_SIZE-1))
- die("Logical sector size (%d bytes) is not a multiple of the physical "
- "sector size.",logical_sector_size);
-
fs->cluster_size = b.cluster_size*logical_sector_size;
if (!fs->cluster_size) die("Cluster size is zero.");
if (b.fats != 2 && b.fats != 1)
@@ -321,17 +286,17 @@ void read_boot(DOS_FS *fs)
total_sectors = sectors ? sectors : CF_LE_L(b.total_sect);
if (verbose) printf("Checking we can access the last sector of the filesystem\n");
/* Can't access last odd sector anyway, so round down */
- fs_test((loff_t)((total_sectors & ~1)-1)*(loff_t)logical_sector_size,
+ fs_test((off_t)((total_sectors & ~1)-1)*(off_t)logical_sector_size,
logical_sector_size);
fat_length = CF_LE_W(b.fat_length) ?
CF_LE_W(b.fat_length) : CF_LE_L(b.fat32_length);
- fs->fat_start = (loff_t)CF_LE_W(b.reserved)*logical_sector_size;
- fs->root_start = ((loff_t)CF_LE_W(b.reserved)+b.fats*fat_length)*
+ fs->fat_start = (off_t)CF_LE_W(b.reserved)*logical_sector_size;
+ fs->root_start = ((off_t)CF_LE_W(b.reserved)+b.fats*fat_length)*
logical_sector_size;
fs->root_entries = GET_UNALIGNED_W(b.dir_entries);
fs->data_start = fs->root_start+ROUND_TO_MULTIPLE(fs->root_entries <<
MSDOS_DIR_BITS,logical_sector_size);
- data_size = (loff_t)total_sectors*logical_sector_size-fs->data_start;
+ data_size = (off_t)total_sectors*logical_sector_size-fs->data_start;
fs->clusters = data_size/fs->cluster_size;
fs->root_cluster = 0; /* indicates standard, pre-FAT32 root dir */
fs->fsinfo_start = 0; /* no FSINFO structure */
@@ -346,33 +311,23 @@ void read_boot(DOS_FS *fs)
* warning, but convertig to a root dir in a cluster chain seems
* to complex for now... */
printf( "Warning: FAT32 root dir not in cluster chain! "
- "Compatibility mode...\n" );
+ "Compability mode...\n" );
else if (!fs->root_cluster && !fs->root_entries)
die("No root directory!");
else if (fs->root_cluster && fs->root_entries)
printf( "Warning: FAT32 root dir is in a cluster chain, but "
"a separate root dir\n"
" area is defined. Cannot fix this easily.\n" );
- if (fs->clusters < FAT16_THRESHOLD)
- printf("Warning: Filesystem is FAT32 according to fat_length "
- "and fat32_length fields,\n"
- " but has only %lu clusters, less than the required "
- "minimum of %d.\n"
- " This may lead to problems on some systems.\n",
- fs->clusters, FAT16_THRESHOLD);
fs->backupboot_start = CF_LE_W(b.backup_boot)*logical_sector_size;
check_backup_boot(fs,&b,logical_sector_size);
-
+
read_fsinfo(fs,&b,logical_sector_size);
}
else if (!atari_format) {
/* On real MS-DOS, a 16 bit FAT is used whenever there would be too
* much clusers otherwise. */
- fs->fat_bits = (fs->clusters >= FAT12_THRESHOLD) ? 16 : 12;
- if (fs->clusters >= FAT16_THRESHOLD)
- die("Too many clusters (%lu) for FAT16 filesystem.",
- fs->clusters);
+ fs->fat_bits = (fs->clusters > MSDOS_FAT12) ? 16 : 12;
}
else {
/* On Atari, things are more difficult: GEMDOS always uses 12bit FATs
@@ -393,21 +348,6 @@ void read_boot(DOS_FS *fs)
/* On FAT32, the high 4 bits of a FAT entry are reserved */
fs->eff_fat_bits = (fs->fat_bits == 32) ? 28 : fs->fat_bits;
fs->fat_size = fat_length*logical_sector_size;
-
- fs->label = calloc(12, sizeof (__u8));
- if (fs->fat_bits == 12 || fs->fat_bits == 16) {
- struct boot_sector_16 *b16 = (struct boot_sector_16 *)&b;
- if (b16->extended_sig == 0x29)
- memmove(fs->label, b16->label, 11);
- else
- fs->label = NULL;
- } else if (fs->fat_bits == 32) {
- if (b.extended_sig == 0x29)
- memmove(fs->label, &b.label, 11);
- else
- fs->label = NULL;
- }
-
if (fs->clusters > ((unsigned long long)fs->fat_size*8/fs->fat_bits)-2)
die("File system has %d clusters but only space for %d FAT entries.",
fs->clusters,((unsigned long long)fs->fat_size*8/fs->fat_bits)-2);
@@ -419,98 +359,12 @@ void read_boot(DOS_FS *fs)
if (logical_sector_size & (SECTOR_SIZE-1))
die("Logical sector size (%d bytes) is not a multiple of the physical "
"sector size.",logical_sector_size);
-#if 0 /* linux kernel doesn't check that either */
/* ++roman: On Atari, these two fields are often left uninitialized */
if (!atari_format && (!b.secs_track || !b.heads))
die("Invalid disk format in boot sector.");
-#endif
if (verbose) dump_boot(fs,&b,logical_sector_size);
}
-static void write_boot_label(DOS_FS *fs, char *label)
-{
- struct boot_sector b;
- struct boot_sector_16 *b16 = (struct boot_sector_16 *)&b;
-
- fs_read(0, sizeof(b), &b);
- if (fs->fat_bits == 12 || fs->fat_bits == 16) {
- if (b16->extended_sig != 0x29) {
- b16->extended_sig = 0x29;
- b16->serial = 0;
- memmove(b16->fs_type, fs->fat_bits == 12 ?"FAT12 ":"FAT16 ", 8);
- }
- memmove(b16->label, label, 11);
- } else if (fs->fat_bits == 32) {
- if (b.extended_sig != 0x29) {
- b.extended_sig = 0x29;
- b.serial = 0;
- memmove(b.fs_type, "FAT32 ", 8);
- }
- memmove(b.label, label, 11);
- }
- fs_write(0, sizeof(b), &b);
- if (fs->fat_bits == 32 && fs->backupboot_start)
- fs_write(fs->backupboot_start, sizeof(b), &b);
-}
-
-static loff_t find_volume_de(DOS_FS *fs, DIR_ENT *de)
-{
- unsigned long cluster;
- loff_t offset;
- int i;
-
- if (fs->root_cluster) {
- for (cluster = fs->root_cluster;
- cluster != 0 && cluster != -1;
- cluster = next_cluster(fs, cluster)) {
- offset = cluster_start(fs, cluster);
- for (i = 0; i * sizeof(DIR_ENT) < fs->cluster_size; i++) {
- fs_read(offset, sizeof(DIR_ENT), de);
- if (de->attr & ATTR_VOLUME)
- return offset;
- offset += sizeof(DIR_ENT);
- }
- }
- } else {
- for (i = 0; i < fs->root_entries; i++) {
- offset = fs->root_start + i * sizeof(DIR_ENT);
- fs_read(offset, sizeof(DIR_ENT), de);
- if (de->attr & ATTR_VOLUME)
- return offset;
- }
- }
-
- return 0;
-}
-
-static void write_volume_label(DOS_FS *fs, char *label)
-{
- time_t now = time(NULL);
- struct tm *mtime = localtime(&now);
- loff_t offset;
- DIR_ENT de;
-
- offset = find_volume_de(fs, &de);
- if (offset == 0)
- return;
-
- memcpy(de.name, label, 11);
- de.time = CT_LE_W((unsigned short)((mtime->tm_sec >> 1) +
- (mtime->tm_min << 5) +
- (mtime->tm_hour << 11)));
- de.date = CT_LE_W((unsigned short)(mtime->tm_mday +
- ((mtime->tm_mon+1) << 5) +
- ((mtime->tm_year-80) << 9)));
- fs_write(offset, sizeof(DIR_ENT), &de);
-}
-
-void write_label(DOS_FS *fs, char *label)
-{
- int l = strlen(label);
-
- while (l < 11)
- label[l++] = ' ';
-
- write_boot_label(fs, label);
- write_volume_label(fs, label);
-}
+/* Local Variables: */
+/* tab-width: 8 */
+/* End: */
diff --git a/dosfsck/boot.h b/dosfsck/boot.h
new file mode 100644
index 0000000..0540c70
--- /dev/null
+++ b/dosfsck/boot.h
@@ -0,0 +1,13 @@
+/* boot.h - Read and analyze ia PC/MS-DOS boot sector */
+
+/* Written 1993 by Werner Almesberger */
+
+
+#ifndef _BOOT_H
+#define _BOOT_H
+
+void read_boot(DOS_FS *fs);
+
+/* Reads the boot sector from the currently open device and initializes *FS */
+
+#endif
diff --git a/src/check.c b/dosfsck/check.c
index d6c54c1..e8c13bb 100644
--- a/src/check.c
+++ b/dosfsck/check.c
@@ -1,24 +1,6 @@
-/* check.c - Check and repair a PC/MS-DOS file system
+/* check.c - Check and repair a PC/MS-DOS file system */
- Copyright (C) 1993 Werner Almesberger <werner.almesberger@lrc.di.epfl.ch>
- Copyright (C) 1998 Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de>
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- On Debian systems, the complete text of the GNU General Public License
- can be found in /usr/share/common-licenses/GPL-3 file.
-*/
+/* Written 1993 by Werner Almesberger */
/* FAT32, VFAT, Atari format support, and various fixes additions May 1998
* by Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de> */
@@ -87,7 +69,7 @@ loff_t alloc_rootdir_entry(DOS_FS *fs, DIR_ENT *de, const char *pattern)
int i = 0, got = 0;
unsigned long clu_num, prev = 0;
loff_t offset2;
-
+
clu_num = fs->root_cluster;
offset = cluster_start(fs,clu_num);
while (clu_num > 0 && clu_num != -1) {
@@ -111,11 +93,8 @@ loff_t alloc_rootdir_entry(DOS_FS *fs, DIR_ENT *de, const char *pattern)
if (!prev)
die("Root directory has no cluster allocated!");
for (clu_num = prev+1; clu_num != prev; clu_num++) {
- FAT_ENTRY entry;
-
if (clu_num >= fs->clusters+2) clu_num = 2;
- get_fat(&entry, fs->fat, clu_num, fs);
- if (!entry.value)
+ if (!fs->fat[clu_num].value)
break;
}
if (clu_num == prev)
@@ -131,10 +110,7 @@ loff_t alloc_rootdir_entry(DOS_FS *fs, DIR_ENT *de, const char *pattern)
}
memset(de,0,sizeof(DIR_ENT));
while (1) {
- char expanded[12];
- sprintf(expanded, pattern, curr_num);
- memcpy(de->name+4, expanded, 4);
- memcpy(de->ext, expanded+4, 3);
+ sprintf(de->name,pattern,curr_num);
clu_num = fs->root_cluster;
i = 0;
offset2 = cluster_start(fs,clu_num);
@@ -189,27 +165,15 @@ loff_t alloc_rootdir_entry(DOS_FS *fs, DIR_ENT *de, const char *pattern)
}
-/**
- * Construct a full path (starting with '/') for the specified dentry,
- * relative to the partition. All components are "long" names where possible.
- *
- * @param[in] file Information about dentry (file or directory) of interest
- *
- * return Pointer to static string containing file's full path
- */
static char *path_name(DOS_FILE *file)
{
static char path[PATH_MAX*2];
- if (!file) *path = 0; /* Reached the root directory */
+ if (!file) *path = 0;
else {
if (strlen(path_name(file->parent)) > PATH_MAX)
die("Path name too long.");
if (strcmp(path,"/") != 0) strcat(path,"/");
-
- /* Append the long name to the path,
- * or the short name if there isn't a long one
- */
strcpy(strrchr(path,0),file->lfn?file->lfn:file_name(file->dir_ent.name));
}
return path;
@@ -253,21 +217,16 @@ static char *file_stat(DOS_FILE *file)
}
-static int bad_name(DOS_FILE *file)
+static int bad_name(unsigned char *name)
{
int i, spc, suspicious = 0;
char *bad_chars = atari_format ? "*?\\/:" : "*?<>|\"\\/:";
- unsigned char *name = file->dir_ent.name;
/* Do not complain about (and auto-correct) the extended attribute files
* of OS/2. */
if (strncmp(name,"EA DATA SF",11) == 0 ||
strncmp(name,"WP ROOT SF",11) == 0) return 0;
-
- /* don't complain about the dummy 11 bytes used by patched Linux
- kernels */
- if (file->dir_ent.lcase & FAT_NO_83NAME) return 0;
-
+
for (i = 0; i < 8; i++) {
if (name[i] < ' ' || name[i] == 0x7f) return 1;
if (name[i] > 0x7f) ++suspicious;
@@ -303,37 +262,21 @@ static int bad_name(DOS_FILE *file)
/* Under GEMDOS, chars >= 128 are never allowed. */
if (atari_format && suspicious)
return 1;
-
- /* Under MS-DOS and Windows, chars >= 128 in short names are valid
- * (but these characters can be visualised differently depending on
- * local codepage: CP437, CP866, etc). The chars are all basically ok,
- * so we shouldn't auto-correct such names. */
+
+ /* Only complain about too much suspicious chars in interactive mode,
+ * never correct them automatically. The chars are all basically ok, so we
+ * shouldn't auto-correct such names. */
+ if (interactive && suspicious > 6)
+ return 1;
return 0;
}
-static void lfn_remove(loff_t from, loff_t to)
-{
- int i;
- DIR_ENT empty;
-
- /* New dir entry is zeroed except first byte, which is set to 0xe5.
- * This is to avoid that some FAT-reading OSes (not Linux! ;) stop reading
- * a directory at the first zero entry...
- */
- memset( &empty, 0, sizeof(empty) );
- empty.name[0] = DELETED_FLAG;
-
- for( ; from < to; from += sizeof(empty) ) {
- fs_write( from, sizeof(DIR_ENT), &empty );
- }
-}
static void drop_file(DOS_FS *fs,DOS_FILE *file)
{
unsigned long cluster;
MODIFY(file,name[0],DELETED_FLAG);
- if (file->lfn) lfn_remove(file->lfn_offset, file->offset);
for (cluster = FSTART(file,fs); cluster > 0 && cluster <
fs->clusters+2; cluster = next_cluster(fs,cluster))
set_owner(fs,cluster,NULL);
@@ -345,7 +288,7 @@ static void truncate_file(DOS_FS *fs,DOS_FILE *file,unsigned long clusters)
{
int deleting;
unsigned long walk,next,prev;
-
+
walk = FSTART(file,fs);
prev = 0;
if ((deleting = !clusters)) MODIFY_START(file,0,fs);
@@ -362,29 +305,22 @@ static void truncate_file(DOS_FS *fs,DOS_FILE *file,unsigned long clusters)
static void auto_rename(DOS_FILE *file)
{
DOS_FILE *first,*walk;
- unsigned long int number;
+ int number;
if (!file->offset) return; /* cannot rename FAT32 root dir */
first = file->parent ? file->parent->first : root;
number = 0;
while (1) {
- char num[8];
- sprintf(num, "%07d", number);
- memcpy(file->dir_ent.name, "FSCK", 4);
- memcpy(file->dir_ent.name+4, num, 4);
- memcpy(file->dir_ent.ext, num+4, 3);
+ sprintf(file->dir_ent.name,"FSCK%04d",number);
+ strncpy(file->dir_ent.ext,"REN",3);
for (walk = first; walk; walk = walk->next)
if (walk != file && !strncmp(walk->dir_ent.name,file->dir_ent.
name,MSDOS_NAME)) break;
if (!walk) {
fs_write(file->offset,MSDOS_NAME,file->dir_ent.name);
- if (file->lfn) lfn_fix_checksum(file->lfn_offset, file->offset, file->dir_ent.name);
return;
}
number++;
- if (number > 9999999) {
- die("Too many files need repair.");
- }
}
die("Can't generate a unique name.");
}
@@ -410,7 +346,6 @@ static void rename_file(DOS_FILE *file)
for (walk = name; *walk == ' ' || *walk == '\t'; walk++);
if (file_cvt(walk,file->dir_ent.name)) {
fs_write(file->offset,MSDOS_NAME,file->dir_ent.name);
- if (file->lfn) lfn_fix_checksum(file->lfn_offset, file->offset, file->dir_ent.name);
return;
}
}
@@ -505,12 +440,9 @@ static int check_file(DOS_FS *fs,DOS_FILE *file)
clusters = prev = 0;
for (curr = FSTART(file,fs) ? FSTART(file,fs) :
-1; curr != -1; curr = next_cluster(fs,curr)) {
- FAT_ENTRY curEntry;
- get_fat(&curEntry, fs->fat, curr, fs);
-
- if (!curEntry.value || bad_cluster(fs,curr)) {
+ if (!fs->fat[curr].value || bad_cluster(fs,curr)) {
printf("%s\n Contains a %s cluster (%lu). Assuming EOF.\n",
- path_name(file), curEntry.value ? "bad" : "free",curr);
+ path_name(file),fs->fat[curr].value ? "bad" : "free",curr);
if (prev) set_fat(fs,prev,-1);
else if (!file->offset)
die( "FAT32 root dir starts with a bad cluster!" );
@@ -518,10 +450,10 @@ static int check_file(DOS_FS *fs,DOS_FILE *file)
break;
}
if (!(file->dir_ent.attr & ATTR_DIR) && CF_LE_L(file->dir_ent.size) <=
- (unsigned long long)clusters*fs->cluster_size) {
- printf("%s\n File size is %u bytes, cluster chain length is > %llu "
+ clusters*fs->cluster_size) {
+ printf("%s\n File size is %u bytes, cluster chain length is > %lu "
"bytes.\n Truncating file to %u bytes.\n",path_name(file),
- CF_LE_L(file->dir_ent.size),(unsigned long long)clusters*fs->cluster_size,
+ CF_LE_L(file->dir_ent.size),clusters*fs->cluster_size,
CF_LE_L(file->dir_ent.size));
truncate_file(fs,file,clusters);
break;
@@ -537,20 +469,20 @@ static int check_file(DOS_FS *fs,DOS_FILE *file)
else clusters2++;
restart = file->dir_ent.attr & ATTR_DIR;
if (!owner->offset) {
- printf( " Truncating second to %llu bytes because first "
- "is FAT32 root dir.\n", (unsigned long long)clusters2*fs->cluster_size );
+ printf( " Truncating second to %lu bytes because first "
+ "is FAT32 root dir.\n", clusters2*fs->cluster_size );
do_trunc = 2;
}
else if (!file->offset) {
- printf( " Truncating first to %llu bytes because second "
- "is FAT32 root dir.\n", (unsigned long long)clusters*fs->cluster_size );
+ printf( " Truncating first to %lu bytes because second "
+ "is FAT32 root dir.\n", clusters*fs->cluster_size );
do_trunc = 1;
}
else if (interactive)
- printf("1) Truncate first to %llu bytes%s\n"
- "2) Truncate second to %llu bytes\n",(unsigned long long)clusters*fs->cluster_size,
- restart ? " and restart" : "",(unsigned long long)clusters2*fs->cluster_size);
- else printf(" Truncating second to %llu bytes.\n",(unsigned long long)clusters2*
+ printf("1) Truncate first to %lu bytes%s\n"
+ "2) Truncate second to %lu bytes\n",clusters*fs->cluster_size,
+ restart ? " and restart" : "",clusters2*fs->cluster_size);
+ else printf(" Truncating second to %lu bytes.\n",clusters2*
fs->cluster_size);
if (do_trunc != 2 &&
(do_trunc == 1 ||
@@ -562,13 +494,12 @@ static int check_file(DOS_FS *fs,DOS_FILE *file)
if (this == curr) {
if (prev) set_fat(fs,prev,-1);
else MODIFY_START(owner,0,fs);
- MODIFY(owner,size,CT_LE_L((unsigned long long)clusters*fs->cluster_size));
+ MODIFY(owner,size,CT_LE_L(clusters*fs->cluster_size));
if (restart) return 1;
while (this > 0 && this != -1) {
set_owner(fs,this,NULL);
this = next_cluster(fs,this);
}
- this = curr;
break;
}
clusters++;
@@ -589,11 +520,11 @@ static int check_file(DOS_FS *fs,DOS_FILE *file)
prev = curr;
}
if (!(file->dir_ent.attr & ATTR_DIR) && CF_LE_L(file->dir_ent.size) >
- (unsigned long long)clusters*fs->cluster_size) {
- printf("%s\n File size is %u bytes, cluster chain length is %llu bytes."
+ clusters*fs->cluster_size) {
+ printf("%s\n File size is %u bytes, cluster chain length is %lu bytes."
"\n Truncating file to %lu bytes.\n",path_name(file),CF_LE_L(file->
- dir_ent.size),(unsigned long long)clusters*fs->cluster_size,(unsigned long long)clusters*fs->cluster_size);
- MODIFY(file,size,CT_LE_L((unsigned long long)clusters*fs->cluster_size));
+ dir_ent.size),clusters*fs->cluster_size,clusters*fs->cluster_size);
+ MODIFY(file,size,CT_LE_L(clusters*fs->cluster_size));
}
return 0;
}
@@ -619,7 +550,7 @@ static int check_dir(DOS_FS *fs,DOS_FILE **root,int dots)
parent = (*root)->parent;
good = bad = 0;
for (walk = root; *walk; walk = &(*walk)->next)
- if (bad_name(*walk)) bad++;
+ if (bad_name((*walk)->dir_ent.name)) bad++;
else good++;
if (*root && parent && good+bad > 4 && bad > good/2) {
printf("%s\n Has a large number of bad entries. (%d/%d)\n",
@@ -646,9 +577,8 @@ static int check_dir(DOS_FS *fs,DOS_FILE **root,int dots)
else dotdot++;
}
if (!((*walk)->dir_ent.attr & ATTR_VOLUME) &&
- bad_name(*walk)) {
- puts(path_name(*walk));
- printf(" Bad short file name (%s).\n", file_name((*walk)->dir_ent.name));
+ bad_name((*walk)->dir_ent.name)) {
+ printf("%s\n Bad file name.\n",path_name(*walk));
if (interactive)
printf("1) Drop file\n2) Rename file\n3) Auto-rename\n"
"4) Keep it\n");
@@ -677,7 +607,7 @@ static int check_dir(DOS_FS *fs,DOS_FILE **root,int dots)
skip = 0;
while (*scan && !skip) {
if (!((*scan)->dir_ent.attr & ATTR_VOLUME) &&
- !memcmp((*walk)->dir_ent.name,(*scan)->dir_ent.name,MSDOS_NAME)) {
+ !strncmp((*walk)->dir_ent.name,(*scan)->dir_ent.name,MSDOS_NAME)) {
printf("%s\n Duplicate directory entry.\n First %s\n",
path_name(*walk),file_stat(*walk));
printf(" Second %s\n",file_stat(*scan));
@@ -738,15 +668,6 @@ static int check_dir(DOS_FS *fs,DOS_FILE **root,int dots)
}
-/**
- * Check a dentry's cluster chain for bad clusters.
- * If requested, we verify readability and mark unreadable clusters as bad.
- *
- * @param[inout] fs Information about the filesystem
- * @param[in] file dentry to check
- * @param[in] read_test Nonzero == verify that dentry's clusters can
- * be read
- */
static void test_file(DOS_FS *fs,DOS_FILE *file,int read_test)
{
DOS_FILE *owner;
@@ -756,11 +677,6 @@ static void test_file(DOS_FS *fs,DOS_FILE *file,int read_test)
for (walk = FSTART(file,fs); walk > 0 && walk < fs->clusters+2;
walk = next_clu) {
next_clu = next_cluster(fs,walk);
-
- /* In this stage we are checking only for a loop within our own
- * cluster chain.
- * Cross-linking of clusters is handled in check_file()
- */
if ((owner = get_owner(fs,walk))) {
if (owner == file) {
printf("%s\n Circular cluster chain. Truncating to %lu "
@@ -789,7 +705,6 @@ static void test_file(DOS_FS *fs,DOS_FILE *file,int read_test)
}
set_owner(fs,walk,file);
}
- /* Revert ownership (for now) */
for (walk = FSTART(file,fs); walk > 0 && walk < fs->clusters+2;
walk = next_cluster(fs,walk))
if (bad_cluster(fs,walk)) break;
@@ -805,28 +720,18 @@ static void undelete(DOS_FS *fs,DOS_FILE *file)
clusters = left = (CF_LE_L(file->dir_ent.size)+fs->cluster_size-1)/
fs->cluster_size;
prev = 0;
-
- walk = FSTART(file,fs);
-
- while (left && (walk >= 2) && (walk < fs->clusters+2)) {
-
- FAT_ENTRY curEntry;
- get_fat(&curEntry, fs->fat, walk, fs);
-
- if (!curEntry.value)
- break;
-
+ for (walk = FSTART(file,fs); left && walk >= 2 && walk <
+ fs->clusters+2 && !fs->fat[walk].value; walk++) {
left--;
if (prev) set_fat(fs,prev,walk);
prev = walk;
- walk++;
}
if (prev) set_fat(fs,prev,-1);
else MODIFY_START(file,0,fs);
if (left)
printf("Warning: Did only undelete %lu of %lu cluster%s.\n",clusters-left,
clusters,clusters == 1 ? "" : "s");
-
+
}
@@ -836,19 +741,6 @@ static void new_dir( void )
}
-/**
- * Create a description for a referenced dentry and insert it in our dentry
- * tree. Then, go check the dentry's cluster chain for bad clusters and
- * cluster loops.
- *
- * @param[inout] fs Information about the filesystem
- * @param[out] chain
- * @param[in] parent Information about parent directory of this file
- * NULL == no parent ('file' is root directory)
- * @param[in] offset Partition-relative byte offset of directory entry of interest
- * 0 == Root directory
- * @param cp
- */
static void add_file(DOS_FS *fs,DOS_FILE ***chain,DOS_FILE *parent,
loff_t offset,FDSC **cp)
{
@@ -859,7 +751,6 @@ static void add_file(DOS_FS *fs,DOS_FILE ***chain,DOS_FILE *parent,
if (offset)
fs_read(offset,sizeof(DIR_ENT),&de);
else {
- /* Construct a DIR_ENT for the root directory */
memcpy(de.name," ",MSDOS_NAME);
de.attr = ATTR_DIR;
de.size = de.time = de.date = 0;
@@ -881,7 +772,7 @@ static void add_file(DOS_FS *fs,DOS_FILE ***chain,DOS_FILE *parent,
return;
}
new = qalloc(&mem_queue,sizeof(DOS_FILE));
- new->lfn = lfn_get(&de, &new->lfn_offset);
+ new->lfn = lfn_get(&de);
new->offset = offset;
memcpy(&new->dir_ent,&de,sizeof(de));
new->next = new->first = NULL;
@@ -892,15 +783,14 @@ static void add_file(DOS_FS *fs,DOS_FILE ***chain,DOS_FILE *parent,
if (list) {
printf("Checking file %s",path_name(new));
if (new->lfn)
- printf(" (%s)", file_name(new->dir_ent.name) ); /* (8.3) */
+ printf(" (%s)", file_name(new->dir_ent.name) );
printf("\n");
}
- /* Don't include root directory, '.', or '..' in the total file count */
if (offset &&
strncmp(de.name,MSDOS_DOT,MSDOS_NAME) != 0 &&
strncmp(de.name,MSDOS_DOTDOT,MSDOS_NAME) != 0)
++n_files;
- test_file(fs,new,test); /* Bad cluster check */
+ test_file(fs,new,test);
}
@@ -932,16 +822,6 @@ static int scan_dir(DOS_FS *fs,DOS_FILE *this,FDSC **cp)
}
-/**
- * Recursively scan subdirectories of the specified parent directory.
- *
- * @param[inout] fs Information about the filesystem
- * @param[in] parent Identifies the directory to scan
- * @param[in] cp
- *
- * @return 0 Success
- * @return 1 Error
- */
static int subdirs(DOS_FS *fs,DOS_FILE *parent,FDSC **cp)
{
DOS_FILE *walk;
@@ -955,14 +835,6 @@ static int subdirs(DOS_FS *fs,DOS_FILE *parent,FDSC **cp)
}
-/**
- * Scan all directory and file information for errors.
- *
- * @param[inout] fs Information about the filesystem
- *
- * @return 0 Success
- * @return 1 Error
- */
int scan_root(DOS_FS *fs)
{
DOS_FILE **chain;
@@ -983,3 +855,7 @@ int scan_root(DOS_FS *fs)
if (check_files(fs,root)) return 1;
return subdirs(fs,NULL,&fp_root);
}
+
+/* Local Variables: */
+/* tab-width: 8 */
+/* End: */
diff --git a/dosfsck/check.h b/dosfsck/check.h
new file mode 100644
index 0000000..38f1c68
--- /dev/null
+++ b/dosfsck/check.h
@@ -0,0 +1,23 @@
+/* check.h - Check and repair a PC/MS-DOS file system */
+
+/* Written 1993 by Werner Almesberger */
+
+
+#ifndef _CHECK_H
+#define _CHECK_H
+
+loff_t alloc_rootdir_entry(DOS_FS *fs, DIR_ENT *de, const char *pattern);
+
+/* Allocate a free slot in the root directory for a new file. The file name is
+ constructed after 'pattern', which must include a %d type format for printf
+ and expand to exactly 11 characters. The name actually used is written into
+ the 'de' structure, the rest of *de is cleared. The offset returned is to
+ where in the filesystem the entry belongs. */
+
+int scan_root(DOS_FS *fs);
+
+/* Scans the root directory and recurses into all subdirectories. See check.c
+ for all the details. Returns a non-zero integer if the file system has to
+ be checked again. */
+
+#endif
diff --git a/src/common.c b/dosfsck/common.c
index 296b7a7..dd5bc74 100644
--- a/src/common.c
+++ b/dosfsck/common.c
@@ -1,24 +1,6 @@
-/* common.c - Common functions
+/* common.c - Common functions */
- Copyright (C) 1993 Werner Almesberger <werner.almesberger@lrc.di.epfl.ch>
- Copyright (C) 1998 Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de>
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- On Debian systems, the complete text of the GNU General Public License
- can be found in /usr/share/common-licenses/GPL-3 file.
-*/
+/* Written 1993 by Werner Almesberger */
/* FAT32, VFAT, Atari format support, and various fixes additions May 1998
* by Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de> */
@@ -119,3 +101,7 @@ char get_key(char *valid,char *prompt)
printf("Invalid input.\n");
}
}
+
+/* Local Variables: */
+/* tab-width: 8 */
+/* End: */
diff --git a/src/common.h b/dosfsck/common.h
index 99e0be1..0586e07 100644
--- a/src/common.h
+++ b/dosfsck/common.h
@@ -1,25 +1,14 @@
-/* common.h - Common functions
+/* common.h - Common functions */
- Copyright (C) 1993 Werner Almesberger <werner.almesberger@lrc.di.epfl.ch>
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- On Debian systems, the complete text of the GNU General Public License
- can be found in /usr/share/common-licenses/GPL-3 file.
-*/
+/* Written 1993 by Werner Almesberger */
+#include <linux/version.h>
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
+# define __KERNEL__
# include <asm/types.h>
+# undef __KERNEL__
+# define MSDOS_FAT12 4084 /* maximum number of clusters in a 12 bit FAT */
+#endif
#ifndef _COMMON_H
#define _COMMON_H
diff --git a/dosfsck/dosfsck.8 b/dosfsck/dosfsck.8
new file mode 100644
index 0000000..85139f0
--- /dev/null
+++ b/dosfsck/dosfsck.8
@@ -0,0 +1,143 @@
+.TH DOSFSCK 8 "December 31 1997" "Linux" "MAINTENANCE COMMANDS"
+.SH NAME
+dosfsck \- check and repair MS-DOS file systems
+.SH SYNOPSIS
+.ad l
+.B dosfsck
+.RB [ \-aAflnrtvVwy ]
+.RB [ \-d\ \fIpath\fB\ \-d\ \fI...\fB ]
+.RB [ \-u\ \fIpath\fB\ \-u\ \fI...\fB ]
+.I device
+.ad b
+.SH DESCRIPTION
+.B dosfsck
+verifies the consistency of MS-DOS file systems and optionally tries to
+repair them. The following file system problems can be corrected (in this
+order):
+.IP \-
+FAT contains invalid cluster numbers. Cluster is changed to EOF.
+.PD 0
+.IP \-
+File's cluster chain contains a loop. The loop is broken.
+.IP \-
+Bad clusters (read errors). The clusters are marked bad and they are
+removed from files owning them. This check is optional.
+.IP \-
+Directories with a large number of bad entries (probably corrupt). The
+directory can be dropped.
+.IP \-
+Files . and .. are non-directories. They can be dropped or renamed.
+.IP \-
+Directories . and .. in root directory. They are dropped.
+.IP \-
+Bad file names. They can be renamed.
+.IP \-
+Duplicate directory entries. They can be dropped or renamed.
+.IP \-
+Directories with non-zero size field. Size is set to zero.
+.IP \-
+Directory . does not point to parent directory. The start pointer is
+adjusted.
+.IP \-
+Directory .. does not point to parent of parent directory. The start pointer
+is adjusted.
+.IP \-
+Start cluster number of a file is invalid. The file is truncated.
+.IP \-
+File contains bad or free clusters. The file is truncated.
+.IP \-
+File's cluster chain is longer than indicated by the size fields. The file
+is truncated.
+.IP \-
+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 file system check is restarted after truncation.
+.IP \-
+File's cluster chain is shorter than indicated by the size fields. The file
+is truncated.
+.IP \-
+Clusters are marked as used but are not owned by a file. They are marked
+as free.
+.PD
+.LP
+Additionally, the following problems are detected, but not repaired:
+.IP \-
+Invalid parameters in boot sector.
+.PD 0
+.IP \-
+Absence of . and .. entries in non-root directories
+.PD
+.LP
+When \fBdosfsck\fP checks a file system, it accumulates all changes in memory
+and performs them only after all checks are complete. This can be disabled
+with the \fB\-w\fP option.
+.SH OPTIONS
+.IP \fB\-a\fP
+Automatically repair the file system. No user intervention is necessary.
+Whenever there is more than one method to solve a problem, the least
+destructive approach is used.
+.IP \fB\-A\fP
+Use Atari variation of the MS-DOS filesystem. This is default if
+\fBdosfsck\fP 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).
+.IP \fB\-d\fP
+Drop the specified file. If more that one file with that name exists, the
+first one is dropped.
+.IP \fB\-f\fP
+Salvage unused cluster chains to files. By default, unused clusters are
+added to the free disk space except in auto mode (\fB-a\fP).
+.IP \fB\-l\fP
+List path names of files being processed.
+.IP \fB\-n\fP
+No-operation mode: non-interactively check for errors, but don't write
+anything to the filesystem.
+.IP \fB\-r\fP
+Interactively repair the file system. The user is asked for advice whenever
+there is more than one approach to fix an inconsistency.
+.IP \fB\-t\fP
+Mark unreadable clusters as bad.
+.IP \fB-u\fP
+Try to undelete the specified file. \fBdosfsck\fP tries to allocate a chain
+of contiguous unallocated clusters beginning with the start cluster of the
+undeleted file.
+.IP \fB\-v\fP
+Verbose mode. Generates slightly more output.
+.IP \fB\-V\fP
+Perform a verification pass. The file system 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.
+.IP \fB\-w\fP
+Write changes to disk immediately.
+.IP \fB\-y\fP
+Same as \fB\-a\fP (automatically repair filesystem) for compatibility
+with other fsck tools.
+.LP
+If \fB\-a\fP and \fB\-r\fP are absent, the file system is only checked,
+but not repaired.
+.SH "EXIT STATUS"
+.IP 0
+No recoverable errors have been detected.
+.IP 1
+Recoverable errors have been detected or \fBdosfsck\fP has discovered an
+internal inconsistency.
+.IP 2
+Usage error. \fBdosfsck\fP did not access the file system.
+.SH BUGS
+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.
+.\".SH "SEE ALSO"
+.\"fs(5)
+.SH AUTHORS
+Werner Almesberger <werner.almesberger@lrc.di.epfl.ch>
+Extensions (FAT32, VFAT) by and current maintainer:
+Roman Hodek <roman@hodek.net>
diff --git a/src/dosfsck.c b/dosfsck/dosfsck.c
index 7657018..2f5886b 100644
--- a/src/dosfsck.c
+++ b/dosfsck/dosfsck.c
@@ -1,30 +1,12 @@
-/* dosfsck.c - User interface
+/* dosfsck.c - User interface */
- Copyright (C) 1993 Werner Almesberger <werner.almesberger@lrc.di.epfl.ch>
- Copyright (C) 1998 Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de>
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- On Debian systems, the complete text of the GNU General Public License
- can be found in /usr/share/common-licenses/GPL-3 file.
-*/
+/* Written 1993 by Werner Almesberger */
/* FAT32, VFAT, Atari format support, and various fixes additions May 1998
* by Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de> */
-#include "version.h"
+#include "../version.h"
#include <stdio.h>
#include <stdlib.h>
@@ -42,7 +24,7 @@
#include "check.h"
-int interactive = 0,rw = 0,list = 0,test = 0,verbose = 0,write_immed = 0;
+int interactive = 0,list = 0,test = 0,verbose = 0,write_immed = 0;
int atari_format = 0;
unsigned n_files = 0;
void *mem_queue = NULL;
@@ -58,7 +40,6 @@ static void usage(char *name)
fprintf(stderr," -f salvage unused chains to files\n");
fprintf(stderr," -l list path names\n");
fprintf(stderr," -n no-op, check non-interactively without changing\n");
- fprintf(stderr," -p same as -a, for compat with other *fsck\n");
fprintf(stderr," -r interactively repair the file system\n");
fprintf(stderr," -t test for bad clusters\n");
fprintf(stderr," -u path try to undelete that (non-directory) file\n");
@@ -102,22 +83,19 @@ static void check_atari( void )
int main(int argc,char **argv)
{
DOS_FS fs;
- int salvage_files,verify,c;
- unsigned n_files_check=0, n_files_verify=0;
+ int rw,salvage_files,verify,c;
unsigned long free_clusters;
-
- memset(&fs, 0, sizeof(fs));
+
rw = salvage_files = verify = 0;
interactive = 1;
check_atari();
- while ((c = getopt(argc,argv,"Aad:flnprtu:vVwy")) != EOF)
+ while ((c = getopt(argc,argv,"Aad:flnrtu:vVwy")) != EOF)
switch (c) {
case 'A': /* toggle Atari format */
atari_format = !atari_format;
break;
case 'a':
- case 'p':
case 'y':
rw = 1;
interactive = 0;
@@ -176,15 +154,12 @@ int main(int argc,char **argv)
free_clusters = update_free(&fs);
file_unused();
qfree(&mem_queue);
- n_files_check = n_files;
if (verify) {
- n_files = 0;
- printf("Starting verification pass.\n");
- read_fat(&fs);
- scan_root(&fs);
- reclaim_free(&fs);
- qfree(&mem_queue);
- n_files_verify = n_files;
+ printf("Starting verification pass.\n");
+ read_fat(&fs);
+ scan_root(&fs);
+ reclaim_free(&fs);
+ qfree(&mem_queue);
}
if (fs_changed()) {
@@ -202,3 +177,7 @@ int main(int argc,char **argv)
return fs_close(rw) ? 1 : 0;
}
+
+/* Local Variables: */
+/* tab-width: 8 */
+/* End: */
diff --git a/src/dosfsck.h b/dosfsck/dosfsck.h
index 25a15ed..e1f400f 100644
--- a/src/dosfsck.h
+++ b/dosfsck/dosfsck.h
@@ -1,24 +1,6 @@
-/* dosfsck.h - Common data structures and global variables
+/* dosfsck.h - Common data structures and global variables */
- Copyright (C) 1993 Werner Almesberger <werner.almesberger@lrc.di.epfl.ch>
- Copyright (C) 1998 Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de>
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- On Debian systems, the complete text of the GNU General Public License
- can be found in /usr/share/common-licenses/GPL-3 file.
-*/
+/* Written 1993 by Werner Almesberger */
/* FAT32, VFAT, Atari format support, and various fixes additions May 1998
* by Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de> */
@@ -32,8 +14,13 @@
#define _LINUX_STRING_H_ /* hack to avoid inclusion of <linux/string.h>*/
#define _LINUX_FS_H /* hack to avoid inclusion of <linux/fs.h> */
+#include <linux/version.h>
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
+# define __KERNEL__
# include <asm/types.h>
# include <asm/byteorder.h>
+# undef __KERNEL__
+#endif
#include <linux/msdos_fs.h>
@@ -75,7 +62,7 @@ struct boot_sector {
__u16 heads; /* number of heads */
__u32 hidden; /* hidden sectors (unused) */
__u32 total_sect; /* number of sectors (if sectors == 0) */
-
+
/* The following fields are only used by FAT32 */
__u32 fat32_length; /* sectors/FAT */
__u16 flags; /* bit 8: fat mirroring, low 4: active fat */
@@ -83,47 +70,10 @@ struct boot_sector {
__u32 root_cluster; /* first cluster in root directory */
__u16 info_sector; /* filesystem info sector */
__u16 backup_boot; /* backup boot sector */
- __u8 reserved2[12]; /* Unused */
-
- __u8 drive_number; /* Logical Drive Number */
- __u8 reserved3; /* Unused */
-
- __u8 extended_sig; /* Extended Signature (0x29) */
- __u32 serial; /* Serial number */
- __u8 label[11]; /* FS label */
- __u8 fs_type[8]; /* FS Type */
+ __u16 reserved2[6]; /* Unused */
/* fill up to 512 bytes */
- __u8 junk[422];
-} __attribute__ ((packed));
-
-struct boot_sector_16 {
- __u8 ignored[3]; /* Boot strap short or near jump */
- __u8 system_id[8]; /* Name - can be used to special case
- partition manager volumes */
- __u8 sector_size[2]; /* bytes per logical sector */
- __u8 cluster_size; /* sectors/cluster */
- __u16 reserved; /* reserved sectors */
- __u8 fats; /* number of FATs */
- __u8 dir_entries[2]; /* root directory entries */
- __u8 sectors[2]; /* number of sectors */
- __u8 media; /* media code (unused) */
- __u16 fat_length; /* sectors/FAT */
- __u16 secs_track; /* sectors per track */
- __u16 heads; /* number of heads */
- __u32 hidden; /* hidden sectors (unused) */
- __u32 total_sect; /* number of sectors (if sectors == 0) */
-
- __u8 drive_number; /* Logical Drive Number */
- __u8 reserved2; /* Unused */
-
- __u8 extended_sig; /* Extended Signature (0x29) */
- __u32 serial; /* Serial number */
- __u8 label[11]; /* FS label */
- __u8 fs_type[8]; /* FS Type */
-
- /* fill up to 512 bytes */
- __u8 junk[450];
+ __u8 junk[448];
} __attribute__ ((packed));
struct info_sector {
@@ -149,13 +99,12 @@ typedef struct {
__u16 starthi; /* High 16 bits of cluster in FAT32 */
__u16 time,date,start;/* time, date and first cluster */
__u32 size; /* file size (in bytes) */
-} __attribute__ ((packed)) DIR_ENT;
+} DIR_ENT;
typedef struct _dos_file {
DIR_ENT dir_ent;
char *lfn;
loff_t offset;
- loff_t lfn_offset;
struct _dos_file *parent; /* parent directory */
struct _dos_file *next; /* next entry */
struct _dos_file *first; /* first entry (directory only) */
@@ -164,6 +113,8 @@ typedef struct _dos_file {
typedef struct {
unsigned long value;
unsigned long reserved;
+ DOS_FILE *owner;
+ int prev; /* number of previous clusters */
} FAT_ENTRY;
typedef struct {
@@ -181,16 +132,14 @@ typedef struct {
loff_t fsinfo_start; /* 0 if not present */
long free_clusters;
loff_t backupboot_start; /* 0 if not present */
- unsigned char *fat;
- DOS_FILE **cluster_owner;
- char *label;
+ FAT_ENTRY *fat;
} DOS_FS;
#ifndef offsetof
#define offsetof(t,e) ((int)&(((t *)0)->e))
#endif
-extern int interactive,rw,list,verbose,test,write_immed;
+extern int interactive,list,verbose,test,write_immed;
extern int atari_format;
extern unsigned n_files;
extern void *mem_queue;
@@ -208,7 +157,8 @@ extern void *mem_queue;
/* return -16 as a number with fs->fat_bits bits */
#define FAT_EXTD(fs) (((1 << fs->eff_fat_bits)-1) & ~0xf)
-/* marker for files with no 8.3 name */
-#define FAT_NO_83NAME 32
-
#endif
+
+/* Local Variables: */
+/* tab-width: 8 */
+/* End: */
diff --git a/dosfsck/fat.c b/dosfsck/fat.c
new file mode 100644
index 0000000..91928d4
--- /dev/null
+++ b/dosfsck/fat.c
@@ -0,0 +1,361 @@
+/* fat.c - Read/write access to the FAT */
+
+/* Written 1993 by Werner Almesberger */
+
+/* FAT32, VFAT, Atari format support, and various fixes additions May 1998
+ * by Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de> */
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "common.h"
+#include "dosfsck.h"
+#include "io.h"
+#include "check.h"
+#include "fat.h"
+
+
+static void get_fat(FAT_ENTRY *entry,void *fat,unsigned long cluster,DOS_FS *fs)
+{
+ unsigned char *ptr;
+
+ switch(fs->fat_bits) {
+ case 12:
+ ptr = &((unsigned char *) fat)[cluster*3/2];
+ entry->value = 0xfff & (cluster & 1 ? (ptr[0] >> 4) | (ptr[1] << 4) :
+ (ptr[0] | ptr[1] << 8));
+ break;
+ case 16:
+ entry->value = CF_LE_W(((unsigned short *) fat)[cluster]);
+ break;
+ case 32:
+ /* According to M$, the high 4 bits of a FAT32 entry are reserved and
+ * are not part of the cluster number. So we cut them off. */
+ {
+ unsigned long e = CF_LE_L(((unsigned int *) fat)[cluster]);
+ entry->value = e & 0xfffffff;
+ entry->reserved = e >> 28;
+ }
+ break;
+ default:
+ die("Bad FAT entry size: %d bits.",fs->fat_bits);
+ }
+ entry->owner = NULL;
+}
+
+
+void read_fat(DOS_FS *fs)
+{
+ int eff_size;
+ unsigned long i;
+ void *first,*second,*use;
+ int first_ok,second_ok;
+
+ eff_size = ((fs->clusters+2)*fs->fat_bits+7)/8;
+ first = alloc(eff_size);
+ fs_read(fs->fat_start,eff_size,first);
+ use = first;
+ if (fs->nfats > 1) {
+ second = alloc(eff_size);
+ fs_read(fs->fat_start+fs->fat_size,eff_size,second);
+ }
+ else
+ second = NULL;
+ if (second && memcmp(first,second,eff_size) != 0) {
+ FAT_ENTRY first_media, second_media;
+ get_fat(&first_media,first,0,fs);
+ get_fat(&second_media,second,0,fs);
+ first_ok = (first_media.value & FAT_EXTD(fs)) == FAT_EXTD(fs);
+ second_ok = (second_media.value & FAT_EXTD(fs)) == FAT_EXTD(fs);
+ if (first_ok && !second_ok) {
+ printf("FATs differ - using first FAT.\n");
+ fs_write(fs->fat_start+fs->fat_size,eff_size,use = first);
+ }
+ if (!first_ok && second_ok) {
+ printf("FATs differ - using second FAT.\n");
+ fs_write(fs->fat_start,eff_size,use = second);
+ }
+ if (first_ok && second_ok) {
+ if (interactive) {
+ printf("FATs differ but appear to be intact. Use which FAT ?\n"
+ "1) Use first FAT\n2) Use second FAT\n");
+ if (get_key("12","?") == '1')
+ fs_write(fs->fat_start+fs->fat_size,eff_size,use = first);
+ else fs_write(fs->fat_start,eff_size,use = second);
+ }
+ else {
+ printf("FATs differ but appear to be intact. Using first "
+ "FAT.\n");
+ fs_write(fs->fat_start+fs->fat_size,eff_size,use = first);
+ }
+ }
+ if (!first_ok && !second_ok) {
+ printf("Both FATs appear to be corrupt. Giving up.\n");
+ exit(1);
+ }
+ }
+ fs->fat = qalloc(&mem_queue,sizeof(FAT_ENTRY)*(fs->clusters+2));
+ for (i = 2; i < fs->clusters+2; i++) get_fat(&fs->fat[i],use,i,fs);
+ for (i = 2; i < fs->clusters+2; i++)
+ if (fs->fat[i].value >= fs->clusters+2 &&
+ (fs->fat[i].value < FAT_MIN_BAD(fs))) {
+ printf("Cluster %ld out of range (%ld > %ld). Setting to EOF.\n",
+ i-2,fs->fat[i].value,fs->clusters+2-1);
+ set_fat(fs,i,-1);
+ }
+ free(first);
+ if (second)
+ free(second);
+}
+
+
+void set_fat(DOS_FS *fs,unsigned long cluster,unsigned long new)
+{
+ unsigned char data[4];
+ int size;
+ loff_t offs;
+
+ if ((long)new == -1)
+ new = FAT_EOF(fs);
+ else if ((long)new == -2)
+ new = FAT_BAD(fs);
+ switch( fs->fat_bits ) {
+ case 12:
+ offs = fs->fat_start+cluster*3/2;
+ if (cluster & 1) {
+ data[0] = ((new & 0xf) << 4) | (fs->fat[cluster-1].value >> 8);
+ data[1] = new >> 4;
+ }
+ else {
+ data[0] = new & 0xff;
+ data[1] = (new >> 8) | (cluster == fs->clusters-1 ? 0 :
+ (0xff & fs->fat[cluster+1].value) << 4);
+ }
+ size = 2;
+ break;
+ case 16:
+ offs = fs->fat_start+cluster*2;
+ *(unsigned short *) data = CT_LE_W(new);
+ size = 2;
+ break;
+ case 32:
+ offs = fs->fat_start+cluster*4;
+ /* According to M$, the high 4 bits of a FAT32 entry are reserved and
+ * are not part of the cluster number. So we never touch them. */
+ *(unsigned long *) data = CT_LE_L( (new & 0xfffffff) |
+ (fs->fat[cluster].reserved << 28) );
+ size = 4;
+ break;
+ default:
+ die("Bad FAT entry size: %d bits.",fs->fat_bits);
+ }
+ fs->fat[cluster].value = new;
+ fs_write(offs,size,&data);
+ fs_write(offs+fs->fat_size,size,&data);
+}
+
+
+int bad_cluster(DOS_FS *fs,unsigned long cluster)
+{
+ return FAT_IS_BAD(fs,fs->fat[cluster].value);
+}
+
+
+unsigned long next_cluster(DOS_FS *fs,unsigned long cluster)
+{
+ unsigned long value;
+
+ value = fs->fat[cluster].value;
+ if (FAT_IS_BAD(fs,value))
+ die("Internal error: next_cluster on bad cluster");
+ return FAT_IS_EOF(fs,value) ? -1 : value;
+}
+
+
+loff_t cluster_start(DOS_FS *fs,unsigned long cluster)
+{
+ return fs->data_start+((loff_t)cluster-2)*fs->cluster_size;
+}
+
+
+void set_owner(DOS_FS *fs,unsigned long cluster,DOS_FILE *owner)
+{
+ if (owner && fs->fat[cluster].owner)
+ die("Internal error: attempt to change file owner");
+ fs->fat[cluster].owner = owner;
+}
+
+
+DOS_FILE *get_owner(DOS_FS *fs,unsigned long cluster)
+{
+ return fs->fat[cluster].owner;
+}
+
+
+void fix_bad(DOS_FS *fs)
+{
+ unsigned long i;
+
+ if (verbose)
+ printf("Checking for bad clusters.\n");
+ for (i = 2; i < fs->clusters+2; i++)
+ if (!get_owner(fs,i) && !FAT_IS_BAD(fs,fs->fat[i].value))
+ if (!fs_test(cluster_start(fs,i),fs->cluster_size)) {
+ printf("Cluster %lu is unreadable.\n",i);
+ set_fat(fs,i,-2);
+ }
+}
+
+
+void reclaim_free(DOS_FS *fs)
+{
+ int reclaimed;
+ unsigned long i;
+
+ if (verbose)
+ printf("Checking for unused clusters.\n");
+ reclaimed = 0;
+ for (i = 2; i < fs->clusters+2; i++)
+ if (!get_owner(fs,i) && fs->fat[i].value &&
+ !FAT_IS_BAD(fs,fs->fat[i].value)) {
+ set_fat(fs,i,0);
+ reclaimed++;
+ }
+ if (reclaimed)
+ printf("Reclaimed %d unused cluster%s (%d bytes).\n",reclaimed,
+ reclaimed == 1 ? "" : "s",reclaimed*fs->cluster_size);
+}
+
+
+static void tag_free(DOS_FS *fs,DOS_FILE *ptr)
+{
+ DOS_FILE *owner;
+ int prev;
+ unsigned long i,walk;
+
+ for (i = 2; i < fs->clusters+2; i++)
+ if (fs->fat[i].value && !FAT_IS_BAD(fs,fs->fat[i].value) &&
+ !get_owner(fs,i) && !fs->fat[i].prev) {
+ prev = 0;
+ for (walk = i; walk > 0 && walk != -1;
+ walk = next_cluster(fs,walk)) {
+ if (!(owner = get_owner(fs,walk))) set_owner(fs,walk,ptr);
+ else if (owner != ptr)
+ die("Internal error: free chain collides with file");
+ else {
+ set_fat(fs,prev,-1);
+ break;
+ }
+ prev = walk;
+ }
+ }
+}
+
+
+void reclaim_file(DOS_FS *fs)
+{
+ DOS_FILE dummy;
+ int reclaimed,files,changed;
+ unsigned long i,next,walk;
+
+ if (verbose)
+ printf("Reclaiming unconnected clusters.\n");
+ for (i = 2; i < fs->clusters+2; i++) fs->fat[i].prev = 0;
+ for (i = 2; i < fs->clusters+2; i++) {
+ next = fs->fat[i].value;
+ if (!get_owner(fs,i) && next && next < fs->clusters+2) {
+ if (get_owner(fs,next) || !fs->fat[next].value ||
+ FAT_IS_BAD(fs,fs->fat[next].value)) set_fat(fs,i,-1);
+ else fs->fat[next].prev++;
+ }
+ }
+ do {
+ tag_free(fs,&dummy);
+ changed = 0;
+ for (i = 2; i < fs->clusters+2; i++)
+ if (fs->fat[i].value && !FAT_IS_BAD(fs,fs->fat[i].value) &&
+ !get_owner(fs, i)) {
+ if (!fs->fat[fs->fat[i].value].prev--)
+ die("Internal error: prev going below zero");
+ set_fat(fs,i,-1);
+ changed = 1;
+ printf("Broke cycle at cluster %lu in free chain.\n",i);
+ break;
+ }
+ }
+ while (changed);
+ files = reclaimed = 0;
+ for (i = 2; i < fs->clusters+2; i++)
+ if (get_owner(fs,i) == &dummy && !fs->fat[i].prev) {
+ DIR_ENT de;
+ loff_t offset;
+ files++;
+ offset = alloc_rootdir_entry(fs,&de,"FSCK%04dREC");
+ de.start = CT_LE_W(i&0xffff);
+ if (fs->fat_bits == 32)
+ de.starthi = CT_LE_W(i>>16);
+ for (walk = i; walk > 0 && walk != -1;
+ walk = next_cluster(fs,walk)) {
+ de.size = CT_LE_L(CF_LE_L(de.size)+fs->cluster_size);
+ reclaimed++;
+ }
+ fs_write(offset,sizeof(DIR_ENT),&de);
+ }
+ if (reclaimed)
+ printf("Reclaimed %d unused cluster%s (%d bytes) in %d chain%s.\n",
+ reclaimed,reclaimed == 1 ? "" : "s",reclaimed*fs->cluster_size,files,
+ files == 1 ? "" : "s");
+}
+
+
+unsigned long update_free(DOS_FS *fs)
+{
+ unsigned long i;
+ unsigned long free = 0;
+ int do_set = 0;
+
+ for (i = 2; i < fs->clusters+2; i++)
+ if (!get_owner(fs,i) && !FAT_IS_BAD(fs,fs->fat[i].value))
+ ++free;
+
+ if (!fs->fsinfo_start)
+ return free;
+
+ if (verbose)
+ printf("Checking free cluster summary.\n");
+ if (fs->free_clusters >= 0) {
+ if (free != fs->free_clusters) {
+ printf( "Free cluster summary wrong (%ld vs. really %ld)\n",
+ fs->free_clusters,free);
+ if (interactive)
+ printf( "1) Correct\n2) Don't correct\n" );
+ else printf( " Auto-correcting.\n" );
+ if (!interactive || get_key("12","?") == '1')
+ do_set = 1;
+ }
+ }
+ else {
+ printf( "Free cluster summary uninitialized (should be %ld)\n", free );
+ if (interactive)
+ printf( "1) Set it\n2) Leave it uninitialized\n" );
+ else printf( " Auto-setting.\n" );
+ if (!interactive || get_key("12","?") == '1')
+ do_set = 1;
+ }
+
+ if (do_set) {
+ fs->free_clusters = free;
+ free = CT_LE_L(free);
+ fs_write(fs->fsinfo_start+offsetof(struct info_sector,free_clusters),
+ sizeof(free),&free);
+ }
+
+ return free;
+}
+
+/* Local Variables: */
+/* tab-width: 8 */
+/* End: */
diff --git a/src/fat.h b/dosfsck/fat.h
index 40bb6d0..8c2312d 100644
--- a/src/fat.h
+++ b/dosfsck/fat.h
@@ -1,23 +1,6 @@
-/* fat.h - Read/write access to the FAT
+/* fat.h - Read/write access to the FAT */
- Copyright (C) 1993 Werner Almesberger <werner.almesberger@lrc.di.epfl.ch>
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- On Debian systems, the complete text of the GNU General Public License
- can be found in /usr/share/common-licenses/GPL-3 file.
-*/
+/* Written 1993 by Werner Almesberger */
#ifndef _FAT_H
@@ -28,10 +11,6 @@ void read_fat(DOS_FS *fs);
/* Loads the FAT of the file system described by FS. Initializes the FAT,
replaces broken FATs and rejects invalid cluster entries. */
-void get_fat(FAT_ENTRY *entry, void *fat, unsigned long cluster, DOS_FS *fs);
-
-/* Retrieve the FAT entry (next chained cluster) for CLUSTER. */
-
void set_fat(DOS_FS *fs,unsigned long cluster,unsigned long new);
/* Changes the value of the CLUSTERth cluster of the FAT of FS to NEW. Special
diff --git a/src/file.c b/dosfsck/file.c
index cb8a94e..f57f4b7 100644
--- a/src/file.c
+++ b/dosfsck/file.c
@@ -1,24 +1,6 @@
-/* file.c - Additional file attributes
+/* file.c - Additional file attributes */
- Copyright (C) 1993 Werner Almesberger <werner.almesberger@lrc.di.epfl.ch>
- Copyright (C) 1998 Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de>
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- On Debian systems, the complete text of the GNU General Public License
- can be found in /usr/share/common-licenses/GPL-3 file.
-*/
+/* Written 1993 by Werner Almesberger */
/* FAT32, VFAT, Atari format support, and various fixes additions May 1998
* by Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de> */
@@ -34,7 +16,12 @@
#define _LINUX_STRING_H_ /* hack to avoid inclusion of <linux/string.h>*/
#define _LINUX_FS_H /* hack to avoid inclusion of <linux/fs.h> */
+#include <linux/version.h>
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
+# define __KERNEL__
# include <asm/types.h>
+# undef __KERNEL__
+#endif
#include <linux/msdos_fs.h>
@@ -57,14 +44,6 @@ static void put_char(char **p,unsigned char c)
}
-/**
- * Construct the "pretty-printed" representation of the name in a short directory entry.
- *
- * @param[in] fixed Pointer to name[0] of a DIR_ENT
- *
- * @return Pointer to static string containing pretty "8.3" equivalent of the
- * name in the directory entry.
- */
char *file_name(unsigned char *fixed)
{
static char path[MSDOS_NAME*4+2];
@@ -212,8 +191,6 @@ static FDSC **file_find(FDSC **dir,char *fixed)
}
-/* Returns the attribute of the file FIXED in directory CURR or FDT_NONE if no
- such file exists or if CURR is NULL. */
FD_TYPE file_type(FDSC **curr,char *fixed)
{
FDSC **this;
@@ -267,3 +244,7 @@ void file_unused(void)
{
report_unused(fp_root);
}
+
+/* Local Variables: */
+/* tab-width: 8 */
+/* End: */
diff --git a/src/file.h b/dosfsck/file.h
index b38523b..d7f1386 100644
--- a/src/file.h
+++ b/dosfsck/file.h
@@ -1,23 +1,6 @@
-/* file.h - Additional file attributes
+/* file.h - Additional file attributes */
- Copyright (C) 1993 Werner Almesberger <werner.almesberger@lrc.di.epfl.ch>
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- On Debian systems, the complete text of the GNU General Public License
- can be found in /usr/share/common-licenses/GPL-3 file.
-*/
+/* Written 1993 by Werner Almesberger */
#ifndef _FILE_H
diff --git a/src/io.c b/dosfsck/io.c
index fb0369e..b5b67d1 100644
--- a/src/io.c
+++ b/dosfsck/io.c
@@ -1,24 +1,6 @@
-/* io.c - Virtual disk input/output
+/* io.c - Virtual disk input/output */
- Copyright (C) 1993 Werner Almesberger <werner.almesberger@lrc.di.epfl.ch>
- Copyright (C) 1998 Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de>
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- On Debian systems, the complete text of the GNU General Public License
- can be found in /usr/share/common-licenses/GPL-3 file.
-*/
+/* Written 1993 by Werner Almesberger */
/*
* Thu Feb 26 01:15:36 CET 1998: Martin Schulze <joey@infodrom.north.de>
@@ -29,8 +11,6 @@
/* FAT32, VFAT, Atari format support, and various fixes additions May 1998
* by Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de> */
-#define _LARGEFILE64_SOURCE
-#include <sys/types.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -62,7 +42,8 @@ unsigned device_no;
#ifdef __DJGPP__
#include "volume.h" /* DOS lowlevel disk access functions */
-loff_t llseek(int fd, loff_t offset, int whence)
+#undef llseek
+static loff_t llseek( int fd, loff_t offset, int whence )
{
if ((whence != SEEK_SET) || (fd == 4711)) return -1; /* only those supported */
return VolumeSeek(offset);
@@ -71,21 +52,14 @@ loff_t llseek(int fd, loff_t offset, int whence)
#define close CloseVolume
#define read(a,b,c) ReadVolume(b,c)
#define write(a,b,c) WriteVolume(b,c)
-#else
-loff_t llseek(int fd, loff_t offset, int whence)
-{
- return (loff_t) lseek64(fd, (off64_t)offset, whence);
-}
#endif
void fs_open(char *path,int rw)
{
struct stat stbuf;
-
- if ((fd = open(path,rw ? O_RDWR : O_RDONLY)) < 0) {
- perror("open");
- exit(6);
- }
+
+ if ((fd = open(path,rw ? O_RDWR : O_RDONLY)) < 0)
+ pdie("open %s",path);
changes = last = NULL;
did_change = 0;
@@ -111,15 +85,6 @@ void fs_open(char *path,int rw)
}
-/**
- * Read data from the partition, accounting for any pending updates that are
- * queued for writing.
- *
- * @param[in] pos Byte offset, relative to the beginning of the partition,
- * at which to read
- * @param[in] size Number of bytes to read
- * @param[out] data Where to put the data read
- */
void fs_read(loff_t pos,int size,void *data)
{
CHANGE *walk;
@@ -220,3 +185,7 @@ int fs_changed(void)
{
return !!changes || did_change;
}
+
+/* Local Variables: */
+/* tab-width: 8 */
+/* End: */
diff --git a/src/io.h b/dosfsck/io.h
index 9da453e..9fb5be0 100644
--- a/src/io.h
+++ b/dosfsck/io.h
@@ -1,24 +1,6 @@
-/* io.h - Virtual disk input/output
+/* io.h - Virtual disk input/output */
- Copyright (C) 1993 Werner Almesberger <werner.almesberger@lrc.di.epfl.ch>
- Copyright (C) 1998 Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de>
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- On Debian systems, the complete text of the GNU General Public License
- can be found in /usr/share/common-licenses/GPL-3 file.
-*/
+/* Written 1993 by Werner Almesberger */
/* FAT32, VFAT, Atari format support, and various fixes additions May 1998
* by Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de> */
@@ -29,9 +11,9 @@
#include <sys/types.h> /* for loff_t */
-loff_t llseek(int fd, loff_t offset, int whence);
-
-/* lseek() analogue for large offsets. */
+/* In earlier versions, an own llseek() was used, but glibc lseek() is
+ * sufficient (or even better :) for 64 bit offsets in the meantime */
+#define llseek lseek
void fs_open(char *path,int rw);
diff --git a/src/lfn.c b/dosfsck/lfn.c
index dc17f20..9b2cfc3 100644
--- a/src/lfn.c
+++ b/dosfsck/lfn.c
@@ -1,23 +1,6 @@
-/* lfn.c - Functions for handling VFAT long filenames
+/* lfn.c - Functions for handling VFAT long filenames */
- Copyright (C) 1998 Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de>
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- On Debian systems, the complete text of the GNU General Public License
- can be found in /usr/share/common-licenses/GPL-3 file.
-*/
+/* Written 1998 by Roman Hodek */
#include <stdio.h>
#include <stdlib.h>
@@ -78,7 +61,7 @@ static unsigned char fat_uni2esc[64] = {
copy_lfn_part( __part_uni, lfn ); \
cnv_unicode( __part_uni, CHARS_PER_LFN, 0 ); \
})
-
+
/* Convert name parts collected so far (from previous slots) from unicode to
* ASCII */
#define CNV_PARTS_SO_FAR() \
@@ -93,7 +76,7 @@ static char *cnv_unicode( const unsigned char *uni, int maxlen, int use_q )
const unsigned char *up;
unsigned char *out, *cp;
int len, val;
-
+
for( len = 0, up = uni; (up-uni)/2 < maxlen && (up[0] || up[1]); up += 2 ){
if (UNICODE_CONVERTABLE(up[0],up[1]))
++len;
@@ -142,24 +125,12 @@ static void clear_lfn_slots( int start, int end )
*/
memset( &empty, 0, sizeof(empty) );
empty.id = DELETED_FLAG;
-
+
for( i = start; i <= end; ++i ) {
fs_write( lfn_offsets[i], sizeof(LFN_ENT), &empty );
}
}
-void lfn_fix_checksum(loff_t from, loff_t to, const char *short_name)
-{
- int i;
- __u8 sum;
- for (sum = 0, i = 0; i < 11; i++)
- sum = (((sum&1) << 7) | ((sum&0xfe) >> 1)) + short_name[i];
-
- for( ; from < to; from += sizeof(LFN_ENT) ) {
- fs_write( from + offsetof(LFN_ENT,alias_checksum), sizeof(sum), &sum );
- }
-}
-
void lfn_reset( void )
{
if (lfn_unicode)
@@ -177,15 +148,12 @@ void lfn_reset( void )
void lfn_add_slot( DIR_ENT *de, loff_t dir_offset )
{
LFN_ENT *lfn = (LFN_ENT *)de;
- int slot = lfn->id & LFN_ID_SLOTMASK;
unsigned offset;
- if (lfn_slot == 0) lfn_check_orphaned();
-
if (de->attr != VFAT_LN_ATTR)
die("lfn_add_slot called with non-LFN directory entry");
- if (lfn->id & LFN_ID_START && slot != 0) {
+ if (lfn->id & LFN_ID_START) {
if (lfn_slot != -1) {
int can_clear = 0;
/* There is already a LFN "in progess", so it is an error that a
@@ -197,7 +165,7 @@ void lfn_add_slot( DIR_ENT *de, loff_t dir_offset )
/* XXX: Should delay that until next LFN known (then can better
* display the name) */
printf( "A new long file name starts within an old one.\n" );
- if (slot == lfn_slot &&
+ if ((lfn->id & LFN_ID_SLOTMASK) == lfn_slot &&
lfn->alias_checksum == lfn_checksum) {
char *part1 = CNV_THIS_PART(lfn);
char *part2 = CNV_PARTS_SO_FAR();
@@ -229,13 +197,13 @@ void lfn_add_slot( DIR_ENT *de, loff_t dir_offset )
}
}
}
- lfn_slot = slot;
+ lfn_slot = lfn->id & LFN_ID_SLOTMASK;
lfn_checksum = lfn->alias_checksum;
lfn_unicode = alloc( (lfn_slot*CHARS_PER_LFN+1)*2 );
lfn_offsets = alloc( lfn_slot*sizeof(loff_t) );
lfn_parts = 0;
}
- else if (lfn_slot == -1 && slot != 0) {
+ else if (lfn_slot == -1) {
/* No LFN in progress, but slot found; start bit missing */
/* Causes: 1) start bit got lost, 2) Previous slot with start bit got
* lost */
@@ -249,30 +217,32 @@ void lfn_add_slot( DIR_ENT *de, loff_t dir_offset )
"3: Set start bit\n" );
}
else printf( " Not auto-correcting this.\n" );
- switch( interactive ? get_key( "123", "?" ) : '2') {
- case '1':
- if (!lfn_offsets)
- lfn_offsets = alloc( sizeof(loff_t) );
- lfn_offsets[0] = dir_offset;
- clear_lfn_slots( 0, 0 );
- lfn_reset();
- return;
- case '2':
- lfn_reset();
- return;
- case '3':
- lfn->id |= LFN_ID_START;
- fs_write( dir_offset+offsetof(LFN_ENT,id),
- sizeof(lfn->id), &lfn->id );
- lfn_slot = slot;
- lfn_checksum = lfn->alias_checksum;
- lfn_unicode = alloc( (lfn_slot*CHARS_PER_LFN+1)*2 );
- lfn_offsets = alloc( lfn_slot*sizeof(loff_t) );
- lfn_parts = 0;
- break;
+ if (interactive) {
+ switch( get_key( "123", "?" )) {
+ case '1':
+ if (!lfn_offsets)
+ lfn_offsets = alloc( sizeof(loff_t) );
+ lfn_offsets[0] = dir_offset;
+ clear_lfn_slots( 0, 0 );
+ lfn_reset();
+ return;
+ case '2':
+ lfn_reset();
+ return;
+ case '3':
+ lfn->id |= LFN_ID_START;
+ fs_write( dir_offset+offsetof(LFN_ENT,id),
+ sizeof(lfn->id), &lfn->id );
+ lfn_slot = lfn->id & LFN_ID_SLOTMASK;
+ lfn_checksum = lfn->alias_checksum;
+ lfn_unicode = alloc( (lfn_slot*CHARS_PER_LFN+1)*2 );
+ lfn_offsets = alloc( lfn_slot*sizeof(loff_t) );
+ lfn_parts = 0;
+ break;
+ }
}
}
- else if (slot != lfn_slot) {
+ else if ((lfn->id & LFN_ID_SLOTMASK) != lfn_slot) {
/* wrong sequence number */
/* Causes: 1) seq-no destroyed */
/* Fixes: 1) delete LFN, 2) fix number (maybe only if following parts
@@ -281,8 +251,8 @@ void lfn_add_slot( DIR_ENT *de, loff_t dir_offset )
int can_fix = 0;
printf( "Unexpected long filename sequence number "
"(%d vs. expected %d).\n",
- slot, lfn_slot );
- if (lfn->alias_checksum == lfn_checksum && lfn_slot > 0) {
+ (lfn->id & LFN_ID_SLOTMASK), lfn_slot );
+ if (lfn->alias_checksum == lfn_checksum) {
char *part1 = CNV_THIS_PART(lfn);
char *part2 = CNV_PARTS_SO_FAR();
printf( " It could be that just the number is wrong\n"
@@ -297,24 +267,22 @@ void lfn_add_slot( DIR_ENT *de, loff_t dir_offset )
printf( "3: Correct sequence number\n" );
}
else printf( " Not auto-correcting this.\n" );
- switch( interactive ? get_key( can_fix ? "123" : "12", "?" ) : '2') {
- case '1':
- if (!lfn_offsets) {
- lfn_offsets = alloc( sizeof(loff_t) );
- lfn_parts = 0;
+ if (interactive) {
+ switch( get_key( can_fix ? "123" : "12", "?" )) {
+ case '1':
+ lfn_offsets[lfn_parts++] = dir_offset;
+ clear_lfn_slots( 0, lfn_parts-1 );
+ lfn_reset();
+ return;
+ case '2':
+ lfn_reset();
+ return;
+ case '3':
+ lfn->id = (lfn->id & ~LFN_ID_SLOTMASK) | lfn_slot;
+ fs_write( dir_offset+offsetof(LFN_ENT,id),
+ sizeof(lfn->id), &lfn->id );
+ break;
}
- lfn_offsets[lfn_parts++] = dir_offset;
- clear_lfn_slots( 0, lfn_parts-1 );
- lfn_reset();
- return;
- case '2':
- lfn_reset();
- return;
- case '3':
- lfn->id = (lfn->id & ~LFN_ID_SLOTMASK) | lfn_slot;
- fs_write( dir_offset+offsetof(LFN_ENT,id),
- sizeof(lfn->id), &lfn->id );
- break;
}
}
@@ -386,13 +354,12 @@ void lfn_add_slot( DIR_ENT *de, loff_t dir_offset )
/* This function is always called when de->attr != VFAT_LN_ATTR is found, to
* retrieve the previously constructed LFN. */
-char *lfn_get( DIR_ENT *de, loff_t *lfn_offset )
+char *lfn_get( DIR_ENT *de )
{
char *lfn;
__u8 sum;
int i;
-
- *lfn_offset = 0;
+
if (de->attr == VFAT_LN_ATTR)
die("lfn_get called with LFN directory entry");
@@ -423,23 +390,25 @@ char *lfn_get( DIR_ENT *de, loff_t *lfn_offset )
"it to short name %s)\n", short_name );
}
else printf( " Not auto-correcting this.\n" );
- switch( interactive ? get_key( "123", "?" ) : '2') {
- case '1':
- clear_lfn_slots( 0, lfn_parts-1 );
- lfn_reset();
- return NULL;
- case '2':
- lfn_reset();
- return NULL;
- case '3':
- for( i = 0; i < lfn_parts; ++i ) {
- __u8 id = (lfn_parts-i) | (i==0 ? LFN_ID_START : 0);
- fs_write( lfn_offsets[i]+offsetof(LFN_ENT,id),
- sizeof(id), &id );
+ if (interactive) {
+ switch( get_key( "123", "?" )) {
+ case '1':
+ clear_lfn_slots( 0, lfn_parts-1 );
+ lfn_reset();
+ return NULL;
+ case '2':
+ lfn_reset();
+ return NULL;
+ case '3':
+ for( i = 0; i < lfn_parts; ++i ) {
+ __u8 id = (lfn_parts-i) | (i==0 ? LFN_ID_START : 0);
+ fs_write( lfn_offsets[i]+offsetof(LFN_ENT,id),
+ sizeof(id), &id );
+ }
+ memmove( lfn_unicode, lfn_unicode+lfn_slot*CHARS_PER_LFN*2,
+ lfn_parts*CHARS_PER_LFN*2 );
+ break;
}
- memmove( lfn_unicode, lfn_unicode+lfn_slot*CHARS_PER_LFN*2,
- lfn_parts*CHARS_PER_LFN*2 );
- break;
}
}
@@ -480,7 +449,6 @@ char *lfn_get( DIR_ENT *de, loff_t *lfn_offset )
}
}
- *lfn_offset = lfn_offsets[0];
lfn = cnv_unicode( lfn_unicode, UNTIL_0, 1 );
lfn_reset();
return( lfn );
@@ -503,3 +471,7 @@ void lfn_check_orphaned(void)
}
lfn_reset();
}
+
+/* Local Variables: */
+/* tab-width: 8 */
+/* End: */
diff --git a/dosfsck/lfn.h b/dosfsck/lfn.h
new file mode 100644
index 0000000..21726ef
--- /dev/null
+++ b/dosfsck/lfn.h
@@ -0,0 +1,20 @@
+/* lfn.h - Functions for handling VFAT long filenames */
+
+/* Written 1998 by Roman Hodek */
+
+
+#ifndef _LFN_H
+#define _LFN_H
+
+void lfn_reset( void );
+/* Reset the state of the LFN parser. */
+
+void lfn_add_slot( DIR_ENT *de, loff_t dir_offset );
+/* Process a dir slot that is a VFAT LFN entry. */
+
+char *lfn_get( DIR_ENT *de );
+/* Retrieve the long name for the proper dir entry. */
+
+void lfn_check_orphaned(void);
+
+#endif
diff --git a/man/dosfsck.8 b/man/dosfsck.8
deleted file mode 100644
index d363c68..0000000
--- a/man/dosfsck.8
+++ /dev/null
@@ -1,112 +0,0 @@
-.TH DOSFSCK 8 "2010\-01\-31" "3.0.9" "check and repair MS\-DOS filesystems"
-
-.SH NAME
-\fBdosfsck\fR \- check and repair MS\-DOS filesystems
-
-.SH SYNOPSIS
-\fBdosfsck\fR|\fBfsck.msdos\fR|\fBfsck.vfat\fR [\-aAflnrtvVwy] [\-d \fIPATH\fR \-d\ \fI...\fR] [\-u\ \fIPATH\fR \-u \fI...\fR] \fIDEVICE\fR
-
-.SH DESCRIPTION
-\fBdosfsck\fR verifies the consistency of MS\-DOS filesystems and optionally tries to repair them.
-.PP
-The following filesystem problems can be corrected (in this order):
-.IP "*" 4
-FAT contains invalid cluster numbers. Cluster is changed to EOF.
-.IP "*" 4
-File's cluster chain contains a loop. The loop is broken.
-.IP "*" 4
-Bad clusters (read errors). The clusters are marked bad and they are removed from files owning them. This check is optional.
-.IP "*" 4
-Directories with a large number of bad entries (probably corrupt). The directory can be deleted.
-.IP "*" 4
-Files . and .. are non\-directories. They can be deleted or renamed.
-.IP "*" 4
-Directories . and .. in root directory. They are deleted.
-.IP "*" 4
-Bad filenames. They can be renamed.
-.IP "*" 4
-Duplicate directory entries. They can be deleted or renamed.
-.IP "*" 4
-Directories with non\-zero size field. Size is set to zero.
-.IP "*" 4
-Directory . does not point to parent directory. The start pointer is adjusted.
-.IP "*" 4
-Directory .. does not point to parent of parent directory. The start pointer is adjusted.
-.IP "*" 4
-Start cluster number of a file is invalid. The file is truncated.
-.IP "*" 4
-File contains bad or free clusters. The file is truncated.
-.IP "*" 4
-File's cluster chain is longer than indicated by the size fields. The file is truncated.
-.IP "*" 4
-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.
-.IP "*" 4
-File's cluster chain is shorter than indicated by the size fields. The file is truncated.
-.IP "*" 4
-Clusters are marked as used but are not owned by a file. They are marked as free.
-.PP
-Additionally, the following problems are detected, but not repaired:
-.IP "*" 4
-Invalid parameters in boot sector.
-.IP "*" 4
-Absence of . and .. entries in non\-root directories
-.PP
-When \fBdosfsck\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.
-
-.SH OPTIONS
-.IP "\fB\-a\fR" 4
-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.
-.IP "\fB\-A\fR" 4
-Use Atari variation of the MS\-DOS filesystem. This is default if \fBdosfsck\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).
-.IP "\fB\-d\fR" 4
-Delete the specified file. If more that one file with that name exists, the first one is deleted.
-.IP "\fB\-f\fR" 4
-Salvage unused cluster chains to files. By default, unused clusters are added to the free disk space except in auto mode (\fB\-a\fR).
-.IP "\fB\-l\fR" 4
-List path names of files being processed.
-.IP "\fB\-n\fR" 4
-No\-operation mode: non\-interactively check for errors, but don't write
-anything to the filesystem.
-.IP "\fB\-r\fR" 4
-Interactively repair the filesystem. The user is asked for advice whenever
-there is more than one approach to fix an inconsistency.
-.IP "\fB\-t\fR" 4
-Mark unreadable clusters as bad.
-.IP "\fB\-u\fR" 4
-Try to undelete the specified file. \fBdosfsck\fR tries to allocate a chain of contiguous unallocated clusters beginning with the start cluster of the undeleted file.
-.IP "\fB\-v\fR" 4
-Verbose mode. Generates slightly more output.
-.IP "\fB\-V\fR" 4
-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.
-.IP "\fB\-w\fR" 4
-Write changes to disk immediately.
-.IP "\fB\-y\fR" 4
-Same as \fB\-a\fR (automatically repair filesystem) for compatibility with other fsck tools.
-.PP
-\fBNote:\fR If \fB\-a\fR and \fB\-r\fR are absent, the filesystem is only checked, but not repaired.
-
-.SH "EXIT STATUS"
-.IP "0" 4
-No recoverable errors have been detected.
-.IP "1" 4
-Recoverable errors have been detected or \fBdosfsck\fR has discovered an internal inconsistency.
-.IP "2" 4
-Usage error. \fBdosfsck\fR did not access the filesystem.
-
-.SH FILES
-.IP "fsck0000.rec, fsck0001.rec, ..." 4
-When recovering from a corrupted filesystem, \fBdosfsck\fR dumps recovered data into files named 'fsckNNNN.rec' in the top level directory of the filesystem.
-
-.SH BUGS
-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.
-
-.SH SEE ALSO
-\fBdosfslabel\fR(8)
-.br
-\fBmkdosfs\fR(8)
-
-.SH HOMEPAGE
-More information about \fBdosfsck\fR and \fBdosfstools\fR can be found at <\fIhttp://www.daniel\-baumann.ch/software/dosfstools/\fR>.
-
-.SH AUTHORS
-\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 <\fIdaniel@debian.org\fR>.
diff --git a/man/dosfslabel.8 b/man/dosfslabel.8
deleted file mode 100644
index 293ff5d..0000000
--- a/man/dosfslabel.8
+++ /dev/null
@@ -1,29 +0,0 @@
-.TH DOSFSLABEL 8 "2010\-01\-31" "3.0.9" "set or get MS\-DOS filesystem label"
-
-.SH NAME
-\fBdosfslabel\fR \- set or get MS\-DOS filesystem label
-
-.SH SYNOPSIS
-\fBdosfslabel\fR \fIDEVICE\fR [\fILABEL\fR]
-
-.SH DESCRIPTION
-\fBdosfslabel\fR set or gets a MS\-DOS filesystem label from a given device.
-.PP
-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 characters.
-
-.SH OPTIONS
-.IP "\fB\-h\fR, \fB\-\-help\fR" 4
-Displays a help message.
-.IP "\fB\-V\fR, \fB\-\-version\fR" 4
-Shows version.
-
-.SH SEE ALSO
-\fBdosfsck\fR(8)
-.br
-\fBmkdosfs\fR(8)
-
-.SH HOMEPAGE
-More information about \fBdosfsck\fR and \fBdosfstools\fR can be found at <\fIhttp://www.daniel\-baumann.ch/software/dosfstools/\fR>.
-
-.SH AUTHORS
-\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 <\fIdaniel@debian.org\fR>.
diff --git a/mkdosfs/.cvsignore b/mkdosfs/.cvsignore
new file mode 100644
index 0000000..7c78b65
--- /dev/null
+++ b/mkdosfs/.cvsignore
@@ -0,0 +1 @@
+mkdosfs
diff --git a/doc/ANNOUNCE.mkdosfs b/mkdosfs/ANNOUNCE
index 1f02ea2..1f02ea2 100644
--- a/doc/ANNOUNCE.mkdosfs
+++ b/mkdosfs/ANNOUNCE
diff --git a/mkdosfs/COPYING b/mkdosfs/COPYING
new file mode 100644
index 0000000..8857e53
--- /dev/null
+++ b/mkdosfs/COPYING
@@ -0,0 +1,347 @@
+ The GPL below is copyrighted by the Free Software
+ Foundation, but the instance of code that it refers to (the mkdosfs
+ utility is copyrighted by me
+
+ - David Hudson
+
+----------------------------------------
+
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 675 Mass Ave, Cambridge, MA 02139, USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ Appendix: How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) 19yy <name of author>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) 19yy name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Library General
+Public License instead of this License.
diff --git a/doc/ChangeLog.mkdosfs b/mkdosfs/ChangeLog
index e39d9d6..c428a50 100644
--- a/doc/ChangeLog.mkdosfs
+++ b/mkdosfs/ChangeLog
@@ -8,7 +8,7 @@
(superblock) format of DOS 3.3+, with support for volume ID's and
volume labels (volume labels are also written to the root
directory, as they should).
-
+
18th February 1994 Dave Hudson (dave@humbug.demon.co.uk)
Released version 0.2 - clears a bug in the FAT sizing code.
diff --git a/mkdosfs/Makefile b/mkdosfs/Makefile
new file mode 100644
index 0000000..1a9365e
--- /dev/null
+++ b/mkdosfs/Makefile
@@ -0,0 +1,31 @@
+
+OBJECTS = mkdosfs.o
+
+all: mkdosfs
+
+mkdosfs: $(OBJECTS)
+ $(CC) $(LDFLAGS) $^ -o $@
+
+.c.o:
+ $(CC) $(CFLAGS) -c $< -o $@
+
+install: mkdosfs
+ mkdir -p $(SBINDIR) $(MANDIR)
+ install -m 755 mkdosfs $(SBINDIR)
+ install -m 644 mkdosfs.8 $(MANDIR)
+ rm -f $(SBINDIR)/mkfs.msdos
+ rm -f $(SBINDIR)/mkfs.vfat
+ ln -s mkdosfs $(SBINDIR)/mkfs.msdos
+ ln -s mkdosfs $(SBINDIR)/mkfs.vfat
+ rm -f $(MANDIR)/mkfs.msdos.8
+ ln -s mkdosfs.8 $(MANDIR)/mkfs.msdos.8
+ ln -s mkdosfs.8 $(MANDIR)/mkfs.vfat.8
+
+clean :
+ echo *.o *.i *.s *~ \#*# core .#* .new*
+ rm -f *.o *.i *.s *~ \#*# core .#* .new*
+
+distclean: clean
+ rm -f mkdosfs *.a *# *.orig *.rej TAGS
+
+dep:
diff --git a/doc/README.mkdosfs b/mkdosfs/README
index ae93ada..ae93ada 100644
--- a/doc/README.mkdosfs
+++ b/mkdosfs/README
diff --git a/mkdosfs/mkdosfs-ygg-0.3b.lsm b/mkdosfs/mkdosfs-ygg-0.3b.lsm
new file mode 100644
index 0000000..9f78af7
--- /dev/null
+++ b/mkdosfs/mkdosfs-ygg-0.3b.lsm
@@ -0,0 +1,19 @@
+Begin3
+Title: mkdosfs
+Version: Yggdrasil 0.3b
+Entered-date: 05MAY95
+Description: A utility to create MS-DOS FAT filesystems under
+ Linux. This version uses the enhanced boot
+ sector/superblock format of DOS 3.3+ as well as
+ provides a default dummy boot sector code.
+ This is a bug fix release.
+Keywords: mkdosfs, DOS FAT filesystem
+Author: Dave Hudson <dave@humbug.demon.co.uk>
+Maintained-by: H. Peter Anvin <hpa@yggdrasil.com>
+Primary-site: sunsite.unc.edu /pub/Linux/system/Filesystems/dosfs
+ 18531 mkdosfs-ygg-0.3b.tar.gz
+Alternate-site: ftp.yggdrasil.com /pub/dist/mkdosfs
+Original-site:
+Platform: Linux
+Copying-policy: GPL
+End
diff --git a/man/mkdosfs.8 b/mkdosfs/mkdosfs.8
index 9100c39..614b5fc 100644
--- a/man/mkdosfs.8
+++ b/mkdosfs/mkdosfs.8
@@ -4,21 +4,18 @@
.B mkdosfs
\- create an MS-DOS file system under Linux
.SH SYNOPSIS
-.B mkdosfs|mkfs.msdos|mkfs.vfat
-[
-.B \-a
-]
+.B mkdosfs
[
.B \-A
]
[
-.B \-b
+.B \-b
.I sector-of-backup
]
[
.B \-c
]
-[
+[
.B \-l
.I filename
]
@@ -55,7 +52,7 @@
.I root-dir-entries
]
[
-.B \-R
+.B \-R
.I number-of-reserved-sectors
]
[
@@ -82,28 +79,19 @@ is the special file corresponding to the device (e.g /dev/hdXX).
.I block-count
is the number of blocks on the device. If omitted,
.B mkdosfs
-automatically determines the file system size.
+automatically determiness the file system size.
.SH OPTIONS
.TP
-.B \-a
-Normally, for any filesystem except very small ones, \fBmkdosfs\fP
-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.
-.TP
.B \-A
-Use Atari variation of the MS-DOS file system. This is default if
+Use Atari variation of the MS-DOS filesystem. This is default if
\fBmkdosfs\fP 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, \fBmkdosfs\fP 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 file systems are managed by raising the logical sector size.
+Larger filesystems are managed by raising the logical sector size.
Under Atari format, an Atari-compatible serial number for the
-file system is generated, and a 12 bit FAT is used only for file systems
+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\fP
option. Some PC-specific boot sector fields aren't written, and a boot
@@ -138,7 +126,9 @@ more than 2 FATs.
.BI \-F " FAT-size"
Specifies the type of file allocation tables used (12, 16 or 32 bit).
If nothing is specified, \fBmkdosfs\fR will automatically select
-between 12, 16 and 32 bit, whatever fits better for the file system size.
+between 12 and 16 bit, whatever fits better for the filesystem size.
+32 bit FAT (FAT32 format) must (still) be selected explicitly if you
+want it.
.TP
.BI \-h " number-of-hidden-sectors "
Select the number of hidden sectors in the volume. Apparently some
@@ -147,18 +137,17 @@ such hidden sectors, this option allows you to satisfy them. Assumes
\'0\' if no value is given on the command line.
.TP
.I \-i " volume-id"
-Sets the volume ID of the newly created file system;
+Sets the volume ID of the newly created filesystem;
.I volume-id
is a 32-bit hexadecimal number (for example, 2e24ec82). The default
-is a number which depends on the file system creation time.
+is a number which depends on the filesystem creation time.
.TP
.B \-I
-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.
+Normally you are not allowed to use any 'full' fixed disk devices.
.B mkdosfs
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 file system can go directly to the whole disk. Under other OSes
+when usind MO disks. One doesn't always need partitions on MO disks.
+The filesytem can go directly to the whole disk. Under other OSes
this is known as the 'superfloppy' format.
This switch will force
@@ -170,14 +159,14 @@ Read the bad blocks list from
.IR filename .
.TP
.BI \-m " message-file"
-Sets the message the user receives on attempts to boot this file system
+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.
+If the filename is a hyphen (-), the text is taken from standard input.
.TP
.BI \-n " volume-name"
-Sets the volume name (label) of the file system. The volume name can
+Sets the volume name (label) of the filesystem. The volume name can
be up to 11 characters long. The default is no label.
.TP
.BI \-r " root-dir-entries"
@@ -185,7 +174,7 @@ Select the number of entries available in the root directory. The
default is 112 or 224 for floppies and 512 for hard disks.
.TP
.BI \-R " number-of-reserved-sectors "
-Select the number of reserved sectors. With FAT32 format at least 2
+Select the number of reserved sectos. With FAT32 format at least 2
reserved sectors are needed, the default is 32. Otherwise the default
is 1 (only the boot sector).
.TP
@@ -202,7 +191,7 @@ and greater than or equal to 512, i.e. 512, 1024, 2048, 4096, 8192,
Verbose execution.
.SH BUGS
.B mkdosfs
-can not create boot-able file systems. This isn't as easy as you might
+can not create bootable filesystems. This isn't as easy as you might
think at first glance for various reasons and has been discussed a lot
already.
.B mkdosfs
@@ -211,14 +200,13 @@ simply will not support it ;)
Dave Hudson - <dave@humbug.demon.co.uk>; modified by Peter Anvin
<hpa@yggdrasil.com>. Fixes and additions by Roman Hodek
<roman@hodek.net> for Debian/GNU Linux.
-.SH ACKNOWLEDGMENTS
+.SH ACKNOWLEDGEMENTS
.B mkdosfs
is based on code from
.BR mke2fs
(written by Remy Card - <card@masi.ibp.fr>) which is itself based on
-.BR mkfs
+.BR mkfs
(written by Linus Torvalds - <torvalds@cs.helsinki.fi>).
.SH SEE ALSO
.BR dosfsck (8),
-.BR dosfslabel (8),
.BR mkfs (8)
diff --git a/src/mkdosfs.c b/mkdosfs/mkdosfs.c
index bfa80a3..19ca88c 100644
--- a/src/mkdosfs.c
+++ b/mkdosfs/mkdosfs.c
@@ -1,29 +1,13 @@
-/* mkdosfs.c - utility to create FAT/MS-DOS filesystems
-
- Copyright (C) 1991 Linus Torvalds <torvalds@klaava.helsinki.fi>
- Copyright (C) 1992-1993 Remy Card <card@masi.ibp.fr>
- Copyright (C) 1993-1994 David Hudson <dave@humbug.demon.co.uk>
- Copyright (C) 1998 H. Peter Anvin <hpa@zytor.com>
- Copyright (C) 1998-2005 Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de>
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- On Debian systems, the complete text of the GNU General Public License
- can be found in /usr/share/common-licenses/GPL-3 file.
-*/
-
-/* Description: Utility to allow an MS-DOS filesystem to be created
+/*
+ Filename: mkdosfs.c
+ Version: 0.3b (Yggdrasil)
+ Author: Dave Hudson
+ Started: 24th August 1994
+ Last Updated: 7th May 1998
+ Updated by: Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de>
+ Target O/S: Linux (2.x)
+
+ Description: Utility to allow an MS-DOS filesystem to be created
under Linux. A lot of the basic structure of this program has been
borrowed from Remy Card's "mke2fs" code.
@@ -39,15 +23,35 @@
- Atari format support
- New options -A, -S, -C
- Support for filesystems > 2GB
- - FAT32 support */
+ - FAT32 support
+
+ Copying: Copyright 1993, 1994 David Hudson (dave@humbug.demon.co.uk)
+
+ Portions copyright 1992, 1993 Remy Card (card@masi.ibp.fr)
+ and 1991 Linus Torvalds (torvalds@klaava.helsinki.fi)
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
/* Include the header files */
-#include "version.h"
+#include "../version.h"
#include <fcntl.h>
#include <linux/hdreg.h>
-#include <sys/mount.h>
+#include <linux/fs.h>
#include <linux/fd.h>
#include <endian.h>
#include <mntent.h>
@@ -57,13 +61,17 @@
#include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
-#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
#include <time.h>
#include <errno.h>
+#include <linux/version.h>
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
+# define __KERNEL__
# include <asm/types.h>
+# undef __KERNEL__
+#endif
#if __BYTE_ORDER == __BIG_ENDIAN
@@ -82,7 +90,7 @@
#define CT_LE_W(v) CF_LE_W(v)
#define CT_LE_L(v) CF_LE_L(v)
#endif /* defined(__le16_to_cpu) */
-
+
#else
#define CF_LE_W(v) (v)
@@ -284,7 +292,6 @@ static int check = FALSE; /* Default to no readablity checking */
static int verbose = 0; /* Default to verbose mode off */
static long volume_id; /* Volume ID number */
static time_t create_time; /* Creation time */
-static struct timeval create_timeval; /* Creation time */
static char volume_name[] = " "; /* Volume name */
static unsigned long long blocks; /* Number of blocks in filesystem */
static int sector_size = 512; /* Size of a logical sector */
@@ -302,7 +309,6 @@ static struct msdos_boot_sector bs; /* Boot sector data */
static int start_data_sector; /* Sector number for the start of the data area */
static int start_data_block; /* Block number for the start of the data area */
static unsigned char *fat; /* File allocation table */
-static unsigned alloced_fat_length; /* # of FAT sectors we can keep in memory */
static unsigned char *info_sector; /* FAT32 info sector */
static struct msdos_dir_entry *root_dir; /* Root directory */
static int size_root_dir; /* Size of the root directory in bytes */
@@ -310,8 +316,7 @@ static int sectors_per_cluster = 0; /* Number of sectors per disk cluster */
static int root_dir_entries = 0; /* Number of root directory entries */
static char *blank_sector; /* Blank sector - all zeros */
static int hidden_sectors = 0; /* Number of hidden sectors */
-static int malloc_entire_fat = FALSE; /* Whether we should malloc() the entire FAT or not */
-static int align_structures = TRUE; /* Whether to enforce alignment */
+
/* Function prototype definitions */
@@ -538,7 +543,7 @@ valid_offset (int fd, loff_t offset)
static unsigned long long
count_blocks (char *filename)
{
- loff_t high, low;
+ off_t high, low;
int fd;
if ((fd = open (filename, O_RDONLY)) < 0)
@@ -592,7 +597,6 @@ establish_params (int device_num,int size)
long loop_size;
struct hd_geometry geometry;
struct floppy_struct param;
- int def_root_dir_entries = 512;
if ((0 == device_num) || ((device_num & 0xff00) == 0x0200))
/* file image or floppy disk */
@@ -605,7 +609,7 @@ establish_params (int device_num,int size)
case 720:
param.sect = 9 ;
param.head = 2;
- break;
+ break;
case 1440:
param.sect = 9;
param.head = 2;
@@ -628,7 +632,7 @@ establish_params (int device_num,int size)
param.head = 64;
break;
}
-
+
}
else /* is a floppy diskette */
{
@@ -642,32 +646,37 @@ establish_params (int device_num,int size)
case 720: /* 5.25", 2, 9, 40 - 360K */
bs.media = (char) 0xfd;
bs.cluster_size = (char) 2;
- def_root_dir_entries = 112;
+ bs.dir_entries[0] = (char) 112;
+ bs.dir_entries[1] = (char) 0;
break;
case 1440: /* 3.5", 2, 9, 80 - 720K */
bs.media = (char) 0xf9;
bs.cluster_size = (char) 2;
- def_root_dir_entries = 112;
+ bs.dir_entries[0] = (char) 112;
+ bs.dir_entries[1] = (char) 0;
break;
case 2400: /* 5.25", 2, 15, 80 - 1200K */
bs.media = (char) 0xf9;
bs.cluster_size = (char)(atari_format ? 2 : 1);
- def_root_dir_entries = 224;
+ bs.dir_entries[0] = (char) 224;
+ bs.dir_entries[1] = (char) 0;
break;
-
+
case 5760: /* 3.5", 2, 36, 80 - 2880K */
bs.media = (char) 0xf0;
bs.cluster_size = (char) 2;
- def_root_dir_entries = 224;
+ bs.dir_entries[0] = (char) 224;
+ bs.dir_entries[1] = (char) 0;
break;
case 2880: /* 3.5", 2, 18, 80 - 1440K */
floppy_default:
bs.media = (char) 0xf0;
bs.cluster_size = (char)(atari_format ? 2 : 1);
- def_root_dir_entries = 224;
+ bs.dir_entries[0] = (char) 224;
+ bs.dir_entries[1] = (char) 0;
break;
default: /* Anything else */
@@ -679,7 +688,7 @@ establish_params (int device_num,int size)
}
else if ((device_num & 0xff00) == 0x0700) /* This is a loop device */
{
- if (ioctl (dev, BLKGETSIZE, &loop_size))
+ if (ioctl (dev, BLKGETSIZE, &loop_size))
die ("unable to get loop device size");
switch (loop_size) /* Assuming the loop device -> floppy later */
@@ -689,7 +698,8 @@ establish_params (int device_num,int size)
bs.heads = CF_LE_W(2);
bs.media = (char) 0xfd;
bs.cluster_size = (char) 2;
- def_root_dir_entries = 112;
+ bs.dir_entries[0] = (char) 112;
+ bs.dir_entries[1] = (char) 0;
break;
case 1440: /* 3.5", 2, 9, 80 - 720K */
@@ -697,7 +707,8 @@ establish_params (int device_num,int size)
bs.heads = CF_LE_W(2);
bs.media = (char) 0xf9;
bs.cluster_size = (char) 2;
- def_root_dir_entries = 112;
+ bs.dir_entries[0] = (char) 112;
+ bs.dir_entries[1] = (char) 0;
break;
case 2400: /* 5.25", 2, 15, 80 - 1200K */
@@ -705,9 +716,10 @@ establish_params (int device_num,int size)
bs.heads = CF_LE_W(2);
bs.media = (char) 0xf9;
bs.cluster_size = (char)(atari_format ? 2 : 1);
- def_root_dir_entries = 224;
+ bs.dir_entries[0] = (char) 224;
+ bs.dir_entries[1] = (char) 0;
break;
-
+
case 5760: /* 3.5", 2, 36, 80 - 2880K */
bs.secs_track = CF_LE_W(36);
bs.heads = CF_LE_W(2);
@@ -722,7 +734,8 @@ establish_params (int device_num,int size)
bs.heads = CF_LE_W(2);
bs.media = (char) 0xf0;
bs.cluster_size = (char)(atari_format ? 2 : 1);
- def_root_dir_entries = 224;
+ bs.dir_entries[0] = (char) 224;
+ bs.dir_entries[1] = (char) 0;
break;
default: /* Anything else: default hd setup */
@@ -738,8 +751,8 @@ establish_params (int device_num,int size)
{
/* Can we get the drive geometry? (Note I'm not too sure about */
/* whether to use HDIO_GETGEO or HDIO_REQ) */
- if (ioctl (dev, HDIO_GETGEO, &geometry) || geometry.sectors == 0 || geometry.heads == 0) {
- printf ("unable to get drive geometry, using default 255/63\n");
+ if (ioctl (dev, HDIO_GETGEO, &geometry)) {
+ printf ("unable to get drive geometry, using default 255/63");
bs.secs_track = CT_LE_W(63);
bs.heads = CT_LE_W(255);
}
@@ -749,47 +762,33 @@ establish_params (int device_num,int size)
}
def_hd_params:
bs.media = (char) 0xf8; /* Set up the media descriptor for a hard drive */
+ bs.dir_entries[0] = (char) 0; /* Default to 512 entries */
+ bs.dir_entries[1] = (char) 2;
if (!size_fat && blocks*SECTORS_PER_BLOCK > 1064960) {
if (verbose) printf("Auto-selecting FAT32 for large filesystem\n");
size_fat = 32;
}
if (size_fat == 32) {
- /* For FAT32, try to do the same as M$'s format command
- * (see http://www.win.tue.nl/~aeb/linux/fs/fat/fatgen103.pdf p. 20):
- * fs size <= 260M: 0.5k clusters
- * fs size <= 8G: 4k clusters
- * fs size <= 16G: 8k clusters
- * fs size > 16G: 16k clusters
+ /* For FAT32, try to do the same as M$'s format command:
+ * fs size < 256M: 0.5k clusters
+ * fs size < 8G: 4k clusters
+ * fs size < 16G: 8k clusters
+ * fs size >= 16G: 16k clusters
*/
unsigned long sz_mb =
(blocks+(1<<(20-BLOCK_SIZE_BITS))-1) >> (20-BLOCK_SIZE_BITS);
- bs.cluster_size = sz_mb > 16*1024 ? 32 :
- sz_mb > 8*1024 ? 16 :
- sz_mb > 260 ? 8 :
- 1;
+ bs.cluster_size = sz_mb >= 16*1024 ? 32 :
+ sz_mb >= 8*1024 ? 16 :
+ sz_mb >= 256 ? 8 :
+ 1;
}
else {
/* FAT12 and FAT16: start at 4 sectors per cluster */
bs.cluster_size = (char) 4;
}
}
-
- if (!root_dir_entries)
- root_dir_entries = def_root_dir_entries;
}
-/*
- * If alignment is enabled, round the first argument up to the second; the
- * latter must be a power of two.
- */
-static unsigned int
-align_object (unsigned int sectors, unsigned int clustsize)
-{
- if (align_structures)
- return (sectors + clustsize - 1) & ~(clustsize - 1);
- else
- return sectors;
-}
/* Create the filesystem data tables */
@@ -798,14 +797,15 @@ setup_tables (void)
{
unsigned num_sectors;
unsigned cluster_count = 0, fat_length;
+ unsigned fatdata; /* Sectors for FATs + data area */
struct tm *ctime;
struct msdos_volume_info *vi = (size_fat == 32 ? &bs.fat32.vi : &bs.oldfat.vi);
-
+
if (atari_format)
/* On Atari, the first few bytes of the boot sector are assigned
* differently: The jump code is only 2 bytes (and m68k machine code
* :-), then 6 bytes filler (ignored), then 3 byte serial number. */
- memcpy( bs.system_id-1, "mkdosf", 6 );
+ strncpy( bs.system_id-1, "mkdosf", 6 );
else
strcpy (bs.system_id, "mkdosfs");
if (sectors_per_cluster)
@@ -814,8 +814,17 @@ setup_tables (void)
{
/* Under FAT32, the root dir is in a cluster chain, and this is
* signalled by bs.dir_entries being 0. */
+ bs.dir_entries[0] = bs.dir_entries[1] = (char) 0;
root_dir_entries = 0;
}
+ else if (root_dir_entries)
+ {
+ /* Override default from establish_params() */
+ bs.dir_entries[0] = (char) (root_dir_entries & 0x00ff);
+ bs.dir_entries[1] = (char) ((root_dir_entries & 0xff00) >> 8);
+ }
+ else
+ root_dir_entries = bs.dir_entries[0] + (bs.dir_entries[1] << 8);
if (atari_format) {
bs.system_id[5] = (unsigned char) (volume_id & 0x000000ff);
@@ -831,7 +840,7 @@ setup_tables (void)
if (!atari_format) {
memcpy(vi->volume_label, volume_name, 11);
-
+
memcpy(bs.boot_jump, dummy_boot_jump, 3);
/* Patch in the correct offset to the boot code */
bs.boot_jump[1] = ((size_fat == 32 ?
@@ -883,24 +892,13 @@ setup_tables (void)
num_sectors = (long long)blocks*BLOCK_SIZE/sector_size;
if (!atari_format) {
- unsigned fatdata1216; /* Sectors for FATs + data area (FAT12/16) */
- unsigned fatdata32; /* Sectors for FATs + data area (FAT32) */
unsigned fatlength12, fatlength16, fatlength32;
unsigned maxclust12, maxclust16, maxclust32;
unsigned clust12, clust16, clust32;
int maxclustsize;
- unsigned root_dir_sectors = cdiv(root_dir_entries*32, sector_size);
-
- /*
- * If the filesystem is 8192 sectors or less (4 MB with 512-byte
- * sectors, i.e. floppy size), don't align the data structures.
- */
- if (num_sectors <= 8192) {
- if (align_structures && verbose >= 2)
- printf ("Disabling alignment due to tiny filesystem\n");
-
- align_structures = FALSE;
- }
+
+ fatdata = num_sectors - cdiv (root_dir_entries * 32, sector_size) -
+ reserved_sectors;
if (sectors_per_cluster)
bs.cluster_size = maxclustsize = sectors_per_cluster;
@@ -908,25 +906,22 @@ setup_tables (void)
/* An initial guess for bs.cluster_size should already be set */
maxclustsize = 128;
+ if (verbose >= 2)
+ printf( "%d sectors for FAT+data, starting with %d sectors/cluster\n",
+ fatdata, bs.cluster_size );
do {
- fatdata32 = num_sectors
- - align_object(reserved_sectors, bs.cluster_size);
- fatdata1216 = fatdata32
- - align_object(root_dir_sectors, bs.cluster_size);
-
if (verbose >= 2)
printf( "Trying with %d sectors/cluster:\n", bs.cluster_size );
/* The factor 2 below avoids cut-off errors for nr_fats == 1.
* The "nr_fats*3" is for the reserved first two FAT entries */
- clust12 = 2*((long long) fatdata1216*sector_size + nr_fats*3) /
+ clust12 = 2*((long long) fatdata *sector_size + nr_fats*3) /
(2*(int) bs.cluster_size * sector_size + nr_fats*3);
- fatlength12 = cdiv(((clust12+2) * 3 + 1) >> 1, sector_size);
- fatlength12 = align_object(fatlength12, bs.cluster_size);
+ fatlength12 = cdiv (((clust12+2) * 3 + 1) >> 1, sector_size);
/* Need to recalculate number of clusters, since the unused parts of the
* FATS and data area together could make up space for an additional,
* not really present cluster. */
- clust12 = (fatdata1216 - nr_fats*fatlength12)/bs.cluster_size;
+ clust12 = (fatdata - nr_fats*fatlength12)/bs.cluster_size;
maxclust12 = (fatlength12 * 2 * sector_size) / 3;
if (maxclust12 > MAX_CLUST_12)
maxclust12 = MAX_CLUST_12;
@@ -939,14 +934,13 @@ setup_tables (void)
printf( "FAT12: too much clusters\n" );
}
- clust16 = ((long long) fatdata1216 *sector_size + nr_fats*4) /
+ clust16 = ((long long) fatdata *sector_size + nr_fats*4) /
((int) bs.cluster_size * sector_size + nr_fats*2);
fatlength16 = cdiv ((clust16+2) * 2, sector_size);
- fatlength16 = align_object(fatlength16, bs.cluster_size);
/* Need to recalculate number of clusters, since the unused parts of the
* FATS and data area together could make up space for an additional,
* not really present cluster. */
- clust16 = (fatdata1216 - nr_fats*fatlength16)/bs.cluster_size;
+ clust16 = (fatdata - nr_fats*fatlength16)/bs.cluster_size;
maxclust16 = (fatlength16 * sector_size) / 2;
if (maxclust16 > MAX_CLUST_16)
maxclust16 = MAX_CLUST_16;
@@ -968,14 +962,13 @@ setup_tables (void)
clust16 = 0;
}
- clust32 = ((long long) fatdata32 *sector_size + nr_fats*8) /
+ clust32 = ((long long) fatdata *sector_size + nr_fats*8) /
((int) bs.cluster_size * sector_size + nr_fats*4);
- fatlength32 = cdiv((clust32+2) * 4, sector_size);
- fatlength32 = align_object(fatlength32, bs.cluster_size);
+ fatlength32 = cdiv ((clust32+2) * 4, sector_size);
/* Need to recalculate number of clusters, since the unused parts of the
* FATS and data area together could make up space for an additional,
* not really present cluster. */
- clust32 = (fatdata32 - nr_fats*fatlength32)/bs.cluster_size;
+ clust32 = (fatdata - nr_fats*fatlength32)/bs.cluster_size;
maxclust32 = (fatlength32 * sector_size) / 4;
if (maxclust32 > MAX_CLUST_32)
maxclust32 = MAX_CLUST_32;
@@ -1043,33 +1036,20 @@ setup_tables (void)
break;
case 32:
- if (clust32 < MIN_CLUST_32)
- fprintf(stderr, "WARNING: Not enough clusters for a 32 bit FAT!\n");
cluster_count = clust32;
fat_length = fatlength32;
bs.fat_length = CT_LE_W(0);
bs.fat32.fat32_length = CT_LE_L(fatlength32);
memcpy(vi->fs_type, MSDOS_FAT32_SIGN, 8);
- root_dir_entries = 0;
break;
-
+
default:
die("FAT not 12, 16 or 32 bits");
}
-
- /* Adjust the reserved number of sectors for alignment */
- reserved_sectors = align_object(reserved_sectors, bs.cluster_size);
- bs.reserved = CT_LE_W(reserved_sectors);
-
- /* Adjust the number of root directory entries to help enforce alignment */
- if (align_structures) {
- root_dir_entries = align_object(root_dir_sectors, bs.cluster_size)
- * (sector_size >> 5);
- }
}
else {
- unsigned clusters, maxclust, fatdata;
-
+ unsigned clusters, maxclust;
+
/* GEMDOS always uses a 12 bit FAT on floppies, and always a 16 bit FAT on
* hard disks. So use 12 bit if the size of the file system suggests that
* this fs is for a floppy disk, if the user hasn't explicitly requested a
@@ -1115,7 +1095,7 @@ setup_tables (void)
if (verbose >= 2)
printf( "ss=%d: #clu=%d, fat_len=%d, maxclu=%d\n",
sector_size, clusters, fat_length, maxclust );
-
+
/* last 10 cluster numbers are special (except FAT32: 4 high bits rsvd);
* first two numbers are reserved */
if (maxclust <= (size_fat == 32 ? MAX_CLUST_32 : (1<<size_fat)-0x10) &&
@@ -1132,7 +1112,7 @@ setup_tables (void)
num_sectors >>= 1;
sector_size <<= 1;
} while( sector_size <= GEMDOS_MAX_SECTOR_SIZE );
-
+
if (sector_size > GEMDOS_MAX_SECTOR_SIZE)
die( "Would need a sector size > 16k, which GEMDOS can't work with");
@@ -1148,9 +1128,6 @@ setup_tables (void)
bs.sector_size[0] = (char) (sector_size & 0x00ff);
bs.sector_size[1] = (char) ((sector_size & 0xff00) >> 8);
- bs.dir_entries[0] = (char) (root_dir_entries & 0x00ff);
- bs.dir_entries[1] = (char) ((root_dir_entries & 0xff00) >> 8);
-
if (size_fat == 32)
{
/* set up additional FAT32 fields */
@@ -1175,7 +1152,7 @@ setup_tables (void)
bs.fat32.backup_boot = CT_LE_W(backup_boot);
memset( &bs.fat32.reserved2, 0, sizeof(bs.fat32.reserved2) );
}
-
+
if (atari_format) {
/* Just some consistency checks */
if (num_sectors >= GEMDOS_MAX_SECTORS)
@@ -1209,7 +1186,7 @@ setup_tables (void)
die ("Attempting to create a too large file system");
}
-
+
/* The two following vars are in hard sectors, i.e. 512 byte sectors! */
start_data_sector = (reserved_sectors + nr_fats * fat_length) *
(sector_size/HARD_SECTOR_SIZE);
@@ -1223,7 +1200,7 @@ setup_tables (void)
{
printf("%s has %d head%s and %d sector%s per track,\n",
device_name, CF_LE_W(bs.heads), (CF_LE_W(bs.heads) != 1) ? "s" : "",
- CF_LE_W(bs.secs_track), (CF_LE_W(bs.secs_track) != 1) ? "s" : "");
+ CF_LE_W(bs.secs_track), (CF_LE_W(bs.secs_track) != 1) ? "s" : "");
printf("logical sector size is %d,\n",sector_size);
printf("using 0x%02x media descriptor, with %d sectors;\n",
(int) (bs.media), num_sectors);
@@ -1233,19 +1210,9 @@ setup_tables (void)
printf ("FAT size is %d sector%s, and provides %d cluster%s.\n",
fat_length, (fat_length != 1) ? "s" : "",
cluster_count, (cluster_count != 1) ? "s" : "");
- printf ("There %s %u reserved sector%s.\n",
- (reserved_sectors != 1) ? "are" : "is",
- reserved_sectors,
- (reserved_sectors != 1) ? "s" : "");
-
- if (size_fat != 32) {
- unsigned root_dir_entries =
- bs.dir_entries[0] + ((bs.dir_entries[1]) * 256);
- unsigned root_dir_sectors =
- cdiv (root_dir_entries*32, sector_size);
- printf ("Root directory contains %u slots and uses %u sectors.\n",
- root_dir_entries, root_dir_sectors);
- }
+ if (size_fat != 32)
+ printf ("Root directory contains %d slots.\n",
+ (int) (bs.dir_entries[0]) + (int) (bs.dir_entries[1]) * 256);
printf ("Volume ID is %08lx, ", volume_id &
(atari_format ? 0x00ffffff : 0xffffffff));
if ( strcmp(volume_name, " ") )
@@ -1256,15 +1223,10 @@ setup_tables (void)
/* Make the file allocation tables! */
- if (malloc_entire_fat)
- alloced_fat_length = fat_length;
- else
- alloced_fat_length = 1;
-
- if ((fat = (unsigned char *) malloc (alloced_fat_length * sector_size)) == NULL)
+ if ((fat = (unsigned char *) malloc (fat_length * sector_size)) == NULL)
die ("unable to allocate space for FAT image in memory");
- memset( fat, 0, alloced_fat_length * sector_size );
+ memset( fat, 0, fat_length * sector_size );
mark_FAT_cluster (0, 0xffffffff); /* Initial fat entries */
mark_FAT_cluster (1, 0xffffffff);
@@ -1290,8 +1252,7 @@ setup_tables (void)
if ( memcmp(volume_name, " ", 11) )
{
struct msdos_dir_entry *de = &root_dir[0];
- memcpy(de->name, volume_name, 8);
- memcpy(de->ext, volume_name+8, 3);
+ memcpy(de->name, volume_name, 11);
de->attr = ATTR_VOLUME;
ctime = localtime(&create_time);
de->time = CT_LE_W((unsigned short)((ctime->tm_sec >> 1) +
@@ -1311,7 +1272,7 @@ setup_tables (void)
if (size_fat == 32) {
/* For FAT32, create an info sector */
struct fat32_fsinfo *info;
-
+
if (!(info_sector = malloc( sector_size )))
die("Out of memory");
memset(info_sector, 0, sector_size);
@@ -1333,7 +1294,7 @@ setup_tables (void)
/* Info sector also must have boot sign */
*(__u16 *)(info_sector + 0x1fe) = CT_LE_W(BOOT_SIGN);
}
-
+
if (!(blank_sector = malloc( sector_size )))
die( "Out of memory" );
memset(blank_sector, 0, sector_size);
@@ -1395,13 +1356,8 @@ write_tables (void)
}
/* seek to start of FATS and write them all */
seekto( reserved_sectors*sector_size, "first FAT" );
- for (x = 1; x <= nr_fats; x++) {
- int y;
- int blank_fat_length = fat_length - alloced_fat_length;
- writebuf( fat, alloced_fat_length * sector_size, "FAT" );
- for (y=0; y<blank_fat_length; y++)
- writebuf( blank_sector, sector_size, "FAT" );
- }
+ for (x = 1; x <= nr_fats; x++)
+ writebuf( fat, fat_length * sector_size, "FAT" );
/* Write the root directory directly after the last FAT. This is the root
* dir area on FAT12/16, and the first cluster on FAT32. */
writebuf( (char *) root_dir, size_root_dir, "root directory" );
@@ -1419,10 +1375,10 @@ void
usage (void)
{
fatal_error("\
-Usage: mkdosfs [-a][-A][-c][-C][-v][-I][-l bad-block-file][-b backup-boot-sector]\n\
- [-m boot-msg-file][-n volume-name][-i volume-id]\n\
- [-s sectors-per-cluster][-S logical-sector-size][-f number-of-FATs]\n\
- [-h hidden-sectors][-F fat-size][-r root-dir-entries][-R reserved-sectors]\n\
+Usage: mkdosfs [-A] [-c] [-C] [-v] [-I] [-l bad-block-file] [-b backup-boot-sector]\n\
+ [-m boot-msg-file] [-n volume-name] [-i volume-id]\n\
+ [-s sectors-per-cluster] [-S logical-sector-size] [-f number-of-FATs]\n\
+ [-h hidden-sectors] [-F fat-size] [-r root-dir-entries] [-R reserved-sectors]\n\
/dev/name [blocks]\n");
}
@@ -1467,9 +1423,8 @@ main (int argc, char **argv)
struct stat statbuf;
int i = 0, pos, ch;
int create = 0;
- unsigned long long cblocks = 0;
- int min_sector_size;
-
+ unsigned long long cblocks;
+
if (argc && *argv) { /* What's the program name? */
char *p;
program_name = *argv;
@@ -1477,15 +1432,14 @@ main (int argc, char **argv)
program_name = p+1;
}
- gettimeofday(&create_timeval, NULL);
- create_time = create_timeval.tv_sec;
- volume_id = (u_int32_t)( (create_timeval.tv_sec << 20) | create_timeval.tv_usec ); /* Default volume ID = creation time, fudged for more uniqueness */
+ time(&create_time);
+ volume_id = (long)create_time; /* Default volume ID = creation time */
check_atari();
-
+
printf ("%s " VERSION " (" VERSION_DATE ")\n",
program_name);
- while ((c = getopt (argc, argv, "aAb:cCf:F:Ii:l:m:n:r:R:s:S:h:v")) != EOF)
+ while ((c = getopt (argc, argv, "AbcCf:F:Ii:l:m:n:r:R:s:S:h:v")) != EOF)
/* Scan the command line for options */
switch (c)
{
@@ -1493,10 +1447,6 @@ main (int argc, char **argv)
atari_format = !atari_format;
break;
- case 'a': /* a : skip alignment */
- align_structures = FALSE;
- break;
-
case 'b': /* b : location of backup boot sector */
backup_boot = (int) strtol (optarg, &tmp, 0);
if (*tmp || backup_boot < 2 || backup_boot > 0xffff)
@@ -1505,10 +1455,9 @@ main (int argc, char **argv)
usage ();
}
break;
-
+
case 'c': /* c : Check FS as we build it */
check = TRUE;
- malloc_entire_fat = TRUE; /* Need to be able to mark clusters bad */
break;
case 'C': /* C : Create a new file */
@@ -1558,7 +1507,6 @@ main (int argc, char **argv)
case 'l': /* l : Bad block filename */
listfile = optarg;
- malloc_entire_fat = TRUE; /* Need to be able to mark clusters bad */
break;
case 'm': /* m : Set boot message */
@@ -1619,10 +1567,10 @@ main (int argc, char **argv)
while( i < BOOTCODE_SIZE-1 )
dummy_boot_code[i++] = '\0';
dummy_boot_code[BOOTCODE_SIZE-1] = '\0'; /* Just in case */
-
+
if ( ch != EOF )
printf ("Warning: message too long; truncated\n");
-
+
if ( msgfile != stdin )
fclose(msgfile);
}
@@ -1649,7 +1597,7 @@ main (int argc, char **argv)
usage ();
}
break;
-
+
case 's': /* s : Sectors per cluster */
sectors_per_cluster = (int) strtol (optarg, &tmp, 0);
if (*tmp || (sectors_per_cluster != 1 && sectors_per_cluster != 2
@@ -1678,7 +1626,7 @@ main (int argc, char **argv)
case 'v': /* v : Verbose execution */
++verbose;
break;
-
+
default:
printf( "Unknown option: %c\n", c );
usage ();
@@ -1686,12 +1634,6 @@ main (int argc, char **argv)
if (optind < argc)
{
device_name = argv[optind]; /* Determine the number of blocks in the FS */
-
- if (!device_name) {
- printf("No device specified.\n");
- usage();
- }
-
if (!create)
cblocks = count_blocks (device_name); /* Have a look and see! */
}
@@ -1727,15 +1669,15 @@ main (int argc, char **argv)
if (!create) {
check_mount (device_name); /* Is the device already mounted? */
- dev = open (device_name, O_EXCL|O_RDWR); /* Is it a suitable device to build the FS on? */
+ dev = open (device_name, O_RDWR); /* Is it a suitable device to build the FS on? */
if (dev < 0)
die ("unable to open %s");
}
else {
- loff_t offset = blocks*BLOCK_SIZE - 1;
+ off_t offset = blocks*BLOCK_SIZE - 1;
char null = 0;
/* create the file */
- dev = open( device_name, O_EXCL|O_RDWR|O_CREAT|O_TRUNC, 0666 );
+ dev = open( device_name, O_RDWR|O_CREAT|O_TRUNC, 0666 );
if (dev < 0)
die("unable to create %s");
/* seek to the intended end-1, and write one byte. this creates a
@@ -1747,7 +1689,7 @@ main (int argc, char **argv)
if (llseek( dev, 0, SEEK_SET ) != 0)
die( "seek failed" );
}
-
+
if (fstat (dev, &statbuf) < 0)
die ("unable to stat %s");
if (!S_ISBLK (statbuf.st_mode)) {
@@ -1768,32 +1710,9 @@ main (int argc, char **argv)
(statbuf.st_rdev & 0xff3f) == 0x0d00 || /* xd */
(statbuf.st_rdev & 0xff3f) == 0x1600 ) /* hdc, hdd */
)
- die ("Device partition expected, not making filesystem on entire device '%s' (use -I to override)");
-
- if (sector_size_set)
- {
- if (ioctl(dev, BLKSSZGET, &min_sector_size) >= 0)
- if (sector_size < min_sector_size)
- {
- sector_size = min_sector_size;
- fprintf(stderr, "Warning: sector size was set to %d (minimal for this device)\n", sector_size);
- }
- }
- else
- {
- if (ioctl(dev, BLKSSZGET, &min_sector_size) >= 0)
- {
- sector_size = min_sector_size;
- sector_size_set = 1;
- }
- }
+ die ("Will not try to make filesystem on full-disk device '%s' (use -I if wanted)");
- if (sector_size > 4096)
- fprintf(stderr,
- "Warning: sector size is set to %d > 4096, such filesystem will not propably mount\n",
- sector_size);
-
- establish_params (statbuf.st_rdev,statbuf.st_size);
+ establish_params (statbuf.st_rdev,statbuf.st_size);
/* Establish the media parameters */
setup_tables (); /* Establish the file system tables */
@@ -1807,3 +1726,9 @@ main (int argc, char **argv)
exit (0); /* Terminate with no errors! */
}
+
+
+/* That's All Folks */
+/* Local Variables: */
+/* tab-width: 8 */
+/* End: */
diff --git a/packaging/dosfstools-2.11-buffer.patch b/packaging/dosfstools-2.11-buffer.patch
new file mode 100644
index 0000000..ba9c775
--- /dev/null
+++ b/packaging/dosfstools-2.11-buffer.patch
@@ -0,0 +1,11 @@
+--- mkdosfs/mkdosfs.c
++++ mkdosfs/mkdosfs.c
+@@ -809,7 +809,7 @@
+ /* On Atari, the first few bytes of the boot sector are assigned
+ * differently: The jump code is only 2 bytes (and m68k machine code
+ * :-), then 6 bytes filler (ignored), then 3 byte serial number. */
+- strncpy( bs.system_id-1, "mkdosf", 6 );
++ strncpy( bs.system_id, "mkdosf", 6);
+ else
+ strcpy (bs.system_id, "mkdosfs");
+ if (sectors_per_cluster)
diff --git a/packaging/dosfstools-2.11-linuxfs.patch b/packaging/dosfstools-2.11-linuxfs.patch
new file mode 100644
index 0000000..4a0ca5d
--- /dev/null
+++ b/packaging/dosfstools-2.11-linuxfs.patch
@@ -0,0 +1,10 @@
+--- mkdosfs/mkdosfs.c
++++ mkdosfs/mkdosfs.c
+@@ -51,6 +51,6 @@
+
+ #include <fcntl.h>
+ #include <linux/hdreg.h>
+-#include <linux/fs.h>
++#include <sys/mount.h>
+ #include <linux/fd.h>
+ #include <endian.h>
diff --git a/packaging/dosfstools-2.11-mkdosfs-geo0.diff b/packaging/dosfstools-2.11-mkdosfs-geo0.diff
new file mode 100644
index 0000000..1e93522
--- /dev/null
+++ b/packaging/dosfstools-2.11-mkdosfs-geo0.diff
@@ -0,0 +1,35 @@
+the HDIO_GETGEO ioctl works on device mapper devices but returns
+zero heads and sectors. Therefore let's a) assume dummy values in
+that case in mkdosfs and b) don't consider such fat file systems as
+invalid in dosfsck. The Linux kernel accepts them anyways.
+Index: dosfstools-2.11/mkdosfs/mkdosfs.c
+===================================================================
+--- dosfstools-2.11.orig/mkdosfs/mkdosfs.c
++++ dosfstools-2.11/mkdosfs/mkdosfs.c
+@@ -751,8 +751,8 @@ establish_params (int device_num,int siz
+ {
+ /* Can we get the drive geometry? (Note I'm not too sure about */
+ /* whether to use HDIO_GETGEO or HDIO_REQ) */
+- if (ioctl (dev, HDIO_GETGEO, &geometry)) {
+- printf ("unable to get drive geometry, using default 255/63");
++ if (ioctl (dev, HDIO_GETGEO, &geometry) || geometry.sectors == 0 || geometry.heads == 0) {
++ printf ("unable to get drive geometry, using default 255/63\n");
+ bs.secs_track = CT_LE_W(63);
+ bs.heads = CT_LE_W(255);
+ }
+Index: dosfstools-2.11/dosfsck/boot.c
+===================================================================
+--- dosfstools-2.11.orig/dosfsck/boot.c
++++ dosfstools-2.11/dosfsck/boot.c
+@@ -353,9 +353,11 @@ void read_boot(DOS_FS *fs)
+ if (logical_sector_size & (SECTOR_SIZE-1))
+ die("Logical sector size (%d bytes) is not a multiple of the physical "
+ "sector size.",logical_sector_size);
++#if 0 /* linux kernel doesn't check that either */
+ /* ++roman: On Atari, these two fields are often left uninitialized */
+ if (!atari_format && (!b.secs_track || !b.heads))
+ die("Invalid disk format in boot sector.");
++#endif
+ if (verbose) dump_boot(fs,&b,logical_sector_size);
+ }
+
diff --git a/packaging/dosfstools-2.11-o_excl.patch b/packaging/dosfstools-2.11-o_excl.patch
new file mode 100644
index 0000000..5c9c493
--- /dev/null
+++ b/packaging/dosfstools-2.11-o_excl.patch
@@ -0,0 +1,20 @@
+--- mkdosfs/mkdosfs.c
++++ mkdosfs/mkdosfs.c
+@@ -1673,7 +1673,7 @@
+
+ if (!create) {
+ check_mount (device_name); /* Is the device already mounted? */
+- dev = open (device_name, O_RDWR); /* Is it a suitable device to build the FS on? */
++ dev = open (device_name, O_EXCL|O_RDWR); /* Is it a suitable device to build the FS on? */
+ if (dev < 0)
+ die ("unable to open %s");
+ }
+@@ -1681,7 +1681,7 @@
+ off_t offset = blocks*BLOCK_SIZE - 1;
+ char null = 0;
+ /* create the file */
+- dev = open( device_name, O_RDWR|O_CREAT|O_TRUNC, 0666 );
++ dev = open( device_name, O_EXCL|O_RDWR|O_CREAT|O_TRUNC, 0666 );
+ if (dev < 0)
+ die("unable to create %s");
+ /* seek to the intended end-1, and write one byte. this creates a
diff --git a/packaging/dosfstools-2.11-unaligned.patch b/packaging/dosfstools-2.11-unaligned.patch
new file mode 100644
index 0000000..23c9614
--- /dev/null
+++ b/packaging/dosfstools-2.11-unaligned.patch
@@ -0,0 +1,145 @@
+---
+ dosfsck/boot.c | 131 ++++++++++++++++++++++++++++++++++++++++++++++++++++-----
+ 1 file changed, 120 insertions(+), 11 deletions(-)
+
+--- a/dosfsck/boot.c
++++ b/dosfsck/boot.c
+@@ -34,18 +34,127 @@ static struct {
+ { 0xff, "5.25\" 320k floppy 2s/40tr/8sec" },
+ };
+
+-#if defined __alpha || defined __ia64__ || defined __s390x__ || defined __x86_64__ || defined __ppc64__
+-/* Unaligned fields must first be copied byte-wise */
+-#define GET_UNALIGNED_W(f) \
+- ({ \
+- unsigned short __v; \
+- memcpy( &__v, &f, sizeof(__v) ); \
+- CF_LE_W( *(unsigned short *)&f ); \
+- })
+-#else
+-#define GET_UNALIGNED_W(f) CF_LE_W( *(unsigned short *)&f )
+-#endif
+
++/*
++ * For the benefit of those who are trying to port Linux to another
++ * architecture, here are some C-language equivalents.
++ *
++ * This is based almost entirely upon Richard Henderson's
++ * asm-alpha/unaligned.h implementation. Some comments were
++ * taken from David Mosberger's asm-ia64/unaligned.h header.
++ */
++
++#include <linux/types.h>
++
++/*
++ * The main single-value unaligned transfer routines.
++ */
++#define get_unaligned(ptr) \
++ __get_unaligned((ptr), sizeof(*(ptr)))
++#define put_unaligned(x,ptr) \
++ __put_unaligned((__u64)(x), (ptr), sizeof(*(ptr)))
++
++/*
++ * This function doesn't actually exist. The idea is that when
++ * someone uses the macros below with an unsupported size (datatype),
++ * the linker will alert us to the problem via an unresolved reference
++ * error.
++ */
++extern void bad_unaligned_access_length(void) __attribute__((noreturn));
++
++struct __una_u64 { __u64 x __attribute__((packed)); };
++struct __una_u32 { __u32 x __attribute__((packed)); };
++struct __una_u16 { __u16 x __attribute__((packed)); };
++
++/*
++ * Elemental unaligned loads
++ */
++
++static inline __u64 __uldq(const __u64 *addr)
++{
++ const struct __una_u64 *ptr = (const struct __una_u64 *) addr;
++ return ptr->x;
++}
++
++static inline __u32 __uldl(const __u32 *addr)
++{
++ const struct __una_u32 *ptr = (const struct __una_u32 *) addr;
++ return ptr->x;
++}
++
++static inline __u16 __uldw(const __u16 *addr)
++{
++ const struct __una_u16 *ptr = (const struct __una_u16 *) addr;
++ return ptr->x;
++}
++
++/*
++ * Elemental unaligned stores
++ */
++
++static inline void __ustq(__u64 val, __u64 *addr)
++{
++ struct __una_u64 *ptr = (struct __una_u64 *) addr;
++ ptr->x = val;
++}
++
++static inline void __ustl(__u32 val, __u32 *addr)
++{
++ struct __una_u32 *ptr = (struct __una_u32 *) addr;
++ ptr->x = val;
++}
++
++static inline void __ustw(__u16 val, __u16 *addr)
++{
++ struct __una_u16 *ptr = (struct __una_u16 *) addr;
++ ptr->x = val;
++}
++
++#define __get_unaligned(ptr, size) ({ \
++ const void *__gu_p = ptr; \
++ __u64 val; \
++ switch (size) { \
++ case 1: \
++ val = *(const __u8 *)__gu_p; \
++ break; \
++ case 2: \
++ val = __uldw(__gu_p); \
++ break; \
++ case 4: \
++ val = __uldl(__gu_p); \
++ break; \
++ case 8: \
++ val = __uldq(__gu_p); \
++ break; \
++ default: \
++ bad_unaligned_access_length(); \
++ }; \
++ (__typeof__(*(ptr)))val; \
++})
++
++#define __put_unaligned(val, ptr, size) \
++do { \
++ void *__gu_p = ptr; \
++ switch (size) { \
++ case 1: \
++ *(__u8 *)__gu_p = val; \
++ break; \
++ case 2: \
++ __ustw(val, __gu_p); \
++ break; \
++ case 4: \
++ __ustl(val, __gu_p); \
++ break; \
++ case 8: \
++ __ustq(val, __gu_p); \
++ break; \
++ default: \
++ bad_unaligned_access_length(); \
++ }; \
++} while(0)
++
++
++#define GET_UNALIGNED_W(f) CF_LE_W( get_unaligned ((unsigned short *)&f))
+
+ static char *get_media_descr( unsigned char media )
+ {
diff --git a/packaging/dosfstools-2.11-unsupported-sector-size.patch b/packaging/dosfstools-2.11-unsupported-sector-size.patch
new file mode 100644
index 0000000..ca1a3e3
--- /dev/null
+++ b/packaging/dosfstools-2.11-unsupported-sector-size.patch
@@ -0,0 +1,14 @@
+--- mkdosfs/mkdosfs.c
++++ mkdosfs/mkdosfs.c
+@@ -1731,6 +1731,11 @@
+ }
+ }
+
++ if (sector_size > 4096)
++ fprintf(stderr,
++ "Warning: sector size is set to %d > 4096, such filesystem will not propably mount\n",
++ sector_size);
++
+ establish_params (statbuf.st_rdev,statbuf.st_size);
+ /* Establish the media parameters */
+
diff --git a/packaging/dosfstools-2.11_determine-sector-size.patch b/packaging/dosfstools-2.11_determine-sector-size.patch
new file mode 100644
index 0000000..2d63b0c
--- /dev/null
+++ b/packaging/dosfstools-2.11_determine-sector-size.patch
@@ -0,0 +1,35 @@
+--- mkdosfs/mkdosfs.c
++++ mkdosfs/mkdosfs.c
+@@ -1424,6 +1424,7 @@
+ int i = 0, pos, ch;
+ int create = 0;
+ unsigned long long cblocks;
++ int min_sector_size;
+
+ if (argc && *argv) { /* What's the program name? */
+ char *p;
+@@ -1712,6 +1713,24 @@
+ )
+ die ("Will not try to make filesystem on full-disk device '%s' (use -I if wanted)");
+
++ if (sector_size_set)
++ {
++ if (ioctl(dev, BLKSSZGET, &min_sector_size) >= 0)
++ if (sector_size < min_sector_size)
++ {
++ sector_size = min_sector_size;
++ fprintf(stderr, "Warning: sector size was set to %d (minimal for this device)\n", sector_size);
++ }
++ }
++ else
++ {
++ if (ioctl(dev, BLKSSZGET, &min_sector_size) >= 0)
++ {
++ sector_size = min_sector_size;
++ sector_size_set = 1;
++ }
++ }
++
+ establish_params (statbuf.st_rdev,statbuf.st_size);
+ /* Establish the media parameters */
+
diff --git a/packaging/dosfstools.changes b/packaging/dosfstools.changes
index ec0cb9b..9400f73 100644
--- a/packaging/dosfstools.changes
+++ b/packaging/dosfstools.changes
@@ -1,163 +1,240 @@
-* Thu Oct 28 2010 Yan Yin <yan.yin@intel.com> - 3.0.10
-- Update to 3.0.10
+-------------------------------------------------------------------
+Tue Jun 24 15:15:31 CEST 2008 - pgajdos@suse.cz
-* Sun Feb 28 2010 Anas Nashif <anas.nashif@intel.com> - 3.0.9
-- Spec cleanup
+- added warning for creation msdos on filesystem with sector size
+ greater than 4096 [fate#303325] (unsupported-sector-size.patch)
-* Mon Feb 01 2010 Yi Yang <yi.y.yang@intel.com> - 3.0.9
-- Update to 3.0.9
+-------------------------------------------------------------------
+Thu Sep 6 16:26:57 CEST 2007 - pgajdos@suse.cz
-* Tue Sep 22 2009 Anas Nashif <anas.nashif@intel.com> - 3.0.1
-- Update to 3.0.1
+- determine sector size of device automatically or if -S parameter
+ present, verify, that it's not under physical sector size
+ (determine-sector-size.patch)
-* Tue Feb 19 2008 Fedora Release Engineering <rel-eng@fedoraproject.org> - 2.11-9
-- Autorebuild for GCC 4.3
+-------------------------------------------------------------------
+Thu Aug 9 17:08:41 CEST 2007 - olh@suse.de
-* Tue Apr 3 2007 Jeremy Katz <katzj@redhat.com> - 2.11-8
-- add dosfslabel (originally by Peter Jones)
+- remove inclusion of asm/unaligned.h, use private copy of
+ asm-generic/unaligned.h
-* Wed Feb 21 2007 Peter Vrabec <pvrabec@redhat.com> 2.11-7
-- fix debuginfo package (#225707)
+-------------------------------------------------------------------
+Thu Apr 26 12:14:35 CEST 2007 - lnussel@suse.de
-* Wed Jul 12 2006 Jesse Keating <jkeating@redhat.com> - 2.11-6.1
-- rebuild
+- remove obsolete subfs patch
+- fix handling of zero heads and sectors
-* Fri Jun 30 2006 Peter Vrabec <pvrabec@redhat.com> 2.11-6
-- fix upgrade path (#197231)
+-------------------------------------------------------------------
+Wed Apr 4 10:29:59 CEST 2007 - pgajdos@suse.cz
-* Thu May 11 2006 Peter Vrabec <pvrabec@redhat.com> 2.11-5
-- fix work with disk image files > 4GB (#191198)
+- added Supplements: filesystem(vfat) line to spec file
+ [fate#301966]
-* Fri Feb 10 2006 Jesse Keating <jkeating@redhat.com> - 2.11-4.2
-- bump again for double-long bug on ppc(64)
+-------------------------------------------------------------------
+Tue Jan 30 14:04:38 CET 2007 - prusnak@suse.cz
-* Tue Feb 07 2006 Jesse Keating <jkeating@redhat.com> - 2.11-4.1
-- rebuilt for new gcc4.1 snapshot and glibc changes
+- mkdosfs now opens device with O_EXCL [#238687]
-* Sun Dec 16 2005 Jakub Jelinek <jakub@redhat.com> 2.11-4
-- rebuilt with GCC 4.1
-- make it build with -D_FORTIFY_SOURCE=2
+-------------------------------------------------------------------
+Sat May 27 19:15:11 CEST 2006 - schwab@suse.de
-* Sun Nov 06 2005 Peter Vrabec <pvrabec@redhat.com> 2.11-3
-- fix LFS (#172369)
+- Don't strip binaries.
-* Fri Nov 04 2005 Peter Vrabec <pvrabec@redhat.com> 2.11-2
-- fix LFS
+-------------------------------------------------------------------
+Wed Jan 25 21:35:33 CET 2006 - mls@suse.de
-* Wed Oct 12 2005 Peter Vrabec <pvrabec@redhat.com> 2.11-1
-- upgrade
+- converted neededforbuild to BuildRequires
-* Thu Apr 28 2005 Peter Vrabec <pvrabec@redhat.com> 2.10-3
-- if HDIO_GETGEO fails, print a warning and default to H=255,S=63 (#155950)
+-------------------------------------------------------------------
+Tue Nov 8 14:25:16 CET 2005 - dmueller@suse.de
-* Thu Mar 17 2005 Peter Vrabec <pvrabec@redhat.com> 2.10-2
-- rebuild
+- don't build as root
-* Thu Dec 09 2004 Peter Vrabec <pvrabec@redhat.com> 2.10-1
-- updated to 2.10
+-------------------------------------------------------------------
+Mon Nov 7 16:15:50 CET 2005 - yxu@suse.de
-* Wed Nov 10 2004 Martin Stransky <stransky@redhat.com> 2.8-16
-- add check for minimum count of clusters in FAT16 and FAT32
+- fixed overflowing buffer problem
-* Wed Oct 13 2004 Peter Vrabec <pvrabec@redhat.com> 2.8-15
-- fix fat_length type in boot.c. (same problem like in RHEL bug #135293)
+-------------------------------------------------------------------
+Mon Apr 11 11:49:11 CEST 2005 - mcihar@suse.cz
-* Wed Oct 6 2004 Jeremy Katz <katzj@redhat.com> - 2.8-14
-- fix rebuilding (#134834)
+- update to 2.11
+- use sys/mount.h instead of linux/fs.h, this fixes compilation with current GCC
-* Tue Jun 15 2004 Elliot Lee <sopwith@redhat.com>
-- rebuilt
+-------------------------------------------------------------------
+Tue Feb 15 16:53:10 CET 2005 - mcihar@suse.cz
-* Fri Feb 13 2004 Elliot Lee <sopwith@redhat.com>
-- rebuilt
+- deal with subfs (bug #50838)
+ - use /proc/mounts if available for deciding whether device is
+ mounted or not
+ - just issue warning if it is mounted as subfs
-* Wed Sep 3 2003 Bill Nottingham <notting@redhat.com> 2.8-11
-- rebuild
+-------------------------------------------------------------------
+Thu Aug 19 14:05:43 CEST 2004 - mcihar@suse.cz
-* Wed Sep 3 2003 Bill Nottingham <notting@redhat.com> 2.8-10
-- don't rely on <linux/msdos_fs.h> including <asm/byteorder.h>
+- merged some dosfsck fixes from FreeDOS
-* Tue Jun 24 2003 Jeremy Katz <katzj@redhat.com> 2.8-9
-- rebuild
+-------------------------------------------------------------------
+Thu Jul 15 17:18:39 CEST 2004 - schwab@suse.de
-* Tue Jun 24 2003 Jeremy Katz <katzj@redhat.com> 2.8-8
-- add patch from Vince Busam (http://www.sixpak.org/dosfstools/) to do auto
- creation of FAT32 on large devices (#97308)
+- Fix unaligned accesses [#40296].
-* Wed Jun 04 2003 Elliot Lee <sopwith@redhat.com>
-- rebuilt
+-------------------------------------------------------------------
+Wed Jun 2 00:50:55 CEST 2004 - ro@suse.de
-* Wed Feb 19 2003 Jeremy Katz <katzj@redhat.com> 2.8-6
-- handle getting the size of loop devices properly (part of #84351)
+- avoid inclusion of linux/audit.h
-* Wed Jan 22 2003 Tim Powers <timp@redhat.com>
-- rebuilt
+-------------------------------------------------------------------
+Thu Mar 18 15:47:09 CET 2004 - mcihar@suse.cz
-* Thu Dec 12 2002 Elliot Lee <sopwith@redhat.com> 2.8-4
-- Patch2 for errno
+- fix dosfsck man page (pointed out in bug #34757)
-* Fri Jun 21 2002 Tim Powers <timp@redhat.com>
-- automated rebuild
+-------------------------------------------------------------------
+Mon Mar 08 19:46:55 CET 2004 - mcihar@suse.cz
-* Thu May 23 2002 Tim Powers <timp@redhat.com>
-- automated rebuild
+- fix broken dosfsck (bug #34757)
-* Thu Mar 07 2002 Florian La Roche <Florian.LaRoche@redhat.de>
-- update to version 2.8
+-------------------------------------------------------------------
+Thu Jan 29 21:42:36 CET 2004 - mcihar@suse.cz
-* Fri Jul 6 2001 Preston Brown <pbrown@redhat.com>
-- major upgrade to v2.7.
-- forward port old ia64 patch (now incorporated) s390 additions
+- include more documentation
-* Tue Mar 20 2001 Oliver Paukstadt <oliver.paukstadt@millenux.com>
-- ported to zSeries (64 bit)
+-------------------------------------------------------------------
+Thu Jan 15 08:56:16 CET 2004 - kukuk@suse.de
-* Wed Jul 12 2000 Prospector <bugzilla@redhat.com>
-- automatic rebuild
+- Make compile with kernel 2.6.1 headers
-* Fri Jun 17 2000 Bill Nottingham <notting@redhat.com>
-- hard link mkdosfs
+-------------------------------------------------------------------
+Thu Oct 23 16:56:31 CEST 2003 - schwab@suse.de
-* Thu Jun 15 2000 Matt Wilson <msw@redhat.com>
-- FHS
-- patch to build against 2.4 kernel headers (patch3)
+- Don't define llseek to lseek64, creates infinite recursion.
-* Fri Apr 28 2000 Bill Nottingham <notting@redhat.com>
-- fix for ia64
+-------------------------------------------------------------------
+Tue Oct 14 12:04:31 CEST 2003 - mcihar@suse.cz
-* Thu Feb 3 2000 Matt Wilson <msw@redhat.com>
-- remove mkdosfs.8 symlink, symlink mkdosfs.8.gz to mkfs.msdos.8.gz
+- install links also for {fsck,mkfs}.vfat + man pages (bug #32284)
-* Wed Feb 02 2000 Cristian Gafton <gafton@redhat.com>
-- fix descriptions and summary
-- man pages are compressed
+-------------------------------------------------------------------
+Mon Sep 29 13:32:05 CEST 2003 - mcihar@suse.cz
-* Thu Dec 16 1999 Cristian Gafton <gafton@redhat.com>
-- fix the 2.88MB drives (patch from hjl)
+- updated to 2.10:
+ - dosfsck: various 64-bit fixes and removed some warnings by Michal
+ Cihar <mcihar@suse.cz>
+ - mkdosfs: better error message if called without parameters (also
+ suggested by Michal)
-* Mon Aug 16 1999 Matt Wilson <msw@redhat.com>
-- updated to 2.2
+-------------------------------------------------------------------
+Mon Jun 09 17:36:02 CEST 2003 - mcihar@suse.cz
-* Sun Jun 27 1999 Matt Wilson <msw@redhat.com>
-- changed to new maintainer, renamed to dosfstools
+- new upstream version 2.9:
+ * dosfsck: Fix potential for "Internal error: next_cluster on bad cluster".
+ * dosfsck: When clearing long file names, don't overwrite the dir
+ entries with all zeros, but put 0xe5 into the first byte.
+ Otherwise, some OSes stop reading the directory at that point...
+ * dosfsck: in statistics printed by -v, fix 32bit overflow in number
+ of data bytes.
+ * dosfsck: fix an potential overflow in "too many clusters" check
+ * dosfsck: allow FAT size > 32MB.
+ * dosfsck: allow for only one FAT
+ * dosfsck: with -v, also check that last sector of the filesystem can
+ be read (in case a partition is smaller than the fs thinks)
+- realy working large file support
+- don't package obsolette documentation
-* Sat Apr 17 1999 Jeff Johnson <jbj@redhat.com>
-- fix mkdosfs on sparc (#1746)
+-------------------------------------------------------------------
+Wed Dec 04 11:05:49 CET 2002 - mcihar@suse.cz
-* Sun Mar 21 1999 Cristian Gafton <gafton@redhat.com>
-- auto rebuild in the new build environment (release 10)
+- don't allow -fPIC on i386 in CFLAGS, even on i386-debug, because
+ this package doesn't build with it
-* Thu Jan 21 1999 Bill Nottingham <notting@redhat.com>
-- build for RH 6.0
+-------------------------------------------------------------------
+Mon Dec 2 00:00:36 CET 2002 - ro@suse.de
-* Tue Oct 13 1998 Cristian Gafton <gafton@redhat.com>
-- avoid using unsinged long on alphas
+- include errno.h where needed
-* Sun Aug 16 1998 Jeff Johnson <jbj@redhat.com>
-- build root
+-------------------------------------------------------------------
+Tue Sep 10 13:43:16 CEST 2002 - mcihar@suse.cz
-* Mon Apr 27 1998 Prospector System <bugs@redhat.com>
-- translations modified for de, fr, tr
+- added -D_FILE_OFFSET_BITS=64 to CFLAGS to support larger files/partitions
+
+-------------------------------------------------------------------
+Tue May 21 01:44:36 CEST 2002 - ro@suse.de
+
+- extend 64bit ifdefs for new platforms
+
+-------------------------------------------------------------------
+Fri Mar 1 16:16:48 CET 2002 - jantos@suse.cz
+
+- Fixed missing files in documentation (bug 13973)
+
+-------------------------------------------------------------------
+Fri Sep 14 16:37:41 CEST 2001 - schwab@suse.de
+
+- Fix crash if mkdosfs is called without arguments.
+
+-------------------------------------------------------------------
+Tue May 22 18:04:31 CEST 2001 - pblaha@suse.cz
+
+- fixed include files on ia64
+
+-------------------------------------------------------------------
+Sun Apr 8 17:45:37 CEST 2001 - schwab@suse.de
+
+- Fix to build on ia64.
+
+-------------------------------------------------------------------
+Mon Mar 5 17:11:41 CET 2001 - pblaha@suse.cz
+
+- update on 2.8
+
+-------------------------------------------------------------------
+Mon Feb 12 07:58:30 CET 2001 - ro@suse.de
+
+- don't include linux/fs.h
+
+-------------------------------------------------------------------
+Thu Jan 18 20:00:23 CET 2001 - schwab@suse.de
+
+- Add Obsoletes: dosfstls.
+
+-------------------------------------------------------------------
+Wed Jan 17 10:41:12 CET 2001 - pblaha@suse.cz
+
+- added message "not enough memory to run dosfsck\n"
+- if not free memory for malloc
+
+-------------------------------------------------------------------
+Fri Dec 22 10:14:48 CET 2000 - pblaha@suse.cz
+
+- upgrade on 2.6 and rename on dosfstools
+
+-------------------------------------------------------------------
+Mon Dec 4 16:13:17 CET 2000 - sf@suse.de
+
+- corrected patch to compile on Alpha and ia64
+
+-------------------------------------------------------------------
+Tue Nov 21 18:09:54 CET 2000 - uli@suse.de
+
+- worked around strncasecmp declaration conflict in mkdosfs.c
+
+-------------------------------------------------------------------
+Mon Nov 13 11:32:39 CET 2000 - ro@suse.de
+
+- hacked to compile on 2.4 includes
+
+-------------------------------------------------------------------
+Thu Nov 2 11:44:12 CET 2000 - pblaha@suse.cz
+
+- update to version 2.4
+
+-------------------------------------------------------------------
+Mon Jun 5 18:33:32 CEST 2000 - schwab@suse.de
+
+- Fix llseek on ia64.
+
+-------------------------------------------------------------------
+Fri Jun 2 15:32:06 MEST 2000 - bubnikv@suse.cz
+
+- new package in SuSE, version 2.2
+- makes packages dosfsck and mkdosfs obsolette
-* Thu Jul 10 1997 Erik Troan <ewt@redhat.com>
-- built against glibc
diff --git a/packaging/dosfstools.manifest b/packaging/dosfstools.manifest
new file mode 100644
index 0000000..ede5999
--- /dev/null
+++ b/packaging/dosfstools.manifest
@@ -0,0 +1,11 @@
+<manifest>
+ <request>
+ <domain name="_"/>
+ </request>
+ <assign>
+ <filesystem path="/bin/*" label="_" exec_label="none" />
+ <filesystem path="/sbin/*" label="_" exec_label="none" />
+ <filesystem path="/usr/bin/*" label="_" exec_label="none" />
+ <filesystem path="/usr/sbin/*" label="_" exec_label="none" />
+ </assign>
+</manifest>
diff --git a/packaging/dosfstools.spec b/packaging/dosfstools.spec
index 2ae191a..07e1d54 100644
--- a/packaging/dosfstools.spec
+++ b/packaging/dosfstools.spec
@@ -1,34 +1,84 @@
-Name: dosfstools
-Summary: Utilities for making and checking MS-DOS FAT filesystems on Linux
-Version: 3.0.10
-Release: 6
-License: GPLv3+
-Group: Applications/System
-Source0: http://www.daniel-baumann.ch/software/dosfstools/%{name}-%{version}.tar.bz2
-URL: http://www.daniel-baumann.ch/software/dosfstools/
-Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root
+Name: dosfstools
+Provides: mkdosfs dosfsck
+License: GPL-2.0+
+Group: System/Filesystems
+AutoReqProv: on
+Summary: Utilities for Making and Checking MS-DOS FAT File Systems on Linux
+Version: 2.11
+Release: 1
+Url: ftp://ftp.uni-erlangen.de/pub/Linux/LOCAL/dosfstools
+Source: %{name}-%{version}.tar.bz2
+Source1001: %{name}.manifest
+Patch0: %{name}-%{version}-linuxfs.patch
+Patch1: %{name}-%{version}-unaligned.patch
+Patch2: %{name}-%{version}-buffer.patch
+Patch3: %{name}-%{version}-o_excl.patch
+Patch4: %{name}-%{version}-mkdosfs-geo0.diff
+Patch5: %{name}-%{version}_determine-sector-size.patch
+Patch6: %{name}-%{version}-unsupported-sector-size.patch
+Obsoletes: mkdosfs dosfsck dosfstls
+BuildRoot: %{_tmppath}/%{name}-%{version}-build
+#Supplements: filesystem(vfat)
%description
The dosfstools package includes the mkdosfs and dosfsck utilities,
-which respectively make and check MS-DOS FAT filesystems on hard
+which respectively make and check MS-DOS FAT file systems on hard
drives or on floppies.
+
+
+Authors:
+--------
+ Dave Hudson <dave@humbug.demon.co.uk>
+ Werner Almesberger <werner.almesberger@lrc.di.epfl.ch>
+ Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de>
+
%prep
-%setup -q
+%setup
+%patch0
+%patch1 -p1
+%patch2
+%patch3
+%patch4 -p1
+%patch5
+%patch6
%build
-make %{?_smp_mflags} CFLAGS="$RPM_OPT_FLAGS -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
+cp %{SOURCE1001} .
+make OPTFLAGS="-D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE $RPM_OPT_FLAGS"
%install
-rm -rf %{buildroot}
-make DESTDIR=%{buildroot} install-bin install-man PREFIX=%{_prefix} SBINDIR=/sbin
+# directories
+install -d $RPM_BUILD_ROOT{/sbin,%{_mandir}/man8}
+# binaries
+install -m755 mkdosfs/mkdosfs $RPM_BUILD_ROOT/sbin/
+install -m755 dosfsck/dosfsck $RPM_BUILD_ROOT/sbin/
+# alternative names
+ln -sf mkdosfs $RPM_BUILD_ROOT/sbin/mkfs.msdos
+ln -sf dosfsck $RPM_BUILD_ROOT/sbin/fsck.msdos
+ln -sf mkdosfs $RPM_BUILD_ROOT/sbin/mkfs.vfat
+ln -sf dosfsck $RPM_BUILD_ROOT/sbin/fsck.vfat
+# man pages
+install -m 644 mkdosfs/mkdosfs.8 $RPM_BUILD_ROOT%{_mandir}/man8/
+install -m 644 dosfsck/dosfsck.8 $RPM_BUILD_ROOT%{_mandir}/man8/
+# man pages for alternative names
+ln -sf mkdosfs.8.gz $RPM_BUILD_ROOT%{_mandir}/man8/mkfs.msdos.8.gz
+ln -sf dosfsck.8.gz $RPM_BUILD_ROOT%{_mandir}/man8/fsck.msdos.8.gz
+ln -sf mkdosfs.8.gz $RPM_BUILD_ROOT%{_mandir}/man8/mkfs.vfat.8.gz
+ln -sf dosfsck.8.gz $RPM_BUILD_ROOT%{_mandir}/man8/fsck.vfat.8.gz
+# documentation
+install -m755 -d $RPM_BUILD_ROOT/%{_docdir}/%{name}/dosfsck
+install -m755 -d $RPM_BUILD_ROOT/%{_docdir}/%{name}/mkdosfs
+install -m644 CHANGES TODO README.Atari $RPM_BUILD_ROOT/%{_docdir}/%{name}/
+install -m644 dosfsck/{COPYING,README} $RPM_BUILD_ROOT/%{_docdir}/%{name}/dosfsck
+install -m644 mkdosfs/{COPYING,README} $RPM_BUILD_ROOT/%{_docdir}/%{name}/mkdosfs
%clean
-rm -rf %{buildroot}
+rm -rf $RPM_BUILD_ROOT
%files
-%defattr(-,root,root,-)
-%doc COPYING doc/*-2.x
+%defattr(-,root,root)
+%manifest %{name}.manifest
+%doc %{_docdir}/%{name}
/sbin/*
-%doc %{_mandir}/man8/*
-
+%{_mandir}/man8/*.gz
diff --git a/src/boot.h b/src/boot.h
deleted file mode 100644
index eedf2b0..0000000
--- a/src/boot.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/* boot.h - Read and analyze ia PC/MS-DOS boot sector
-
- Copyright (C) 1993 Werner Almesberger <werner.almesberger@lrc.di.epfl.ch>
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- On Debian systems, the complete text of the GNU General Public License
- can be found in /usr/share/common-licenses/GPL-3 file.
-*/
-
-
-#ifndef _BOOT_H
-#define _BOOT_H
-
-void read_boot(DOS_FS *fs);
-void write_label(DOS_FS *fs, char *label);
-
-/* Reads the boot sector from the currently open device and initializes *FS */
-
-#endif
diff --git a/src/check.h b/src/check.h
deleted file mode 100644
index a41bb86..0000000
--- a/src/check.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/* check.h - Check and repair a PC/MS-DOS file system
-
- Copyright (C) 1993 Werner Almesberger <werner.almesberger@lrc.di.epfl.ch>
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- On Debian systems, the complete text of the GNU General Public License
- can be found in /usr/share/common-licenses/GPL-3 file.
-*/
-
-
-#ifndef _CHECK_H
-#define _CHECK_H
-
-loff_t alloc_rootdir_entry(DOS_FS *fs, DIR_ENT *de, const char *pattern);
-
-/* Allocate a free slot in the root directory for a new file. The file name is
- constructed after 'pattern', which must include a %d type format for printf
- and expand to exactly 11 characters. The name actually used is written into
- the 'de' structure, the rest of *de is cleared. The offset returned is to
- where in the filesystem the entry belongs. */
-
-int scan_root(DOS_FS *fs);
-
-/* Scans the root directory and recurses into all subdirectories. See check.c
- for all the details. Returns a non-zero integer if the file system has to
- be checked again. */
-
-#endif
diff --git a/src/dosfslabel.c b/src/dosfslabel.c
deleted file mode 100644
index aabde3f..0000000
--- a/src/dosfslabel.c
+++ /dev/null
@@ -1,127 +0,0 @@
-/* dosfslabel.c - User interface
-
- Copyright (C) 1993 Werner Almesberger <werner.almesberger@lrc.di.epfl.ch>
- Copyright (C) 1998 Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de>
- Copyright (C) 2007 Red Hat, Inc.
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- On Debian systems, the complete text of the GNU General Public License
- can be found in /usr/share/common-licenses/GPL-3 file.
-*/
-
-#include "version.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <getopt.h>
-
-#include "common.h"
-#include "dosfsck.h"
-#include "io.h"
-#include "boot.h"
-#include "fat.h"
-#include "file.h"
-#include "check.h"
-
-
-int interactive = 0,rw = 0,list = 0,test = 0,verbose = 0,write_immed = 0;
-int atari_format = 0;
-unsigned n_files = 0;
-void *mem_queue = NULL;
-
-
-static void usage(int error)
-{
- FILE *f = error ? stderr : stdout;
- int status = error ? 1 : 0;
-
- fprintf(f,"usage: dosfslabel device [label]\n");
- exit(status);
-}
-
-/*
- * ++roman: On m68k, check if this is an Atari; if yes, turn on Atari variant
- * of MS-DOS filesystem by default.
- */
-static void check_atari( void )
-{
-#ifdef __mc68000__
- FILE *f;
- char line[128], *p;
-
- if (!(f = fopen( "/proc/hardware", "r" ))) {
- perror( "/proc/hardware" );
- return;
- }
-
- while( fgets( line, sizeof(line), f ) ) {
- if (strncmp( line, "Model:", 6 ) == 0) {
- p = line + 6;
- p += strspn( p, " \t" );
- if (strncmp( p, "Atari ", 6 ) == 0)
- atari_format = 1;
- break;
- }
- }
- fclose( f );
-#endif
-}
-
-
-int main(int argc, char *argv[])
-{
- DOS_FS fs;
- rw = 0;
-
- char *device = NULL;
- char *label = NULL;
-
- check_atari();
-
- if (argc < 2 || argc > 3)
- usage(1);
-
- if (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help"))
- usage(0);
- else if (!strcmp(argv[1], "-V") || !strcmp(argv[1], "--version")) {
- printf( "dosfslabel " VERSION ", " VERSION_DATE ", FAT32, LFN\n" );
- exit(0);
- }
-
- device = argv[1];
- if (argc == 3) {
- label = argv[2];
- if (strlen(label) > 11) {
- fprintf(stderr,
- "dosfslabel: labels can be no longer than 11 characters\n");
- exit(1);
- }
- rw = 1;
- }
-
- fs_open(device, rw);
- read_boot(&fs);
- if (!rw) {
- fprintf(stdout, "%s\n", fs.label);
- exit(0);
- }
-
- write_label(&fs, label);
- fs_close(rw);
- return 0;
-}
diff --git a/src/fat.c b/src/fat.c
deleted file mode 100644
index 329e3cd..0000000
--- a/src/fat.c
+++ /dev/null
@@ -1,558 +0,0 @@
-/* fat.c - Read/write access to the FAT
-
- Copyright (C) 1993 Werner Almesberger <werner.almesberger@lrc.di.epfl.ch>
- Copyright (C) 1998 Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de>
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- On Debian systems, the complete text of the GNU General Public License
- can be found in /usr/share/common-licenses/GPL-3 file.
-*/
-
-/* FAT32, VFAT, Atari format support, and various fixes additions May 1998
- * by Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de> */
-
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include "common.h"
-#include "dosfsck.h"
-#include "io.h"
-#include "check.h"
-#include "fat.h"
-
-
-/**
- * Fetch the FAT entry for a specified cluster.
- *
- * @param[out] entry Cluster to which cluster of interest is linked
- * @param[in] fat FAT table for the partition
- * @param[in] cluster Cluster of interest
- * @param[in] fs Information from the FAT boot sectors (bits per FAT entry)
- */
-void get_fat(FAT_ENTRY *entry,void *fat,unsigned long cluster,DOS_FS *fs)
-{
- unsigned char *ptr;
-
- switch(fs->fat_bits) {
- case 12:
- ptr = &((unsigned char *) fat)[cluster*3/2];
- entry->value = 0xfff & (cluster & 1 ? (ptr[0] >> 4) | (ptr[1] << 4) :
- (ptr[0] | ptr[1] << 8));
- break;
- case 16:
- entry->value = CF_LE_W(((unsigned short *) fat)[cluster]);
- break;
- case 32:
- /* According to M$, the high 4 bits of a FAT32 entry are reserved and
- * are not part of the cluster number. So we cut them off. */
- {
- unsigned long e = CF_LE_L(((unsigned int *) fat)[cluster]);
- entry->value = e & 0xfffffff;
- entry->reserved = e >> 28;
- }
- break;
- default:
- die("Bad FAT entry size: %d bits.",fs->fat_bits);
- }
-}
-
-
-/**
- * Build a bookkeeping structure from the partition's FAT table.
- * If the partition has multiple FATs and they don't agree, try to pick a winner,
- * and queue a command to overwrite the loser.
- * One error that is fixed here is a cluster that links to something out of range.
- *
- * @param[inout] fs Information about the filesystem
- */
-void read_fat(DOS_FS *fs)
-{
- int eff_size;
- unsigned long i;
- void *first,*second = NULL;
- int first_ok,second_ok;
- unsigned long total_num_clusters;
-
- /* Clean up from previous pass */
- free(fs->fat);
- free(fs->cluster_owner);
- fs->fat = NULL;
- fs->cluster_owner = NULL;
-
- total_num_clusters = fs->clusters + 2UL;
- eff_size = (total_num_clusters*fs->fat_bits+7)/8ULL;
- first = alloc(eff_size);
- fs_read(fs->fat_start,eff_size,first);
- if (fs->nfats > 1) {
- second = alloc(eff_size);
- fs_read(fs->fat_start+fs->fat_size,eff_size,second);
- }
- if (second && memcmp(first,second,eff_size) != 0) {
- FAT_ENTRY first_media, second_media;
- get_fat(&first_media,first,0,fs);
- get_fat(&second_media,second,0,fs);
- first_ok = (first_media.value & FAT_EXTD(fs)) == FAT_EXTD(fs);
- second_ok = (second_media.value & FAT_EXTD(fs)) == FAT_EXTD(fs);
- if (first_ok && !second_ok) {
- printf("FATs differ - using first FAT.\n");
- fs_write(fs->fat_start+fs->fat_size,eff_size,first);
- }
- if (!first_ok && second_ok) {
- printf("FATs differ - using second FAT.\n");
- fs_write(fs->fat_start,eff_size,second);
- memcpy(first,second,eff_size);
- }
- if (first_ok && second_ok) {
- if (interactive) {
- printf("FATs differ but appear to be intact. Use which FAT ?\n"
- "1) Use first FAT\n2) Use second FAT\n");
- if (get_key("12","?") == '1') {
- fs_write(fs->fat_start+fs->fat_size,eff_size,first);
- } else {
- fs_write(fs->fat_start,eff_size,second);
- memcpy(first,second,eff_size);
- }
- }
- else {
- printf("FATs differ but appear to be intact. Using first "
- "FAT.\n");
- fs_write(fs->fat_start+fs->fat_size,eff_size,first);
- }
- }
- if (!first_ok && !second_ok) {
- printf("Both FATs appear to be corrupt. Giving up.\n");
- exit(1);
- }
- }
- if (second) {
- free(second);
- }
- fs->fat = (unsigned char*) first;
-
- fs->cluster_owner = alloc(total_num_clusters * sizeof(DOS_FILE *));
- memset(fs->cluster_owner, 0, (total_num_clusters * sizeof(DOS_FILE *)));
-
- /* Truncate any cluster chains that link to something out of range */
- for (i = 2; i < fs->clusters+2; i++) {
- FAT_ENTRY curEntry;
- get_fat(&curEntry, fs->fat, i, fs);
- if (curEntry.value == 1) {
- printf("Cluster %ld out of range (1). Setting to EOF.\n",
- i-2);
- set_fat(fs, i, -1);
- }
- if (curEntry.value >= fs->clusters+2 &&
- (curEntry.value < FAT_MIN_BAD(fs))) {
- printf("Cluster %ld out of range (%ld > %ld). Setting to EOF.\n",
- i-2, curEntry.value, fs->clusters+2-1);
- set_fat(fs,i,-1);
- }
- }
-}
-
-
-/**
- * Update the FAT entry for a specified cluster
- * (i.e., change the cluster it links to).
- * Queue a command to write out this change.
- *
- * @param[in,out] fs Information about the filesystem
- * @param[in] cluster Cluster to change
- * @param[in] new Cluster to link to
- * Special values:
- * 0 == free cluster
- * -1 == end-of-chain
- * -2 == bad cluster
- */
-void set_fat(DOS_FS *fs,unsigned long cluster,unsigned long new)
-{
- unsigned char *data = NULL;
- int size;
- loff_t offs;
-
- if ((long)new == -1)
- new = FAT_EOF(fs);
- else if ((long)new == -2)
- new = FAT_BAD(fs);
- switch( fs->fat_bits ) {
- case 12:
- data = fs->fat + cluster*3/2;
- offs = fs->fat_start+cluster*3/2;
- if (cluster & 1) {
- FAT_ENTRY prevEntry;
- get_fat(&prevEntry, fs->fat, cluster-1, fs);
- data[0] = ((new & 0xf) << 4) | (prevEntry.value >> 8);
- data[1] = new >> 4;
- }
- else {
- FAT_ENTRY subseqEntry;
- get_fat(&subseqEntry, fs->fat, cluster+1, fs);
- data[0] = new & 0xff;
- data[1] = (new >> 8) | (cluster == fs->clusters-1 ? 0 :
- (0xff & subseqEntry.value) << 4);
- }
- size = 2;
- break;
- case 16:
- data = fs->fat + cluster*2;
- offs = fs->fat_start+cluster*2;
- *(unsigned short *) data = CT_LE_W(new);
- size = 2;
- break;
- case 32:
- {
- FAT_ENTRY curEntry;
- get_fat(&curEntry, fs->fat, cluster, fs);
-
- data = fs->fat + cluster*4;
- offs = fs->fat_start+cluster*4;
- /* According to M$, the high 4 bits of a FAT32 entry are reserved and
- * are not part of the cluster number. So we never touch them. */
- *(unsigned long *) data = CT_LE_L( (new & 0xfffffff) |
- (curEntry.reserved << 28) );
- size = 4;
- }
- break;
- default:
- die("Bad FAT entry size: %d bits.",fs->fat_bits);
- }
- fs_write(offs,size,data);
- if (fs->nfats > 1) {
- fs_write(offs+fs->fat_size,size,data);
- }
-}
-
-
-int bad_cluster(DOS_FS *fs,unsigned long cluster)
-{
- FAT_ENTRY curEntry;
- get_fat(&curEntry, fs->fat, cluster, fs);
-
- return FAT_IS_BAD(fs, curEntry.value);
-}
-
-
-/**
- * Get the cluster to which the specified cluster is linked.
- * If the linked cluster is marked bad, abort.
- *
- * @param[in] fs Information about the filesystem
- * @param[in] cluster Cluster to follow
- *
- * @return -1 'cluster' is at the end of the chain
- * @return Other values Next cluster in this chain
- */
-unsigned long next_cluster(DOS_FS *fs,unsigned long cluster)
-{
- unsigned long value;
- FAT_ENTRY curEntry;
-
- get_fat(&curEntry, fs->fat, cluster, fs);
-
- value = curEntry.value;
- if (FAT_IS_BAD(fs,value))
- die("Internal error: next_cluster on bad cluster");
- return FAT_IS_EOF(fs,value) ? -1 : value;
-}
-
-
-loff_t cluster_start(DOS_FS *fs,unsigned long cluster)
-{
- return fs->data_start+((loff_t)cluster-2)*(unsigned long long)fs->cluster_size;
-}
-
-
-/**
- * Update internal bookkeeping to show that the specified cluster belongs
- * to the specified dentry.
- *
- * @param[in,out] fs Information about the filesystem
- * @param[in] cluster Cluster being assigned
- * @param[in] owner Information on dentry that owns this cluster
- * (may be NULL)
- */
-void set_owner(DOS_FS *fs,unsigned long cluster,DOS_FILE *owner)
-{
- if (fs->cluster_owner == NULL)
- die("Internal error: attempt to set owner in non-existent table");
-
- if (owner && fs->cluster_owner[cluster] && (fs->cluster_owner[cluster] != owner))
- die("Internal error: attempt to change file owner");
- fs->cluster_owner[cluster] = owner;
-}
-
-
-DOS_FILE *get_owner(DOS_FS *fs,unsigned long cluster)
-{
- if (fs->cluster_owner == NULL)
- return NULL;
- else
- return fs->cluster_owner[cluster];
-}
-
-
-void fix_bad(DOS_FS *fs)
-{
- unsigned long i;
-
- if (verbose)
- printf("Checking for bad clusters.\n");
- for (i = 2; i < fs->clusters+2; i++) {
- FAT_ENTRY curEntry;
- get_fat(&curEntry, fs->fat, i, fs);
-
- if (!get_owner(fs,i) && !FAT_IS_BAD(fs, curEntry.value))
- if (!fs_test(cluster_start(fs,i),fs->cluster_size)) {
- printf("Cluster %lu is unreadable.\n",i);
- set_fat(fs,i,-2);
- }
- }
-}
-
-
-void reclaim_free(DOS_FS *fs)
-{
- int reclaimed;
- unsigned long i;
-
- if (verbose)
- printf("Checking for unused clusters.\n");
- reclaimed = 0;
- for (i = 2; i < fs->clusters+2; i++) {
- FAT_ENTRY curEntry;
- get_fat(&curEntry, fs->fat, i, fs);
-
- if (!get_owner(fs,i) && curEntry.value &&
- !FAT_IS_BAD(fs, curEntry.value)) {
- set_fat(fs,i,0);
- reclaimed++;
- }
- }
- if (reclaimed)
- printf("Reclaimed %d unused cluster%s (%llu bytes).\n",reclaimed,
- reclaimed == 1 ? "" : "s",(unsigned long long)reclaimed*fs->cluster_size);
-}
-
-
-/**
- * Assign the specified owner to all orphan chains (except cycles).
- * Break cross-links between orphan chains.
- *
- * @param[in,out] fs Information about the filesystem
- * @param[in] owner dentry to be assigned ownership of orphans
- * @param[in,out] num_refs For each orphan cluster [index], how many
- * clusters link to it.
- * @param[in] start_cluster Where to start scanning for orphans
- */
-static void tag_free(DOS_FS *fs, DOS_FILE *owner, unsigned long *num_refs,
- unsigned long start_cluster)
-{
- int prev;
- unsigned long i,walk;
-
- if (start_cluster == 0)
- start_cluster = 2;
-
- for (i = start_cluster; i < fs->clusters+2; i++) {
- FAT_ENTRY curEntry;
- get_fat(&curEntry, fs->fat, i, fs);
-
- /* If the current entry is the head of an un-owned chain... */
- if (curEntry.value && !FAT_IS_BAD(fs, curEntry.value) &&
- !get_owner(fs, i) && !num_refs[i]) {
- prev = 0;
- /* Walk the chain, claiming ownership as we go */
- for (walk = i; walk != -1;
- walk = next_cluster(fs,walk)) {
- if (!get_owner(fs, walk)) {
- set_owner(fs, walk, owner);
- } else {
- /* We've run into cross-links between orphaned chains,
- * or a cycle with a tail.
- * Terminate this orphan chain (break the link)
- */
- set_fat(fs,prev,-1);
-
- /* This is not necessary because 'walk' is owned and thus
- * will never become the head of a chain (the only case
- * that would matter during reclaim to files).
- * It's easier to decrement than to prove that it's
- * unnecessary.
- */
- num_refs[walk]--;
- break;
- }
- prev = walk;
- }
- }
- }
-}
-
-/**
- * Recover orphan chains to files, handling any cycles or cross-links.
- *
- * @param[in,out] fs Information about the filesystem
- */
-void reclaim_file(DOS_FS *fs)
-{
- DOS_FILE orphan;
- int reclaimed,files;
- int changed = 0;
- unsigned long i,next,walk;
- unsigned long *num_refs = NULL; /* Only for orphaned clusters */
- unsigned long total_num_clusters;
-
- if (verbose)
- printf("Reclaiming unconnected clusters.\n");
-
- total_num_clusters = fs->clusters + 2UL;
- num_refs = alloc(total_num_clusters * sizeof(unsigned long));
- memset(num_refs, 0, (total_num_clusters * sizeof(unsigned long)));
-
- /* Guarantee that all orphan chains (except cycles) end cleanly
- * with an end-of-chain mark.
- */
-
- for (i = 2; i < total_num_clusters; i++) {
- FAT_ENTRY curEntry;
- get_fat(&curEntry, fs->fat, i, fs);
-
- next = curEntry.value;
- if (!get_owner(fs,i) && next && next < fs->clusters+2) {
- /* Cluster is linked, but not owned (orphan) */
- FAT_ENTRY nextEntry;
- get_fat(&nextEntry, fs->fat, next, fs);
-
- /* Mark it end-of-chain if it links into an owned cluster,
- * a free cluster, or a bad cluster.
- */
- if (get_owner(fs,next) || !nextEntry.value ||
- FAT_IS_BAD(fs, nextEntry.value)) set_fat(fs,i,-1);
- else
- num_refs[next]++;
- }
- }
-
- /* Scan until all the orphans are accounted for,
- * and all cycles and cross-links are broken
- */
- do {
- tag_free(fs, &orphan, num_refs, changed);
- changed = 0;
-
- /* Any unaccounted-for orphans must be part of a cycle */
- for (i = 2; i < total_num_clusters; i++) {
- FAT_ENTRY curEntry;
- get_fat(&curEntry, fs->fat, i, fs);
-
- if (curEntry.value && !FAT_IS_BAD(fs, curEntry.value) &&
- !get_owner(fs, i)) {
- if (!num_refs[curEntry.value]--)
- die("Internal error: num_refs going below zero");
- set_fat(fs,i,-1);
- changed = curEntry.value;
- printf("Broke cycle at cluster %lu in free chain.\n",i);
-
- /* If we've created a new chain head,
- * tag_free() can claim it
- */
- if (num_refs[curEntry.value] == 0)
- break;
- }
- }
- }
- while (changed);
-
- /* Now we can start recovery */
- files = reclaimed = 0;
- for (i = 2; i < total_num_clusters; i++)
- /* If this cluster is the head of an orphan chain... */
- if (get_owner(fs, i) == &orphan && !num_refs[i]) {
- DIR_ENT de;
- loff_t offset;
- files++;
- offset = alloc_rootdir_entry(fs,&de,"FSCK%04dREC");
- de.start = CT_LE_W(i&0xffff);
- if (fs->fat_bits == 32)
- de.starthi = CT_LE_W(i>>16);
- for (walk = i; walk > 0 && walk != -1;
- walk = next_cluster(fs,walk)) {
- de.size = CT_LE_L(CF_LE_L(de.size)+fs->cluster_size);
- reclaimed++;
- }
- fs_write(offset,sizeof(DIR_ENT),&de);
- }
- if (reclaimed)
- printf("Reclaimed %d unused cluster%s (%llu bytes) in %d chain%s.\n",
- reclaimed,reclaimed == 1 ? "" : "s",(unsigned long long)reclaimed*fs->cluster_size,files,
- files == 1 ? "" : "s");
-
- free(num_refs);
-}
-
-
-unsigned long update_free(DOS_FS *fs)
-{
- unsigned long i;
- unsigned long free = 0;
- int do_set = 0;
-
- for (i = 2; i < fs->clusters+2; i++) {
- FAT_ENTRY curEntry;
- get_fat(&curEntry, fs->fat, i, fs);
-
- if (!get_owner(fs,i) && !FAT_IS_BAD(fs, curEntry.value))
- ++free;
- }
-
- if (!fs->fsinfo_start)
- return free;
-
- if (verbose)
- printf("Checking free cluster summary.\n");
- if (fs->free_clusters != 0xFFFFFFFF) {
- if (free != fs->free_clusters) {
- printf( "Free cluster summary wrong (%ld vs. really %ld)\n",
- fs->free_clusters,free);
- if (interactive)
- printf( "1) Correct\n2) Don't correct\n" );
- else printf( " Auto-correcting.\n" );
- if (!interactive || get_key("12","?") == '1')
- do_set = 1;
- }
- }
- else {
- printf( "Free cluster summary uninitialized (should be %ld)\n", free );
- if (rw) {
- if (interactive)
- printf( "1) Set it\n2) Leave it uninitialized\n" );
- else printf( " Auto-setting.\n" );
- if (!interactive || get_key("12","?") == '1')
- do_set = 1;
- }
- }
-
- if (do_set) {
- unsigned long le_free = CT_LE_L(free);
- fs->free_clusters = free;
- fs_write(fs->fsinfo_start+offsetof(struct info_sector,free_clusters),
- sizeof(le_free), &le_free);
- }
-
- return free;
-}
diff --git a/src/lfn.h b/src/lfn.h
deleted file mode 100644
index 2da426d..0000000
--- a/src/lfn.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/* lfn.h - Functions for handling VFAT long filenames
-
- Copyright (C) 1998 Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de>
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- On Debian systems, the complete text of the GNU General Public License
- can be found in /usr/share/common-licenses/GPL-3 file.
-*/
-
-#ifndef _LFN_H
-#define _LFN_H
-
-void lfn_reset( void );
-/* Reset the state of the LFN parser. */
-
-void lfn_add_slot( DIR_ENT *de, loff_t dir_offset );
-/* Process a dir slot that is a VFAT LFN entry. */
-
-char *lfn_get( DIR_ENT *de, loff_t *lfn_offset );
-/* Retrieve the long name for the proper dir entry. */
-
-void lfn_check_orphaned(void);
-
-void lfn_fix_checksum(loff_t from, loff_t to, const char *short_name);
-
-#endif
diff --git a/src/version.h b/src/version.h
deleted file mode 100644
index dde3e0b..0000000
--- a/src/version.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/* version.h
-
- Copyright (C) 1998-2005 Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de>
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- On Debian systems, the complete text of the GNU General Public License
- can be found in /usr/share/common-licenses/GPL-3 file.
-*/
-
-#ifndef _version_h
-#define _version_h
-
-#define VERSION "3.0.10"
-#define VERSION_DATE "12 Sep 2010"
-
-#endif
diff --git a/version.h b/version.h
new file mode 100644
index 0000000..1258f47
--- /dev/null
+++ b/version.h
@@ -0,0 +1,8 @@
+#ifndef _version_h
+#define _version_h
+
+#define VERSION "2.11"
+#define VERSION_DATE "12 Mar 2005"
+
+#endif /* _version_h */
+