ODROID: Add exfat filesystem.

https: //github.com/AndyLavr/exfat-nofuse
Change-Id: Id4ad62b99e29565ec92fcc48e885c2873750bad7
This commit is contained in:
Chris
2023-09-21 08:13:40 +09:00
parent cd1ab317ab
commit b4245fafbb
30 changed files with 13124 additions and 0 deletions

View File

@@ -136,6 +136,7 @@ if BLOCK
menu "DOS/FAT/NT Filesystems"
source "fs/fat/Kconfig"
source "fs/exfat/Kconfig"
source "fs/ntfs/Kconfig"
endmenu

View File

@@ -80,6 +80,7 @@ obj-$(CONFIG_HUGETLBFS) += hugetlbfs/
obj-$(CONFIG_CODA_FS) += coda/
obj-$(CONFIG_MINIX_FS) += minix/
obj-$(CONFIG_FAT_FS) += fat/
obj-$(CONFIG_EXFAT_FS) += exfat/
obj-$(CONFIG_BFS_FS) += bfs/
obj-$(CONFIG_ISO9660_FS) += isofs/
obj-$(CONFIG_HFSPLUS_FS) += hfsplus/ # Before hfs to find wrapped HFS+

8
fs/exfat/.gitignore vendored Normal file
View File

@@ -0,0 +1,8 @@
*.cmd
*.ko
*.mod.c
modules.order
Module.symvers
*.o
.tmp_versions
/.project

65
fs/exfat/Kconfig Normal file
View File

@@ -0,0 +1,65 @@
config EXFAT_FS
tristate "exFAT fs support"
default m
select NLS
select NLS_UTF8
select NLS_CODEPAGE_437
select NLS_ISO8859_1
help
If you want to use the exFAT file systems, then you must say Y or M here
to inlucde exFAT support.
config EXFAT_USE_FOR_VFAT
bool "Register exFAT as VFAT"
default y
depends on EXFAT_FS && !VFAT_FS
help
If you want to register exFAT as available for VFAT, say Y.
config EXFAT_DISCARD
bool "Enable discard support"
depends on EXFAT_FS
default y
config EXFAT_KERNEL_DEBUG
bool "Enable kernel debug features via ioctl"
depends on EXFAT_FS
default n
config EXFAT_DEBUG_MSG
bool "Print debug messages"
depends on EXFAT_FS
default n
config EXFAT_DEFAULT_CODEPAGE
int "Default codepage for exFAT"
default 437
depends on EXFAT_FS
help
This option should be set to the codepage of your exFAT filesystems.
config EXFAT_DEFAULT_IOCHARSET
string "Default iocharset for exFAT"
default "utf8"
depends on EXFAT_FS
help
Set this to the default input/output character set you'd like exFAT to use.
config EXFAT_VIRTUAL_XATTR
bool "Virtual xattr support for exFAT filesystem"
default y
depends on EXFAT_FS
help
Modification of exFAT filesystem for virtual xattr
config EXFAT_VIRTUAL_XATTR_SELINUX_LABEL
string "Default string for SELinux label"
depends on EXFAT_FS && EXFAT_VIRTUAL_XATTR
default "u:object_r:sdcard_external:s0"
help
Set this to the default string for SELinux label.
config EXFAT_SUPPORT_STLOG
bool "Enable storage log"
default y
depends on EXFAT_FS && PROC_STLOG

674
fs/exfat/LICENSE Normal file
View File

@@ -0,0 +1,674 @@
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.
ubuntu-wip-kernel
Copyright (C) 2018 Oregon USA
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:
ubuntu-wip-kernel Copyright (C) 2018 Oregon USA
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>.

71
fs/exfat/Makefile Normal file
View File

@@ -0,0 +1,71 @@
#
# Makefile for Linux FAT12/FAT16/FAT32(VFAT)/FAT64(ExFAT) filesystem driver.
#
ifneq ($(KERNELRELEASE),)
# call from kernel build system
obj-$(CONFIG_EXFAT_FS) += exfat_core.o exfat_fs.o
exfat_fs-y := exfat_super.o
exfat_core-y := exfat.o exfat_api.o exfat_blkdev.o exfat_cache.o \
exfat_data.o exfat_global.o exfat_nls.o \
exfat_oal.o exfat_upcase.o exfat_xattr.o
all:
$(MAKE) -C /lib/modules/$(KERNELRELEASE)/build M=$(PWD) modules
clean:
$(MAKE) -C /lib/modules/$(KERNELRELEASE)/build M=$(PWD) clean
else
# external module build
EXTRA_FLAGS += -I$(PWD)
#
# KDIR is a path to a directory containing kernel source.
# It can be specified on the command line passed to make to enable the module to
# be built and installed for a kernel other than the one currently running.
# By default it is the path to the symbolic link created when
# the current kernel's modules were installed, but
# any valid path to the directory in which the target kernel's source is located
# can be provided on the command line.
#
KVER ?= $(shell uname -r)
KDIR := /lib/modules/$(KVER)/build
MDIR := /lib/modules/$(KVER)
PWD := $(shell pwd)
KREL := $(shell cd ${KDIR} && make -s kernelrelease)
PWD := $(shell pwd)
export CONFIG_EXFAT_FS := m
all:
$(MAKE) -C $(KDIR) M=$(PWD) modules
clean:
$(MAKE) -C $(KDIR) M=$(PWD) clean
help:
$(MAKE) -C $(KDIR) M=$(PWD) help
install:all
rm -f ${DESTDIR}${MDIR}/kernel/fs/exfat/exfat.ko
rm -f ${DESTDIR}${MDIR}/kernel/fs/exfat/exfat_fs.ko
rm -f ${DESTDIR}${MDIR}/kernel/fs/exfat/exfat_core.ko
install -m644 -b -D exfat_core.ko ${DESTDIR}${MDIR}/kernel/fs/exfat/exfat_core.ko
install -m644 -b -D exfat_fs.ko ${DESTDIR}${MDIR}/kernel/fs/exfat/exfat_fs.ko
ifeq ($(DESTDIR),)
depmod -a
endif
uninstall:
rm -rf ${DESTDIR}/${MDIR}/kernel/fs/exfat
ifeq ($(DESTDIR),)
depmod -a
endif
endif
.PHONY : all clean install uninstall

41
fs/exfat/README.md Normal file
View File

@@ -0,0 +1,41 @@
exFAT-nofuse v1.2.24-dragon
============
Linux non-fuse read/write kernel driver for the exFAT, FAT12, FAT16 and vfat (FAT32) file systems.<br />
**Full adaptation to kernel 4.19.y**
To load the driver manually, run this as root:
==============================================
modprobe exfat_core
modprobe exfat_fs
Enable exFAT module and install exfat-utils:
============================================
Add to /etc/initramfs-tools/modules:
exfat_core
exfat_fs
For filesystem creation and manipulation beyond that of the mount command it is necessary to install the exfat-utils package:
=============================================================================================================================
$ sudo apt install exfat-utils
$ sudo apt purge exfat-fuse
To create an exFAT file system, use mkfs.exfat (or the mkexfatfs command, which is synonymous):
===============================================================================================
root #mkfs.exfat
mkexfatfs 1.2.8
Usage: mkfs.exfat [-i volume-id] [-n label] [-p partition-first-sector] [-s sectors-per-cluster] [-V] <device>
For instance, to create it on a removable device present at /dev/sde1 while assigning "Flash" as the file system label:
root #mkfs.exfat -n Flash /dev/sde1

5063
fs/exfat/exfat.c Normal file

File diff suppressed because it is too large Load Diff

601
fs/exfat/exfat.h Normal file
View File

@@ -0,0 +1,601 @@
/*
* Copyright (C) 2012-2013 Samsung Electronics Co., Ltd.
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _EXFAT_H
#define _EXFAT_H
#include "exfat_config.h"
#include "exfat_global.h"
#include "exfat_data.h"
#include "exfat_oal.h"
#include "exfat_blkdev.h"
#include "exfat_cache.h"
#include "exfat_nls.h"
#include "exfat_api.h"
#include "exfat_cache.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifdef CONFIG_EXFAT_KERNEL_DEBUG
#define EXFAT_IOC_GET_DEBUGFLAGS _IOR('f', 100, long)
#define EXFAT_IOC_SET_DEBUGFLAGS _IOW('f', 101, long)
#define EXFAT_DEBUGFLAGS_INVALID_UMOUNT 0x01
#define EXFAT_DEBUGFLAGS_ERROR_RW 0x02
#endif
#define MAX_VOLUME 4
#define DENTRY_SIZE 32
#define DENTRY_SIZE_BITS 5
#define PBR_SIGNATURE 0xAA55
#define EXT_SIGNATURE 0xAA550000
#define VOL_LABEL "NO NAME "
#define OEM_NAME "MSWIN4.1"
#define STR_FAT12 "FAT12 "
#define STR_FAT16 "FAT16 "
#define STR_FAT32 "FAT32 "
#define STR_EXFAT "EXFAT "
#define VOL_CLEAN 0x0000
#define VOL_DIRTY 0x0002
#define FAT12_THRESHOLD 4087
#define FAT16_THRESHOLD 65527
#define FAT32_THRESHOLD 268435457
#define EXFAT_THRESHOLD 268435457
#define TYPE_UNUSED 0x0000
#define TYPE_DELETED 0x0001
#define TYPE_INVALID 0x0002
#define TYPE_CRITICAL_PRI 0x0100
#define TYPE_BITMAP 0x0101
#define TYPE_UPCASE 0x0102
#define TYPE_VOLUME 0x0103
#define TYPE_DIR 0x0104
#define TYPE_FILE 0x011F
#define TYPE_SYMLINK 0x015F
#define TYPE_CRITICAL_SEC 0x0200
#define TYPE_STREAM 0x0201
#define TYPE_EXTEND 0x0202
#define TYPE_ACL 0x0203
#define TYPE_BENIGN_PRI 0x0400
#define TYPE_GUID 0x0401
#define TYPE_PADDING 0x0402
#define TYPE_ACLTAB 0x0403
#define TYPE_BENIGN_SEC 0x0800
#define TYPE_ALL 0x0FFF
#define TM_CREATE 0
#define TM_MODIFY 1
#define TM_ACCESS 2
#define CS_DIR_ENTRY 0
#define CS_PBR_SECTOR 1
#define CS_DEFAULT 2
#define DIR_DELETED 0xFFFF0321
#define CLUSTER_16(x) ((u16)(x))
#define CLUSTER_32(x) ((u32)(x))
#define START_SECTOR(x) \
((((sector_t)((x) - 2)) << p_fs->sectors_per_clu_bits) + p_fs->data_start_sector)
#define IS_LAST_SECTOR_IN_CLUSTER(sec) \
( (((sec) - p_fs->data_start_sector + 1) & ((1 << p_fs->sectors_per_clu_bits) -1)) == 0)
#define GET_CLUSTER_FROM_SECTOR(sec) \
((((sec) - p_fs->data_start_sector) >> p_fs->sectors_per_clu_bits) +2)
#define GET16(p_src) \
( ((u16)(p_src)[0]) | (((u16)(p_src)[1]) << 8) )
#define GET32(p_src) \
( ((u32)(p_src)[0]) | (((u32)(p_src)[1]) << 8) | \
(((u32)(p_src)[2]) << 16) | (((u32)(p_src)[3]) << 24) )
#define GET64(p_src) \
( ((u64)(p_src)[0]) | (((u64)(p_src)[1]) << 8) | \
(((u64)(p_src)[2]) << 16) | (((u64)(p_src)[3]) << 24) | \
(((u64)(p_src)[4]) << 32) | (((u64)(p_src)[5]) << 40) | \
(((u64)(p_src)[6]) << 48) | (((u64)(p_src)[7]) << 56) )
#define SET16(p_dst,src) \
do { \
(p_dst)[0]=(u8)(src); \
(p_dst)[1]=(u8)(((u16)(src)) >> 8); \
} while (0)
#define SET32(p_dst,src) \
do { \
(p_dst)[0]=(u8)(src); \
(p_dst)[1]=(u8)(((u32)(src)) >> 8); \
(p_dst)[2]=(u8)(((u32)(src)) >> 16); \
(p_dst)[3]=(u8)(((u32)(src)) >> 24); \
} while (0)
#define SET64(p_dst,src) \
do { \
(p_dst)[0]=(u8)(src); \
(p_dst)[1]=(u8)(((u64)(src)) >> 8); \
(p_dst)[2]=(u8)(((u64)(src)) >> 16); \
(p_dst)[3]=(u8)(((u64)(src)) >> 24); \
(p_dst)[4]=(u8)(((u64)(src)) >> 32); \
(p_dst)[5]=(u8)(((u64)(src)) >> 40); \
(p_dst)[6]=(u8)(((u64)(src)) >> 48); \
(p_dst)[7]=(u8)(((u64)(src)) >> 56); \
} while (0)
#if (FFS_CONFIG_LITTLE_ENDIAN == 1)
#define GET16_A(p_src) (*((u16 *)(p_src)))
#define GET32_A(p_src) (*((u32 *)(p_src)))
#define GET64_A(p_src) (*((u64 *)(p_src)))
#define SET16_A(p_dst,src) *((u16 *)(p_dst)) = (u16)(src)
#define SET32_A(p_dst,src) *((u32 *)(p_dst)) = (u32)(src)
#define SET64_A(p_dst,src) *((u64 *)(p_dst)) = (u64)(src)
#else
#define GET16_A(p_src) GET16(p_src)
#define GET32_A(p_src) GET32(p_src)
#define GET64_A(p_src) GET64(p_src)
#define SET16_A(p_dst,src) SET16(p_dst, src)
#define SET32_A(p_dst,src) SET32(p_dst, src)
#define SET64_A(p_dst,src) SET64(p_dst, src)
#endif
#define HIGH_INDEX_BIT (8)
#define HIGH_INDEX_MASK (0xFF00)
#define LOW_INDEX_BIT (16-HIGH_INDEX_BIT)
#define UTBL_ROW_COUNT (1<<LOW_INDEX_BIT)
#define UTBL_COL_COUNT (1<<HIGH_INDEX_BIT)
static inline u16 get_col_index(u16 i)
{
return i >> LOW_INDEX_BIT;
}
static inline u16 get_row_index(u16 i)
{
return i & ~HIGH_INDEX_MASK;
}
typedef struct {
u8 jmp_boot[3];
u8 oem_name[8];
u8 bpb[109];
u8 boot_code[390];
u8 signature[2];
} PBR_SECTOR_T;
typedef struct {
u8 sector_size[2];
u8 sectors_per_clu;
u8 num_reserved[2];
u8 num_fats;
u8 num_root_entries[2];
u8 num_sectors[2];
u8 media_type;
u8 num_fat_sectors[2];
u8 sectors_in_track[2];
u8 num_heads[2];
u8 num_hid_sectors[4];
u8 num_huge_sectors[4];
u8 phy_drv_no;
u8 reserved;
u8 ext_signature;
u8 vol_serial[4];
u8 vol_label[11];
u8 vol_type[8];
} BPB16_T;
typedef struct {
u8 sector_size[2];
u8 sectors_per_clu;
u8 num_reserved[2];
u8 num_fats;
u8 num_root_entries[2];
u8 num_sectors[2];
u8 media_type;
u8 num_fat_sectors[2];
u8 sectors_in_track[2];
u8 num_heads[2];
u8 num_hid_sectors[4];
u8 num_huge_sectors[4];
u8 num_fat32_sectors[4];
u8 ext_flags[2];
u8 fs_version[2];
u8 root_cluster[4];
u8 fsinfo_sector[2];
u8 backup_sector[2];
u8 reserved[12];
u8 phy_drv_no;
u8 ext_reserved;
u8 ext_signature;
u8 vol_serial[4];
u8 vol_label[11];
u8 vol_type[8];
} BPB32_T;
typedef struct {
u8 reserved1[53];
u8 vol_offset[8];
u8 vol_length[8];
u8 fat_offset[4];
u8 fat_length[4];
u8 clu_offset[4];
u8 clu_count[4];
u8 root_cluster[4];
u8 vol_serial[4];
u8 fs_version[2];
u8 vol_flags[2];
u8 sector_size_bits;
u8 sectors_per_clu_bits;
u8 num_fats;
u8 phy_drv_no;
u8 perc_in_use;
u8 reserved2[7];
} BPBEX_T;
typedef struct {
u8 signature1[4];
u8 reserved1[480];
u8 signature2[4];
u8 free_cluster[4];
u8 next_cluster[4];
u8 reserved2[14];
u8 signature3[2];
} FSI_SECTOR_T;
typedef struct {
u8 dummy[32];
} DENTRY_T;
typedef struct {
u8 name[DOS_NAME_LENGTH];
u8 attr;
u8 lcase;
u8 create_time_ms;
u8 create_time[2];
u8 create_date[2];
u8 access_date[2];
u8 start_clu_hi[2];
u8 modify_time[2];
u8 modify_date[2];
u8 start_clu_lo[2];
u8 size[4];
} DOS_DENTRY_T;
typedef struct {
u8 order;
u8 unicode_0_4[10];
u8 attr;
u8 sysid;
u8 checksum;
u8 unicode_5_10[12];
u8 start_clu[2];
u8 unicode_11_12[4];
} EXT_DENTRY_T;
typedef struct {
u8 type;
u8 num_ext;
u8 checksum[2];
u8 attr[2];
u8 reserved1[2];
u8 create_time[2];
u8 create_date[2];
u8 modify_time[2];
u8 modify_date[2];
u8 access_time[2];
u8 access_date[2];
u8 create_time_ms;
u8 modify_time_ms;
u8 access_time_ms;
u8 reserved2[9];
} FILE_DENTRY_T;
typedef struct {
u8 type;
u8 flags;
u8 reserved1;
u8 name_len;
u8 name_hash[2];
u8 reserved2[2];
u8 valid_size[8];
u8 reserved3[4];
u8 start_clu[4];
u8 size[8];
} STRM_DENTRY_T;
typedef struct {
u8 type;
u8 flags;
u8 unicode_0_14[30];
} NAME_DENTRY_T;
typedef struct {
u8 type;
u8 flags;
u8 reserved[18];
u8 start_clu[4];
u8 size[8];
} BMAP_DENTRY_T;
typedef struct {
u8 type;
u8 reserved1[3];
u8 checksum[4];
u8 reserved2[12];
u8 start_clu[4];
u8 size[8];
} CASE_DENTRY_T;
typedef struct {
u8 type;
u8 label_len;
u8 unicode_0_10[22];
u8 reserved[8];
} VOLM_DENTRY_T;
typedef struct {
u32 dir;
s32 entry;
CHAIN_T clu;
} UENTRY_T;
typedef struct __FS_STRUCT_T {
u32 mounted;
struct super_block *sb;
struct semaphore v_sem;
} FS_STRUCT_T;
typedef struct {
s32 (*alloc_cluster)(struct super_block *sb, s32 num_alloc, CHAIN_T *p_chain);
void (*free_cluster)(struct super_block *sb, CHAIN_T *p_chain, s32 do_relse);
s32 (*count_used_clusters)(struct super_block *sb);
s32 (*init_dir_entry)(struct super_block *sb, CHAIN_T *p_dir, s32 entry, u32 type,
u32 start_clu, u64 size);
s32 (*init_ext_entry)(struct super_block *sb, CHAIN_T *p_dir, s32 entry, s32 num_entries,
UNI_NAME_T *p_uniname, DOS_NAME_T *p_dosname);
s32 (*find_dir_entry)(struct super_block *sb, CHAIN_T *p_dir, UNI_NAME_T *p_uniname, s32 num_entries, DOS_NAME_T *p_dosname, u32 type);
void (*delete_dir_entry)(struct super_block *sb, CHAIN_T *p_dir, s32 entry, s32 offset, s32 num_entries);
void (*get_uni_name_from_ext_entry)(struct super_block *sb, CHAIN_T *p_dir, s32 entry, u16 *uniname);
s32 (*count_ext_entries)(struct super_block *sb, CHAIN_T *p_dir, s32 entry, DENTRY_T *p_entry);
s32 (*calc_num_entries)(UNI_NAME_T *p_uniname);
u32 (*get_entry_type)(DENTRY_T *p_entry);
void (*set_entry_type)(DENTRY_T *p_entry, u32 type);
u32 (*get_entry_attr)(DENTRY_T *p_entry);
void (*set_entry_attr)(DENTRY_T *p_entry, u32 attr);
u8 (*get_entry_flag)(DENTRY_T *p_entry);
void (*set_entry_flag)(DENTRY_T *p_entry, u8 flag);
u32 (*get_entry_clu0)(DENTRY_T *p_entry);
void (*set_entry_clu0)(DENTRY_T *p_entry, u32 clu0);
u64 (*get_entry_size)(DENTRY_T *p_entry);
void (*set_entry_size)(DENTRY_T *p_entry, u64 size);
void (*get_entry_time)(DENTRY_T *p_entry, TIMESTAMP_T *tp, u8 mode);
void (*set_entry_time)(DENTRY_T *p_entry, TIMESTAMP_T *tp, u8 mode);
} FS_FUNC_T;
typedef struct __FS_INFO_T {
u32 drv;
u32 vol_type;
u32 vol_id;
u64 num_sectors;
u32 num_clusters;
u32 cluster_size;
u32 cluster_size_bits;
u32 sectors_per_clu;
u32 sectors_per_clu_bits;
u32 PBR_sector;
u32 FAT1_start_sector;
u32 FAT2_start_sector;
u32 root_start_sector;
u32 data_start_sector;
u32 num_FAT_sectors;
u32 root_dir;
u32 dentries_in_root;
u32 dentries_per_clu;
u32 vol_flag;
struct buffer_head *pbr_bh;
u32 map_clu;
u32 map_sectors;
struct buffer_head **vol_amap;
u16 **vol_utbl;
u32 clu_srch_ptr;
u32 used_clusters;
UENTRY_T hint_uentry;
u32 dev_ejected;
FS_FUNC_T *fs_func;
BUF_CACHE_T FAT_cache_array[FAT_CACHE_SIZE];
BUF_CACHE_T FAT_cache_lru_list;
BUF_CACHE_T FAT_cache_hash_list[FAT_CACHE_HASH_SIZE];
BUF_CACHE_T buf_cache_array[BUF_CACHE_SIZE];
BUF_CACHE_T buf_cache_lru_list;
BUF_CACHE_T buf_cache_hash_list[BUF_CACHE_HASH_SIZE];
} FS_INFO_T;
#define ES_2_ENTRIES 2
#define ES_3_ENTRIES 3
#define ES_ALL_ENTRIES 0
typedef struct {
sector_t sector;
s32 offset;
s32 alloc_flag;
u32 num_entries;
void *__buf;
} ENTRY_SET_CACHE_T;
s32 ffsInit(void);
s32 ffsShutdown(void);
s32 ffsMountVol(struct super_block *sb, s32 drv);
s32 ffsUmountVol(struct super_block *sb);
s32 ffsCheckVol(struct super_block *sb);
s32 ffsGetVolInfo(struct super_block *sb, VOL_INFO_T *info);
s32 ffsSyncVol(struct super_block *sb, s32 do_sync);
s32 ffsLookupFile(struct inode *inode, u8 *path, FILE_ID_T *fid);
s32 ffsCreateFile(struct inode *inode, u8 *path, u8 mode, FILE_ID_T *fid);
s32 ffsReadFile(struct inode *inode, FILE_ID_T *fid, void *buffer, u64 count, u64 *rcount);
s32 ffsWriteFile(struct inode *inode, FILE_ID_T *fid, void *buffer, u64 count, u64 *wcount);
s32 ffsTruncateFile(struct inode *inode, u64 old_size, u64 new_size);
s32 ffsMoveFile(struct inode *old_parent_inode, FILE_ID_T *fid, struct inode *new_parent_inode, struct dentry *new_dentry);
s32 ffsRemoveFile(struct inode *inode, FILE_ID_T *fid);
s32 ffsSetAttr(struct inode *inode, u32 attr);
s32 ffsGetStat(struct inode *inode, DIR_ENTRY_T *info);
s32 ffsSetStat(struct inode *inode, DIR_ENTRY_T *info);
s32 ffsMapCluster(struct inode *inode, s32 clu_offset, u32 *clu);
s32 ffsCreateDir(struct inode *inode, u8 *path, FILE_ID_T *fid);
s32 ffsReadDir(struct inode *inode, DIR_ENTRY_T *dir_ent);
s32 ffsRemoveDir(struct inode *inode, FILE_ID_T *fid);
s32 ffsRemoveEntry(struct inode *inode, FILE_ID_T *fid);
s32 fs_init(void);
s32 fs_shutdown(void);
void fs_set_vol_flags(struct super_block *sb, u32 new_flag);
void fs_sync(struct super_block *sb, s32 do_sync);
void fs_error(struct super_block *sb);
s32 clear_cluster(struct super_block *sb, u32 clu);
s32 fat_alloc_cluster(struct super_block *sb, s32 num_alloc, CHAIN_T *p_chain);
s32 exfat_alloc_cluster(struct super_block *sb, s32 num_alloc, CHAIN_T *p_chain);
void fat_free_cluster(struct super_block *sb, CHAIN_T *p_chain, s32 do_relse);
void exfat_free_cluster(struct super_block *sb, CHAIN_T *p_chain, s32 do_relse);
u32 find_last_cluster(struct super_block *sb, CHAIN_T *p_chain);
s32 count_num_clusters(struct super_block *sb, CHAIN_T *dir);
s32 fat_count_used_clusters(struct super_block *sb);
s32 exfat_count_used_clusters(struct super_block *sb);
void exfat_chain_cont_cluster(struct super_block *sb, u32 chain, s32 len);
s32 load_alloc_bitmap(struct super_block *sb);
void free_alloc_bitmap(struct super_block *sb);
s32 set_alloc_bitmap(struct super_block *sb, u32 clu);
s32 clr_alloc_bitmap(struct super_block *sb, u32 clu);
u32 test_alloc_bitmap(struct super_block *sb, u32 clu);
void sync_alloc_bitmap(struct super_block *sb);
s32 load_upcase_table(struct super_block *sb);
void free_upcase_table(struct super_block *sb);
u32 fat_get_entry_type(DENTRY_T *p_entry);
u32 exfat_get_entry_type(DENTRY_T *p_entry);
void fat_set_entry_type(DENTRY_T *p_entry, u32 type);
void exfat_set_entry_type(DENTRY_T *p_entry, u32 type);
u32 fat_get_entry_attr(DENTRY_T *p_entry);
u32 exfat_get_entry_attr(DENTRY_T *p_entry);
void fat_set_entry_attr(DENTRY_T *p_entry, u32 attr);
void exfat_set_entry_attr(DENTRY_T *p_entry, u32 attr);
u8 fat_get_entry_flag(DENTRY_T *p_entry);
u8 exfat_get_entry_flag(DENTRY_T *p_entry);
void fat_set_entry_flag(DENTRY_T *p_entry, u8 flag);
void exfat_set_entry_flag(DENTRY_T *p_entry, u8 flag);
u32 fat_get_entry_clu0(DENTRY_T *p_entry);
u32 exfat_get_entry_clu0(DENTRY_T *p_entry);
void fat_set_entry_clu0(DENTRY_T *p_entry, u32 start_clu);
void exfat_set_entry_clu0(DENTRY_T *p_entry, u32 start_clu);
u64 fat_get_entry_size(DENTRY_T *p_entry);
u64 exfat_get_entry_size(DENTRY_T *p_entry);
void fat_set_entry_size(DENTRY_T *p_entry, u64 size);
void exfat_set_entry_size(DENTRY_T *p_entry, u64 size);
void fat_get_entry_time(DENTRY_T *p_entry, TIMESTAMP_T *tp, u8 mode);
void exfat_get_entry_time(DENTRY_T *p_entry, TIMESTAMP_T *tp, u8 mode);
void fat_set_entry_time(DENTRY_T *p_entry, TIMESTAMP_T *tp, u8 mode);
void exfat_set_entry_time(DENTRY_T *p_entry, TIMESTAMP_T *tp, u8 mode);
s32 fat_init_dir_entry(struct super_block *sb, CHAIN_T *p_dir, s32 entry, u32 type, u32 start_clu, u64 size);
s32 exfat_init_dir_entry(struct super_block *sb, CHAIN_T *p_dir, s32 entry, u32 type, u32 start_clu, u64 size);
s32 fat_init_ext_dir_entry(struct super_block *sb, CHAIN_T *p_dir, s32 entry, s32 num_entries, UNI_NAME_T *p_uniname, DOS_NAME_T *p_dosname);
s32 exfat_init_ext_dir_entry(struct super_block *sb, CHAIN_T *p_dir, s32 entry, s32 num_entries, UNI_NAME_T *p_uniname, DOS_NAME_T *p_dosname);
void init_dos_entry(DOS_DENTRY_T *ep, u32 type, u32 start_clu, u8 tz_utc);
void init_ext_entry(EXT_DENTRY_T *ep, s32 order, u8 chksum, u16 *uniname);
void init_file_entry(FILE_DENTRY_T *ep, u32 type, u8 tz_utc);
void init_strm_entry(STRM_DENTRY_T *ep, u8 flags, u32 start_clu, u64 size);
void init_name_entry(NAME_DENTRY_T *ep, u16 *uniname);
void fat_delete_dir_entry(struct super_block *sb, CHAIN_T *p_dir, s32 entry, s32 order, s32 num_entries);
void exfat_delete_dir_entry(struct super_block *sb, CHAIN_T *p_dir, s32 entry, s32 order, s32 num_entries);
s32 find_location(struct super_block *sb, CHAIN_T *p_dir, s32 entry, sector_t *sector, s32 *offset);
DENTRY_T *get_entry_with_sector(struct super_block *sb, sector_t sector, s32 offset);
DENTRY_T *get_entry_in_dir(struct super_block *sb, CHAIN_T *p_dir, s32 entry, sector_t *sector);
ENTRY_SET_CACHE_T *get_entry_set_in_dir (struct super_block *sb, CHAIN_T *p_dir, s32 entry, u32 type, DENTRY_T **file_ep);
void release_entry_set (ENTRY_SET_CACHE_T *es);
s32 write_whole_entry_set (struct super_block *sb, ENTRY_SET_CACHE_T *es);
s32 write_partial_entries_in_entry_set (struct super_block *sb, ENTRY_SET_CACHE_T *es, DENTRY_T *ep, u32 count);
s32 search_deleted_or_unused_entry(struct super_block *sb, CHAIN_T *p_dir, s32 num_entries);
s32 find_empty_entry(struct inode *inode, CHAIN_T *p_dir, s32 num_entries);
s32 fat_find_dir_entry(struct super_block *sb, CHAIN_T *p_dir, UNI_NAME_T *p_uniname, s32 num_entries, DOS_NAME_T *p_dosname, u32 type);
s32 exfat_find_dir_entry(struct super_block *sb, CHAIN_T *p_dir, UNI_NAME_T *p_uniname, s32 num_entries, DOS_NAME_T *p_dosname, u32 type);
s32 fat_count_ext_entries(struct super_block *sb, CHAIN_T *p_dir, s32 entry, DENTRY_T *p_entry);
s32 exfat_count_ext_entries(struct super_block *sb, CHAIN_T *p_dir, s32 entry, DENTRY_T *p_entry);
s32 count_dos_name_entries(struct super_block *sb, CHAIN_T *p_dir, u32 type);
void update_dir_checksum(struct super_block *sb, CHAIN_T *p_dir, s32 entry);
void update_dir_checksum_with_entry_set (struct super_block *sb, ENTRY_SET_CACHE_T *es);
BOOL is_dir_empty(struct super_block *sb, CHAIN_T *p_dir);
s32 get_num_entries_and_dos_name(struct super_block *sb, CHAIN_T *p_dir, UNI_NAME_T *p_uniname, s32 *entries, DOS_NAME_T *p_dosname);
void get_uni_name_from_dos_entry(struct super_block *sb, DOS_DENTRY_T *ep, UNI_NAME_T *p_uniname, u8 mode);
void fat_get_uni_name_from_ext_entry(struct super_block *sb, CHAIN_T *p_dir, s32 entry, u16 *uniname);
void exfat_get_uni_name_from_ext_entry(struct super_block *sb, CHAIN_T *p_dir, s32 entry, u16 *uniname);
s32 extract_uni_name_from_ext_entry(EXT_DENTRY_T *ep, u16 *uniname, s32 order);
s32 extract_uni_name_from_name_entry(NAME_DENTRY_T *ep, u16 *uniname, s32 order);
s32 fat_generate_dos_name(struct super_block *sb, CHAIN_T *p_dir, DOS_NAME_T *p_dosname);
void fat_attach_count_to_dos_name(u8 *dosname, s32 count);
s32 fat_calc_num_entries(UNI_NAME_T *p_uniname);
s32 exfat_calc_num_entries(UNI_NAME_T *p_uniname);
u8 calc_checksum_1byte(void *data, s32 len, u8 chksum);
u16 calc_checksum_2byte(void *data, s32 len, u16 chksum, s32 type);
u32 calc_checksum_4byte(void *data, s32 len, u32 chksum, s32 type);
s32 resolve_path(struct inode *inode, u8 *path, CHAIN_T *p_dir, UNI_NAME_T *p_uniname);
s32 resolve_name(u8 *name, u8 **arg);
s32 fat16_mount(struct super_block *sb, PBR_SECTOR_T *p_pbr);
s32 fat32_mount(struct super_block *sb, PBR_SECTOR_T *p_pbr);
s32 exfat_mount(struct super_block *sb, PBR_SECTOR_T *p_pbr);
s32 create_dir(struct inode *inode, CHAIN_T *p_dir, UNI_NAME_T *p_uniname, FILE_ID_T *fid);
s32 create_file(struct inode *inode, CHAIN_T *p_dir, UNI_NAME_T *p_uniname, u8 mode, FILE_ID_T *fid);
void remove_file(struct inode *inode, CHAIN_T *p_dir, s32 entry);
s32 rename_file(struct inode *inode, CHAIN_T *p_dir, s32 old_entry, UNI_NAME_T *p_uniname, FILE_ID_T *fid);
s32 move_file(struct inode *inode, CHAIN_T *p_olddir, s32 oldentry, CHAIN_T *p_newdir, UNI_NAME_T *p_uniname, FILE_ID_T *fid);
s32 sector_read(struct super_block *sb, sector_t sec, struct buffer_head **bh, s32 read);
s32 sector_write(struct super_block *sb, sector_t sec, struct buffer_head *bh, s32 sync);
s32 multi_sector_read(struct super_block *sb, sector_t sec, struct buffer_head **bh, s32 num_secs, s32 read);
s32 multi_sector_write(struct super_block *sb, sector_t sec, struct buffer_head *bh, s32 num_secs, s32 sync);
#ifdef __cplusplus
}
#endif
#endif

480
fs/exfat/exfat_api.c Normal file
View File

@@ -0,0 +1,480 @@
/*
* Copyright (C) 2012-2013 Samsung Electronics Co., Ltd.
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <linux/version.h>
#include <linux/module.h>
#include <linux/init.h>
#include "exfat_version.h"
#include "exfat_config.h"
#include "exfat_global.h"
#include "exfat_data.h"
#include "exfat_oal.h"
#include "exfat_part.h"
#include "exfat_nls.h"
#include "exfat_api.h"
#include "exfat_super.h"
#include "exfat.h"
extern FS_STRUCT_T fs_struct[];
extern struct semaphore z_sem;
s32 FsInit(void)
{
s32 i;
for (i = 0; i < MAX_DRIVE; i++) {
fs_struct[i].mounted = FALSE;
fs_struct[i].sb = NULL;
sm_init(&(fs_struct[i].v_sem));
}
return(ffsInit());
}
s32 FsShutdown(void)
{
s32 i;
for (i = 0; i < MAX_DRIVE; i++) {
if (!fs_struct[i].mounted) continue;
ffsUmountVol(fs_struct[i].sb);
}
return(ffsShutdown());
}
s32 FsMountVol(struct super_block *sb)
{
s32 err, drv;
sm_P(&z_sem);
for (drv = 0; drv < MAX_DRIVE; drv++) {
if (!fs_struct[drv].mounted) break;
}
if (drv >= MAX_DRIVE) {
err = FFS_ERROR;
goto ret_unlock;
}
sm_P(&(fs_struct[drv].v_sem));
err = buf_init(sb);
if (!err) {
err = ffsMountVol(sb, drv);
}
sm_V(&(fs_struct[drv].v_sem));
if (!err) {
fs_struct[drv].mounted = TRUE;
fs_struct[drv].sb = sb;
} else {
buf_shutdown(sb);
}
ret_unlock:
sm_V(&z_sem);
return(err);
}
s32 FsUmountVol(struct super_block *sb)
{
s32 err;
FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info);
sm_P(&z_sem);
sm_P(&(fs_struct[p_fs->drv].v_sem));
err = ffsUmountVol(sb);
buf_shutdown(sb);
sm_V(&(fs_struct[p_fs->drv].v_sem));
fs_struct[p_fs->drv].mounted = FALSE;
fs_struct[p_fs->drv].sb = NULL;
sm_V(&z_sem);
return(err);
}
s32 FsGetVolInfo(struct super_block *sb, VOL_INFO_T *info)
{
s32 err;
FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info);
if (info == NULL) return(FFS_ERROR);
sm_P(&(fs_struct[p_fs->drv].v_sem));
err = ffsGetVolInfo(sb, info);
sm_V(&(fs_struct[p_fs->drv].v_sem));
return(err);
}
s32 FsSyncVol(struct super_block *sb, s32 do_sync)
{
s32 err;
FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info);
sm_P(&(fs_struct[p_fs->drv].v_sem));
err = ffsSyncVol(sb, do_sync);
sm_V(&(fs_struct[p_fs->drv].v_sem));
return(err);
}
s32 FsLookupFile(struct inode *inode, u8 *path, FILE_ID_T *fid)
{
s32 err;
struct super_block *sb = inode->i_sb;
FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info);
if ((fid == NULL) || (path == NULL) || (STRLEN(path) == 0))
return(FFS_ERROR);
sm_P(&(fs_struct[p_fs->drv].v_sem));
err = ffsLookupFile(inode, path, fid);
sm_V(&(fs_struct[p_fs->drv].v_sem));
return(err);
}
s32 FsCreateFile(struct inode *inode, u8 *path, u8 mode, FILE_ID_T *fid)
{
s32 err;
struct super_block *sb = inode->i_sb;
FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info);
if ((fid == NULL) || (path == NULL) || (STRLEN(path) == 0))
return(FFS_ERROR);
sm_P(&(fs_struct[p_fs->drv].v_sem));
err = ffsCreateFile(inode, path, mode, fid);
sm_V(&(fs_struct[p_fs->drv].v_sem));
return(err);
}
s32 FsReadFile(struct inode *inode, FILE_ID_T *fid, void *buffer, u64 count, u64 *rcount)
{
s32 err;
struct super_block *sb = inode->i_sb;
FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info);
if (fid == NULL) return(FFS_INVALIDFID);
if (buffer == NULL) return(FFS_ERROR);
sm_P(&(fs_struct[p_fs->drv].v_sem));
err = ffsReadFile(inode, fid, buffer, count, rcount);
sm_V(&(fs_struct[p_fs->drv].v_sem));
return(err);
}
s32 FsWriteFile(struct inode *inode, FILE_ID_T *fid, void *buffer, u64 count, u64 *wcount)
{
s32 err;
struct super_block *sb = inode->i_sb;
FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info);
if (fid == NULL) return(FFS_INVALIDFID);
if (buffer == NULL) return(FFS_ERROR);
sm_P(&(fs_struct[p_fs->drv].v_sem));
err = ffsWriteFile(inode, fid, buffer, count, wcount);
sm_V(&(fs_struct[p_fs->drv].v_sem));
return(err);
}
s32 FsTruncateFile(struct inode *inode, u64 old_size, u64 new_size)
{
s32 err;
struct super_block *sb = inode->i_sb;
FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info);
sm_P(&(fs_struct[p_fs->drv].v_sem));
PRINTK("FsTruncateFile entered (inode %p size %llu)\n", inode, new_size);
err = ffsTruncateFile(inode, old_size, new_size);
PRINTK("FsTruncateFile exitted (%d)\n", err);
sm_V(&(fs_struct[p_fs->drv].v_sem));
return(err);
}
s32 FsMoveFile(struct inode *old_parent_inode, FILE_ID_T *fid, struct inode *new_parent_inode, struct dentry *new_dentry)
{
s32 err;
struct super_block *sb = old_parent_inode->i_sb;
FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info);
if (fid == NULL) return(FFS_INVALIDFID);
sm_P(&(fs_struct[p_fs->drv].v_sem));
err = ffsMoveFile(old_parent_inode, fid, new_parent_inode, new_dentry);
sm_V(&(fs_struct[p_fs->drv].v_sem));
return(err);
}
s32 FsRemoveFile(struct inode *inode, FILE_ID_T *fid)
{
s32 err;
struct super_block *sb = inode->i_sb;
FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info);
if (fid == NULL) return(FFS_INVALIDFID);
sm_P(&(fs_struct[p_fs->drv].v_sem));
err = ffsRemoveFile(inode, fid);
sm_V(&(fs_struct[p_fs->drv].v_sem));
return(err);
}
s32 FsSetAttr(struct inode *inode, u32 attr)
{
s32 err;
struct super_block *sb = inode->i_sb;
FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info);
sm_P(&(fs_struct[p_fs->drv].v_sem));
err = ffsSetAttr(inode, attr);
sm_V(&(fs_struct[p_fs->drv].v_sem));
return(err);
}
s32 FsReadStat(struct inode *inode, DIR_ENTRY_T *info)
{
s32 err;
struct super_block *sb = inode->i_sb;
FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info);
sm_P(&(fs_struct[p_fs->drv].v_sem));
err = ffsGetStat(inode, info);
sm_V(&(fs_struct[p_fs->drv].v_sem));
return(err);
}
s32 FsWriteStat(struct inode *inode, DIR_ENTRY_T *info)
{
s32 err;
struct super_block *sb = inode->i_sb;
FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info);
sm_P(&(fs_struct[p_fs->drv].v_sem));
PRINTK("FsWriteStat entered (inode %p info %p\n", inode, info);
err = ffsSetStat(inode, info);
sm_V(&(fs_struct[p_fs->drv].v_sem));
PRINTK("FsWriteStat exited (%d)\n", err);
return(err);
}
s32 FsMapCluster(struct inode *inode, s32 clu_offset, u32 *clu)
{
s32 err;
struct super_block *sb = inode->i_sb;
FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info);
if (clu == NULL) return(FFS_ERROR);
sm_P(&(fs_struct[p_fs->drv].v_sem));
err = ffsMapCluster(inode, clu_offset, clu);
sm_V(&(fs_struct[p_fs->drv].v_sem));
return(err);
}
s32 FsCreateDir(struct inode *inode, u8 *path, FILE_ID_T *fid)
{
s32 err;
struct super_block *sb = inode->i_sb;
FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info);
if ((fid == NULL) || (path == NULL) || (STRLEN(path) == 0))
return(FFS_ERROR);
sm_P(&(fs_struct[p_fs->drv].v_sem));
err = ffsCreateDir(inode, path, fid);
sm_V(&(fs_struct[p_fs->drv].v_sem));
return(err);
}
s32 FsReadDir(struct inode *inode, DIR_ENTRY_T *dir_entry)
{
s32 err;
struct super_block *sb = inode->i_sb;
FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info);
if (dir_entry == NULL) return(FFS_ERROR);
sm_P(&(fs_struct[p_fs->drv].v_sem));
err = ffsReadDir(inode, dir_entry);
sm_V(&(fs_struct[p_fs->drv].v_sem));
return(err);
}
s32 FsRemoveDir(struct inode *inode, FILE_ID_T *fid)
{
s32 err;
struct super_block *sb = inode->i_sb;
FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info);
if (fid == NULL) return(FFS_INVALIDFID);
sm_P(&(fs_struct[p_fs->drv].v_sem));
err = ffsRemoveDir(inode, fid);
sm_V(&(fs_struct[p_fs->drv].v_sem));
return(err);
}
s32 FsRemoveEntry(struct inode *inode, FILE_ID_T *fid)
{
s32 err;
struct super_block *sb = inode->i_sb;
FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info);
if (fid == NULL) return(FFS_INVALIDFID);
sm_P(&(fs_struct[p_fs->drv].v_sem));
err = ffsRemoveEntry(inode, fid);
sm_V(&(fs_struct[p_fs->drv].v_sem));
return(err);
}
EXPORT_SYMBOL(FsMountVol);
EXPORT_SYMBOL(FsUmountVol);
EXPORT_SYMBOL(FsGetVolInfo);
EXPORT_SYMBOL(FsSyncVol);
EXPORT_SYMBOL(FsLookupFile);
EXPORT_SYMBOL(FsCreateFile);
EXPORT_SYMBOL(FsReadFile);
EXPORT_SYMBOL(FsWriteFile);
EXPORT_SYMBOL(FsTruncateFile);
EXPORT_SYMBOL(FsMoveFile);
EXPORT_SYMBOL(FsRemoveFile);
EXPORT_SYMBOL(FsSetAttr);
EXPORT_SYMBOL(FsReadStat);
EXPORT_SYMBOL(FsWriteStat);
EXPORT_SYMBOL(FsMapCluster);
EXPORT_SYMBOL(FsCreateDir);
EXPORT_SYMBOL(FsReadDir);
EXPORT_SYMBOL(FsRemoveDir);
EXPORT_SYMBOL(FsRemoveEntry);
#ifdef CONFIG_EXFAT_KERNEL_DEBUG
s32 FsReleaseCache(struct super_block *sb)
{
FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info);
sm_P(&(fs_struct[p_fs->drv].v_sem));
FAT_release_all(sb);
buf_release_all(sb);
sm_V(&(fs_struct[p_fs->drv].v_sem));
return 0;
}
EXPORT_SYMBOL(FsReleaseCache);
#endif
static int __init init_exfat_core(void)
{
int err;
printk(KERN_INFO "exFAT: Core Version %s\n", EXFAT_VERSION);
err = FsInit();
if (err) {
if (err == FFS_MEMORYERR)
return -ENOMEM;
else
return -EIO;
}
return 0;
}
static void __exit exit_exfat_core(void)
{
FsShutdown();
}
module_init(init_exfat_core);
module_exit(exit_exfat_core);
MODULE_LICENSE("GPL");

176
fs/exfat/exfat_api.h Normal file
View File

@@ -0,0 +1,176 @@
/*
* Copyright (C) 2012-2013 Samsung Electronics Co., Ltd.
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _EXFAT_API_H
#define _EXFAT_API_H
#include <linux/fs.h>
#include "exfat_config.h"
#include "exfat_global.h"
#ifdef __cplusplus
extern "C" {
#endif
/*----------------------------------------------------------------------*/
/* Constant & Macro Definitions */
/*----------------------------------------------------------------------*/
#define EXFAT_SUPER_MAGIC (0x2011BAB0L)
#define EXFAT_ROOT_INO 1
/* FAT types */
#define FAT12 0x01 /* FAT12 */
#define FAT16 0x0E /* Win95 FAT16 (LBA) */
#define FAT32 0x0C /* Win95 FAT32 (LBA) */
#define EXFAT 0x07 /* exFAT */
/* file name lengths */
#define MAX_CHARSET_SIZE 3 /* max size of multi-byte character */
#define MAX_PATH_DEPTH 15 /* max depth of path name */
#define MAX_NAME_LENGTH 256 /* max len of file name including NULL */
#define MAX_PATH_LENGTH 260 /* max len of path name including NULL */
#define DOS_NAME_LENGTH 11 /* DOS file name length excluding NULL */
#define DOS_PATH_LENGTH 80 /* DOS path name length excluding NULL */
/* file attributes */
#define ATTR_NORMAL 0x0000
#define ATTR_READONLY 0x0001
#define ATTR_HIDDEN 0x0002
#define ATTR_SYSTEM 0x0004
#define ATTR_VOLUME 0x0008
#define ATTR_SUBDIR 0x0010
#define ATTR_ARCHIVE 0x0020
#define ATTR_SYMLINK 0x0040
#define ATTR_EXTEND 0x000F
#define ATTR_RWMASK 0x007E
/* file creation modes */
#define FM_REGULAR 0x00
#define FM_SYMLINK 0x40
/* return values */
#define FFS_SUCCESS 0
#define FFS_MEDIAERR 1
#define FFS_FORMATERR 2
#define FFS_MOUNTED 3
#define FFS_NOTMOUNTED 4
#define FFS_ALIGNMENTERR 5
#define FFS_SEMAPHOREERR 6
#define FFS_INVALIDPATH 7
#define FFS_INVALIDFID 8
#define FFS_NOTFOUND 9
#define FFS_FILEEXIST 10
#define FFS_PERMISSIONERR 11
#define FFS_NOTOPENED 12
#define FFS_MAXOPENED 13
#define FFS_FULL 14
#define FFS_EOF 15
#define FFS_DIRBUSY 16
#define FFS_MEMORYERR 17
#define FFS_NAMETOOLONG 18
#define FFS_ERROR 19
typedef struct {
u16 Year;
u16 Month;
u16 Day;
u16 Hour;
u16 Minute;
u16 Second;
u16 MilliSecond;
} DATE_TIME_T;
typedef struct {
u32 Offset;
u32 Size;
} PART_INFO_T;
typedef struct {
u32 SecSize;
u32 DevSize;
} DEV_INFO_T;
typedef struct {
u32 FatType;
u32 ClusterSize;
u32 NumClusters;
u32 FreeClusters;
u32 UsedClusters;
} VOL_INFO_T;
typedef struct {
u32 dir;
s32 size;
u8 flags;
} CHAIN_T;
typedef struct {
CHAIN_T dir;
s32 entry;
u32 type;
u32 attr;
u32 start_clu;
u64 size;
u8 flags;
s64 rwoffset;
s32 hint_last_off;
u32 hint_last_clu;
} FILE_ID_T;
typedef struct {
s8 Name[MAX_NAME_LENGTH *MAX_CHARSET_SIZE];
s8 ShortName[DOS_NAME_LENGTH + 2];
u32 Attr;
u64 Size;
u32 NumSubdirs;
DATE_TIME_T CreateTimestamp;
DATE_TIME_T ModifyTimestamp;
DATE_TIME_T AccessTimestamp;
} DIR_ENTRY_T;
s32 FsInit(void);
s32 FsShutdown(void);
s32 FsMountVol(struct super_block *sb);
s32 FsUmountVol(struct super_block *sb);
s32 FsGetVolInfo(struct super_block *sb, VOL_INFO_T *info);
s32 FsSyncVol(struct super_block *sb, s32 do_sync);
s32 FsLookupFile(struct inode *inode, u8 *path, FILE_ID_T *fid);
s32 FsCreateFile(struct inode *inode, u8 *path, u8 mode, FILE_ID_T *fid);
s32 FsReadFile(struct inode *inode, FILE_ID_T *fid, void *buffer, u64 count, u64 *rcount);
s32 FsWriteFile(struct inode *inode, FILE_ID_T *fid, void *buffer, u64 count, u64 *wcount);
s32 FsTruncateFile(struct inode *inode, u64 old_size, u64 new_size);
s32 FsMoveFile(struct inode *old_parent_inode, FILE_ID_T *fid, struct inode *new_parent_inode, struct dentry *new_dentry);
s32 FsRemoveFile(struct inode *inode, FILE_ID_T *fid);
s32 FsSetAttr(struct inode *inode, u32 attr);
s32 FsReadStat(struct inode *inode, DIR_ENTRY_T *info);
s32 FsWriteStat(struct inode *inode, DIR_ENTRY_T *info);
s32 FsMapCluster(struct inode *inode, s32 clu_offset, u32 *clu);
s32 FsCreateDir(struct inode *inode, u8 *path, FILE_ID_T *fid);
s32 FsReadDir(struct inode *inode, DIR_ENTRY_T *dir_entry);
s32 FsRemoveDir(struct inode *inode, FILE_ID_T *fid);
s32 FsRemoveEntry(struct inode *inode, FILE_ID_T *fid);
s32 FsReleaseCache(struct super_block *sb);
#ifdef __cplusplus
}
#endif
#endif

195
fs/exfat/exfat_blkdev.c Normal file
View File

@@ -0,0 +1,195 @@
/*
* Copyright (C) 2012-2013 Samsung Electronics Co., Ltd.
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <linux/blkdev.h>
#include "exfat_config.h"
#include "exfat_global.h"
#include "exfat_blkdev.h"
#include "exfat_data.h"
#include "exfat_api.h"
#include "exfat_super.h"
s32 bdev_init(void)
{
return (FFS_SUCCESS);
}
s32 bdev_shutdown(void)
{
return (FFS_SUCCESS);
}
s32 bdev_open(struct super_block *sb)
{
BD_INFO_T *p_bd = &(EXFAT_SB(sb)->bd_info);
if (p_bd->opened)
return FFS_SUCCESS;
p_bd->sector_size = bdev_logical_block_size(sb->s_bdev);
p_bd->sector_size_bits = my_log2(p_bd->sector_size);
p_bd->sector_size_mask = p_bd->sector_size - 1;
p_bd->num_sectors = i_size_read(sb->s_bdev->bd_inode) >> p_bd->sector_size_bits;
p_bd->opened = TRUE;
return (FFS_SUCCESS);
}
s32 bdev_close(struct super_block *sb)
{
BD_INFO_T *p_bd = &(EXFAT_SB(sb)->bd_info);
if (!p_bd->opened)
return (FFS_SUCCESS);
p_bd->opened = FALSE;
return (FFS_SUCCESS);
}
s32 bdev_read(struct super_block *sb, sector_t secno, struct buffer_head **bh, u32 num_secs, s32 read)
{
BD_INFO_T *p_bd = &(EXFAT_SB(sb)->bd_info);
FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info);
#ifdef CONFIG_EXFAT_KERNEL_DEBUG
struct exfat_sb_info *sbi = EXFAT_SB(sb);
long flags = sbi->debug_flags;
if (flags & EXFAT_DEBUGFLAGS_ERROR_RW)
return (FFS_MEDIAERR);
#endif
if (!p_bd->opened)
return (FFS_MEDIAERR);
if (*bh) __brelse(*bh);
if (read)
*bh = __bread(sb->s_bdev, secno, num_secs << p_bd->sector_size_bits);
else
*bh = __getblk(sb->s_bdev, secno, num_secs << p_bd->sector_size_bits);
if (*bh)
return (FFS_SUCCESS);
WARN(!p_fs->dev_ejected,
"[EXFAT] No bh, device seems wrong or to be ejected.\n");
return (FFS_MEDIAERR);
}
s32 bdev_write(struct super_block *sb, sector_t secno, struct buffer_head *bh, u32 num_secs, s32 sync)
{
s32 count;
struct buffer_head *bh2;
BD_INFO_T *p_bd = &(EXFAT_SB(sb)->bd_info);
FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info);
#ifdef CONFIG_EXFAT_KERNEL_DEBUG
struct exfat_sb_info *sbi = EXFAT_SB(sb);
long flags = sbi->debug_flags;
if (flags & EXFAT_DEBUGFLAGS_ERROR_RW)
return (FFS_MEDIAERR);
#endif
if (!p_bd->opened)
return (FFS_MEDIAERR);
if (secno == bh->b_blocknr) {
set_buffer_uptodate(bh);
mark_buffer_dirty(bh);
if (sync && (sync_dirty_buffer(bh) != 0))
return (FFS_MEDIAERR);
} else {
count = num_secs << p_bd->sector_size_bits;
bh2 = __getblk(sb->s_bdev, secno, count);
if (bh2 == NULL)
goto no_bh;
lock_buffer(bh2);
memcpy(bh2->b_data, bh->b_data, count);
set_buffer_uptodate(bh2);
mark_buffer_dirty(bh2);
unlock_buffer(bh2);
if (sync && (sync_dirty_buffer(bh2) != 0)) {
__brelse(bh2);
goto no_bh;
}
__brelse(bh2);
}
return (FFS_SUCCESS);
no_bh:
WARN(!p_fs->dev_ejected,
"[EXFAT] No bh, device seems wrong or to be ejected.\n");
return (FFS_MEDIAERR);
}
s32 bdev_sync(struct super_block *sb)
{
BD_INFO_T *p_bd = &(EXFAT_SB(sb)->bd_info);
#ifdef CONFIG_EXFAT_KERNEL_DEBUG
struct exfat_sb_info *sbi = EXFAT_SB(sb);
long flags = sbi->debug_flags;
if (flags & EXFAT_DEBUGFLAGS_ERROR_RW)
return (FFS_MEDIAERR);
#endif
if (!p_bd->opened)
return (FFS_MEDIAERR);
return sync_blockdev(sb->s_bdev);
}
s32 bdev_reada(struct super_block *sb, sector_t secno, u32 num_secs)
{
BD_INFO_T *p_bd = &(EXFAT_SB(sb)->bd_info);
u32 sects_per_page = (PAGE_SIZE >> sb->s_blocksize_bits);
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38)
struct blk_plug plug;
#endif
u32 i;
if (!p_bd->opened)
return (FFS_MEDIAERR);
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38)
blk_start_plug(&plug);
#endif
for (i = 0; i < num_secs; i++) {
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38)
if (i && !(i & (sects_per_page - 1)))
blk_finish_plug(&plug);
#endif
sb_breadahead(sb, secno + i);
}
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38)
blk_finish_plug(&plug);
#endif
return 0;
}

47
fs/exfat/exfat_blkdev.h Normal file
View File

@@ -0,0 +1,47 @@
/*
* Copyright (C) 2012-2013 Samsung Electronics Co., Ltd.
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _EXFAT_BLKDEV_H
#define _EXFAT_BLKDEV_H
#include "exfat_config.h"
#include "exfat_global.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct __BD_INFO_T {
s32 sector_size;
s32 sector_size_bits;
s32 sector_size_mask;
s32 num_sectors;
BOOL opened;
} BD_INFO_T;
s32 bdev_init(void);
s32 bdev_shutdown(void);
s32 bdev_open(struct super_block *sb);
s32 bdev_close(struct super_block *sb);
s32 bdev_read(struct super_block *sb, sector_t secno, struct buffer_head **bh, u32 num_secs, s32 read);
s32 bdev_write(struct super_block *sb, sector_t secno, struct buffer_head *bh, u32 num_secs, s32 sync);
s32 bdev_sync(struct super_block *sb);
s32 bdev_reada(struct super_block *sb, sector_t secno, u32 num_secs);
#ifdef __cplusplus
}
#endif
#endif

772
fs/exfat/exfat_cache.c Normal file
View File

@@ -0,0 +1,772 @@
/*
* Copyright (C) 2012-2013 Samsung Electronics Co., Ltd.
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "exfat_config.h"
#include "exfat_global.h"
#include "exfat_data.h"
#include "exfat_cache.h"
#include "exfat_super.h"
#include "exfat.h"
extern FS_STRUCT_T fs_struct[];
#define sm_P(s)
#define sm_V(s)
static s32 __FAT_read(struct super_block *sb, u32 loc, u32 *content);
static s32 __FAT_write(struct super_block *sb, u32 loc, u32 content);
static BUF_CACHE_T *FAT_cache_find(struct super_block *sb, sector_t sec);
static BUF_CACHE_T *FAT_cache_get(struct super_block *sb, sector_t sec);
static void FAT_cache_insert_hash(struct super_block *sb, BUF_CACHE_T *bp);
static void FAT_cache_remove_hash(BUF_CACHE_T *bp);
static u8 *__buf_getblk(struct super_block *sb, sector_t sec);
static BUF_CACHE_T *buf_cache_find(struct super_block *sb, sector_t sec);
static BUF_CACHE_T *buf_cache_get(struct super_block *sb, sector_t sec);
static void buf_cache_insert_hash(struct super_block *sb, BUF_CACHE_T *bp);
static void buf_cache_remove_hash(BUF_CACHE_T *bp);
static void push_to_mru(BUF_CACHE_T *bp, BUF_CACHE_T *list);
static void push_to_lru(BUF_CACHE_T *bp, BUF_CACHE_T *list);
static void move_to_mru(BUF_CACHE_T *bp, BUF_CACHE_T *list);
static void move_to_lru(BUF_CACHE_T *bp, BUF_CACHE_T *list);
s32 buf_init(struct super_block *sb)
{
FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info);
s32 i;
p_fs->FAT_cache_lru_list.next = p_fs->FAT_cache_lru_list.prev = &p_fs->FAT_cache_lru_list;
for (i = 0; i < FAT_CACHE_SIZE; i++) {
p_fs->FAT_cache_array[i].drv = -1;
p_fs->FAT_cache_array[i].sec = ~0;
p_fs->FAT_cache_array[i].flag = 0;
p_fs->FAT_cache_array[i].buf_bh = NULL;
p_fs->FAT_cache_array[i].prev = p_fs->FAT_cache_array[i].next = NULL;
push_to_mru(&(p_fs->FAT_cache_array[i]), &p_fs->FAT_cache_lru_list);
}
p_fs->buf_cache_lru_list.next = p_fs->buf_cache_lru_list.prev = &p_fs->buf_cache_lru_list;
for (i = 0; i < BUF_CACHE_SIZE; i++) {
p_fs->buf_cache_array[i].drv = -1;
p_fs->buf_cache_array[i].sec = ~0;
p_fs->buf_cache_array[i].flag = 0;
p_fs->buf_cache_array[i].buf_bh = NULL;
p_fs->buf_cache_array[i].prev = p_fs->buf_cache_array[i].next = NULL;
push_to_mru(&(p_fs->buf_cache_array[i]), &p_fs->buf_cache_lru_list);
}
for (i = 0; i < FAT_CACHE_HASH_SIZE; i++) {
p_fs->FAT_cache_hash_list[i].drv = -1;
p_fs->FAT_cache_hash_list[i].sec = ~0;
p_fs->FAT_cache_hash_list[i].hash_next = p_fs->FAT_cache_hash_list[i].hash_prev = &(p_fs->FAT_cache_hash_list[i]);
}
for (i = 0; i < FAT_CACHE_SIZE; i++) {
FAT_cache_insert_hash(sb, &(p_fs->FAT_cache_array[i]));
}
for (i = 0; i < BUF_CACHE_HASH_SIZE; i++) {
p_fs->buf_cache_hash_list[i].drv = -1;
p_fs->buf_cache_hash_list[i].sec = ~0;
p_fs->buf_cache_hash_list[i].hash_next = p_fs->buf_cache_hash_list[i].hash_prev = &(p_fs->buf_cache_hash_list[i]);
}
for (i = 0; i < BUF_CACHE_SIZE; i++) {
buf_cache_insert_hash(sb, &(p_fs->buf_cache_array[i]));
}
return(FFS_SUCCESS);
}
s32 buf_shutdown(struct super_block *sb)
{
return(FFS_SUCCESS);
}
s32 FAT_read(struct super_block *sb, u32 loc, u32 *content)
{
s32 ret;
sm_P(&f_sem);
ret = __FAT_read(sb, loc, content);
sm_V(&f_sem);
return(ret);
}
s32 FAT_write(struct super_block *sb, u32 loc, u32 content)
{
s32 ret;
sm_P(&f_sem);
ret = __FAT_write(sb, loc, content);
sm_V(&f_sem);
return(ret);
}
static s32 __FAT_read(struct super_block *sb, u32 loc, u32 *content)
{
s32 off;
u32 _content;
sector_t sec;
u8 *fat_sector, *fat_entry;
FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info);
BD_INFO_T *p_bd = &(EXFAT_SB(sb)->bd_info);
if (p_fs->vol_type == FAT12) {
sec = p_fs->FAT1_start_sector + ((loc + (loc >> 1)) >> p_bd->sector_size_bits);
off = (loc + (loc >> 1)) & p_bd->sector_size_mask;
if (off == (p_bd->sector_size-1)) {
fat_sector = FAT_getblk(sb, sec);
if (!fat_sector)
return -1;
_content = (u32) fat_sector[off];
fat_sector = FAT_getblk(sb, ++sec);
if (!fat_sector)
return -1;
_content |= (u32) fat_sector[0] << 8;
} else {
fat_sector = FAT_getblk(sb, sec);
if (!fat_sector)
return -1;
fat_entry = &(fat_sector[off]);
_content = GET16(fat_entry);
}
if (loc & 1) _content >>= 4;
_content &= 0x00000FFF;
if (_content >= CLUSTER_16(0x0FF8)) {
*content = CLUSTER_32(~0);
return 0;
} else {
*content = CLUSTER_32(_content);
return 0;
}
} else if (p_fs->vol_type == FAT16) {
sec = p_fs->FAT1_start_sector + (loc >> (p_bd->sector_size_bits-1));
off = (loc << 1) & p_bd->sector_size_mask;
fat_sector = FAT_getblk(sb, sec);
if
(!fat_sector)
return -1;
fat_entry = &(fat_sector[off]);
_content = GET16_A(fat_entry);
_content &= 0x0000FFFF;
if (_content >= CLUSTER_16(0xFFF8)) {
*content = CLUSTER_32(~0);
return 0;
} else {
*content = CLUSTER_32(_content);
return 0;
}
} else if (p_fs->vol_type == FAT32) {
sec = p_fs->FAT1_start_sector + (loc >> (p_bd->sector_size_bits-2));
off = (loc << 2) & p_bd->sector_size_mask;
fat_sector = FAT_getblk(sb, sec);
if (!fat_sector)
return -1;
fat_entry = &(fat_sector[off]);
_content = GET32_A(fat_entry);
_content &= 0x0FFFFFFF;
if (_content >= CLUSTER_32(0x0FFFFFF8)) {
*content = CLUSTER_32(~0);
return 0;
} else {
*content = CLUSTER_32(_content);
return 0;
}
} else {
sec = p_fs->FAT1_start_sector + (loc >> (p_bd->sector_size_bits-2));
off = (loc << 2) & p_bd->sector_size_mask;
fat_sector = FAT_getblk(sb, sec);
if (!fat_sector)
return -1;
fat_entry = &(fat_sector[off]);
_content = GET32_A(fat_entry);
if (_content >= CLUSTER_32(0xFFFFFFF8)) {
*content = CLUSTER_32(~0);
return 0;
} else {
*content = CLUSTER_32(_content);
return 0;
}
}
*content = CLUSTER_32(~0);
return 0;
}
static s32 __FAT_write(struct super_block *sb, u32 loc, u32 content)
{
s32 off;
sector_t sec;
u8 *fat_sector, *fat_entry;
FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info);
BD_INFO_T *p_bd = &(EXFAT_SB(sb)->bd_info);
if (p_fs->vol_type == FAT12) {
content &= 0x00000FFF;
sec = p_fs->FAT1_start_sector + ((loc + (loc >> 1)) >> p_bd->sector_size_bits);
off = (loc + (loc >> 1)) & p_bd->sector_size_mask;
fat_sector = FAT_getblk(sb, sec);
if (!fat_sector)
return -1;
if (loc & 1) {
content <<= 4;
if (off == (p_bd->sector_size-1)) {
fat_sector[off] = (u8)(content | (fat_sector[off] & 0x0F));
FAT_modify(sb, sec);
fat_sector = FAT_getblk(sb, ++sec);
if (!fat_sector)
return -1;
fat_sector[0] = (u8)(content >> 8);
} else {
fat_entry = &(fat_sector[off]);
content |= GET16(fat_entry) & 0x000F;
SET16(fat_entry, content);
}
} else {
fat_sector[off] = (u8)(content);
if (off == (p_bd->sector_size-1)) {
fat_sector[off] = (u8)(content);
FAT_modify(sb, sec);
fat_sector = FAT_getblk(sb, ++sec);
fat_sector[0] = (u8)((fat_sector[0] & 0xF0) | (content >> 8));
} else {
fat_entry = &(fat_sector[off]);
content |= GET16(fat_entry) & 0xF000;
SET16(fat_entry, content);
}
}
}
else if (p_fs->vol_type == FAT16) {
content &= 0x0000FFFF;
sec = p_fs->FAT1_start_sector + (loc >> (p_bd->sector_size_bits-1));
off = (loc << 1) & p_bd->sector_size_mask;
fat_sector = FAT_getblk(sb, sec);
if (!fat_sector)
return -1;
fat_entry = &(fat_sector[off]);
SET16_A(fat_entry, content);
}
else if (p_fs->vol_type == FAT32) {
content &= 0x0FFFFFFF;
sec = p_fs->FAT1_start_sector + (loc >> (p_bd->sector_size_bits-2));
off = (loc << 2) & p_bd->sector_size_mask;
fat_sector = FAT_getblk(sb, sec);
if (!fat_sector)
return -1;
fat_entry = &(fat_sector[off]);
content |= GET32_A(fat_entry) & 0xF0000000;
SET32_A(fat_entry, content);
}
else {
sec = p_fs->FAT1_start_sector + (loc >> (p_bd->sector_size_bits-2));
off = (loc << 2) & p_bd->sector_size_mask;
fat_sector = FAT_getblk(sb, sec);
if (!fat_sector)
return -1;
fat_entry = &(fat_sector[off]);
SET32_A(fat_entry, content);
}
FAT_modify(sb, sec);
return 0;
}
u8 *FAT_getblk(struct super_block *sb, sector_t sec)
{
BUF_CACHE_T *bp;
FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info);
bp = FAT_cache_find(sb, sec);
if (bp != NULL) {
move_to_mru(bp, &p_fs->FAT_cache_lru_list);
return(bp->buf_bh->b_data);
}
bp = FAT_cache_get(sb, sec);
FAT_cache_remove_hash(bp);
bp->drv = p_fs->drv;
bp->sec = sec;
bp->flag = 0;
FAT_cache_insert_hash(sb, bp);
if (sector_read(sb, sec, &(bp->buf_bh), 1) != FFS_SUCCESS) {
FAT_cache_remove_hash(bp);
bp->drv = -1;
bp->sec = ~0;
bp->flag = 0;
bp->buf_bh = NULL;
move_to_lru(bp, &p_fs->FAT_cache_lru_list);
return NULL;
}
return(bp->buf_bh->b_data);
}
void FAT_modify(struct super_block *sb, sector_t sec)
{
BUF_CACHE_T *bp;
bp = FAT_cache_find(sb, sec);
if (bp != NULL) {
sector_write(sb, sec, bp->buf_bh, 0);
}
}
void FAT_release_all(struct super_block *sb)
{
BUF_CACHE_T *bp;
FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info);
sm_P(&f_sem);
bp = p_fs->FAT_cache_lru_list.next;
while (bp != &p_fs->FAT_cache_lru_list) {
if (bp->drv == p_fs->drv) {
bp->drv = -1;
bp->sec = ~0;
bp->flag = 0;
if(bp->buf_bh) {
__brelse(bp->buf_bh);
bp->buf_bh = NULL;
}
}
bp = bp->next;
}
sm_V(&f_sem);
}
void FAT_sync(struct super_block *sb)
{
BUF_CACHE_T *bp;
FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info);
sm_P(&f_sem);
bp = p_fs->FAT_cache_lru_list.next;
while (bp != &p_fs->FAT_cache_lru_list) {
if ((bp->drv == p_fs->drv) && (bp->flag & DIRTYBIT)) {
sync_dirty_buffer(bp->buf_bh);
bp->flag &= ~(DIRTYBIT);
}
bp = bp->next;
}
sm_V(&f_sem);
}
static BUF_CACHE_T *FAT_cache_find(struct super_block *sb, sector_t sec)
{
s32 off;
BUF_CACHE_T *bp, *hp;
FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info);
off = (sec + (sec >> p_fs->sectors_per_clu_bits)) & (FAT_CACHE_HASH_SIZE - 1);
hp = &(p_fs->FAT_cache_hash_list[off]);
for (bp = hp->hash_next; bp != hp; bp = bp->hash_next) {
if ((bp->drv == p_fs->drv) && (bp->sec == sec)) {
WARN(!bp->buf_bh, "[EXFAT] FAT_cache has no bh. "
"It will make system panic.\n");
touch_buffer(bp->buf_bh);
return(bp);
}
}
return(NULL);
}
static BUF_CACHE_T *FAT_cache_get(struct super_block *sb, sector_t sec)
{
BUF_CACHE_T *bp;
FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info);
bp = p_fs->FAT_cache_lru_list.prev;
move_to_mru(bp, &p_fs->FAT_cache_lru_list);
return(bp);
}
static void FAT_cache_insert_hash(struct super_block *sb, BUF_CACHE_T *bp)
{
s32 off;
BUF_CACHE_T *hp;
FS_INFO_T *p_fs;
p_fs = &(EXFAT_SB(sb)->fs_info);
off = (bp->sec + (bp->sec >> p_fs->sectors_per_clu_bits)) & (FAT_CACHE_HASH_SIZE-1);
hp = &(p_fs->FAT_cache_hash_list[off]);
bp->hash_next = hp->hash_next;
bp->hash_prev = hp;
hp->hash_next->hash_prev = bp;
hp->hash_next = bp;
}
static void FAT_cache_remove_hash(BUF_CACHE_T *bp)
{
(bp->hash_prev)->hash_next = bp->hash_next;
(bp->hash_next)->hash_prev = bp->hash_prev;
}
u8 *buf_getblk(struct super_block *sb, sector_t sec)
{
u8 *buf;
sm_P(&b_sem);
buf = __buf_getblk(sb, sec);
sm_V(&b_sem);
return(buf);
}
static u8 *__buf_getblk(struct super_block *sb, sector_t sec)
{
BUF_CACHE_T *bp;
FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info);
bp = buf_cache_find(sb, sec);
if (bp != NULL) {
move_to_mru(bp, &p_fs->buf_cache_lru_list);
return(bp->buf_bh->b_data);
}
bp = buf_cache_get(sb, sec);
buf_cache_remove_hash(bp);
bp->drv = p_fs->drv;
bp->sec = sec;
bp->flag = 0;
buf_cache_insert_hash(sb, bp);
if (sector_read(sb, sec, &(bp->buf_bh), 1) != FFS_SUCCESS) {
buf_cache_remove_hash(bp);
bp->drv = -1;
bp->sec = ~0;
bp->flag = 0;
bp->buf_bh = NULL;
move_to_lru(bp, &p_fs->buf_cache_lru_list);
return NULL;
}
return(bp->buf_bh->b_data);
}
void buf_modify(struct super_block *sb, sector_t sec)
{
BUF_CACHE_T *bp;
sm_P(&b_sem);
bp = buf_cache_find(sb, sec);
if (likely(bp != NULL)) {
sector_write(sb, sec, bp->buf_bh, 0);
}
WARN(!bp, "[EXFAT] failed to find buffer_cache(sector:%llu).\n",
(unsigned long long)sec);
sm_V(&b_sem);
}
void buf_lock(struct super_block *sb, sector_t sec)
{
BUF_CACHE_T *bp;
sm_P(&b_sem);
bp = buf_cache_find(sb, sec);
if (likely(bp != NULL)) bp->flag |= LOCKBIT;
WARN(!bp, "[EXFAT] failed to find buffer_cache(sector:%llu).\n",
(unsigned long long)sec);
sm_V(&b_sem);
}
void buf_unlock(struct super_block *sb, sector_t sec)
{
BUF_CACHE_T *bp;
sm_P(&b_sem);
bp = buf_cache_find(sb, sec);
if (likely(bp != NULL)) bp->flag &= ~(LOCKBIT);
WARN(!bp, "[EXFAT] failed to find buffer_cache(sector:%llu).\n",
(unsigned long long)sec);
sm_V(&b_sem);
}
void buf_release(struct super_block *sb, sector_t sec)
{
BUF_CACHE_T *bp;
FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info);
sm_P(&b_sem);
bp = buf_cache_find(sb, sec);
if (likely(bp != NULL)) {
bp->drv = -1;
bp->sec = ~0;
bp->flag = 0;
if(bp->buf_bh) {
__brelse(bp->buf_bh);
bp->buf_bh = NULL;
}
move_to_lru(bp, &p_fs->buf_cache_lru_list);
}
sm_V(&b_sem);
}
void buf_release_all(struct super_block *sb)
{
BUF_CACHE_T *bp;
FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info);
sm_P(&b_sem);
bp = p_fs->buf_cache_lru_list.next;
while (bp != &p_fs->buf_cache_lru_list) {
if (bp->drv == p_fs->drv) {
bp->drv = -1;
bp->sec = ~0;
bp->flag = 0;
if(bp->buf_bh) {
__brelse(bp->buf_bh);
bp->buf_bh = NULL;
}
}
bp = bp->next;
}
sm_V(&b_sem);
}
void buf_sync(struct super_block *sb)
{
BUF_CACHE_T *bp;
FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info);
sm_P(&b_sem);
bp = p_fs->buf_cache_lru_list.next;
while (bp != &p_fs->buf_cache_lru_list) {
if ((bp->drv == p_fs->drv) && (bp->flag & DIRTYBIT)) {
sync_dirty_buffer(bp->buf_bh);
bp->flag &= ~(DIRTYBIT);
}
bp = bp->next;
}
sm_V(&b_sem);
}
static BUF_CACHE_T *buf_cache_find(struct super_block *sb, sector_t sec)
{
s32 off;
BUF_CACHE_T *bp, *hp;
FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info);
off = (sec + (sec >> p_fs->sectors_per_clu_bits)) & (BUF_CACHE_HASH_SIZE - 1);
hp = &(p_fs->buf_cache_hash_list[off]);
for (bp = hp->hash_next; bp != hp; bp = bp->hash_next) {
if ((bp->drv == p_fs->drv) && (bp->sec == sec)) {
touch_buffer(bp->buf_bh);
return(bp);
}
}
return(NULL);
}
static BUF_CACHE_T *buf_cache_get(struct super_block *sb, sector_t sec)
{
BUF_CACHE_T *bp;
FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info);
bp = p_fs->buf_cache_lru_list.prev;
while (bp->flag & LOCKBIT) bp = bp->prev;
move_to_mru(bp, &p_fs->buf_cache_lru_list);
return(bp);
}
static void buf_cache_insert_hash(struct super_block *sb, BUF_CACHE_T *bp)
{
s32 off;
BUF_CACHE_T *hp;
FS_INFO_T *p_fs;
p_fs = &(EXFAT_SB(sb)->fs_info);
off = (bp->sec + (bp->sec >> p_fs->sectors_per_clu_bits)) & (BUF_CACHE_HASH_SIZE-1);
hp = &(p_fs->buf_cache_hash_list[off]);
bp->hash_next = hp->hash_next;
bp->hash_prev = hp;
hp->hash_next->hash_prev = bp;
hp->hash_next = bp;
}
static void buf_cache_remove_hash(BUF_CACHE_T *bp)
{
(bp->hash_prev)->hash_next = bp->hash_next;
(bp->hash_next)->hash_prev = bp->hash_prev;
}
static void push_to_mru(BUF_CACHE_T *bp, BUF_CACHE_T *list)
{
bp->next = list->next;
bp->prev = list;
list->next->prev = bp;
list->next = bp;
}
static void push_to_lru(BUF_CACHE_T *bp, BUF_CACHE_T *list)
{
bp->prev = list->prev;
bp->next = list;
list->prev->next = bp;
list->prev = bp;
}
static void move_to_mru(BUF_CACHE_T *bp, BUF_CACHE_T *list)
{
bp->prev->next = bp->next;
bp->next->prev = bp->prev;
push_to_mru(bp, list);
}
static void move_to_lru(BUF_CACHE_T *bp, BUF_CACHE_T *list)
{
bp->prev->next = bp->next;
bp->next->prev = bp->prev;
push_to_lru(bp, list);
}
s32 buf_cache_readahead(struct super_block * sb, sector_t sec)
{
FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info);
struct buffer_head *bh;
u32 max_ra_count = DCACHE_MAX_RA_SIZE >> sb->s_blocksize_bits;
u32 page_ra_count = PAGE_SIZE >> sb->s_blocksize_bits;
u32 adj_ra_count = max(p_fs->sectors_per_clu, page_ra_count);
u32 ra_count = min(adj_ra_count, max_ra_count);
if (p_fs->sectors_per_clu == 1)
return 0;
if (sec < p_fs->data_start_sector)
return (FFS_MEDIAERR);
/* Not sector aligned with ra_count, resize ra_count to page size */
if ((sec - p_fs->data_start_sector) & (ra_count - 1))
ra_count = page_ra_count;
bh = sb_find_get_block(sb, sec);
if (!bh || !buffer_uptodate(bh))
bdev_reada(sb, sec, ra_count);
brelse(bh);
return 0;
}

66
fs/exfat/exfat_cache.h Normal file
View File

@@ -0,0 +1,66 @@
/*
* Copyright (C) 2012-2013 Samsung Electronics Co., Ltd.
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _EXFAT_CACHE_H
#define _EXFAT_CACHE_H
#include "exfat_config.h"
#include "exfat_global.h"
#ifdef __cplusplus
extern "C" {
#endif
#define LOCKBIT 0x01
#define DIRTYBIT 0x02
#define DCACHE_MAX_RA_SIZE (128*1024)
typedef struct __BUF_CACHE_T {
struct __BUF_CACHE_T *next;
struct __BUF_CACHE_T *prev;
struct __BUF_CACHE_T *hash_next;
struct __BUF_CACHE_T *hash_prev;
s32 drv;
sector_t sec;
u32 flag;
struct buffer_head *buf_bh;
} BUF_CACHE_T;
s32 buf_init(struct super_block *sb);
s32 buf_shutdown(struct super_block *sb);
s32 FAT_read(struct super_block *sb, u32 loc, u32 *content);
s32 FAT_write(struct super_block *sb, u32 loc, u32 content);
u8 *FAT_getblk(struct super_block *sb, sector_t sec);
void FAT_modify(struct super_block *sb, sector_t sec);
void FAT_release_all(struct super_block *sb);
void FAT_sync(struct super_block *sb);
u8 *buf_getblk(struct super_block *sb, sector_t sec);
void buf_modify(struct super_block *sb, sector_t sec);
void buf_lock(struct super_block *sb, sector_t sec);
void buf_unlock(struct super_block *sb, sector_t sec);
void buf_release(struct super_block *sb, sector_t sec);
void buf_release_all(struct super_block *sb);
void buf_sync(struct super_block *sb);
s32 buf_cache_readahead(struct super_block * sb, sector_t sec);
#ifdef __cplusplus
}
#endif
#endif

57
fs/exfat/exfat_config.h Normal file
View File

@@ -0,0 +1,57 @@
/*
* Copyright (C) 2012-2013 Samsung Electronics Co., Ltd.
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _EXFAT_CONFIG_H
#define _EXFAT_CONFIG_H
#ifdef __cplusplus
extern "C" {
#endif
#define OS_NONOS 1
#define OS_LINUX 2
#define FFS_CONFIG_OS OS_LINUX
#define FFS_CONFIG_LITTLE_ENDIAN 1
#define FFS_CONFIG_LEGACY_32BIT_API 0
#define FFS_CONFIG_LEGACY_32BIT_API 0
#define FFS_CONFIG_SUPPORT_CP1250 1
#define FFS_CONFIG_SUPPORT_CP1251 1
#define FFS_CONFIG_SUPPORT_CP1252 1
#define FFS_CONFIG_SUPPORT_CP1253 1
#define FFS_CONFIG_SUPPORT_CP1254 1
#define FFS_CONFIG_SUPPORT_CP1255 1
#define FFS_CONFIG_SUPPORT_CP1256 1
#define FFS_CONFIG_SUPPORT_CP1257 1
#define FFS_CONFIG_SUPPORT_CP1258 1
#define FFS_CONFIG_SUPPORT_CP874 1
#define FFS_CONFIG_SUPPORT_CP932 1
#define FFS_CONFIG_SUPPORT_CP936 1
#define FFS_CONFIG_SUPPORT_CP949 1
#define FFS_CONFIG_SUPPORT_CP950 1
#define FFS_CONFIG_SUPPORT_UTF8 1
#define EXFAT_CONFIG_DISCARD 1
#define EXFAT_CONFIG_KERNEL_DEBUG 1
#define EXFAT_CONFIG_DEBUG_MSG 0
#ifdef __cplusplus
}
#endif
#endif

40
fs/exfat/exfat_data.c Normal file
View File

@@ -0,0 +1,40 @@
/*
* Copyright (C) 2012-2013 Samsung Electronics Co., Ltd.
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "exfat_config.h"
#include "exfat_global.h"
#include "exfat_data.h"
#include "exfat_oal.h"
#include "exfat_blkdev.h"
#include "exfat_cache.h"
#include "exfat_nls.h"
#include "exfat_super.h"
#include "exfat.h"
FS_STRUCT_T fs_struct[MAX_DRIVE];
DECLARE_MUTEX(f_sem);
BUF_CACHE_T FAT_cache_array[FAT_CACHE_SIZE];
BUF_CACHE_T FAT_cache_lru_list;
BUF_CACHE_T FAT_cache_hash_list[FAT_CACHE_HASH_SIZE];
DECLARE_MUTEX(b_sem);
BUF_CACHE_T buf_cache_array[BUF_CACHE_SIZE];
BUF_CACHE_T buf_cache_lru_list;
BUF_CACHE_T buf_cache_hash_list[BUF_CACHE_HASH_SIZE];

39
fs/exfat/exfat_data.h Normal file
View File

@@ -0,0 +1,39 @@
/*
* Copyright (C) 2012-2013 Samsung Electronics Co., Ltd.
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _EXFAT_DATA_H
#define _EXFAT_DATA_H
#include "exfat_config.h"
#include "exfat_global.h"
#ifdef __cplusplus
extern "C" {
#endif
#define MAX_DEVICE 2
#define MAX_DRIVE 4
#define MAX_OPEN 20
#define MAX_DENTRY 512
#define FAT_CACHE_SIZE 128
#define FAT_CACHE_HASH_SIZE 64
#define BUF_CACHE_SIZE 256
#define BUF_CACHE_HASH_SIZE 64
#define DEFAULT_CODEPAGE 437
#define DEFAULT_IOCHARSET "utf8"
#ifdef __cplusplus
}
#endif
#endif

119
fs/exfat/exfat_global.c Normal file
View File

@@ -0,0 +1,119 @@
/*
* Copyright (C) 2012-2013 Samsung Electronics Co., Ltd.
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "exfat_config.h"
#include "exfat_global.h"
s32 __wstrchr(u16 *str, u16 wchar)
{
while (*str) {
if (*(str++) == wchar) return(1);
}
return(0);
}
s32 __wstrlen(u16 *str)
{
s32 length = 0;
while (*(str++)) length++;
return(length);
}
#define BITMAP_LOC(v) ((v) >> 3)
#define BITMAP_SHIFT(v) ((v) & 0x07)
void Bitmap_set_all(u8 *bitmap, s32 mapsize)
{
MEMSET(bitmap, 0xFF, mapsize);
}
void Bitmap_clear_all(u8 *bitmap, s32 mapsize)
{
MEMSET(bitmap, 0x0, mapsize);
}
s32 Bitmap_test(u8 *bitmap, s32 i)
{
u8 data;
data = bitmap[BITMAP_LOC(i)];
if ((data >> BITMAP_SHIFT(i)) & 0x01) return(1);
return(0);
}
void Bitmap_set(u8 *bitmap, s32 i)
{
bitmap[BITMAP_LOC(i)] |= (0x01 << BITMAP_SHIFT(i));
}
void Bitmap_clear(u8 *bitmap, s32 i)
{
bitmap[BITMAP_LOC(i)] &= ~(0x01 << BITMAP_SHIFT(i));
}
void Bitmap_nbits_set(u8 *bitmap, s32 offset, s32 nbits)
{
s32 i;
for (i = 0; i < nbits; i++) {
Bitmap_set(bitmap, offset+i);
}
}
void Bitmap_nbits_clear(u8 *bitmap, s32 offset, s32 nbits)
{
s32 i;
for (i = 0; i < nbits; i++) {
Bitmap_clear(bitmap, offset+i);
}
}
void my_itoa(s8 *buf, s32 v)
{
s32 mod[10];
s32 i;
for (i = 0; i < 10; i++) {
mod[i] = (v % 10);
v = v / 10;
if (v == 0) break;
}
if (i == 10)
i--;
for (; i >= 0; i--) {
*buf = (u8) ('0' + mod[i]);
buf++;
}
*buf = '\0';
}
s32 my_log2(u32 v)
{
u32 bits = 0;
while (v > 1) {
if (v & 0x01) return(-1);
v >>= 1;
bits++;
}
return(bits);
}

132
fs/exfat/exfat_global.h Normal file
View File

@@ -0,0 +1,132 @@
/*
* Copyright (C) 2012-2013 Samsung Electronics Co., Ltd.
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _EXFAT_GLOBAL_H
#define _EXFAT_GLOBAL_H
#include <linux/kernel.h>
#include <linux/mm.h>
#include <linux/slab.h>
#include <linux/string.h>
#include <linux/fs.h>
#include "exfat_config.h"
#ifdef CONFIG_EXFAT_SUPPORT_STLOG
#include <linux/stlog.h>
#else
#define ST_LOG(fmt,...)
#endif
#ifdef __cplusplus
extern "C" {
#endif
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
#ifndef OK
#define OK 0
#endif
#ifndef FAIL
#define FAIL 1
#endif
#ifndef NULL
#define NULL 0
#endif
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
typedef char INT8;
typedef short INT16;
typedef int INT32;
typedef long long INT64;
typedef unsigned char UINT8;
typedef unsigned short UINT16;
typedef unsigned int UINT32;
typedef unsigned long long UINT64;
typedef unsigned char BOOL;
#ifdef MALLOC
#undef MALLOC
#endif
#ifdef FREE
#undef FREE
#endif
#ifdef MEMSET
#undef MEMSET
#endif
#ifdef MEMCPY
#undef MEMCPY
#endif
#ifdef MEMCMP
#undef MEMCMP
#endif
#define MALLOC(size) kmalloc(size, GFP_KERNEL)
#define FREE(mem) if (mem) kfree(mem)
#define MEMSET(mem, value, size) memset(mem, value, size)
#define MEMCPY(dest, src, size) memcpy(dest, src, size)
#define MEMCMP(mem1, mem2, size) memcmp(mem1, mem2, size)
#define COPY_DENTRY(dest, src) memcpy(dest, src, sizeof(DENTRY_T))
#define STRCPY(dest, src) strcpy(dest, src)
#define STRNCPY(dest, src, n) strncpy(dest, src, n)
#define STRCAT(str1, str2) strcat(str1, str2)
#define STRCMP(str1, str2) strcmp(str1, str2)
#define STRNCMP(str1, str2, n) strncmp(str1, str2, n)
#define STRLEN(str) strlen(str)
s32 __wstrchr(u16 *str, u16 wchar);
s32 __wstrlen(u16 *str);
#define WSTRCHR(str, wchar) __wstrchr(str, wchar)
#define WSTRLEN(str) __wstrlen(str)
#ifdef CONFIG_EXFAT_DEBUG_MSG
#define PRINTK(...) \
do { \
printk("[EXFAT] " __VA_ARGS__); \
} while(0)
#else
#define PRINTK(...)
#endif
void Bitmap_set_all(u8 *bitmap, s32 mapsize);
void Bitmap_clear_all(u8 *bitmap, s32 mapsize);
s32 Bitmap_test(u8 *bitmap, s32 i);
void Bitmap_set(u8 *bitmap, s32 i);
void Bitmap_clear(u8 *bitmpa, s32 i);
void Bitmap_nbits_set(u8 *bitmap, s32 offset, s32 nbits);
void Bitmap_nbits_clear(u8 *bitmap, s32 offset, s32 nbits);
void my_itoa(s8 *buf, s32 v);
s32 my_log2(u32 v);
#ifdef PRINT
#undef PRINT
#endif
#define PRINT printk
#ifdef __cplusplus
}
#endif
#endif

347
fs/exfat/exfat_nls.c Normal file
View File

@@ -0,0 +1,347 @@
/*
* Copyright (C) 2012-2013 Samsung Electronics Co., Ltd.
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "exfat_config.h"
#include "exfat_global.h"
#include "exfat_data.h"
#include "exfat_nls.h"
#include "exfat_api.h"
#include "exfat_super.h"
#include "exfat.h"
#include <linux/nls.h>
static u16 bad_dos_chars[] = {
0x002B, 0x002C, 0x003B, 0x003D, 0x005B, 0x005D,
0xFF0B, 0xFF0C, 0xFF1B, 0xFF1D, 0xFF3B, 0xFF3D,
0
};
static u16 bad_uni_chars[] = {
0x0022, 0x002A, 0x002F, 0x003A,
0x003C, 0x003E, 0x003F, 0x005C, 0x007C,
0
};
static s32 convert_uni_to_ch(struct nls_table *nls, u8 *ch, u16 uni, s32 *lossy);
static s32 convert_ch_to_uni(struct nls_table *nls, u16 *uni, u8 *ch, s32 *lossy);
u16 nls_upper(struct super_block *sb, u16 a)
{
FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info);
if (EXFAT_SB(sb)->options.casesensitive)
return(a);
if ((p_fs->vol_utbl)[get_col_index(a)] != NULL)
return (p_fs->vol_utbl)[get_col_index(a)][get_row_index(a)];
else
return a;
}
s32 nls_dosname_cmp(struct super_block *sb, u8 *a, u8 *b)
{
return(STRNCMP((void *) a, (void *) b, DOS_NAME_LENGTH));
}
s32 nls_uniname_cmp(struct super_block *sb, u16 *a, u16 *b)
{
s32 i;
for (i = 0; i < MAX_NAME_LENGTH; i++, a++, b++) {
if (nls_upper(sb, *a) != nls_upper(sb, *b)) return(1);
if (*a == 0x0) return(0);
}
return(0);
}
void nls_uniname_to_dosname(struct super_block *sb, DOS_NAME_T *p_dosname, UNI_NAME_T *p_uniname, s32 *p_lossy)
{
s32 i, j, len, lossy = FALSE;
u8 buf[MAX_CHARSET_SIZE];
u8 lower = 0, upper = 0;
u8 *dosname = p_dosname->name;
u16 *uniname = p_uniname->name;
u16 *p, *last_period;
struct nls_table *nls = EXFAT_SB(sb)->nls_disk;
for (i = 0; i < DOS_NAME_LENGTH; i++) {
*(dosname+i) = ' ';
}
if (!nls_uniname_cmp(sb, uniname, (u16 *) UNI_CUR_DIR_NAME)) {
*(dosname) = '.';
p_dosname->name_case = 0x0;
if (p_lossy != NULL) *p_lossy = FALSE;
return;
}
if (!nls_uniname_cmp(sb, uniname, (u16 *) UNI_PAR_DIR_NAME)) {
*(dosname) = '.';
*(dosname+1) = '.';
p_dosname->name_case = 0x0;
if (p_lossy != NULL) *p_lossy = FALSE;
return;
}
last_period = NULL;
for (p = uniname; *p; p++) {
if (*p == (u16) '.') last_period = p;
}
i = 0;
while (i < DOS_NAME_LENGTH) {
if (i == 8) {
if (last_period == NULL) break;
if (uniname <= last_period) {
if (uniname < last_period) lossy = TRUE;
uniname = last_period + 1;
}
}
if (*uniname == (u16) '\0') {
break;
} else if (*uniname == (u16) ' ') {
lossy = TRUE;
} else if (*uniname == (u16) '.') {
if (uniname < last_period) lossy = TRUE;
else i = 8;
} else if (WSTRCHR(bad_dos_chars, *uniname)) {
lossy = TRUE;
*(dosname+i) = '_';
i++;
} else {
len = convert_uni_to_ch(nls, buf, *uniname, &lossy);
if (len > 1) {
if ((i >= 8) && ((i+len) > DOS_NAME_LENGTH)) {
break;
}
if ((i < 8) && ((i+len) > 8)) {
i = 8;
continue;
}
lower = 0xFF;
for (j = 0; j < len; j++, i++) {
*(dosname+i) = *(buf+j);
}
} else {
if ((*buf >= 'a') && (*buf <= 'z')) {
*(dosname+i) = *buf - ('a' - 'A');
if (i < 8) lower |= 0x08;
else lower |= 0x10;
} else if ((*buf >= 'A') && (*buf <= 'Z')) {
*(dosname+i) = *buf;
if (i < 8) upper |= 0x08;
else upper |= 0x10;
} else {
*(dosname+i) = *buf;
}
i++;
}
}
uniname++;
}
if (*dosname == 0xE5) *dosname = 0x05;
if (*uniname != 0x0) lossy = TRUE;
if (upper & lower) p_dosname->name_case = 0xFF;
else p_dosname->name_case = lower;
if (p_lossy != NULL) *p_lossy = lossy;
}
void nls_dosname_to_uniname(struct super_block *sb, UNI_NAME_T *p_uniname, DOS_NAME_T *p_dosname)
{
s32 i = 0, j, n = 0;
u8 buf[DOS_NAME_LENGTH+2];
u8 *dosname = p_dosname->name;
u16 *uniname = p_uniname->name;
struct nls_table *nls = EXFAT_SB(sb)->nls_disk;
if (*dosname == 0x05) {
*buf = 0xE5;
i++;
n++;
}
for ( ; i < 8; i++, n++) {
if (*(dosname+i) == ' ') break;
if ((*(dosname+i) >= 'A') && (*(dosname+i) <= 'Z') && (p_dosname->name_case & 0x08))
*(buf+n) = *(dosname+i) + ('a' - 'A');
else
*(buf+n) = *(dosname+i);
}
if (*(dosname+8) != ' ') {
*(buf+n) = '.';
n++;
}
for (i = 8; i < DOS_NAME_LENGTH; i++, n++) {
if (*(dosname+i) == ' ') break;
if ((*(dosname+i) >= 'A') && (*(dosname+i) <= 'Z') && (p_dosname->name_case & 0x10))
*(buf+n) = *(dosname+i) + ('a' - 'A');
else
*(buf+n) = *(dosname+i);
}
*(buf+n) = '\0';
i = j = 0;
while (j < (MAX_NAME_LENGTH-1)) {
if (*(buf+i) == '\0') break;
i += convert_ch_to_uni(nls, uniname, (buf+i), NULL);
uniname++;
j++;
}
*uniname = (u16) '\0';
}
void nls_uniname_to_cstring(struct super_block *sb, u8 *p_cstring, UNI_NAME_T *p_uniname)
{
s32 i, j, len;
u8 buf[MAX_CHARSET_SIZE];
u16 *uniname = p_uniname->name;
struct nls_table *nls = EXFAT_SB(sb)->nls_io;
i = 0;
while (i < (MAX_NAME_LENGTH-1)) {
if (*uniname == (u16) '\0') break;
len = convert_uni_to_ch(nls, buf, *uniname, NULL);
if (len > 1) {
for (j = 0; j < len; j++)
*p_cstring++ = (s8) *(buf+j);
} else {
*p_cstring++ = (s8) *buf;
}
uniname++;
i++;
}
*p_cstring = '\0';
}
void nls_cstring_to_uniname(struct super_block *sb, UNI_NAME_T *p_uniname, u8 *p_cstring, s32 *p_lossy)
{
s32 i, j, lossy = FALSE;
u8 *end_of_name;
u16 upname[MAX_NAME_LENGTH];
u16 *uniname = p_uniname->name;
struct nls_table *nls = EXFAT_SB(sb)->nls_io;
end_of_name = p_cstring + STRLEN((s8 *) p_cstring);
while (*(--end_of_name) == ' ') {
if (end_of_name < p_cstring) break;
}
*(++end_of_name) = '\0';
if (STRCMP((s8 *) p_cstring, ".") && STRCMP((s8 *) p_cstring, "..")) {
while (*(--end_of_name) == '.') {
if (end_of_name < p_cstring) break;
}
*(++end_of_name) = '\0';
}
if (*p_cstring == '\0')
lossy = TRUE;
i = j = 0;
while (j < (MAX_NAME_LENGTH-1)) {
if (*(p_cstring+i) == '\0') break;
i += convert_ch_to_uni(nls, uniname, (u8 *)(p_cstring+i), &lossy);
if ((*uniname < 0x0020) || WSTRCHR(bad_uni_chars, *uniname))
lossy = TRUE;
*(upname+j) = nls_upper(sb, *uniname);
uniname++;
j++;
}
if (*(p_cstring+i) != '\0')
lossy = TRUE;
*uniname = (u16) '\0';
p_uniname->name_len = j;
p_uniname->name_hash = calc_checksum_2byte((void *) upname, j<<1, 0, CS_DEFAULT);
if (p_lossy != NULL)
*p_lossy = lossy;
}
static s32 convert_ch_to_uni(struct nls_table *nls, u16 *uni, u8 *ch, s32 *lossy)
{
int len;
*uni = 0x0;
if (ch[0] < 0x80) {
*uni = (u16) ch[0];
return(1);
}
if ((len = nls->char2uni(ch, NLS_MAX_CHARSET_SIZE, uni)) < 0) {
printk("%s: fail to use nls \n", __func__);
if (lossy != NULL)
*lossy = TRUE;
*uni = (u16) '_';
if (!strcmp(nls->charset, "utf8")) return(1);
else return(2);
}
return(len);
}
static s32 convert_uni_to_ch(struct nls_table *nls, u8 *ch, u16 uni, s32 *lossy)
{
int len;
ch[0] = 0x0;
if (uni < 0x0080) {
ch[0] = (u8) uni;
return(1);
}
if ((len = nls->uni2char(uni, ch, NLS_MAX_CHARSET_SIZE)) < 0) {
printk("%s: fail to use nls \n", __func__);
if (lossy != NULL) *lossy = TRUE;
ch[0] = '_';
return(1);
}
return(len);
}

68
fs/exfat/exfat_nls.h Normal file
View File

@@ -0,0 +1,68 @@
/*
* Copyright (C) 2012-2013 Samsung Electronics Co., Ltd.
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _EXFAT_NLS_H
#define _EXFAT_NLS_H
#include <linux/nls.h>
#include "exfat_config.h"
#include "exfat_global.h"
#include "exfat_api.h"
#ifdef __cplusplus
extern "C" {
#endif
#define NUM_UPCASE 2918
#define DOS_CUR_DIR_NAME ". "
#define DOS_PAR_DIR_NAME ".. "
#if (FFS_CONFIG_LITTLE_ENDIAN == 1)
#define UNI_CUR_DIR_NAME ".\0"
#define UNI_PAR_DIR_NAME ".\0.\0"
#else
#define UNI_CUR_DIR_NAME "\0."
#define UNI_PAR_DIR_NAME "\0.\0."
#endif
typedef struct {
u8 name[DOS_NAME_LENGTH];
u8 name_case;
} DOS_NAME_T;
typedef struct {
u16 name[MAX_NAME_LENGTH];
u16 name_hash;
u8 name_len;
} UNI_NAME_T;
u16 nls_upper(struct super_block *sb, u16 a);
s32 nls_dosname_cmp(struct super_block *sb, u8 *a, u8 *b);
s32 nls_uniname_cmp(struct super_block *sb, u16 *a, u16 *b);
void nls_uniname_to_dosname(struct super_block *sb, DOS_NAME_T *p_dosname, UNI_NAME_T *p_uniname, s32 *p_lossy);
void nls_dosname_to_uniname(struct super_block *sb, UNI_NAME_T *p_uniname, DOS_NAME_T *p_dosname);
void nls_uniname_to_cstring(struct super_block *sb, u8 *p_cstring, UNI_NAME_T *p_uniname);
void nls_cstring_to_uniname(struct super_block *sb, UNI_NAME_T *p_uniname, u8 *p_cstring, s32 *p_lossy);
#ifdef __cplusplus
}
#endif
#endif

153
fs/exfat/exfat_oal.c Normal file
View File

@@ -0,0 +1,153 @@
/* Some of the source code in this file came from "linux/fs/fat/misc.c". */
/*
* linux/fs/fat/misc.c
*
* Written 1992,1993 by Werner Almesberger
* 22/11/2000 - Fixed fat_date_unix2dos for dates earlier than 01/01/1980
* and date_dos2unix for date==0 by Igor Zhbanov(bsg@uniyar.ac.ru)
*/
/*
* Copyright (C) 2012-2013 Samsung Electronics Co., Ltd.
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <linux/semaphore.h>
#include <linux/time.h>
#include "exfat_config.h"
#include "exfat_global.h"
#include "exfat_api.h"
#include "exfat_oal.h"
DECLARE_MUTEX(z_sem);
s32 sm_init(struct semaphore *sm)
{
sema_init(sm, 1);
return(0);
}
s32 sm_P(struct semaphore *sm)
{
down(sm);
return 0;
}
void sm_V(struct semaphore *sm)
{
up(sm);
}
extern struct timezone sys_tz;
#define UNIX_SECS_1980 315532800L
#if BITS_PER_LONG == 64
#define UNIX_SECS_2108 4354819200L
#endif
#define DAYS_DELTA_DECADE (365 * 10 + 2)
#define NO_LEAP_YEAR_2100 (120)
#define IS_LEAP_YEAR(y) (!((y) & 3) && (y) != NO_LEAP_YEAR_2100)
#define SECS_PER_MIN (60)
#define SECS_PER_HOUR (60 * SECS_PER_MIN)
#define SECS_PER_DAY (24 * SECS_PER_HOUR)
#define MAKE_LEAP_YEAR(leap_year, year) \
do { \
if (unlikely(year > NO_LEAP_YEAR_2100)) \
leap_year = ((year + 3) / 4) - 1; \
else \
leap_year = ((year + 3) / 4); \
} while(0)
static time_t accum_days_in_year[] = {
0, 0, 31, 59, 90,120,151,181,212,243,273,304,334, 0, 0, 0,
};
TIMESTAMP_T *tm_current(TIMESTAMP_T *tp, u8 tz_utc)
{
time_t second, day, leap_day, month, year;
#if LINUX_VERSION_CODE < KERNEL_VERSION(4,8,0)
struct timespec ts;
ts = CURRENT_TIME_SEC;
second = ts.tv_sec;
#else
second = ktime_get_real_seconds();
#endif
if (!tz_utc)
second -= sys_tz.tz_minuteswest * SECS_PER_MIN;
if (second < UNIX_SECS_1980) {
tp->sec = 0;
tp->min = 0;
tp->hour = 0;
tp->day = 1;
tp->mon = 1;
tp->year = 0;
return(tp);
}
#if BITS_PER_LONG == 64
if (second >= UNIX_SECS_2108) {
tp->sec = 59;
tp->min = 59;
tp->hour = 23;
tp->day = 31;
tp->mon = 12;
tp->year = 127;
return(tp);
}
#endif
day = second / SECS_PER_DAY - DAYS_DELTA_DECADE;
year = day / 365;
MAKE_LEAP_YEAR(leap_day, year);
if (year * 365 + leap_day > day)
year--;
MAKE_LEAP_YEAR(leap_day, year);
day -= year * 365 + leap_day;
if (IS_LEAP_YEAR(year) && day == accum_days_in_year[3]) {
month = 2;
} else {
if (IS_LEAP_YEAR(year) && day > accum_days_in_year[3])
day--;
for (month = 1; month < 12; month++) {
if (accum_days_in_year[month + 1] > day)
break;
}
}
day -= accum_days_in_year[month];
tp->sec = second % SECS_PER_MIN;
tp->min = (second / SECS_PER_MIN) % 60;
tp->hour = (second / SECS_PER_HOUR) % 24;
tp->day = day + 1;
tp->mon = month;
tp->year = year;
return(tp);
}

53
fs/exfat/exfat_oal.h Normal file
View File

@@ -0,0 +1,53 @@
/*
* Copyright (C) 2012-2013 Samsung Electronics Co., Ltd.
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _EXFAT_OAL_H
#define _EXFAT_OAL_H
#include "exfat_config.h"
#include "exfat_global.h"
#include <linux/version.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
u16 sec;
u16 min;
u16 hour;
u16 day;
u16 mon;
u16 year;
} TIMESTAMP_T;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)
#define DECLARE_MUTEX(m) DEFINE_SEMAPHORE(m)
#endif
s32 sm_init(struct semaphore *sm);
s32 sm_P(struct semaphore *sm);
void sm_V(struct semaphore *sm);
TIMESTAMP_T *tm_current(TIMESTAMP_T *tm, u8 tz_utc);
#ifdef __cplusplus
}
#endif
#endif

54
fs/exfat/exfat_part.h Normal file
View File

@@ -0,0 +1,54 @@
/*
* Copyright (C) 2012-2013 Samsung Electronics Co., Ltd.
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _EXFAT_PART_H
#define _EXFAT_PART_H
#include "exfat_config.h"
#include "exfat_global.h"
#include "exfat_api.h"
#ifdef __cplusplus
extern "C" {
#endif
#define MBR_SIGNATURE 0xAA55
typedef struct {
u8 boot_code[446];
u8 partition[64];
u8 signature[2];
} MBR_SECTOR_T;
typedef struct {
u8 def_boot;
u8 bgn_chs[3];
u8 sys_type;
u8 end_chs[3];
u8 start_sector[4];
u8 num_sectors[4];
} PART_ENTRY_T;
s32 ffsSetPartition(s32 dev, s32 num_vol, PART_INFO_T *vol_spec);
s32 ffsGetPartition(s32 dev, s32 *num_vol, PART_INFO_T *vol_spec);
s32 ffsGetDevInfo(s32 dev, DEV_INFO_T *info);
#ifdef __cplusplus
}
#endif
#endif

3120
fs/exfat/exfat_super.c Normal file

File diff suppressed because it is too large Load Diff

185
fs/exfat/exfat_super.h Normal file
View File

@@ -0,0 +1,185 @@
/* Some of the source code in this file came from "linux/fs/fat/fat.h". */
/*
* Copyright (C) 2012-2013 Samsung Electronics Co., Ltd.
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _EXFAT_LINUX_H
#define _EXFAT_LINUX_H
#include <linux/buffer_head.h>
#include <linux/string.h>
#include <linux/nls.h>
#include <linux/fs.h>
#include <linux/mutex.h>
#include <linux/swap.h>
#include "exfat_config.h"
#include "exfat_global.h"
#include "exfat_data.h"
#include "exfat_oal.h"
#include "exfat_blkdev.h"
#include "exfat_cache.h"
#include "exfat_part.h"
#include "exfat_nls.h"
#include "exfat_api.h"
#include "exfat.h"
#define EXFAT_ERRORS_CONT 1 /* ignore error and continue */
#define EXFAT_ERRORS_PANIC 2 /* panic on error */
#define EXFAT_ERRORS_RO 3 /* remount r/o on error */
/* ioctl command */
#define EXFAT_IOCTL_GET_VOLUME_ID _IOR('r', 0x12, __u32)
struct exfat_mount_options {
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0)
uid_t fs_uid;
gid_t fs_gid;
#else
kuid_t fs_uid;
kgid_t fs_gid;
#endif
unsigned short fs_fmask;
unsigned short fs_dmask;
unsigned short allow_utime; /* permission for setting the [am]time */
unsigned short codepage; /* codepage for shortname conversions */
char *iocharset; /* charset for filename input/display */
unsigned char casesensitive;
unsigned char tz_utc;
unsigned char errors;
#ifdef CONFIG_EXFAT_DISCARD
unsigned char discard; /* flag on if -o dicard specified and device support discard() */
#endif /* CONFIG_EXFAT_DISCARD */
};
#define EXFAT_HASH_BITS 8
#define EXFAT_HASH_SIZE (1UL << EXFAT_HASH_BITS)
/*
* EXFAT file system in-core superblock data
*/
struct exfat_sb_info {
FS_INFO_T fs_info;
BD_INFO_T bd_info;
struct exfat_mount_options options;
int use_vmalloc;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,00)
int s_dirt;
struct mutex s_lock;
#endif
struct nls_table *nls_disk; /* Codepage used on disk */
struct nls_table *nls_io; /* Charset used for input and display */
struct inode *fat_inode;
spinlock_t inode_hash_lock;
struct hlist_head inode_hashtable[EXFAT_HASH_SIZE];
#ifdef CONFIG_EXFAT_KERNEL_DEBUG
long debug_flags;
#endif /* CONFIG_EXFAT_KERNEL_DEBUG */
};
/*
* EXFAT file system inode data in memory
*/
struct exfat_inode_info {
FILE_ID_T fid;
char *target;
/* NOTE: mmu_private is 64bits, so must hold ->i_mutex to access */
loff_t mmu_private; /* physically allocated size */
loff_t i_pos; /* on-disk position of directory entry or 0 */
struct hlist_node i_hash_fat; /* hash by i_location */
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,00)
struct rw_semaphore truncate_lock;
#endif
struct inode vfs_inode;
};
#define EXFAT_SB(sb) ((struct exfat_sb_info *)((sb)->s_fs_info))
static inline struct exfat_inode_info *EXFAT_I(struct inode *inode)
{
return container_of(inode, struct exfat_inode_info, vfs_inode);
}
/*
* If ->i_mode can't hold S_IWUGO (i.e. ATTR_RO), we use ->i_attrs to
* save ATTR_RO instead of ->i_mode.
*
* If it's directory and !sbi->options.rodir, ATTR_RO isn't read-only
* bit, it's just used as flag for app.
*/
static inline int exfat_mode_can_hold_ro(struct inode *inode)
{
struct exfat_sb_info *sbi = EXFAT_SB(inode->i_sb);
if (S_ISDIR(inode->i_mode))
return 0;
if ((~sbi->options.fs_fmask) & S_IWUGO)
return 1;
return 0;
}
/* Convert attribute bits and a mask to the UNIX mode. */
static inline mode_t exfat_make_mode(struct exfat_sb_info *sbi,
u32 attr, mode_t mode)
{
if ((attr & ATTR_READONLY) && !(attr & ATTR_SUBDIR))
mode &= ~S_IWUGO;
if (attr & ATTR_SUBDIR)
return (mode & ~sbi->options.fs_dmask) | S_IFDIR;
else if (attr & ATTR_SYMLINK)
return (mode & ~sbi->options.fs_dmask) | S_IFLNK;
else
return (mode & ~sbi->options.fs_fmask) | S_IFREG;
}
/* Return the FAT attribute byte for this inode */
static inline u32 exfat_make_attr(struct inode *inode)
{
if (exfat_mode_can_hold_ro(inode) && !(inode->i_mode & S_IWUGO))
return ((EXFAT_I(inode)->fid.attr) | ATTR_READONLY);
else
return (EXFAT_I(inode)->fid.attr);
}
static inline void exfat_save_attr(struct inode *inode, u32 attr)
{
if (exfat_mode_can_hold_ro(inode))
EXFAT_I(inode)->fid.attr = attr & ATTR_RWMASK;
else
EXFAT_I(inode)->fid.attr = attr & (ATTR_RWMASK | ATTR_READONLY);
}
/* exfat_xattr.c */
#ifdef CONFIG_EXFAT_VIRTUAL_XATTR
void setup_exfat_xattr_handler(struct super_block *sb);
extern int exfat_setxattr(struct dentry *dentry, const char *name, const void *value, size_t size, int flags);
extern ssize_t exfat_getxattr(struct dentry *dentry, const char *name, void *value, size_t size);
extern ssize_t exfat_listxattr(struct dentry *dentry, char *list, size_t size);
extern int exfat_removexattr(struct dentry *dentry, const char *name);
#else
static inline void setup_exfat_xattr_handler(struct super_block *sb) {};
#endif
#endif

390
fs/exfat/exfat_upcase.c Normal file
View File

@@ -0,0 +1,390 @@
/*
* Copyright (C) 2012-2013 Samsung Electronics Co., Ltd.
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "exfat_config.h"
#include "exfat_global.h"
#include "exfat_nls.h"
u8 uni_upcase[NUM_UPCASE<<1] = {
0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x03, 0x00, 0x04, 0x00, 0x05, 0x00, 0x06, 0x00, 0x07, 0x00,
0x08, 0x00, 0x09, 0x00, 0x0A, 0x00, 0x0B, 0x00, 0x0C, 0x00, 0x0D, 0x00, 0x0E, 0x00, 0x0F, 0x00,
0x10, 0x00, 0x11, 0x00, 0x12, 0x00, 0x13, 0x00, 0x14, 0x00, 0x15, 0x00, 0x16, 0x00, 0x17, 0x00,
0x18, 0x00, 0x19, 0x00, 0x1A, 0x00, 0x1B, 0x00, 0x1C, 0x00, 0x1D, 0x00, 0x1E, 0x00, 0x1F, 0x00,
0x20, 0x00, 0x21, 0x00, 0x22, 0x00, 0x23, 0x00, 0x24, 0x00, 0x25, 0x00, 0x26, 0x00, 0x27, 0x00,
0x28, 0x00, 0x29, 0x00, 0x2A, 0x00, 0x2B, 0x00, 0x2C, 0x00, 0x2D, 0x00, 0x2E, 0x00, 0x2F, 0x00,
0x30, 0x00, 0x31, 0x00, 0x32, 0x00, 0x33, 0x00, 0x34, 0x00, 0x35, 0x00, 0x36, 0x00, 0x37, 0x00,
0x38, 0x00, 0x39, 0x00, 0x3A, 0x00, 0x3B, 0x00, 0x3C, 0x00, 0x3D, 0x00, 0x3E, 0x00, 0x3F, 0x00,
0x40, 0x00, 0x41, 0x00, 0x42, 0x00, 0x43, 0x00, 0x44, 0x00, 0x45, 0x00, 0x46, 0x00, 0x47, 0x00,
0x48, 0x00, 0x49, 0x00, 0x4A, 0x00, 0x4B, 0x00, 0x4C, 0x00, 0x4D, 0x00, 0x4E, 0x00, 0x4F, 0x00,
0x50, 0x00, 0x51, 0x00, 0x52, 0x00, 0x53, 0x00, 0x54, 0x00, 0x55, 0x00, 0x56, 0x00, 0x57, 0x00,
0x58, 0x00, 0x59, 0x00, 0x5A, 0x00, 0x5B, 0x00, 0x5C, 0x00, 0x5D, 0x00, 0x5E, 0x00, 0x5F, 0x00,
0x60, 0x00, 0x41, 0x00, 0x42, 0x00, 0x43, 0x00, 0x44, 0x00, 0x45, 0x00, 0x46, 0x00, 0x47, 0x00,
0x48, 0x00, 0x49, 0x00, 0x4A, 0x00, 0x4B, 0x00, 0x4C, 0x00, 0x4D, 0x00, 0x4E, 0x00, 0x4F, 0x00,
0x50, 0x00, 0x51, 0x00, 0x52, 0x00, 0x53, 0x00, 0x54, 0x00, 0x55, 0x00, 0x56, 0x00, 0x57, 0x00,
0x58, 0x00, 0x59, 0x00, 0x5A, 0x00, 0x7B, 0x00, 0x7C, 0x00, 0x7D, 0x00, 0x7E, 0x00, 0x7F, 0x00,
0x80, 0x00, 0x81, 0x00, 0x82, 0x00, 0x83, 0x00, 0x84, 0x00, 0x85, 0x00, 0x86, 0x00, 0x87, 0x00,
0x88, 0x00, 0x89, 0x00, 0x8A, 0x00, 0x8B, 0x00, 0x8C, 0x00, 0x8D, 0x00, 0x8E, 0x00, 0x8F, 0x00,
0x90, 0x00, 0x91, 0x00, 0x92, 0x00, 0x93, 0x00, 0x94, 0x00, 0x95, 0x00, 0x96, 0x00, 0x97, 0x00,
0x98, 0x00, 0x99, 0x00, 0x9A, 0x00, 0x9B, 0x00, 0x9C, 0x00, 0x9D, 0x00, 0x9E, 0x00, 0x9F, 0x00,
0xA0, 0x00, 0xA1, 0x00, 0xA2, 0x00, 0xA3, 0x00, 0xA4, 0x00, 0xA5, 0x00, 0xA6, 0x00, 0xA7, 0x00,
0xA8, 0x00, 0xA9, 0x00, 0xAA, 0x00, 0xAB, 0x00, 0xAC, 0x00, 0xAD, 0x00, 0xAE, 0x00, 0xAF, 0x00,
0xB0, 0x00, 0xB1, 0x00, 0xB2, 0x00, 0xB3, 0x00, 0xB4, 0x00, 0xB5, 0x00, 0xB6, 0x00, 0xB7, 0x00,
0xB8, 0x00, 0xB9, 0x00, 0xBA, 0x00, 0xBB, 0x00, 0xBC, 0x00, 0xBD, 0x00, 0xBE, 0x00, 0xBF, 0x00,
0xC0, 0x00, 0xC1, 0x00, 0xC2, 0x00, 0xC3, 0x00, 0xC4, 0x00, 0xC5, 0x00, 0xC6, 0x00, 0xC7, 0x00,
0xC8, 0x00, 0xC9, 0x00, 0xCA, 0x00, 0xCB, 0x00, 0xCC, 0x00, 0xCD, 0x00, 0xCE, 0x00, 0xCF, 0x00,
0xD0, 0x00, 0xD1, 0x00, 0xD2, 0x00, 0xD3, 0x00, 0xD4, 0x00, 0xD5, 0x00, 0xD6, 0x00, 0xD7, 0x00,
0xD8, 0x00, 0xD9, 0x00, 0xDA, 0x00, 0xDB, 0x00, 0xDC, 0x00, 0xDD, 0x00, 0xDE, 0x00, 0xDF, 0x00,
0xC0, 0x00, 0xC1, 0x00, 0xC2, 0x00, 0xC3, 0x00, 0xC4, 0x00, 0xC5, 0x00, 0xC6, 0x00, 0xC7, 0x00,
0xC8, 0x00, 0xC9, 0x00, 0xCA, 0x00, 0xCB, 0x00, 0xCC, 0x00, 0xCD, 0x00, 0xCE, 0x00, 0xCF, 0x00,
0xD0, 0x00, 0xD1, 0x00, 0xD2, 0x00, 0xD3, 0x00, 0xD4, 0x00, 0xD5, 0x00, 0xD6, 0x00, 0xF7, 0x00,
0xD8, 0x00, 0xD9, 0x00, 0xDA, 0x00, 0xDB, 0x00, 0xDC, 0x00, 0xDD, 0x00, 0xDE, 0x00, 0x78, 0x01,
0x00, 0x01, 0x00, 0x01, 0x02, 0x01, 0x02, 0x01, 0x04, 0x01, 0x04, 0x01, 0x06, 0x01, 0x06, 0x01,
0x08, 0x01, 0x08, 0x01, 0x0A, 0x01, 0x0A, 0x01, 0x0C, 0x01, 0x0C, 0x01, 0x0E, 0x01, 0x0E, 0x01,
0x10, 0x01, 0x10, 0x01, 0x12, 0x01, 0x12, 0x01, 0x14, 0x01, 0x14, 0x01, 0x16, 0x01, 0x16, 0x01,
0x18, 0x01, 0x18, 0x01, 0x1A, 0x01, 0x1A, 0x01, 0x1C, 0x01, 0x1C, 0x01, 0x1E, 0x01, 0x1E, 0x01,
0x20, 0x01, 0x20, 0x01, 0x22, 0x01, 0x22, 0x01, 0x24, 0x01, 0x24, 0x01, 0x26, 0x01, 0x26, 0x01,
0x28, 0x01, 0x28, 0x01, 0x2A, 0x01, 0x2A, 0x01, 0x2C, 0x01, 0x2C, 0x01, 0x2E, 0x01, 0x2E, 0x01,
0x30, 0x01, 0x31, 0x01, 0x32, 0x01, 0x32, 0x01, 0x34, 0x01, 0x34, 0x01, 0x36, 0x01, 0x36, 0x01,
0x38, 0x01, 0x39, 0x01, 0x39, 0x01, 0x3B, 0x01, 0x3B, 0x01, 0x3D, 0x01, 0x3D, 0x01, 0x3F, 0x01,
0x3F, 0x01, 0x41, 0x01, 0x41, 0x01, 0x43, 0x01, 0x43, 0x01, 0x45, 0x01, 0x45, 0x01, 0x47, 0x01,
0x47, 0x01, 0x49, 0x01, 0x4A, 0x01, 0x4A, 0x01, 0x4C, 0x01, 0x4C, 0x01, 0x4E, 0x01, 0x4E, 0x01,
0x50, 0x01, 0x50, 0x01, 0x52, 0x01, 0x52, 0x01, 0x54, 0x01, 0x54, 0x01, 0x56, 0x01, 0x56, 0x01,
0x58, 0x01, 0x58, 0x01, 0x5A, 0x01, 0x5A, 0x01, 0x5C, 0x01, 0x5C, 0x01, 0x5E, 0x01, 0x5E, 0x01,
0x60, 0x01, 0x60, 0x01, 0x62, 0x01, 0x62, 0x01, 0x64, 0x01, 0x64, 0x01, 0x66, 0x01, 0x66, 0x01,
0x68, 0x01, 0x68, 0x01, 0x6A, 0x01, 0x6A, 0x01, 0x6C, 0x01, 0x6C, 0x01, 0x6E, 0x01, 0x6E, 0x01,
0x70, 0x01, 0x70, 0x01, 0x72, 0x01, 0x72, 0x01, 0x74, 0x01, 0x74, 0x01, 0x76, 0x01, 0x76, 0x01,
0x78, 0x01, 0x79, 0x01, 0x79, 0x01, 0x7B, 0x01, 0x7B, 0x01, 0x7D, 0x01, 0x7D, 0x01, 0x7F, 0x01,
0x43, 0x02, 0x81, 0x01, 0x82, 0x01, 0x82, 0x01, 0x84, 0x01, 0x84, 0x01, 0x86, 0x01, 0x87, 0x01,
0x87, 0x01, 0x89, 0x01, 0x8A, 0x01, 0x8B, 0x01, 0x8B, 0x01, 0x8D, 0x01, 0x8E, 0x01, 0x8F, 0x01,
0x90, 0x01, 0x91, 0x01, 0x91, 0x01, 0x93, 0x01, 0x94, 0x01, 0xF6, 0x01, 0x96, 0x01, 0x97, 0x01,
0x98, 0x01, 0x98, 0x01, 0x3D, 0x02, 0x9B, 0x01, 0x9C, 0x01, 0x9D, 0x01, 0x20, 0x02, 0x9F, 0x01,
0xA0, 0x01, 0xA0, 0x01, 0xA2, 0x01, 0xA2, 0x01, 0xA4, 0x01, 0xA4, 0x01, 0xA6, 0x01, 0xA7, 0x01,
0xA7, 0x01, 0xA9, 0x01, 0xAA, 0x01, 0xAB, 0x01, 0xAC, 0x01, 0xAC, 0x01, 0xAE, 0x01, 0xAF, 0x01,
0xAF, 0x01, 0xB1, 0x01, 0xB2, 0x01, 0xB3, 0x01, 0xB3, 0x01, 0xB5, 0x01, 0xB5, 0x01, 0xB7, 0x01,
0xB8, 0x01, 0xB8, 0x01, 0xBA, 0x01, 0xBB, 0x01, 0xBC, 0x01, 0xBC, 0x01, 0xBE, 0x01, 0xF7, 0x01,
0xC0, 0x01, 0xC1, 0x01, 0xC2, 0x01, 0xC3, 0x01, 0xC4, 0x01, 0xC5, 0x01, 0xC4, 0x01, 0xC7, 0x01,
0xC8, 0x01, 0xC7, 0x01, 0xCA, 0x01, 0xCB, 0x01, 0xCA, 0x01, 0xCD, 0x01, 0xCD, 0x01, 0xCF, 0x01,
0xCF, 0x01, 0xD1, 0x01, 0xD1, 0x01, 0xD3, 0x01, 0xD3, 0x01, 0xD5, 0x01, 0xD5, 0x01, 0xD7, 0x01,
0xD7, 0x01, 0xD9, 0x01, 0xD9, 0x01, 0xDB, 0x01, 0xDB, 0x01, 0x8E, 0x01, 0xDE, 0x01, 0xDE, 0x01,
0xE0, 0x01, 0xE0, 0x01, 0xE2, 0x01, 0xE2, 0x01, 0xE4, 0x01, 0xE4, 0x01, 0xE6, 0x01, 0xE6, 0x01,
0xE8, 0x01, 0xE8, 0x01, 0xEA, 0x01, 0xEA, 0x01, 0xEC, 0x01, 0xEC, 0x01, 0xEE, 0x01, 0xEE, 0x01,
0xF0, 0x01, 0xF1, 0x01, 0xF2, 0x01, 0xF1, 0x01, 0xF4, 0x01, 0xF4, 0x01, 0xF6, 0x01, 0xF7, 0x01,
0xF8, 0x01, 0xF8, 0x01, 0xFA, 0x01, 0xFA, 0x01, 0xFC, 0x01, 0xFC, 0x01, 0xFE, 0x01, 0xFE, 0x01,
0x00, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x04, 0x02, 0x04, 0x02, 0x06, 0x02, 0x06, 0x02,
0x08, 0x02, 0x08, 0x02, 0x0A, 0x02, 0x0A, 0x02, 0x0C, 0x02, 0x0C, 0x02, 0x0E, 0x02, 0x0E, 0x02,
0x10, 0x02, 0x10, 0x02, 0x12, 0x02, 0x12, 0x02, 0x14, 0x02, 0x14, 0x02, 0x16, 0x02, 0x16, 0x02,
0x18, 0x02, 0x18, 0x02, 0x1A, 0x02, 0x1A, 0x02, 0x1C, 0x02, 0x1C, 0x02, 0x1E, 0x02, 0x1E, 0x02,
0x20, 0x02, 0x21, 0x02, 0x22, 0x02, 0x22, 0x02, 0x24, 0x02, 0x24, 0x02, 0x26, 0x02, 0x26, 0x02,
0x28, 0x02, 0x28, 0x02, 0x2A, 0x02, 0x2A, 0x02, 0x2C, 0x02, 0x2C, 0x02, 0x2E, 0x02, 0x2E, 0x02,
0x30, 0x02, 0x30, 0x02, 0x32, 0x02, 0x32, 0x02, 0x34, 0x02, 0x35, 0x02, 0x36, 0x02, 0x37, 0x02,
0x38, 0x02, 0x39, 0x02, 0x65, 0x2C, 0x3B, 0x02, 0x3B, 0x02, 0x3D, 0x02, 0x66, 0x2C, 0x3F, 0x02,
0x40, 0x02, 0x41, 0x02, 0x41, 0x02, 0x43, 0x02, 0x44, 0x02, 0x45, 0x02, 0x46, 0x02, 0x46, 0x02,
0x48, 0x02, 0x48, 0x02, 0x4A, 0x02, 0x4A, 0x02, 0x4C, 0x02, 0x4C, 0x02, 0x4E, 0x02, 0x4E, 0x02,
0x50, 0x02, 0x51, 0x02, 0x52, 0x02, 0x81, 0x01, 0x86, 0x01, 0x55, 0x02, 0x89, 0x01, 0x8A, 0x01,
0x58, 0x02, 0x8F, 0x01, 0x5A, 0x02, 0x90, 0x01, 0x5C, 0x02, 0x5D, 0x02, 0x5E, 0x02, 0x5F, 0x02,
0x93, 0x01, 0x61, 0x02, 0x62, 0x02, 0x94, 0x01, 0x64, 0x02, 0x65, 0x02, 0x66, 0x02, 0x67, 0x02,
0x97, 0x01, 0x96, 0x01, 0x6A, 0x02, 0x62, 0x2C, 0x6C, 0x02, 0x6D, 0x02, 0x6E, 0x02, 0x9C, 0x01,
0x70, 0x02, 0x71, 0x02, 0x9D, 0x01, 0x73, 0x02, 0x74, 0x02, 0x9F, 0x01, 0x76, 0x02, 0x77, 0x02,
0x78, 0x02, 0x79, 0x02, 0x7A, 0x02, 0x7B, 0x02, 0x7C, 0x02, 0x64, 0x2C, 0x7E, 0x02, 0x7F, 0x02,
0xA6, 0x01, 0x81, 0x02, 0x82, 0x02, 0xA9, 0x01, 0x84, 0x02, 0x85, 0x02, 0x86, 0x02, 0x87, 0x02,
0xAE, 0x01, 0x44, 0x02, 0xB1, 0x01, 0xB2, 0x01, 0x45, 0x02, 0x8D, 0x02, 0x8E, 0x02, 0x8F, 0x02,
0x90, 0x02, 0x91,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F, 0x02,
0xF0, 0x02, 0xF1, 0x02, 0xF2, 0x02, 0xF3, 0x02, 0xF4, 0x02, 0xF5, 0x02, 0xF6, 0x02, 0xF7, 0x02,
0xF8, 0x02, 0xF9, 0x02, 0xFA, 0x02, 0xFB, 0x02, 0xFC, 0x02, 0xFD, 0x02, 0xFE, 0x02, 0xFF, 0x02,
0x00, 0x03, 0x01, 0x03, 0x02, 0x03, 0x03, 0x03, 0x04, 0x03, 0x05, 0x03, 0x06, 0x03, 0x07, 0x03,
0x08, 0x03, 0x09, 0x03, 0x0A, 0x03, 0x0B, 0x03, 0x0C, 0x03, 0x0D, 0x03, 0x0E, 0x03, 0x0F, 0x03,
0x10, 0x03, 0x11, 0x03, 0x12, 0x03, 0x13, 0x03, 0x14, 0x03, 0x15, 0x03, 0x16, 0x03, 0x17, 0x03,
0x18, 0x03, 0x19, 0x03, 0x1A, 0x03, 0x1B, 0x03, 0x1C, 0x03, 0x1D, 0x03, 0x1E, 0x03, 0x1F, 0x03,
0x20, 0x03, 0x21, 0x03, 0x22, 0x03, 0x23, 0x03, 0x24, 0x03, 0x25, 0x03, 0x26, 0x03, 0x27, 0x03,
0x28, 0x03, 0x29, 0x03, 0x2A, 0x03, 0x2B, 0x03, 0x2C, 0x03, 0x2D, 0x03, 0x2E, 0x03, 0x2F, 0x03,
0x30, 0x03, 0x31, 0x03, 0x32, 0x03, 0x33, 0x03, 0x34, 0x03, 0x35, 0x03, 0x36, 0x03, 0x37, 0x03,
0x38, 0x03, 0x39, 0x03, 0x3A, 0x03, 0x3B, 0x03, 0x3C, 0x03, 0x3D, 0x03, 0x3E, 0x03, 0x3F, 0x03,
0x40, 0x03, 0x41, 0x03, 0x42, 0x03, 0x43, 0x03, 0x44, 0x03, 0x45, 0x03, 0x46, 0x03, 0x47, 0x03,
0x48, 0x03, 0x49, 0x03, 0x4A, 0x03, 0x4B, 0x03, 0x4C, 0x03, 0x4D, 0x03, 0x4E, 0x03, 0x4F, 0x03,
0x50, 0x03, 0x51, 0x03, 0x52, 0x03, 0x53, 0x03, 0x54, 0x03, 0x55, 0x03, 0x56, 0x03, 0x57, 0x03,
0x58, 0x03, 0x59, 0x03, 0x5A, 0x03, 0x5B, 0x03, 0x5C, 0x03, 0x5D, 0x03, 0x5E, 0x03, 0x5F, 0x03,
0x60, 0x03, 0x61, 0x03, 0x62, 0x03, 0x63, 0x03, 0x64, 0x03, 0x65, 0x03, 0x66, 0x03, 0x67, 0x03,
0x68, 0x03, 0x69, 0x03, 0x6A, 0x03, 0x6B, 0x03, 0x6C, 0x03, 0x6D, 0x03, 0x6E, 0x03, 0x6F, 0x03,
0x70, 0x03, 0x71, 0x03, 0x72, 0x03, 0x73, 0x03, 0x74, 0x03, 0x75, 0x03, 0x76, 0x03, 0x77, 0x03,
0x78, 0x03, 0x79, 0x03, 0x7A, 0x03, 0xFD, 0x03, 0xFE, 0x03, 0xFF, 0x03, 0x7E, 0x03, 0x7F, 0x03,
0x80, 0x03, 0x81, 0x03, 0x82, 0x03, 0x83, 0x03, 0x84, 0x03, 0x85, 0x03, 0x86, 0x03, 0x87, 0x03,
0x88, 0x03, 0x89, 0x03, 0x8A, 0x03, 0x8B, 0x03, 0x8C, 0x03, 0x8D, 0x03, 0x8E, 0x03, 0x8F, 0x03,
0x90, 0x03, 0x91, 0x03, 0x92, 0x03, 0x93, 0x03, 0x94, 0x03, 0x95, 0x03, 0x96, 0x03, 0x97, 0x03,
0x98, 0x03, 0x99, 0x03, 0x9A, 0x03, 0x9B, 0x03, 0x9C, 0x03, 0x9D, 0x03, 0x9E, 0x03, 0x9F, 0x03,
0xA0, 0x03, 0xA1, 0x03, 0xA2, 0x03, 0xA3, 0x03, 0xA4, 0x03, 0xA5, 0x03, 0xA6, 0x03, 0xA7, 0x03,
0xA8, 0x03, 0xA9, 0x03, 0xAA, 0x03, 0xAB, 0x03, 0x86, 0x03, 0x88, 0x03, 0x89, 0x03, 0x8A, 0x03,
0xB0, 0x03, 0x91, 0x03, 0x92, 0x03, 0x93, 0x03, 0x94, 0x03, 0x95, 0x03, 0x96, 0x03, 0x97, 0x03,
0x98, 0x03, 0x99, 0x03, 0x9A, 0x03, 0x9B, 0x03, 0x9C, 0x03, 0x9D, 0x03, 0x9E, 0x03, 0x9F, 0x03,
0xA0, 0x03, 0xA1, 0x03, 0xA3, 0x03, 0xA3, 0x03, 0xA4, 0x03, 0xA5, 0x03, 0xA6, 0x03, 0xA7, 0x03,
0xA8, 0x03, 0xA9, 0x03, 0xAA, 0x03, 0xAB, 0x03, 0x8C, 0x03, 0x8E, 0x03, 0x8F, 0x03, 0xCF, 0x03,
0xD0, 0x03, 0xD1, 0x03, 0xD2, 0x03, 0xD3, 0x03, 0xD4, 0x03, 0xD5, 0x03, 0xD6, 0x03, 0xD7, 0x03,
0xD8, 0x03, 0xD8, 0x03, 0xDA, 0x03, 0xDA, 0x03, 0xDC, 0x03, 0xDC, 0x03, 0xDE, 0x03, 0xDE, 0x03,
0xE0, 0x03, 0xE0, 0x03, 0xE2, 0x03, 0xE2, 0x03, 0xE4, 0x03, 0xE4, 0x03, 0xE6, 0x03, 0xE6, 0x03,
0xE8, 0x03, 0xE8, 0x03, 0xEA, 0x03, 0xEA, 0x03, 0xEC, 0x03, 0xEC, 0x03, 0xEE, 0x03, 0xEE, 0x03,
0xF0, 0x03, 0xF1, 0x03, 0xF9, 0x03, 0xF3, 0x03, 0xF4, 0x03, 0xF5, 0x03, 0xF6, 0x03, 0xF7, 0x03,
0xF7, 0x03, 0xF9, 0x03, 0xFA, 0x03, 0xFA, 0x03, 0xFC, 0x03, 0xFD, 0x03, 0xFE, 0x03, 0xFF, 0x03,
0x00, 0x04, 0x01, 0x04, 0x02, 0x04, 0x03, 0x04, 0x04, 0x04, 0x05, 0x04, 0x06, 0x04, 0x07, 0x04,
0x08, 0x04, 0x09, 0x04, 0x0A, 0x04, 0x0B, 0x04, 0x0C, 0x04, 0x0D, 0x04, 0x0E, 0x04, 0x0F, 0x04,
0x10, 0x04, 0x11, 0x04, 0x12, 0x04, 0x13, 0x04, 0x14, 0x04, 0x15, 0x04, 0x16, 0x04, 0x17, 0x04,
0x18, 0x04, 0x19, 0x04, 0x1A, 0x04, 0x1B, 0x04, 0x1C, 0x04, 0x1D, 0x04, 0x1E, 0x04, 0x1F, 0x04,
0x20, 0x04, 0x21, 0x04, 0x22, 0x04, 0x23, 0x04, 0x24, 0x04, 0x25, 0x04, 0x26, 0x04, 0x27, 0x04,
0x28, 0x04, 0x29, 0x04, 0x2A, 0x04, 0x2B, 0x04, 0x2C, 0x04, 0x2D, 0x04, 0x2E, 0x04, 0x2F, 0x04,
0x10, 0x04, 0x11, 0x04, 0x12, 0x04, 0x13, 0x04, 0x14, 0x04, 0x15, 0x04, 0x16, 0x04, 0x17, 0x04,
0x18, 0x04, 0x19, 0x04, 0x1A, 0x04, 0x1B, 0x04, 0x1C, 0x04, 0x1D, 0x04, 0x1E, 0x04, 0x1F, 0x04,
0x20, 0x04, 0x21, 0x04, 0x22, 0x04, 0x23, 0x04, 0x24, 0x04, 0x25, 0x04, 0x26, 0x04, 0x27, 0x04,
0x28, 0x04, 0x29, 0x04, 0x2A, 0x04, 0x2B, 0x04, 0x2C, 0x04, 0x2D, 0x04, 0x2E, 0x04, 0x2F, 0x04,
0x00, 0x04, 0x01, 0x04, 0x02, 0x04, 0x03, 0x04, 0x04, 0x04, 0x05, 0x04, 0x06, 0x04, 0x07, 0x04,
0x08, 0x04, 0x09, 0x04, 0x0A, 0x04, 0x0B, 0x04, 0x0C, 0x04, 0x0D, 0x04, 0x0E, 0x04, 0x0F, 0x04,
0x60, 0x04, 0x60, 0x04, 0x62, 0x04, 0x62, 0x04, 0x64, 0x04, 0x64, 0x04, 0x66, 0x04, 0x66, 0x04,
0x68, 0x04, 0x68, 0x04, 0x6A, 0x04, 0x6A, 0x04, 0x6C, 0x04, 0x6C, 0x04, 0x6E, 0x04, 0x6E, 0x04,
0x70, 0x04, 0x70, 0x04, 0x72, 0x04, 0x72, 0x04, 0x74, 0x04, 0x74, 0x04, 0x76, 0x04, 0x76, 0x04,
0x78, 0x04, 0x78, 0x04, 0x7A, 0x04, 0x7A, 0x04, 0x7C, 0x04, 0x7C, 0x04, 0x7E, 0x04, 0x7E, 0x04,
0x80, 0x04, 0x80, 0x04, 0x82, 0x04, 0x83, 0x04, 0x84, 0x04, 0x85, 0x04, 0x86, 0x04, 0x87, 0x04,
0x88, 0x04, 0x89, 0x04, 0x8A, 0x04, 0x8A, 0x04, 0x8C, 0x04, 0x8C, 0x04, 0x8E, 0x04, 0x8E, 0x04,
0x90, 0x04, 0x90, 0x04, 0x92, 0x04, 0x92, 0x04, 0x94, 0x04, 0x94, 0x04, 0x96, 0x04, 0x96, 0x04,
0x98, 0x04, 0x98, 0x04, 0x9A, 0x04, 0x9A, 0x04, 0x9C, 0x04, 0x9C, 0x04, 0x9E, 0x04, 0x9E, 0x04,
0xA0, 0x04, 0xA0, 0x04, 0xA2, 0x04, 0xA2, 0x04, 0xA4, 0x04, 0xA4, 0x04, 0xA6, 0x04, 0xA6, 0x04,
0xA8, 0x04, 0xA8, 0x04, 0xAA, 0x04, 0xAA, 0x04, 0xAC, 0x04, 0xAC, 0x04, 0xAE, 0x04, 0xAE, 0x04,
0xB0, 0x04, 0xB0, 0x04, 0xB2, 0x04, 0xB2, 0x04, 0xB4, 0x04, 0xB4, 0x04, 0xB6, 0x04, 0xB6, 0x04,
0xB8, 0x04, 0xB8, 0x04, 0xBA, 0x04, 0xBA, 0x04, 0xBC, 0x04, 0xBC, 0x04, 0xBE, 0x04, 0xBE, 0x04,
0xC0, 0x04, 0xC1, 0x04, 0xC1, 0x04, 0xC3, 0x04, 0xC3, 0x04, 0xC5, 0x04, 0xC5, 0x04, 0xC7, 0x04,
0xC7, 0x04, 0xC9, 0x04, 0xC9, 0x04, 0xCB, 0x04, 0xCB, 0x04, 0xCD, 0x04, 0xCD, 0x04, 0xC0, 0x04,
0xD0, 0x04, 0xD0, 0x04, 0xD2, 0x04, 0xD2, 0x04, 0xD4, 0x04, 0xD4, 0x04, 0xD6, 0x04, 0xD6, 0x04,
0xD8, 0x04, 0xD8, 0x04, 0xDA, 0x04, 0xDA, 0x04, 0xDC, 0x04, 0xDC, 0x04, 0xDE, 0x04, 0xDE, 0x04,
0xE0, 0x04, 0xE0, 0x04, 0xE2, 0x04, 0xE2, 0x04, 0xE4, 0x04, 0xE4, 0x04, 0xE6, 0x04, 0xE6, 0x04,
0xE8, 0x04, 0xE8, 0x04, 0xEA, 0x04, 0xEA, 0x04, 0xEC, 0x04, 0xEC, 0x04, 0xEE, 0x04, 0xEE, 0x04,
0xF0, 0x04, 0xF0, 0x04, 0xF2, 0x04, 0xF2, 0x04, 0xF4, 0x04, 0xF4, 0x04, 0xF6, 0x04, 0xF6, 0x04,
0xF8, 0x04, 0xF8, 0x04, 0xFA, 0x04, 0xFA, 0x04, 0xFC, 0x04, 0xFC, 0x04, 0xFE, 0x04, 0xFE, 0x04,
0x00, 0x05, 0x00, 0x05, 0x02, 0x05, 0x02, 0x05, 0x04, 0x05, 0x04, 0x05, 0x06, 0x05, 0x06, 0x05,
0x08, 0x05, 0x08, 0x05, 0x0A, 0x05, 0x0A, 0x05, 0x0C, 0x05, 0x0C, 0x05, 0x0E, 0x05, 0x0E, 0x05,
0x10, 0x05, 0x10, 0x05, 0x12, 0x05, 0x12, 0x05, 0x14, 0x05, 0x15, 0x05, 0x16, 0x05, 0x17, 0x05,
0x18, 0x05, 0x19, 0x05, 0x1A, 0x05, 0x1B, 0x05, 0x1C, 0x05, 0x1D, 0x05, 0x1E, 0x05, 0x1F, 0x05,
0x20, 0x05, 0x21, 0x05, 0x22, 0x05, 0x23, 0x05, 0x24, 0x05, 0x25, 0x05, 0x26, 0x05, 0x27, 0x05,
0x28, 0x05, 0x29, 0x05, 0x2A, 0x05, 0x2B, 0x05, 0x2C, 0x05, 0x2D, 0x05, 0x2E, 0x05, 0x2F, 0x05,
0x30, 0x05, 0x31, 0x05, 0x32, 0x05, 0x33, 0x05, 0x34, 0x05, 0x35, 0x05, 0x36, 0x05, 0x37, 0x05,
0x38, 0x05, 0x39, 0x05, 0x3A, 0x05, 0x3B, 0x05, 0x3C, 0x05, 0x3D, 0x05, 0x3E, 0x05, 0x3F, 0x05,
0x40, 0x05, 0x41, 0x05, 0x42, 0x05, 0x43, 0x05, 0x44, 0x05, 0x45, 0x05, 0x46, 0x05, 0x47, 0x05,
0x48, 0x05, 0x49, 0x05, 0x4A, 0x05, 0x4B, 0x05, 0x4C, 0x05, 0x4D, 0x05, 0x4E, 0x05, 0x4F, 0x05,
0x50, 0x05, 0x51, 0x05, 0x52, 0x05, 0x53, 0x05, 0x54, 0x05, 0x55, 0x05, 0x56, 0x05, 0x57, 0x05,
0x58, 0x05, 0x59, 0x05, 0x5A, 0x05, 0x5B, 0x05, 0x5C, 0x05, 0x5D, 0x05, 0x5E, 0x05, 0x5F, 0x05,
0x60, 0x05, 0x31, 0x05, 0x32, 0x05, 0x33, 0x05, 0x34, 0x05, 0x35, 0x05, 0x36, 0x05, 0x37, 0x05,
0x38, 0x05, 0x39, 0x05, 0x3A, 0x05, 0x3B, 0x05, 0x3C, 0x05, 0x3D, 0x05, 0x3E, 0x05, 0x3F, 0x05,
0x40, 0x05, 0x41, 0x05, 0x42, 0x05, 0x43, 0x05, 0x44, 0x05, 0x45, 0x05, 0x46, 0x05, 0x47, 0x05,
0x48, 0x05, 0x49, 0x05, 0x4A, 0x05, 0x4B, 0x05, 0x4C, 0x05, 0x4D, 0x05, 0x4E, 0x05, 0x4F, 0x05,
0x50, 0x05, 0x51, 0x05, 0x52, 0x05, 0x53, 0x05, 0x54, 0x05, 0x55, 0x05, 0x56, 0x05, 0xFF, 0xFF,
0xF6, 0x17, 0x63, 0x2C, 0x7E, 0x1D, 0x7F, 0x1D, 0x80, 0x1D, 0x81, 0x1D, 0x82, 0x1D, 0x83, 0x1D,
0x84, 0x1D, 0x85, 0x1D, 0x86, 0x1D, 0x87, 0x1D, 0x88, 0x1D, 0x89, 0x1D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0xEC, 0x1F, 0xED, 0x1F, 0xEE, 0x1F, 0xEF, 0x1F, 0xF0, 0x1F, 0xF1, 0x1F, 0xF2, 0x1F, 0xF3, 0x1F,
0xF4, 0x1F, 0xF5, 0x1F, 0xF6, 0x1F, 0xF7, 0x1F, 0xF8, 0x1F, 0xF9, 0x1F, 0xFA, 0x1F, 0xFB, 0x1F,
0xF3, 0x1F, 0xFD, 0x1F, 0xFE, 0x1F, 0xFF, 0x1F, 0x00, 0x20, 0x01, 0x20, 0x02, 0x20, 0x03, 0x20,
0x04, 0x20, 0x05, 0x20, 0x06, 0x20, 0x07, 0x20, 0x08, 0x20, 0x09, 0x20, 0x0A, 0x20, 0x0B, 0x20,
0x0C, 0x20, 0x0D, 0x20, 0x0E, 0x20, 0x0F, 0x20, 0x10, 0x20, 0x11, 0x20, 0x12, 0x20, 0x13, 0x20,
0x14, 0x20, 0x15, 0x20, 0x16, 0x20, 0x17, 0x20, 0x18, 0x20, 0x19, 0x20, 0x1A, 0x20, 0x1B, 0x20,
0x1C, 0x20, 0x1D, 0x20, 0x1E, 0x20, 0x1F, 0x20, 0x20, 0x20, 0x21, 0x20, 0x22, 0x20, 0x23, 0x20,
0x24, 0x20, 0x25, 0x20, 0x26, 0x20, 0x27, 0x20, 0x28, 0x20, 0x29, 0x20, 0x2A, 0x20, 0x2B, 0x20,
0x2C, 0x20, 0x2D, 0x20, 0x2E, 0x20, 0x2F, 0x20, 0x30, 0x20, 0x31, 0x20, 0x32, 0x20, 0x33, 0x20,
0x34, 0x20, 0x35, 0x20, 0x36, 0x20, 0x37, 0x20, 0x38, 0x20, 0x39, 0x20, 0x3A, 0x20, 0x3B, 0x20,
0x3C, 0x20, 0x3D, 0x20, 0x3E, 0x20, 0x3F, 0x20, 0x40, 0x20, 0x41, 0x20, 0x42, 0x20, 0x43, 0x20,
0x44, 0x20, 0x45, 0x20, 0x46, 0x20, 0x47, 0x20, 0x48, 0x20, 0x49, 0x20, 0x4A, 0x20, 0x4B, 0x20,
0x4C, 0x20, 0x4D, 0x20, 0x4E, 0x20, 0x4F, 0x20, 0x50, 0x20, 0x51, 0x20, 0x52, 0x20, 0x53, 0x20,
0x54, 0x20, 0x55, 0x20, 0x56, 0x20, 0x57, 0x20, 0x58, 0x20, 0x59, 0x20, 0x5A, 0x20, 0x5B, 0x20,
0x5C, 0x20, 0x5D, 0x20, 0x5E, 0x20, 0x5F, 0x20, 0x60, 0x20, 0x61, 0x20, 0x62, 0x20, 0x63, 0x20,
0x64, 0x20, 0x65, 0x20, 0x66, 0x20, 0x67, 0x20, 0x68, 0x20, 0x69, 0x20, 0x6A, 0x20, 0x6B, 0x20,
0x6C, 0x20, 0x6D, 0x20, 0x6E, 0x20, 0x6F, 0x20, 0x70, 0x20, 0x71, 0x20, 0x72, 0x20, 0x73, 0x20,
0x74, 0x20, 0x75, 0x20, 0x76, 0x20, 0x77, 0x20, 0x78, 0x20, 0x79, 0x20, 0x7A, 0x20, 0x7B, 0x20,
0x7C, 0x20, 0x7D, 0x20, 0x7E, 0x20, 0x7F, 0x20, 0x80, 0x20, 0x81, 0x20, 0x82, 0x20, 0x83, 0x20,
0x84, 0x20, 0x85, 0x20, 0x86, 0x20, 0x87, 0x20, 0x88, 0x20, 0x89, 0x20, 0x8A, 0x20, 0x8B, 0x20,
0x8C, 0x20, 0x8D, 0x20, 0x8E, 0x20, 0x8F, 0x20, 0x90, 0x20, 0x91, 0x20, 0x92, 0x20, 0x93, 0x20,
0x94, 0x20, 0x95, 0x20, 0x96, 0x20, 0x97, 0x20, 0x98, 0x20, 0x99, 0x20, 0x9A, 0x20, 0x9B, 0x20,
0x9C, 0x20, 0x9D, 0x20, 0x9E, 0x20, 0x9F, 0x20, 0xA0, 0x20, 0xA1, 0x20, 0xA2, 0x20, 0xA3, 0x20,
0xA4, 0x20, 0xA5, 0x20, 0xA6, 0x20, 0xA7, 0x20, 0xA8, 0x20, 0xA9, 0x20, 0xAA, 0x20, 0xAB, 0x20,
0xAC, 0x20, 0xAD, 0x20, 0xAE, 0x20, 0xAF, 0x20, 0xB0, 0x20, 0xB1, 0x20, 0xB2, 0x20, 0xB3, 0x20,
0xB4, 0x20, 0xB5, 0x20, 0xB6, 0x20, 0xB7, 0x20, 0xB8, 0x20, 0xB9, 0x20, 0xBA, 0x20, 0xBB, 0x20,
0xBC, 0x20, 0xBD, 0x20, 0xBE, 0x20, 0xBF, 0x20, 0xC0, 0x20, 0xC1, 0x20, 0xC2, 0x20, 0xC3, 0x20,
0xC4, 0x20, 0xC5, 0x20, 0xC6, 0x20, 0xC7, 0x20, 0xC8, 0x20, 0xC9, 0x20, 0xCA, 0x20, 0xCB, 0x20,
0xCC, 0x20, 0xCD, 0x20, 0xCE, 0x20, 0xCF, 0x20, 0xD0, 0x20, 0xD1, 0x20, 0xD2, 0x20, 0xD3, 0x20,
0xD4, 0x20, 0xD5, 0x20, 0xD6, 0x20, 0xD7, 0x20, 0xD8, 0x20, 0xD9, 0x20, 0xDA, 0x20, 0xDB, 0x20,
0xDC, 0x20, 0xDD, 0x20, 0xDE, 0x20, 0xDF, 0x20, 0xE0, 0x20, 0xE1, 0x20, 0xE2, 0x20, 0xE3, 0x20,
0xE4, 0x20, 0xE5, 0x20, 0xE6, 0x20, 0xE7, 0x20, 0xE8, 0x20, 0xE9, 0x20, 0xEA, 0x20, 0xEB, 0x20,
0xEC, 0x20, 0xED, 0x20, 0xEE, 0x20, 0xEF, 0x20, 0xF0, 0x20, 0xF1, 0x20, 0xF2, 0x20, 0xF3, 0x20,
0xF4, 0x20, 0xF5, 0x20, 0xF6, 0x20, 0xF7, 0x20, 0xF8, 0x20, 0xF9, 0x20, 0xFA, 0x20, 0xFB, 0x20,
0xFC, 0x20, 0xFD, 0x20, 0xFE, 0x20, 0xFF, 0x20, 0x00, 0x21, 0x01, 0x21, 0x02, 0x21, 0x03, 0x21,
0x04, 0x21, 0x05, 0x21, 0x06, 0x21, 0x07, 0x21, 0x08, 0x21, 0x09, 0x21, 0x0A, 0x21, 0x0B, 0x21,
0x0C, 0x21, 0x0D, 0x21, 0x0E, 0x21, 0x0F, 0x21, 0x10, 0x21, 0x11, 0x21, 0x12, 0x21, 0x13, 0x21,
0x14, 0x21, 0x15, 0x21, 0x16, 0x21, 0x17, 0x21, 0x18, 0x21, 0x19, 0x21, 0x1A, 0x21, 0x1B, 0x21,
0x1C, 0x21, 0x1D, 0x21, 0x1E, 0x21, 0x1F, 0x21, 0x20, 0x21, 0x21, 0x21, 0x22, 0x21, 0x23, 0x21,
0x24, 0x21, 0x25, 0x21, 0x26, 0x21, 0x27, 0x21, 0x28, 0x21, 0x29, 0x21, 0x2A, 0x21, 0x2B, 0x21,
0x2C, 0x21, 0x2D, 0x21, 0x2E, 0x21, 0x2F, 0x21, 0x30, 0x21, 0x31, 0x21, 0x32, 0x21, 0x33, 0x21,
0x34, 0x21, 0x35, 0x21, 0x36, 0x21, 0x37, 0x21, 0x38, 0x21, 0x39, 0x21, 0x3A, 0x21, 0x3B, 0x21,
0x3C, 0x21, 0x3D, 0x21, 0x3E, 0x21, 0x3F, 0x21, 0x40, 0x21, 0x41, 0x21, 0x42, 0x21, 0x43, 0x21,
0x44, 0x21, 0x45, 0x21, 0x46, 0x21, 0x47, 0x21, 0x48, 0x21, 0x49, 0x21, 0x4A, 0x21, 0x4B, 0x21,
0x4C, 0x21, 0x4D, 0x21, 0x32, 0x21, 0x4F, 0x21, 0x50, 0x21, 0x51, 0x21, 0x52, 0x21, 0x53, 0x21,
0x54, 0x21, 0x55, 0x21, 0x56, 0x21, 0x57, 0x21, 0x58, 0x21, 0x59, 0x21, 0x5A, 0x21, 0x5B, 0x21,
0x5C, 0x21, 0x5D, 0x21, 0x5E, 0x21, 0x5F, 0x21, 0x60, 0x21, 0x61, 0x21, 0x62, 0x21, 0x63, 0x21,
0x64, 0x21, 0x65, 0x21, 0x66, 0x21, 0x67, 0x21, 0x68, 0x21, 0x69, 0x21, 0x6A, 0x21, 0x6B, 0x21,
0x6C, 0x21, 0x6D, 0x21, 0x6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xFF, 0xD3, 0xFF, 0xD4, 0xFF, 0xD5, 0xFF, 0xD6, 0xFF, 0xD7, 0xFF, 0xD8, 0xFF, 0xD9, 0xFF,
0xDA, 0xFF, 0xDB, 0xFF, 0xDC, 0xFF, 0xDD, 0xFF, 0xDE, 0xFF, 0xDF, 0xFF, 0xE0, 0xFF, 0xE1, 0xFF,
0xE2, 0xFF, 0xE3, 0xFF, 0xE4, 0xFF, 0xE5, 0xFF, 0xE6, 0xFF, 0xE7, 0xFF, 0xE8, 0xFF, 0xE9, 0xFF,
0xEA, 0xFF, 0xEB, 0xFF, 0xEC, 0xFF, 0xED, 0xFF, 0xEE, 0xFF, 0xEF, 0xFF, 0xF0, 0xFF, 0xF1, 0xFF,
0xF2, 0xFF, 0xF3, 0xFF, 0xF4, 0xFF, 0xF5, 0xFF, 0xF6, 0xFF, 0xF7, 0xFF, 0xF8, 0xFF, 0xF9, 0xFF,
0xFA, 0xFF, 0xFB, 0xFF, 0xFC, 0xFF, 0xFD, 0xFF, 0xFE, 0xFF, 0xFF, 0xFF
};

1
fs/exfat/exfat_version.h Normal file
View File

@@ -0,0 +1 @@
#define EXFAT_VERSION "1.2.24-dragon"

105
fs/exfat/exfat_xattr.c Normal file
View File

@@ -0,0 +1,105 @@
#include <linux/file.h>
#include <linux/fs.h>
#include <linux/xattr.h>
#include <linux/dcache.h>
#include "exfat.h"
#ifndef CONFIG_EXFAT_VIRTUAL_XATTR_SELINUX_LABEL
#define CONFIG_EXFAT_VIRTUAL_XATTR_SELINUX_LABEL ("undefined")
#endif
static const char default_xattr[] = CONFIG_EXFAT_VIRTUAL_XATTR_SELINUX_LABEL;
static int can_support(const char *name)
{
if (!name || strcmp(name, "security.selinux"))
return -1;
return 0;
}
ssize_t exfat_listxattr(struct dentry *dentry, char *list, size_t size)
{
return 0;
}
EXPORT_SYMBOL(exfat_listxattr);
/*************************************************************************
* INNER FUNCTIONS WHICH HAS KERNEL VERSION DEPENDENCY
*************************************************************************/
static int __exfat_xattr_check_support(const char *name)
{
if (can_support(name))
return -EOPNOTSUPP;
return 0;
}
ssize_t __exfat_getxattr(const char *name, void *value, size_t size)
{
if (can_support(name))
return -EOPNOTSUPP;
if ((size > strlen(default_xattr)+1) && value)
strcpy(value, default_xattr);
return strlen(default_xattr);
}
/*************************************************************************
* FUNCTIONS WHICH HAS KERNEL VERSION DEPENDENCY
*************************************************************************/
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 9, 0)
static int exfat_xattr_get(const struct xattr_handler *handler,
struct dentry *dentry, struct inode *inode,
const char *name, void *buffer, size_t size)
{
return __exfat_getxattr(name, buffer, size);
}
static int exfat_xattr_set(const struct xattr_handler *handler,
struct dentry *dentry, struct inode *inode,
const char *name, const void *value, size_t size,
int flags)
{
return __exfat_xattr_check_support(name);
}
const struct xattr_handler exfat_xattr_handler = {
.prefix = "", /* match anything */
.get = exfat_xattr_get,
.set = exfat_xattr_set,
};
const struct xattr_handler *exfat_xattr_handlers[] = {
&exfat_xattr_handler,
NULL
};
void setup_exfat_xattr_handler(struct super_block *sb)
{
sb->s_xattr = exfat_xattr_handlers;
}
EXPORT_SYMBOL(setup_exfat_xattr_handler);
#else /* LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 0) */
int exfat_setxattr(struct dentry *dentry, const char *name, const void *value, size_t size, int flags)
{
return __exfat_xattr_check_support(name);
}
ssize_t exfat_getxattr(struct dentry *dentry, const char *name, void *value, size_t size)
{
return __exfat_getxattr(name, value, size);
}
int exfat_removexattr(struct dentry *dentry, const char *name)
{
return __exfat_xattr_check_support(name);
}
void setup_exfat_xattr_handler(struct super_block *sb)
{
/* DO NOTHING */
}
EXPORT_SYMBOL(setup_exfat_xattr_handler);
#endif