mirror of
https://github.com/CTCaer/CTCaer-TWRP.git
synced 2024-11-23 02:10:00 +00:00
Add libtar to TWRP instead of using busybox tar
Add proper mkdosfs tool Add fuse to TWRP Add experimental exfat-fuse to TWRP Convert all system() functions to use new Exec_Cmd function
This commit is contained in:
parent
6ff55cefd0
commit
9c754053b0
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
.*.swp
|
19
Android.mk
19
Android.mk
@ -26,11 +26,11 @@ LOCAL_SRC_FILES := \
|
||||
screen_ui.cpp \
|
||||
verifier.cpp \
|
||||
fixPermissions.cpp \
|
||||
twrpTar.cpp \
|
||||
adb_install.cpp
|
||||
|
||||
LOCAL_SRC_FILES += \
|
||||
data.cpp \
|
||||
makelist.cpp \
|
||||
partition.cpp \
|
||||
partitionmanager.cpp \
|
||||
mtdutils/mtdutils.c \
|
||||
@ -65,7 +65,7 @@ LOCAL_SHARED_LIBRARIES :=
|
||||
LOCAL_STATIC_LIBRARIES += libmtdutils
|
||||
LOCAL_STATIC_LIBRARIES += libminadbd libminzip libunz
|
||||
LOCAL_STATIC_LIBRARIES += libminuitwrp libpixelflinger_static libpng libjpegtwrp libgui
|
||||
LOCAL_SHARED_LIBRARIES += libz libc libstlport libcutils libstdc++ libmincrypt libext4_utils
|
||||
LOCAL_SHARED_LIBRARIES += libz libc libstlport libcutils libstdc++ libmincrypt libext4_utils libtar
|
||||
|
||||
ifeq ($(TARGET_USERIMAGES_USE_EXT4), true)
|
||||
LOCAL_CFLAGS += -DUSE_EXT4
|
||||
@ -76,7 +76,7 @@ endif
|
||||
ifeq ($(HAVE_SELINUX), true)
|
||||
LOCAL_C_INCLUDES += external/libselinux/include
|
||||
LOCAL_STATIC_LIBRARIES += libselinux
|
||||
LOCAL_CFLAGS += -DHAVE_SELINUX
|
||||
LOCAL_CFLAGS += -DHAVE_SELINUX -g
|
||||
endif # HAVE_SELINUX
|
||||
|
||||
# This binary is in the recovery ramdisk, which is otherwise a copy of root.
|
||||
@ -269,14 +269,16 @@ include $(commands_recovery_local_path)/libjpegtwrp/Android.mk \
|
||||
$(commands_recovery_local_path)/gui/Android.mk \
|
||||
$(commands_recovery_local_path)/mmcutils/Android.mk \
|
||||
$(commands_recovery_local_path)/bmlutils/Android.mk \
|
||||
$(commands_recovery_local_path)/flashutils/Android.mk \
|
||||
$(commands_recovery_local_path)/prebuilt/Android.mk \
|
||||
$(commands_recovery_local_path)/mtdutils/Android.mk \
|
||||
$(commands_recovery_local_path)/flashutils/Android.mk \
|
||||
$(commands_recovery_local_path)/pigz/Android.mk \
|
||||
$(commands_recovery_local_path)/dosfstools/Android.mk \
|
||||
$(commands_recovery_local_path)/libtar/Android.mk \
|
||||
$(commands_recovery_local_path)/crypto/cryptsettings/Android.mk \
|
||||
$(commands_recovery_local_path)/crypto/cryptfs/Android.mk \
|
||||
$(commands_recovery_local_path)/libcrecovery/Android.mk \
|
||||
$(commands_recovery_local_path)/twmincrypt/Android.mk
|
||||
$(commands_recovery_local_path)/twmincrypt/Android.mk \
|
||||
|
||||
ifeq ($(TW_INCLUDE_CRYPTO_SAMSUNG), true)
|
||||
include $(commands_recovery_local_path)/crypto/libcrypt_samsung/Android.mk
|
||||
@ -286,4 +288,11 @@ ifeq ($(TW_INCLUDE_JB_CRYPTO), true)
|
||||
include $(commands_recovery_local_path)/crypto/fs_mgr/Android.mk
|
||||
endif
|
||||
|
||||
ifeq ($(TW_INCLUDE_EXFAT), true)
|
||||
include $(commands_recovery_local_path)/fuse/Android.mk
|
||||
include $(commands_recovery_local_path)/exfat/libexfat/Android.mk
|
||||
include $(commands_recovery_local_path)/exfat/exfat-fuse/Android.mk
|
||||
include $(commands_recovery_local_path)/exfat/mkfs/Android.mk
|
||||
endif
|
||||
|
||||
commands_recovery_local_path :=
|
||||
|
@ -2,9 +2,11 @@
|
||||
|
||||
The goal of this branch is to rebase TWRP onto AOSP while maintaining as much of the original AOSP code as possible. This goal should allow us to apply updates to the AOSP code going forward with little to no extra work. With this goal in mind, we will carefully consider any changes needed to the AOSP code before allowing them. In most cases, instead of changing the AOSP code, we'll create our own functions instead. The only changes that should be made to AOSP code should be those affecting startup of the recovery and some of the make files.
|
||||
|
||||
This branch is currently a work in progress, however, most features have been implemented and it is now ready for testing.
|
||||
If there are changes that need to be merged from AOSP, we will pull the change directly from AOSP instead of creating a new patch in order to prevent merge conflicts with AOSP.
|
||||
|
||||
You can find a compiling guide [here](http://rootzwiki.com/topic/23903-how-to-compile-twrp-from-source/ "Guide").
|
||||
This branch is under final testing and will be used shortly for public builds, but has not officially been released.
|
||||
|
||||
You can find a compiling guide [here](http://forum.xda-developers.com/showthread.php?t=1943625 "Guide").
|
||||
|
||||
[More information about the project.](http://www.teamw.in/project/twrp2 "More Information")
|
||||
|
||||
|
4
data.cpp
4
data.cpp
@ -390,7 +390,6 @@ int DataManager::SetValue(const string varName, string value, int persist /* = 0
|
||||
|
||||
if (pos->second.second != 0)
|
||||
SaveValues();
|
||||
|
||||
gui_notifyVarChange(varName.c_str(), value.c_str());
|
||||
return 0;
|
||||
}
|
||||
@ -842,8 +841,7 @@ void DataManager::Output_Version(void) {
|
||||
}
|
||||
Path += "/TWRP/.version";
|
||||
if (TWFunc::Path_Exists(Path)) {
|
||||
Command = "rm -f " + Path;
|
||||
system(Command.c_str());
|
||||
unlink(Path.c_str());
|
||||
}
|
||||
FILE *fp = fopen(Path.c_str(), "w");
|
||||
if (fp == NULL) {
|
||||
|
59
dosfstools/Android.mk
Normal file
59
dosfstools/Android.mk
Normal file
@ -0,0 +1,59 @@
|
||||
ifneq ($(TARGET_SIMULATOR),true)
|
||||
LOCAL_PATH:= $(call my-dir)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_SRC_FILES := src/boot.c src/check.c src/common.c \
|
||||
src/fat.c src/file.c src/io.c src/lfn.c src/dosfsck.c
|
||||
LOCAL_C_INCLUDES := $(KERNEL_HEADERS)
|
||||
LOCAL_SHARED_LIBRARIES := libc
|
||||
LOCAL_CFLAGS += -D_USING_BIONIC_
|
||||
LOCAL_CFLAGS += -DUSE_ANDROID_RETVALS
|
||||
LOCAL_MODULE = dosfsck
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES
|
||||
LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin
|
||||
include $(BUILD_EXECUTABLE)
|
||||
|
||||
# build symlink
|
||||
SYMLINKS := $(addprefix $(TARGET_OUT)/bin/,fsck_msdos)
|
||||
$(SYMLINKS): DOSFSCK_BINARY := $(LOCAL_MODULE)
|
||||
$(SYMLINKS): $(LOCAL_INSTALLED_MODULE) $(LOCAL_PATH)/Android.mk
|
||||
@echo "Symlink: $@ -> $(DOSFSCK_BINARY)"
|
||||
@mkdir -p $(dir $@)
|
||||
@rm -rf $@
|
||||
$(hide) ln -sf $(DOSFSCK_BINARY) $@
|
||||
|
||||
ALL_DEFAULT_INSTALLED_MODULES += $(SYMLINKS)
|
||||
|
||||
# We need this so that the installed files could be picked up based on the
|
||||
# local module name
|
||||
ALL_MODULES.$(LOCAL_MODULE).INSTALLED := \
|
||||
$(ALL_MODULES.$(LOCAL_MODULE).INSTALLED) $(SYMLINKS)
|
||||
|
||||
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_SRC_FILES := src/boot.c src/check.c src/common.c src/fat.c \
|
||||
src/file.c src/io.c src/lfn.c src/dosfslabel.c
|
||||
LOCAL_C_INCLUDES := $(KERNEL_HEADERS) \
|
||||
bionic/libc/kernel/common
|
||||
LOCAL_SHARED_LIBRARIES := libc
|
||||
LOCAL_CFLAGS += -D_USING_BIONIC_
|
||||
LOCAL_MODULE = dosfslabel
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES
|
||||
LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin
|
||||
include $(BUILD_EXECUTABLE)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_SRC_FILES := src/mkdosfs.c
|
||||
LOCAL_C_INCLUDES := $(KERNEL_HEADERS)
|
||||
LOCAL_SHARED_LIBRARIES := libc
|
||||
LOCAL_CFLAGS += -D_USING_BIONIC_
|
||||
LOCAL_MODULE = mkdosfs
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES
|
||||
LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin
|
||||
include $(BUILD_EXECUTABLE)
|
||||
|
||||
endif
|
674
dosfstools/COPYING
Normal file
674
dosfstools/COPYING
Normal 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.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
760
dosfstools/ChangeLog
Normal file
760
dosfstools/ChangeLog
Normal file
@ -0,0 +1,760 @@
|
||||
commit 2e20319843ea85d77c51a9ce9a9b278662426d98
|
||||
Author: Michael Casadevall <mcasadevall@ubuntu.com>
|
||||
Date: Tue Jun 7 19:19:30 2011 +0200
|
||||
|
||||
Correcting miscalculation of sector number in some cases.
|
||||
|
||||
mkdosfs will incorrectly calculate the number of sectors of a
|
||||
given FAT partition if the number sectors are odd due to
|
||||
count_blocks incorrectly handling the remainder of a division
|
||||
operation. This miscalculation causes the OMAP4 bootloader to
|
||||
fail to boot.
|
||||
|
||||
This bug can be observed by comparing the total sector size in
|
||||
fdisk expert more to fsck.msdos; this discrepancy only shows up
|
||||
when the number of sectors are odd.
|
||||
|
||||
See https://bugs.launchpad.net/ubuntu/+source/dosfstools/+bug/794043
|
||||
for more information.
|
||||
|
||||
commit 45c3a5d8229ef998962e495f1efe7d2a6cd8a825
|
||||
Author: Daniel Baumann <daniel@debian.org>
|
||||
Date: Sat Jan 8 23:38:59 2011 +0100
|
||||
|
||||
Re-running Nindent.
|
||||
|
||||
commit 37115695884422e6f58ec490d11d460539715f8a
|
||||
Author: Sergey Gusarov <laborer2008@gmail.com>
|
||||
Date: Sat Jan 8 23:36:11 2011 +0100
|
||||
|
||||
Fixing compiler warnings related to the mismatch of types "char *" / "unsigned
|
||||
char *".
|
||||
|
||||
These warnings appear when you compile the project with the option "-Wall", what
|
||||
is done with the current default Makefile.
|
||||
|
||||
commit a9055613f0d826021db65c79c2df87ac91e89215
|
||||
Author: Jaroslav Skarvada <jskarvad@redhat.com>
|
||||
Date: Thu Jan 6 22:35:00 2011 +0100
|
||||
|
||||
Fixing overflow bug in reclaim_file function, see
|
||||
https://bugzilla.redhat.com/show_bug.cgi?id=660154 for more information.
|
||||
|
||||
The problem is that alloc_rootdir_entry counts with 10000 files at max, but the
|
||||
filename buffer is only 8 chars long. Due to pattern mask used it results to
|
||||
only 10 files at max (FSCK0-9REC). If there is more than 10 files, it overflows
|
||||
and hangs.
|
||||
|
||||
commit 5a2b37f3ef664dbc7850f3d800890d7bb919b3cd
|
||||
Author: Sergey Gusarov <laborer2008@gmail.com>
|
||||
Date: Thu Jan 6 22:31:39 2011 +0100
|
||||
|
||||
Fixing conversion specifiers in accordance with the type of expressions.
|
||||
|
||||
commit 258e5ebbb24fd6293a86fe22d6bcda8ce1794dcd
|
||||
Author: Daniel Baumann <daniel@debian.org>
|
||||
Date: Sun Jan 2 15:41:44 2011 +0100
|
||||
|
||||
Indenting source files.
|
||||
|
||||
commit 9c22278dda0f8fc05aa537eb0bcb07e51f0dec6a
|
||||
Author: Daniel Baumann <daniel@debian.org>
|
||||
Date: Sun Jan 2 15:39:03 2011 +0100
|
||||
|
||||
Adding Nindent script from syslinux.
|
||||
|
||||
commit e6008ff5c15dc2e6d5b33f88a447d1159165c95d
|
||||
Author: Daniel Baumann <daniel@debian.org>
|
||||
Date: Fri Dec 24 17:58:29 2010 +0100
|
||||
|
||||
Releasing upstream version 3.0.11.
|
||||
|
||||
commit bce60d1b0b739612b63852722d8504986096b40d
|
||||
Author: Michael Stapelberg <michael@stapelberg.de>
|
||||
Date: Fri Nov 19 14:09:36 2010 +0100
|
||||
|
||||
Add better error message when the device cannot be opened.
|
||||
|
||||
This is helpful for SD cards or other removable media which have an enabled
|
||||
write lock -- without the "Permission denied" message, the user has to strace
|
||||
mkdosfs to find out what's going on.
|
||||
|
||||
commit ff45bd967e5d8ff7edc496adbad57257d4d5432b
|
||||
Author: Jaroslav Skarvada <jskarvad@redhat.com>
|
||||
Date: Fri Oct 8 13:38:16 2010 +0200
|
||||
|
||||
Unalign on s390x, see http://bugzilla.redhat.com/show_bug.cgi?id=624596 for
|
||||
more information.
|
||||
|
||||
commit 22874327372f914d2919490326c95f4607f8de74
|
||||
Author: Daniel Baumann <daniel@debian.org>
|
||||
Date: Sun Sep 12 09:35:47 2010 +0200
|
||||
|
||||
Releasing upstream version 3.0.10.
|
||||
|
||||
commit 8b7c9d94a4571142a77a587138bc26b39f8e2863
|
||||
Author: Alexander Korolkov <alexander.korolkov@gmail.com>
|
||||
Date: Sun Sep 12 09:29:12 2010 +0200
|
||||
|
||||
Modify LFN direntries when file is renamed or deleted, see
|
||||
Debian bug #596329.
|
||||
|
||||
commit 761b798f3bf2b4a87f2d454f555e18758791c864
|
||||
Author: Alexander Korolkov <alexander.korolkov@gmail.com>
|
||||
Date: Sun Sep 12 09:27:07 2010 +0200
|
||||
|
||||
If the test of short filename fails, dosfsck could complain about
|
||||
bad long filename, see Debian bug #596327.
|
||||
|
||||
commit 8fa3587a946614cd43d813052e0e31e595e6d63d
|
||||
Author: Alexander Korolkov <alexander.korolkov@gmail.com>
|
||||
Date: Sun Sep 12 09:24:47 2010 +0200
|
||||
|
||||
dosfsck: don't complain about bad filenames when short filename
|
||||
contains 7 or more characters with codes 128-255, see Debian
|
||||
bug #596327.
|
||||
|
||||
commit 3893857b841096de6a422ef5bed1b2618a7037d5
|
||||
Author: Mitch Rybczynski <mrybczynski@miovision.com>
|
||||
Date: Mon Jul 5 14:45:54 2010 +0200
|
||||
|
||||
Adding __arm__ define check for some crosscompile toolchains.
|
||||
|
||||
commit 7d03b3cc96b83b67638b463610a29abfd6f51f77
|
||||
Author: Daniel Baumann <daniel@debian.org>
|
||||
Date: Sun Mar 14 16:42:32 2010 +0100
|
||||
|
||||
Modernizing dosfslabel manpage.
|
||||
|
||||
commit 258049911c5df476fb434e0d87e0ece01b9ba137
|
||||
Author: Daniel Baumann <daniel@debian.org>
|
||||
Date: Sun Mar 14 16:33:47 2010 +0100
|
||||
|
||||
Modernizing dosfsck manpage.
|
||||
|
||||
commit 50d1d96b9666913a90e16904a63e29925675859c
|
||||
Author: Daniel Baumann <daniel@debian.org>
|
||||
Date: Sun Mar 14 16:05:32 2010 +0100
|
||||
|
||||
Fixing spelling error in boot.c.
|
||||
|
||||
commit 0e87c7890b598d78c6aa3d2a06b2306980e75a3d
|
||||
Author: Daniel Baumann <daniel@debian.org>
|
||||
Date: Sun Jan 31 08:31:32 2010 +0100
|
||||
|
||||
Releasing upstream version 3.0.9.
|
||||
|
||||
commit 9415707c2c9ad22b48660593915667dd228722fa
|
||||
Author: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
|
||||
Date: Sun Jan 31 00:11:41 2010 -0500
|
||||
|
||||
Be sure to store the updated reserved_sector count in the boot sector,
|
||||
see Debian bug #567337.
|
||||
|
||||
commit 68b3f00471f60a692fe021d65289bbaf2dc990d5
|
||||
Author: Daniel Baumann <daniel@debian.org>
|
||||
Date: Sat Jan 23 10:16:18 2010 +0100
|
||||
|
||||
Releasing upstream version 3.0.8.
|
||||
|
||||
commit 69dbf2e002f0cb3f0781256dec7258b66ffae3b6
|
||||
Author: Daniel Baumann <daniel@debian.org>
|
||||
Date: Sat Jan 23 10:15:01 2010 +0100
|
||||
|
||||
Removing some cruft in end-comments.
|
||||
|
||||
commit eef306657f3152bbf913a8a45c514f11b2dc2494
|
||||
Author: Steven J. Magnani <steve@digidescorp.com>
|
||||
Date: Thu Jan 21 16:58:11 2010 +0100
|
||||
|
||||
When compiling a 32-bit version of dosfstools on an x86_64 machine,
|
||||
the resulting applications report strange errors on "large" (> 2 GiB)
|
||||
partitions:
|
||||
|
||||
Seek to -2118967808:Invalid argument
|
||||
|
||||
Warning: Filesystem is FAT32 according to fat_length and fat32_length fields,
|
||||
but has only 8613 clusters, less than the required minimum of 65525.
|
||||
This may lead to problems on some systems.
|
||||
|
||||
This appears to be due to compilation with a 32-bit off_t and lseek() library
|
||||
function.
|
||||
|
||||
Use lseek64 for positioning, and change some suspect uses of off_t to loff_t.
|
||||
|
||||
commit e69f49dd1fe52780071cb3f024d1a8246125915a
|
||||
Author: Steven J. Magnani <steve@digidescorp.com>
|
||||
Date: Thu Jan 21 16:56:26 2010 +0100
|
||||
|
||||
If dosfsck is run in read-only mode (-n), exit with code 0
|
||||
if the only issue found is an uninitialized free cluster summary.
|
||||
|
||||
commit e52a16d488cf680117e4d476400bdd7915ef2f7a
|
||||
Author: Steven J. Magnani <steve@digidescorp.com>
|
||||
Date: Thu Jan 21 16:55:30 2010 +0100
|
||||
|
||||
On x86_64, dosfsck incorrectly claims that a free_cluster summary of
|
||||
0xFFFFFFFF, defined by Microsoft to be "uninitialized," is wrong.
|
||||
|
||||
commit 32db02998ed7882df355fa4077009e8d363df3ab
|
||||
Author: H. Peter Anvin <hpa@zytor.com>
|
||||
Date: Fri Jan 8 09:16:38 2010 +0100
|
||||
|
||||
mkdosfs: correct alignment of the root directory.
|
||||
|
||||
Correct the code to align the root directory; it was broken before
|
||||
since bs.dir_entries had already been set at the point of alignment.
|
||||
This patch removes the dual use of bs.dir_entries and root_dir_entries
|
||||
to carry the same information: the information is carried in
|
||||
root_dir_entires exclusively, and then bs.dir_entries is set inside
|
||||
setup_tables() at a late point.
|
||||
|
||||
The code to align the root directory is also wrapped in
|
||||
if (align_structures); this avoids rounding the number of root
|
||||
directory entries up to a whole sector when used with -a
|
||||
(i.e. preserves the previous behavior.)
|
||||
|
||||
commit e462ac31a1d5d235b8a31a9e392e44e2dbc3783c
|
||||
Author: H. Peter Anvin <hpa@zytor.com>
|
||||
Date: Wed Jan 6 20:55:36 2010 +0100
|
||||
|
||||
mkdosfs: improve wording in the man page for the -a option.
|
||||
|
||||
Improve the English language used in the man page for the -a (no
|
||||
align) option to mkdosfs.
|
||||
|
||||
commit 680d71d167f30a823f88dd66473fc664cd887ab0
|
||||
Author: Daniel Baumann <daniel@debian.org>
|
||||
Date: Wed Jan 6 11:27:25 2010 +0100
|
||||
|
||||
Adding reference to dosfslable in mkdosfs manpage.
|
||||
|
||||
commit 60fc9f853c1045e615b34a193738f88021678d30
|
||||
Author: H. Peter Anvin <hpa@zytor.com>
|
||||
Date: Wed Jan 6 11:18:55 2010 +0100
|
||||
|
||||
mkdosfs: by default align all structures to cluster boundaries
|
||||
|
||||
Align all data structures (reserved sectors, FATs, root directory for
|
||||
FAT12/16) to an even multiple of the cluster size. This means that if
|
||||
the partition is aligned, so will all clusters be. This adds
|
||||
significant performance for anything where the physical sector size is
|
||||
larger than the logical sector size, e.g. flash media or large-sector
|
||||
hard disks.
|
||||
|
||||
commit 312b05fc47107f695483994375a1f6f429069708
|
||||
Author: Daniel Baumann <daniel@debian.org>
|
||||
Date: Thu Dec 24 10:53:36 2009 +0100
|
||||
|
||||
Releasing upstream version 3.0.7.
|
||||
|
||||
commit 844307669208608a3464157ddb5e789bd9556f34
|
||||
Author: Ben Hutchings <ben@decadent.org.uk>
|
||||
Date: Thu Dec 24 09:55:52 2009 +0100
|
||||
|
||||
Fixing dosfslabel to set volume label in the right place,
|
||||
see Debian bug #559985.
|
||||
|
||||
commit 1bae0e2037717d65b3283db9da51ae7686a7a9be
|
||||
Author: Lubomir Rintel <lkundrak@v3.sk>
|
||||
Date: Thu Dec 24 09:39:39 2009 +0100
|
||||
|
||||
Fixing out-of bound writes.
|
||||
|
||||
Firstly, packed attribute is added to the structure so that extension
|
||||
is guarranteed to immediately follow name for the cross-name-extension
|
||||
reads to succeed.
|
||||
|
||||
Secondly, writes into dir_entry->name that span through the extension as
|
||||
well are split into two, so that FORTIFY_SOURCE's bound checking does
|
||||
not abort dosfsck. There also was an off-by-one error in auto_rename()'s
|
||||
sprintf().
|
||||
|
||||
commit eb297071adfca1ed7af85ca111f20ab41db8ac59
|
||||
Author: San Mehat <san@google.com>
|
||||
Date: Thu Dec 24 09:31:41 2009 +0100
|
||||
|
||||
Adding custom exit code in dosfsck for the case where the FS is read only.
|
||||
|
||||
commit b3864d0939c960d0e0f15e4e3b1d626639b64681
|
||||
Author: Daniel Baumann <daniel@debian.org>
|
||||
Date: Sun Oct 4 10:59:33 2009 +0200
|
||||
|
||||
Releasing upstream version 3.0.6.
|
||||
|
||||
commit 144f8fcfc3f7982e8f460f8379a753b7a5941783
|
||||
Author: Steven J. Magnani <steve@digidescorp.com>
|
||||
Date: Sun Oct 4 10:58:43 2009 +0200
|
||||
|
||||
Attempt to improve clarity of the orphan cluster reclaim code.
|
||||
Minor optimization - remove some unnecessary checking.
|
||||
|
||||
commit 343fe6d5e7135efadc498fd91e19ba8da499d0c9
|
||||
Author: Steven J. Magnani <steve@digidescorp.com>
|
||||
Date: Sun Oct 4 08:37:19 2009 +0200
|
||||
|
||||
Close hole that permitted clusters to link to (invalid) cluster 1.
|
||||
|
||||
If an orphan chain that linked to cluster 1 was reclaimed to a file,
|
||||
deletion of the file would result in a filesystem panic.
|
||||
|
||||
commit db079a02059d7f7296fbe9f87624623a43816c5f
|
||||
Author: Steven J. Magnani <steve@digidescorp.com>
|
||||
Date: Sun Oct 4 08:32:30 2009 +0200
|
||||
|
||||
Fix erroneous report of huge number of clusters in use on big-endian
|
||||
systems when the FSINFO free cluster count is reset.
|
||||
|
||||
commit 7d5320b8a374b8da1a16b09b3b9b0713828d6755
|
||||
Author: Daniel Baumann <daniel@debian.org>
|
||||
Date: Mon Jul 27 14:26:11 2009 +0200
|
||||
|
||||
Releasing upstream version 3.0.5.
|
||||
|
||||
commit e80ede4dd3c2058fe32e29ff82244ecb1c7c5514
|
||||
Author: Piotr Kaczuba <pepe@attika.ath.cx>
|
||||
Date: Sun Jul 26 22:21:25 2009 +0200
|
||||
|
||||
Signed/unsigned char mismatch in check.c causes false positives
|
||||
in bad_name() and can result in data loss, see Debian bug #538758.
|
||||
|
||||
commit 9e15ddf6d52dd166efcb59f91f16fb9d695c86c5
|
||||
Author: Andrew Tridgell <tridge@samba.org>
|
||||
Date: Sun Jul 26 22:12:06 2009 +0200
|
||||
|
||||
Update to new kernel patches that add FAT_NO_83NAME flag.
|
||||
|
||||
See http://lkml.org/lkml/2009/7/20/425 and
|
||||
http://lkml.org/lkml/2009/7/20/424 for more information.
|
||||
|
||||
commit 6c68b94008157c444954d2f90a7f9ec8ffc2ec87
|
||||
Author: Daniel Baumann <daniel@debian.org>
|
||||
Date: Tue Jul 21 08:10:52 2009 +0200
|
||||
|
||||
Releasing upstream version 3.0.4.
|
||||
|
||||
commit 3ce6422e93f3de746be092e324253a8722917a86
|
||||
Author: Andrew Tridgell <tridge@samba.org>
|
||||
Date: Tue Jul 21 07:59:22 2009 +0200
|
||||
|
||||
Modify dosfstools to support the dummy 8.3 short filename values
|
||||
used by Linux systems with the VFAT_FS_DUALNAMES option disabled.
|
||||
|
||||
See http://lkml.org/lkml/2009/6/26/313 and
|
||||
http://lkml.org/lkml/2009/6/26/314 for more information.
|
||||
|
||||
commit 94f8769aeddf0d0d3f0be54361514a464907a4a1
|
||||
Author: Paul Rupe <prupe@nc.rr.com>
|
||||
Date: Tue May 19 10:37:52 2009 +0200
|
||||
|
||||
Fixing "Too many files need repair" error during fsck.
|
||||
|
||||
commit 89566399e407e54eb14d275770106ad42b3ac87c
|
||||
Author: Daniel Baumann <daniel@debian.org>
|
||||
Date: Mon May 18 15:12:04 2009 +0200
|
||||
|
||||
Releasing upstream version 3.0.3.
|
||||
|
||||
commit 8147c98a542b714ccab34b57c84ed842bb6b50f2
|
||||
Author: Daniel Baumann <daniel@debian.org>
|
||||
Date: Mon May 18 15:10:55 2009 +0200
|
||||
|
||||
Also declaring arm as an unaligned architecture, see Debian bug #502961.
|
||||
|
||||
commit 18e27fa5c0f811e7edc10bca771acc7c04b19146
|
||||
Author: Steven J. Magnani <steve@digidescorp.com>
|
||||
Date: Mon May 18 15:01:49 2009 +0200
|
||||
|
||||
Adding support for limited-memory embedded systems.
|
||||
|
||||
This patch reorganizes heap memory usage by dosfsck and mkdosfs
|
||||
to support limited-memory embedded systems - in particular, those
|
||||
based on Xilinx's Microblaze processor. It also adds a few comments.
|
||||
|
||||
commit 180b68e652df7bfeb7f336e0247aee8873edea7f
|
||||
Author: Mike Frysinger <vapier@gentoo.org>
|
||||
Date: Thu Mar 5 07:03:36 2009 +0100
|
||||
|
||||
Declaring Blackfin as an unaligned architecture.
|
||||
|
||||
commit 71ac75353d9158aed663f0a3a9d1a1a67ee4ff4f
|
||||
Author: Daniel Baumann <daniel@debian.org>
|
||||
Date: Sat Feb 28 09:48:04 2009 +0100
|
||||
|
||||
Releasing upstream version 3.0.2.
|
||||
|
||||
commit a75924b8ff629fe7ca5ba9c58ac75f66290242ee
|
||||
Author: Hiroaki Ishizawa <hiroaki.ishizawa@gmail.com>
|
||||
Date: Fri Feb 13 10:00:46 2009 +0100
|
||||
|
||||
dosfsck corrupts root directory when fs->nfats is 1.
|
||||
|
||||
commit 161a5e1fdd019732e0a304beceaeeb606eb128d6
|
||||
Author: Stepan Kasal <skasal@redhat.com>
|
||||
Date: Fri Jan 30 14:56:33 2009 +0100
|
||||
|
||||
src/dosfslabel.c (main): After writing the label, exit code should be 0.
|
||||
|
||||
commit 26ffa1fb565c2b3284b846ca2733118808c85cb5
|
||||
Author: Daniel Baumann <daniel@debian.org>
|
||||
Date: Fri Jan 30 14:06:01 2009 +0100
|
||||
|
||||
Also installing ChangeLog in install-doc target of Makefile.
|
||||
|
||||
commit abad38ee561b02ec47be7e861780bf5fa2a05d0b
|
||||
Author: Stepan Kasal <skasal@redhat.com>
|
||||
Date: Fri Jan 30 14:05:12 2009 +0100
|
||||
|
||||
Makefile: Do not clobber time stamps of doc files.
|
||||
|
||||
commit 81882d20ec6bd4bf4914d39636cecc8c8e57dd67
|
||||
Author: Daniel Baumann <daniel@debian.org>
|
||||
Date: Sun Nov 23 22:45:45 2008 +0100
|
||||
|
||||
Releasing upstream version 3.0.1.
|
||||
|
||||
commit 41574812a2586f0b6aa1d4f6e2276e557e9cbbcf
|
||||
Author: Daniel Baumann <daniel@debian.org>
|
||||
Date: Sun Nov 23 18:41:01 2008 +0100
|
||||
|
||||
Applying Fedoras dosfstools-vfat-timingfix.diff from Bill Nottingham
|
||||
<notting@redhat.com> to fix vfat timing issue. See
|
||||
https://bugzilla.redhat.com/show_bug.cgi?id=448247 for more information.
|
||||
|
||||
commit b80656109cc5cffdefd626c2ec9d45e3cf63a03e
|
||||
Author: Ulrich Mueller <ulm@gentoo.org>
|
||||
Date: Tue Oct 7 07:55:37 2008 +0200
|
||||
|
||||
Patch to check for bad number of clusters in dosfsck:
|
||||
|
||||
* FAT16 filesystems with 65525 clusters or more will be rejected
|
||||
(Before, this was not tested for. Up to 65535 clusters were accepted
|
||||
as good).
|
||||
|
||||
* For FAT32 filesystems with less than 65525 a warning message will be
|
||||
output.
|
||||
|
||||
Macro MSDOS_FAT12 is now replaced by FAT12_THRESHOLD to make it
|
||||
consistent with the definition in mkdosfs and to remove the dependency
|
||||
on the kernel version.
|
||||
|
||||
commit b9c13d143c420a3ec6e1dcb652cafa407621e9c7
|
||||
Author: Dann Frazier <dannf@hp.com>
|
||||
Date: Tue Sep 30 07:25:19 2008 +0200
|
||||
|
||||
Changing some wording to make the indended meaning of "full-disk device"
|
||||
more obvious.
|
||||
|
||||
commit 4df18ad463f41ae368c3c51bfb5a033072605663
|
||||
Author: Daniel Baumann <daniel@debian.org>
|
||||
Date: Sun Sep 28 11:43:19 2008 +0200
|
||||
|
||||
Releasing upstream version 3.0.0.
|
||||
|
||||
commit 17fbf2a6dc9255a6bb832472ae7cda674b55e961
|
||||
Author: Daniel Baumann <daniel@debian.org>
|
||||
Date: Sun Sep 28 11:29:01 2008 +0200
|
||||
|
||||
Adding GPL headers to all files.
|
||||
|
||||
commit d2039e12c8d53472411c91eb8e7a7c0544e13d6d
|
||||
Author: Daniel Baumann <daniel@debian.org>
|
||||
Date: Sun Sep 28 10:51:55 2008 +0200
|
||||
|
||||
Adding new GPL license file.
|
||||
|
||||
commit e4e457f4b57090ecf0539f48dc682ab9afd14ab8
|
||||
Author: Daniel Baumann <daniel@debian.org>
|
||||
Date: Fri Sep 26 23:31:12 2008 +0200
|
||||
|
||||
Redoing Makefile from scratch.
|
||||
|
||||
commit 216568ca3a01ed38962b22c7bf838d15d5a4d98d
|
||||
Author: Daniel Baumann <daniel@debian.org>
|
||||
Date: Sat Sep 27 00:17:38 2008 +0200
|
||||
|
||||
Removing whitespaces in all files at EOL and EOF.
|
||||
|
||||
commit f59157e06561c525605279145057361afa721042
|
||||
Author: Daniel Baumann <daniel@debian.org>
|
||||
Date: Fri Sep 26 23:48:56 2008 +0200
|
||||
|
||||
Adding Debians dosfslabel.8 manpage from Francois Wendling
|
||||
<frwendling@free.fr>.
|
||||
|
||||
commit c1bacab212d2b7f6ea93914976cb60056ff8276d
|
||||
Author: Daniel Baumann <daniel@debian.org>
|
||||
Date: Fri Sep 26 18:36:04 2008 +0200
|
||||
|
||||
Updating version.h includes to new location of version.h file.
|
||||
|
||||
commit 1dae9f522062037d3539cadf344e0359c644171f
|
||||
Author: Daniel Baumann <daniel@debian.org>
|
||||
Date: Fri Sep 26 18:19:36 2008 +0200
|
||||
|
||||
Removing old lsm file.
|
||||
|
||||
commit d843bec0b987f5582fe048f70e42df18c34d3ae4
|
||||
Author: Daniel Baumann <daniel@debian.org>
|
||||
Date: Fri Sep 26 18:07:47 2008 +0200
|
||||
|
||||
Removing old cvsignore files.
|
||||
|
||||
commit 77fddbc03016752286b26913c62b98f86ee63211
|
||||
Author: Daniel Baumann <daniel@debian.org>
|
||||
Date: Fri Sep 26 18:18:39 2008 +0200
|
||||
|
||||
Removing old build file.
|
||||
|
||||
commit f3e7168fc9eb6f32a6c85021186d84944cefeba8
|
||||
Author: Daniel Baumann <daniel@debian.org>
|
||||
Date: Fri Sep 26 18:19:16 2008 +0200
|
||||
|
||||
Removing old GPL license files.
|
||||
|
||||
commit 68089477036e97911791516ee2167286f26ff819
|
||||
Author: Daniel Baumann <daniel@debian.org>
|
||||
Date: Fri Sep 26 18:21:57 2008 +0200
|
||||
|
||||
Unifying dosfsck and mkdosfs Makefiles in common src/Makefile.
|
||||
|
||||
commit 9432a02d6e7c38872d7b1042f1b8be1b24a57427
|
||||
Author: Daniel Baumann <daniel@debian.org>
|
||||
Date: Fri Sep 26 18:04:02 2008 +0200
|
||||
|
||||
Unifying dosfsck and mkdosfs sources in common src directory.
|
||||
|
||||
commit 0c179b9ee47174d0f34d9fc796d540012740ac01
|
||||
Author: Daniel Baumann <daniel@debian.org>
|
||||
Date: Fri Sep 26 18:05:27 2008 +0200
|
||||
|
||||
Unifying dosfsck and mkdosfs manpages in common man directory.
|
||||
|
||||
commit 2d246c28ba6cfd43be2e44b11283891d922f352b
|
||||
Author: Daniel Baumann <daniel@debian.org>
|
||||
Date: Fri Sep 26 18:12:29 2008 +0200
|
||||
|
||||
Unifying dosfsck and mkdosfs documents in common doc directory.
|
||||
|
||||
commit e5b16990515d0214fd103dd8aa22ff6a3cda4b64
|
||||
Author: Daniel Baumann <daniel@debian.org>
|
||||
Date: Fri Sep 26 15:39:51 2008 +0200
|
||||
|
||||
Applying Gentoos dosfstools-2.11-preen.patch from Roy Marples
|
||||
<uberlord@gentoo.org> to alias dosfsck -p to -a:
|
||||
|
||||
* Map -p to -a for baselayout-2, #177514.
|
||||
|
||||
commit 6a1d974251a9f9a142775ace3a8048149abfa90c
|
||||
Author: Daniel Baumann <daniel@debian.org>
|
||||
Date: Fri Sep 26 15:49:43 2008 +0200
|
||||
|
||||
Applying Gentoos dosfstools-2.11-build.patch from Mike Frysinger
|
||||
<vapier@gentoo.org> to improve Makefile:
|
||||
|
||||
* Respect user settings #157785/#157786 by Diego Petteno.
|
||||
|
||||
commit 1ea49f00e61b554dc833d44e1a3617e923be667e
|
||||
Author: Daniel Baumann <daniel@debian.org>
|
||||
Date: Fri Sep 26 15:37:34 2008 +0200
|
||||
|
||||
Applying Gentoos dosfstools-2.11-verify-double-count-fix.patch from
|
||||
Robin H. Johnson <robbat2@gentoo.org> to fix double count of files
|
||||
during verification:
|
||||
|
||||
* Don't double-count n_files during a verification pass.
|
||||
Bugzilla: http://bugs.gentoo.org/show_bug.cgi?id=99845
|
||||
|
||||
commit 2d2f20b2c495fa620c7bb3ec5a0838b08f65ab05
|
||||
Author: Daniel Baumann <daniel@debian.org>
|
||||
Date: Fri Sep 26 15:33:36 2008 +0200
|
||||
|
||||
Applying Gentoos dosfstools-2.11-fat32size.patch from Mike Frysinger
|
||||
<vapier@gentoo.org> to fix generation of filesystems on 256meg devices:
|
||||
|
||||
* Fix generation of FAT filesystems on devices that are 256meg in size
|
||||
Patch by Ulrich Mueller and accepted upstream
|
||||
http://bugs.gentoo.org/112504
|
||||
|
||||
commit a86564a9317b2bf9f7734feacdce794f20af74a7
|
||||
Author: Daniel Baumann <daniel@debian.org>
|
||||
Date: Fri Sep 26 15:22:06 2008 +0200
|
||||
|
||||
Applying Suses dosfstools-2.11-unsupported-sector-size.patch from Petr
|
||||
Gajdos <pgajdos@suse.cz> to add sector size warning:
|
||||
|
||||
* added warning for creation msdos on filesystem with sector size
|
||||
greater than 4096 [fate#303325]
|
||||
|
||||
commit 8171e51f4e02bd9f92bb515ca7896d3cb1b564b5
|
||||
Author: Daniel Baumann <daniel@debian.org>
|
||||
Date: Fri Sep 26 15:18:35 2008 +0200
|
||||
|
||||
Applying Suses dosfstools-2.11-mkdosfs-geo0.diff from Ludwig Nussel
|
||||
<lnussel@suse.de> to fix handling of zero heads and sectors:
|
||||
|
||||
* the HDIO_GETGEO ioctl works on device mapper devices but returns
|
||||
zero heads and sectors. Therefore let's a) assume dummy values in
|
||||
that case in mkdosfs and b) don't consider such fat file systems as
|
||||
invalid in dosfsck. The Linux kernel accepts them anyways.
|
||||
|
||||
commit db887df619f4e995db0ab112334f31464a03fa0e
|
||||
Author: Daniel Baumann <daniel@debian.org>
|
||||
Date: Fri Sep 26 15:15:40 2008 +0200
|
||||
|
||||
Applying Suses dosfstools-2.11-linuxfs.patch from Ruediger Oertel
|
||||
<ro@suse.de> to not include linux/fs.h.
|
||||
|
||||
commit 7fe3fa643494b26962d542fac38d988ac60f8c09
|
||||
Author: Daniel Baumann <daniel@debian.org>
|
||||
Date: Fri Sep 26 15:11:50 2008 +0200
|
||||
|
||||
Applying Fedoras dosfstools-2.11-assumeKernel26.patch from Peter Vrabec
|
||||
<pvrabec@redhat.com> to remove linux 2.6 conditionals:
|
||||
|
||||
* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0) does not work with
|
||||
glibc-kernheaders-2.4-9.1.94
|
||||
|
||||
commit 90c1c93c100722a03e48be51b1312fe65c1cb156
|
||||
Author: Daniel Baumann <daniel@debian.org>
|
||||
Date: Fri Sep 26 15:05:00 2008 +0200
|
||||
|
||||
Applying Debians 99-conglomeration.dpatch (no other information
|
||||
available).
|
||||
|
||||
commit bb6541bf4735e3a7f1c71b4722c6d03bb4549eea
|
||||
Author: Daniel Baumann <daniel@debian.org>
|
||||
Date: Fri Sep 26 14:26:41 2008 +0200
|
||||
|
||||
Applying Debians 15-manpage-files.dpatch from Daniel Baumann
|
||||
<daniel@debian.org> to improve dosfsck manpage:
|
||||
|
||||
* Lists fsckNNNN.rec files in FILES section (Closes: #444596).
|
||||
|
||||
commit 49282165866be19d3bc54a3f4bdee2cf3a63ba6c
|
||||
Author: Daniel Baumann <daniel@debian.org>
|
||||
Date: Fri Sep 26 14:34:42 2008 +0200
|
||||
|
||||
Applying Debians 13-getopt.dpatch from Adonikam Virgo
|
||||
<adonikam@virgonet.org> to fix mkdosfs getopt:
|
||||
|
||||
* Fixes backup sector getopt (Closes: #232387, #479794).
|
||||
|
||||
commit c32e44b85f4eac6f6a94bd620eea4abba257042a
|
||||
Author: Daniel Baumann <daniel@debian.org>
|
||||
Date: Fri Sep 26 14:34:17 2008 +0200
|
||||
|
||||
Applying Debians 12-zero-slot.dpatch by Karl Tomlinson
|
||||
<karlt@karlt.net> to fix dosfsck zero slot crashes:
|
||||
|
||||
* Fixes crashes due to zero slot numbers causing a negative offset in
|
||||
the call to copy_lfn_part in lfn_add_slot. On amd64 this results in
|
||||
a SIGSEGV in copy_lfn_part. On x86 the result is heap corruption
|
||||
and thus sometimes a SIGSEGV or double free abort later. (Closes:
|
||||
#152550, #353198, #356377, #401798).
|
||||
|
||||
commit 370847af533e628aa9e38710e6d50af09f2b71ba
|
||||
Author: Daniel Baumann <daniel@debian.org>
|
||||
Date: Fri Sep 26 14:33:54 2008 +0200
|
||||
|
||||
Applying Debians 11-memory-efficiency.dpatch from Eero Tamminen
|
||||
<eero.tamminen@nokia.com> to improve dosfsck memory efficiency:
|
||||
|
||||
* Improves memory efficiency when checking filesystems.
|
||||
|
||||
commit 28da9f286a52acec7df7ad06cb0679e5f828e7f3
|
||||
Author: Daniel Baumann <daniel@debian.org>
|
||||
Date: Fri Sep 26 14:33:28 2008 +0200
|
||||
|
||||
Applying Debians 10-manpage-synopsis.dpatch from Daniel Baumann
|
||||
<daniel@debian.org> to fix manpage synopsis:
|
||||
|
||||
* List alternative binary names in manpage synopsis (Closes: #284983).
|
||||
|
||||
commit f253073021551c9b58d0f2ac262deb3c1b950b06
|
||||
Author: Daniel Baumann <daniel@debian.org>
|
||||
Date: Fri Sep 26 14:32:46 2008 +0200
|
||||
|
||||
Applying Debians 09-manpage-fat32.dpatch from Daniel Baumann
|
||||
<daniel@debian.org> to improve mkdosfs manpage:
|
||||
|
||||
* Don't claim that FAT32 is not choosed automatically (Closes:
|
||||
#414183).
|
||||
|
||||
commit f37c07aec3972cfc0db374d544ee3b27c0b4b20b
|
||||
Author: Daniel Baumann <daniel@debian.org>
|
||||
Date: Fri Sep 26 14:32:23 2008 +0200
|
||||
|
||||
Applying Debians 08-manpage-drop.dpatch from Daniel Baumann
|
||||
<daniel@debian.org> to improve dosfsck manpage:
|
||||
|
||||
* Don't use confusing word 'drop' when 'delete' is meant (Closes:
|
||||
#134100).
|
||||
|
||||
commit 3f970c65586da2f44d2a49b639e89341bbaf1fba
|
||||
Author: Daniel Baumann <daniel@debian.org>
|
||||
Date: Fri Sep 26 14:31:50 2008 +0200
|
||||
|
||||
Applying Debians 07-manpage-spelling.dpatch from Justin Pryzby
|
||||
<justinpryzby@users.sourceforge.net> to fix mkdosfs manpage typos.
|
||||
|
||||
commit 18678ba5f3a10c2a54ffee735651d7a265ae7d54
|
||||
Author: Daniel Baumann <daniel@debian.org>
|
||||
Date: Fri Sep 26 14:30:31 2008 +0200
|
||||
|
||||
Applying Suses dosfstools-2.11_determine-sector-size.patch from Petr
|
||||
Gajdos <pgajdos@suse.cz> to determine mkdosfs sector size automatically:
|
||||
|
||||
* determine sector size of device automatically or if -S parameter
|
||||
present, verify, that it's not under physical sector size
|
||||
|
||||
commit 29753931b078856d78f473cfb6273e111a26891e
|
||||
Author: Daniel Baumann <daniel@debian.org>
|
||||
Date: Fri Sep 26 14:30:03 2008 +0200
|
||||
|
||||
Applying Suses dosfstools-2.11-o_excl.patch from Pavol Rusnak
|
||||
<prusnak@suse.cz> to use O_EXCL in mkdosfs:
|
||||
|
||||
* mkdosfs now opens device with O_EXCL [#238687]
|
||||
|
||||
commit 16bb7b09ad9eaf0fe37a732cabcdbdf975b77d3e
|
||||
Author: Daniel Baumann <daniel@debian.org>
|
||||
Date: Fri Sep 26 14:29:36 2008 +0200
|
||||
|
||||
Applying Debians 04-unaligned-memory.dpatch from Khalid Aziz
|
||||
<khalid_aziz@hp.com> to fix dosfsck unaligned memory accesses:
|
||||
|
||||
* Fix unaligned memory accesses which cause warnings to appear
|
||||
everytime the elilo bootloader script runs. This has led a number
|
||||
of users to believe their install has failed (Closes: #258839).
|
||||
|
||||
commit 1298cc8f37eaa27ca542b8b7186ea5a47a63cd7e
|
||||
Author: Daniel Baumann <daniel@debian.org>
|
||||
Date: Fri Sep 26 13:47:40 2008 +0200
|
||||
|
||||
Applying Fedoras dosfstools-2.11-label.patch from Jeremy Katz
|
||||
<katzj@redhat.com> to add dosfslabel (originally by Peter Jones).
|
||||
|
||||
commit d23890e1d89770d6d2ba58362c2fc4ebafbde15c
|
||||
Author: Daniel Baumann <daniel@debian.org>
|
||||
Date: Fri Sep 26 13:41:14 2008 +0200
|
||||
|
||||
Applying Fedoras dosfstools-2.11-fortify.patch from Jakub Jelinek
|
||||
<jakub@redhat.com> to make it build with -D_FORTIFY_SOURCE=2:
|
||||
|
||||
* This violates -D_FORTIFY_SOURCE=2 (which is stricter than C
|
||||
standard), but isn't actually any buffer overflow. But using memcpy
|
||||
is more efficient anyway.
|
||||
|
||||
commit 7dbd82000e59246c1c2f8c280c4491259e10a767
|
||||
Author: Daniel Baumann <daniel@debian.org>
|
||||
Date: Fri Sep 26 13:40:47 2008 +0200
|
||||
|
||||
Applying Fedoras dosfstools-2.7-argfix.patch (no other information
|
||||
available).
|
||||
|
||||
commit 88f3b3139c72ac11cb3dd3f5afa8dbb2198a8de5
|
||||
Author: Daniel Baumann <daniel@debian.org>
|
||||
Date: Thu Jun 26 12:45:36 2008 +0200
|
||||
|
||||
Adding upstream version 2.11.
|
112
dosfstools/Makefile
Normal file
112
dosfstools/Makefile
Normal file
@ -0,0 +1,112 @@
|
||||
# Makefile
|
||||
#
|
||||
# Copyright (C) 2008 Daniel Baumann <daniel@debian.org>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# On Debian systems, the complete text of the GNU General Public License
|
||||
# can be found in /usr/share/common-licenses/GPL-3 file.
|
||||
|
||||
DESTDIR =
|
||||
PREFIX = /usr/local
|
||||
SBINDIR = $(PREFIX)/sbin
|
||||
DOCDIR = $(PREFIX)/share/doc
|
||||
MANDIR = $(PREFIX)/share/man
|
||||
|
||||
#OPTFLAGS = -O2 -fomit-frame-pointer -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
|
||||
OPTFLAGS = -O2 -fomit-frame-pointer $(shell getconf LFS_CFLAGS)
|
||||
#WARNFLAGS = -Wall -pedantic -std=c99
|
||||
WARNFLAGS = -Wall
|
||||
DEBUGFLAGS = -g
|
||||
CFLAGS += $(OPTFLAGS) $(WARNFLAGS) $(DEBUGFLAGS)
|
||||
|
||||
VPATH = src
|
||||
|
||||
all: build
|
||||
|
||||
build: dosfsck dosfslabel mkdosfs
|
||||
|
||||
dosfsck: boot.o check.o common.o fat.o file.o io.o lfn.o dosfsck.o
|
||||
|
||||
dosfslabel: boot.o check.o common.o fat.o file.o io.o lfn.o dosfslabel.o
|
||||
|
||||
mkdosfs: mkdosfs.o
|
||||
|
||||
rebuild: distclean build
|
||||
|
||||
install: install-bin install-doc install-man
|
||||
|
||||
install-bin: build
|
||||
install -d -m 0755 $(DESTDIR)/$(SBINDIR)
|
||||
install -m 0755 dosfsck dosfslabel mkdosfs $(DESTDIR)/$(SBINDIR)
|
||||
|
||||
ln -sf dosfsck $(DESTDIR)/$(SBINDIR)/fsck.msdos
|
||||
ln -sf dosfsck $(DESTDIR)/$(SBINDIR)/fsck.vfat
|
||||
ln -sf mkdosfs $(DESTDIR)/$(SBINDIR)/mkfs.msdos
|
||||
ln -sf mkdosfs $(DESTDIR)/$(SBINDIR)/mkfs.vfat
|
||||
|
||||
install-doc:
|
||||
install -d -m 0755 $(DESTDIR)/$(DOCDIR)/dosfstools
|
||||
install -p -m 0644 ChangeLog doc/* $(DESTDIR)/$(DOCDIR)/dosfstools
|
||||
|
||||
install-man:
|
||||
install -d -m 0755 $(DESTDIR)/$(MANDIR)/man8
|
||||
install -p -m 0644 man/*.8 $(DESTDIR)/$(MANDIR)/man8
|
||||
|
||||
ln -sf dosfsck.8 $(DESTDIR)/$(MANDIR)/man8/fsck.msdos.8
|
||||
ln -sf dosfsck.8 $(DESTDIR)/$(MANDIR)/man8/fsck.vfat.8
|
||||
ln -sf mkdosfs.8 $(DESTDIR)/$(MANDIR)/man8/mkfs.msdos.8
|
||||
ln -sf mkdosfs.8 $(DESTDIR)/$(MANDIR)/man8/mkfs.vfat.8
|
||||
|
||||
uninstall: uninstall-bin uninstall-doc uninstall-man
|
||||
|
||||
uninstall-bin:
|
||||
rm -f $(DESTDIR)/$(SBINDIR)/dosfsck
|
||||
rm -f $(DESTDIR)/$(SBINDIR)/dosfslabel
|
||||
rm -f $(DESTDIR)/$(SBINDIR)/mkdosfs
|
||||
|
||||
rm -f $(DESTDIR)/$(SBINDIR)/fsck.msdos
|
||||
rm -f $(DESTDIR)/$(SBINDIR)/fsck.vfat
|
||||
rm -f $(DESTDIR)/$(SBINDIR)/mkfs.msdos
|
||||
rm -f $(DESTDIR)/$(SBINDIR)/mkfs.vfat
|
||||
|
||||
rmdir --ignore-fail-on-non-empty $(DESTDIR)/$(SBINDIR)
|
||||
|
||||
uninstall-doc:
|
||||
rm -rf $(DESTDIR)/$(DOCDIR)/dosfstools
|
||||
|
||||
rmdir --ignore-fail-on-non-empty $(DESTDIR)/$(DOCDIR)
|
||||
|
||||
uninstall-man:
|
||||
rm -f $(DESTDIR)/$(MANDIR)/man8/dosfsck.8
|
||||
rm -f $(DESTDIR)/$(MANDIR)/man8/dosfslabel.8
|
||||
rm -f $(DESTDIR)/$(MANDIR)/man8/mkdosfs.8
|
||||
|
||||
rm -f $(DESTDIR)/$(MANDIR)/man8/fsck.msdos.8
|
||||
rm -f $(DESTDIR)/$(MANDIR)/man8/fsck.vfat.8
|
||||
rm -f $(DESTDIR)/$(MANDIR)/man8/mkfs.msdos.8
|
||||
rm -f $(DESTDIR)/$(MANDIR)/man8/mkfs.vfat.8
|
||||
|
||||
rmdir --ignore-fail-on-non-empty $(DESTDIR)/$(MANDIR)/man8
|
||||
rmdir --ignore-fail-on-non-empty $(DESTDIR)/$(MANDIR)
|
||||
|
||||
reinstall: distclean install
|
||||
|
||||
clean:
|
||||
rm -f *.o
|
||||
|
||||
distclean: clean
|
||||
rm -f dosfsck dosfslabel mkdosfs
|
||||
|
||||
.PHONY: build rebuild install install-bin install-doc install-man uninstall uninstall-bin uninstall-doc uninstall-man reinstall clean distclean
|
18
dosfstools/bin/Nindent
Executable file
18
dosfstools/bin/Nindent
Executable file
@ -0,0 +1,18 @@
|
||||
#!/bin/sh
|
||||
PARAM="-npro -kr -i4 -ts8 -sob -l80 -ss -ncs -cp1"
|
||||
RES=`indent --version`
|
||||
V1=`echo $RES | cut -d' ' -f3 | cut -d'.' -f1`
|
||||
V2=`echo $RES | cut -d' ' -f3 | cut -d'.' -f2`
|
||||
V3=`echo $RES | cut -d' ' -f3 | cut -d'.' -f3`
|
||||
if [ $V1 -gt 2 ]; then
|
||||
PARAM="$PARAM -il0"
|
||||
elif [ $V1 -eq 2 ]; then
|
||||
if [ $V2 -gt 2 ]; then
|
||||
PARAM="$PARAM -il0";
|
||||
elif [ $V2 -eq 2 ]; then
|
||||
if [ $V3 -ge 10 ]; then
|
||||
PARAM="$PARAM -il0"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
exec indent $PARAM "$@"
|
41
dosfstools/doc/ANNOUNCE.mkdosfs
Normal file
41
dosfstools/doc/ANNOUNCE.mkdosfs
Normal file
@ -0,0 +1,41 @@
|
||||
Announcing the release of mkdosfs version 0.3b (Yggdrasil)
|
||||
|
||||
It seems I didn't get the bug completely fixed in 0.3a. Some
|
||||
borderline cases would still allocate too many sectors for the FAT.
|
||||
Again, nothing to worry about, just a nitpick -- this one would only
|
||||
in certain cases add one sector per FAT.
|
||||
|
||||
Announcing the release of mkdosfs version 0.3a (Yggdrasil)
|
||||
|
||||
Fixed a bug which would cause too many sectors to be reserved for the
|
||||
FAT (filesystem will still work fine, but have slightly less space
|
||||
available).
|
||||
|
||||
Announcing the release of mkdosfs version 0.3 (Yggdrasil)
|
||||
|
||||
This version correctly handles even very large filesystems, and
|
||||
properly supports the modern (3.3+) DOS bootsector format, including a
|
||||
message printed on boot attempts.
|
||||
|
||||
Peter Anvin
|
||||
Yggdrasil Computing, Inc.
|
||||
hpa@yggdrasil.com
|
||||
|
||||
--------------
|
||||
|
||||
Announcing the release of mkdosfs version 0.2
|
||||
|
||||
|
||||
I've just uploaded mkdosfs to sunsite.unc.edu. It works in a similar way
|
||||
to Remy Card's mke2fs, but creates an MS-DOS file system.
|
||||
|
||||
The filename is mkdosfs-0.2.tar.gz.
|
||||
|
||||
This second release should fix a small bug that could lead to FAT sizes that
|
||||
Linux's dosfs would accept but MS-DOS wouldn't.
|
||||
|
||||
The archive contains a manual page, binary and source versions.
|
||||
|
||||
|
||||
Dave Hudson
|
||||
dave@humbug.demon.co.uk
|
10
dosfstools/doc/ChangeLog.dosfsck
Normal file
10
dosfstools/doc/ChangeLog.dosfsck
Normal file
@ -0,0 +1,10 @@
|
||||
Changes from version 0 to 1
|
||||
===========================
|
||||
|
||||
- fixed an off-by-two error in check.c:check_file
|
||||
- fixed marking clusters bad in fat.c:set_fat
|
||||
- fat.c:reclaim_free was also reclaiming bad clusters.
|
||||
- fixed many incorrect byte sex conversions in check.c and fat.c
|
||||
- -t and -w now require -a or -r
|
||||
- added option -d to drop files.
|
||||
- added option -u to try to "undelete" non-directory files.
|
161
dosfstools/doc/ChangeLog.dosfstools-2.x
Normal file
161
dosfstools/doc/ChangeLog.dosfstools-2.x
Normal file
@ -0,0 +1,161 @@
|
||||
version 2.11
|
||||
============
|
||||
|
||||
- all: don't use own llseek() anymore, glibc lseek() does everything we need
|
||||
- dosfsck: lfn.c: avoid segfault
|
||||
- dosfsck: check.c, lfn.c: check for orphaned LFN slots
|
||||
- dosfsck: check.c alloc_rootdir_entry(): set owner of newly alloced clusters
|
||||
- dosfsck: dosfsck.h: better use <byteswap.h> for byte swapping
|
||||
- dosfsck: io.c: added code for real DOS
|
||||
- mkdosfs: raised FAT12_THRESHOLD from 4078 to 4085, introduced MIN_CLUST_32
|
||||
- mkdosfs: fix loop device size
|
||||
- mkdosfs: by default, use FAT32 on devices >= 512MB
|
||||
- mkdosfs: fix a memory leak (blank_sector)
|
||||
- mkdosfs: fix parsing of number of blocks on command line, so that numbers
|
||||
>2G can be used
|
||||
- mkdosfs: add 'b' to getopt() string so this option can be used :)
|
||||
- mkdosfs: fix parsing of -i arg (should be unsigned)
|
||||
- mkdosfs: change default permissions of created images (-C) to 0666 & ~umask
|
||||
- mkdosfs: relax geometry check: if HDIO_GETGEO fails, print a warning and
|
||||
default to H=255,S=63
|
||||
- dosfsck: new option -n (no-op): just check non-interactively, but
|
||||
don't write anything to filesystem
|
||||
- A few #include changes to support compilation with linux 2.6
|
||||
headers (thanks to Jim Gifford <jim@jg555.com>)
|
||||
- dosfsck: remove directory entries pointing to start cluster 0, if they're
|
||||
not "." or ".." entries that should actually point to the root dir
|
||||
(pointed out by Thomas Winkler <twinkler@sysgo.de>)
|
||||
- mkdosfs: new option -h to set number of hidden sectors
|
||||
(thanks to Godwin Stewart <gstewart@spamcop.net>)
|
||||
- all: updated my mail address everywhere...
|
||||
|
||||
version 2.10
|
||||
============
|
||||
|
||||
- dosfsck: various 64-bit fixes and removed some warnings by Michal
|
||||
Cihar <mcihar@suse.cz>
|
||||
- mkdosfs: better error message if called without parameters (also
|
||||
suggested by Michal)
|
||||
|
||||
version 2.9
|
||||
===========
|
||||
|
||||
- dosfsck: if EOF from stdin, exit with error code
|
||||
- dosfsck: Fix potential for "Internal error: next_cluster on bad cluster".
|
||||
- dosfsck: When clearing long file names, don't overwrite the dir
|
||||
entries with all zeros, but put 0xe5 into the first byte.
|
||||
Otherwise, some OSes stop reading the directory at that point...
|
||||
- dosfsck: in statistics printed by -v, fix 32bit overflow in number
|
||||
of data bytes.
|
||||
- dosfsck: fix an potential overflow in "too many clusters" check
|
||||
- dosfsck: fix 64bit problem in fat.c (Debian bug #152769)
|
||||
- dosfsck: allow FAT size > 32MB.
|
||||
- dosfsck: allow for only one FAT
|
||||
- dosfsck: with -v, also check that last sector of the filesystem can
|
||||
be read (in case a partition is smaller than the fs thinks)
|
||||
- mkdosfs: add note in manpage that creating bootable filesystems is
|
||||
not supported.
|
||||
- mkdosfs: better error message with pointer to -I if target is a
|
||||
full-disk device.
|
||||
|
||||
version 2.8
|
||||
===========
|
||||
|
||||
- dosfsck: Fixed endless loop whenever a volume label was present.
|
||||
|
||||
version 2.7
|
||||
===========
|
||||
|
||||
- dosfsck: Don't check volume label for bad characters, everything
|
||||
seems to be allowed there... Also ignore duplicate names where one of
|
||||
them is a volume label.
|
||||
|
||||
version 2.6
|
||||
===========
|
||||
|
||||
- mkdosfs: Added correct heads definition for 2.88M floppies if not
|
||||
created via loopback.
|
||||
- dosfsck: If boot sector and its backup are different (FAT32), offer
|
||||
to write the backup to sector 0. (tnx to Pavel Roskin for this)
|
||||
- For 64 bit alpha, struct bootsector in dosfsck.h must be defined
|
||||
with __attribute__((packed)).
|
||||
- mkdosfs now actually accepts -R option. (tnx to David Kerrawn)
|
||||
- Fixed typo in dosfsck boot.c (recognition of boot signature in FSINFO)
|
||||
- Various compilation fixes for 2.4 kernel headers and for ia64.
|
||||
|
||||
version 2.5
|
||||
===========
|
||||
|
||||
- The llseek() implementation for alpha didn't really work; fixed it.
|
||||
|
||||
version 2.4
|
||||
===========
|
||||
|
||||
- Fix compiling problem on alpha (made a silly typo...)
|
||||
|
||||
version 2.3
|
||||
===========
|
||||
|
||||
- mkdosfs: Fixed usage message (printed only "bad address").
|
||||
- both: made man pages and usage statements more consistent.
|
||||
- both: fix llseek function for alpha.
|
||||
- dosfsck: fix reading of unaligned fields in boot sector for alpha.
|
||||
- dosfsck: fixed renaming of files (extension wasn't really written).
|
||||
|
||||
version 2.2
|
||||
===========
|
||||
|
||||
- Added dosfsck/COPYING, putting dosfsck officially under GPL (Werner
|
||||
and I agree that it should be GPL).
|
||||
- mkdosfs: Allow creation of a 16 bit FAT on filesystems that are too
|
||||
small for it if the user explicitly selected FAT16 (but a warning
|
||||
is printed). Formerly, you got the misleading error message "make
|
||||
the fs a bit smaller".
|
||||
- dosfsck: new option -y as synonym for -y; for compability with
|
||||
other fs checkers, which also accept this option.
|
||||
- dosfsck: Now prints messages similar to e2fsck: at start version
|
||||
and feature list; at end number of files (and directories) and
|
||||
number of used/total clusters. This makes the printouts of *fsck at
|
||||
boot time nicer.
|
||||
- dosfsck: -a (auto repair) now turns on -f (salvage files), too. -a
|
||||
should act as non-destructive as possible, so lost clusters should
|
||||
be assigned to files. Otherwise the data in them might be
|
||||
overwritten later.
|
||||
- dosfsck: Don't drop a directory with lots of bad entries in
|
||||
auto-repair mode for the same reason as above.
|
||||
- dosfsck: avoid deleting the whole FAT32 root dir if something is
|
||||
wrong with it (bad start cluster or the like).
|
||||
- general: also create symlinks {mkfs,fsck}.vfat.8 to the respective
|
||||
real man pages.
|
||||
|
||||
version 2.1
|
||||
===========
|
||||
|
||||
- Fix some forgotten loff_t's for filesystems > 4GB. (Thanks to
|
||||
<ki@kretz.co.at>).
|
||||
- Fix typo in mkdosfs manpage.
|
||||
- Removed inclusion of <linux/loop.h> from mkdosfs.c; it's unnecessary and
|
||||
caused problems in some environments.
|
||||
- Fix condition when to expect . and .. entries in a directory. (Was
|
||||
wrong for non-FAT32 if first entry in root dir was a directory also.)
|
||||
- Also create mkfs.vfat and fsck.vfat symlinks, so that also
|
||||
filesystems listed with type "vfat" in /etc/fstab can be
|
||||
automatically checked.
|
||||
|
||||
version 2.0
|
||||
===========
|
||||
|
||||
- merge of mkdosfs and dosfstools in one package
|
||||
- new maintainer: Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de>
|
||||
- FAT32 support in both mkdosfs and dosfsck
|
||||
- VFAT (long filename) support in dosfsck
|
||||
- Support for Atari variant of MS-DOS filesystem in both tools
|
||||
- Working support for big-endian systems in both tools
|
||||
- Better support for loop devices in mkdosfs: usual floppy sizes are
|
||||
detected and media byte etc. set accordingly; if loop fs has no
|
||||
standard floppy size, use hd params
|
||||
(mainly by Giuliano Procida <gpp10@cus.cam.ac.uk>)
|
||||
- Removed lots of gcc warnings
|
||||
- Fixed some minor calculation bugs in mkdosfs.
|
||||
|
||||
For change logs previous to 2.0, see the CHANGES files in the subdirectories.
|
18
dosfstools/doc/ChangeLog.mkdosfs
Normal file
18
dosfstools/doc/ChangeLog.mkdosfs
Normal file
@ -0,0 +1,18 @@
|
||||
28th January 1995 H. Peter Anvin (hpa@yggdrasil.com)
|
||||
|
||||
Better algorithm to select cluster sizes on large filesystems.
|
||||
Added bogus boot sector code that on attempts to boot prints a
|
||||
message (which can be chosen at mkdosfs time) and lets the user
|
||||
press any key and try again. Corrected support for 1.2 Mb
|
||||
floppies. mkdosfs now generates the extended bootsector
|
||||
(superblock) format of DOS 3.3+, with support for volume ID's and
|
||||
volume labels (volume labels are also written to the root
|
||||
directory, as they should).
|
||||
|
||||
18th February 1994 Dave Hudson (dave@humbug.demon.co.uk)
|
||||
|
||||
Released version 0.2 - clears a bug in the FAT sizing code.
|
||||
|
||||
1st September 1993 Dave Hudson (dave@humbug.demon.co.uk)
|
||||
|
||||
Released version 0.1 - ALPHA release of mkdosfs
|
60
dosfstools/doc/README.dosfsck
Normal file
60
dosfstools/doc/README.dosfsck
Normal file
@ -0,0 +1,60 @@
|
||||
dosfsck, version 1
|
||||
==================
|
||||
|
||||
WARNING: This is ALPHA test software. Use at your own risk.
|
||||
|
||||
dosfsck is the Linux equivalent of PC/MS-DOS' CHKDSK. It checks the
|
||||
consistency of PC/MS-DOS file systems and optionally tries to repair
|
||||
them. The tests dosfsck performs are described in the man page.
|
||||
|
||||
dosfsck needs header files from dosfs.9 (or later) to compile.
|
||||
|
||||
Before using dosfsck to repair a file system that contains data of any
|
||||
value, you should verify that dosfsck is able to correct all reported
|
||||
errors. (Except fatal errors and those reported as unfixable, of
|
||||
course.) In order to do this, run it with the -V option, e.g.
|
||||
|
||||
dosfsck -V /dev/sda1 (automatic check)
|
||||
or dosfsck -V -r /dev/sda1 (interactive check and repair)
|
||||
|
||||
dosfsck will perform two passes: in the first pass, inconsistencies are
|
||||
detected and a list of changes to correct the problems is generated. In
|
||||
the second pass, those changes are applied whenever dosfsck reads data
|
||||
from disk. Hence no fixable errors should be reported in the second
|
||||
pass if the first pass was successful.
|
||||
|
||||
Please notify the author if fixable errors are reported in the second
|
||||
pass.
|
||||
|
||||
After verifying that dosfsck appears to be able to perform the desired
|
||||
operations, either confirm that you want the changes to be performed
|
||||
(if dosfsck was started with -r) or re-run dosfsck with the -a option
|
||||
(if it was started without -r).
|
||||
|
||||
Please send bug reports, comments, flames, etc. to
|
||||
almesber@nessie.cs.id.ethz.ch or almesber@bernina.ethz.ch
|
||||
|
||||
- Werner
|
||||
|
||||
FAT32 and LFN support
|
||||
=====================
|
||||
|
||||
I've finally implemented some of the new features of MS-DOS
|
||||
filesystems: FAT32 and long filenames.
|
||||
|
||||
FAT32 is automatically detected and of course the different FAT
|
||||
structure is handled. (Internally many changes were needed, so 32 bit
|
||||
variables for all cluster numbers and 64 bit vars for offsets inside
|
||||
the filesystem.) New checks for FAT32 are most notably on the backup
|
||||
boot sector and the new info sector. Also the possibility that the
|
||||
root directory resides in a cluster chain (instead of in a static
|
||||
area) on FAT32 is handled.
|
||||
|
||||
dosfscheck also knows about VFAT long filenames now. It parses those
|
||||
names and uses them in listings etc. when available. There are also
|
||||
some checks on the (cruel) structure of how LFNs are stored and some
|
||||
attempts to fix problems.
|
||||
|
||||
- Roman <roman@hodek.net>
|
||||
|
||||
BTW, version 2 isn't ALPHA anymore :-)
|
60
dosfstools/doc/README.dosfstools-2.x
Normal file
60
dosfstools/doc/README.dosfstools-2.x
Normal file
@ -0,0 +1,60 @@
|
||||
|
||||
Atari format support
|
||||
====================
|
||||
|
||||
Both mkdosfs and dosfsck now can also handle the Atari variation of
|
||||
the MS-DOS filesystem format. The Atari format has some minor
|
||||
differences, some caused by the different machine architecture (m68k),
|
||||
some being "historic" (Atari didn't change some things that M$
|
||||
changed).
|
||||
|
||||
Both tools automatically select Atari format if they run on an Atari.
|
||||
Additionally the -A switch toggles between Atari and MS-DOS format.
|
||||
I.e., on an Atari it selects plain DOS format, on any other machine it
|
||||
switches to Atari format.
|
||||
|
||||
The differences are in detail:
|
||||
|
||||
- Atari TOS doesn't like cluster sizes != 2, so the usual solution
|
||||
for bigger partitions was to increase the logical sector size. So
|
||||
mkdosfs can handle sector sizes != 512 now, you can also manually
|
||||
select it with the -S option. On filesystems larger than approx. 32
|
||||
MB, the sector size is automatically increased (stead of the
|
||||
cluster size) to make the filesystem fit. mkdosfs will always use 2
|
||||
sectors per cluster (also with the floppy standard configurations),
|
||||
except when directed otherwise on the command line.
|
||||
|
||||
- From the docs, all values between 0xfff8 and 0xffff in the FAT mark
|
||||
an end-of-file. However, DOS usually uses 0xfff8 and Atari 0xffff.
|
||||
This seems to be only an consmetic difference. At least TOS doesn't
|
||||
complain about 0xffff EOF marks. Don't know what DOS thinks of
|
||||
0xfff8 :-) Anyway, both tools use the EOF mark common to the
|
||||
system (DOS/Atari).
|
||||
|
||||
- Something similar of the bad cluster marks: On Atari the FAT values
|
||||
0xfff0 to 0xfff7 are used for this, under DOS only 0xfff7 (the
|
||||
others can be normal cluster numbers, allowing 7 more clusters :-)
|
||||
However, both systems usually mark with 0xfff7. Just dosfsck has to
|
||||
interpret 0xfff0...0xfff7 differently.
|
||||
|
||||
- Some fields in the boot sector are interpreted differently. For
|
||||
example, Atari has a disk serial number (used to aid disk change
|
||||
detection) where DOS stores the system name; the 'hidden' field is
|
||||
32 bit for DOS, but 16 bit for Atari, and there's no 'total_sect'
|
||||
field; the 12/16 bit FAT decision is different: it's not based on
|
||||
the number of clusters, but always FAT12 on floppies and FAT16 on
|
||||
hard disks. mkdosfs nows about these differences and constructs the
|
||||
boot sector accordingly.
|
||||
|
||||
- In dosfsck, the boot sector differences also have to known, to not
|
||||
warn about things that are no error on Atari. In addition, most
|
||||
Atari formatting tools fill the 'tracks' and 'heads' fields with 0
|
||||
for hard disks, because they're meaningless on SCSI disks (Atari
|
||||
has/had no IDE). Due to this, the check that they should be
|
||||
non-zero is switched off.
|
||||
|
||||
- Under Atari TOS, some other characters are illegal in filenames:
|
||||
'<', '>', '|', '"', and ':' are allowed, but all non-ASCII chars
|
||||
(codes >= 128) are forbidden.
|
||||
|
||||
- Roman <Roman.Hodek@informatik.uni-erlangen.de>
|
50
dosfstools/doc/README.mkdosfs
Normal file
50
dosfstools/doc/README.mkdosfs
Normal file
@ -0,0 +1,50 @@
|
||||
mkdosfs - Make DOS file system utilty.
|
||||
|
||||
|
||||
I wrote this, partially to complement the dosfsck utility written by Werner
|
||||
Almesberger (who graciously gave me some pointers when I asked for some
|
||||
advice about writing this code), and also to avoid me having to boot DOS
|
||||
just to create data partitions (I use Linux to back up DOS :-) ).
|
||||
|
||||
The code is really derived from Remy Card's mke2fs utility - I used this as a
|
||||
framework, although all of the file system specific stuff was removed and the
|
||||
DOS stuff inserted. I believe originally mke2fs was based on Linus' mkfs
|
||||
code, hence the acknowledgements in the source code.
|
||||
|
||||
Neither Remy nor Linus have had any involvement with mkdosfs, so if there are
|
||||
any bugs they're almost certainly "all my own work".
|
||||
|
||||
The code has been available for ftp since 1st September 1993, and I have yet
|
||||
to receive any bug reports from users. I don't know of any bugs, but if you
|
||||
do find a bug or have any constructive comments, please mail me!
|
||||
|
||||
The only bug I found with version 0.1 was an obscure fault that could lead
|
||||
to an invalid (for MS-DOS, not Linux's dos fs) number of sectors used in the
|
||||
file allocation table(s).
|
||||
|
||||
|
||||
Dave Hudson
|
||||
dave@humbug.demon.co.uk
|
||||
|
||||
|
||||
FAT32 support
|
||||
=============
|
||||
|
||||
mkdosfs now can also create filesystems in the new FAT32 format. To do
|
||||
this, give mkdosfs a "-F 32" option. FAT32 isn't selected
|
||||
automatically (yet), even if very large clusters are needed with
|
||||
FAT16. With FAT32 you have two additional options, -R to select the
|
||||
number of reserved sectors (usually 32), and -b to select the location
|
||||
of the backup boot sector (default 6). Of course such a backup is
|
||||
created, as well as the new info sector. On FAT32, the root directory
|
||||
is always created as a cluster chain. Sorry, there's no switch to
|
||||
generate an old static root dir.
|
||||
|
||||
One bigger bug fix besides FAT32 was to reject filesystems that need a
|
||||
16 bit FAT to fit all possible clusters, but the bigger FAT needs some
|
||||
more sectors, so the total number of clusters drop below the border
|
||||
where MS-DOS expects a 12 bit FAT. So such filesystems would be FAT16,
|
||||
but interpreted as FAT32 by DOS. The fix is to reduce filesystem size
|
||||
a bit.
|
||||
|
||||
- Roman <roman@hodek.net>
|
14
dosfstools/doc/TODO.dosfstools-2.x
Normal file
14
dosfstools/doc/TODO.dosfstools-2.x
Normal file
@ -0,0 +1,14 @@
|
||||
-*- mode: indented-text -*-
|
||||
|
||||
- dosfsck: Better checking of file times: ctime <= mtime <= atime
|
||||
|
||||
- mkdosfs: If /etc/bootsect.dos (or similar) exists, use it as a
|
||||
template for generating boot sectors. This way, you can, e.g., make
|
||||
bootable DOS disks.
|
||||
|
||||
Addendum: Don't know if that's so wise... There are really many
|
||||
variants of DOS/Windows bootcode out in the wild, and the code is
|
||||
proprietary, too.
|
||||
|
||||
- dosfsck: read-only sector test (-t without -a or -r); just print
|
||||
out errors.
|
112
dosfstools/man/dosfsck.8
Normal file
112
dosfstools/man/dosfsck.8
Normal file
@ -0,0 +1,112 @@
|
||||
.TH DOSFSCK 8 "2010\-01\-31" "3.0.9" "check and repair MS\-DOS filesystems"
|
||||
|
||||
.SH NAME
|
||||
\fBdosfsck\fR \- check and repair MS\-DOS filesystems
|
||||
|
||||
.SH SYNOPSIS
|
||||
\fBdosfsck\fR|\fBfsck.msdos\fR|\fBfsck.vfat\fR [\-aAflnrtvVwy] [\-d \fIPATH\fR \-d\ \fI...\fR] [\-u\ \fIPATH\fR \-u \fI...\fR] \fIDEVICE\fR
|
||||
|
||||
.SH DESCRIPTION
|
||||
\fBdosfsck\fR verifies the consistency of MS\-DOS filesystems and optionally tries to repair them.
|
||||
.PP
|
||||
The following filesystem problems can be corrected (in this order):
|
||||
.IP "*" 4
|
||||
FAT contains invalid cluster numbers. Cluster is changed to EOF.
|
||||
.IP "*" 4
|
||||
File's cluster chain contains a loop. The loop is broken.
|
||||
.IP "*" 4
|
||||
Bad clusters (read errors). The clusters are marked bad and they are removed from files owning them. This check is optional.
|
||||
.IP "*" 4
|
||||
Directories with a large number of bad entries (probably corrupt). The directory can be deleted.
|
||||
.IP "*" 4
|
||||
Files . and .. are non\-directories. They can be deleted or renamed.
|
||||
.IP "*" 4
|
||||
Directories . and .. in root directory. They are deleted.
|
||||
.IP "*" 4
|
||||
Bad filenames. They can be renamed.
|
||||
.IP "*" 4
|
||||
Duplicate directory entries. They can be deleted or renamed.
|
||||
.IP "*" 4
|
||||
Directories with non\-zero size field. Size is set to zero.
|
||||
.IP "*" 4
|
||||
Directory . does not point to parent directory. The start pointer is adjusted.
|
||||
.IP "*" 4
|
||||
Directory .. does not point to parent of parent directory. The start pointer is adjusted.
|
||||
.IP "*" 4
|
||||
Start cluster number of a file is invalid. The file is truncated.
|
||||
.IP "*" 4
|
||||
File contains bad or free clusters. The file is truncated.
|
||||
.IP "*" 4
|
||||
File's cluster chain is longer than indicated by the size fields. The file is truncated.
|
||||
.IP "*" 4
|
||||
Two or more files share the same cluster(s). All but one of the files are truncated. If the file being truncated is a directory file that has already been read, the filesystem check is restarted after truncation.
|
||||
.IP "*" 4
|
||||
File's cluster chain is shorter than indicated by the size fields. The file is truncated.
|
||||
.IP "*" 4
|
||||
Clusters are marked as used but are not owned by a file. They are marked as free.
|
||||
.PP
|
||||
Additionally, the following problems are detected, but not repaired:
|
||||
.IP "*" 4
|
||||
Invalid parameters in boot sector.
|
||||
.IP "*" 4
|
||||
Absence of . and .. entries in non\-root directories
|
||||
.PP
|
||||
When \fBdosfsck\fR checks a filesystem, it accumulates all changes in memory and performs them only after all checks are complete. This can be disabled with the \fB\-w\fR option.
|
||||
|
||||
.SH OPTIONS
|
||||
.IP "\fB\-a\fR" 4
|
||||
Automatically repair the filesystem. No user intervention is necessary. Whenever there is more than one method to solve a problem, the least destructive approach is used.
|
||||
.IP "\fB\-A\fR" 4
|
||||
Use Atari variation of the MS\-DOS filesystem. This is default if \fBdosfsck\fR is run on an Atari, then this option turns off Atari format. There are some minor differences in Atari format: Some boot sector fields are interpreted slightly different, and the special FAT entries for end\-of\-file and bad cluster can be different. Under MS\-DOS 0xfff8 is used for EOF and Atari employs 0xffff by default, but both systems recognize all values from 0xfff8...0xffff as end\-of\-file. MS\-DOS uses only 0xfff7 for bad clusters, where on Atari values 0xfff0...0xfff7 are for this purpose (but the standard value is still 0xfff7).
|
||||
.IP "\fB\-d\fR" 4
|
||||
Delete the specified file. If more that one file with that name exists, the first one is deleted.
|
||||
.IP "\fB\-f\fR" 4
|
||||
Salvage unused cluster chains to files. By default, unused clusters are added to the free disk space except in auto mode (\fB\-a\fR).
|
||||
.IP "\fB\-l\fR" 4
|
||||
List path names of files being processed.
|
||||
.IP "\fB\-n\fR" 4
|
||||
No\-operation mode: non\-interactively check for errors, but don't write
|
||||
anything to the filesystem.
|
||||
.IP "\fB\-r\fR" 4
|
||||
Interactively repair the filesystem. The user is asked for advice whenever
|
||||
there is more than one approach to fix an inconsistency.
|
||||
.IP "\fB\-t\fR" 4
|
||||
Mark unreadable clusters as bad.
|
||||
.IP "\fB\-u\fR" 4
|
||||
Try to undelete the specified file. \fBdosfsck\fR tries to allocate a chain of contiguous unallocated clusters beginning with the start cluster of the undeleted file.
|
||||
.IP "\fB\-v\fR" 4
|
||||
Verbose mode. Generates slightly more output.
|
||||
.IP "\fB\-V\fR" 4
|
||||
Perform a verification pass. The filesystem check is repeated after the first run. The second pass should never report any fixable errors. It may take considerably longer than the first pass, because the first pass may have generated long list of modifications that have to be scanned for each disk read.
|
||||
.IP "\fB\-w\fR" 4
|
||||
Write changes to disk immediately.
|
||||
.IP "\fB\-y\fR" 4
|
||||
Same as \fB\-a\fR (automatically repair filesystem) for compatibility with other fsck tools.
|
||||
.PP
|
||||
\fBNote:\fR If \fB\-a\fR and \fB\-r\fR are absent, the filesystem is only checked, but not repaired.
|
||||
|
||||
.SH "EXIT STATUS"
|
||||
.IP "0" 4
|
||||
No recoverable errors have been detected.
|
||||
.IP "1" 4
|
||||
Recoverable errors have been detected or \fBdosfsck\fR has discovered an internal inconsistency.
|
||||
.IP "2" 4
|
||||
Usage error. \fBdosfsck\fR did not access the filesystem.
|
||||
|
||||
.SH FILES
|
||||
.IP "fsck0000.rec, fsck0001.rec, ..." 4
|
||||
When recovering from a corrupted filesystem, \fBdosfsck\fR dumps recovered data into files named 'fsckNNNN.rec' in the top level directory of the filesystem.
|
||||
|
||||
.SH BUGS
|
||||
Does not create . and .. files where necessary. Does not remove entirely empty directories. Should give more diagnostic messages. Undeleting files should use a more sophisticated algorithm.
|
||||
|
||||
.SH SEE ALSO
|
||||
\fBdosfslabel\fR(8)
|
||||
.br
|
||||
\fBmkdosfs\fR(8)
|
||||
|
||||
.SH HOMEPAGE
|
||||
More information about \fBdosfsck\fR and \fBdosfstools\fR can be found at <\fIhttp://www.daniel\-baumann.ch/software/dosfstools/\fR>.
|
||||
|
||||
.SH AUTHORS
|
||||
\fBdosfstools\fR were written by Werner Almesberger <\fIwerner.almesberger@lrc.di.epfl.ch\fR>, Roman Hodek <\fIRoman.Hodek@informatik.uni-erlangen.de\fR>, and others. The current maintainer is Daniel Baumann <\fIdaniel@debian.org\fR>.
|
29
dosfstools/man/dosfslabel.8
Normal file
29
dosfstools/man/dosfslabel.8
Normal file
@ -0,0 +1,29 @@
|
||||
.TH DOSFSLABEL 8 "2010\-01\-31" "3.0.9" "set or get MS\-DOS filesystem label"
|
||||
|
||||
.SH NAME
|
||||
\fBdosfslabel\fR \- set or get MS\-DOS filesystem label
|
||||
|
||||
.SH SYNOPSIS
|
||||
\fBdosfslabel\fR \fIDEVICE\fR [\fILABEL\fR]
|
||||
|
||||
.SH DESCRIPTION
|
||||
\fBdosfslabel\fR set or gets a MS\-DOS filesystem label from a given device.
|
||||
.PP
|
||||
If the label is omitted, then the label name of the specified device is written on the standard output. A label can't be longer than 11 characters.
|
||||
|
||||
.SH OPTIONS
|
||||
.IP "\fB\-h\fR, \fB\-\-help\fR" 4
|
||||
Displays a help message.
|
||||
.IP "\fB\-V\fR, \fB\-\-version\fR" 4
|
||||
Shows version.
|
||||
|
||||
.SH SEE ALSO
|
||||
\fBdosfsck\fR(8)
|
||||
.br
|
||||
\fBmkdosfs\fR(8)
|
||||
|
||||
.SH HOMEPAGE
|
||||
More information about \fBdosfsck\fR and \fBdosfstools\fR can be found at <\fIhttp://www.daniel\-baumann.ch/software/dosfstools/\fR>.
|
||||
|
||||
.SH AUTHORS
|
||||
\fBdosfstools\fR were written by Werner Almesberger <\fIwerner.almesberger@lrc.di.epfl.ch\fR>, Roman Hodek <\fIRoman.Hodek@informatik.uni-erlangen.de\fR>, and others. The current maintainer is Daniel Baumann <\fIdaniel@debian.org\fR>.
|
224
dosfstools/man/mkdosfs.8
Normal file
224
dosfstools/man/mkdosfs.8
Normal file
@ -0,0 +1,224 @@
|
||||
.\" -*- nroff -*-
|
||||
.TH MKDOSFS 8 "5 May 1995" "Version 2.x"
|
||||
.SH NAME
|
||||
.B mkdosfs
|
||||
\- create an MS-DOS file system under Linux
|
||||
.SH SYNOPSIS
|
||||
.B mkdosfs|mkfs.msdos|mkfs.vfat
|
||||
[
|
||||
.B \-a
|
||||
]
|
||||
[
|
||||
.B \-A
|
||||
]
|
||||
[
|
||||
.B \-b
|
||||
.I sector-of-backup
|
||||
]
|
||||
[
|
||||
.B \-c
|
||||
]
|
||||
[
|
||||
.B \-l
|
||||
.I filename
|
||||
]
|
||||
[
|
||||
.B \-C
|
||||
]
|
||||
[
|
||||
.B \-f
|
||||
.I number-of-FATs
|
||||
]
|
||||
[
|
||||
.B \-F
|
||||
.I FAT-size
|
||||
]
|
||||
[
|
||||
.B \-h
|
||||
.I number-of-hidden-sectors
|
||||
]
|
||||
[
|
||||
.B \-i
|
||||
.I volume-id
|
||||
]
|
||||
.RB [ " \-I " ]
|
||||
[
|
||||
.B \-m
|
||||
.I message-file
|
||||
]
|
||||
[
|
||||
.B \-n
|
||||
.I volume-name
|
||||
]
|
||||
[
|
||||
.B \-r
|
||||
.I root-dir-entries
|
||||
]
|
||||
[
|
||||
.B \-R
|
||||
.I number-of-reserved-sectors
|
||||
]
|
||||
[
|
||||
.B \-s
|
||||
.I sectors-per-cluster
|
||||
]
|
||||
[
|
||||
.B \-S
|
||||
.I logical-sector-size
|
||||
]
|
||||
[
|
||||
.B \-v
|
||||
]
|
||||
.I device
|
||||
[
|
||||
.I block-count
|
||||
]
|
||||
.SH DESCRIPTION
|
||||
.B mkdosfs
|
||||
is used to create an MS-DOS file system under Linux on a device (usually
|
||||
a disk partition).
|
||||
.I device
|
||||
is the special file corresponding to the device (e.g /dev/hdXX).
|
||||
.I block-count
|
||||
is the number of blocks on the device. If omitted,
|
||||
.B mkdosfs
|
||||
automatically determines the file system size.
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
.B \-a
|
||||
Normally, for any filesystem except very small ones, \fBmkdosfs\fP
|
||||
will align all the data structures to cluster size, to make sure that
|
||||
as long as the partition is properly aligned, so will all the data
|
||||
structures in the filesystem. This option disables alignment; this
|
||||
may provide a handful of additional clusters of storage at the expense
|
||||
of a significant performance degradation on RAIDs, flash media or
|
||||
large-sector hard disks.
|
||||
.TP
|
||||
.B \-A
|
||||
Use Atari variation of the MS-DOS file system. This is default if
|
||||
\fBmkdosfs\fP is run on an Atari, then this option turns off Atari
|
||||
format. There are some differences when using Atari format: If not
|
||||
directed otherwise by the user, \fBmkdosfs\fP will always use 2
|
||||
sectors per cluster, since GEMDOS doesn't like other values very much.
|
||||
It will also obey the maximum number of sectors GEMDOS can handle.
|
||||
Larger file systems are managed by raising the logical sector size.
|
||||
Under Atari format, an Atari-compatible serial number for the
|
||||
file system is generated, and a 12 bit FAT is used only for file systems
|
||||
that have one of the usual floppy sizes (720k, 1.2M, 1.44M, 2.88M), a
|
||||
16 bit FAT otherwise. This can be overridden with the \fB\-F\fP
|
||||
option. Some PC-specific boot sector fields aren't written, and a boot
|
||||
message (option \fB\-m\fP) is ignored.
|
||||
.TP
|
||||
.BI \-b " sector-of-backup "
|
||||
Selects the location of the backup boot sector for FAT32. Default
|
||||
depends on number of reserved sectors, but usually is sector 6. The
|
||||
backup must be within the range of reserved sectors.
|
||||
.TP
|
||||
.B \-c
|
||||
Check the device for bad blocks before creating the file system.
|
||||
.TP
|
||||
.B \-C
|
||||
Create the file given as \fIdevice\fP on the command line, and write
|
||||
the to-be-created file system to it. This can be used to create the
|
||||
new file system in a file instead of on a real device, and to avoid
|
||||
using \fBdd\fP in advance to create a file of appropriate size. With
|
||||
this option, the \fIblock-count\fP must be given, because otherwise
|
||||
the intended size of the file system wouldn't be known. The file
|
||||
created is a sparse file, which actually only contains the meta-data
|
||||
areas (boot sector, FATs, and root directory). The data portions won't
|
||||
be stored on the disk, but the file nevertheless will have the
|
||||
correct size. The resulting file can be copied later to a floppy disk
|
||||
or other device, or mounted through a loop device.
|
||||
.TP
|
||||
.BI \-f " number-of-FATs"
|
||||
Specify the number of file allocation tables in the file system. The
|
||||
default is 2. Currently the Linux MS-DOS file system does not support
|
||||
more than 2 FATs.
|
||||
.TP
|
||||
.BI \-F " FAT-size"
|
||||
Specifies the type of file allocation tables used (12, 16 or 32 bit).
|
||||
If nothing is specified, \fBmkdosfs\fR will automatically select
|
||||
between 12, 16 and 32 bit, whatever fits better for the file system size.
|
||||
.TP
|
||||
.BI \-h " number-of-hidden-sectors "
|
||||
Select the number of hidden sectors in the volume. Apparently some
|
||||
digital cameras get indigestion if you feed them a CF card without
|
||||
such hidden sectors, this option allows you to satisfy them. Assumes
|
||||
\'0\' if no value is given on the command line.
|
||||
.TP
|
||||
.I \-i " volume-id"
|
||||
Sets the volume ID of the newly created file system;
|
||||
.I volume-id
|
||||
is a 32-bit hexadecimal number (for example, 2e24ec82). The default
|
||||
is a number which depends on the file system creation time.
|
||||
.TP
|
||||
.B \-I
|
||||
It is typical for fixed disk devices to be partitioned so, by default, you are
|
||||
not permitted to create a filesystem across the entire device.
|
||||
.B mkdosfs
|
||||
will complain and tell you that it refuses to work. This is different
|
||||
when using MO disks. One doesn't always need partitions on MO disks.
|
||||
The file system can go directly to the whole disk. Under other OSes
|
||||
this is known as the 'superfloppy' format.
|
||||
|
||||
This switch will force
|
||||
.B mkdosfs
|
||||
to work properly.
|
||||
.TP
|
||||
.BI \-l " filename"
|
||||
Read the bad blocks list from
|
||||
.IR filename .
|
||||
.TP
|
||||
.BI \-m " message-file"
|
||||
Sets the message the user receives on attempts to boot this file system
|
||||
without having properly installed an operating system. The message
|
||||
file must not exceed 418 bytes once line feeds have been converted to
|
||||
carriage return-line feed combinations, and tabs have been expanded.
|
||||
If the filename is a hyphen (-), the text is taken from standard input.
|
||||
.TP
|
||||
.BI \-n " volume-name"
|
||||
Sets the volume name (label) of the file system. The volume name can
|
||||
be up to 11 characters long. The default is no label.
|
||||
.TP
|
||||
.BI \-r " root-dir-entries"
|
||||
Select the number of entries available in the root directory. The
|
||||
default is 112 or 224 for floppies and 512 for hard disks.
|
||||
.TP
|
||||
.BI \-R " number-of-reserved-sectors "
|
||||
Select the number of reserved sectors. With FAT32 format at least 2
|
||||
reserved sectors are needed, the default is 32. Otherwise the default
|
||||
is 1 (only the boot sector).
|
||||
.TP
|
||||
.BI \-s " sectors-per-cluster"
|
||||
Specify the number of disk sectors per cluster. Must be a power of 2,
|
||||
i.e. 1, 2, 4, 8, ... 128.
|
||||
.TP
|
||||
.BI \-S " logical-sector-size"
|
||||
Specify the number of bytes per logical sector. Must be a power of 2
|
||||
and greater than or equal to 512, i.e. 512, 1024, 2048, 4096, 8192,
|
||||
16384, or 32768.
|
||||
.TP
|
||||
.B \-v
|
||||
Verbose execution.
|
||||
.SH BUGS
|
||||
.B mkdosfs
|
||||
can not create boot-able file systems. This isn't as easy as you might
|
||||
think at first glance for various reasons and has been discussed a lot
|
||||
already.
|
||||
.B mkdosfs
|
||||
simply will not support it ;)
|
||||
.SH AUTHOR
|
||||
Dave Hudson - <dave@humbug.demon.co.uk>; modified by Peter Anvin
|
||||
<hpa@yggdrasil.com>. Fixes and additions by Roman Hodek
|
||||
<roman@hodek.net> for Debian/GNU Linux.
|
||||
.SH ACKNOWLEDGMENTS
|
||||
.B mkdosfs
|
||||
is based on code from
|
||||
.BR mke2fs
|
||||
(written by Remy Card - <card@masi.ibp.fr>) which is itself based on
|
||||
.BR mkfs
|
||||
(written by Linus Torvalds - <torvalds@cs.helsinki.fi>).
|
||||
.SH SEE ALSO
|
||||
.BR dosfsck (8),
|
||||
.BR dosfslabel (8),
|
||||
.BR mkfs (8)
|
518
dosfstools/src/boot.c
Normal file
518
dosfstools/src/boot.c
Normal file
@ -0,0 +1,518 @@
|
||||
/* boot.c - Read and analyze ia PC/MS-DOS boot sector
|
||||
|
||||
Copyright (C) 1993 Werner Almesberger <werner.almesberger@lrc.di.epfl.ch>
|
||||
Copyright (C) 1998 Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
On Debian systems, the complete text of the GNU General Public License
|
||||
can be found in /usr/share/common-licenses/GPL-3 file.
|
||||
*/
|
||||
|
||||
/* FAT32, VFAT, Atari format support, and various fixes additions May 1998
|
||||
* by Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de> */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "common.h"
|
||||
#include "dosfsck.h"
|
||||
#include "fat.h"
|
||||
#include "io.h"
|
||||
#include "boot.h"
|
||||
|
||||
#define ROUND_TO_MULTIPLE(n,m) ((n) && (m) ? (n)+(m)-1-((n)-1)%(m) : 0)
|
||||
/* don't divide by zero */
|
||||
|
||||
/* cut-over cluster counts for FAT12 and FAT16 */
|
||||
#define FAT12_THRESHOLD 4085
|
||||
#define FAT16_THRESHOLD 65525
|
||||
|
||||
static struct {
|
||||
__u8 media;
|
||||
char *descr;
|
||||
} mediabytes[] = {
|
||||
{
|
||||
0xf0, "5.25\" or 3.5\" HD floppy"}, {
|
||||
0xf8, "hard disk"}, {
|
||||
0xf9, "3,5\" 720k floppy 2s/80tr/9sec or "
|
||||
"5.25\" 1.2M floppy 2s/80tr/15sec"}, {
|
||||
0xfa, "5.25\" 320k floppy 1s/80tr/8sec"}, {
|
||||
0xfb, "3.5\" 640k floppy 2s/80tr/8sec"}, {
|
||||
0xfc, "5.25\" 180k floppy 1s/40tr/9sec"}, {
|
||||
0xfd, "5.25\" 360k floppy 2s/40tr/9sec"}, {
|
||||
0xfe, "5.25\" 160k floppy 1s/40tr/8sec"}, {
|
||||
0xff, "5.25\" 320k floppy 2s/40tr/8sec"},};
|
||||
|
||||
#if defined __alpha || defined __arm || defined __arm__ || defined __ia64__ || defined __x86_64__ \
|
||||
|| defined __ppc64__ || defined __bfin__ || defined __MICROBLAZE__
|
||||
/* Unaligned fields must first be copied byte-wise */
|
||||
#define GET_UNALIGNED_W(f) \
|
||||
({ \
|
||||
unsigned short __v; \
|
||||
memcpy( &__v, &f, sizeof(__v) ); \
|
||||
CF_LE_W( *(unsigned short *)&__v ); \
|
||||
})
|
||||
#else
|
||||
#define GET_UNALIGNED_W(f) CF_LE_W( *(unsigned short *)&f )
|
||||
#endif
|
||||
|
||||
static char *get_media_descr(unsigned char media)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < sizeof(mediabytes) / sizeof(*mediabytes); ++i) {
|
||||
if (mediabytes[i].media == media)
|
||||
return (mediabytes[i].descr);
|
||||
}
|
||||
return ("undefined");
|
||||
}
|
||||
|
||||
static void dump_boot(DOS_FS * fs, struct boot_sector *b, unsigned lss)
|
||||
{
|
||||
unsigned short sectors;
|
||||
|
||||
printf("Boot sector contents:\n");
|
||||
if (!atari_format) {
|
||||
char id[9];
|
||||
strncpy(id, (const char *)b->system_id, 8);
|
||||
id[8] = 0;
|
||||
printf("System ID \"%s\"\n", id);
|
||||
} else {
|
||||
/* On Atari, a 24 bit serial number is stored at offset 8 of the boot
|
||||
* sector */
|
||||
printf("Serial number 0x%x\n",
|
||||
b->system_id[5] | (b->
|
||||
system_id[6] << 8) | (b->system_id[7] << 16));
|
||||
}
|
||||
printf("Media byte 0x%02x (%s)\n", b->media, get_media_descr(b->media));
|
||||
printf("%10d bytes per logical sector\n", GET_UNALIGNED_W(b->sector_size));
|
||||
printf("%10d bytes per cluster\n", fs->cluster_size);
|
||||
printf("%10d reserved sector%s\n", CF_LE_W(b->reserved),
|
||||
CF_LE_W(b->reserved) == 1 ? "" : "s");
|
||||
printf("First FAT starts at byte %llu (sector %llu)\n",
|
||||
(unsigned long long)fs->fat_start,
|
||||
(unsigned long long)fs->fat_start / lss);
|
||||
printf("%10d FATs, %d bit entries\n", b->fats, fs->fat_bits);
|
||||
printf("%10d bytes per FAT (= %u sectors)\n", fs->fat_size,
|
||||
fs->fat_size / lss);
|
||||
if (!fs->root_cluster) {
|
||||
printf("Root directory starts at byte %llu (sector %llu)\n",
|
||||
(unsigned long long)fs->root_start,
|
||||
(unsigned long long)fs->root_start / lss);
|
||||
printf("%10d root directory entries\n", fs->root_entries);
|
||||
} else {
|
||||
printf("Root directory start at cluster %lu (arbitrary size)\n",
|
||||
fs->root_cluster);
|
||||
}
|
||||
printf("Data area starts at byte %llu (sector %llu)\n",
|
||||
(unsigned long long)fs->data_start,
|
||||
(unsigned long long)fs->data_start / lss);
|
||||
printf("%10lu data clusters (%llu bytes)\n", fs->clusters,
|
||||
(unsigned long long)fs->clusters * fs->cluster_size);
|
||||
printf("%u sectors/track, %u heads\n", CF_LE_W(b->secs_track),
|
||||
CF_LE_W(b->heads));
|
||||
printf("%10u hidden sectors\n", atari_format ?
|
||||
/* On Atari, the hidden field is only 16 bit wide and unused */
|
||||
(((unsigned char *)&b->hidden)[0] |
|
||||
((unsigned char *)&b->hidden)[1] << 8) : CF_LE_L(b->hidden));
|
||||
sectors = GET_UNALIGNED_W(b->sectors);
|
||||
printf("%10u sectors total\n", sectors ? sectors : CF_LE_L(b->total_sect));
|
||||
}
|
||||
|
||||
static void check_backup_boot(DOS_FS * fs, struct boot_sector *b, int lss)
|
||||
{
|
||||
struct boot_sector b2;
|
||||
|
||||
if (!fs->backupboot_start) {
|
||||
printf("There is no backup boot sector.\n");
|
||||
if (CF_LE_W(b->reserved) < 3) {
|
||||
printf("And there is no space for creating one!\n");
|
||||
return;
|
||||
}
|
||||
if (interactive)
|
||||
printf("1) Create one\n2) Do without a backup\n");
|
||||
else
|
||||
printf(" Auto-creating backup boot block.\n");
|
||||
if (!interactive || get_key("12", "?") == '1') {
|
||||
int bbs;
|
||||
/* The usual place for the backup boot sector is sector 6. Choose
|
||||
* that or the last reserved sector. */
|
||||
if (CF_LE_W(b->reserved) >= 7 && CF_LE_W(b->info_sector) != 6)
|
||||
bbs = 6;
|
||||
else {
|
||||
bbs = CF_LE_W(b->reserved) - 1;
|
||||
if (bbs == CF_LE_W(b->info_sector))
|
||||
--bbs; /* this is never 0, as we checked reserved >= 3! */
|
||||
}
|
||||
fs->backupboot_start = bbs * lss;
|
||||
b->backup_boot = CT_LE_W(bbs);
|
||||
fs_write(fs->backupboot_start, sizeof(*b), b);
|
||||
fs_write((loff_t) offsetof(struct boot_sector, backup_boot),
|
||||
sizeof(b->backup_boot), &b->backup_boot);
|
||||
printf("Created backup of boot sector in sector %d\n", bbs);
|
||||
return;
|
||||
} else
|
||||
return;
|
||||
}
|
||||
|
||||
fs_read(fs->backupboot_start, sizeof(b2), &b2);
|
||||
if (memcmp(b, &b2, sizeof(b2)) != 0) {
|
||||
/* there are any differences */
|
||||
__u8 *p, *q;
|
||||
int i, pos, first = 1;
|
||||
char buf[20];
|
||||
|
||||
printf("There are differences between boot sector and its backup.\n");
|
||||
printf("Differences: (offset:original/backup)\n ");
|
||||
pos = 2;
|
||||
for (p = (__u8 *) b, q = (__u8 *) & b2, i = 0; i < sizeof(b2);
|
||||
++p, ++q, ++i) {
|
||||
if (*p != *q) {
|
||||
sprintf(buf, "%s%u:%02x/%02x", first ? "" : ", ",
|
||||
(unsigned)(p - (__u8 *) b), *p, *q);
|
||||
if (pos + strlen(buf) > 78)
|
||||
printf("\n "), pos = 2;
|
||||
printf("%s", buf);
|
||||
pos += strlen(buf);
|
||||
first = 0;
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
if (interactive)
|
||||
printf("1) Copy original to backup\n"
|
||||
"2) Copy backup to original\n" "3) No action\n");
|
||||
else
|
||||
printf(" Not automatically fixing this.\n");
|
||||
switch (interactive ? get_key("123", "?") : '3') {
|
||||
case '1':
|
||||
fs_write(fs->backupboot_start, sizeof(*b), b);
|
||||
break;
|
||||
case '2':
|
||||
fs_write(0, sizeof(b2), &b2);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void init_fsinfo(struct info_sector *i)
|
||||
{
|
||||
i->magic = CT_LE_L(0x41615252);
|
||||
i->signature = CT_LE_L(0x61417272);
|
||||
i->free_clusters = CT_LE_L(-1);
|
||||
i->next_cluster = CT_LE_L(2);
|
||||
i->boot_sign = CT_LE_W(0xaa55);
|
||||
}
|
||||
|
||||
static void read_fsinfo(DOS_FS * fs, struct boot_sector *b, int lss)
|
||||
{
|
||||
struct info_sector i;
|
||||
|
||||
if (!b->info_sector) {
|
||||
printf("No FSINFO sector\n");
|
||||
if (interactive)
|
||||
printf("1) Create one\n2) Do without FSINFO\n");
|
||||
else
|
||||
printf(" Not automatically creating it.\n");
|
||||
if (interactive && get_key("12", "?") == '1') {
|
||||
/* search for a free reserved sector (not boot sector and not
|
||||
* backup boot sector) */
|
||||
__u32 s;
|
||||
for (s = 1; s < CF_LE_W(b->reserved); ++s)
|
||||
if (s != CF_LE_W(b->backup_boot))
|
||||
break;
|
||||
if (s > 0 && s < CF_LE_W(b->reserved)) {
|
||||
init_fsinfo(&i);
|
||||
fs_write((loff_t) s * lss, sizeof(i), &i);
|
||||
b->info_sector = CT_LE_W(s);
|
||||
fs_write((loff_t) offsetof(struct boot_sector, info_sector),
|
||||
sizeof(b->info_sector), &b->info_sector);
|
||||
if (fs->backupboot_start)
|
||||
fs_write(fs->backupboot_start +
|
||||
offsetof(struct boot_sector, info_sector),
|
||||
sizeof(b->info_sector), &b->info_sector);
|
||||
} else {
|
||||
printf("No free reserved sector found -- "
|
||||
"no space for FSINFO sector!\n");
|
||||
return;
|
||||
}
|
||||
} else
|
||||
return;
|
||||
}
|
||||
|
||||
fs->fsinfo_start = CF_LE_W(b->info_sector) * lss;
|
||||
fs_read(fs->fsinfo_start, sizeof(i), &i);
|
||||
|
||||
if (i.magic != CT_LE_L(0x41615252) ||
|
||||
i.signature != CT_LE_L(0x61417272) || i.boot_sign != CT_LE_W(0xaa55)) {
|
||||
printf("FSINFO sector has bad magic number(s):\n");
|
||||
if (i.magic != CT_LE_L(0x41615252))
|
||||
printf(" Offset %llu: 0x%08x != expected 0x%08x\n",
|
||||
(unsigned long long)offsetof(struct info_sector, magic),
|
||||
CF_LE_L(i.magic), 0x41615252);
|
||||
if (i.signature != CT_LE_L(0x61417272))
|
||||
printf(" Offset %llu: 0x%08x != expected 0x%08x\n",
|
||||
(unsigned long long)offsetof(struct info_sector, signature),
|
||||
CF_LE_L(i.signature), 0x61417272);
|
||||
if (i.boot_sign != CT_LE_W(0xaa55))
|
||||
printf(" Offset %llu: 0x%04x != expected 0x%04x\n",
|
||||
(unsigned long long)offsetof(struct info_sector, boot_sign),
|
||||
CF_LE_W(i.boot_sign), 0xaa55);
|
||||
if (interactive)
|
||||
printf("1) Correct\n2) Don't correct (FSINFO invalid then)\n");
|
||||
else
|
||||
printf(" Auto-correcting it.\n");
|
||||
if (!interactive || get_key("12", "?") == '1') {
|
||||
init_fsinfo(&i);
|
||||
fs_write(fs->fsinfo_start, sizeof(i), &i);
|
||||
} else
|
||||
fs->fsinfo_start = 0;
|
||||
}
|
||||
|
||||
if (fs->fsinfo_start)
|
||||
fs->free_clusters = CF_LE_L(i.free_clusters);
|
||||
}
|
||||
|
||||
void read_boot(DOS_FS * fs)
|
||||
{
|
||||
struct boot_sector b;
|
||||
unsigned total_sectors;
|
||||
unsigned short logical_sector_size, sectors;
|
||||
unsigned fat_length;
|
||||
loff_t data_size;
|
||||
|
||||
fs_read(0, sizeof(b), &b);
|
||||
logical_sector_size = GET_UNALIGNED_W(b.sector_size);
|
||||
if (!logical_sector_size)
|
||||
die("Logical sector size is zero.");
|
||||
|
||||
/* This was moved up because it's the first thing that will fail */
|
||||
/* if the platform needs special handling of unaligned multibyte accesses */
|
||||
/* but such handling isn't being provided. See GET_UNALIGNED_W() above. */
|
||||
if (logical_sector_size & (SECTOR_SIZE - 1))
|
||||
die("Logical sector size (%d bytes) is not a multiple of the physical "
|
||||
"sector size.", logical_sector_size);
|
||||
|
||||
fs->cluster_size = b.cluster_size * logical_sector_size;
|
||||
if (!fs->cluster_size)
|
||||
die("Cluster size is zero.");
|
||||
if (b.fats != 2 && b.fats != 1)
|
||||
die("Currently, only 1 or 2 FATs are supported, not %d.\n", b.fats);
|
||||
fs->nfats = b.fats;
|
||||
sectors = GET_UNALIGNED_W(b.sectors);
|
||||
total_sectors = sectors ? sectors : CF_LE_L(b.total_sect);
|
||||
if (verbose)
|
||||
printf("Checking we can access the last sector of the filesystem\n");
|
||||
/* Can't access last odd sector anyway, so round down */
|
||||
fs_test((loff_t) ((total_sectors & ~1) - 1) * (loff_t) logical_sector_size,
|
||||
logical_sector_size);
|
||||
fat_length = CF_LE_W(b.fat_length) ?
|
||||
CF_LE_W(b.fat_length) : CF_LE_L(b.fat32_length);
|
||||
fs->fat_start = (loff_t) CF_LE_W(b.reserved) * logical_sector_size;
|
||||
fs->root_start = ((loff_t) CF_LE_W(b.reserved) + b.fats * fat_length) *
|
||||
logical_sector_size;
|
||||
fs->root_entries = GET_UNALIGNED_W(b.dir_entries);
|
||||
fs->data_start = fs->root_start + ROUND_TO_MULTIPLE(fs->root_entries <<
|
||||
MSDOS_DIR_BITS,
|
||||
logical_sector_size);
|
||||
data_size = (loff_t) total_sectors *logical_sector_size - fs->data_start;
|
||||
fs->clusters = data_size / fs->cluster_size;
|
||||
fs->root_cluster = 0; /* indicates standard, pre-FAT32 root dir */
|
||||
fs->fsinfo_start = 0; /* no FSINFO structure */
|
||||
fs->free_clusters = -1; /* unknown */
|
||||
if (!b.fat_length && b.fat32_length) {
|
||||
fs->fat_bits = 32;
|
||||
fs->root_cluster = CF_LE_L(b.root_cluster);
|
||||
if (!fs->root_cluster && fs->root_entries)
|
||||
/* M$ hasn't specified this, but it looks reasonable: If
|
||||
* root_cluster is 0 but there is a separate root dir
|
||||
* (root_entries != 0), we handle the root dir the old way. Give a
|
||||
* warning, but convertig to a root dir in a cluster chain seems
|
||||
* to complex for now... */
|
||||
printf("Warning: FAT32 root dir not in cluster chain! "
|
||||
"Compatibility mode...\n");
|
||||
else if (!fs->root_cluster && !fs->root_entries)
|
||||
die("No root directory!");
|
||||
else if (fs->root_cluster && fs->root_entries)
|
||||
printf("Warning: FAT32 root dir is in a cluster chain, but "
|
||||
"a separate root dir\n"
|
||||
" area is defined. Cannot fix this easily.\n");
|
||||
if (fs->clusters < FAT16_THRESHOLD)
|
||||
printf("Warning: Filesystem is FAT32 according to fat_length "
|
||||
"and fat32_length fields,\n"
|
||||
" but has only %lu clusters, less than the required "
|
||||
"minimum of %d.\n"
|
||||
" This may lead to problems on some systems.\n",
|
||||
fs->clusters, FAT16_THRESHOLD);
|
||||
|
||||
fs->backupboot_start = CF_LE_W(b.backup_boot) * logical_sector_size;
|
||||
check_backup_boot(fs, &b, logical_sector_size);
|
||||
|
||||
read_fsinfo(fs, &b, logical_sector_size);
|
||||
} else if (!atari_format) {
|
||||
/* On real MS-DOS, a 16 bit FAT is used whenever there would be too
|
||||
* much clusers otherwise. */
|
||||
fs->fat_bits = (fs->clusters >= FAT12_THRESHOLD) ? 16 : 12;
|
||||
if (fs->clusters >= FAT16_THRESHOLD)
|
||||
die("Too many clusters (%lu) for FAT16 filesystem.", fs->clusters);
|
||||
} else {
|
||||
/* On Atari, things are more difficult: GEMDOS always uses 12bit FATs
|
||||
* on floppies, and always 16 bit on harddisks. */
|
||||
fs->fat_bits = 16; /* assume 16 bit FAT for now */
|
||||
/* If more clusters than fat entries in 16-bit fat, we assume
|
||||
* it's a real MSDOS FS with 12-bit fat. */
|
||||
if (fs->clusters + 2 > fat_length * logical_sector_size * 8 / 16 ||
|
||||
/* if it's a floppy disk --> 12bit fat */
|
||||
device_no == 2 ||
|
||||
/* if it's a ramdisk or loopback device and has one of the usual
|
||||
* floppy sizes -> 12bit FAT */
|
||||
((device_no == 1 || device_no == 7) &&
|
||||
(total_sectors == 720 || total_sectors == 1440 ||
|
||||
total_sectors == 2880)))
|
||||
fs->fat_bits = 12;
|
||||
}
|
||||
/* On FAT32, the high 4 bits of a FAT entry are reserved */
|
||||
fs->eff_fat_bits = (fs->fat_bits == 32) ? 28 : fs->fat_bits;
|
||||
fs->fat_size = fat_length * logical_sector_size;
|
||||
|
||||
fs->label = calloc(12, sizeof(__u8));
|
||||
if (fs->fat_bits == 12 || fs->fat_bits == 16) {
|
||||
struct boot_sector_16 *b16 = (struct boot_sector_16 *)&b;
|
||||
if (b16->extended_sig == 0x29)
|
||||
memmove(fs->label, b16->label, 11);
|
||||
else
|
||||
fs->label = NULL;
|
||||
} else if (fs->fat_bits == 32) {
|
||||
if (b.extended_sig == 0x29)
|
||||
memmove(fs->label, &b.label, 11);
|
||||
else
|
||||
fs->label = NULL;
|
||||
}
|
||||
|
||||
if (fs->clusters >
|
||||
((unsigned long long)fs->fat_size * 8 / fs->fat_bits) - 2)
|
||||
die("File system has %d clusters but only space for %d FAT entries.",
|
||||
fs->clusters,
|
||||
((unsigned long long)fs->fat_size * 8 / fs->fat_bits) - 2);
|
||||
if (!fs->root_entries && !fs->root_cluster)
|
||||
die("Root directory has zero size.");
|
||||
if (fs->root_entries & (MSDOS_DPS - 1))
|
||||
die("Root directory (%d entries) doesn't span an integral number of "
|
||||
"sectors.", fs->root_entries);
|
||||
if (logical_sector_size & (SECTOR_SIZE - 1))
|
||||
die("Logical sector size (%d bytes) is not a multiple of the physical "
|
||||
"sector size.", logical_sector_size);
|
||||
#if 0 /* linux kernel doesn't check that either */
|
||||
/* ++roman: On Atari, these two fields are often left uninitialized */
|
||||
if (!atari_format && (!b.secs_track || !b.heads))
|
||||
die("Invalid disk format in boot sector.");
|
||||
#endif
|
||||
if (verbose)
|
||||
dump_boot(fs, &b, logical_sector_size);
|
||||
}
|
||||
|
||||
static void write_boot_label(DOS_FS * fs, char *label)
|
||||
{
|
||||
struct boot_sector b;
|
||||
struct boot_sector_16 *b16 = (struct boot_sector_16 *)&b;
|
||||
|
||||
fs_read(0, sizeof(b), &b);
|
||||
if (fs->fat_bits == 12 || fs->fat_bits == 16) {
|
||||
if (b16->extended_sig != 0x29) {
|
||||
b16->extended_sig = 0x29;
|
||||
b16->serial = 0;
|
||||
memmove(b16->fs_type, fs->fat_bits == 12 ? "FAT12 " : "FAT16 ",
|
||||
8);
|
||||
}
|
||||
memmove(b16->label, label, 11);
|
||||
} else if (fs->fat_bits == 32) {
|
||||
if (b.extended_sig != 0x29) {
|
||||
b.extended_sig = 0x29;
|
||||
b.serial = 0;
|
||||
memmove(b.fs_type, "FAT32 ", 8);
|
||||
}
|
||||
memmove(b.label, label, 11);
|
||||
}
|
||||
fs_write(0, sizeof(b), &b);
|
||||
if (fs->fat_bits == 32 && fs->backupboot_start)
|
||||
fs_write(fs->backupboot_start, sizeof(b), &b);
|
||||
}
|
||||
|
||||
static loff_t find_volume_de(DOS_FS * fs, DIR_ENT * de)
|
||||
{
|
||||
unsigned long cluster;
|
||||
loff_t offset;
|
||||
int i;
|
||||
|
||||
if (fs->root_cluster) {
|
||||
for (cluster = fs->root_cluster;
|
||||
cluster != 0 && cluster != -1;
|
||||
cluster = next_cluster(fs, cluster)) {
|
||||
offset = cluster_start(fs, cluster);
|
||||
for (i = 0; i * sizeof(DIR_ENT) < fs->cluster_size; i++) {
|
||||
fs_read(offset, sizeof(DIR_ENT), de);
|
||||
if (de->attr & ATTR_VOLUME)
|
||||
return offset;
|
||||
offset += sizeof(DIR_ENT);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (i = 0; i < fs->root_entries; i++) {
|
||||
offset = fs->root_start + i * sizeof(DIR_ENT);
|
||||
fs_read(offset, sizeof(DIR_ENT), de);
|
||||
if (de->attr & ATTR_VOLUME)
|
||||
return offset;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void write_volume_label(DOS_FS * fs, char *label)
|
||||
{
|
||||
time_t now = time(NULL);
|
||||
struct tm *mtime = localtime(&now);
|
||||
loff_t offset;
|
||||
DIR_ENT de;
|
||||
|
||||
offset = find_volume_de(fs, &de);
|
||||
if (offset == 0)
|
||||
return;
|
||||
|
||||
memcpy(de.name, label, 11);
|
||||
de.time = CT_LE_W((unsigned short)((mtime->tm_sec >> 1) +
|
||||
(mtime->tm_min << 5) +
|
||||
(mtime->tm_hour << 11)));
|
||||
de.date = CT_LE_W((unsigned short)(mtime->tm_mday +
|
||||
((mtime->tm_mon + 1) << 5) +
|
||||
((mtime->tm_year - 80) << 9)));
|
||||
fs_write(offset, sizeof(DIR_ENT), &de);
|
||||
}
|
||||
|
||||
void write_label(DOS_FS * fs, char *label)
|
||||
{
|
||||
int l = strlen(label);
|
||||
|
||||
while (l < 11)
|
||||
label[l++] = ' ';
|
||||
|
||||
write_boot_label(fs, label);
|
||||
write_volume_label(fs, label);
|
||||
}
|
30
dosfstools/src/boot.h
Normal file
30
dosfstools/src/boot.h
Normal file
@ -0,0 +1,30 @@
|
||||
/* boot.h - Read and analyze ia PC/MS-DOS boot sector
|
||||
|
||||
Copyright (C) 1993 Werner Almesberger <werner.almesberger@lrc.di.epfl.ch>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
On Debian systems, the complete text of the GNU General Public License
|
||||
can be found in /usr/share/common-licenses/GPL-3 file.
|
||||
*/
|
||||
|
||||
#ifndef _BOOT_H
|
||||
#define _BOOT_H
|
||||
|
||||
void read_boot(DOS_FS * fs);
|
||||
void write_label(DOS_FS * fs, char *label);
|
||||
|
||||
/* Reads the boot sector from the currently open device and initializes *FS */
|
||||
|
||||
#endif
|
1051
dosfstools/src/check.c
Normal file
1051
dosfstools/src/check.c
Normal file
File diff suppressed because it is too large
Load Diff
39
dosfstools/src/check.h
Normal file
39
dosfstools/src/check.h
Normal file
@ -0,0 +1,39 @@
|
||||
/* check.h - Check and repair a PC/MS-DOS file system
|
||||
|
||||
Copyright (C) 1993 Werner Almesberger <werner.almesberger@lrc.di.epfl.ch>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
On Debian systems, the complete text of the GNU General Public License
|
||||
can be found in /usr/share/common-licenses/GPL-3 file.
|
||||
*/
|
||||
|
||||
#ifndef _CHECK_H
|
||||
#define _CHECK_H
|
||||
|
||||
loff_t alloc_rootdir_entry(DOS_FS * fs, DIR_ENT * de, const char *pattern);
|
||||
|
||||
/* Allocate a free slot in the root directory for a new file. The file name is
|
||||
constructed after 'pattern', which must include a %d type format for printf
|
||||
and expand to exactly 11 characters. The name actually used is written into
|
||||
the 'de' structure, the rest of *de is cleared. The offset returned is to
|
||||
where in the filesystem the entry belongs. */
|
||||
|
||||
int scan_root(DOS_FS * fs);
|
||||
|
||||
/* Scans the root directory and recurses into all subdirectories. See check.c
|
||||
for all the details. Returns a non-zero integer if the file system has to
|
||||
be checked again. */
|
||||
|
||||
#endif
|
118
dosfstools/src/common.c
Normal file
118
dosfstools/src/common.c
Normal file
@ -0,0 +1,118 @@
|
||||
/* common.c - Common functions
|
||||
|
||||
Copyright (C) 1993 Werner Almesberger <werner.almesberger@lrc.di.epfl.ch>
|
||||
Copyright (C) 1998 Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
On Debian systems, the complete text of the GNU General Public License
|
||||
can be found in /usr/share/common-licenses/GPL-3 file.
|
||||
*/
|
||||
|
||||
/* FAT32, VFAT, Atari format support, and various fixes additions May 1998
|
||||
* by Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de> */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "common.h"
|
||||
|
||||
typedef struct _link {
|
||||
void *data;
|
||||
struct _link *next;
|
||||
} LINK;
|
||||
|
||||
void die(char *msg, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
va_start(args, msg);
|
||||
vfprintf(stderr, msg, args);
|
||||
va_end(args);
|
||||
fprintf(stderr, "\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void pdie(char *msg, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
va_start(args, msg);
|
||||
vfprintf(stderr, msg, args);
|
||||
va_end(args);
|
||||
fprintf(stderr, ":%s\n", strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void *alloc(int size)
|
||||
{
|
||||
void *this;
|
||||
|
||||
if ((this = malloc(size)))
|
||||
return this;
|
||||
pdie("malloc");
|
||||
return NULL; /* for GCC */
|
||||
}
|
||||
|
||||
void *qalloc(void **root, int size)
|
||||
{
|
||||
LINK *link;
|
||||
|
||||
link = alloc(sizeof(LINK));
|
||||
link->next = *root;
|
||||
*root = link;
|
||||
return link->data = alloc(size);
|
||||
}
|
||||
|
||||
void qfree(void **root)
|
||||
{
|
||||
LINK *this;
|
||||
|
||||
while (*root) {
|
||||
this = (LINK *) * root;
|
||||
*root = this->next;
|
||||
free(this->data);
|
||||
free(this);
|
||||
}
|
||||
}
|
||||
|
||||
int min(int a, int b)
|
||||
{
|
||||
return a < b ? a : b;
|
||||
}
|
||||
|
||||
char get_key(char *valid, char *prompt)
|
||||
{
|
||||
int ch, okay;
|
||||
|
||||
while (1) {
|
||||
if (prompt)
|
||||
printf("%s ", prompt);
|
||||
fflush(stdout);
|
||||
while (ch = getchar(), ch == ' ' || ch == '\t') ;
|
||||
if (ch == EOF)
|
||||
exit(1);
|
||||
if (!strchr(valid, okay = ch))
|
||||
okay = 0;
|
||||
while (ch = getchar(), ch != '\n' && ch != EOF) ;
|
||||
if (ch == EOF)
|
||||
exit(1);
|
||||
if (okay)
|
||||
return okay;
|
||||
printf("Invalid input.\n");
|
||||
}
|
||||
}
|
57
dosfstools/src/common.h
Normal file
57
dosfstools/src/common.h
Normal file
@ -0,0 +1,57 @@
|
||||
/* common.h - Common functions
|
||||
|
||||
Copyright (C) 1993 Werner Almesberger <werner.almesberger@lrc.di.epfl.ch>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
On Debian systems, the complete text of the GNU General Public License
|
||||
can be found in /usr/share/common-licenses/GPL-3 file.
|
||||
*/
|
||||
|
||||
#include <asm/types.h>
|
||||
|
||||
#ifndef _COMMON_H
|
||||
#define _COMMON_H
|
||||
|
||||
void die(char *msg, ...) __attribute((noreturn));
|
||||
|
||||
/* Displays a prinf-style message and terminates the program. */
|
||||
|
||||
void pdie(char *msg, ...) __attribute((noreturn));
|
||||
|
||||
/* Like die, but appends an error message according to the state of errno. */
|
||||
|
||||
void *alloc(int size);
|
||||
|
||||
/* mallocs SIZE bytes and returns a pointer to the data. Terminates the program
|
||||
if malloc fails. */
|
||||
|
||||
void *qalloc(void **root, int size);
|
||||
|
||||
/* Like alloc, but registers the data area in a list described by ROOT. */
|
||||
|
||||
void qfree(void **root);
|
||||
|
||||
/* Deallocates all qalloc'ed data areas described by ROOT. */
|
||||
|
||||
int min(int a, int b);
|
||||
|
||||
/* Returns the smaller integer value of a and b. */
|
||||
|
||||
char get_key(char *valid, char *prompt);
|
||||
|
||||
/* Displays PROMPT and waits for user input. Only characters in VALID are
|
||||
accepted. Terminates the program on EOF. Returns the character. */
|
||||
|
||||
#endif
|
224
dosfstools/src/dosfsck.c
Normal file
224
dosfstools/src/dosfsck.c
Normal file
@ -0,0 +1,224 @@
|
||||
/* dosfsck.c - User interface
|
||||
|
||||
Copyright (C) 1993 Werner Almesberger <werner.almesberger@lrc.di.epfl.ch>
|
||||
Copyright (C) 1998 Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
On Debian systems, the complete text of the GNU General Public License
|
||||
can be found in /usr/share/common-licenses/GPL-3 file.
|
||||
*/
|
||||
|
||||
/* FAT32, VFAT, Atari format support, and various fixes additions May 1998
|
||||
* by Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de> */
|
||||
|
||||
#include "version.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <getopt.h>
|
||||
|
||||
#include "common.h"
|
||||
#include "dosfsck.h"
|
||||
#include "io.h"
|
||||
#include "boot.h"
|
||||
#include "fat.h"
|
||||
#include "file.h"
|
||||
#include "check.h"
|
||||
|
||||
int interactive = 0, rw = 0, list = 0, test = 0, verbose = 0, write_immed = 0;
|
||||
int atari_format = 0;
|
||||
unsigned n_files = 0;
|
||||
void *mem_queue = NULL;
|
||||
|
||||
#ifdef USE_ANDROID_RETVALS
|
||||
unsigned retandroid = 1;
|
||||
#else
|
||||
unsigned retandroid = 0;
|
||||
#endif
|
||||
|
||||
static void usage(char *name)
|
||||
{
|
||||
fprintf(stderr, "usage: %s [-aAflrtvVwy] [-d path -d ...] "
|
||||
"[-u path -u ...]\n%15sdevice\n", name, "");
|
||||
fprintf(stderr, " -a automatically repair the file system\n");
|
||||
fprintf(stderr, " -A toggle Atari file system format\n");
|
||||
fprintf(stderr, " -d path drop that file\n");
|
||||
fprintf(stderr, " -f ignored\n");
|
||||
fprintf(stderr, " -l list path names\n");
|
||||
fprintf(stderr,
|
||||
" -n no-op, check non-interactively without changing\n");
|
||||
fprintf(stderr, " -p same as -a, for compat with other *fsck\n");
|
||||
fprintf(stderr, " -r interactively repair the file system\n");
|
||||
fprintf(stderr, " -t test for bad clusters\n");
|
||||
fprintf(stderr, " -u path try to undelete that (non-directory) file\n");
|
||||
fprintf(stderr, " -v verbose mode\n");
|
||||
fprintf(stderr, " -V perform a verification pass\n");
|
||||
fprintf(stderr, " -w write changes to disk immediately\n");
|
||||
fprintf(stderr, " -y same as -a, for compat with other *fsck\n");
|
||||
if (retandroid) {
|
||||
exit(1);
|
||||
} else {
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* ++roman: On m68k, check if this is an Atari; if yes, turn on Atari variant
|
||||
* of MS-DOS filesystem by default.
|
||||
*/
|
||||
static void check_atari(void)
|
||||
{
|
||||
#ifdef __mc68000__
|
||||
FILE *f;
|
||||
char line[128], *p;
|
||||
|
||||
if (!(f = fopen("/proc/hardware", "r"))) {
|
||||
perror("/proc/hardware");
|
||||
return;
|
||||
}
|
||||
|
||||
while (fgets(line, sizeof(line), f)) {
|
||||
if (strncmp(line, "Model:", 6) == 0) {
|
||||
p = line + 6;
|
||||
p += strspn(p, " \t");
|
||||
if (strncmp(p, "Atari ", 6) == 0)
|
||||
atari_format = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
fclose(f);
|
||||
#endif
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
DOS_FS fs;
|
||||
int salvage_files, verify, c;
|
||||
unsigned n_files_check = 0, n_files_verify = 0;
|
||||
unsigned long free_clusters;
|
||||
|
||||
memset(&fs, 0, sizeof(fs));
|
||||
rw = salvage_files = verify = 0;
|
||||
interactive = 1;
|
||||
check_atari();
|
||||
|
||||
while ((c = getopt(argc, argv, "Aad:flnprtu:vVwy")) != EOF)
|
||||
switch (c) {
|
||||
case 'A': /* toggle Atari format */
|
||||
atari_format = !atari_format;
|
||||
break;
|
||||
case 'a':
|
||||
case 'p':
|
||||
case 'y':
|
||||
rw = 1;
|
||||
interactive = 0;
|
||||
salvage_files = 1;
|
||||
break;
|
||||
case 'd':
|
||||
file_add(optarg, fdt_drop);
|
||||
break;
|
||||
case 'f':
|
||||
salvage_files = 1;
|
||||
break;
|
||||
case 'l':
|
||||
list = 1;
|
||||
break;
|
||||
case 'n':
|
||||
rw = 0;
|
||||
interactive = 0;
|
||||
break;
|
||||
case 'r':
|
||||
rw = 1;
|
||||
interactive = 1;
|
||||
break;
|
||||
case 't':
|
||||
test = 1;
|
||||
break;
|
||||
case 'u':
|
||||
file_add(optarg, fdt_undelete);
|
||||
break;
|
||||
case 'v':
|
||||
verbose = 1;
|
||||
printf("dosfsck " VERSION " (" VERSION_DATE ")\n");
|
||||
break;
|
||||
case 'V':
|
||||
verify = 1;
|
||||
break;
|
||||
case 'w':
|
||||
write_immed = 1;
|
||||
break;
|
||||
default:
|
||||
usage(argv[0]);
|
||||
}
|
||||
if ((test || write_immed) && !rw) {
|
||||
fprintf(stderr, "-t and -w require -a or -r\n");
|
||||
if (retandroid) {
|
||||
exit(1);
|
||||
} else {
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
if (optind != argc - 1)
|
||||
usage(argv[0]);
|
||||
|
||||
printf("dosfsck " VERSION ", " VERSION_DATE ", FAT32, LFN\n");
|
||||
fs_open(argv[optind], rw);
|
||||
read_boot(&fs);
|
||||
if (verify)
|
||||
printf("Starting check/repair pass.\n");
|
||||
while (read_fat(&fs), scan_root(&fs))
|
||||
qfree(&mem_queue);
|
||||
if (test)
|
||||
fix_bad(&fs);
|
||||
if (salvage_files && 0)
|
||||
reclaim_file(&fs);
|
||||
else
|
||||
reclaim_free(&fs);
|
||||
free_clusters = update_free(&fs);
|
||||
file_unused();
|
||||
qfree(&mem_queue);
|
||||
n_files_check = n_files;
|
||||
if (verify) {
|
||||
n_files = 0;
|
||||
printf("Starting verification pass.\n");
|
||||
read_fat(&fs);
|
||||
scan_root(&fs);
|
||||
reclaim_free(&fs);
|
||||
qfree(&mem_queue);
|
||||
n_files_verify = n_files;
|
||||
}
|
||||
|
||||
if (fs_changed()) {
|
||||
if (rw) {
|
||||
if (interactive)
|
||||
rw = get_key("yn", "Perform changes ? (y/n)") == 'y';
|
||||
else
|
||||
printf("Performing changes.\n");
|
||||
} else
|
||||
printf("Leaving file system unchanged.\n");
|
||||
}
|
||||
|
||||
printf("%s: %u files, %lu/%lu clusters\n", argv[optind],
|
||||
n_files, fs.clusters - free_clusters, fs.clusters);
|
||||
|
||||
if (retandroid) {
|
||||
return fs_close(rw) ? 4 : 0;
|
||||
} else {
|
||||
return fs_close(rw) ? 1 : 0;
|
||||
}
|
||||
}
|
218
dosfstools/src/dosfsck.h
Normal file
218
dosfstools/src/dosfsck.h
Normal file
@ -0,0 +1,218 @@
|
||||
/* dosfsck.h - Common data structures and global variables
|
||||
|
||||
Copyright (C) 1993 Werner Almesberger <werner.almesberger@lrc.di.epfl.ch>
|
||||
Copyright (C) 1998 Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
On Debian systems, the complete text of the GNU General Public License
|
||||
can be found in /usr/share/common-licenses/GPL-3 file.
|
||||
*/
|
||||
|
||||
/* FAT32, VFAT, Atari format support, and various fixes additions May 1998
|
||||
* by Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de> */
|
||||
|
||||
#ifndef _DOSFSCK_H
|
||||
#define _DOSFSCK_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#define _LINUX_STAT_H /* hack to avoid inclusion of <linux/stat.h> */
|
||||
#define _LINUX_STRING_H_ /* hack to avoid inclusion of <linux/string.h> */
|
||||
#define _LINUX_FS_H /* hack to avoid inclusion of <linux/fs.h> */
|
||||
|
||||
#ifdef _USING_BIONIC_
|
||||
#include <sys/endian.h>
|
||||
#endif
|
||||
|
||||
#include <asm/types.h>
|
||||
#include <asm/byteorder.h>
|
||||
|
||||
#include <linux/msdos_fs.h>
|
||||
|
||||
#undef CF_LE_W
|
||||
#undef CF_LE_L
|
||||
#undef CT_LE_W
|
||||
#undef CT_LE_L
|
||||
|
||||
#if __BYTE_ORDER == __BIG_ENDIAN
|
||||
#include <byteswap.h>
|
||||
#define CF_LE_W(v) bswap_16(v)
|
||||
#define CF_LE_L(v) bswap_32(v)
|
||||
#define CT_LE_W(v) CF_LE_W(v)
|
||||
#define CT_LE_L(v) CF_LE_L(v)
|
||||
#else
|
||||
#define CF_LE_W(v) (v)
|
||||
#define CF_LE_L(v) (v)
|
||||
#define CT_LE_W(v) (v)
|
||||
#define CT_LE_L(v) (v)
|
||||
#endif /* __BIG_ENDIAN */
|
||||
|
||||
#define VFAT_LN_ATTR (ATTR_RO | ATTR_HIDDEN | ATTR_SYS | ATTR_VOLUME)
|
||||
|
||||
/* ++roman: Use own definition of boot sector structure -- the kernel headers'
|
||||
* name for it is msdos_boot_sector in 2.0 and fat_boot_sector in 2.1 ... */
|
||||
struct boot_sector {
|
||||
__u8 ignored[3]; /* Boot strap short or near jump */
|
||||
__u8 system_id[8]; /* Name - can be used to special case
|
||||
partition manager volumes */
|
||||
__u8 sector_size[2]; /* bytes per logical sector */
|
||||
__u8 cluster_size; /* sectors/cluster */
|
||||
__u16 reserved; /* reserved sectors */
|
||||
__u8 fats; /* number of FATs */
|
||||
__u8 dir_entries[2]; /* root directory entries */
|
||||
__u8 sectors[2]; /* number of sectors */
|
||||
__u8 media; /* media code (unused) */
|
||||
__u16 fat_length; /* sectors/FAT */
|
||||
__u16 secs_track; /* sectors per track */
|
||||
__u16 heads; /* number of heads */
|
||||
__u32 hidden; /* hidden sectors (unused) */
|
||||
__u32 total_sect; /* number of sectors (if sectors == 0) */
|
||||
|
||||
/* The following fields are only used by FAT32 */
|
||||
__u32 fat32_length; /* sectors/FAT */
|
||||
__u16 flags; /* bit 8: fat mirroring, low 4: active fat */
|
||||
__u8 version[2]; /* major, minor filesystem version */
|
||||
__u32 root_cluster; /* first cluster in root directory */
|
||||
__u16 info_sector; /* filesystem info sector */
|
||||
__u16 backup_boot; /* backup boot sector */
|
||||
__u8 reserved2[12]; /* Unused */
|
||||
|
||||
__u8 drive_number; /* Logical Drive Number */
|
||||
__u8 reserved3; /* Unused */
|
||||
|
||||
__u8 extended_sig; /* Extended Signature (0x29) */
|
||||
__u32 serial; /* Serial number */
|
||||
__u8 label[11]; /* FS label */
|
||||
__u8 fs_type[8]; /* FS Type */
|
||||
|
||||
/* fill up to 512 bytes */
|
||||
__u8 junk[422];
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct boot_sector_16 {
|
||||
__u8 ignored[3]; /* Boot strap short or near jump */
|
||||
__u8 system_id[8]; /* Name - can be used to special case
|
||||
partition manager volumes */
|
||||
__u8 sector_size[2]; /* bytes per logical sector */
|
||||
__u8 cluster_size; /* sectors/cluster */
|
||||
__u16 reserved; /* reserved sectors */
|
||||
__u8 fats; /* number of FATs */
|
||||
__u8 dir_entries[2]; /* root directory entries */
|
||||
__u8 sectors[2]; /* number of sectors */
|
||||
__u8 media; /* media code (unused) */
|
||||
__u16 fat_length; /* sectors/FAT */
|
||||
__u16 secs_track; /* sectors per track */
|
||||
__u16 heads; /* number of heads */
|
||||
__u32 hidden; /* hidden sectors (unused) */
|
||||
__u32 total_sect; /* number of sectors (if sectors == 0) */
|
||||
|
||||
__u8 drive_number; /* Logical Drive Number */
|
||||
__u8 reserved2; /* Unused */
|
||||
|
||||
__u8 extended_sig; /* Extended Signature (0x29) */
|
||||
__u32 serial; /* Serial number */
|
||||
__u8 label[11]; /* FS label */
|
||||
__u8 fs_type[8]; /* FS Type */
|
||||
|
||||
/* fill up to 512 bytes */
|
||||
__u8 junk[450];
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct info_sector {
|
||||
__u32 magic; /* Magic for info sector ('RRaA') */
|
||||
__u8 junk[0x1dc];
|
||||
__u32 reserved1; /* Nothing as far as I can tell */
|
||||
__u32 signature; /* 0x61417272 ('rrAa') */
|
||||
__u32 free_clusters; /* Free cluster count. -1 if unknown */
|
||||
__u32 next_cluster; /* Most recently allocated cluster. */
|
||||
__u32 reserved2[3];
|
||||
__u16 reserved3;
|
||||
__u16 boot_sign;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
__u8 name[8], ext[3]; /* name and extension */
|
||||
__u8 attr; /* attribute bits */
|
||||
__u8 lcase; /* Case for base and extension */
|
||||
__u8 ctime_ms; /* Creation time, milliseconds */
|
||||
__u16 ctime; /* Creation time */
|
||||
__u16 cdate; /* Creation date */
|
||||
__u16 adate; /* Last access date */
|
||||
__u16 starthi; /* High 16 bits of cluster in FAT32 */
|
||||
__u16 time, date, start; /* time, date and first cluster */
|
||||
__u32 size; /* file size (in bytes) */
|
||||
} __attribute__ ((packed)) DIR_ENT;
|
||||
|
||||
typedef struct _dos_file {
|
||||
DIR_ENT dir_ent;
|
||||
char *lfn;
|
||||
loff_t offset;
|
||||
loff_t lfn_offset;
|
||||
struct _dos_file *parent; /* parent directory */
|
||||
struct _dos_file *next; /* next entry */
|
||||
struct _dos_file *first; /* first entry (directory only) */
|
||||
} DOS_FILE;
|
||||
|
||||
typedef struct {
|
||||
unsigned long value;
|
||||
unsigned long reserved;
|
||||
} FAT_ENTRY;
|
||||
|
||||
typedef struct {
|
||||
int nfats;
|
||||
loff_t fat_start;
|
||||
unsigned int fat_size; /* unit is bytes */
|
||||
unsigned int fat_bits; /* size of a FAT entry */
|
||||
unsigned int eff_fat_bits; /* # of used bits in a FAT entry */
|
||||
unsigned long root_cluster; /* 0 for old-style root dir */
|
||||
loff_t root_start;
|
||||
unsigned int root_entries;
|
||||
loff_t data_start;
|
||||
unsigned int cluster_size;
|
||||
unsigned long clusters;
|
||||
loff_t fsinfo_start; /* 0 if not present */
|
||||
long free_clusters;
|
||||
loff_t backupboot_start; /* 0 if not present */
|
||||
unsigned char *fat;
|
||||
DOS_FILE **cluster_owner;
|
||||
char *label;
|
||||
} DOS_FS;
|
||||
|
||||
#ifndef offsetof
|
||||
#define offsetof(t,e) ((int)&(((t *)0)->e))
|
||||
#endif
|
||||
|
||||
extern int interactive, rw, list, verbose, test, write_immed;
|
||||
extern int atari_format;
|
||||
extern unsigned n_files;
|
||||
extern void *mem_queue;
|
||||
extern unsigned retandroid;
|
||||
|
||||
/* value to use as end-of-file marker */
|
||||
#define FAT_EOF(fs) ((atari_format ? 0xfff : 0xff8) | FAT_EXTD(fs))
|
||||
#define FAT_IS_EOF(fs,v) ((unsigned long)(v) >= (0xff8|FAT_EXTD(fs)))
|
||||
/* value to mark bad clusters */
|
||||
#define FAT_BAD(fs) (0xff7 | FAT_EXTD(fs))
|
||||
/* range of values used for bad clusters */
|
||||
#define FAT_MIN_BAD(fs) ((atari_format ? 0xff0 : 0xff7) | FAT_EXTD(fs))
|
||||
#define FAT_MAX_BAD(fs) ((atari_format ? 0xff7 : 0xff7) | FAT_EXTD(fs))
|
||||
#define FAT_IS_BAD(fs,v) ((v) >= FAT_MIN_BAD(fs) && (v) <= FAT_MAX_BAD(fs))
|
||||
|
||||
/* return -16 as a number with fs->fat_bits bits */
|
||||
#define FAT_EXTD(fs) (((1 << fs->eff_fat_bits)-1) & ~0xf)
|
||||
|
||||
/* marker for files with no 8.3 name */
|
||||
#define FAT_NO_83NAME 32
|
||||
|
||||
#endif
|
128
dosfstools/src/dosfslabel.c
Normal file
128
dosfstools/src/dosfslabel.c
Normal file
@ -0,0 +1,128 @@
|
||||
/* dosfslabel.c - User interface
|
||||
|
||||
Copyright (C) 1993 Werner Almesberger <werner.almesberger@lrc.di.epfl.ch>
|
||||
Copyright (C) 1998 Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de>
|
||||
Copyright (C) 2007 Red Hat, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
On Debian systems, the complete text of the GNU General Public License
|
||||
can be found in /usr/share/common-licenses/GPL-3 file.
|
||||
*/
|
||||
|
||||
#include "version.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <getopt.h>
|
||||
|
||||
#ifdef _USING_BIONIC_
|
||||
#include <linux/fs.h>
|
||||
#endif
|
||||
|
||||
#include "common.h"
|
||||
#include "dosfsck.h"
|
||||
#include "io.h"
|
||||
#include "boot.h"
|
||||
#include "fat.h"
|
||||
#include "file.h"
|
||||
#include "check.h"
|
||||
|
||||
int interactive = 0, rw = 0, list = 0, test = 0, verbose = 0, write_immed = 0;
|
||||
int atari_format = 0;
|
||||
unsigned n_files = 0;
|
||||
void *mem_queue = NULL;
|
||||
|
||||
static void usage(int error)
|
||||
{
|
||||
FILE *f = error ? stderr : stdout;
|
||||
int status = error ? 1 : 0;
|
||||
|
||||
fprintf(f, "usage: dosfslabel device [label]\n");
|
||||
exit(status);
|
||||
}
|
||||
|
||||
/*
|
||||
* ++roman: On m68k, check if this is an Atari; if yes, turn on Atari variant
|
||||
* of MS-DOS filesystem by default.
|
||||
*/
|
||||
static void check_atari(void)
|
||||
{
|
||||
#ifdef __mc68000__
|
||||
FILE *f;
|
||||
char line[128], *p;
|
||||
|
||||
if (!(f = fopen("/proc/hardware", "r"))) {
|
||||
perror("/proc/hardware");
|
||||
return;
|
||||
}
|
||||
|
||||
while (fgets(line, sizeof(line), f)) {
|
||||
if (strncmp(line, "Model:", 6) == 0) {
|
||||
p = line + 6;
|
||||
p += strspn(p, " \t");
|
||||
if (strncmp(p, "Atari ", 6) == 0)
|
||||
atari_format = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
fclose(f);
|
||||
#endif
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
DOS_FS fs;
|
||||
rw = 0;
|
||||
|
||||
char *device = NULL;
|
||||
char *label = NULL;
|
||||
|
||||
check_atari();
|
||||
|
||||
if (argc < 2 || argc > 3)
|
||||
usage(1);
|
||||
|
||||
if (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help"))
|
||||
usage(0);
|
||||
else if (!strcmp(argv[1], "-V") || !strcmp(argv[1], "--version")) {
|
||||
printf("dosfslabel " VERSION ", " VERSION_DATE ", FAT32, LFN\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
device = argv[1];
|
||||
if (argc == 3) {
|
||||
label = argv[2];
|
||||
if (strlen(label) > 11) {
|
||||
fprintf(stderr,
|
||||
"dosfslabel: labels can be no longer than 11 characters\n");
|
||||
exit(1);
|
||||
}
|
||||
rw = 1;
|
||||
}
|
||||
|
||||
fs_open(device, rw);
|
||||
read_boot(&fs);
|
||||
if (!rw) {
|
||||
fprintf(stdout, "%s\n", fs.label);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
write_label(&fs, label);
|
||||
fs_close(rw);
|
||||
return 0;
|
||||
}
|
547
dosfstools/src/fat.c
Normal file
547
dosfstools/src/fat.c
Normal file
@ -0,0 +1,547 @@
|
||||
/* fat.c - Read/write access to the FAT
|
||||
|
||||
Copyright (C) 1993 Werner Almesberger <werner.almesberger@lrc.di.epfl.ch>
|
||||
Copyright (C) 1998 Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
On Debian systems, the complete text of the GNU General Public License
|
||||
can be found in /usr/share/common-licenses/GPL-3 file.
|
||||
*/
|
||||
|
||||
/* FAT32, VFAT, Atari format support, and various fixes additions May 1998
|
||||
* by Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de> */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "common.h"
|
||||
#include "dosfsck.h"
|
||||
#include "io.h"
|
||||
#include "check.h"
|
||||
#include "fat.h"
|
||||
|
||||
/**
|
||||
* Fetch the FAT entry for a specified cluster.
|
||||
*
|
||||
* @param[out] entry Cluster to which cluster of interest is linked
|
||||
* @param[in] fat FAT table for the partition
|
||||
* @param[in] cluster Cluster of interest
|
||||
* @param[in] fs Information from the FAT boot sectors (bits per FAT entry)
|
||||
*/
|
||||
void get_fat(FAT_ENTRY * entry, void *fat, unsigned long cluster, DOS_FS * fs)
|
||||
{
|
||||
unsigned char *ptr;
|
||||
|
||||
switch (fs->fat_bits) {
|
||||
case 12:
|
||||
ptr = &((unsigned char *)fat)[cluster * 3 / 2];
|
||||
entry->value = 0xfff & (cluster & 1 ? (ptr[0] >> 4) | (ptr[1] << 4) :
|
||||
(ptr[0] | ptr[1] << 8));
|
||||
break;
|
||||
case 16:
|
||||
entry->value = CF_LE_W(((unsigned short *)fat)[cluster]);
|
||||
break;
|
||||
case 32:
|
||||
/* According to M$, the high 4 bits of a FAT32 entry are reserved and
|
||||
* are not part of the cluster number. So we cut them off. */
|
||||
{
|
||||
unsigned long e = CF_LE_L(((unsigned int *)fat)[cluster]);
|
||||
entry->value = e & 0xfffffff;
|
||||
entry->reserved = e >> 28;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
die("Bad FAT entry size: %d bits.", fs->fat_bits);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a bookkeeping structure from the partition's FAT table.
|
||||
* If the partition has multiple FATs and they don't agree, try to pick a winner,
|
||||
* and queue a command to overwrite the loser.
|
||||
* One error that is fixed here is a cluster that links to something out of range.
|
||||
*
|
||||
* @param[inout] fs Information about the filesystem
|
||||
*/
|
||||
void read_fat(DOS_FS * fs)
|
||||
{
|
||||
int eff_size;
|
||||
unsigned long i;
|
||||
void *first, *second = NULL;
|
||||
int first_ok, second_ok;
|
||||
unsigned long total_num_clusters;
|
||||
|
||||
/* Clean up from previous pass */
|
||||
free(fs->fat);
|
||||
free(fs->cluster_owner);
|
||||
fs->fat = NULL;
|
||||
fs->cluster_owner = NULL;
|
||||
|
||||
total_num_clusters = fs->clusters + 2UL;
|
||||
eff_size = (total_num_clusters * fs->fat_bits + 7) / 8ULL;
|
||||
first = alloc(eff_size);
|
||||
fs_read(fs->fat_start, eff_size, first);
|
||||
if (fs->nfats > 1) {
|
||||
second = alloc(eff_size);
|
||||
fs_read(fs->fat_start + fs->fat_size, eff_size, second);
|
||||
}
|
||||
if (second && memcmp(first, second, eff_size) != 0) {
|
||||
FAT_ENTRY first_media, second_media;
|
||||
get_fat(&first_media, first, 0, fs);
|
||||
get_fat(&second_media, second, 0, fs);
|
||||
first_ok = (first_media.value & FAT_EXTD(fs)) == FAT_EXTD(fs);
|
||||
second_ok = (second_media.value & FAT_EXTD(fs)) == FAT_EXTD(fs);
|
||||
if (first_ok && !second_ok) {
|
||||
printf("FATs differ - using first FAT.\n");
|
||||
fs_write(fs->fat_start + fs->fat_size, eff_size, first);
|
||||
}
|
||||
if (!first_ok && second_ok) {
|
||||
printf("FATs differ - using second FAT.\n");
|
||||
fs_write(fs->fat_start, eff_size, second);
|
||||
memcpy(first, second, eff_size);
|
||||
}
|
||||
if (first_ok && second_ok) {
|
||||
if (interactive) {
|
||||
printf("FATs differ but appear to be intact. Use which FAT ?\n"
|
||||
"1) Use first FAT\n2) Use second FAT\n");
|
||||
if (get_key("12", "?") == '1') {
|
||||
fs_write(fs->fat_start + fs->fat_size, eff_size, first);
|
||||
} else {
|
||||
fs_write(fs->fat_start, eff_size, second);
|
||||
memcpy(first, second, eff_size);
|
||||
}
|
||||
} else {
|
||||
printf("FATs differ but appear to be intact. Using first "
|
||||
"FAT.\n");
|
||||
fs_write(fs->fat_start + fs->fat_size, eff_size, first);
|
||||
}
|
||||
}
|
||||
if (!first_ok && !second_ok) {
|
||||
printf("Both FATs appear to be corrupt. Giving up.\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
if (second) {
|
||||
free(second);
|
||||
}
|
||||
fs->fat = (unsigned char *)first;
|
||||
|
||||
fs->cluster_owner = alloc(total_num_clusters * sizeof(DOS_FILE *));
|
||||
memset(fs->cluster_owner, 0, (total_num_clusters * sizeof(DOS_FILE *)));
|
||||
|
||||
/* Truncate any cluster chains that link to something out of range */
|
||||
for (i = 2; i < fs->clusters + 2; i++) {
|
||||
FAT_ENTRY curEntry;
|
||||
get_fat(&curEntry, fs->fat, i, fs);
|
||||
if (curEntry.value == 1) {
|
||||
printf("Cluster %ld out of range (1). Setting to EOF.\n", i - 2);
|
||||
set_fat(fs, i, -1);
|
||||
}
|
||||
if (curEntry.value >= fs->clusters + 2 &&
|
||||
(curEntry.value < FAT_MIN_BAD(fs))) {
|
||||
printf("Cluster %ld out of range (%ld > %ld). Setting to EOF.\n",
|
||||
i - 2, curEntry.value, fs->clusters + 2 - 1);
|
||||
set_fat(fs, i, -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the FAT entry for a specified cluster
|
||||
* (i.e., change the cluster it links to).
|
||||
* Queue a command to write out this change.
|
||||
*
|
||||
* @param[in,out] fs Information about the filesystem
|
||||
* @param[in] cluster Cluster to change
|
||||
* @param[in] new Cluster to link to
|
||||
* Special values:
|
||||
* 0 == free cluster
|
||||
* -1 == end-of-chain
|
||||
* -2 == bad cluster
|
||||
*/
|
||||
void set_fat(DOS_FS * fs, unsigned long cluster, unsigned long new)
|
||||
{
|
||||
unsigned char *data = NULL;
|
||||
int size;
|
||||
loff_t offs;
|
||||
|
||||
if ((long)new == -1)
|
||||
new = FAT_EOF(fs);
|
||||
else if ((long)new == -2)
|
||||
new = FAT_BAD(fs);
|
||||
switch (fs->fat_bits) {
|
||||
case 12:
|
||||
data = fs->fat + cluster * 3 / 2;
|
||||
offs = fs->fat_start + cluster * 3 / 2;
|
||||
if (cluster & 1) {
|
||||
FAT_ENTRY prevEntry;
|
||||
get_fat(&prevEntry, fs->fat, cluster - 1, fs);
|
||||
data[0] = ((new & 0xf) << 4) | (prevEntry.value >> 8);
|
||||
data[1] = new >> 4;
|
||||
} else {
|
||||
FAT_ENTRY subseqEntry;
|
||||
get_fat(&subseqEntry, fs->fat, cluster + 1, fs);
|
||||
data[0] = new & 0xff;
|
||||
data[1] = (new >> 8) | (cluster == fs->clusters - 1 ? 0 :
|
||||
(0xff & subseqEntry.value) << 4);
|
||||
}
|
||||
size = 2;
|
||||
break;
|
||||
case 16:
|
||||
data = fs->fat + cluster * 2;
|
||||
offs = fs->fat_start + cluster * 2;
|
||||
*(unsigned short *)data = CT_LE_W(new);
|
||||
size = 2;
|
||||
break;
|
||||
case 32:
|
||||
{
|
||||
FAT_ENTRY curEntry;
|
||||
get_fat(&curEntry, fs->fat, cluster, fs);
|
||||
|
||||
data = fs->fat + cluster * 4;
|
||||
offs = fs->fat_start + cluster * 4;
|
||||
/* According to M$, the high 4 bits of a FAT32 entry are reserved and
|
||||
* are not part of the cluster number. So we never touch them. */
|
||||
*(unsigned long *)data = CT_LE_L((new & 0xfffffff) |
|
||||
(curEntry.reserved << 28));
|
||||
size = 4;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
die("Bad FAT entry size: %d bits.", fs->fat_bits);
|
||||
}
|
||||
fs_write(offs, size, data);
|
||||
if (fs->nfats > 1) {
|
||||
fs_write(offs + fs->fat_size, size, data);
|
||||
}
|
||||
}
|
||||
|
||||
int bad_cluster(DOS_FS * fs, unsigned long cluster)
|
||||
{
|
||||
FAT_ENTRY curEntry;
|
||||
get_fat(&curEntry, fs->fat, cluster, fs);
|
||||
|
||||
return FAT_IS_BAD(fs, curEntry.value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cluster to which the specified cluster is linked.
|
||||
* If the linked cluster is marked bad, abort.
|
||||
*
|
||||
* @param[in] fs Information about the filesystem
|
||||
* @param[in] cluster Cluster to follow
|
||||
*
|
||||
* @return -1 'cluster' is at the end of the chain
|
||||
* @return Other values Next cluster in this chain
|
||||
*/
|
||||
unsigned long next_cluster(DOS_FS * fs, unsigned long cluster)
|
||||
{
|
||||
unsigned long value;
|
||||
FAT_ENTRY curEntry;
|
||||
|
||||
get_fat(&curEntry, fs->fat, cluster, fs);
|
||||
|
||||
value = curEntry.value;
|
||||
if (FAT_IS_BAD(fs, value))
|
||||
die("Internal error: next_cluster on bad cluster");
|
||||
return FAT_IS_EOF(fs, value) ? -1 : value;
|
||||
}
|
||||
|
||||
loff_t cluster_start(DOS_FS * fs, unsigned long cluster)
|
||||
{
|
||||
return fs->data_start + ((loff_t) cluster -
|
||||
2) * (unsigned long long)fs->cluster_size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update internal bookkeeping to show that the specified cluster belongs
|
||||
* to the specified dentry.
|
||||
*
|
||||
* @param[in,out] fs Information about the filesystem
|
||||
* @param[in] cluster Cluster being assigned
|
||||
* @param[in] owner Information on dentry that owns this cluster
|
||||
* (may be NULL)
|
||||
*/
|
||||
void set_owner(DOS_FS * fs, unsigned long cluster, DOS_FILE * owner)
|
||||
{
|
||||
if (fs->cluster_owner == NULL)
|
||||
die("Internal error: attempt to set owner in non-existent table");
|
||||
|
||||
if (owner && fs->cluster_owner[cluster]
|
||||
&& (fs->cluster_owner[cluster] != owner))
|
||||
die("Internal error: attempt to change file owner");
|
||||
fs->cluster_owner[cluster] = owner;
|
||||
}
|
||||
|
||||
DOS_FILE *get_owner(DOS_FS * fs, unsigned long cluster)
|
||||
{
|
||||
if (fs->cluster_owner == NULL)
|
||||
return NULL;
|
||||
else
|
||||
return fs->cluster_owner[cluster];
|
||||
}
|
||||
|
||||
void fix_bad(DOS_FS * fs)
|
||||
{
|
||||
unsigned long i;
|
||||
|
||||
if (verbose)
|
||||
printf("Checking for bad clusters.\n");
|
||||
for (i = 2; i < fs->clusters + 2; i++) {
|
||||
FAT_ENTRY curEntry;
|
||||
get_fat(&curEntry, fs->fat, i, fs);
|
||||
|
||||
if (!get_owner(fs, i) && !FAT_IS_BAD(fs, curEntry.value))
|
||||
if (!fs_test(cluster_start(fs, i), fs->cluster_size)) {
|
||||
printf("Cluster %lu is unreadable.\n", i);
|
||||
set_fat(fs, i, -2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void reclaim_free(DOS_FS * fs)
|
||||
{
|
||||
int reclaimed;
|
||||
unsigned long i;
|
||||
|
||||
if (verbose)
|
||||
printf("Checking for unused clusters.\n");
|
||||
reclaimed = 0;
|
||||
for (i = 2; i < fs->clusters + 2; i++) {
|
||||
FAT_ENTRY curEntry;
|
||||
get_fat(&curEntry, fs->fat, i, fs);
|
||||
|
||||
if (!get_owner(fs, i) && curEntry.value &&
|
||||
!FAT_IS_BAD(fs, curEntry.value)) {
|
||||
set_fat(fs, i, 0);
|
||||
reclaimed++;
|
||||
}
|
||||
}
|
||||
if (reclaimed)
|
||||
printf("Reclaimed %d unused cluster%s (%llu bytes).\n", reclaimed,
|
||||
reclaimed == 1 ? "" : "s",
|
||||
(unsigned long long)reclaimed * fs->cluster_size);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assign the specified owner to all orphan chains (except cycles).
|
||||
* Break cross-links between orphan chains.
|
||||
*
|
||||
* @param[in,out] fs Information about the filesystem
|
||||
* @param[in] owner dentry to be assigned ownership of orphans
|
||||
* @param[in,out] num_refs For each orphan cluster [index], how many
|
||||
* clusters link to it.
|
||||
* @param[in] start_cluster Where to start scanning for orphans
|
||||
*/
|
||||
static void tag_free(DOS_FS * fs, DOS_FILE * owner, unsigned long *num_refs,
|
||||
unsigned long start_cluster)
|
||||
{
|
||||
int prev;
|
||||
unsigned long i, walk;
|
||||
|
||||
if (start_cluster == 0)
|
||||
start_cluster = 2;
|
||||
|
||||
for (i = start_cluster; i < fs->clusters + 2; i++) {
|
||||
FAT_ENTRY curEntry;
|
||||
get_fat(&curEntry, fs->fat, i, fs);
|
||||
|
||||
/* If the current entry is the head of an un-owned chain... */
|
||||
if (curEntry.value && !FAT_IS_BAD(fs, curEntry.value) &&
|
||||
!get_owner(fs, i) && !num_refs[i]) {
|
||||
prev = 0;
|
||||
/* Walk the chain, claiming ownership as we go */
|
||||
for (walk = i; walk != -1; walk = next_cluster(fs, walk)) {
|
||||
if (!get_owner(fs, walk)) {
|
||||
set_owner(fs, walk, owner);
|
||||
} else {
|
||||
/* We've run into cross-links between orphaned chains,
|
||||
* or a cycle with a tail.
|
||||
* Terminate this orphan chain (break the link)
|
||||
*/
|
||||
set_fat(fs, prev, -1);
|
||||
|
||||
/* This is not necessary because 'walk' is owned and thus
|
||||
* will never become the head of a chain (the only case
|
||||
* that would matter during reclaim to files).
|
||||
* It's easier to decrement than to prove that it's
|
||||
* unnecessary.
|
||||
*/
|
||||
num_refs[walk]--;
|
||||
break;
|
||||
}
|
||||
prev = walk;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Recover orphan chains to files, handling any cycles or cross-links.
|
||||
*
|
||||
* @param[in,out] fs Information about the filesystem
|
||||
*/
|
||||
void reclaim_file(DOS_FS * fs)
|
||||
{
|
||||
DOS_FILE orphan;
|
||||
int reclaimed, files;
|
||||
int changed = 0;
|
||||
unsigned long i, next, walk;
|
||||
unsigned long *num_refs = NULL; /* Only for orphaned clusters */
|
||||
unsigned long total_num_clusters;
|
||||
|
||||
if (verbose)
|
||||
printf("Reclaiming unconnected clusters.\n");
|
||||
|
||||
total_num_clusters = fs->clusters + 2UL;
|
||||
num_refs = alloc(total_num_clusters * sizeof(unsigned long));
|
||||
memset(num_refs, 0, (total_num_clusters * sizeof(unsigned long)));
|
||||
|
||||
/* Guarantee that all orphan chains (except cycles) end cleanly
|
||||
* with an end-of-chain mark.
|
||||
*/
|
||||
|
||||
for (i = 2; i < total_num_clusters; i++) {
|
||||
FAT_ENTRY curEntry;
|
||||
get_fat(&curEntry, fs->fat, i, fs);
|
||||
|
||||
next = curEntry.value;
|
||||
if (!get_owner(fs, i) && next && next < fs->clusters + 2) {
|
||||
/* Cluster is linked, but not owned (orphan) */
|
||||
FAT_ENTRY nextEntry;
|
||||
get_fat(&nextEntry, fs->fat, next, fs);
|
||||
|
||||
/* Mark it end-of-chain if it links into an owned cluster,
|
||||
* a free cluster, or a bad cluster.
|
||||
*/
|
||||
if (get_owner(fs, next) || !nextEntry.value ||
|
||||
FAT_IS_BAD(fs, nextEntry.value))
|
||||
set_fat(fs, i, -1);
|
||||
else
|
||||
num_refs[next]++;
|
||||
}
|
||||
}
|
||||
|
||||
/* Scan until all the orphans are accounted for,
|
||||
* and all cycles and cross-links are broken
|
||||
*/
|
||||
do {
|
||||
tag_free(fs, &orphan, num_refs, changed);
|
||||
changed = 0;
|
||||
|
||||
/* Any unaccounted-for orphans must be part of a cycle */
|
||||
for (i = 2; i < total_num_clusters; i++) {
|
||||
FAT_ENTRY curEntry;
|
||||
get_fat(&curEntry, fs->fat, i, fs);
|
||||
|
||||
if (curEntry.value && !FAT_IS_BAD(fs, curEntry.value) &&
|
||||
!get_owner(fs, i)) {
|
||||
if (!num_refs[curEntry.value]--)
|
||||
die("Internal error: num_refs going below zero");
|
||||
set_fat(fs, i, -1);
|
||||
changed = curEntry.value;
|
||||
printf("Broke cycle at cluster %lu in free chain.\n", i);
|
||||
|
||||
/* If we've created a new chain head,
|
||||
* tag_free() can claim it
|
||||
*/
|
||||
if (num_refs[curEntry.value] == 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
while (changed);
|
||||
|
||||
/* Now we can start recovery */
|
||||
files = reclaimed = 0;
|
||||
for (i = 2; i < total_num_clusters; i++)
|
||||
/* If this cluster is the head of an orphan chain... */
|
||||
if (get_owner(fs, i) == &orphan && !num_refs[i]) {
|
||||
DIR_ENT de;
|
||||
loff_t offset;
|
||||
files++;
|
||||
offset = alloc_rootdir_entry(fs, &de, "FSCK%04d");
|
||||
de.start = CT_LE_W(i & 0xffff);
|
||||
if (fs->fat_bits == 32)
|
||||
de.starthi = CT_LE_W(i >> 16);
|
||||
for (walk = i; walk > 0 && walk != -1;
|
||||
walk = next_cluster(fs, walk)) {
|
||||
de.size = CT_LE_L(CF_LE_L(de.size) + fs->cluster_size);
|
||||
reclaimed++;
|
||||
}
|
||||
fs_write(offset, sizeof(DIR_ENT), &de);
|
||||
}
|
||||
if (reclaimed)
|
||||
printf("Reclaimed %d unused cluster%s (%llu bytes) in %d chain%s.\n",
|
||||
reclaimed, reclaimed == 1 ? "" : "s",
|
||||
(unsigned long long)reclaimed * fs->cluster_size, files,
|
||||
files == 1 ? "" : "s");
|
||||
|
||||
free(num_refs);
|
||||
}
|
||||
|
||||
unsigned long update_free(DOS_FS * fs)
|
||||
{
|
||||
unsigned long i;
|
||||
unsigned long free = 0;
|
||||
int do_set = 0;
|
||||
|
||||
for (i = 2; i < fs->clusters + 2; i++) {
|
||||
FAT_ENTRY curEntry;
|
||||
get_fat(&curEntry, fs->fat, i, fs);
|
||||
|
||||
if (!get_owner(fs, i) && !FAT_IS_BAD(fs, curEntry.value))
|
||||
++free;
|
||||
}
|
||||
|
||||
if (!fs->fsinfo_start)
|
||||
return free;
|
||||
|
||||
if (verbose)
|
||||
printf("Checking free cluster summary.\n");
|
||||
if (fs->free_clusters != 0xFFFFFFFF) {
|
||||
if (free != fs->free_clusters) {
|
||||
printf("Free cluster summary wrong (%ld vs. really %ld)\n",
|
||||
fs->free_clusters, free);
|
||||
if (interactive)
|
||||
printf("1) Correct\n2) Don't correct\n");
|
||||
else
|
||||
printf(" Auto-correcting.\n");
|
||||
if (!interactive || get_key("12", "?") == '1')
|
||||
do_set = 1;
|
||||
}
|
||||
} else {
|
||||
printf("Free cluster summary uninitialized (should be %ld)\n", free);
|
||||
if (rw) {
|
||||
if (interactive)
|
||||
printf("1) Set it\n2) Leave it uninitialized\n");
|
||||
else
|
||||
printf(" Auto-setting.\n");
|
||||
if (!interactive || get_key("12", "?") == '1')
|
||||
do_set = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (do_set) {
|
||||
unsigned long le_free = CT_LE_L(free);
|
||||
fs->free_clusters = free;
|
||||
fs_write(fs->fsinfo_start + offsetof(struct info_sector, free_clusters),
|
||||
sizeof(le_free), &le_free);
|
||||
}
|
||||
|
||||
return free;
|
||||
}
|
84
dosfstools/src/fat.h
Normal file
84
dosfstools/src/fat.h
Normal file
@ -0,0 +1,84 @@
|
||||
/* fat.h - Read/write access to the FAT
|
||||
|
||||
Copyright (C) 1993 Werner Almesberger <werner.almesberger@lrc.di.epfl.ch>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
On Debian systems, the complete text of the GNU General Public License
|
||||
can be found in /usr/share/common-licenses/GPL-3 file.
|
||||
*/
|
||||
|
||||
#ifndef _FAT_H
|
||||
#define _FAT_H
|
||||
|
||||
void read_fat(DOS_FS * fs);
|
||||
|
||||
/* Loads the FAT of the file system described by FS. Initializes the FAT,
|
||||
replaces broken FATs and rejects invalid cluster entries. */
|
||||
|
||||
void get_fat(FAT_ENTRY * entry, void *fat, unsigned long cluster, DOS_FS * fs);
|
||||
|
||||
/* Retrieve the FAT entry (next chained cluster) for CLUSTER. */
|
||||
|
||||
void set_fat(DOS_FS * fs, unsigned long cluster, unsigned long new);
|
||||
|
||||
/* Changes the value of the CLUSTERth cluster of the FAT of FS to NEW. Special
|
||||
values of NEW are -1 (EOF, 0xff8 or 0xfff8) and -2 (bad sector, 0xff7 or
|
||||
0xfff7) */
|
||||
|
||||
int bad_cluster(DOS_FS * fs, unsigned long cluster);
|
||||
|
||||
/* Returns a non-zero integer if the CLUSTERth cluster is marked as bad or zero
|
||||
otherwise. */
|
||||
|
||||
unsigned long next_cluster(DOS_FS * fs, unsigned long cluster);
|
||||
|
||||
/* Returns the number of the cluster following CLUSTER, or -1 if this is the
|
||||
last cluster of the respective cluster chain. CLUSTER must not be a bad
|
||||
cluster. */
|
||||
|
||||
loff_t cluster_start(DOS_FS * fs, unsigned long cluster);
|
||||
|
||||
/* Returns the byte offset of CLUSTER, relative to the respective device. */
|
||||
|
||||
void set_owner(DOS_FS * fs, unsigned long cluster, DOS_FILE * owner);
|
||||
|
||||
/* Sets the owner pointer of the respective cluster to OWNER. If OWNER was NULL
|
||||
before, it can be set to NULL or any non-NULL value. Otherwise, only NULL is
|
||||
accepted as the new value. */
|
||||
|
||||
DOS_FILE *get_owner(DOS_FS * fs, unsigned long cluster);
|
||||
|
||||
/* Returns the owner of the repective cluster or NULL if the cluster has no
|
||||
owner. */
|
||||
|
||||
void fix_bad(DOS_FS * fs);
|
||||
|
||||
/* Scans the disk for currently unused bad clusters and marks them as bad. */
|
||||
|
||||
void reclaim_free(DOS_FS * fs);
|
||||
|
||||
/* Marks all allocated, but unused clusters as free. */
|
||||
|
||||
void reclaim_file(DOS_FS * fs);
|
||||
|
||||
/* Scans the FAT for chains of allocated, but unused clusters and creates files
|
||||
for them in the root directory. Also tries to fix all inconsistencies (e.g.
|
||||
loops, shared clusters, etc.) in the process. */
|
||||
|
||||
unsigned long update_free(DOS_FS * fs);
|
||||
|
||||
/* Updates free cluster count in FSINFO sector. */
|
||||
|
||||
#endif
|
282
dosfstools/src/file.c
Normal file
282
dosfstools/src/file.c
Normal file
@ -0,0 +1,282 @@
|
||||
/* file.c - Additional file attributes
|
||||
|
||||
Copyright (C) 1993 Werner Almesberger <werner.almesberger@lrc.di.epfl.ch>
|
||||
Copyright (C) 1998 Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
On Debian systems, the complete text of the GNU General Public License
|
||||
can be found in /usr/share/common-licenses/GPL-3 file.
|
||||
*/
|
||||
|
||||
/* FAT32, VFAT, Atari format support, and various fixes additions May 1998
|
||||
* by Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de> */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define _LINUX_STAT_H /* hack to avoid inclusion of <linux/stat.h> */
|
||||
#define _LINUX_STRING_H_ /* hack to avoid inclusion of <linux/string.h> */
|
||||
#define _LINUX_FS_H /* hack to avoid inclusion of <linux/fs.h> */
|
||||
|
||||
#include <asm/types.h>
|
||||
|
||||
#include <linux/msdos_fs.h>
|
||||
|
||||
#include "common.h"
|
||||
#include "file.h"
|
||||
|
||||
FDSC *fp_root = NULL;
|
||||
|
||||
static void put_char(char **p, unsigned char c)
|
||||
{
|
||||
if ((c >= ' ' && c < 0x7f) || c >= 0xa0)
|
||||
*(*p)++ = c;
|
||||
else {
|
||||
*(*p)++ = '\\';
|
||||
*(*p)++ = '0' + (c >> 6);
|
||||
*(*p)++ = '0' + ((c >> 3) & 7);
|
||||
*(*p)++ = '0' + (c & 7);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct the "pretty-printed" representation of the name in a short directory entry.
|
||||
*
|
||||
* @param[in] fixed Pointer to name[0] of a DIR_ENT
|
||||
*
|
||||
* @return Pointer to static string containing pretty "8.3" equivalent of the
|
||||
* name in the directory entry.
|
||||
*/
|
||||
char *file_name(unsigned char *fixed)
|
||||
{
|
||||
static char path[MSDOS_NAME * 4 + 2];
|
||||
char *p;
|
||||
int i, j;
|
||||
|
||||
p = path;
|
||||
for (i = j = 0; i < 8; i++)
|
||||
if (fixed[i] != ' ') {
|
||||
while (j++ < i)
|
||||
*p++ = ' ';
|
||||
put_char(&p, fixed[i]);
|
||||
}
|
||||
if (strncmp((const char *)(fixed + 8), " ", 3)) {
|
||||
*p++ = '.';
|
||||
for (i = j = 0; i < 3; i++)
|
||||
if (fixed[i + 8] != ' ') {
|
||||
while (j++ < i)
|
||||
*p++ = ' ';
|
||||
put_char(&p, fixed[i + 8]);
|
||||
}
|
||||
}
|
||||
*p = 0;
|
||||
return path;
|
||||
}
|
||||
|
||||
int file_cvt(unsigned char *name, unsigned char *fixed)
|
||||
{
|
||||
unsigned char c;
|
||||
int size, ext, cnt;
|
||||
|
||||
size = 8;
|
||||
ext = 0;
|
||||
while (*name) {
|
||||
c = *name;
|
||||
if (c < ' ' || c > 0x7e || strchr("*?<>|\"/", c)) {
|
||||
printf("Invalid character in name. Use \\ooo for special "
|
||||
"characters.\n");
|
||||
return 0;
|
||||
}
|
||||
if (c == '.') {
|
||||
if (ext) {
|
||||
printf("Duplicate dots in name.\n");
|
||||
return 0;
|
||||
}
|
||||
while (size--)
|
||||
*fixed++ = ' ';
|
||||
size = 3;
|
||||
ext = 1;
|
||||
name++;
|
||||
continue;
|
||||
}
|
||||
if (c == '\\') {
|
||||
c = 0;
|
||||
for (cnt = 3; cnt; cnt--) {
|
||||
if (*name < '0' || *name > '7') {
|
||||
printf("Invalid octal character.\n");
|
||||
return 0;
|
||||
}
|
||||
c = c * 8 + *name++ - '0';
|
||||
}
|
||||
if (cnt < 4) {
|
||||
printf("Expected three octal digits.\n");
|
||||
return 0;
|
||||
}
|
||||
name += 3;
|
||||
}
|
||||
if (islower(c))
|
||||
c = toupper(c);
|
||||
if (size) {
|
||||
*fixed++ = c;
|
||||
size--;
|
||||
}
|
||||
name++;
|
||||
}
|
||||
if (*name || size == 8)
|
||||
return 0;
|
||||
if (!ext) {
|
||||
while (size--)
|
||||
*fixed++ = ' ';
|
||||
size = 3;
|
||||
}
|
||||
while (size--)
|
||||
*fixed++ = ' ';
|
||||
return 1;
|
||||
}
|
||||
|
||||
void file_add(char *path, FD_TYPE type)
|
||||
{
|
||||
FDSC **current, *walk;
|
||||
char name[MSDOS_NAME];
|
||||
char *here;
|
||||
|
||||
current = &fp_root;
|
||||
if (*path != '/')
|
||||
die("%s: Absolute path required.", path);
|
||||
path++;
|
||||
while (1) {
|
||||
if ((here = strchr(path, '/')))
|
||||
*here = 0;
|
||||
if (!file_cvt((unsigned char *)path, (unsigned char *)name))
|
||||
exit(2);
|
||||
for (walk = *current; walk; walk = walk->next)
|
||||
if (!here && (!strncmp(name, walk->name, MSDOS_NAME) || (type ==
|
||||
fdt_undelete
|
||||
&&
|
||||
!strncmp
|
||||
(name + 1,
|
||||
walk->name
|
||||
+ 1,
|
||||
MSDOS_NAME
|
||||
- 1))))
|
||||
die("Ambiguous name: \"%s\"", path);
|
||||
else if (here && !strncmp(name, walk->name, MSDOS_NAME))
|
||||
break;
|
||||
if (!walk) {
|
||||
walk = alloc(sizeof(FDSC));
|
||||
strncpy(walk->name, name, MSDOS_NAME);
|
||||
walk->type = here ? fdt_none : type;
|
||||
walk->first = NULL;
|
||||
walk->next = *current;
|
||||
*current = walk;
|
||||
}
|
||||
current = &walk->first;
|
||||
if (!here)
|
||||
break;
|
||||
*here = '/';
|
||||
path = here + 1;
|
||||
}
|
||||
}
|
||||
|
||||
FDSC **file_cd(FDSC ** curr, char *fixed)
|
||||
{
|
||||
FDSC **walk;
|
||||
|
||||
if (!curr || !*curr)
|
||||
return NULL;
|
||||
for (walk = curr; *walk; walk = &(*walk)->next)
|
||||
if (!strncmp((*walk)->name, fixed, MSDOS_NAME) && (*walk)->first)
|
||||
return &(*walk)->first;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static FDSC **file_find(FDSC ** dir, char *fixed)
|
||||
{
|
||||
if (!dir || !*dir)
|
||||
return NULL;
|
||||
if (*(unsigned char *)fixed == DELETED_FLAG) {
|
||||
while (*dir) {
|
||||
if (!strncmp((*dir)->name + 1, fixed + 1, MSDOS_NAME - 1)
|
||||
&& !(*dir)->first)
|
||||
return dir;
|
||||
dir = &(*dir)->next;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
while (*dir) {
|
||||
if (!strncmp((*dir)->name, fixed, MSDOS_NAME) && !(*dir)->first)
|
||||
return dir;
|
||||
dir = &(*dir)->next;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Returns the attribute of the file FIXED in directory CURR or FDT_NONE if no
|
||||
such file exists or if CURR is NULL. */
|
||||
FD_TYPE file_type(FDSC ** curr, char *fixed)
|
||||
{
|
||||
FDSC **this;
|
||||
|
||||
if ((this = file_find(curr, fixed)))
|
||||
return (*this)->type;
|
||||
return fdt_none;
|
||||
}
|
||||
|
||||
void file_modify(FDSC ** curr, char *fixed)
|
||||
{
|
||||
FDSC **this, *next;
|
||||
|
||||
if (!(this = file_find(curr, fixed)))
|
||||
die("Internal error: file_find failed");
|
||||
switch ((*this)->type) {
|
||||
case fdt_drop:
|
||||
printf("Dropping %s\n", file_name((unsigned char *)fixed));
|
||||
*(unsigned char *)fixed = DELETED_FLAG;
|
||||
break;
|
||||
case fdt_undelete:
|
||||
*fixed = *(*this)->name;
|
||||
printf("Undeleting %s\n", file_name((unsigned char *)fixed));
|
||||
break;
|
||||
default:
|
||||
die("Internal error: file_modify");
|
||||
}
|
||||
next = (*this)->next;
|
||||
free(*this);
|
||||
*this = next;
|
||||
}
|
||||
|
||||
static void report_unused(FDSC * this)
|
||||
{
|
||||
FDSC *next;
|
||||
|
||||
while (this) {
|
||||
next = this->next;
|
||||
if (this->first)
|
||||
report_unused(this->first);
|
||||
else if (this->type != fdt_none)
|
||||
printf("Warning: did not %s file %s\n", this->type == fdt_drop ?
|
||||
"drop" : "undelete", file_name((unsigned char *)this->name));
|
||||
free(this);
|
||||
this = next;
|
||||
}
|
||||
}
|
||||
|
||||
void file_unused(void)
|
||||
{
|
||||
report_unused(fp_root);
|
||||
}
|
69
dosfstools/src/file.h
Normal file
69
dosfstools/src/file.h
Normal file
@ -0,0 +1,69 @@
|
||||
/* file.h - Additional file attributes
|
||||
|
||||
Copyright (C) 1993 Werner Almesberger <werner.almesberger@lrc.di.epfl.ch>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
On Debian systems, the complete text of the GNU General Public License
|
||||
can be found in /usr/share/common-licenses/GPL-3 file.
|
||||
*/
|
||||
|
||||
#ifndef _FILE_H
|
||||
#define _FILE_H
|
||||
|
||||
typedef enum { fdt_none, fdt_drop, fdt_undelete } FD_TYPE;
|
||||
|
||||
typedef struct _fptr {
|
||||
char name[MSDOS_NAME];
|
||||
FD_TYPE type;
|
||||
struct _fptr *first; /* first entry */
|
||||
struct _fptr *next; /* next file in directory */
|
||||
} FDSC;
|
||||
|
||||
extern FDSC *fp_root;
|
||||
|
||||
char *file_name(unsigned char *fixed);
|
||||
|
||||
/* Returns a pointer to a pretty-printed representation of a fixed MS-DOS file
|
||||
name. */
|
||||
|
||||
int file_cvt(unsigned char *name, unsigned char *fixed);
|
||||
|
||||
/* Converts a pretty-printed file name to the fixed MS-DOS format. Returns a
|
||||
non-zero integer on success, zero on failure. */
|
||||
|
||||
void file_add(char *path, FD_TYPE type);
|
||||
|
||||
/* Define special attributes for a path. TYPE can be either FDT_DROP or
|
||||
FDT_UNDELETE. */
|
||||
|
||||
FDSC **file_cd(FDSC ** curr, char *fixed);
|
||||
|
||||
/* Returns a pointer to the directory descriptor of the subdirectory FIXED of
|
||||
CURR, or NULL if no such subdirectory exists. */
|
||||
|
||||
FD_TYPE file_type(FDSC ** curr, char *fixed);
|
||||
|
||||
/* Returns the attribute of the file FIXED in directory CURR or FDT_NONE if no
|
||||
such file exists or if CURR is NULL. */
|
||||
|
||||
void file_modify(FDSC ** curr, char *fixed);
|
||||
|
||||
/* Performs the necessary operation on the entry of CURR that is named FIXED. */
|
||||
|
||||
void file_unused(void);
|
||||
|
||||
/* Displays warnings for all unused file attributes. */
|
||||
|
||||
#endif
|
230
dosfstools/src/io.c
Normal file
230
dosfstools/src/io.c
Normal file
@ -0,0 +1,230 @@
|
||||
/* io.c - Virtual disk input/output
|
||||
|
||||
Copyright (C) 1993 Werner Almesberger <werner.almesberger@lrc.di.epfl.ch>
|
||||
Copyright (C) 1998 Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
On Debian systems, the complete text of the GNU General Public License
|
||||
can be found in /usr/share/common-licenses/GPL-3 file.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Thu Feb 26 01:15:36 CET 1998: Martin Schulze <joey@infodrom.north.de>
|
||||
* Fixed nasty bug that caused every file with a name like
|
||||
* xxxxxxxx.xxx to be treated as bad name that needed to be fixed.
|
||||
*/
|
||||
|
||||
/* FAT32, VFAT, Atari format support, and various fixes additions May 1998
|
||||
* by Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de> */
|
||||
|
||||
#define _LARGEFILE64_SOURCE
|
||||
#include <sys/types.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <linux/fd.h>
|
||||
|
||||
#include "dosfsck.h"
|
||||
#include "common.h"
|
||||
#include "io.h"
|
||||
|
||||
typedef struct _change {
|
||||
void *data;
|
||||
loff_t pos;
|
||||
int size;
|
||||
struct _change *next;
|
||||
} CHANGE;
|
||||
|
||||
static CHANGE *changes, *last;
|
||||
static int fd, did_change = 0;
|
||||
|
||||
unsigned device_no;
|
||||
|
||||
#ifdef __DJGPP__
|
||||
#include "volume.h" /* DOS lowlevel disk access functions */
|
||||
loff_t llseek(int fd, loff_t offset, int whence)
|
||||
{
|
||||
if ((whence != SEEK_SET) || (fd == 4711))
|
||||
return -1; /* only those supported */
|
||||
return VolumeSeek(offset);
|
||||
}
|
||||
|
||||
#define open OpenVolume
|
||||
#define close CloseVolume
|
||||
#define read(a,b,c) ReadVolume(b,c)
|
||||
#define write(a,b,c) WriteVolume(b,c)
|
||||
#else
|
||||
loff_t llseek(int fd, loff_t offset, int whence)
|
||||
{
|
||||
return (loff_t) lseek64(fd, (off64_t) offset, whence);
|
||||
}
|
||||
#endif
|
||||
|
||||
void fs_open(char *path, int rw)
|
||||
{
|
||||
struct stat stbuf;
|
||||
|
||||
if ((fd = open(path, rw ? O_RDWR : O_RDONLY)) < 0) {
|
||||
perror("open");
|
||||
exit(6);
|
||||
}
|
||||
changes = last = NULL;
|
||||
did_change = 0;
|
||||
|
||||
#ifndef _DJGPP_
|
||||
if (fstat(fd, &stbuf) < 0)
|
||||
pdie("fstat %s", path);
|
||||
device_no = S_ISBLK(stbuf.st_mode) ? (stbuf.st_rdev >> 8) & 0xff : 0;
|
||||
#else
|
||||
if (IsWorkingOnImageFile()) {
|
||||
if (fstat(GetVolumeHandle(), &stbuf) < 0)
|
||||
pdie("fstat image %s", path);
|
||||
device_no = 0;
|
||||
} else {
|
||||
/* return 2 for floppy, 1 for ramdisk, 7 for loopback */
|
||||
/* used by boot.c in Atari mode: floppy always FAT12, */
|
||||
/* loopback / ramdisk only FAT12 if usual floppy size, */
|
||||
/* harddisk always FAT16 on Atari... */
|
||||
device_no = (GetVolumeHandle() < 2) ? 2 : 1;
|
||||
/* telling "floppy" for A:/B:, "ramdisk" for the rest */
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Read data from the partition, accounting for any pending updates that are
|
||||
* queued for writing.
|
||||
*
|
||||
* @param[in] pos Byte offset, relative to the beginning of the partition,
|
||||
* at which to read
|
||||
* @param[in] size Number of bytes to read
|
||||
* @param[out] data Where to put the data read
|
||||
*/
|
||||
void fs_read(loff_t pos, int size, void *data)
|
||||
{
|
||||
CHANGE *walk;
|
||||
int got;
|
||||
|
||||
if (llseek(fd, pos, 0) != pos)
|
||||
pdie("Seek to %lld", pos);
|
||||
if ((got = read(fd, data, size)) < 0)
|
||||
pdie("Read %d bytes at %lld", size, pos);
|
||||
if (got != size)
|
||||
die("Got %d bytes instead of %d at %lld", got, size, pos);
|
||||
for (walk = changes; walk; walk = walk->next) {
|
||||
if (walk->pos < pos + size && walk->pos + walk->size > pos) {
|
||||
if (walk->pos < pos)
|
||||
memcpy(data, (char *)walk->data + pos - walk->pos, min(size,
|
||||
walk->size
|
||||
- pos +
|
||||
walk->pos));
|
||||
else
|
||||
memcpy((char *)data + walk->pos - pos, walk->data,
|
||||
min(walk->size, size + pos - walk->pos));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int fs_test(loff_t pos, int size)
|
||||
{
|
||||
void *scratch;
|
||||
int okay;
|
||||
|
||||
if (llseek(fd, pos, 0) != pos)
|
||||
pdie("Seek to %lld", pos);
|
||||
scratch = alloc(size);
|
||||
okay = read(fd, scratch, size) == size;
|
||||
free(scratch);
|
||||
return okay;
|
||||
}
|
||||
|
||||
void fs_write(loff_t pos, int size, void *data)
|
||||
{
|
||||
CHANGE *new;
|
||||
int did;
|
||||
|
||||
if (write_immed) {
|
||||
did_change = 1;
|
||||
if (llseek(fd, pos, 0) != pos)
|
||||
pdie("Seek to %lld", pos);
|
||||
if ((did = write(fd, data, size)) == size)
|
||||
return;
|
||||
if (did < 0)
|
||||
pdie("Write %d bytes at %lld", size, pos);
|
||||
die("Wrote %d bytes instead of %d at %lld", did, size, pos);
|
||||
}
|
||||
new = alloc(sizeof(CHANGE));
|
||||
new->pos = pos;
|
||||
memcpy(new->data = alloc(new->size = size), data, size);
|
||||
new->next = NULL;
|
||||
if (last)
|
||||
last->next = new;
|
||||
else
|
||||
changes = new;
|
||||
last = new;
|
||||
}
|
||||
|
||||
static void fs_flush(void)
|
||||
{
|
||||
CHANGE *this;
|
||||
int size;
|
||||
|
||||
while (changes) {
|
||||
this = changes;
|
||||
changes = changes->next;
|
||||
if (llseek(fd, this->pos, 0) != this->pos)
|
||||
fprintf(stderr,
|
||||
"Seek to %lld failed: %s\n Did not write %d bytes.\n",
|
||||
(long long)this->pos, strerror(errno), this->size);
|
||||
else if ((size = write(fd, this->data, this->size)) < 0)
|
||||
fprintf(stderr, "Writing %d bytes at %lld failed: %s\n", this->size,
|
||||
(long long)this->pos, strerror(errno));
|
||||
else if (size != this->size)
|
||||
fprintf(stderr, "Wrote %d bytes instead of %d bytes at %lld."
|
||||
"\n", size, this->size, (long long)this->pos);
|
||||
free(this->data);
|
||||
free(this);
|
||||
}
|
||||
}
|
||||
|
||||
int fs_close(int write)
|
||||
{
|
||||
CHANGE *next;
|
||||
int changed;
|
||||
|
||||
changed = ! !changes;
|
||||
if (write)
|
||||
fs_flush();
|
||||
else
|
||||
while (changes) {
|
||||
next = changes->next;
|
||||
free(changes->data);
|
||||
free(changes);
|
||||
changes = next;
|
||||
}
|
||||
if (close(fd) < 0)
|
||||
pdie("closing file system");
|
||||
return changed || did_change;
|
||||
}
|
||||
|
||||
int fs_changed(void)
|
||||
{
|
||||
return ! !changes || did_change;
|
||||
}
|
70
dosfstools/src/io.h
Normal file
70
dosfstools/src/io.h
Normal file
@ -0,0 +1,70 @@
|
||||
/* io.h - Virtual disk input/output
|
||||
|
||||
Copyright (C) 1993 Werner Almesberger <werner.almesberger@lrc.di.epfl.ch>
|
||||
Copyright (C) 1998 Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
On Debian systems, the complete text of the GNU General Public License
|
||||
can be found in /usr/share/common-licenses/GPL-3 file.
|
||||
*/
|
||||
|
||||
/* FAT32, VFAT, Atari format support, and various fixes additions May 1998
|
||||
* by Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de> */
|
||||
|
||||
#ifndef _IO_H
|
||||
#define _IO_H
|
||||
|
||||
#include <sys/types.h> /* for loff_t */
|
||||
|
||||
loff_t llseek(int fd, loff_t offset, int whence);
|
||||
|
||||
/* lseek() analogue for large offsets. */
|
||||
|
||||
void fs_open(char *path, int rw);
|
||||
|
||||
/* Opens the file system PATH. If RW is zero, the file system is opened
|
||||
read-only, otherwise, it is opened read-write. */
|
||||
|
||||
void fs_read(loff_t pos, int size, void *data);
|
||||
|
||||
/* Reads SIZE bytes starting at POS into DATA. Performs all applicable
|
||||
changes. */
|
||||
|
||||
int fs_test(loff_t pos, int size);
|
||||
|
||||
/* Returns a non-zero integer if SIZE bytes starting at POS can be read without
|
||||
errors. Otherwise, it returns zero. */
|
||||
|
||||
void fs_write(loff_t pos, int size, void *data);
|
||||
|
||||
/* If write_immed is non-zero, SIZE bytes are written from DATA to the disk,
|
||||
starting at POS. If write_immed is zero, the change is added to a list in
|
||||
memory. */
|
||||
|
||||
int fs_close(int write);
|
||||
|
||||
/* Closes the file system, performs all pending changes if WRITE is non-zero
|
||||
and removes the list of changes. Returns a non-zero integer if the file
|
||||
system has been changed since the last fs_open, zero otherwise. */
|
||||
|
||||
int fs_changed(void);
|
||||
|
||||
/* Determines whether the file system has changed. See fs_close. */
|
||||
|
||||
extern unsigned device_no;
|
||||
|
||||
/* Major number of device (0 if file) and size (in 512 byte sectors) */
|
||||
|
||||
#endif
|
502
dosfstools/src/lfn.c
Normal file
502
dosfstools/src/lfn.c
Normal file
@ -0,0 +1,502 @@
|
||||
/* lfn.c - Functions for handling VFAT long filenames
|
||||
|
||||
Copyright (C) 1998 Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
On Debian systems, the complete text of the GNU General Public License
|
||||
can be found in /usr/share/common-licenses/GPL-3 file.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "common.h"
|
||||
#include "io.h"
|
||||
#include "dosfsck.h"
|
||||
#include "lfn.h"
|
||||
#include "file.h"
|
||||
|
||||
typedef struct {
|
||||
__u8 id; /* sequence number for slot */
|
||||
__u8 name0_4[10]; /* first 5 characters in name */
|
||||
__u8 attr; /* attribute byte */
|
||||
__u8 reserved; /* always 0 */
|
||||
__u8 alias_checksum; /* checksum for 8.3 alias */
|
||||
__u8 name5_10[12]; /* 6 more characters in name */
|
||||
__u16 start; /* starting cluster number, 0 in long slots */
|
||||
__u8 name11_12[4]; /* last 2 characters in name */
|
||||
} LFN_ENT;
|
||||
|
||||
#define LFN_ID_START 0x40
|
||||
#define LFN_ID_SLOTMASK 0x1f
|
||||
|
||||
#define CHARS_PER_LFN 13
|
||||
|
||||
/* These modul-global vars represent the state of the LFN parser */
|
||||
unsigned char *lfn_unicode = NULL;
|
||||
unsigned char lfn_checksum;
|
||||
int lfn_slot = -1;
|
||||
loff_t *lfn_offsets = NULL;
|
||||
int lfn_parts = 0;
|
||||
|
||||
static unsigned char fat_uni2esc[64] = {
|
||||
'0', '1', '2', '3', '4', '5', '6', '7',
|
||||
'8', '9', 'A', 'B', 'C', 'D', 'E', 'F',
|
||||
'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
|
||||
'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V',
|
||||
'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd',
|
||||
'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l',
|
||||
'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
|
||||
'u', 'v', 'w', 'x', 'y', 'z', '+', '-'
|
||||
};
|
||||
|
||||
/* This defines which unicode chars are directly convertable to ISO-8859-1 */
|
||||
#define UNICODE_CONVERTABLE(cl,ch) (ch == 0 && (cl < 0x80 || cl >= 0xa0))
|
||||
|
||||
/* for maxlen param */
|
||||
#define UNTIL_0 INT_MAX
|
||||
|
||||
/* Convert name part in 'lfn' from unicode to ASCII */
|
||||
#define CNV_THIS_PART(lfn) \
|
||||
({ \
|
||||
unsigned char __part_uni[CHARS_PER_LFN*2]; \
|
||||
copy_lfn_part( __part_uni, lfn ); \
|
||||
cnv_unicode( __part_uni, CHARS_PER_LFN, 0 ); \
|
||||
})
|
||||
|
||||
/* Convert name parts collected so far (from previous slots) from unicode to
|
||||
* ASCII */
|
||||
#define CNV_PARTS_SO_FAR() \
|
||||
(cnv_unicode( lfn_unicode+(lfn_slot*CHARS_PER_LFN*2), \
|
||||
lfn_parts*CHARS_PER_LFN, 0 ))
|
||||
|
||||
/* This function converts an unicode string to a normal ASCII string, assuming
|
||||
* ISO-8859-1 charset. Characters not in 8859-1 are converted to the same
|
||||
* escape notation as used by the kernel, i.e. the uuencode-like ":xxx" */
|
||||
static char *cnv_unicode(const unsigned char *uni, int maxlen, int use_q)
|
||||
{
|
||||
const unsigned char *up;
|
||||
unsigned char *out, *cp;
|
||||
int len, val;
|
||||
|
||||
for (len = 0, up = uni; (up - uni) / 2 < maxlen && (up[0] || up[1]);
|
||||
up += 2) {
|
||||
if (UNICODE_CONVERTABLE(up[0], up[1]))
|
||||
++len;
|
||||
else
|
||||
len += 4;
|
||||
}
|
||||
cp = out = use_q ? qalloc(&mem_queue, len + 1) : alloc(len + 1);
|
||||
|
||||
for (up = uni; (up - uni) / 2 < maxlen && (up[0] || up[1]); up += 2) {
|
||||
if (UNICODE_CONVERTABLE(up[0], up[1]))
|
||||
*cp++ = up[0];
|
||||
else {
|
||||
/* here the same escape notation is used as in the Linux kernel */
|
||||
*cp++ = ':';
|
||||
val = (up[1] << 8) + up[0];
|
||||
cp[2] = fat_uni2esc[val & 0x3f];
|
||||
val >>= 6;
|
||||
cp[1] = fat_uni2esc[val & 0x3f];
|
||||
val >>= 6;
|
||||
cp[0] = fat_uni2esc[val & 0x3f];
|
||||
cp += 3;
|
||||
}
|
||||
}
|
||||
*cp = 0;
|
||||
|
||||
return (char *)out;
|
||||
}
|
||||
|
||||
static void copy_lfn_part(unsigned char *dst, LFN_ENT * lfn)
|
||||
{
|
||||
memcpy(dst, lfn->name0_4, 10);
|
||||
memcpy(dst + 10, lfn->name5_10, 12);
|
||||
memcpy(dst + 22, lfn->name11_12, 4);
|
||||
}
|
||||
|
||||
static void clear_lfn_slots(int start, int end)
|
||||
{
|
||||
int i;
|
||||
LFN_ENT empty;
|
||||
|
||||
/* New dir entry is zeroed except first byte, which is set to 0xe5.
|
||||
* This is to avoid that some FAT-reading OSes (not Linux! ;) stop reading
|
||||
* a directory at the first zero entry...
|
||||
*/
|
||||
memset(&empty, 0, sizeof(empty));
|
||||
empty.id = DELETED_FLAG;
|
||||
|
||||
for (i = start; i <= end; ++i) {
|
||||
fs_write(lfn_offsets[i], sizeof(LFN_ENT), &empty);
|
||||
}
|
||||
}
|
||||
|
||||
void lfn_fix_checksum(loff_t from, loff_t to, const char *short_name)
|
||||
{
|
||||
int i;
|
||||
__u8 sum;
|
||||
for (sum = 0, i = 0; i < 11; i++)
|
||||
sum = (((sum & 1) << 7) | ((sum & 0xfe) >> 1)) + short_name[i];
|
||||
|
||||
for (; from < to; from += sizeof(LFN_ENT)) {
|
||||
fs_write(from + offsetof(LFN_ENT, alias_checksum), sizeof(sum), &sum);
|
||||
}
|
||||
}
|
||||
|
||||
void lfn_reset(void)
|
||||
{
|
||||
if (lfn_unicode)
|
||||
free(lfn_unicode);
|
||||
lfn_unicode = NULL;
|
||||
if (lfn_offsets)
|
||||
free(lfn_offsets);
|
||||
lfn_offsets = NULL;
|
||||
lfn_slot = -1;
|
||||
}
|
||||
|
||||
/* This function is only called with de->attr == VFAT_LN_ATTR. It stores part
|
||||
* of the long name. */
|
||||
void lfn_add_slot(DIR_ENT * de, loff_t dir_offset)
|
||||
{
|
||||
LFN_ENT *lfn = (LFN_ENT *) de;
|
||||
int slot = lfn->id & LFN_ID_SLOTMASK;
|
||||
unsigned offset;
|
||||
|
||||
if (lfn_slot == 0)
|
||||
lfn_check_orphaned();
|
||||
|
||||
if (de->attr != VFAT_LN_ATTR)
|
||||
die("lfn_add_slot called with non-LFN directory entry");
|
||||
|
||||
if (lfn->id & LFN_ID_START && slot != 0) {
|
||||
if (lfn_slot != -1) {
|
||||
int can_clear = 0;
|
||||
/* There is already a LFN "in progess", so it is an error that a
|
||||
* new start entry is here. */
|
||||
/* Causes: 1) if slot# == expected: start bit set mysteriously, 2)
|
||||
* old LFN overwritten by new one */
|
||||
/* Fixes: 1) delete previous LFN 2) if slot# == expected and
|
||||
* checksum ok: clear start bit */
|
||||
/* XXX: Should delay that until next LFN known (then can better
|
||||
* display the name) */
|
||||
printf("A new long file name starts within an old one.\n");
|
||||
if (slot == lfn_slot && lfn->alias_checksum == lfn_checksum) {
|
||||
char *part1 = CNV_THIS_PART(lfn);
|
||||
char *part2 = CNV_PARTS_SO_FAR();
|
||||
printf(" It could be that the LFN start bit is wrong here\n"
|
||||
" if \"%s\" seems to match \"%s\".\n", part1, part2);
|
||||
free(part1);
|
||||
free(part2);
|
||||
can_clear = 1;
|
||||
}
|
||||
if (interactive) {
|
||||
printf("1: Delete previous LFN\n2: Leave it as it is.\n");
|
||||
if (can_clear)
|
||||
printf("3: Clear start bit and concatenate LFNs\n");
|
||||
} else
|
||||
printf(" Not auto-correcting this.\n");
|
||||
if (interactive) {
|
||||
switch (get_key(can_clear ? "123" : "12", "?")) {
|
||||
case '1':
|
||||
clear_lfn_slots(0, lfn_parts - 1);
|
||||
lfn_reset();
|
||||
break;
|
||||
case '2':
|
||||
break;
|
||||
case '3':
|
||||
lfn->id &= ~LFN_ID_START;
|
||||
fs_write(dir_offset + offsetof(LFN_ENT, id),
|
||||
sizeof(lfn->id), &lfn->id);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
lfn_slot = slot;
|
||||
lfn_checksum = lfn->alias_checksum;
|
||||
lfn_unicode = alloc((lfn_slot * CHARS_PER_LFN + 1) * 2);
|
||||
lfn_offsets = alloc(lfn_slot * sizeof(loff_t));
|
||||
lfn_parts = 0;
|
||||
} else if (lfn_slot == -1 && slot != 0) {
|
||||
/* No LFN in progress, but slot found; start bit missing */
|
||||
/* Causes: 1) start bit got lost, 2) Previous slot with start bit got
|
||||
* lost */
|
||||
/* Fixes: 1) delete LFN, 2) set start bit */
|
||||
char *part = CNV_THIS_PART(lfn);
|
||||
printf("Long filename fragment \"%s\" found outside a LFN "
|
||||
"sequence.\n (Maybe the start bit is missing on the "
|
||||
"last fragment)\n", part);
|
||||
if (interactive) {
|
||||
printf("1: Delete fragment\n2: Leave it as it is.\n"
|
||||
"3: Set start bit\n");
|
||||
} else
|
||||
printf(" Not auto-correcting this.\n");
|
||||
switch (interactive ? get_key("123", "?") : '2') {
|
||||
case '1':
|
||||
if (!lfn_offsets)
|
||||
lfn_offsets = alloc(sizeof(loff_t));
|
||||
lfn_offsets[0] = dir_offset;
|
||||
clear_lfn_slots(0, 0);
|
||||
lfn_reset();
|
||||
return;
|
||||
case '2':
|
||||
lfn_reset();
|
||||
return;
|
||||
case '3':
|
||||
lfn->id |= LFN_ID_START;
|
||||
fs_write(dir_offset + offsetof(LFN_ENT, id),
|
||||
sizeof(lfn->id), &lfn->id);
|
||||
lfn_slot = slot;
|
||||
lfn_checksum = lfn->alias_checksum;
|
||||
lfn_unicode = alloc((lfn_slot * CHARS_PER_LFN + 1) * 2);
|
||||
lfn_offsets = alloc(lfn_slot * sizeof(loff_t));
|
||||
lfn_parts = 0;
|
||||
break;
|
||||
}
|
||||
} else if (slot != lfn_slot) {
|
||||
/* wrong sequence number */
|
||||
/* Causes: 1) seq-no destroyed */
|
||||
/* Fixes: 1) delete LFN, 2) fix number (maybe only if following parts
|
||||
* are ok?, maybe only if checksum is ok?) (Attention: space
|
||||
* for name was allocated before!) */
|
||||
int can_fix = 0;
|
||||
printf("Unexpected long filename sequence number "
|
||||
"(%d vs. expected %d).\n", slot, lfn_slot);
|
||||
if (lfn->alias_checksum == lfn_checksum && lfn_slot > 0) {
|
||||
char *part1 = CNV_THIS_PART(lfn);
|
||||
char *part2 = CNV_PARTS_SO_FAR();
|
||||
printf(" It could be that just the number is wrong\n"
|
||||
" if \"%s\" seems to match \"%s\".\n", part1, part2);
|
||||
free(part1);
|
||||
free(part2);
|
||||
can_fix = 1;
|
||||
}
|
||||
if (interactive) {
|
||||
printf
|
||||
("1: Delete LFN\n2: Leave it as it is (and ignore LFN so far)\n");
|
||||
if (can_fix)
|
||||
printf("3: Correct sequence number\n");
|
||||
} else
|
||||
printf(" Not auto-correcting this.\n");
|
||||
switch (interactive ? get_key(can_fix ? "123" : "12", "?") : '2') {
|
||||
case '1':
|
||||
if (!lfn_offsets) {
|
||||
lfn_offsets = alloc(sizeof(loff_t));
|
||||
lfn_parts = 0;
|
||||
}
|
||||
lfn_offsets[lfn_parts++] = dir_offset;
|
||||
clear_lfn_slots(0, lfn_parts - 1);
|
||||
lfn_reset();
|
||||
return;
|
||||
case '2':
|
||||
lfn_reset();
|
||||
return;
|
||||
case '3':
|
||||
lfn->id = (lfn->id & ~LFN_ID_SLOTMASK) | lfn_slot;
|
||||
fs_write(dir_offset + offsetof(LFN_ENT, id),
|
||||
sizeof(lfn->id), &lfn->id);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (lfn->alias_checksum != lfn_checksum) {
|
||||
/* checksum mismatch */
|
||||
/* Causes: 1) checksum field here destroyed */
|
||||
/* Fixes: 1) delete LFN, 2) fix checksum */
|
||||
printf("Checksum in long filename part wrong "
|
||||
"(%02x vs. expected %02x).\n",
|
||||
lfn->alias_checksum, lfn_checksum);
|
||||
if (interactive) {
|
||||
printf("1: Delete LFN\n2: Leave it as it is.\n"
|
||||
"3: Correct checksum\n");
|
||||
} else
|
||||
printf(" Not auto-correcting this.\n");
|
||||
if (interactive) {
|
||||
switch (get_key("123", "?")) {
|
||||
case '1':
|
||||
lfn_offsets[lfn_parts++] = dir_offset;
|
||||
clear_lfn_slots(0, lfn_parts - 1);
|
||||
lfn_reset();
|
||||
return;
|
||||
case '2':
|
||||
break;
|
||||
case '3':
|
||||
lfn->alias_checksum = lfn_checksum;
|
||||
fs_write(dir_offset + offsetof(LFN_ENT, alias_checksum),
|
||||
sizeof(lfn->alias_checksum), &lfn->alias_checksum);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (lfn_slot != -1) {
|
||||
lfn_slot--;
|
||||
offset = lfn_slot * CHARS_PER_LFN * 2;
|
||||
copy_lfn_part(lfn_unicode + offset, lfn);
|
||||
if (lfn->id & LFN_ID_START)
|
||||
lfn_unicode[offset + 26] = lfn_unicode[offset + 27] = 0;
|
||||
lfn_offsets[lfn_parts++] = dir_offset;
|
||||
}
|
||||
|
||||
if (lfn->reserved != 0) {
|
||||
printf("Reserved field in VFAT long filename slot is not 0 "
|
||||
"(but 0x%02x).\n", lfn->reserved);
|
||||
if (interactive)
|
||||
printf("1: Fix.\n2: Leave it.\n");
|
||||
else
|
||||
printf("Auto-setting to 0.\n");
|
||||
if (!interactive || get_key("12", "?") == '1') {
|
||||
lfn->reserved = 0;
|
||||
fs_write(dir_offset + offsetof(LFN_ENT, reserved),
|
||||
sizeof(lfn->reserved), &lfn->reserved);
|
||||
}
|
||||
}
|
||||
if (lfn->start != CT_LE_W(0)) {
|
||||
printf("Start cluster field in VFAT long filename slot is not 0 "
|
||||
"(but 0x%04x).\n", lfn->start);
|
||||
if (interactive)
|
||||
printf("1: Fix.\n2: Leave it.\n");
|
||||
else
|
||||
printf("Auto-setting to 0.\n");
|
||||
if (!interactive || get_key("12", "?") == '1') {
|
||||
lfn->start = CT_LE_W(0);
|
||||
fs_write(dir_offset + offsetof(LFN_ENT, start),
|
||||
sizeof(lfn->start), &lfn->start);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* This function is always called when de->attr != VFAT_LN_ATTR is found, to
|
||||
* retrieve the previously constructed LFN. */
|
||||
char *lfn_get(DIR_ENT * de, loff_t * lfn_offset)
|
||||
{
|
||||
char *lfn;
|
||||
__u8 sum;
|
||||
int i;
|
||||
|
||||
*lfn_offset = 0;
|
||||
if (de->attr == VFAT_LN_ATTR)
|
||||
die("lfn_get called with LFN directory entry");
|
||||
|
||||
#if 0
|
||||
if (de->lcase)
|
||||
printf("lcase=%02x\n", de->lcase);
|
||||
#endif
|
||||
|
||||
if (lfn_slot == -1)
|
||||
/* no long name for this file */
|
||||
return NULL;
|
||||
|
||||
if (lfn_slot != 0) {
|
||||
/* The long name isn't finished yet. */
|
||||
/* Causes: 1) LFN slot overwritten by non-VFAT aware tool */
|
||||
/* Fixes: 1) delete LFN 2) move overwriting entry to somewhere else
|
||||
* and let user enter missing part of LFN (hard to do :-()
|
||||
* 3) renumber entries and truncate name */
|
||||
char *long_name = CNV_PARTS_SO_FAR();
|
||||
char *short_name = file_name(de->name);
|
||||
printf("Unfinished long file name \"%s\".\n"
|
||||
" (Start may have been overwritten by %s)\n",
|
||||
long_name, short_name);
|
||||
free(long_name);
|
||||
if (interactive) {
|
||||
printf("1: Delete LFN\n2: Leave it as it is.\n"
|
||||
"3: Fix numbering (truncates long name and attaches "
|
||||
"it to short name %s)\n", short_name);
|
||||
} else
|
||||
printf(" Not auto-correcting this.\n");
|
||||
switch (interactive ? get_key("123", "?") : '2') {
|
||||
case '1':
|
||||
clear_lfn_slots(0, lfn_parts - 1);
|
||||
lfn_reset();
|
||||
return NULL;
|
||||
case '2':
|
||||
lfn_reset();
|
||||
return NULL;
|
||||
case '3':
|
||||
for (i = 0; i < lfn_parts; ++i) {
|
||||
__u8 id = (lfn_parts - i) | (i == 0 ? LFN_ID_START : 0);
|
||||
fs_write(lfn_offsets[i] + offsetof(LFN_ENT, id),
|
||||
sizeof(id), &id);
|
||||
}
|
||||
memmove(lfn_unicode, lfn_unicode + lfn_slot * CHARS_PER_LFN * 2,
|
||||
lfn_parts * CHARS_PER_LFN * 2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (sum = 0, i = 0; i < 11; i++)
|
||||
sum = (((sum & 1) << 7) | ((sum & 0xfe) >> 1)) + de->name[i];
|
||||
if (sum != lfn_checksum) {
|
||||
/* checksum doesn't match, long name doesn't apply to this alias */
|
||||
/* Causes: 1) alias renamed */
|
||||
/* Fixes: 1) Fix checksum in LFN entries */
|
||||
char *long_name = CNV_PARTS_SO_FAR();
|
||||
char *short_name = file_name(de->name);
|
||||
printf("Wrong checksum for long file name \"%s\".\n"
|
||||
" (Short name %s may have changed without updating the long name)\n",
|
||||
long_name, short_name);
|
||||
free(long_name);
|
||||
if (interactive) {
|
||||
printf("1: Delete LFN\n2: Leave it as it is.\n"
|
||||
"3: Fix checksum (attaches to short name %s)\n", short_name);
|
||||
} else
|
||||
printf(" Not auto-correcting this.\n");
|
||||
if (interactive) {
|
||||
switch (get_key("123", "?")) {
|
||||
case '1':
|
||||
clear_lfn_slots(0, lfn_parts - 1);
|
||||
lfn_reset();
|
||||
return NULL;
|
||||
case '2':
|
||||
lfn_reset();
|
||||
return NULL;
|
||||
case '3':
|
||||
for (i = 0; i < lfn_parts; ++i) {
|
||||
fs_write(lfn_offsets[i] + offsetof(LFN_ENT, alias_checksum),
|
||||
sizeof(sum), &sum);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*lfn_offset = lfn_offsets[0];
|
||||
lfn = cnv_unicode(lfn_unicode, UNTIL_0, 1);
|
||||
lfn_reset();
|
||||
return (lfn);
|
||||
}
|
||||
|
||||
void lfn_check_orphaned(void)
|
||||
{
|
||||
char *long_name;
|
||||
|
||||
if (lfn_slot == -1)
|
||||
return;
|
||||
|
||||
long_name = CNV_PARTS_SO_FAR();
|
||||
printf("Orphaned long file name part \"%s\"\n", long_name);
|
||||
if (interactive)
|
||||
printf("1: Delete.\n2: Leave it.\n");
|
||||
else
|
||||
printf(" Auto-deleting.\n");
|
||||
if (!interactive || get_key("12", "?") == '1') {
|
||||
clear_lfn_slots(0, lfn_parts - 1);
|
||||
}
|
||||
lfn_reset();
|
||||
}
|
38
dosfstools/src/lfn.h
Normal file
38
dosfstools/src/lfn.h
Normal file
@ -0,0 +1,38 @@
|
||||
/* lfn.h - Functions for handling VFAT long filenames
|
||||
|
||||
Copyright (C) 1998 Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
On Debian systems, the complete text of the GNU General Public License
|
||||
can be found in /usr/share/common-licenses/GPL-3 file.
|
||||
*/
|
||||
|
||||
#ifndef _LFN_H
|
||||
#define _LFN_H
|
||||
|
||||
void lfn_reset(void);
|
||||
/* Reset the state of the LFN parser. */
|
||||
|
||||
void lfn_add_slot(DIR_ENT * de, loff_t dir_offset);
|
||||
/* Process a dir slot that is a VFAT LFN entry. */
|
||||
|
||||
char *lfn_get(DIR_ENT * de, loff_t * lfn_offset);
|
||||
/* Retrieve the long name for the proper dir entry. */
|
||||
|
||||
void lfn_check_orphaned(void);
|
||||
|
||||
void lfn_fix_checksum(loff_t from, loff_t to, const char *short_name);
|
||||
|
||||
#endif
|
1733
dosfstools/src/mkdosfs.c
Normal file
1733
dosfstools/src/mkdosfs.c
Normal file
File diff suppressed because it is too large
Load Diff
28
dosfstools/src/version.h
Normal file
28
dosfstools/src/version.h
Normal file
@ -0,0 +1,28 @@
|
||||
/* version.h
|
||||
|
||||
Copyright (C) 1998-2005 Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
On Debian systems, the complete text of the GNU General Public License
|
||||
can be found in /usr/share/common-licenses/GPL-3 file.
|
||||
*/
|
||||
|
||||
#ifndef _version_h
|
||||
#define _version_h
|
||||
|
||||
#define VERSION "3.0.12"
|
||||
#define VERSION_DATE "29 Oct 2011"
|
||||
|
||||
#endif
|
674
exfat/COPYING
Normal file
674
exfat/COPYING
Normal 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.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
70
exfat/ChangeLog
Normal file
70
exfat/ChangeLog
Normal file
@ -0,0 +1,70 @@
|
||||
0.9.8 (2012-08-09)
|
||||
|
||||
* The mkfs utility can now create huge file systems (up to several exabytes).
|
||||
* Fixed handling of characters beyond Basic Multilingual Plane.
|
||||
* Echo messages to syslog only if stderr is not connected to a terminal.
|
||||
|
||||
0.9.7 (2012-03-08)
|
||||
|
||||
* Out-of-the-box FreeBSD support (via ublio library).
|
||||
* Fixed "missing EOD entry" error (could happen while reading directory that
|
||||
consists of several clusters).
|
||||
* Fixed interpretation of minutes field in files timestamps (minutes could be
|
||||
displayed incorrectly).
|
||||
* Fixed mtime seconds field initialization for newly created file (mtime could
|
||||
be 1 sec less than creation time).
|
||||
* SConscript now respects CC, CCFLAGS and LDFLAGS environment variables.
|
||||
|
||||
0.9.6 (2012-01-14)
|
||||
|
||||
* Fixed write performance regression introduced in 0.9.4.
|
||||
* Mount in read-only mode if the device is write-protected.
|
||||
* Set ctime to mtime to ensure we don't break programs that rely on ctime
|
||||
(e.g. rsync considered that all files are outdated) [Eldad Zack].
|
||||
* Indicate that FS in not clean when it was not cleanly unmounted.
|
||||
* Utilities are now compatible with GNU/Hurd.
|
||||
* Fixed several memory leaks that could occur on error handling paths.
|
||||
* Improved handling of corrupted file systems.
|
||||
|
||||
0.9.5 (2011-05-15)
|
||||
|
||||
* Fixed erasing of the root directory cluster when creating a new FS with
|
||||
mkexfatfs. This bug could cause mkexfatfs to produce invalid FS.
|
||||
* Utilities are not linked with libfuse anymore.
|
||||
* Ensure that the path being opened is either a device or a regular file.
|
||||
|
||||
0.9.4 (2011-03-05)
|
||||
|
||||
* Introduced exfat-utils: dumpexfat, exfatfsck, mkexfatfs, exfatlabel.
|
||||
* Fixed "Invalid argument" error while mounting a volume from a disk with sector size greater than 512 bytes.
|
||||
* Wait for all data to be flushed to disk on unmount.
|
||||
* Kernel cache is no longer flushed on open. This can slightly improve read performance by avoiding extra read requests from kernel to user-space.
|
||||
* Allow to unmount volumes as user (fusermount -u) if they were mounted from the very same user [Tino Lange].
|
||||
* Errors and warnings are now duplicated to syslog.
|
||||
|
||||
0.9.3 (2010-09-25)
|
||||
|
||||
* Directories now can shrink.
|
||||
* Improved timestamps resolution from 2 sec to 1 sec.
|
||||
* Fixed timestamps displaying under Mac OS X when compiled for i386 or ppc.
|
||||
* Fixed FS size displaying for non-GNU systems.
|
||||
|
||||
0.9.2 (2010-07-24)
|
||||
|
||||
* Fixed a bug which could cause the whole directory to become unreadable after renaming a file in it.
|
||||
* Support for Solaris and various *BSD [Albert Lee].
|
||||
* Improved error handling on corrupted volumes.
|
||||
* Improved allowed file name characters filter.
|
||||
* Added man page.
|
||||
|
||||
0.9.1 (2010-06-12)
|
||||
|
||||
* Implemented automounting (util-linux-ng 2.18 or later is required).
|
||||
* Fixed mounting when cluster bitmap is larger than expected.
|
||||
* Fixed crash on statfs() when root directory contains error.
|
||||
* Fixed bugs specific to big-endian machines.
|
||||
* Other bugfixes.
|
||||
|
||||
0.9.0 (2010-03-21)
|
||||
|
||||
* Initial release.
|
46
exfat/dump/dumpexfat.8
Normal file
46
exfat/dump/dumpexfat.8
Normal file
@ -0,0 +1,46 @@
|
||||
.\" Copyright (C) 2011 Andrew Nayenko
|
||||
.\"
|
||||
.TH DUMPEXFAT 8 "February 2011"
|
||||
.SH NAME
|
||||
.B dumpexfat
|
||||
\- dump exFAT file system
|
||||
.SH SYNOPSIS
|
||||
.B exfatlabel
|
||||
[
|
||||
.B \-s
|
||||
]
|
||||
[
|
||||
.B \-u
|
||||
]
|
||||
[
|
||||
.B \-v
|
||||
]
|
||||
.I device
|
||||
|
||||
.SH DESCRIPTION
|
||||
.B dumpexfat
|
||||
dumps details about exFAT file system including low-level info. All sizes are
|
||||
in bytes.
|
||||
|
||||
.SH OPTIONS
|
||||
Command line options available:
|
||||
.TP
|
||||
.B \-s
|
||||
Dump only info from super block. May be useful for heavily corrupted file
|
||||
systems.
|
||||
.TP
|
||||
.B \-u
|
||||
Dump ranges of used sectors starting from 0 and separated with spaces. May be
|
||||
useful for backup tools.
|
||||
.TP
|
||||
.BI \-v
|
||||
Print version and copyright.
|
||||
|
||||
.SH EXIT CODES
|
||||
Zero is returned on success. Any other code means an error.
|
||||
|
||||
.SH AUTHOR
|
||||
Andrew Nayenko
|
||||
|
||||
.SH SEE ALSO
|
||||
.BR mkexfatfs (8)
|
180
exfat/dump/main.c
Normal file
180
exfat/dump/main.c
Normal file
@ -0,0 +1,180 @@
|
||||
/*
|
||||
main.c (08.11.10)
|
||||
Prints detailed information about exFAT volume.
|
||||
|
||||
Copyright (C) 2011, 2012 Andrew Nayenko
|
||||
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <exfat.h>
|
||||
|
||||
static void print_generic_info(const struct exfat_super_block* sb)
|
||||
{
|
||||
printf("Volume serial number 0x%08x\n",
|
||||
le32_to_cpu(sb->volume_serial));
|
||||
printf("FS version %hhu.%hhu\n",
|
||||
sb->version.major, sb->version.minor);
|
||||
printf("Sector size %10u\n",
|
||||
SECTOR_SIZE(*sb));
|
||||
printf("Cluster size %10u\n",
|
||||
CLUSTER_SIZE(*sb));
|
||||
}
|
||||
|
||||
static void print_sector_info(const struct exfat_super_block* sb)
|
||||
{
|
||||
printf("Sectors count %10"PRIu64"\n",
|
||||
le64_to_cpu(sb->sector_count));
|
||||
}
|
||||
|
||||
static void print_cluster_info(const struct exfat_super_block* sb)
|
||||
{
|
||||
printf("Clusters count %10u\n",
|
||||
le32_to_cpu(sb->cluster_count));
|
||||
}
|
||||
|
||||
static void print_other_info(const struct exfat_super_block* sb)
|
||||
{
|
||||
printf("First sector %10"PRIu64"\n",
|
||||
le64_to_cpu(sb->sector_start));
|
||||
printf("FAT first sector %10u\n",
|
||||
le32_to_cpu(sb->fat_sector_start));
|
||||
printf("FAT sectors count %10u\n",
|
||||
le32_to_cpu(sb->fat_sector_count));
|
||||
printf("First cluster sector %10u\n",
|
||||
le32_to_cpu(sb->cluster_sector_start));
|
||||
printf("Root directory cluster %10u\n",
|
||||
le32_to_cpu(sb->rootdir_cluster));
|
||||
printf("Volume state 0x%04hx\n",
|
||||
le16_to_cpu(sb->volume_state));
|
||||
printf("FATs count %10hhu\n",
|
||||
sb->fat_count);
|
||||
printf("Drive number 0x%02hhx\n",
|
||||
sb->drive_no);
|
||||
printf("Allocated space %9hhu%%\n",
|
||||
sb->allocated_percent);
|
||||
}
|
||||
|
||||
static int dump_sb(const char* spec)
|
||||
{
|
||||
struct exfat_dev* dev;
|
||||
struct exfat_super_block sb;
|
||||
|
||||
dev = exfat_open(spec, EXFAT_MODE_RO);
|
||||
if (dev == NULL)
|
||||
return 1;
|
||||
|
||||
if (exfat_read(dev, &sb, sizeof(struct exfat_super_block)) < 0)
|
||||
{
|
||||
exfat_close(dev);
|
||||
exfat_error("failed to read from `%s'", spec);
|
||||
return 1;
|
||||
}
|
||||
if (memcmp(sb.oem_name, "EXFAT ", sizeof(sb.oem_name)) != 0)
|
||||
{
|
||||
exfat_close(dev);
|
||||
exfat_error("exFAT file system is not found on `%s'", spec);
|
||||
return 1;
|
||||
}
|
||||
|
||||
print_generic_info(&sb);
|
||||
print_sector_info(&sb);
|
||||
print_cluster_info(&sb);
|
||||
print_other_info(&sb);
|
||||
|
||||
exfat_close(dev);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void dump_sectors(struct exfat* ef)
|
||||
{
|
||||
off_t a = 0, b = 0;
|
||||
|
||||
printf("Used sectors ");
|
||||
while (exfat_find_used_sectors(ef, &a, &b) == 0)
|
||||
printf(" %"PRIu64"-%"PRIu64, a, b);
|
||||
puts("");
|
||||
}
|
||||
|
||||
static int dump_full(const char* spec, bool used_sectors)
|
||||
{
|
||||
struct exfat ef;
|
||||
uint32_t free_clusters;
|
||||
uint64_t free_sectors;
|
||||
|
||||
if (exfat_mount(&ef, spec, "ro") != 0)
|
||||
return 1;
|
||||
|
||||
free_clusters = exfat_count_free_clusters(&ef);
|
||||
free_sectors = (uint64_t) free_clusters << ef.sb->spc_bits;
|
||||
|
||||
printf("Volume label %15s\n", exfat_get_label(&ef));
|
||||
print_generic_info(ef.sb);
|
||||
print_sector_info(ef.sb);
|
||||
printf("Free sectors %10"PRIu64"\n", free_sectors);
|
||||
print_cluster_info(ef.sb);
|
||||
printf("Free clusters %10u\n", free_clusters);
|
||||
print_other_info(ef.sb);
|
||||
if (used_sectors)
|
||||
dump_sectors(&ef);
|
||||
|
||||
exfat_unmount(&ef);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void usage(const char* prog)
|
||||
{
|
||||
fprintf(stderr, "Usage: %s [-s] [-u] [-v] <device>\n", prog);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
char** pp;
|
||||
const char* spec = NULL;
|
||||
bool sb_only = false;
|
||||
bool used_sectors = false;
|
||||
|
||||
printf("dumpexfat %u.%u.%u\n",
|
||||
EXFAT_VERSION_MAJOR, EXFAT_VERSION_MINOR, EXFAT_VERSION_PATCH);
|
||||
|
||||
for (pp = argv + 1; *pp; pp++)
|
||||
{
|
||||
if (strcmp(*pp, "-s") == 0)
|
||||
sb_only = true;
|
||||
else if (strcmp(*pp, "-u") == 0)
|
||||
used_sectors = true;
|
||||
else if (strcmp(*pp, "-v") == 0)
|
||||
{
|
||||
puts("Copyright (C) 2011, 2012 Andrew Nayenko");
|
||||
return 0;
|
||||
}
|
||||
else if (spec == NULL)
|
||||
spec = *pp;
|
||||
else
|
||||
usage(argv[0]);
|
||||
}
|
||||
if (spec == NULL)
|
||||
usage(argv[0]);
|
||||
|
||||
if (sb_only)
|
||||
return dump_sb(spec);
|
||||
|
||||
return dump_full(spec, used_sectors);
|
||||
}
|
22
exfat/exfat-fuse/Android.mk
Normal file
22
exfat/exfat-fuse/Android.mk
Normal file
@ -0,0 +1,22 @@
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE := exfat-fuse
|
||||
LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES
|
||||
LOCAL_MODULE_TAGS := eng
|
||||
LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
LOCAL_CFLAGS = -D_FILE_OFFSET_BITS=64
|
||||
LOCAL_SRC_FILES = main.c
|
||||
LOCAL_C_INCLUDES += $(LOCAL_PATH) \
|
||||
bootable/recovery/exfat/libexfat \
|
||||
bootable/recovery/fuse/include
|
||||
LOCAL_SHARED_LIBRARIES += libz libc libexfat libdl
|
||||
LOCAL_STATIC_LIBRARIES += libfuse
|
||||
|
||||
include $(BUILD_EXECUTABLE)
|
||||
|
||||
# We need this so that the installed files could be picked up based on the
|
||||
# local module name
|
||||
ALL_MODULES.$(LOCAL_MODULE).INSTALLED := \
|
||||
$(ALL_MODULES.$(LOCAL_MODULE).INSTALLED) $(SYMLINKS)
|
543
exfat/exfat-fuse/main.c
Normal file
543
exfat/exfat-fuse/main.c
Normal file
@ -0,0 +1,543 @@
|
||||
/*
|
||||
main.c (01.09.09)
|
||||
FUSE-based exFAT implementation. Requires FUSE 2.6 or later.
|
||||
|
||||
Copyright (C) 2010-2012 Andrew Nayenko
|
||||
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#define FUSE_USE_VERSION 26
|
||||
#include <fuse.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <exfat.h>
|
||||
#include <inttypes.h>
|
||||
#include <limits.h>
|
||||
#include <sys/types.h>
|
||||
#include <pwd.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define exfat_debug(format, ...)
|
||||
|
||||
#if !defined(FUSE_VERSION) || (FUSE_VERSION < 26)
|
||||
#error FUSE 2.6 or later is required
|
||||
#endif
|
||||
|
||||
const char* default_options = "ro_fallback,allow_other,blkdev,big_writes";
|
||||
|
||||
struct exfat ef;
|
||||
|
||||
static struct exfat_node* get_node(const struct fuse_file_info* fi)
|
||||
{
|
||||
return (struct exfat_node*) (size_t) fi->fh;
|
||||
}
|
||||
|
||||
static void set_node(struct fuse_file_info* fi, struct exfat_node* node)
|
||||
{
|
||||
fi->fh = (uint64_t) (size_t) node;
|
||||
}
|
||||
|
||||
static int fuse_exfat_getattr(const char* path, struct stat* stbuf)
|
||||
{
|
||||
struct exfat_node* node;
|
||||
int rc;
|
||||
|
||||
exfat_debug("[%s] %s", __func__, path);
|
||||
|
||||
rc = exfat_lookup(&ef, &node, path);
|
||||
if (rc != 0)
|
||||
return rc;
|
||||
|
||||
exfat_stat(&ef, node, stbuf);
|
||||
exfat_put_node(&ef, node);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int fuse_exfat_truncate(const char* path, off64_t size)
|
||||
{
|
||||
struct exfat_node* node;
|
||||
int rc;
|
||||
|
||||
exfat_debug("[%s] %s, %"PRId64, __func__, path, size);
|
||||
|
||||
rc = exfat_lookup(&ef, &node, path);
|
||||
if (rc != 0)
|
||||
return rc;
|
||||
|
||||
rc = exfat_truncate(&ef, node, size);
|
||||
exfat_put_node(&ef, node);
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int fuse_exfat_readdir(const char* path, void* buffer,
|
||||
fuse_fill_dir_t filler, off64_t offset, struct fuse_file_info* fi)
|
||||
{
|
||||
struct exfat_node* parent;
|
||||
struct exfat_node* node;
|
||||
struct exfat_iterator it;
|
||||
int rc;
|
||||
char name[EXFAT_NAME_MAX + 1];
|
||||
|
||||
exfat_debug("[%s] %s", __func__, path);
|
||||
|
||||
rc = exfat_lookup(&ef, &parent, path);
|
||||
if (rc != 0)
|
||||
return rc;
|
||||
if (!(parent->flags & EXFAT_ATTRIB_DIR))
|
||||
{
|
||||
exfat_put_node(&ef, parent);
|
||||
exfat_error("`%s' is not a directory (0x%x)", path, parent->flags);
|
||||
return -ENOTDIR;
|
||||
}
|
||||
|
||||
filler(buffer, ".", NULL, 0);
|
||||
filler(buffer, "..", NULL, 0);
|
||||
|
||||
rc = exfat_opendir(&ef, parent, &it);
|
||||
if (rc != 0)
|
||||
{
|
||||
exfat_put_node(&ef, parent);
|
||||
exfat_error("failed to open directory `%s'", path);
|
||||
return rc;
|
||||
}
|
||||
while ((node = exfat_readdir(&ef, &it)))
|
||||
{
|
||||
exfat_get_name(node, name, EXFAT_NAME_MAX);
|
||||
exfat_debug("[%s] %s: %s, %"PRId64" bytes, cluster 0x%x", __func__,
|
||||
name, IS_CONTIGUOUS(*node) ? "contiguous" : "fragmented",
|
||||
node->size, node->start_cluster);
|
||||
filler(buffer, name, NULL, 0);
|
||||
exfat_put_node(&ef, node);
|
||||
}
|
||||
exfat_closedir(&ef, &it);
|
||||
exfat_put_node(&ef, parent);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int fuse_exfat_open(const char* path, struct fuse_file_info* fi)
|
||||
{
|
||||
struct exfat_node* node;
|
||||
int rc;
|
||||
|
||||
exfat_debug("[%s] %s", __func__, path);
|
||||
|
||||
rc = exfat_lookup(&ef, &node, path);
|
||||
if (rc != 0)
|
||||
return rc;
|
||||
set_node(fi, node);
|
||||
fi->keep_cache = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int fuse_exfat_release(const char* path, struct fuse_file_info* fi)
|
||||
{
|
||||
exfat_debug("[%s] %s", __func__, path);
|
||||
exfat_put_node(&ef, get_node(fi));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int fuse_exfat_read(const char* path, char* buffer, size_t size,
|
||||
off64_t offset, struct fuse_file_info* fi)
|
||||
{
|
||||
exfat_debug("[%s] %s (%zu bytes)", __func__, path, size);
|
||||
if (exfat_generic_pread(&ef, get_node(fi), buffer, size, offset) != size)
|
||||
return EOF;
|
||||
return size;
|
||||
}
|
||||
|
||||
static int fuse_exfat_write(const char* path, const char* buffer, size_t size,
|
||||
off64_t offset, struct fuse_file_info* fi)
|
||||
{
|
||||
exfat_debug("[%s] %s (%zu bytes)", __func__, path, size);
|
||||
if (exfat_generic_pwrite(&ef, get_node(fi), buffer, size, offset) != size)
|
||||
return EOF;
|
||||
return size;
|
||||
}
|
||||
|
||||
static int fuse_exfat_unlink(const char* path)
|
||||
{
|
||||
struct exfat_node* node;
|
||||
int rc;
|
||||
|
||||
exfat_debug("[%s] %s", __func__, path);
|
||||
|
||||
rc = exfat_lookup(&ef, &node, path);
|
||||
if (rc != 0)
|
||||
return rc;
|
||||
|
||||
rc = exfat_unlink(&ef, node);
|
||||
exfat_put_node(&ef, node);
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int fuse_exfat_rmdir(const char* path)
|
||||
{
|
||||
struct exfat_node* node;
|
||||
int rc;
|
||||
|
||||
exfat_debug("[%s] %s", __func__, path);
|
||||
|
||||
rc = exfat_lookup(&ef, &node, path);
|
||||
if (rc != 0)
|
||||
return rc;
|
||||
|
||||
rc = exfat_rmdir(&ef, node);
|
||||
exfat_put_node(&ef, node);
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int fuse_exfat_mknod(const char* path, mode_t mode, dev_t dev)
|
||||
{
|
||||
exfat_debug("[%s] %s 0%ho", __func__, path, mode);
|
||||
return exfat_mknod(&ef, path);
|
||||
}
|
||||
|
||||
static int fuse_exfat_mkdir(const char* path, mode_t mode)
|
||||
{
|
||||
exfat_debug("[%s] %s 0%ho", __func__, path, mode);
|
||||
return exfat_mkdir(&ef, path);
|
||||
}
|
||||
|
||||
static int fuse_exfat_rename(const char* old_path, const char* new_path)
|
||||
{
|
||||
exfat_debug("[%s] %s => %s", __func__, old_path, new_path);
|
||||
return exfat_rename(&ef, old_path, new_path);
|
||||
}
|
||||
|
||||
static int fuse_exfat_utimens(const char* path, const struct timespec tv[2])
|
||||
{
|
||||
struct exfat_node* node;
|
||||
int rc;
|
||||
|
||||
exfat_debug("[%s] %s", __func__, path);
|
||||
|
||||
rc = exfat_lookup(&ef, &node, path);
|
||||
if (rc != 0)
|
||||
return rc;
|
||||
|
||||
exfat_utimes(node, tv);
|
||||
exfat_put_node(&ef, node);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef __APPLE__
|
||||
static int fuse_exfat_chmod(const char* path, mode_t mode)
|
||||
{
|
||||
exfat_debug("[%s] %s 0%ho", __func__, path, mode);
|
||||
/* make OS X utilities happy */
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int fuse_exfat_statfs(const char* path, struct statvfs* sfs)
|
||||
{
|
||||
exfat_debug("[%s]", __func__);
|
||||
|
||||
sfs->f_bsize = CLUSTER_SIZE(*ef.sb);
|
||||
sfs->f_frsize = CLUSTER_SIZE(*ef.sb);
|
||||
sfs->f_blocks = le64_to_cpu(ef.sb->sector_count) >> ef.sb->spc_bits;
|
||||
sfs->f_bavail = exfat_count_free_clusters(&ef);
|
||||
sfs->f_bfree = sfs->f_bavail;
|
||||
sfs->f_namemax = EXFAT_NAME_MAX;
|
||||
|
||||
/*
|
||||
Below are fake values because in exFAT there is
|
||||
a) no simple way to count files;
|
||||
b) no such thing as inode;
|
||||
So here we assume that inode = cluster.
|
||||
*/
|
||||
sfs->f_files = (sfs->f_blocks - sfs->f_bfree) >> ef.sb->spc_bits;
|
||||
sfs->f_favail = sfs->f_bfree >> ef.sb->spc_bits;
|
||||
sfs->f_ffree = sfs->f_bavail;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void* fuse_exfat_init(struct fuse_conn_info* fci)
|
||||
{
|
||||
exfat_debug("[%s]", __func__);
|
||||
#ifdef FUSE_CAP_BIG_WRITES
|
||||
fci->want |= FUSE_CAP_BIG_WRITES;
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void fuse_exfat_destroy(void* unused)
|
||||
{
|
||||
exfat_debug("[%s]", __func__);
|
||||
exfat_unmount(&ef);
|
||||
}
|
||||
|
||||
static void usage(const char* prog)
|
||||
{
|
||||
fprintf(stderr, "Usage: %s [-d] [-o options] [-v] <device> <dir>\n", prog);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static struct fuse_operations fuse_exfat_ops =
|
||||
{
|
||||
.getattr = fuse_exfat_getattr,
|
||||
.truncate = fuse_exfat_truncate,
|
||||
.readdir = fuse_exfat_readdir,
|
||||
.open = fuse_exfat_open,
|
||||
.release = fuse_exfat_release,
|
||||
.read = fuse_exfat_read,
|
||||
.write = fuse_exfat_write,
|
||||
.unlink = fuse_exfat_unlink,
|
||||
.rmdir = fuse_exfat_rmdir,
|
||||
.mknod = fuse_exfat_mknod,
|
||||
.mkdir = fuse_exfat_mkdir,
|
||||
.rename = fuse_exfat_rename,
|
||||
.utimens = fuse_exfat_utimens,
|
||||
#ifdef __APPLE__
|
||||
.chmod = fuse_exfat_chmod,
|
||||
#endif
|
||||
.statfs = fuse_exfat_statfs,
|
||||
.init = fuse_exfat_init,
|
||||
.destroy = fuse_exfat_destroy,
|
||||
};
|
||||
|
||||
static char* add_option(char* options, const char* name, const char* value)
|
||||
{
|
||||
size_t size;
|
||||
|
||||
if (value)
|
||||
size = strlen(options) + strlen(name) + strlen(value) + 3;
|
||||
else
|
||||
size = strlen(options) + strlen(name) + 2;
|
||||
|
||||
options = realloc(options, size);
|
||||
if (options == NULL)
|
||||
{
|
||||
exfat_error("failed to reallocate options string");
|
||||
return NULL;
|
||||
}
|
||||
strcat(options, ",");
|
||||
strcat(options, name);
|
||||
if (value)
|
||||
{
|
||||
strcat(options, "=");
|
||||
strcat(options, value);
|
||||
}
|
||||
return options;
|
||||
}
|
||||
|
||||
static char* add_fsname_option(char* options, const char* spec)
|
||||
{
|
||||
char spec_abs[PATH_MAX];
|
||||
|
||||
if (realpath(spec, spec_abs) == NULL)
|
||||
{
|
||||
free(options);
|
||||
exfat_error("failed to get absolute path for `%s'", spec);
|
||||
return NULL;
|
||||
}
|
||||
return add_option(options, "fsname", spec_abs);
|
||||
}
|
||||
|
||||
static char* add_user_option(char* options)
|
||||
{
|
||||
struct passwd* pw;
|
||||
|
||||
if (getuid() == 0)
|
||||
return options;
|
||||
|
||||
pw = getpwuid(getuid());
|
||||
if (pw == NULL || pw->pw_name == NULL)
|
||||
{
|
||||
free(options);
|
||||
exfat_error("failed to determine username");
|
||||
return NULL;
|
||||
}
|
||||
return add_option(options, "user", pw->pw_name);
|
||||
}
|
||||
|
||||
static char* add_blksize_option(char* options, long cluster_size)
|
||||
{
|
||||
long page_size = sysconf(_SC_PAGESIZE);
|
||||
char blksize[20];
|
||||
|
||||
if (page_size < 1)
|
||||
page_size = 0x1000;
|
||||
|
||||
snprintf(blksize, sizeof(blksize), "%ld", MIN(page_size, cluster_size));
|
||||
return add_option(options, "blksize", blksize);
|
||||
}
|
||||
|
||||
static char* add_fuse_options(char* options, const char* spec)
|
||||
{
|
||||
options = add_fsname_option(options, spec);
|
||||
if (options == NULL)
|
||||
return NULL;
|
||||
options = add_user_option(options);
|
||||
if (options == NULL)
|
||||
return NULL;
|
||||
options = add_blksize_option(options, CLUSTER_SIZE(*ef.sb));
|
||||
if (options == NULL)
|
||||
return NULL;
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
struct fuse_args mount_args = FUSE_ARGS_INIT(0, NULL);
|
||||
struct fuse_args newfs_args = FUSE_ARGS_INIT(0, NULL);
|
||||
const char* spec = NULL;
|
||||
const char* mount_point = NULL;
|
||||
char* mount_options;
|
||||
int debug = 0;
|
||||
struct fuse_chan* fc = NULL;
|
||||
struct fuse* fh = NULL;
|
||||
char** pp;
|
||||
|
||||
printf("FUSE exfat %u.%u.%u\n",
|
||||
EXFAT_VERSION_MAJOR, EXFAT_VERSION_MINOR, EXFAT_VERSION_PATCH);
|
||||
|
||||
mount_options = strdup(default_options);
|
||||
if (mount_options == NULL)
|
||||
{
|
||||
exfat_error("failed to allocate options string");
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (pp = argv + 1; *pp; pp++)
|
||||
{
|
||||
if (strcmp(*pp, "-o") == 0)
|
||||
{
|
||||
pp++;
|
||||
if (*pp == NULL)
|
||||
usage(argv[0]);
|
||||
mount_options = add_option(mount_options, *pp, NULL);
|
||||
if (mount_options == NULL)
|
||||
return 1;
|
||||
}
|
||||
else if (strcmp(*pp, "-d") == 0)
|
||||
debug = 1;
|
||||
else if (strcmp(*pp, "-v") == 0)
|
||||
{
|
||||
free(mount_options);
|
||||
puts("Copyright (C) 2010-2012 Andrew Nayenko");
|
||||
return 0;
|
||||
}
|
||||
else if (spec == NULL)
|
||||
spec = *pp;
|
||||
else if (mount_point == NULL)
|
||||
mount_point = *pp;
|
||||
else
|
||||
{
|
||||
free(mount_options);
|
||||
usage(argv[0]);
|
||||
}
|
||||
}
|
||||
if (spec == NULL || mount_point == NULL)
|
||||
{
|
||||
free(mount_options);
|
||||
usage(argv[0]);
|
||||
}
|
||||
|
||||
if (exfat_mount(&ef, spec, mount_options) != 0)
|
||||
{
|
||||
free(mount_options);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (ef.ro == -1) /* read-only fallback was used */
|
||||
{
|
||||
mount_options = add_option(mount_options, "ro", NULL);
|
||||
if (mount_options == NULL)
|
||||
{
|
||||
exfat_unmount(&ef);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
mount_options = add_fuse_options(mount_options, spec);
|
||||
if (mount_options == NULL)
|
||||
{
|
||||
exfat_unmount(&ef);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* create arguments for fuse_mount() */
|
||||
if (fuse_opt_add_arg(&mount_args, "exfat") != 0 ||
|
||||
fuse_opt_add_arg(&mount_args, "-o") != 0 ||
|
||||
fuse_opt_add_arg(&mount_args, mount_options) != 0)
|
||||
{
|
||||
exfat_unmount(&ef);
|
||||
free(mount_options);
|
||||
return 1;
|
||||
}
|
||||
|
||||
free(mount_options);
|
||||
|
||||
/* create FUSE mount point */
|
||||
fc = fuse_mount(mount_point, &mount_args);
|
||||
fuse_opt_free_args(&mount_args);
|
||||
if (fc == NULL)
|
||||
{
|
||||
exfat_unmount(&ef);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* create arguments for fuse_new() */
|
||||
if (fuse_opt_add_arg(&newfs_args, "") != 0 ||
|
||||
(debug && fuse_opt_add_arg(&newfs_args, "-d") != 0))
|
||||
{
|
||||
fuse_unmount(mount_point, fc);
|
||||
exfat_unmount(&ef);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* create new FUSE file system */
|
||||
fh = fuse_new(fc, &newfs_args, &fuse_exfat_ops,
|
||||
sizeof(struct fuse_operations), NULL);
|
||||
fuse_opt_free_args(&newfs_args);
|
||||
if (fh == NULL)
|
||||
{
|
||||
fuse_unmount(mount_point, fc);
|
||||
exfat_unmount(&ef);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* exit session on HUP, TERM and INT signals and ignore PIPE signal */
|
||||
if (fuse_set_signal_handlers(fuse_get_session(fh)) != 0)
|
||||
{
|
||||
fuse_unmount(mount_point, fc);
|
||||
fuse_destroy(fh);
|
||||
exfat_unmount(&ef);
|
||||
exfat_error("failed to set signal handlers");
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* go to background (unless "-d" option is passed) and run FUSE
|
||||
main loop */
|
||||
if (fuse_daemonize(debug) == 0)
|
||||
{
|
||||
if (fuse_loop(fh) != 0)
|
||||
exfat_error("FUSE loop failure");
|
||||
}
|
||||
else
|
||||
exfat_error("failed to daemonize");
|
||||
|
||||
fuse_remove_signal_handlers(fuse_get_session(fh));
|
||||
/* note that fuse_unmount() must be called BEFORE fuse_destroy() */
|
||||
fuse_unmount(mount_point, fc);
|
||||
fuse_destroy(fh);
|
||||
return 0;
|
||||
}
|
76
exfat/exfat-fuse/mount.exfat-fuse.8
Normal file
76
exfat/exfat-fuse/mount.exfat-fuse.8
Normal file
@ -0,0 +1,76 @@
|
||||
.\" Copyright (C) 2010 Andrew Nayenko
|
||||
.\"
|
||||
.TH EXFAT-FUSE 8 "July 2010"
|
||||
.SH NAME
|
||||
mount.exfat-fuse \- mount an exFAT file system
|
||||
.SH SYNOPSIS
|
||||
.B mount.exfat-fuse
|
||||
[
|
||||
.B \-d
|
||||
]
|
||||
[
|
||||
.B \-o
|
||||
.I options
|
||||
]
|
||||
[
|
||||
.B \-v
|
||||
]
|
||||
.I device dir
|
||||
|
||||
.SH DESCRIPTION
|
||||
.B mount.exfat-fuse
|
||||
is a free exFAT file system implementation with write support. exFAT is a
|
||||
simple file system created by Microsoft. It is intended to replace FAT32
|
||||
removing some of it's limitations. exFAT is a standard FS for SDXC memory
|
||||
cards.
|
||||
|
||||
.SH COMMAND LINE OPTIONS
|
||||
Command line options available:
|
||||
.TP
|
||||
.BI \-d
|
||||
Enable debug logging and do not detach from shell.
|
||||
.TP
|
||||
.BI \-o " options"
|
||||
File system specific options. For more details see
|
||||
.B FILE SYSTEM OPTIONS
|
||||
section below.
|
||||
.TP
|
||||
.BI \-v
|
||||
Print version and copyright.
|
||||
|
||||
.SH FILE SYSTEM OPTIONS
|
||||
.TP
|
||||
.BI umask= value
|
||||
Set the umask (the bitmask of the permissions that are
|
||||
.B not
|
||||
present, in octal).
|
||||
The default is the umask of the current process.
|
||||
.TP
|
||||
.BI dmask= value
|
||||
Set the umask for directories only.
|
||||
.TP
|
||||
.BI fmask= value
|
||||
Set the umask for files only.
|
||||
.TP
|
||||
.BI uid= n
|
||||
Set the owner for all files and directories.
|
||||
The default is the owner of the current process.
|
||||
.TP
|
||||
.BI gid= n
|
||||
Set the group for all files and directories.
|
||||
The default is the group of the current process.
|
||||
.TP
|
||||
.BI ro
|
||||
Mount the file system in read only mode.
|
||||
.TP
|
||||
.BI noatime
|
||||
Do not update access time when file is read.
|
||||
|
||||
.SH EXIT CODES
|
||||
Zero is returned on successful mount. Any other code means an error.
|
||||
|
||||
.SH AUTHOR
|
||||
Andrew Nayenko
|
||||
|
||||
.SH SEE ALSO
|
||||
.BR mount (8)
|
BIN
exfat/fsck/exfatfsck
Executable file
BIN
exfat/fsck/exfatfsck
Executable file
Binary file not shown.
32
exfat/fsck/exfatfsck.8
Normal file
32
exfat/fsck/exfatfsck.8
Normal file
@ -0,0 +1,32 @@
|
||||
.\" Copyright (C) 2011 Andrew Nayenko
|
||||
.\"
|
||||
.TH EXFATFSCK 8 "February 2011"
|
||||
.SH NAME
|
||||
.B exfatfsck
|
||||
\- check an exFAT file system
|
||||
.SH SYNOPSIS
|
||||
.B exfatfsck
|
||||
[
|
||||
.B \-v
|
||||
]
|
||||
.I device
|
||||
|
||||
.SH DESCRIPTION
|
||||
.B exfatfsck
|
||||
checks an exFAT file system for errors. Note that it cannot repair corrupted
|
||||
FS, it just reports found errors.
|
||||
|
||||
.SH COMMAND LINE OPTIONS
|
||||
Command line options available:
|
||||
.TP
|
||||
.BI \-v
|
||||
Print version and copyright.
|
||||
|
||||
.SH EXIT CODES
|
||||
Zero is returned if errors were not found. Any other code means an error.
|
||||
|
||||
.SH AUTHOR
|
||||
Andrew Nayenko
|
||||
|
||||
.SH SEE ALSO
|
||||
.BR fsck (8)
|
172
exfat/fsck/main.c
Normal file
172
exfat/fsck/main.c
Normal file
@ -0,0 +1,172 @@
|
||||
/*
|
||||
main.c (02.09.09)
|
||||
exFAT file system checker.
|
||||
|
||||
Copyright (C) 2011, 2012 Andrew Nayenko
|
||||
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <exfat.h>
|
||||
#include <exfatfs.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#define exfat_debug(format, ...)
|
||||
|
||||
uint64_t files_count, directories_count;
|
||||
|
||||
static int nodeck(struct exfat* ef, struct exfat_node* node)
|
||||
{
|
||||
const cluster_t cluster_size = CLUSTER_SIZE(*ef->sb);
|
||||
cluster_t clusters = (node->size + cluster_size - 1) / cluster_size;
|
||||
cluster_t c = node->start_cluster;
|
||||
int rc = 0;
|
||||
|
||||
while (clusters--)
|
||||
{
|
||||
if (CLUSTER_INVALID(c))
|
||||
{
|
||||
char name[EXFAT_NAME_MAX + 1];
|
||||
|
||||
exfat_get_name(node, name, EXFAT_NAME_MAX);
|
||||
exfat_error("file `%s' has invalid cluster 0x%x", name, c);
|
||||
rc = 1;
|
||||
break;
|
||||
}
|
||||
if (BMAP_GET(ef->cmap.chunk, c - EXFAT_FIRST_DATA_CLUSTER) == 0)
|
||||
{
|
||||
char name[EXFAT_NAME_MAX + 1];
|
||||
|
||||
exfat_get_name(node, name, EXFAT_NAME_MAX);
|
||||
exfat_error("cluster 0x%x of file `%s' is not allocated", c, name);
|
||||
rc = 1;
|
||||
}
|
||||
c = exfat_next_cluster(ef, node, c);
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
static void dirck(struct exfat* ef, const char* path)
|
||||
{
|
||||
struct exfat_node* parent;
|
||||
struct exfat_node* node;
|
||||
struct exfat_iterator it;
|
||||
int rc;
|
||||
size_t path_length;
|
||||
char* entry_path;
|
||||
|
||||
if (exfat_lookup(ef, &parent, path) != 0)
|
||||
exfat_bug("directory `%s' is not found", path);
|
||||
if (!(parent->flags & EXFAT_ATTRIB_DIR))
|
||||
exfat_bug("`%s' is not a directory (0x%x)", path, parent->flags);
|
||||
if (nodeck(ef, parent) != 0)
|
||||
return;
|
||||
|
||||
path_length = strlen(path);
|
||||
entry_path = malloc(path_length + 1 + EXFAT_NAME_MAX);
|
||||
if (entry_path == NULL)
|
||||
{
|
||||
exfat_error("out of memory");
|
||||
return;
|
||||
}
|
||||
strcpy(entry_path, path);
|
||||
strcat(entry_path, "/");
|
||||
|
||||
rc = exfat_opendir(ef, parent, &it);
|
||||
if (rc != 0)
|
||||
{
|
||||
free(entry_path);
|
||||
exfat_put_node(ef, parent);
|
||||
exfat_error("failed to open directory `%s'", path);
|
||||
return;
|
||||
}
|
||||
while ((node = exfat_readdir(ef, &it)))
|
||||
{
|
||||
exfat_get_name(node, entry_path + path_length + 1, EXFAT_NAME_MAX);
|
||||
exfat_debug("%s: %s, %"PRIu64" bytes, cluster %u", entry_path,
|
||||
IS_CONTIGUOUS(*node) ? "contiguous" : "fragmented",
|
||||
node->size, node->start_cluster);
|
||||
if (node->flags & EXFAT_ATTRIB_DIR)
|
||||
{
|
||||
directories_count++;
|
||||
dirck(ef, entry_path);
|
||||
}
|
||||
else
|
||||
{
|
||||
files_count++;
|
||||
nodeck(ef, node);
|
||||
}
|
||||
exfat_put_node(ef, node);
|
||||
}
|
||||
exfat_closedir(ef, &it);
|
||||
exfat_put_node(ef, parent);
|
||||
free(entry_path);
|
||||
}
|
||||
|
||||
static void fsck(struct exfat* ef)
|
||||
{
|
||||
exfat_print_info(ef->sb, exfat_count_free_clusters(ef));
|
||||
dirck(ef, "");
|
||||
}
|
||||
|
||||
static void usage(const char* prog)
|
||||
{
|
||||
fprintf(stderr, "Usage: %s [-v] <device>\n", prog);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
char** pp;
|
||||
const char* spec = NULL;
|
||||
struct exfat ef;
|
||||
|
||||
printf("exfatfsck %u.%u.%u\n",
|
||||
EXFAT_VERSION_MAJOR, EXFAT_VERSION_MINOR, EXFAT_VERSION_PATCH);
|
||||
|
||||
for (pp = argv + 1; *pp; pp++)
|
||||
{
|
||||
if (strcmp(*pp, "-v") == 0)
|
||||
{
|
||||
puts("Copyright (C) 2011, 2012 Andrew Nayenko");
|
||||
return 0;
|
||||
}
|
||||
else if (spec == NULL)
|
||||
spec = *pp;
|
||||
else
|
||||
usage(argv[0]);
|
||||
}
|
||||
if (spec == NULL)
|
||||
usage(argv[0]);
|
||||
|
||||
if (exfat_mount(&ef, spec, "ro") != 0)
|
||||
return 1;
|
||||
|
||||
printf("Checking file system on %s.\n", spec);
|
||||
fsck(&ef);
|
||||
exfat_unmount(&ef);
|
||||
printf("Totally %"PRIu64" directories and %"PRIu64" files.\n",
|
||||
directories_count, files_count);
|
||||
|
||||
fputs("File system checking finished. ", stdout);
|
||||
if (exfat_errors != 0)
|
||||
{
|
||||
printf("ERRORS FOUND: %d.\n", exfat_errors);
|
||||
return 1;
|
||||
}
|
||||
puts("No errors found.");
|
||||
return 0;
|
||||
}
|
48
exfat/label/exfatlabel.8
Normal file
48
exfat/label/exfatlabel.8
Normal file
@ -0,0 +1,48 @@
|
||||
.\" Copyright (C) 2011 Andrew Nayenko
|
||||
.\"
|
||||
.TH EXFATLABEL 8 "February 2011"
|
||||
.SH NAME
|
||||
.B exfatlabel
|
||||
\- get or set an exFAT file system label
|
||||
.SH SYNOPSIS
|
||||
.B exfatlabel
|
||||
[
|
||||
.B \-v
|
||||
]
|
||||
.I device
|
||||
[
|
||||
.I label
|
||||
]
|
||||
|
||||
.SH DESCRIPTION
|
||||
.B exfatlabel
|
||||
reads or changes an exFAT file system label (volume name).
|
||||
|
||||
If
|
||||
.I label
|
||||
argument is present,
|
||||
.B exfatlabel
|
||||
sets the new volume name. Label can be up to 15 characters. This limit is
|
||||
shorter if characters beyond Unicode BMP are used because internally label
|
||||
is stored in UTF-16.
|
||||
|
||||
If
|
||||
.I label
|
||||
argument is omitted,
|
||||
.B exfatlabel
|
||||
just prints current volume name.
|
||||
|
||||
.SH COMMAND LINE OPTIONS
|
||||
Command line options available:
|
||||
.TP
|
||||
.BI \-v
|
||||
Print version and copyright.
|
||||
|
||||
.SH EXIT CODES
|
||||
Zero is returned on success. Any other code means an error.
|
||||
|
||||
.SH AUTHOR
|
||||
Andrew Nayenko
|
||||
|
||||
.SH SEE ALSO
|
||||
.BR mkexfatfs (8)
|
61
exfat/label/main.c
Normal file
61
exfat/label/main.c
Normal file
@ -0,0 +1,61 @@
|
||||
/*
|
||||
main.c (20.01.11)
|
||||
Prints or changes exFAT volume label.
|
||||
|
||||
Copyright (C) 2011, 2012 Andrew Nayenko
|
||||
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <exfat.h>
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
char** pp;
|
||||
struct exfat ef;
|
||||
int rc = 0;
|
||||
|
||||
for (pp = argv + 1; *pp; pp++)
|
||||
if (strcmp(*pp, "-v") == 0)
|
||||
{
|
||||
printf("exfatlabel %u.%u.%u\n", EXFAT_VERSION_MAJOR,
|
||||
EXFAT_VERSION_MINOR, EXFAT_VERSION_PATCH);
|
||||
puts("Copyright (C) 2011, 2012 Andrew Nayenko");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (argc != 2 && argc != 3)
|
||||
{
|
||||
fprintf(stderr, "Usage: %s [-v] <device> [label]\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (argv[2])
|
||||
{
|
||||
if (exfat_mount(&ef, argv[1], "") != 0)
|
||||
return 1;
|
||||
rc = (exfat_set_label(&ef, argv[2]) != 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (exfat_mount(&ef, argv[1], "ro") != 0)
|
||||
return 1;
|
||||
puts(exfat_get_label(&ef));
|
||||
}
|
||||
|
||||
exfat_unmount(&ef);
|
||||
return rc;
|
||||
}
|
13
exfat/libexfat/Android.mk
Normal file
13
exfat/libexfat/Android.mk
Normal file
@ -0,0 +1,13 @@
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE := libexfat
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin
|
||||
LOCAL_CFLAGS = -D_FILE_OFFSET_BITS=64
|
||||
LOCAL_SRC_FILES = cluster.c io.c log.c lookup.c mount.c node.c time.c utf.c utils.c
|
||||
LOCAL_C_INCLUDES += $(LOCAL_PATH) \
|
||||
LOCAL_SHARED_LIBRARIES += libc
|
||||
|
||||
include $(BUILD_SHARED_LIBRARY)
|
109
exfat/libexfat/byteorder.h
Normal file
109
exfat/libexfat/byteorder.h
Normal file
@ -0,0 +1,109 @@
|
||||
/*
|
||||
byteorder.h (12.01.10)
|
||||
Endianness stuff. exFAT uses little-endian byte order.
|
||||
|
||||
Copyright (C) 2010-2012 Andrew Nayenko
|
||||
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#ifndef BYTEORDER_H_INCLUDED
|
||||
#define BYTEORDER_H_INCLUDED
|
||||
|
||||
#define __GLIBC__
|
||||
#include <stdint.h>
|
||||
|
||||
#if defined(__GLIBC__)
|
||||
|
||||
#include <endian.h>
|
||||
#include <byteswap.h>
|
||||
|
||||
#elif defined(__APPLE__)
|
||||
|
||||
#include <machine/endian.h>
|
||||
#include <libkern/OSByteOrder.h>
|
||||
#define bswap_16(x) OSSwapInt16(x)
|
||||
#define bswap_32(x) OSSwapInt32(x)
|
||||
#define bswap_64(x) OSSwapInt64(x)
|
||||
#define __BYTE_ORDER BYTE_ORDER
|
||||
#define __LITTLE_ENDIAN LITTLE_ENDIAN
|
||||
#define __BIG_ENDIAN BIG_ENDIAN
|
||||
|
||||
#elif defined(__FreeBSD__) || defined(__DragonFlyBSD__) || defined(__NetBSD__)
|
||||
|
||||
#include <sys/endian.h>
|
||||
#define bswap_16(x) bswap16(x)
|
||||
#define bswap_32(x) bswap32(x)
|
||||
#define bswap_64(x) bswap64(x)
|
||||
#define __BYTE_ORDER _BYTE_ORDER
|
||||
#define __LITTLE_ENDIAN _LITTLE_ENDIAN
|
||||
#define __BIG_ENDIAN _BIG_ENDIAN
|
||||
|
||||
#elif defined(__OpenBSD__)
|
||||
|
||||
#include <machine/endian.h>
|
||||
#define bswap_16(x) swap16(x)
|
||||
#define bswap_32(x) swap32(x)
|
||||
#define bswap_64(x) swap64(x)
|
||||
#define __BYTE_ORDER _BYTE_ORDER
|
||||
#define __LITTLE_ENDIAN _LITTLE_ENDIAN
|
||||
#define __BIG_ENDIAN _BIG_ENDIAN
|
||||
|
||||
#elif defined(__sun)
|
||||
|
||||
#include <sys/byteorder.h>
|
||||
#define bswap_16(x) BSWAP_16(x)
|
||||
#define bswap_32(x) BSWAP_32(x)
|
||||
#define bswap_64(x) BSWAP_64(x)
|
||||
#define __LITTLE_ENDIAN 1234
|
||||
#define __BIG_ENDIAN 4321
|
||||
#ifdef _LITTLE_ENDIAN
|
||||
#define __BYTE_ORDER __LITTLE_ENDIAN
|
||||
#else
|
||||
#define __BYTE_ORDER __BIG_ENDIAN
|
||||
#endif
|
||||
|
||||
#else
|
||||
#error No byte order macros available for your platform
|
||||
#endif
|
||||
|
||||
#define __BYTE_ORDER __LITTLE_ENDIAN
|
||||
typedef struct { uint16_t __u16; } le16_t;
|
||||
typedef struct { uint32_t __u32; } le32_t;
|
||||
typedef struct { uint64_t __u64; } le64_t;
|
||||
|
||||
#if __BYTE_ORDER == __LITTLE_ENDIAN
|
||||
static inline uint16_t le16_to_cpu(le16_t v) { return v.__u16; }
|
||||
static inline uint32_t le32_to_cpu(le32_t v) { return v.__u32; }
|
||||
static inline uint64_t le64_to_cpu(le64_t v) { return v.__u64; }
|
||||
|
||||
static inline le16_t cpu_to_le16(uint16_t v) { le16_t t = {v}; return t; }
|
||||
static inline le32_t cpu_to_le32(uint32_t v) { le32_t t = {v}; return t; }
|
||||
static inline le64_t cpu_to_le64(uint64_t v) { le64_t t = {v}; return t; }
|
||||
#elif __BYTE_ORDER == __BIG_ENDIAN
|
||||
static inline uint16_t le16_to_cpu(le16_t v) { return bswap_16(v.__u16); }
|
||||
static inline uint32_t le32_to_cpu(le32_t v) { return bswap_32(v.__u32); }
|
||||
static inline uint64_t le64_to_cpu(le64_t v) { return bswap_64(v.__u64); }
|
||||
|
||||
static inline le16_t cpu_to_le16(uint16_t v)
|
||||
{ le16_t t = {bswap_16(v)}; return t; }
|
||||
static inline le32_t cpu_to_le32(uint32_t v)
|
||||
{ le32_t t = {bswap_32(v)}; return t; }
|
||||
static inline le64_t cpu_to_le64(uint64_t v)
|
||||
{ le64_t t = {bswap_64(v)}; return t; }
|
||||
#else
|
||||
#error Wow! You have a PDP machine?!
|
||||
#endif
|
||||
|
||||
#endif /* ifndef BYTEORDER_H_INCLUDED */
|
445
exfat/libexfat/cluster.c
Normal file
445
exfat/libexfat/cluster.c
Normal file
@ -0,0 +1,445 @@
|
||||
/*
|
||||
cluster.c (03.09.09)
|
||||
exFAT file system implementation library.
|
||||
|
||||
Copyright (C) 2010-2012 Andrew Nayenko
|
||||
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#include "exfat.h"
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
/*
|
||||
* Sector to absolute offset.
|
||||
*/
|
||||
static off64_t s2o(const struct exfat* ef, off64_t sector)
|
||||
{
|
||||
return sector << ef->sb->sector_bits;
|
||||
}
|
||||
|
||||
/*
|
||||
* Cluster to sector.
|
||||
*/
|
||||
static off64_t c2s(const struct exfat* ef, cluster_t cluster)
|
||||
{
|
||||
if (cluster < EXFAT_FIRST_DATA_CLUSTER)
|
||||
exfat_bug("invalid cluster number %u", cluster);
|
||||
return le32_to_cpu(ef->sb->cluster_sector_start) +
|
||||
((off64_t) (cluster - EXFAT_FIRST_DATA_CLUSTER) << ef->sb->spc_bits);
|
||||
}
|
||||
|
||||
/*
|
||||
* Cluster to absolute offset.
|
||||
*/
|
||||
off64_t exfat_c2o(const struct exfat* ef, cluster_t cluster)
|
||||
{
|
||||
return s2o(ef, c2s(ef, cluster));
|
||||
}
|
||||
|
||||
/*
|
||||
* Sector to cluster.
|
||||
*/
|
||||
static cluster_t s2c(const struct exfat* ef, off64_t sector)
|
||||
{
|
||||
return ((sector - le32_to_cpu(ef->sb->cluster_sector_start)) >>
|
||||
ef->sb->spc_bits) + EXFAT_FIRST_DATA_CLUSTER;
|
||||
}
|
||||
|
||||
/*
|
||||
* Size in bytes to size in clusters (rounded upwards).
|
||||
*/
|
||||
static uint32_t bytes2clusters(const struct exfat* ef, uint64_t bytes)
|
||||
{
|
||||
uint64_t cluster_size = CLUSTER_SIZE(*ef->sb);
|
||||
return (bytes + cluster_size - 1) / cluster_size;
|
||||
}
|
||||
|
||||
cluster_t exfat_next_cluster(const struct exfat* ef,
|
||||
const struct exfat_node* node, cluster_t cluster)
|
||||
{
|
||||
le32_t next;
|
||||
off64_t fat_offset;
|
||||
|
||||
if (cluster < EXFAT_FIRST_DATA_CLUSTER)
|
||||
exfat_bug("bad cluster 0x%x", cluster);
|
||||
|
||||
if (IS_CONTIGUOUS(*node))
|
||||
return cluster + 1;
|
||||
fat_offset = s2o(ef, le32_to_cpu(ef->sb->fat_sector_start))
|
||||
+ cluster * sizeof(cluster_t);
|
||||
exfat_pread(ef->dev, &next, sizeof(next), fat_offset);
|
||||
return le32_to_cpu(next);
|
||||
}
|
||||
|
||||
cluster_t exfat_advance_cluster(const struct exfat* ef,
|
||||
struct exfat_node* node, uint32_t count)
|
||||
{
|
||||
uint32_t i;
|
||||
|
||||
if (node->fptr_index > count)
|
||||
{
|
||||
node->fptr_index = 0;
|
||||
node->fptr_cluster = node->start_cluster;
|
||||
}
|
||||
|
||||
for (i = node->fptr_index; i < count; i++)
|
||||
{
|
||||
node->fptr_cluster = exfat_next_cluster(ef, node, node->fptr_cluster);
|
||||
if (CLUSTER_INVALID(node->fptr_cluster))
|
||||
break; /* the caller should handle this and print appropriate
|
||||
error message */
|
||||
}
|
||||
node->fptr_index = count;
|
||||
return node->fptr_cluster;
|
||||
}
|
||||
|
||||
static cluster_t find_bit_and_set(uint8_t* bitmap, cluster_t start,
|
||||
cluster_t end)
|
||||
{
|
||||
const cluster_t mid_start = (start + 7) / 8 * 8;
|
||||
const cluster_t mid_end = end / 8 * 8;
|
||||
cluster_t c;
|
||||
cluster_t byte;
|
||||
|
||||
for (c = start; c < mid_start; c++)
|
||||
if (BMAP_GET(bitmap, c) == 0)
|
||||
{
|
||||
BMAP_SET(bitmap, c);
|
||||
return c + EXFAT_FIRST_DATA_CLUSTER;
|
||||
}
|
||||
|
||||
for (byte = mid_start / 8; byte < mid_end / 8; byte++)
|
||||
if (bitmap[byte] != 0xff)
|
||||
{
|
||||
cluster_t bit;
|
||||
|
||||
for (bit = 0; bit < 8; bit++)
|
||||
if (!(bitmap[byte] & (1u << bit)))
|
||||
{
|
||||
bitmap[byte] |= (1u << bit);
|
||||
return byte * 8 + bit + EXFAT_FIRST_DATA_CLUSTER;
|
||||
}
|
||||
}
|
||||
|
||||
for (c = mid_end; c < end; c++)
|
||||
if (BMAP_GET(bitmap, c) == 0)
|
||||
{
|
||||
BMAP_SET(bitmap, c);
|
||||
return c + EXFAT_FIRST_DATA_CLUSTER;
|
||||
}
|
||||
|
||||
return EXFAT_CLUSTER_END;
|
||||
}
|
||||
|
||||
void exfat_flush_cmap(struct exfat* ef)
|
||||
{
|
||||
exfat_pwrite(ef->dev, ef->cmap.chunk, (ef->cmap.chunk_size + 7) / 8,
|
||||
exfat_c2o(ef, ef->cmap.start_cluster));
|
||||
ef->cmap.dirty = false;
|
||||
}
|
||||
|
||||
static void set_next_cluster(const struct exfat* ef, int contiguous,
|
||||
cluster_t current, cluster_t next)
|
||||
{
|
||||
off64_t fat_offset;
|
||||
le32_t next_le32;
|
||||
|
||||
if (contiguous)
|
||||
return;
|
||||
fat_offset = s2o(ef, le32_to_cpu(ef->sb->fat_sector_start))
|
||||
+ current * sizeof(cluster_t);
|
||||
next_le32 = cpu_to_le32(next);
|
||||
exfat_pwrite(ef->dev, &next_le32, sizeof(next_le32), fat_offset);
|
||||
}
|
||||
|
||||
static cluster_t allocate_cluster(struct exfat* ef, cluster_t hint)
|
||||
{
|
||||
cluster_t cluster;
|
||||
|
||||
hint -= EXFAT_FIRST_DATA_CLUSTER;
|
||||
if (hint >= ef->cmap.chunk_size)
|
||||
hint = 0;
|
||||
|
||||
cluster = find_bit_and_set(ef->cmap.chunk, hint, ef->cmap.chunk_size);
|
||||
if (cluster == EXFAT_CLUSTER_END)
|
||||
cluster = find_bit_and_set(ef->cmap.chunk, 0, hint);
|
||||
if (cluster == EXFAT_CLUSTER_END)
|
||||
{
|
||||
exfat_error("no free space left");
|
||||
return EXFAT_CLUSTER_END;
|
||||
}
|
||||
|
||||
ef->cmap.dirty = true;
|
||||
return cluster;
|
||||
}
|
||||
|
||||
static void free_cluster(struct exfat* ef, cluster_t cluster)
|
||||
{
|
||||
if (CLUSTER_INVALID(cluster))
|
||||
exfat_bug("freeing invalid cluster 0x%x", cluster);
|
||||
if (cluster - EXFAT_FIRST_DATA_CLUSTER >= ef->cmap.size)
|
||||
exfat_bug("freeing non-existing cluster 0x%x (0x%x)", cluster,
|
||||
ef->cmap.size);
|
||||
|
||||
BMAP_CLR(ef->cmap.chunk, cluster - EXFAT_FIRST_DATA_CLUSTER);
|
||||
ef->cmap.dirty = true;
|
||||
}
|
||||
|
||||
static void make_noncontiguous(const struct exfat* ef, cluster_t first,
|
||||
cluster_t last)
|
||||
{
|
||||
cluster_t c;
|
||||
|
||||
for (c = first; c < last; c++)
|
||||
set_next_cluster(ef, 0, c, c + 1);
|
||||
}
|
||||
|
||||
static int shrink_file(struct exfat* ef, struct exfat_node* node,
|
||||
uint32_t current, uint32_t difference);
|
||||
|
||||
static int grow_file(struct exfat* ef, struct exfat_node* node,
|
||||
uint32_t current, uint32_t difference)
|
||||
{
|
||||
cluster_t previous;
|
||||
cluster_t next;
|
||||
uint32_t allocated = 0;
|
||||
|
||||
if (difference == 0)
|
||||
exfat_bug("zero clusters count passed");
|
||||
|
||||
if (node->start_cluster != EXFAT_CLUSTER_FREE)
|
||||
{
|
||||
/* get the last cluster of the file */
|
||||
previous = exfat_advance_cluster(ef, node, current - 1);
|
||||
if (CLUSTER_INVALID(previous))
|
||||
{
|
||||
exfat_error("invalid cluster 0x%x while growing", previous);
|
||||
return -EIO;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (node->fptr_index != 0)
|
||||
exfat_bug("non-zero pointer index (%u)", node->fptr_index);
|
||||
/* file does not have clusters (i.e. is empty), allocate
|
||||
the first one for it */
|
||||
previous = allocate_cluster(ef, 0);
|
||||
if (CLUSTER_INVALID(previous))
|
||||
return -ENOSPC;
|
||||
node->fptr_cluster = node->start_cluster = previous;
|
||||
allocated = 1;
|
||||
/* file consists of only one cluster, so it's contiguous */
|
||||
node->flags |= EXFAT_ATTRIB_CONTIGUOUS;
|
||||
}
|
||||
|
||||
while (allocated < difference)
|
||||
{
|
||||
next = allocate_cluster(ef, previous + 1);
|
||||
if (CLUSTER_INVALID(next))
|
||||
{
|
||||
if (allocated != 0)
|
||||
shrink_file(ef, node, current + allocated, allocated);
|
||||
return -ENOSPC;
|
||||
}
|
||||
if (next != previous - 1 && IS_CONTIGUOUS(*node))
|
||||
{
|
||||
/* it's a pity, but we are not able to keep the file contiguous
|
||||
anymore */
|
||||
make_noncontiguous(ef, node->start_cluster, previous);
|
||||
node->flags &= ~EXFAT_ATTRIB_CONTIGUOUS;
|
||||
node->flags |= EXFAT_ATTRIB_DIRTY;
|
||||
}
|
||||
set_next_cluster(ef, IS_CONTIGUOUS(*node), previous, next);
|
||||
previous = next;
|
||||
allocated++;
|
||||
}
|
||||
|
||||
set_next_cluster(ef, IS_CONTIGUOUS(*node), previous, EXFAT_CLUSTER_END);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int shrink_file(struct exfat* ef, struct exfat_node* node,
|
||||
uint32_t current, uint32_t difference)
|
||||
{
|
||||
cluster_t previous;
|
||||
cluster_t next;
|
||||
|
||||
if (difference == 0)
|
||||
exfat_bug("zero difference passed");
|
||||
if (node->start_cluster == EXFAT_CLUSTER_FREE)
|
||||
exfat_bug("unable to shrink empty file (%u clusters)", current);
|
||||
if (current < difference)
|
||||
exfat_bug("file underflow (%u < %u)", current, difference);
|
||||
|
||||
/* crop the file */
|
||||
if (current > difference)
|
||||
{
|
||||
cluster_t last = exfat_advance_cluster(ef, node,
|
||||
current - difference - 1);
|
||||
if (CLUSTER_INVALID(last))
|
||||
{
|
||||
exfat_error("invalid cluster 0x%x while shrinking", last);
|
||||
return -EIO;
|
||||
}
|
||||
previous = exfat_next_cluster(ef, node, last);
|
||||
set_next_cluster(ef, IS_CONTIGUOUS(*node), last, EXFAT_CLUSTER_END);
|
||||
}
|
||||
else
|
||||
{
|
||||
previous = node->start_cluster;
|
||||
node->start_cluster = EXFAT_CLUSTER_FREE;
|
||||
}
|
||||
node->fptr_index = 0;
|
||||
node->fptr_cluster = node->start_cluster;
|
||||
|
||||
/* free remaining clusters */
|
||||
while (difference--)
|
||||
{
|
||||
if (CLUSTER_INVALID(previous))
|
||||
{
|
||||
exfat_error("invalid cluster 0x%x while freeing after shrink",
|
||||
previous);
|
||||
return -EIO;
|
||||
}
|
||||
next = exfat_next_cluster(ef, node, previous);
|
||||
set_next_cluster(ef, IS_CONTIGUOUS(*node), previous,
|
||||
EXFAT_CLUSTER_FREE);
|
||||
free_cluster(ef, previous);
|
||||
previous = next;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void erase_raw(struct exfat* ef, size_t size, off64_t offset)
|
||||
{
|
||||
exfat_pwrite(ef->dev, ef->zero_cluster, size, offset);
|
||||
}
|
||||
|
||||
static int erase_range(struct exfat* ef, struct exfat_node* node,
|
||||
uint64_t begin, uint64_t end)
|
||||
{
|
||||
uint64_t cluster_boundary;
|
||||
cluster_t cluster;
|
||||
|
||||
if (begin >= end)
|
||||
return 0;
|
||||
|
||||
cluster_boundary = (begin | (CLUSTER_SIZE(*ef->sb) - 1)) + 1;
|
||||
cluster = exfat_advance_cluster(ef, node,
|
||||
begin / CLUSTER_SIZE(*ef->sb));
|
||||
if (CLUSTER_INVALID(cluster))
|
||||
{
|
||||
exfat_error("invalid cluster 0x%x while erasing", cluster);
|
||||
return -EIO;
|
||||
}
|
||||
/* erase from the beginning to the closest cluster boundary */
|
||||
erase_raw(ef, MIN(cluster_boundary, end) - begin,
|
||||
exfat_c2o(ef, cluster) + begin % CLUSTER_SIZE(*ef->sb));
|
||||
/* erase whole clusters */
|
||||
while (cluster_boundary < end)
|
||||
{
|
||||
cluster = exfat_next_cluster(ef, node, cluster);
|
||||
/* the cluster cannot be invalid because we have just allocated it */
|
||||
if (CLUSTER_INVALID(cluster))
|
||||
exfat_bug("invalid cluster 0x%x after allocation", cluster);
|
||||
erase_raw(ef, CLUSTER_SIZE(*ef->sb), exfat_c2o(ef, cluster));
|
||||
cluster_boundary += CLUSTER_SIZE(*ef->sb);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int exfat_truncate(struct exfat* ef, struct exfat_node* node, uint64_t size)
|
||||
{
|
||||
uint32_t c1 = bytes2clusters(ef, node->size);
|
||||
uint32_t c2 = bytes2clusters(ef, size);
|
||||
int rc = 0;
|
||||
|
||||
if (node->references == 0 && node->parent)
|
||||
exfat_bug("no references, node changes can be lost");
|
||||
|
||||
if (node->size == size)
|
||||
return 0;
|
||||
|
||||
if (c1 < c2)
|
||||
rc = grow_file(ef, node, c1, c2 - c1);
|
||||
else if (c1 > c2)
|
||||
rc = shrink_file(ef, node, c1, c1 - c2);
|
||||
|
||||
if (rc != 0)
|
||||
return rc;
|
||||
|
||||
rc = erase_range(ef, node, node->size, size);
|
||||
if (rc != 0)
|
||||
return rc;
|
||||
|
||||
exfat_update_mtime(node);
|
||||
node->size = size;
|
||||
node->flags |= EXFAT_ATTRIB_DIRTY;
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t exfat_count_free_clusters(const struct exfat* ef)
|
||||
{
|
||||
uint32_t free_clusters = 0;
|
||||
uint32_t i;
|
||||
|
||||
for (i = 0; i < ef->cmap.size; i++)
|
||||
if (BMAP_GET(ef->cmap.chunk, i) == 0)
|
||||
free_clusters++;
|
||||
return free_clusters;
|
||||
}
|
||||
|
||||
static int find_used_clusters(const struct exfat* ef,
|
||||
cluster_t* a, cluster_t* b)
|
||||
{
|
||||
const cluster_t end = le32_to_cpu(ef->sb->cluster_count);
|
||||
|
||||
/* find first used cluster */
|
||||
for (*a = *b + 1; *a < end; (*a)++)
|
||||
if (BMAP_GET(ef->cmap.chunk, *a - EXFAT_FIRST_DATA_CLUSTER))
|
||||
break;
|
||||
if (*a >= end)
|
||||
return 1;
|
||||
|
||||
/* find last contiguous used cluster */
|
||||
for (*b = *a; *b < end; (*b)++)
|
||||
if (BMAP_GET(ef->cmap.chunk, *b - EXFAT_FIRST_DATA_CLUSTER) == 0)
|
||||
{
|
||||
(*b)--;
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int exfat_find_used_sectors(const struct exfat* ef, off64_t* a, off64_t* b)
|
||||
{
|
||||
cluster_t ca, cb;
|
||||
|
||||
if (*a == 0 && *b == 0)
|
||||
ca = cb = EXFAT_FIRST_DATA_CLUSTER - 1;
|
||||
else
|
||||
{
|
||||
ca = s2c(ef, *a);
|
||||
cb = s2c(ef, *b);
|
||||
}
|
||||
if (find_used_clusters(ef, &ca, &cb) != 0)
|
||||
return 1;
|
||||
if (*a != 0 || *b != 0)
|
||||
*a = c2s(ef, ca);
|
||||
*b = c2s(ef, cb) + (CLUSTER_SIZE(*ef->sb) - 1) / SECTOR_SIZE(*ef->sb);
|
||||
return 0;
|
||||
}
|
215
exfat/libexfat/exfat.h
Normal file
215
exfat/libexfat/exfat.h
Normal file
@ -0,0 +1,215 @@
|
||||
/*
|
||||
exfat.h (29.08.09)
|
||||
Definitions of structures and constants used in exFAT file system
|
||||
implementation.
|
||||
|
||||
Copyright (C) 2010-2012 Andrew Nayenko
|
||||
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#ifndef EXFAT_H_INCLUDED
|
||||
#define EXFAT_H_INCLUDED
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <stdbool.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include "exfatfs.h"
|
||||
#include "version.h"
|
||||
|
||||
#define EXFAT_NAME_MAX 256
|
||||
#define EXFAT_ATTRIB_CONTIGUOUS 0x10000
|
||||
#define EXFAT_ATTRIB_CACHED 0x20000
|
||||
#define EXFAT_ATTRIB_DIRTY 0x40000
|
||||
#define EXFAT_ATTRIB_UNLINKED 0x80000
|
||||
#define IS_CONTIGUOUS(node) (((node).flags & EXFAT_ATTRIB_CONTIGUOUS) != 0)
|
||||
#define SECTOR_SIZE(sb) (1 << (sb).sector_bits)
|
||||
#define CLUSTER_SIZE(sb) (SECTOR_SIZE(sb) << (sb).spc_bits)
|
||||
#define CLUSTER_INVALID(c) \
|
||||
((c) < EXFAT_FIRST_DATA_CLUSTER || (c) > EXFAT_LAST_DATA_CLUSTER)
|
||||
|
||||
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||
#define MAX(a, b) ((a) > (b) ? (a) : (b))
|
||||
#define DIV_ROUND_UP(x, d) (((x) + (d) - 1) / (d))
|
||||
#define ROUND_UP(x, d) (DIV_ROUND_UP(x, d) * (d))
|
||||
|
||||
#define BMAP_GET(bitmap, index) \
|
||||
(((uint8_t*) bitmap)[(index) / 8] & (1u << ((index) % 8)))
|
||||
#define BMAP_SET(bitmap, index) \
|
||||
((uint8_t*) bitmap)[(index) / 8] |= (1u << ((index) % 8))
|
||||
#define BMAP_CLR(bitmap, index) \
|
||||
((uint8_t*) bitmap)[(index) / 8] &= ~(1u << ((index) % 8))
|
||||
|
||||
struct exfat_node
|
||||
{
|
||||
struct exfat_node* parent;
|
||||
struct exfat_node* child;
|
||||
struct exfat_node* next;
|
||||
struct exfat_node* prev;
|
||||
|
||||
int references;
|
||||
uint32_t fptr_index;
|
||||
cluster_t fptr_cluster;
|
||||
cluster_t entry_cluster;
|
||||
off64_t entry_offset;
|
||||
cluster_t start_cluster;
|
||||
int flags;
|
||||
uint64_t size;
|
||||
time_t mtime, atime;
|
||||
le16_t name[EXFAT_NAME_MAX + 1];
|
||||
};
|
||||
|
||||
enum exfat_mode
|
||||
{
|
||||
EXFAT_MODE_RO,
|
||||
EXFAT_MODE_RW,
|
||||
EXFAT_MODE_ANY,
|
||||
};
|
||||
|
||||
struct exfat_dev;
|
||||
|
||||
struct exfat
|
||||
{
|
||||
struct exfat_dev* dev;
|
||||
struct exfat_super_block* sb;
|
||||
le16_t* upcase;
|
||||
size_t upcase_chars;
|
||||
struct exfat_node* root;
|
||||
struct
|
||||
{
|
||||
cluster_t start_cluster;
|
||||
uint32_t size; /* in bits */
|
||||
uint8_t* chunk;
|
||||
uint32_t chunk_size; /* in bits */
|
||||
bool dirty;
|
||||
}
|
||||
cmap;
|
||||
char label[EXFAT_ENAME_MAX * 6 + 1]; /* a character can occupy up to
|
||||
6 bytes in UTF-8 */
|
||||
void* zero_cluster;
|
||||
int dmask, fmask;
|
||||
uid_t uid;
|
||||
gid_t gid;
|
||||
int ro;
|
||||
bool noatime;
|
||||
};
|
||||
|
||||
/* in-core nodes iterator */
|
||||
struct exfat_iterator
|
||||
{
|
||||
struct exfat_node* parent;
|
||||
struct exfat_node* current;
|
||||
};
|
||||
|
||||
struct exfat_human_bytes
|
||||
{
|
||||
uint64_t value;
|
||||
const char* unit;
|
||||
};
|
||||
|
||||
extern int exfat_errors;
|
||||
|
||||
void exfat_bug(const char* format, ...)
|
||||
__attribute__((format(printf, 1, 2), noreturn));
|
||||
void exfat_error(const char* format, ...)
|
||||
__attribute__((format(printf, 1, 2)));
|
||||
void exfat_warn(const char* format, ...)
|
||||
__attribute__((format(printf, 1, 2)));
|
||||
void exfat_debug(const char* format, ...)
|
||||
__attribute__((format(printf, 1, 2)));
|
||||
|
||||
struct exfat_dev* exfat_open(const char* spec, enum exfat_mode mode);
|
||||
int exfat_close(struct exfat_dev* dev);
|
||||
int exfat_fsync(struct exfat_dev* dev);
|
||||
enum exfat_mode exfat_get_mode(const struct exfat_dev* dev);
|
||||
off64_t exfat_get_size(const struct exfat_dev* dev);
|
||||
off64_t exfat_seek(struct exfat_dev* dev, off64_t offset, int whence);
|
||||
ssize_t exfat_read(struct exfat_dev* dev, void* buffer, size_t size);
|
||||
ssize_t exfat_write(struct exfat_dev* dev, const void* buffer, size_t size);
|
||||
void exfat_pread(struct exfat_dev* dev, void* buffer, size_t size,
|
||||
off64_t offset);
|
||||
void exfat_pwrite(struct exfat_dev* dev, const void* buffer, size_t size,
|
||||
off64_t offset);
|
||||
ssize_t exfat_generic_pread(const struct exfat* ef, struct exfat_node* node,
|
||||
void* buffer, size_t size, off64_t offset);
|
||||
ssize_t exfat_generic_pwrite(struct exfat* ef, struct exfat_node* node,
|
||||
const void* buffer, size_t size, off64_t offset);
|
||||
|
||||
int exfat_opendir(struct exfat* ef, struct exfat_node* dir,
|
||||
struct exfat_iterator* it);
|
||||
void exfat_closedir(struct exfat* ef, struct exfat_iterator* it);
|
||||
struct exfat_node* exfat_readdir(struct exfat* ef, struct exfat_iterator* it);
|
||||
int exfat_lookup(struct exfat* ef, struct exfat_node** node,
|
||||
const char* path);
|
||||
int exfat_split(struct exfat* ef, struct exfat_node** parent,
|
||||
struct exfat_node** node, le16_t* name, const char* path);
|
||||
|
||||
off64_t exfat_c2o(const struct exfat* ef, cluster_t cluster);
|
||||
cluster_t exfat_next_cluster(const struct exfat* ef,
|
||||
const struct exfat_node* node, cluster_t cluster);
|
||||
cluster_t exfat_advance_cluster(const struct exfat* ef,
|
||||
struct exfat_node* node, uint32_t count);
|
||||
void exfat_flush_cmap(struct exfat* ef);
|
||||
int exfat_truncate(struct exfat* ef, struct exfat_node* node, uint64_t size);
|
||||
uint32_t exfat_count_free_clusters(const struct exfat* ef);
|
||||
int exfat_find_used_sectors(const struct exfat* ef, off64_t* a, off64_t* b);
|
||||
|
||||
void exfat_stat(const struct exfat* ef, const struct exfat_node* node,
|
||||
struct stat* stbuf);
|
||||
void exfat_get_name(const struct exfat_node* node, char* buffer, size_t n);
|
||||
uint16_t exfat_start_checksum(const struct exfat_entry_meta1* entry);
|
||||
uint16_t exfat_add_checksum(const void* entry, uint16_t sum);
|
||||
le16_t exfat_calc_checksum(const struct exfat_entry_meta1* meta1,
|
||||
const struct exfat_entry_meta2* meta2, const le16_t* name);
|
||||
uint32_t exfat_vbr_start_checksum(const void* sector, size_t size);
|
||||
uint32_t exfat_vbr_add_checksum(const void* sector, size_t size, uint32_t sum);
|
||||
le16_t exfat_calc_name_hash(const struct exfat* ef, const le16_t* name);
|
||||
void exfat_humanize_bytes(uint64_t value, struct exfat_human_bytes* hb);
|
||||
void exfat_print_info(const struct exfat_super_block* sb,
|
||||
uint32_t free_clusters);
|
||||
|
||||
int utf16_to_utf8(char* output, const le16_t* input, size_t outsize,
|
||||
size_t insize);
|
||||
int utf8_to_utf16(le16_t* output, const char* input, size_t outsize,
|
||||
size_t insize);
|
||||
size_t utf16_length(const le16_t* str);
|
||||
|
||||
struct exfat_node* exfat_get_node(struct exfat_node* node);
|
||||
void exfat_put_node(struct exfat* ef, struct exfat_node* node);
|
||||
int exfat_cache_directory(struct exfat* ef, struct exfat_node* dir);
|
||||
void exfat_reset_cache(struct exfat* ef);
|
||||
void exfat_flush_node(struct exfat* ef, struct exfat_node* node);
|
||||
int exfat_unlink(struct exfat* ef, struct exfat_node* node);
|
||||
int exfat_rmdir(struct exfat* ef, struct exfat_node* node);
|
||||
int exfat_mknod(struct exfat* ef, const char* path);
|
||||
int exfat_mkdir(struct exfat* ef, const char* path);
|
||||
int exfat_rename(struct exfat* ef, const char* old_path, const char* new_path);
|
||||
void exfat_utimes(struct exfat_node* node, const struct timespec tv[2]);
|
||||
void exfat_update_atime(struct exfat_node* node);
|
||||
void exfat_update_mtime(struct exfat_node* node);
|
||||
const char* exfat_get_label(struct exfat* ef);
|
||||
int exfat_set_label(struct exfat* ef, const char* label);
|
||||
|
||||
int exfat_mount(struct exfat* ef, const char* spec, const char* options);
|
||||
void exfat_unmount(struct exfat* ef);
|
||||
|
||||
time_t exfat_exfat2unix(le16_t date, le16_t time, uint8_t centisec);
|
||||
void exfat_unix2exfat(time_t unix_time, le16_t* date, le16_t* time,
|
||||
uint8_t* centisec);
|
||||
void exfat_tzset(void);
|
||||
|
||||
#endif /* ifndef EXFAT_H_INCLUDED */
|
163
exfat/libexfat/exfatfs.h
Normal file
163
exfat/libexfat/exfatfs.h
Normal file
@ -0,0 +1,163 @@
|
||||
/*
|
||||
exfatfs.h (29.08.09)
|
||||
Definitions of structures and constants used in exFAT file system.
|
||||
|
||||
Copyright (C) 2010-2012 Andrew Nayenko
|
||||
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#ifndef EXFATFS_H_INCLUDED
|
||||
#define EXFATFS_H_INCLUDED
|
||||
|
||||
#include "byteorder.h"
|
||||
|
||||
typedef uint32_t cluster_t; /* cluster number */
|
||||
|
||||
#define EXFAT_FIRST_DATA_CLUSTER 2
|
||||
#define EXFAT_LAST_DATA_CLUSTER 0xfffffff6
|
||||
|
||||
#define EXFAT_CLUSTER_FREE 0 /* free cluster */
|
||||
#define EXFAT_CLUSTER_BAD 0xfffffff7 /* cluster contains bad sector */
|
||||
#define EXFAT_CLUSTER_END 0xffffffff /* final cluster of file or directory */
|
||||
|
||||
#define EXFAT_STATE_MOUNTED 2
|
||||
|
||||
struct exfat_super_block
|
||||
{
|
||||
uint8_t jump[3]; /* 0x00 jmp and nop instructions */
|
||||
uint8_t oem_name[8]; /* 0x03 "EXFAT " */
|
||||
uint8_t __unused1[53]; /* 0x0B always 0 */
|
||||
le64_t sector_start; /* 0x40 partition first sector */
|
||||
le64_t sector_count; /* 0x48 partition sectors count */
|
||||
le32_t fat_sector_start; /* 0x50 FAT first sector */
|
||||
le32_t fat_sector_count; /* 0x54 FAT sectors count */
|
||||
le32_t cluster_sector_start; /* 0x58 first cluster sector */
|
||||
le32_t cluster_count; /* 0x5C total clusters count */
|
||||
le32_t rootdir_cluster; /* 0x60 first cluster of the root dir */
|
||||
le32_t volume_serial; /* 0x64 volume serial number */
|
||||
struct /* 0x68 FS version */
|
||||
{
|
||||
uint8_t minor;
|
||||
uint8_t major;
|
||||
}
|
||||
version;
|
||||
le16_t volume_state; /* 0x6A volume state flags */
|
||||
uint8_t sector_bits; /* 0x6C sector size as (1 << n) */
|
||||
uint8_t spc_bits; /* 0x6D sectors per cluster as (1 << n) */
|
||||
uint8_t fat_count; /* 0x6E always 1 */
|
||||
uint8_t drive_no; /* 0x6F always 0x80 */
|
||||
uint8_t allocated_percent; /* 0x70 percentage of allocated space */
|
||||
uint8_t __unused2[397]; /* 0x71 always 0 */
|
||||
le16_t boot_signature; /* the value of 0xAA55 */
|
||||
}
|
||||
__attribute__((__packed__));
|
||||
|
||||
#define EXFAT_ENTRY_VALID 0x80
|
||||
#define EXFAT_ENTRY_CONTINUED 0x40
|
||||
|
||||
#define EXFAT_ENTRY_BITMAP (0x01 | EXFAT_ENTRY_VALID)
|
||||
#define EXFAT_ENTRY_UPCASE (0x02 | EXFAT_ENTRY_VALID)
|
||||
#define EXFAT_ENTRY_LABEL (0x03 | EXFAT_ENTRY_VALID)
|
||||
#define EXFAT_ENTRY_FILE (0x05 | EXFAT_ENTRY_VALID)
|
||||
#define EXFAT_ENTRY_FILE_INFO (0x00 | EXFAT_ENTRY_VALID | EXFAT_ENTRY_CONTINUED)
|
||||
#define EXFAT_ENTRY_FILE_NAME (0x01 | EXFAT_ENTRY_VALID | EXFAT_ENTRY_CONTINUED)
|
||||
|
||||
struct exfat_entry /* common container for all entries */
|
||||
{
|
||||
uint8_t type; /* any of EXFAT_ENTRY_xxx */
|
||||
uint8_t data[31];
|
||||
}
|
||||
__attribute__((__packed__));
|
||||
|
||||
#define EXFAT_ENAME_MAX 15
|
||||
|
||||
struct exfat_entry_bitmap /* allocated clusters bitmap */
|
||||
{
|
||||
uint8_t type; /* EXFAT_ENTRY_BITMAP */
|
||||
uint8_t __unknown1[19];
|
||||
le32_t start_cluster;
|
||||
le64_t size; /* in bytes */
|
||||
}
|
||||
__attribute__((__packed__));
|
||||
|
||||
struct exfat_entry_upcase /* upper case translation table */
|
||||
{
|
||||
uint8_t type; /* EXFAT_ENTRY_UPCASE */
|
||||
uint8_t __unknown1[3];
|
||||
le32_t checksum;
|
||||
uint8_t __unknown2[12];
|
||||
le32_t start_cluster;
|
||||
le64_t size; /* in bytes */
|
||||
}
|
||||
__attribute__((__packed__));
|
||||
|
||||
struct exfat_entry_label /* volume label */
|
||||
{
|
||||
uint8_t type; /* EXFAT_ENTRY_LABEL */
|
||||
uint8_t length; /* number of characters */
|
||||
le16_t name[EXFAT_ENAME_MAX]; /* in UTF-16LE */
|
||||
}
|
||||
__attribute__((__packed__));
|
||||
|
||||
#define EXFAT_ATTRIB_RO 0x01
|
||||
#define EXFAT_ATTRIB_HIDDEN 0x02
|
||||
#define EXFAT_ATTRIB_SYSTEM 0x04
|
||||
#define EXFAT_ATTRIB_VOLUME 0x08
|
||||
#define EXFAT_ATTRIB_DIR 0x10
|
||||
#define EXFAT_ATTRIB_ARCH 0x20
|
||||
|
||||
struct exfat_entry_meta1 /* file or directory info (part 1) */
|
||||
{
|
||||
uint8_t type; /* EXFAT_ENTRY_FILE */
|
||||
uint8_t continuations;
|
||||
le16_t checksum;
|
||||
le16_t attrib; /* combination of EXFAT_ATTRIB_xxx */
|
||||
le16_t __unknown1;
|
||||
le16_t crtime, crdate; /* creation date and time */
|
||||
le16_t mtime, mdate; /* latest modification date and time */
|
||||
le16_t atime, adate; /* latest access date and time */
|
||||
uint8_t crtime_cs; /* creation time in cs (centiseconds) */
|
||||
uint8_t mtime_cs; /* latest modification time in cs */
|
||||
uint8_t __unknown2[10];
|
||||
}
|
||||
__attribute__((__packed__));
|
||||
|
||||
#define EXFAT_FLAG_ALWAYS1 (1u << 0)
|
||||
#define EXFAT_FLAG_CONTIGUOUS (1u << 1)
|
||||
|
||||
struct exfat_entry_meta2 /* file or directory info (part 2) */
|
||||
{
|
||||
uint8_t type; /* EXFAT_ENTRY_FILE_INFO */
|
||||
uint8_t flags; /* combination of EXFAT_FLAG_xxx */
|
||||
uint8_t __unknown1;
|
||||
uint8_t name_length;
|
||||
le16_t name_hash;
|
||||
le16_t __unknown2;
|
||||
le64_t real_size; /* in bytes, equals to size */
|
||||
uint8_t __unknown3[4];
|
||||
le32_t start_cluster;
|
||||
le64_t size; /* in bytes, equals to real_size */
|
||||
}
|
||||
__attribute__((__packed__));
|
||||
|
||||
struct exfat_entry_name /* file or directory name */
|
||||
{
|
||||
uint8_t type; /* EXFAT_ENTRY_FILE_NAME */
|
||||
uint8_t __unknown;
|
||||
le16_t name[EXFAT_ENAME_MAX]; /* in UTF-16LE */
|
||||
}
|
||||
__attribute__((__packed__));
|
||||
|
||||
#endif /* ifndef EXFATFS_H_INCLUDED */
|
385
exfat/libexfat/io.c
Normal file
385
exfat/libexfat/io.c
Normal file
@ -0,0 +1,385 @@
|
||||
/*
|
||||
io.c (02.09.09)
|
||||
exFAT file system implementation library.
|
||||
|
||||
Copyright (C) 2010-2012 Andrew Nayenko
|
||||
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#include "exfat.h"
|
||||
#include <inttypes.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/mount.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#ifdef __APPLE__
|
||||
#include <sys/disk.h>
|
||||
#endif
|
||||
#ifdef USE_UBLIO
|
||||
#include <sys/uio.h>
|
||||
#include <ublio.h>
|
||||
#endif
|
||||
|
||||
struct exfat_dev
|
||||
{
|
||||
int fd;
|
||||
enum exfat_mode mode;
|
||||
off64_t size; /* in bytes */
|
||||
#ifdef USE_UBLIO
|
||||
off64_t pos;
|
||||
ublio_filehandle_t ufh;
|
||||
#endif
|
||||
};
|
||||
|
||||
static int open_ro(const char* spec)
|
||||
{
|
||||
return open(spec, O_RDONLY);
|
||||
}
|
||||
|
||||
static int open_rw(const char* spec)
|
||||
{
|
||||
int fd = open(spec, O_RDWR);
|
||||
#ifdef __linux__
|
||||
int ro = 0;
|
||||
|
||||
/*
|
||||
This ioctl is needed because after "blockdev --setro" kernel still
|
||||
allows to open the device in read-write mode but fails writes.
|
||||
*/
|
||||
if (fd != -1 && ioctl(fd, BLKROGET, &ro) == 0 && ro)
|
||||
{
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
return fd;
|
||||
}
|
||||
|
||||
struct exfat_dev* exfat_open(const char* spec, enum exfat_mode mode)
|
||||
{
|
||||
struct exfat_dev* dev;
|
||||
struct stat stbuf;
|
||||
#ifdef USE_UBLIO
|
||||
struct ublio_param up;
|
||||
#endif
|
||||
|
||||
dev = malloc(sizeof(struct exfat_dev));
|
||||
if (dev == NULL)
|
||||
{
|
||||
exfat_error("failed to allocate memory for device structure");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case EXFAT_MODE_RO:
|
||||
dev->fd = open_ro(spec);
|
||||
if (dev->fd == -1)
|
||||
{
|
||||
free(dev);
|
||||
exfat_error("failed to open `%s' in read-only mode", spec);
|
||||
return NULL;
|
||||
}
|
||||
dev->mode = EXFAT_MODE_RO;
|
||||
break;
|
||||
case EXFAT_MODE_RW:
|
||||
dev->fd = open_rw(spec);
|
||||
if (dev->fd == -1)
|
||||
{
|
||||
free(dev);
|
||||
exfat_error("failed to open `%s' in read-write mode", spec);
|
||||
return NULL;
|
||||
}
|
||||
dev->mode = EXFAT_MODE_RW;
|
||||
break;
|
||||
case EXFAT_MODE_ANY:
|
||||
dev->fd = open_rw(spec);
|
||||
if (dev->fd != -1)
|
||||
{
|
||||
dev->mode = EXFAT_MODE_RW;
|
||||
break;
|
||||
}
|
||||
dev->fd = open_ro(spec);
|
||||
if (dev->fd != -1)
|
||||
{
|
||||
dev->mode = EXFAT_MODE_RO;
|
||||
exfat_warn("`%s' is write-protected, mounting read-only", spec);
|
||||
break;
|
||||
}
|
||||
free(dev);
|
||||
exfat_error("failed to open `%s'", spec);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (fstat(dev->fd, &stbuf) != 0)
|
||||
{
|
||||
close(dev->fd);
|
||||
free(dev);
|
||||
exfat_error("failed to fstat `%s'", spec);
|
||||
return NULL;
|
||||
}
|
||||
if (!S_ISBLK(stbuf.st_mode) &&
|
||||
!S_ISCHR(stbuf.st_mode) &&
|
||||
!S_ISREG(stbuf.st_mode))
|
||||
{
|
||||
close(dev->fd);
|
||||
free(dev);
|
||||
exfat_error("`%s' is neither a device, nor a regular file", spec);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef __APPLE__
|
||||
if (!S_ISREG(stbuf.st_mode))
|
||||
{
|
||||
uint32_t block_size = 0;
|
||||
uint64_t blocks = 0;
|
||||
|
||||
if (ioctl(dev->fd, DKIOCGETBLOCKSIZE, &block_size) != 0)
|
||||
{
|
||||
close(dev->fd);
|
||||
free(dev);
|
||||
exfat_error("failed to get block size");
|
||||
return NULL;
|
||||
}
|
||||
if (ioctl(dev->fd, DKIOCGETBLOCKCOUNT, &blocks) != 0)
|
||||
{
|
||||
close(dev->fd);
|
||||
free(dev);
|
||||
exfat_error("failed to get blocks count");
|
||||
return NULL;
|
||||
}
|
||||
dev->size = blocks * block_size;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
/* works for Linux, FreeBSD, Solaris */
|
||||
dev->size = exfat_seek(dev, 0, SEEK_END);
|
||||
if (dev->size <= 0)
|
||||
{
|
||||
close(dev->fd);
|
||||
free(dev);
|
||||
exfat_error("failed to get size of `%s'", spec);
|
||||
return NULL;
|
||||
}
|
||||
if (exfat_seek(dev, 0, SEEK_SET) == -1)
|
||||
{
|
||||
close(dev->fd);
|
||||
free(dev);
|
||||
exfat_error("failed to seek to the beginning of `%s'", spec);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef USE_UBLIO
|
||||
memset(&up, 0, sizeof(struct ublio_param));
|
||||
up.up_blocksize = 256 * 1024;
|
||||
up.up_items = 64;
|
||||
up.up_grace = 32;
|
||||
up.up_priv = &dev->fd;
|
||||
|
||||
dev->pos = 0;
|
||||
dev->ufh = ublio_open(&up);
|
||||
if (dev->ufh == NULL)
|
||||
{
|
||||
close(dev->fd);
|
||||
free(dev);
|
||||
exfat_error("failed to initialize ublio");
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
return dev;
|
||||
}
|
||||
|
||||
int exfat_close(struct exfat_dev* dev)
|
||||
{
|
||||
#ifdef USE_UBLIO
|
||||
if (ublio_close(dev->ufh) != 0)
|
||||
exfat_error("failed to close ublio");
|
||||
#endif
|
||||
if (close(dev->fd) != 0)
|
||||
{
|
||||
free(dev);
|
||||
exfat_error("failed to close device");
|
||||
return 1;
|
||||
}
|
||||
free(dev);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int exfat_fsync(struct exfat_dev* dev)
|
||||
{
|
||||
#ifdef USE_UBLIO
|
||||
if (ublio_fsync(dev->ufh) != 0)
|
||||
#else
|
||||
if (fsync(dev->fd) != 0)
|
||||
#endif
|
||||
{
|
||||
exfat_error("fsync failed");
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
enum exfat_mode exfat_get_mode(const struct exfat_dev* dev)
|
||||
{
|
||||
return dev->mode;
|
||||
}
|
||||
|
||||
off64_t exfat_get_size(const struct exfat_dev* dev)
|
||||
{
|
||||
return dev->size;
|
||||
}
|
||||
|
||||
off64_t exfat_seek(struct exfat_dev* dev, off64_t offset, int whence)
|
||||
{
|
||||
#ifdef USE_UBLIO
|
||||
/* XXX SEEK_CUR will be handled incorrectly */
|
||||
return dev->pos = lseek64(dev->fd, offset, whence);
|
||||
#else
|
||||
return lseek64(dev->fd, offset, whence);
|
||||
#endif
|
||||
}
|
||||
|
||||
ssize_t exfat_read(struct exfat_dev* dev, void* buffer, size_t size)
|
||||
{
|
||||
#ifdef USE_UBLIO
|
||||
ssize_t result = ublio_pread(dev->ufh, buffer, size, dev->pos);
|
||||
if (result >= 0)
|
||||
dev->pos += size;
|
||||
return result;
|
||||
#else
|
||||
return read(dev->fd, buffer, size);
|
||||
#endif
|
||||
}
|
||||
|
||||
ssize_t exfat_write(struct exfat_dev* dev, const void* buffer, size_t size)
|
||||
{
|
||||
#ifdef USE_UBLIO
|
||||
ssize_t result = ublio_pwrite(dev->ufh, buffer, size, dev->pos);
|
||||
if (result >= 0)
|
||||
dev->pos += size;
|
||||
return result;
|
||||
#else
|
||||
return write(dev->fd, buffer, size);
|
||||
#endif
|
||||
}
|
||||
|
||||
void exfat_pread(struct exfat_dev* dev, void* buffer, size_t size,
|
||||
off64_t offset)
|
||||
{
|
||||
#ifdef USE_UBLIO
|
||||
if (ublio_pread(dev->ufh, buffer, size, offset) != size)
|
||||
#else
|
||||
if (pread64(dev->fd, buffer, size, offset) != size)
|
||||
#endif
|
||||
exfat_bug("failed to read %zu bytes from file at %"PRIu64, size,
|
||||
(uint64_t) offset);
|
||||
}
|
||||
|
||||
void exfat_pwrite(struct exfat_dev* dev, const void* buffer, size_t size,
|
||||
off64_t offset)
|
||||
{
|
||||
#ifdef USE_UBLIO
|
||||
if (ublio_pwrite(dev->ufh, buffer, size, offset) != size)
|
||||
#else
|
||||
if (pwrite64(dev->fd, buffer, size, offset) != size)
|
||||
#endif
|
||||
exfat_bug("failed to write %zu bytes to file at %"PRIu64, size,
|
||||
(uint64_t) offset);
|
||||
}
|
||||
|
||||
ssize_t exfat_generic_pread(const struct exfat* ef, struct exfat_node* node,
|
||||
void* buffer, size_t size, off64_t offset)
|
||||
{
|
||||
cluster_t cluster;
|
||||
char* bufp = buffer;
|
||||
off64_t lsize, loffset, remainder;
|
||||
|
||||
if (offset >= node->size)
|
||||
return 0;
|
||||
if (size == 0)
|
||||
return 0;
|
||||
|
||||
cluster = exfat_advance_cluster(ef, node, offset / CLUSTER_SIZE(*ef->sb));
|
||||
if (CLUSTER_INVALID(cluster))
|
||||
{
|
||||
exfat_error("invalid cluster 0x%x while reading", cluster);
|
||||
return -1;
|
||||
}
|
||||
|
||||
loffset = offset % CLUSTER_SIZE(*ef->sb);
|
||||
remainder = MIN(size, node->size - offset);
|
||||
while (remainder > 0)
|
||||
{
|
||||
if (CLUSTER_INVALID(cluster))
|
||||
{
|
||||
exfat_error("invalid cluster 0x%x while reading", cluster);
|
||||
return -1;
|
||||
}
|
||||
lsize = MIN(CLUSTER_SIZE(*ef->sb) - loffset, remainder);
|
||||
exfat_pread(ef->dev, bufp, lsize, exfat_c2o(ef, cluster) + loffset);
|
||||
bufp += lsize;
|
||||
loffset = 0;
|
||||
remainder -= lsize;
|
||||
cluster = exfat_next_cluster(ef, node, cluster);
|
||||
}
|
||||
if (!ef->ro && !ef->noatime)
|
||||
exfat_update_atime(node);
|
||||
return size - remainder;
|
||||
}
|
||||
|
||||
ssize_t exfat_generic_pwrite(struct exfat* ef, struct exfat_node* node,
|
||||
const void* buffer, size_t size, off64_t offset)
|
||||
{
|
||||
cluster_t cluster;
|
||||
const char* bufp = buffer;
|
||||
off64_t lsize, loffset, remainder;
|
||||
printf("node: %s\n", node);
|
||||
if (offset + size > node->size)
|
||||
if (exfat_truncate(ef, node, offset + size) != 0)
|
||||
return -1;
|
||||
if (size == 0)
|
||||
return 0;
|
||||
|
||||
cluster = exfat_advance_cluster(ef, node, offset / CLUSTER_SIZE(*ef->sb));
|
||||
if (CLUSTER_INVALID(cluster))
|
||||
{
|
||||
exfat_error("invalid cluster 0x%x while writing", cluster);
|
||||
return -1;
|
||||
}
|
||||
|
||||
loffset = offset % CLUSTER_SIZE(*ef->sb);
|
||||
remainder = size;
|
||||
while (remainder > 0)
|
||||
{
|
||||
if (CLUSTER_INVALID(cluster))
|
||||
{
|
||||
exfat_error("invalid cluster 0x%x while writing", cluster);
|
||||
return -1;
|
||||
}
|
||||
lsize = MIN(CLUSTER_SIZE(*ef->sb) - loffset, remainder);
|
||||
exfat_pwrite(ef->dev, bufp, lsize, exfat_c2o(ef, cluster) + loffset);
|
||||
bufp += lsize;
|
||||
loffset = 0;
|
||||
remainder -= lsize;
|
||||
cluster = exfat_next_cluster(ef, node, cluster);
|
||||
}
|
||||
exfat_update_mtime(node);
|
||||
return size - remainder;
|
||||
}
|
108
exfat/libexfat/log.c
Normal file
108
exfat/libexfat/log.c
Normal file
@ -0,0 +1,108 @@
|
||||
/*
|
||||
log.c (02.09.09)
|
||||
exFAT file system implementation library.
|
||||
|
||||
Copyright (C) 2010-2012 Andrew Nayenko
|
||||
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#include "exfat.h"
|
||||
#include <stdarg.h>
|
||||
#include <syslog.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int exfat_errors;
|
||||
|
||||
/*
|
||||
* This message means an internal bug in exFAT implementation.
|
||||
*/
|
||||
void exfat_bug(const char* format, ...)
|
||||
{
|
||||
va_list ap, aq;
|
||||
|
||||
va_start(ap, format);
|
||||
va_copy(aq, ap);
|
||||
|
||||
fflush(stdout);
|
||||
fputs("BUG: ", stderr);
|
||||
vfprintf(stderr, format, ap);
|
||||
va_end(ap);
|
||||
fputs(".\n", stderr);
|
||||
|
||||
if (!isatty(STDERR_FILENO))
|
||||
vsyslog(LOG_CRIT, format, aq);
|
||||
va_end(aq);
|
||||
|
||||
abort();
|
||||
}
|
||||
|
||||
/*
|
||||
* This message means an error in exFAT file system.
|
||||
*/
|
||||
void exfat_error(const char* format, ...)
|
||||
{
|
||||
va_list ap, aq;
|
||||
|
||||
exfat_errors++;
|
||||
va_start(ap, format);
|
||||
va_copy(aq, ap);
|
||||
|
||||
fflush(stdout);
|
||||
fputs("ERROR: ", stderr);
|
||||
vfprintf(stderr, format, ap);
|
||||
va_end(ap);
|
||||
fputs(".\n", stderr);
|
||||
|
||||
if (!isatty(STDERR_FILENO))
|
||||
vsyslog(LOG_ERR, format, aq);
|
||||
va_end(aq);
|
||||
}
|
||||
|
||||
/*
|
||||
* This message means that there is something unexpected in exFAT file system
|
||||
* that can be a potential problem.
|
||||
*/
|
||||
void exfat_warn(const char* format, ...)
|
||||
{
|
||||
va_list ap, aq;
|
||||
|
||||
va_start(ap, format);
|
||||
va_copy(aq, ap);
|
||||
|
||||
fflush(stdout);
|
||||
fputs("WARN: ", stderr);
|
||||
vfprintf(stderr, format, ap);
|
||||
va_end(ap);
|
||||
fputs(".\n", stderr);
|
||||
|
||||
if (!isatty(STDERR_FILENO))
|
||||
vsyslog(LOG_WARNING, format, aq);
|
||||
va_end(aq);
|
||||
}
|
||||
|
||||
/*
|
||||
* Just debug message. Disabled by default.
|
||||
*/
|
||||
void exfat_debug(const char* format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
fflush(stdout);
|
||||
fputs("DEBUG: ", stderr);
|
||||
va_start(ap, format);
|
||||
vfprintf(stderr, format, ap);
|
||||
va_end(ap);
|
||||
fputs(".\n", stderr);
|
||||
}
|
223
exfat/libexfat/lookup.c
Normal file
223
exfat/libexfat/lookup.c
Normal file
@ -0,0 +1,223 @@
|
||||
/*
|
||||
lookup.c (02.09.09)
|
||||
exFAT file system implementation library.
|
||||
|
||||
Copyright (C) 2010-2012 Andrew Nayenko
|
||||
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#include "exfat.h"
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
int exfat_opendir(struct exfat* ef, struct exfat_node* dir,
|
||||
struct exfat_iterator* it)
|
||||
{
|
||||
int rc;
|
||||
|
||||
exfat_get_node(dir);
|
||||
it->parent = dir;
|
||||
it->current = NULL;
|
||||
rc = exfat_cache_directory(ef, dir);
|
||||
if (rc != 0)
|
||||
exfat_put_node(ef, dir);
|
||||
return rc;
|
||||
}
|
||||
|
||||
void exfat_closedir(struct exfat* ef, struct exfat_iterator* it)
|
||||
{
|
||||
exfat_put_node(ef, it->parent);
|
||||
it->parent = NULL;
|
||||
it->current = NULL;
|
||||
}
|
||||
|
||||
struct exfat_node* exfat_readdir(struct exfat* ef, struct exfat_iterator* it)
|
||||
{
|
||||
if (it->current == NULL)
|
||||
it->current = it->parent->child;
|
||||
else
|
||||
it->current = it->current->next;
|
||||
|
||||
if (it->current != NULL)
|
||||
return exfat_get_node(it->current);
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int compare_char(struct exfat* ef, uint16_t a, uint16_t b)
|
||||
{
|
||||
if (a >= ef->upcase_chars || b >= ef->upcase_chars)
|
||||
return (int) a - (int) b;
|
||||
|
||||
return (int) le16_to_cpu(ef->upcase[a]) - (int) le16_to_cpu(ef->upcase[b]);
|
||||
}
|
||||
|
||||
static int compare_name(struct exfat* ef, const le16_t* a, const le16_t* b)
|
||||
{
|
||||
while (le16_to_cpu(*a) && le16_to_cpu(*b))
|
||||
{
|
||||
int rc = compare_char(ef, le16_to_cpu(*a), le16_to_cpu(*b));
|
||||
if (rc != 0)
|
||||
return rc;
|
||||
a++;
|
||||
b++;
|
||||
}
|
||||
return compare_char(ef, le16_to_cpu(*a), le16_to_cpu(*b));
|
||||
}
|
||||
|
||||
static int lookup_name(struct exfat* ef, struct exfat_node* parent,
|
||||
struct exfat_node** node, const char* name, size_t n)
|
||||
{
|
||||
struct exfat_iterator it;
|
||||
le16_t buffer[EXFAT_NAME_MAX + 1];
|
||||
int rc;
|
||||
|
||||
*node = NULL;
|
||||
|
||||
rc = utf8_to_utf16(buffer, name, EXFAT_NAME_MAX, n);
|
||||
if (rc != 0)
|
||||
return rc;
|
||||
|
||||
rc = exfat_opendir(ef, parent, &it);
|
||||
if (rc != 0)
|
||||
return rc;
|
||||
while ((*node = exfat_readdir(ef, &it)))
|
||||
{
|
||||
if (compare_name(ef, buffer, (*node)->name) == 0)
|
||||
{
|
||||
exfat_closedir(ef, &it);
|
||||
return 0;
|
||||
}
|
||||
exfat_put_node(ef, *node);
|
||||
}
|
||||
exfat_closedir(ef, &it);
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
static size_t get_comp(const char* path, const char** comp)
|
||||
{
|
||||
const char* end;
|
||||
|
||||
*comp = path + strspn(path, "/"); /* skip leading slashes */
|
||||
end = strchr(*comp, '/');
|
||||
if (end == NULL)
|
||||
return strlen(*comp);
|
||||
else
|
||||
return end - *comp;
|
||||
}
|
||||
|
||||
int exfat_lookup(struct exfat* ef, struct exfat_node** node,
|
||||
const char* path)
|
||||
{
|
||||
struct exfat_node* parent;
|
||||
const char* p;
|
||||
size_t n;
|
||||
int rc;
|
||||
|
||||
/* start from the root directory */
|
||||
parent = *node = exfat_get_node(ef->root);
|
||||
for (p = path; (n = get_comp(p, &p)); p += n)
|
||||
{
|
||||
if (n == 1 && *p == '.') /* skip "." component */
|
||||
continue;
|
||||
rc = lookup_name(ef, parent, node, p, n);
|
||||
if (rc != 0)
|
||||
{
|
||||
exfat_put_node(ef, parent);
|
||||
return rc;
|
||||
}
|
||||
exfat_put_node(ef, parent);
|
||||
parent = *node;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool is_last_comp(const char* comp, size_t length)
|
||||
{
|
||||
const char* p = comp + length;
|
||||
|
||||
return get_comp(p, &p) == 0;
|
||||
}
|
||||
|
||||
static bool is_allowed(const char* comp, size_t length)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < length; i++)
|
||||
switch (comp[i])
|
||||
{
|
||||
case 0x01 ... 0x1f:
|
||||
case '/':
|
||||
case '\\':
|
||||
case ':':
|
||||
case '*':
|
||||
case '?':
|
||||
case '"':
|
||||
case '<':
|
||||
case '>':
|
||||
case '|':
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int exfat_split(struct exfat* ef, struct exfat_node** parent,
|
||||
struct exfat_node** node, le16_t* name, const char* path)
|
||||
{
|
||||
const char* p;
|
||||
size_t n;
|
||||
int rc;
|
||||
|
||||
memset(name, 0, (EXFAT_NAME_MAX + 1) * sizeof(le16_t));
|
||||
*parent = *node = exfat_get_node(ef->root);
|
||||
for (p = path; (n = get_comp(p, &p)); p += n)
|
||||
{
|
||||
if (n == 1 && *p == '.')
|
||||
continue;
|
||||
if (is_last_comp(p, n))
|
||||
{
|
||||
if (!is_allowed(p, n))
|
||||
{
|
||||
/* contains characters that are not allowed */
|
||||
exfat_put_node(ef, *parent);
|
||||
return -ENOENT;
|
||||
}
|
||||
rc = utf8_to_utf16(name, p, EXFAT_NAME_MAX, n);
|
||||
if (rc != 0)
|
||||
{
|
||||
exfat_put_node(ef, *parent);
|
||||
return rc;
|
||||
}
|
||||
|
||||
rc = lookup_name(ef, *parent, node, p, n);
|
||||
if (rc != 0 && rc != -ENOENT)
|
||||
{
|
||||
exfat_put_node(ef, *parent);
|
||||
return rc;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
rc = lookup_name(ef, *parent, node, p, n);
|
||||
if (rc != 0)
|
||||
{
|
||||
exfat_put_node(ef, *parent);
|
||||
return rc;
|
||||
}
|
||||
exfat_put_node(ef, *parent);
|
||||
*parent = *node;
|
||||
}
|
||||
exfat_bug("impossible");
|
||||
}
|
314
exfat/libexfat/mount.c
Normal file
314
exfat/libexfat/mount.c
Normal file
@ -0,0 +1,314 @@
|
||||
/*
|
||||
mount.c (22.10.09)
|
||||
exFAT file system implementation library.
|
||||
|
||||
Copyright (C) 2010-2012 Andrew Nayenko
|
||||
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#include "exfat.h"
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
static uint64_t rootdir_size(const struct exfat* ef)
|
||||
{
|
||||
uint64_t clusters = 0;
|
||||
cluster_t rootdir_cluster = le32_to_cpu(ef->sb->rootdir_cluster);
|
||||
|
||||
while (!CLUSTER_INVALID(rootdir_cluster))
|
||||
{
|
||||
clusters++;
|
||||
/* root directory cannot be contiguous because there is no flag
|
||||
to indicate this */
|
||||
rootdir_cluster = exfat_next_cluster(ef, ef->root, rootdir_cluster);
|
||||
}
|
||||
return clusters * CLUSTER_SIZE(*ef->sb);
|
||||
}
|
||||
|
||||
static const char* get_option(const char* options, const char* option_name)
|
||||
{
|
||||
const char* p;
|
||||
size_t length = strlen(option_name);
|
||||
|
||||
for (p = strstr(options, option_name); p; p = strstr(p + 1, option_name))
|
||||
if ((p == options || p[-1] == ',') && p[length] == '=')
|
||||
return p + length + 1;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int get_int_option(const char* options, const char* option_name,
|
||||
int base, int default_value)
|
||||
{
|
||||
const char* p = get_option(options, option_name);
|
||||
|
||||
if (p == NULL)
|
||||
return default_value;
|
||||
return strtol(p, NULL, base);
|
||||
}
|
||||
|
||||
static bool match_option(const char* options, const char* option_name)
|
||||
{
|
||||
const char* p;
|
||||
size_t length = strlen(option_name);
|
||||
|
||||
for (p = strstr(options, option_name); p; p = strstr(p + 1, option_name))
|
||||
if ((p == options || p[-1] == ',') &&
|
||||
(p[length] == ',' || p[length] == '\0'))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
static void parse_options(struct exfat* ef, const char* options)
|
||||
{
|
||||
int sys_umask = umask(0);
|
||||
int opt_umask;
|
||||
|
||||
umask(sys_umask); /* restore umask */
|
||||
opt_umask = get_int_option(options, "umask", 8, sys_umask);
|
||||
ef->dmask = get_int_option(options, "dmask", 8, opt_umask) & 0777;
|
||||
ef->fmask = get_int_option(options, "fmask", 8, opt_umask) & 0777;
|
||||
|
||||
ef->uid = get_int_option(options, "uid", 10, geteuid());
|
||||
ef->gid = get_int_option(options, "gid", 10, getegid());
|
||||
|
||||
ef->noatime = match_option(options, "noatime");
|
||||
}
|
||||
|
||||
static int verify_vbr_checksum(struct exfat_dev* dev, void* sector,
|
||||
off64_t sector_size)
|
||||
{
|
||||
uint32_t vbr_checksum;
|
||||
int i;
|
||||
|
||||
exfat_pread(dev, sector, sector_size, 0);
|
||||
vbr_checksum = exfat_vbr_start_checksum(sector, sector_size);
|
||||
for (i = 1; i < 11; i++)
|
||||
{
|
||||
exfat_pread(dev, sector, sector_size, i * sector_size);
|
||||
vbr_checksum = exfat_vbr_add_checksum(sector, sector_size,
|
||||
vbr_checksum);
|
||||
}
|
||||
exfat_pread(dev, sector, sector_size, i * sector_size);
|
||||
for (i = 0; i < sector_size / sizeof(vbr_checksum); i++)
|
||||
if (le32_to_cpu(((const le32_t*) sector)[i]) != vbr_checksum)
|
||||
{
|
||||
exfat_error("invalid VBR checksum 0x%x (expected 0x%x)",
|
||||
le32_to_cpu(((const le32_t*) sector)[i]), vbr_checksum);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int commit_super_block(const struct exfat* ef)
|
||||
{
|
||||
exfat_pwrite(ef->dev, ef->sb, sizeof(struct exfat_super_block), 0);
|
||||
return exfat_fsync(ef->dev);
|
||||
}
|
||||
|
||||
static int prepare_super_block(const struct exfat* ef)
|
||||
{
|
||||
if (le16_to_cpu(ef->sb->volume_state) & EXFAT_STATE_MOUNTED)
|
||||
exfat_warn("volume was not unmounted cleanly");
|
||||
|
||||
if (ef->ro)
|
||||
return 0;
|
||||
|
||||
ef->sb->volume_state = cpu_to_le16(
|
||||
le16_to_cpu(ef->sb->volume_state) | EXFAT_STATE_MOUNTED);
|
||||
return commit_super_block(ef);
|
||||
}
|
||||
|
||||
int exfat_mount(struct exfat* ef, const char* spec, const char* options)
|
||||
{
|
||||
int rc;
|
||||
enum exfat_mode mode;
|
||||
|
||||
exfat_tzset();
|
||||
memset(ef, 0, sizeof(struct exfat));
|
||||
|
||||
parse_options(ef, options);
|
||||
|
||||
if (match_option(options, "ro"))
|
||||
mode = EXFAT_MODE_RO;
|
||||
else if (match_option(options, "ro_fallback"))
|
||||
mode = EXFAT_MODE_ANY;
|
||||
else
|
||||
mode = EXFAT_MODE_RW;
|
||||
ef->dev = exfat_open(spec, mode);
|
||||
if (ef->dev == NULL)
|
||||
return -EIO;
|
||||
if (exfat_get_mode(ef->dev) == EXFAT_MODE_RO)
|
||||
{
|
||||
if (mode == EXFAT_MODE_ANY)
|
||||
ef->ro = -1;
|
||||
else
|
||||
ef->ro = 1;
|
||||
}
|
||||
|
||||
ef->sb = malloc(sizeof(struct exfat_super_block));
|
||||
if (ef->sb == NULL)
|
||||
{
|
||||
exfat_close(ef->dev);
|
||||
exfat_error("failed to allocate memory for the super block");
|
||||
return -ENOMEM;
|
||||
}
|
||||
memset(ef->sb, 0, sizeof(struct exfat_super_block));
|
||||
|
||||
exfat_pread(ef->dev, ef->sb, sizeof(struct exfat_super_block), 0);
|
||||
if (memcmp(ef->sb->oem_name, "EXFAT ", 8) != 0)
|
||||
{
|
||||
exfat_close(ef->dev);
|
||||
free(ef->sb);
|
||||
exfat_error("exFAT file system is not found");
|
||||
return -EIO;
|
||||
}
|
||||
if (ef->sb->version.major != 1 || ef->sb->version.minor != 0)
|
||||
{
|
||||
exfat_close(ef->dev);
|
||||
exfat_error("unsupported exFAT version: %hhu.%hhu",
|
||||
ef->sb->version.major, ef->sb->version.minor);
|
||||
free(ef->sb);
|
||||
return -EIO;
|
||||
}
|
||||
if (ef->sb->fat_count != 1)
|
||||
{
|
||||
exfat_close(ef->dev);
|
||||
free(ef->sb);
|
||||
exfat_error("unsupported FAT count: %hhu", ef->sb->fat_count);
|
||||
return -EIO;
|
||||
}
|
||||
/* officially exFAT supports cluster size up to 32 MB */
|
||||
if ((int) ef->sb->sector_bits + (int) ef->sb->spc_bits > 25)
|
||||
{
|
||||
exfat_close(ef->dev);
|
||||
free(ef->sb);
|
||||
exfat_error("too big cluster size: 2^%d",
|
||||
(int) ef->sb->sector_bits + (int) ef->sb->spc_bits);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
ef->zero_cluster = malloc(CLUSTER_SIZE(*ef->sb));
|
||||
if (ef->zero_cluster == NULL)
|
||||
{
|
||||
exfat_close(ef->dev);
|
||||
free(ef->sb);
|
||||
exfat_error("failed to allocate zero sector");
|
||||
return -ENOMEM;
|
||||
}
|
||||
/* use zero_cluster as a temporary buffer for VBR checksum verification */
|
||||
if (verify_vbr_checksum(ef->dev, ef->zero_cluster,
|
||||
SECTOR_SIZE(*ef->sb)) != 0)
|
||||
{
|
||||
free(ef->zero_cluster);
|
||||
exfat_close(ef->dev);
|
||||
free(ef->sb);
|
||||
return -EIO;
|
||||
}
|
||||
memset(ef->zero_cluster, 0, CLUSTER_SIZE(*ef->sb));
|
||||
|
||||
ef->root = malloc(sizeof(struct exfat_node));
|
||||
if (ef->root == NULL)
|
||||
{
|
||||
free(ef->zero_cluster);
|
||||
exfat_close(ef->dev);
|
||||
free(ef->sb);
|
||||
exfat_error("failed to allocate root node");
|
||||
return -ENOMEM;
|
||||
}
|
||||
memset(ef->root, 0, sizeof(struct exfat_node));
|
||||
ef->root->flags = EXFAT_ATTRIB_DIR;
|
||||
ef->root->start_cluster = le32_to_cpu(ef->sb->rootdir_cluster);
|
||||
ef->root->fptr_cluster = ef->root->start_cluster;
|
||||
ef->root->name[0] = cpu_to_le16('\0');
|
||||
ef->root->size = rootdir_size(ef);
|
||||
/* exFAT does not have time attributes for the root directory */
|
||||
ef->root->mtime = 0;
|
||||
ef->root->atime = 0;
|
||||
/* always keep at least 1 reference to the root node */
|
||||
exfat_get_node(ef->root);
|
||||
|
||||
rc = exfat_cache_directory(ef, ef->root);
|
||||
if (rc != 0)
|
||||
goto error;
|
||||
if (ef->upcase == NULL)
|
||||
{
|
||||
exfat_error("upcase table is not found");
|
||||
goto error;
|
||||
}
|
||||
if (ef->cmap.chunk == NULL)
|
||||
{
|
||||
exfat_error("clusters bitmap is not found");
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (prepare_super_block(ef) != 0)
|
||||
goto error;
|
||||
|
||||
return 0;
|
||||
|
||||
error:
|
||||
exfat_put_node(ef, ef->root);
|
||||
exfat_reset_cache(ef);
|
||||
free(ef->root);
|
||||
free(ef->zero_cluster);
|
||||
exfat_close(ef->dev);
|
||||
free(ef->sb);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
static void finalize_super_block(struct exfat* ef)
|
||||
{
|
||||
if (ef->ro)
|
||||
return;
|
||||
|
||||
ef->sb->volume_state = cpu_to_le16(
|
||||
le16_to_cpu(ef->sb->volume_state) & ~EXFAT_STATE_MOUNTED);
|
||||
|
||||
/* Some implementations set the percentage of allocated space to 0xff
|
||||
on FS creation and never update it. In this case leave it as is. */
|
||||
if (ef->sb->allocated_percent != 0xff)
|
||||
{
|
||||
uint32_t free, total;
|
||||
|
||||
free = exfat_count_free_clusters(ef);
|
||||
total = le32_to_cpu(ef->sb->cluster_count);
|
||||
ef->sb->allocated_percent = ((total - free) * 100 + total / 2) / total;
|
||||
}
|
||||
|
||||
commit_super_block(ef);
|
||||
}
|
||||
|
||||
void exfat_unmount(struct exfat* ef)
|
||||
{
|
||||
exfat_put_node(ef, ef->root);
|
||||
exfat_reset_cache(ef);
|
||||
free(ef->root);
|
||||
ef->root = NULL;
|
||||
finalize_super_block(ef);
|
||||
exfat_close(ef->dev); /* close descriptor immediately after fsync */
|
||||
ef->dev = NULL;
|
||||
free(ef->zero_cluster);
|
||||
ef->zero_cluster = NULL;
|
||||
free(ef->cmap.chunk);
|
||||
ef->cmap.chunk = NULL;
|
||||
free(ef->sb);
|
||||
ef->sb = NULL;
|
||||
free(ef->upcase);
|
||||
ef->upcase = NULL;
|
||||
ef->upcase_chars = 0;
|
||||
}
|
1041
exfat/libexfat/node.c
Normal file
1041
exfat/libexfat/node.c
Normal file
File diff suppressed because it is too large
Load Diff
156
exfat/libexfat/time.c
Normal file
156
exfat/libexfat/time.c
Normal file
@ -0,0 +1,156 @@
|
||||
/*
|
||||
time.c (03.02.12)
|
||||
exFAT file system implementation library.
|
||||
|
||||
Copyright (C) 2010-2012 Andrew Nayenko
|
||||
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#include "exfat.h"
|
||||
|
||||
/* timezone offset from UTC in seconds; positive for western timezones,
|
||||
negative for eastern ones */
|
||||
static long exfat_timezone;
|
||||
|
||||
#define SEC_IN_MIN 60ll
|
||||
#define SEC_IN_HOUR (60 * SEC_IN_MIN)
|
||||
#define SEC_IN_DAY (24 * SEC_IN_HOUR)
|
||||
#define SEC_IN_YEAR (365 * SEC_IN_DAY) /* not leap year */
|
||||
/* Unix epoch started at 0:00:00 UTC 1 January 1970 */
|
||||
#define UNIX_EPOCH_YEAR 1970
|
||||
/* exFAT epoch started at 0:00:00 UTC 1 January 1980 */
|
||||
#define EXFAT_EPOCH_YEAR 1980
|
||||
/* number of years from Unix epoch to exFAT epoch */
|
||||
#define EPOCH_DIFF_YEAR (EXFAT_EPOCH_YEAR - UNIX_EPOCH_YEAR)
|
||||
/* number of days from Unix epoch to exFAT epoch (considering leap days) */
|
||||
#define EPOCH_DIFF_DAYS (EPOCH_DIFF_YEAR * 365 + EPOCH_DIFF_YEAR / 4)
|
||||
/* number of seconds from Unix epoch to exFAT epoch (considering leap days) */
|
||||
#define EPOCH_DIFF_SEC (EPOCH_DIFF_DAYS * SEC_IN_DAY)
|
||||
/* number of leap years passed from exFAT epoch to the specified year
|
||||
(excluding the specified year itself) */
|
||||
#define LEAP_YEARS(year) ((EXFAT_EPOCH_YEAR + (year) - 1) / 4 \
|
||||
- (EXFAT_EPOCH_YEAR - 1) / 4)
|
||||
/* checks whether the specified year is leap */
|
||||
#define IS_LEAP_YEAR(year) ((EXFAT_EPOCH_YEAR + (year)) % 4 == 0)
|
||||
|
||||
static const time_t days_in_year[] =
|
||||
{
|
||||
/* Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec */
|
||||
0, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334
|
||||
};
|
||||
|
||||
time_t exfat_exfat2unix(le16_t date, le16_t time, uint8_t centisec)
|
||||
{
|
||||
time_t unix_time = EPOCH_DIFF_SEC;
|
||||
uint16_t ndate = le16_to_cpu(date);
|
||||
uint16_t ntime = le16_to_cpu(time);
|
||||
|
||||
uint16_t day = ndate & 0x1f; /* 5 bits, 1-31 */
|
||||
uint16_t month = ndate >> 5 & 0xf; /* 4 bits, 1-12 */
|
||||
uint16_t year = ndate >> 9; /* 7 bits, 1-127 (+1980) */
|
||||
|
||||
uint16_t twosec = ntime & 0x1f; /* 5 bits, 0-29 (2 sec granularity) */
|
||||
uint16_t min = ntime >> 5 & 0x3f; /* 6 bits, 0-59 */
|
||||
uint16_t hour = ntime >> 11; /* 5 bits, 0-23 */
|
||||
|
||||
if (day == 0 || month == 0 || month > 12)
|
||||
{
|
||||
exfat_error("bad date %u-%02hu-%02hu",
|
||||
year + EXFAT_EPOCH_YEAR, month, day);
|
||||
return 0;
|
||||
}
|
||||
if (hour > 23 || min > 59 || twosec > 29)
|
||||
{
|
||||
exfat_error("bad time %hu:%02hu:%02u",
|
||||
hour, min, twosec * 2);
|
||||
return 0;
|
||||
}
|
||||
if (centisec > 199)
|
||||
{
|
||||
exfat_error("bad centiseconds count %hhu", centisec);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* every 4th year between 1904 and 2096 is leap */
|
||||
unix_time += year * SEC_IN_YEAR + LEAP_YEARS(year) * SEC_IN_DAY;
|
||||
unix_time += days_in_year[month] * SEC_IN_DAY;
|
||||
/* if it's leap year and February has passed we should add 1 day */
|
||||
if ((EXFAT_EPOCH_YEAR + year) % 4 == 0 && month > 2)
|
||||
unix_time += SEC_IN_DAY;
|
||||
unix_time += (day - 1) * SEC_IN_DAY;
|
||||
|
||||
unix_time += hour * SEC_IN_HOUR;
|
||||
unix_time += min * SEC_IN_MIN;
|
||||
/* exFAT represents time with 2 sec granularity */
|
||||
unix_time += twosec * 2;
|
||||
unix_time += centisec / 100;
|
||||
|
||||
/* exFAT stores timestamps in local time, so we correct it to UTC */
|
||||
unix_time += exfat_timezone;
|
||||
|
||||
return unix_time;
|
||||
}
|
||||
|
||||
void exfat_unix2exfat(time_t unix_time, le16_t* date, le16_t* time,
|
||||
uint8_t* centisec)
|
||||
{
|
||||
time_t shift = EPOCH_DIFF_SEC + exfat_timezone;
|
||||
uint16_t day, month, year;
|
||||
uint16_t twosec, min, hour;
|
||||
int days;
|
||||
int i;
|
||||
|
||||
/* time before exFAT epoch cannot be represented */
|
||||
if (unix_time < shift)
|
||||
unix_time = shift;
|
||||
|
||||
unix_time -= shift;
|
||||
|
||||
days = unix_time / SEC_IN_DAY;
|
||||
year = (4 * days) / (4 * 365 + 1);
|
||||
days -= year * 365 + LEAP_YEARS(year);
|
||||
month = 0;
|
||||
for (i = 1; i <= 12; i++)
|
||||
{
|
||||
int leap_day = (IS_LEAP_YEAR(year) && i == 2);
|
||||
int leap_sub = (IS_LEAP_YEAR(year) && i >= 3);
|
||||
|
||||
if (i == 12 || days - leap_sub < days_in_year[i + 1] + leap_day)
|
||||
{
|
||||
month = i;
|
||||
days -= days_in_year[i] + leap_sub;
|
||||
break;
|
||||
}
|
||||
}
|
||||
day = days + 1;
|
||||
|
||||
hour = (unix_time % SEC_IN_DAY) / SEC_IN_HOUR;
|
||||
min = (unix_time % SEC_IN_HOUR) / SEC_IN_MIN;
|
||||
twosec = (unix_time % SEC_IN_MIN) / 2;
|
||||
|
||||
*date = cpu_to_le16(day | (month << 5) | (year << 9));
|
||||
*time = cpu_to_le16(twosec | (min << 5) | (hour << 11));
|
||||
if (centisec)
|
||||
*centisec = (unix_time % 2) * 100;
|
||||
}
|
||||
|
||||
void exfat_tzset(void)
|
||||
{
|
||||
time_t now;
|
||||
|
||||
tzset();
|
||||
now = time(NULL);
|
||||
exfat_timezone = mktime(gmtime(&now)) - now;
|
||||
}
|
229
exfat/libexfat/utf.c
Normal file
229
exfat/libexfat/utf.c
Normal file
@ -0,0 +1,229 @@
|
||||
/*
|
||||
utf.c (13.09.09)
|
||||
exFAT file system implementation library.
|
||||
|
||||
Copyright (C) 2010-2012 Andrew Nayenko
|
||||
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#include "exfat.h"
|
||||
#include <errno.h>
|
||||
|
||||
static char* wchar_to_utf8(char* output, wchar_t wc, size_t outsize)
|
||||
{
|
||||
if (wc <= 0x7f)
|
||||
{
|
||||
if (outsize < 1)
|
||||
return NULL;
|
||||
*output++ = (char) wc;
|
||||
}
|
||||
else if (wc <= 0x7ff)
|
||||
{
|
||||
if (outsize < 2)
|
||||
return NULL;
|
||||
*output++ = 0xc0 | (wc >> 6);
|
||||
*output++ = 0x80 | (wc & 0x3f);
|
||||
}
|
||||
else if (wc <= 0xffff)
|
||||
{
|
||||
if (outsize < 3)
|
||||
return NULL;
|
||||
*output++ = 0xe0 | (wc >> 12);
|
||||
*output++ = 0x80 | ((wc >> 6) & 0x3f);
|
||||
*output++ = 0x80 | (wc & 0x3f);
|
||||
}
|
||||
else if (wc <= 0x1fffff)
|
||||
{
|
||||
if (outsize < 4)
|
||||
return NULL;
|
||||
*output++ = 0xf0 | (wc >> 18);
|
||||
*output++ = 0x80 | ((wc >> 12) & 0x3f);
|
||||
*output++ = 0x80 | ((wc >> 6) & 0x3f);
|
||||
*output++ = 0x80 | (wc & 0x3f);
|
||||
}
|
||||
else if (wc <= 0x3ffffff)
|
||||
{
|
||||
if (outsize < 5)
|
||||
return NULL;
|
||||
*output++ = 0xf8 | (wc >> 24);
|
||||
*output++ = 0x80 | ((wc >> 18) & 0x3f);
|
||||
*output++ = 0x80 | ((wc >> 12) & 0x3f);
|
||||
*output++ = 0x80 | ((wc >> 6) & 0x3f);
|
||||
*output++ = 0x80 | (wc & 0x3f);
|
||||
}
|
||||
else if (wc <= 0x7fffffff)
|
||||
{
|
||||
if (outsize < 6)
|
||||
return NULL;
|
||||
*output++ = 0xfc | (wc >> 30);
|
||||
*output++ = 0x80 | ((wc >> 24) & 0x3f);
|
||||
*output++ = 0x80 | ((wc >> 18) & 0x3f);
|
||||
*output++ = 0x80 | ((wc >> 12) & 0x3f);
|
||||
*output++ = 0x80 | ((wc >> 6) & 0x3f);
|
||||
*output++ = 0x80 | (wc & 0x3f);
|
||||
}
|
||||
else
|
||||
return NULL;
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
static const le16_t* utf16_to_wchar(const le16_t* input, wchar_t* wc,
|
||||
size_t insize)
|
||||
{
|
||||
if ((le16_to_cpu(input[0]) & 0xfc00) == 0xd800)
|
||||
{
|
||||
if (insize < 2 || (le16_to_cpu(input[1]) & 0xfc00) != 0xdc00)
|
||||
return NULL;
|
||||
*wc = ((wchar_t) (le16_to_cpu(input[0]) & 0x3ff) << 10);
|
||||
*wc |= (le16_to_cpu(input[1]) & 0x3ff);
|
||||
*wc += 0x10000;
|
||||
return input + 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
*wc = le16_to_cpu(*input);
|
||||
return input + 1;
|
||||
}
|
||||
}
|
||||
|
||||
int utf16_to_utf8(char* output, const le16_t* input, size_t outsize,
|
||||
size_t insize)
|
||||
{
|
||||
const le16_t* inp = input;
|
||||
char* outp = output;
|
||||
wchar_t wc;
|
||||
|
||||
while (inp - input < insize && le16_to_cpu(*inp))
|
||||
{
|
||||
inp = utf16_to_wchar(inp, &wc, insize - (inp - input));
|
||||
if (inp == NULL)
|
||||
{
|
||||
exfat_error("illegal UTF-16 sequence");
|
||||
return -EILSEQ;
|
||||
}
|
||||
outp = wchar_to_utf8(outp, wc, outsize - (outp - output));
|
||||
if (outp == NULL)
|
||||
{
|
||||
exfat_error("name is too long");
|
||||
return -ENAMETOOLONG;
|
||||
}
|
||||
}
|
||||
*outp = '\0';
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const char* utf8_to_wchar(const char* input, wchar_t* wc,
|
||||
size_t insize)
|
||||
{
|
||||
if ((input[0] & 0x80) == 0 && insize >= 1)
|
||||
{
|
||||
*wc = (wchar_t) input[0];
|
||||
return input + 1;
|
||||
}
|
||||
if ((input[0] & 0xe0) == 0xc0 && insize >= 2)
|
||||
{
|
||||
*wc = (((wchar_t) input[0] & 0x1f) << 6) |
|
||||
((wchar_t) input[1] & 0x3f);
|
||||
return input + 2;
|
||||
}
|
||||
if ((input[0] & 0xf0) == 0xe0 && insize >= 3)
|
||||
{
|
||||
*wc = (((wchar_t) input[0] & 0x0f) << 12) |
|
||||
(((wchar_t) input[1] & 0x3f) << 6) |
|
||||
((wchar_t) input[2] & 0x3f);
|
||||
return input + 3;
|
||||
}
|
||||
if ((input[0] & 0xf8) == 0xf0 && insize >= 4)
|
||||
{
|
||||
*wc = (((wchar_t) input[0] & 0x07) << 18) |
|
||||
(((wchar_t) input[1] & 0x3f) << 12) |
|
||||
(((wchar_t) input[2] & 0x3f) << 6) |
|
||||
((wchar_t) input[3] & 0x3f);
|
||||
return input + 4;
|
||||
}
|
||||
if ((input[0] & 0xfc) == 0xf8 && insize >= 5)
|
||||
{
|
||||
*wc = (((wchar_t) input[0] & 0x03) << 24) |
|
||||
(((wchar_t) input[1] & 0x3f) << 18) |
|
||||
(((wchar_t) input[2] & 0x3f) << 12) |
|
||||
(((wchar_t) input[3] & 0x3f) << 6) |
|
||||
((wchar_t) input[4] & 0x3f);
|
||||
return input + 5;
|
||||
}
|
||||
if ((input[0] & 0xfe) == 0xfc && insize >= 6)
|
||||
{
|
||||
*wc = (((wchar_t) input[0] & 0x01) << 30) |
|
||||
(((wchar_t) input[1] & 0x3f) << 24) |
|
||||
(((wchar_t) input[2] & 0x3f) << 18) |
|
||||
(((wchar_t) input[3] & 0x3f) << 12) |
|
||||
(((wchar_t) input[4] & 0x3f) << 6) |
|
||||
((wchar_t) input[5] & 0x3f);
|
||||
return input + 6;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static le16_t* wchar_to_utf16(le16_t* output, wchar_t wc, size_t outsize)
|
||||
{
|
||||
if (wc <= 0xffff) /* if character is from BMP */
|
||||
{
|
||||
if (outsize == 0)
|
||||
return NULL;
|
||||
output[0] = cpu_to_le16(wc);
|
||||
return output + 1;
|
||||
}
|
||||
if (outsize < 2)
|
||||
return NULL;
|
||||
wc -= 0x10000;
|
||||
output[0] = cpu_to_le16(0xd800 | ((wc >> 10) & 0x3ff));
|
||||
output[1] = cpu_to_le16(0xdc00 | (wc & 0x3ff));
|
||||
return output + 2;
|
||||
}
|
||||
|
||||
int utf8_to_utf16(le16_t* output, const char* input, size_t outsize,
|
||||
size_t insize)
|
||||
{
|
||||
const char* inp = input;
|
||||
le16_t* outp = output;
|
||||
wchar_t wc;
|
||||
|
||||
while (inp - input < insize && *inp)
|
||||
{
|
||||
inp = utf8_to_wchar(inp, &wc, insize - (inp - input));
|
||||
if (inp == NULL)
|
||||
{
|
||||
exfat_error("illegal UTF-8 sequence");
|
||||
return -EILSEQ;
|
||||
}
|
||||
outp = wchar_to_utf16(outp, wc, outsize - (outp - output));
|
||||
if (outp == NULL)
|
||||
{
|
||||
exfat_error("name is too long");
|
||||
return -ENAMETOOLONG;
|
||||
}
|
||||
}
|
||||
*outp = cpu_to_le16(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t utf16_length(const le16_t* str)
|
||||
{
|
||||
size_t i = 0;
|
||||
|
||||
while (le16_to_cpu(str[i]))
|
||||
i++;
|
||||
return i;
|
||||
}
|
176
exfat/libexfat/utils.c
Normal file
176
exfat/libexfat/utils.c
Normal file
@ -0,0 +1,176 @@
|
||||
/*
|
||||
utils.c (04.09.09)
|
||||
exFAT file system implementation library.
|
||||
|
||||
Copyright (C) 2010-2012 Andrew Nayenko
|
||||
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#include "exfat.h"
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
void exfat_stat(const struct exfat* ef, const struct exfat_node* node,
|
||||
struct stat* stbuf)
|
||||
{
|
||||
memset(stbuf, 0, sizeof(struct stat));
|
||||
if (node->flags & EXFAT_ATTRIB_DIR)
|
||||
stbuf->st_mode = S_IFDIR | (0777 & ~ef->dmask);
|
||||
else
|
||||
stbuf->st_mode = S_IFREG | (0777 & ~ef->fmask);
|
||||
stbuf->st_nlink = 1;
|
||||
stbuf->st_uid = ef->uid;
|
||||
stbuf->st_gid = ef->gid;
|
||||
stbuf->st_size = node->size;
|
||||
stbuf->st_blocks = DIV_ROUND_UP(node->size, CLUSTER_SIZE(*ef->sb)) *
|
||||
CLUSTER_SIZE(*ef->sb) / 512;
|
||||
stbuf->st_mtime = node->mtime;
|
||||
stbuf->st_atime = node->atime;
|
||||
/* set ctime to mtime to ensure we don't break programs that rely on ctime
|
||||
(e.g. rsync) */
|
||||
stbuf->st_ctime = node->mtime;
|
||||
}
|
||||
|
||||
void exfat_get_name(const struct exfat_node* node, char* buffer, size_t n)
|
||||
{
|
||||
if (utf16_to_utf8(buffer, node->name, n, EXFAT_NAME_MAX) != 0)
|
||||
exfat_bug("failed to convert name to UTF-8");
|
||||
}
|
||||
|
||||
uint16_t exfat_start_checksum(const struct exfat_entry_meta1* entry)
|
||||
{
|
||||
uint16_t sum = 0;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < sizeof(struct exfat_entry); i++)
|
||||
if (i != 2 && i != 3) /* skip checksum field itself */
|
||||
sum = ((sum << 15) | (sum >> 1)) + ((const uint8_t*) entry)[i];
|
||||
return sum;
|
||||
}
|
||||
|
||||
uint16_t exfat_add_checksum(const void* entry, uint16_t sum)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < sizeof(struct exfat_entry); i++)
|
||||
sum = ((sum << 15) | (sum >> 1)) + ((const uint8_t*) entry)[i];
|
||||
return sum;
|
||||
}
|
||||
|
||||
le16_t exfat_calc_checksum(const struct exfat_entry_meta1* meta1,
|
||||
const struct exfat_entry_meta2* meta2, const le16_t* name)
|
||||
{
|
||||
uint16_t checksum;
|
||||
const int name_entries = DIV_ROUND_UP(utf16_length(name), EXFAT_ENAME_MAX);
|
||||
int i;
|
||||
|
||||
checksum = exfat_start_checksum(meta1);
|
||||
checksum = exfat_add_checksum(meta2, checksum);
|
||||
for (i = 0; i < name_entries; i++)
|
||||
{
|
||||
struct exfat_entry_name name_entry = {EXFAT_ENTRY_FILE_NAME, 0};
|
||||
memcpy(name_entry.name, name + i * EXFAT_ENAME_MAX,
|
||||
EXFAT_ENAME_MAX * sizeof(le16_t));
|
||||
checksum = exfat_add_checksum(&name_entry, checksum);
|
||||
}
|
||||
return cpu_to_le16(checksum);
|
||||
}
|
||||
|
||||
uint32_t exfat_vbr_start_checksum(const void* sector, size_t size)
|
||||
{
|
||||
size_t i;
|
||||
uint32_t sum = 0;
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
/* skip volume_state and allocated_percent fields */
|
||||
if (i != 0x6a && i != 0x6b && i != 0x70)
|
||||
sum = ((sum << 31) | (sum >> 1)) + ((const uint8_t*) sector)[i];
|
||||
return sum;
|
||||
}
|
||||
|
||||
uint32_t exfat_vbr_add_checksum(const void* sector, size_t size, uint32_t sum)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
sum = ((sum << 31) | (sum >> 1)) + ((const uint8_t*) sector)[i];
|
||||
return sum;
|
||||
}
|
||||
|
||||
le16_t exfat_calc_name_hash(const struct exfat* ef, const le16_t* name)
|
||||
{
|
||||
size_t i;
|
||||
size_t length = utf16_length(name);
|
||||
uint16_t hash = 0;
|
||||
|
||||
for (i = 0; i < length; i++)
|
||||
{
|
||||
uint16_t c = le16_to_cpu(name[i]);
|
||||
|
||||
/* convert to upper case */
|
||||
if (c < ef->upcase_chars)
|
||||
c = le16_to_cpu(ef->upcase[c]);
|
||||
|
||||
hash = ((hash << 15) | (hash >> 1)) + (c & 0xff);
|
||||
hash = ((hash << 15) | (hash >> 1)) + (c >> 8);
|
||||
}
|
||||
return cpu_to_le16(hash);
|
||||
}
|
||||
|
||||
void exfat_humanize_bytes(uint64_t value, struct exfat_human_bytes* hb)
|
||||
{
|
||||
size_t i;
|
||||
/* 16 EB (minus 1 byte) is the largest size that can be represented by
|
||||
uint64_t */
|
||||
const char* units[] = {"bytes", "KB", "MB", "GB", "TB", "PB", "EB"};
|
||||
uint64_t divisor = 1;
|
||||
uint64_t temp = 0;
|
||||
|
||||
for (i = 0; ; i++, divisor *= 1024)
|
||||
{
|
||||
temp = (value + divisor / 2) / divisor;
|
||||
|
||||
if (temp == 0)
|
||||
break;
|
||||
if (temp / 1024 * 1024 == temp)
|
||||
continue;
|
||||
if (temp < 10240)
|
||||
break;
|
||||
}
|
||||
hb->value = temp;
|
||||
hb->unit = units[i];
|
||||
}
|
||||
|
||||
void exfat_print_info(const struct exfat_super_block* sb,
|
||||
uint32_t free_clusters)
|
||||
{
|
||||
struct exfat_human_bytes hb;
|
||||
off64_t total_space = le64_to_cpu(sb->sector_count) * SECTOR_SIZE(*sb);
|
||||
off64_t avail_space = (off64_t) free_clusters * CLUSTER_SIZE(*sb);
|
||||
|
||||
printf("File system version %hhu.%hhu\n",
|
||||
sb->version.major, sb->version.minor);
|
||||
exfat_humanize_bytes(SECTOR_SIZE(*sb), &hb);
|
||||
printf("Sector size %10"PRIu64" %s\n", hb.value, hb.unit);
|
||||
exfat_humanize_bytes(CLUSTER_SIZE(*sb), &hb);
|
||||
printf("Cluster size %10"PRIu64" %s\n", hb.value, hb.unit);
|
||||
exfat_humanize_bytes(total_space, &hb);
|
||||
printf("Volume size %10"PRIu64" %s\n", hb.value, hb.unit);
|
||||
exfat_humanize_bytes(total_space - avail_space, &hb);
|
||||
printf("Used space %10"PRIu64" %s\n", hb.value, hb.unit);
|
||||
exfat_humanize_bytes(avail_space, &hb);
|
||||
printf("Available space %10"PRIu64" %s\n", hb.value, hb.unit);
|
||||
}
|
28
exfat/libexfat/version.h
Normal file
28
exfat/libexfat/version.h
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
version.h (12.06.10)
|
||||
Version constants.
|
||||
|
||||
Copyright (C) 2010-2012 Andrew Nayenko
|
||||
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#ifndef VERSION_H_INCLUDED
|
||||
#define VERSION_H_INCLUDED
|
||||
|
||||
#define EXFAT_VERSION_MAJOR 0
|
||||
#define EXFAT_VERSION_MINOR 9
|
||||
#define EXFAT_VERSION_PATCH 8
|
||||
|
||||
#endif /* ifndef VERSION_H_INCLUDED */
|
21
exfat/mkfs/Android.mk
Normal file
21
exfat/mkfs/Android.mk
Normal file
@ -0,0 +1,21 @@
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE := mkexfatfs
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin
|
||||
LOCAL_CFLAGS = -D_FILE_OFFSET_BITS=64
|
||||
LOCAL_SRC_FILES = cbm.c fat.c main.c mkexfat.c rootdir.c uct.c uctc.c vbr.c
|
||||
LOCAL_C_INCLUDES += $(LOCAL_PATH) \
|
||||
bootable/recovery/exfat/libexfat \
|
||||
bootable/recovery/fuse/include
|
||||
LOCAL_SHARED_LIBRARIES += libz libc libexfat libdl
|
||||
LOCAL_STATIC_LIBRARIES += libfuse
|
||||
|
||||
include $(BUILD_EXECUTABLE)
|
||||
|
||||
# We need this so that the installed files could be picked up based on the
|
||||
# local module name
|
||||
ALL_MODULES.$(LOCAL_MODULE).INSTALLED := \
|
||||
$(ALL_MODULES.$(LOCAL_MODULE).INSTALLED) $(SYMLINKS)
|
74
exfat/mkfs/cbm.c
Normal file
74
exfat/mkfs/cbm.c
Normal file
@ -0,0 +1,74 @@
|
||||
/*
|
||||
cbm.c (09.11.10)
|
||||
Clusters Bitmap creation code.
|
||||
|
||||
Copyright (C) 2011, 2012 Andrew Nayenko
|
||||
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#include <limits.h>
|
||||
#include "cbm.h"
|
||||
#include "fat.h"
|
||||
#include "uct.h"
|
||||
#include "rootdir.h"
|
||||
|
||||
static off64_t cbm_alignment(void)
|
||||
{
|
||||
return get_cluster_size();
|
||||
}
|
||||
|
||||
static off64_t cbm_size(void)
|
||||
{
|
||||
return DIV_ROUND_UP(
|
||||
(get_volume_size() - get_position(&cbm)) / get_cluster_size(),
|
||||
CHAR_BIT);
|
||||
}
|
||||
|
||||
static int cbm_write(struct exfat_dev* dev)
|
||||
{
|
||||
uint32_t allocated_clusters =
|
||||
DIV_ROUND_UP(cbm.get_size(), get_cluster_size()) +
|
||||
DIV_ROUND_UP(uct.get_size(), get_cluster_size()) +
|
||||
DIV_ROUND_UP(rootdir.get_size(), get_cluster_size());
|
||||
size_t bitmap_size = DIV_ROUND_UP(allocated_clusters, CHAR_BIT);
|
||||
uint8_t* bitmap = malloc(bitmap_size);
|
||||
size_t i;
|
||||
|
||||
if (bitmap == NULL)
|
||||
{
|
||||
exfat_error("failed to allocate bitmap of %zu bytes", bitmap_size);
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (i = 0; i < bitmap_size * CHAR_BIT; i++)
|
||||
if (i < allocated_clusters)
|
||||
BMAP_SET(bitmap, i);
|
||||
else
|
||||
BMAP_CLR(bitmap, i);
|
||||
if (exfat_write(dev, bitmap, bitmap_size) < 0)
|
||||
{
|
||||
exfat_error("failed to write bitmap of %zu bytes", bitmap_size);
|
||||
return 1;
|
||||
}
|
||||
free(bitmap);
|
||||
return 0;
|
||||
}
|
||||
|
||||
const struct fs_object cbm =
|
||||
{
|
||||
.get_alignment = cbm_alignment,
|
||||
.get_size = cbm_size,
|
||||
.write = cbm_write,
|
||||
};
|
28
exfat/mkfs/cbm.h
Normal file
28
exfat/mkfs/cbm.h
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
cbm.h (09.11.10)
|
||||
Clusters Bitmap creation code.
|
||||
|
||||
Copyright (C) 2011, 2012 Andrew Nayenko
|
||||
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#ifndef MKFS_CBM_H_INCLUDED
|
||||
#define MKFS_CBM_H_INCLUDED
|
||||
|
||||
#include "mkexfat.h"
|
||||
|
||||
extern const struct fs_object cbm;
|
||||
|
||||
#endif /* ifndef MKFS_CBM_H_INCLUDED */
|
86
exfat/mkfs/fat.c
Normal file
86
exfat/mkfs/fat.c
Normal file
@ -0,0 +1,86 @@
|
||||
/*
|
||||
fat.c (09.11.10)
|
||||
File Allocation Table creation code.
|
||||
|
||||
Copyright (C) 2011, 2012 Andrew Nayenko
|
||||
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include "fat.h"
|
||||
#include "cbm.h"
|
||||
#include "uct.h"
|
||||
#include "rootdir.h"
|
||||
|
||||
static off64_t fat_alignment(void)
|
||||
{
|
||||
return (off64_t) 128 * get_sector_size();
|
||||
}
|
||||
|
||||
static off64_t fat_size(void)
|
||||
{
|
||||
return get_volume_size() / get_cluster_size() * sizeof(cluster_t);
|
||||
}
|
||||
|
||||
static cluster_t fat_write_entry(struct exfat_dev* dev, cluster_t cluster,
|
||||
cluster_t value)
|
||||
{
|
||||
le32_t fat_entry = cpu_to_le32(value);
|
||||
if (exfat_write(dev, &fat_entry, sizeof(fat_entry)) < 0)
|
||||
{
|
||||
exfat_error("failed to write FAT entry 0x%x", value);
|
||||
return 0;
|
||||
}
|
||||
return cluster + 1;
|
||||
}
|
||||
|
||||
static cluster_t fat_write_entries(struct exfat_dev* dev, cluster_t cluster,
|
||||
uint64_t length)
|
||||
{
|
||||
cluster_t end = cluster + DIV_ROUND_UP(length, get_cluster_size());
|
||||
|
||||
while (cluster < end - 1)
|
||||
{
|
||||
cluster = fat_write_entry(dev, cluster, cluster + 1);
|
||||
if (cluster == 0)
|
||||
return 0;
|
||||
}
|
||||
return fat_write_entry(dev, cluster, EXFAT_CLUSTER_END);
|
||||
}
|
||||
|
||||
static int fat_write(struct exfat_dev* dev)
|
||||
{
|
||||
cluster_t c = 0;
|
||||
|
||||
if (!(c = fat_write_entry(dev, c, 0xfffffff8))) /* media type */
|
||||
return 1;
|
||||
if (!(c = fat_write_entry(dev, c, 0xffffffff))) /* some weird constant */
|
||||
return 1;
|
||||
if (!(c = fat_write_entries(dev, c, cbm.get_size())))
|
||||
return 1;
|
||||
if (!(c = fat_write_entries(dev, c, uct.get_size())))
|
||||
return 1;
|
||||
if (!(c = fat_write_entries(dev, c, rootdir.get_size())))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
const struct fs_object fat =
|
||||
{
|
||||
.get_alignment = fat_alignment,
|
||||
.get_size = fat_size,
|
||||
.write = fat_write,
|
||||
};
|
28
exfat/mkfs/fat.h
Normal file
28
exfat/mkfs/fat.h
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
fat.h (09.11.10)
|
||||
File Allocation Table creation code.
|
||||
|
||||
Copyright (C) 2011, 2012 Andrew Nayenko
|
||||
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#ifndef MKFS_FAT_H_INCLUDED
|
||||
#define MKFS_FAT_H_INCLUDED
|
||||
|
||||
#include "mkexfat.h"
|
||||
|
||||
extern const struct fs_object fat;
|
||||
|
||||
#endif /* ifndef MKFS_FAT_H_INCLUDED */
|
269
exfat/mkfs/main.c
Normal file
269
exfat/mkfs/main.c
Normal file
@ -0,0 +1,269 @@
|
||||
/*
|
||||
main.c (15.08.10)
|
||||
Creates exFAT file system.
|
||||
|
||||
Copyright (C) 2011, 2012 Andrew Nayenko
|
||||
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
#include <exfat.h>
|
||||
#include "mkexfat.h"
|
||||
#include "vbr.h"
|
||||
#include "fat.h"
|
||||
#include "cbm.h"
|
||||
#include "uct.h"
|
||||
#include "rootdir.h"
|
||||
|
||||
const struct fs_object* objects[] =
|
||||
{
|
||||
&vbr,
|
||||
&vbr,
|
||||
&fat,
|
||||
/* clusters heap */
|
||||
&cbm,
|
||||
&uct,
|
||||
&rootdir,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static struct
|
||||
{
|
||||
int sector_bits;
|
||||
int spc_bits;
|
||||
off64_t volume_size;
|
||||
le16_t volume_label[EXFAT_ENAME_MAX + 1];
|
||||
uint32_t volume_serial;
|
||||
uint64_t first_sector;
|
||||
}
|
||||
param;
|
||||
|
||||
int get_sector_bits(void)
|
||||
{
|
||||
return param.sector_bits;
|
||||
}
|
||||
|
||||
int get_spc_bits(void)
|
||||
{
|
||||
return param.spc_bits;
|
||||
}
|
||||
|
||||
off64_t get_volume_size(void)
|
||||
{
|
||||
return param.volume_size;
|
||||
}
|
||||
|
||||
const le16_t* get_volume_label(void)
|
||||
{
|
||||
return param.volume_label;
|
||||
}
|
||||
|
||||
uint32_t get_volume_serial(void)
|
||||
{
|
||||
return param.volume_serial;
|
||||
}
|
||||
|
||||
uint64_t get_first_sector(void)
|
||||
{
|
||||
return param.first_sector;
|
||||
}
|
||||
|
||||
int get_sector_size(void)
|
||||
{
|
||||
return 1 << get_sector_bits();
|
||||
}
|
||||
|
||||
int get_cluster_size(void)
|
||||
{
|
||||
return get_sector_size() << get_spc_bits();
|
||||
}
|
||||
|
||||
static int setup_spc_bits(int sector_bits, int user_defined, off64_t volume_size)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (user_defined != -1)
|
||||
{
|
||||
off64_t cluster_size = 1 << sector_bits << user_defined;
|
||||
if (volume_size / cluster_size > EXFAT_LAST_DATA_CLUSTER)
|
||||
{
|
||||
struct exfat_human_bytes chb, vhb;
|
||||
|
||||
exfat_humanize_bytes(cluster_size, &chb);
|
||||
exfat_humanize_bytes(volume_size, &vhb);
|
||||
exfat_error("cluster size %"PRIu64" %s is too small for "
|
||||
"%"PRIu64" %s volume, try -s %d",
|
||||
chb.value, chb.unit,
|
||||
vhb.value, vhb.unit,
|
||||
1 << setup_spc_bits(sector_bits, -1, volume_size));
|
||||
return -1;
|
||||
}
|
||||
return user_defined;
|
||||
}
|
||||
|
||||
if (volume_size < 256ull * 1024 * 1024)
|
||||
return MAX(0, 12 - sector_bits); /* 4 KB */
|
||||
if (volume_size < 32ull * 1024 * 1024 * 1024)
|
||||
return MAX(0, 15 - sector_bits); /* 32 KB */
|
||||
|
||||
for (i = 17; ; i++) /* 128 KB or more */
|
||||
if (DIV_ROUND_UP(volume_size, 1 << i) <= EXFAT_LAST_DATA_CLUSTER)
|
||||
return MAX(0, i - sector_bits);
|
||||
}
|
||||
|
||||
static int setup_volume_label(le16_t label[EXFAT_ENAME_MAX + 1], const char* s)
|
||||
{
|
||||
memset(label, 0, (EXFAT_ENAME_MAX + 1) * sizeof(le16_t));
|
||||
if (s == NULL)
|
||||
return 0;
|
||||
return utf8_to_utf16(label, s, EXFAT_ENAME_MAX, strlen(s));
|
||||
}
|
||||
|
||||
static uint32_t setup_volume_serial(uint32_t user_defined)
|
||||
{
|
||||
struct timeval now;
|
||||
|
||||
if (user_defined != 0)
|
||||
return user_defined;
|
||||
|
||||
if (gettimeofday(&now, NULL) != 0)
|
||||
{
|
||||
exfat_error("failed to form volume id");
|
||||
return 0;
|
||||
}
|
||||
return (now.tv_sec << 20) | now.tv_usec;
|
||||
}
|
||||
|
||||
static int setup(struct exfat_dev* dev, int sector_bits, int spc_bits,
|
||||
const char* volume_label, uint32_t volume_serial,
|
||||
uint64_t first_sector)
|
||||
{
|
||||
param.sector_bits = sector_bits;
|
||||
param.first_sector = first_sector;
|
||||
param.volume_size = exfat_get_size(dev);
|
||||
|
||||
param.spc_bits = setup_spc_bits(sector_bits, spc_bits, param.volume_size);
|
||||
if (param.spc_bits == -1)
|
||||
return 1;
|
||||
|
||||
if (setup_volume_label(param.volume_label, volume_label) != 0)
|
||||
return 1;
|
||||
|
||||
param.volume_serial = setup_volume_serial(volume_serial);
|
||||
if (param.volume_serial == 0)
|
||||
return 1;
|
||||
|
||||
return mkfs(dev, param.volume_size);
|
||||
}
|
||||
|
||||
static int logarithm2(int n)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < sizeof(int) * CHAR_BIT - 1; i++)
|
||||
if ((1 << i) == n)
|
||||
return i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void usage(const char* prog)
|
||||
{
|
||||
fprintf(stderr, "Usage: %s [-i volume-id] [-n label] "
|
||||
"[-p partition-first-sector] "
|
||||
"[-s sectors-per-cluster] [-v] <device>\n", prog);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
const char* spec = NULL;
|
||||
char** pp;
|
||||
int spc_bits = -1;
|
||||
const char* volume_label = NULL;
|
||||
uint32_t volume_serial = 0;
|
||||
uint64_t first_sector = 0;
|
||||
struct exfat_dev* dev;
|
||||
|
||||
printf("mkexfatfs %u.%u.%u\n",
|
||||
EXFAT_VERSION_MAJOR, EXFAT_VERSION_MINOR, EXFAT_VERSION_PATCH);
|
||||
|
||||
for (pp = argv + 1; *pp; pp++)
|
||||
{
|
||||
if (strcmp(*pp, "-s") == 0)
|
||||
{
|
||||
pp++;
|
||||
if (*pp == NULL)
|
||||
usage(argv[0]);
|
||||
spc_bits = logarithm2(atoi(*pp));
|
||||
if (spc_bits < 0)
|
||||
{
|
||||
exfat_error("invalid option value: `%s'", *pp);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else if (strcmp(*pp, "-n") == 0)
|
||||
{
|
||||
pp++;
|
||||
if (*pp == NULL)
|
||||
usage(argv[0]);
|
||||
volume_label = *pp;
|
||||
}
|
||||
else if (strcmp(*pp, "-i") == 0)
|
||||
{
|
||||
pp++;
|
||||
if (*pp == NULL)
|
||||
usage(argv[0]);
|
||||
volume_serial = strtol(*pp, NULL, 16);
|
||||
}
|
||||
else if (strcmp(*pp, "-p") == 0)
|
||||
{
|
||||
pp++;
|
||||
if (*pp == NULL)
|
||||
usage(argv[0]);
|
||||
first_sector = strtoll(*pp, NULL, 10);
|
||||
}
|
||||
else if (strcmp(*pp, "-v") == 0)
|
||||
{
|
||||
puts("Copyright (C) 2011, 2012 Andrew Nayenko");
|
||||
return 0;
|
||||
}
|
||||
else if (spec == NULL)
|
||||
spec = *pp;
|
||||
else
|
||||
usage(argv[0]);
|
||||
}
|
||||
if (spec == NULL)
|
||||
usage(argv[0]);
|
||||
|
||||
dev = exfat_open(spec, EXFAT_MODE_RW);
|
||||
if (dev == NULL)
|
||||
return 1;
|
||||
if (setup(dev, 9, spc_bits, volume_label, volume_serial,
|
||||
first_sector) != 0)
|
||||
{
|
||||
exfat_close(dev);
|
||||
return 1;
|
||||
}
|
||||
if (exfat_close(dev) != 0)
|
||||
return 1;
|
||||
printf("File system created successfully.\n");
|
||||
return 0;
|
||||
}
|
160
exfat/mkfs/mkexfat.c
Normal file
160
exfat/mkfs/mkexfat.c
Normal file
@ -0,0 +1,160 @@
|
||||
/*
|
||||
mkexfat.c (22.04.12)
|
||||
FS creation engine.
|
||||
|
||||
Copyright (C) 2011, 2012 Andrew Nayenko
|
||||
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "mkexfat.h"
|
||||
|
||||
static int check_size(off64_t volume_size)
|
||||
{
|
||||
const struct fs_object** pp;
|
||||
off64_t position = 0;
|
||||
|
||||
for (pp = objects; *pp; pp++)
|
||||
{
|
||||
position = ROUND_UP(position, (*pp)->get_alignment());
|
||||
position += (*pp)->get_size();
|
||||
}
|
||||
|
||||
if (position > volume_size)
|
||||
{
|
||||
struct exfat_human_bytes vhb;
|
||||
|
||||
exfat_humanize_bytes(volume_size, &vhb);
|
||||
exfat_error("too small device (%"PRIu64" %s)", vhb.value, vhb.unit);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
static int erase_object(struct exfat_dev* dev, const void* block,
|
||||
size_t block_size, off64_t start, off64_t size)
|
||||
{
|
||||
const off64_t block_count = DIV_ROUND_UP(size, block_size);
|
||||
off64_t i;
|
||||
|
||||
if (exfat_seek(dev, start, SEEK_SET) == (off64_t) -1)
|
||||
{
|
||||
exfat_error("seek to 0x%"PRIx64" failed", start);
|
||||
return 1;
|
||||
}
|
||||
for (i = 0; i < size; i += block_size)
|
||||
{
|
||||
if (exfat_write(dev, block, MIN(size - i, block_size)) < 0)
|
||||
{
|
||||
exfat_error("failed to erase block %"PRIu64"/%"PRIu64
|
||||
" at 0x%"PRIx64, i + 1, block_count, start);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int erase(struct exfat_dev* dev)
|
||||
{
|
||||
const struct fs_object** pp;
|
||||
off64_t position = 0;
|
||||
const size_t block_size = 1024 * 1024;
|
||||
void* block = malloc(block_size);
|
||||
|
||||
if (block == NULL)
|
||||
{
|
||||
exfat_error("failed to allocate erase block of %zu bytes", block_size);
|
||||
return 1;
|
||||
}
|
||||
memset(block, 0, block_size);
|
||||
|
||||
for (pp = objects; *pp; pp++)
|
||||
{
|
||||
position = ROUND_UP(position, (*pp)->get_alignment());
|
||||
if (erase_object(dev, block, block_size, position,
|
||||
(*pp)->get_size()) != 0)
|
||||
{
|
||||
free(block);
|
||||
return 1;
|
||||
}
|
||||
position += (*pp)->get_size();
|
||||
}
|
||||
|
||||
free(block);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int create(struct exfat_dev* dev)
|
||||
{
|
||||
const struct fs_object** pp;
|
||||
off64_t position = 0;
|
||||
|
||||
for (pp = objects; *pp; pp++)
|
||||
{
|
||||
position = ROUND_UP(position, (*pp)->get_alignment());
|
||||
if (exfat_seek(dev, position, SEEK_SET) == (off64_t) -1)
|
||||
{
|
||||
exfat_error("seek to 0x%"PRIx64" failed", position);
|
||||
return 1;
|
||||
}
|
||||
if ((*pp)->write(dev) != 0)
|
||||
return 1;
|
||||
position += (*pp)->get_size();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mkfs(struct exfat_dev* dev, off64_t volume_size)
|
||||
{
|
||||
if (check_size(volume_size) != 0)
|
||||
return 1;
|
||||
|
||||
fputs("Creating... ", stdout);
|
||||
fflush(stdout);
|
||||
if (erase(dev) != 0)
|
||||
return 1;
|
||||
if (create(dev) != 0)
|
||||
return 1;
|
||||
puts("done.");
|
||||
|
||||
fputs("Flushing... ", stdout);
|
||||
fflush(stdout);
|
||||
if (exfat_fsync(dev) != 0)
|
||||
return 1;
|
||||
puts("done.");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
off64_t get_position(const struct fs_object* object)
|
||||
{
|
||||
const struct fs_object** pp;
|
||||
off64_t position = 0;
|
||||
|
||||
for (pp = objects; *pp; pp++)
|
||||
{
|
||||
position = ROUND_UP(position, (*pp)->get_alignment());
|
||||
if (*pp == object)
|
||||
return position;
|
||||
position += (*pp)->get_size();
|
||||
}
|
||||
exfat_bug("unknown object");
|
||||
}
|
47
exfat/mkfs/mkexfat.h
Normal file
47
exfat/mkfs/mkexfat.h
Normal file
@ -0,0 +1,47 @@
|
||||
/*
|
||||
mkexfat.h (09.11.10)
|
||||
FS creation engine.
|
||||
|
||||
Copyright (C) 2011, 2012 Andrew Nayenko
|
||||
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#ifndef MKFS_MKEXFAT_H_INCLUDED
|
||||
#define MKFS_MKEXFAT_H_INCLUDED
|
||||
|
||||
#include <exfat.h>
|
||||
|
||||
struct fs_object
|
||||
{
|
||||
off64_t (*get_alignment)(void);
|
||||
off64_t (*get_size)(void);
|
||||
int (*write)(struct exfat_dev* dev);
|
||||
};
|
||||
|
||||
extern const struct fs_object* objects[];
|
||||
|
||||
int get_sector_bits(void);
|
||||
int get_spc_bits(void);
|
||||
off64_t get_volume_size(void);
|
||||
const le16_t* get_volume_label(void);
|
||||
uint32_t get_volume_serial(void);
|
||||
uint64_t get_first_sector(void);
|
||||
int get_sector_size(void);
|
||||
int get_cluster_size(void);
|
||||
|
||||
int mkfs(struct exfat_dev* dev, off64_t volume_size);
|
||||
off64_t get_position(const struct fs_object* object);
|
||||
|
||||
#endif /* ifndef MKFS_MKEXFAT_H_INCLUDED */
|
68
exfat/mkfs/mkexfatfs.8
Normal file
68
exfat/mkfs/mkexfatfs.8
Normal file
@ -0,0 +1,68 @@
|
||||
.\" Copyright (C) 2011 Andrew Nayenko
|
||||
.\"
|
||||
.TH MKEXFATFS 8 "January 2011"
|
||||
.SH NAME
|
||||
.B mkexfatfs
|
||||
\- create an exFAT file system
|
||||
.SH SYNOPSIS
|
||||
.B mkexfatfs
|
||||
[
|
||||
.B \-i
|
||||
.I volume-id
|
||||
]
|
||||
[
|
||||
.B \-n
|
||||
.I volume-name
|
||||
]
|
||||
[
|
||||
.B \-p
|
||||
.I partition-first-sector
|
||||
]
|
||||
[
|
||||
.B \-s
|
||||
.I sectors-per-cluster
|
||||
]
|
||||
[
|
||||
.B \-v
|
||||
]
|
||||
.I device
|
||||
|
||||
.SH DESCRIPTION
|
||||
.B mkexfatfs
|
||||
creates an exFAT file system on a block device.
|
||||
.I device
|
||||
is a special file corresponding to the device.
|
||||
|
||||
.SH OPTIONS
|
||||
Command line options available:
|
||||
.TP
|
||||
.BI \-i " volume-id"
|
||||
A 32-bit hexadecimal number. By default a value based on current time is set.
|
||||
.TP
|
||||
.BI \-n " volume-name"
|
||||
Volume name (label), up to 15 characters. By default no label is set.
|
||||
.TP
|
||||
.BI \-p " partition-first-sector"
|
||||
First sector of the partition starting from the beginning of the whole disk.
|
||||
exFAT super block has a field for this value but in fact it's optional and
|
||||
does not affect anything. Default is 0.
|
||||
.TP
|
||||
.BI \-s " sectors-per-cluster"
|
||||
Number of physical sectors per cluster (cluster is an allocation unit in
|
||||
exFAT). Must be a power of 2, i.e. 1, 2, 4, 8, etc. Cluster size can not
|
||||
exceed 32 MB. Default cluster sizes are:
|
||||
4 KB if volume size is less than 256 MB,
|
||||
32 KB if volume size is from 256 MB to 32 GB,
|
||||
128 KB if volume size is 32 GB or larger.
|
||||
.TP
|
||||
.BI \-v
|
||||
Print version and copyright.
|
||||
|
||||
.SH EXIT CODES
|
||||
Zero is returned on successful creation. Any other code means an error.
|
||||
|
||||
.SH AUTHOR
|
||||
Andrew Nayenko
|
||||
|
||||
.SH SEE ALSO
|
||||
.BR mkfs (8)
|
100
exfat/mkfs/rootdir.c
Normal file
100
exfat/mkfs/rootdir.c
Normal file
@ -0,0 +1,100 @@
|
||||
/*
|
||||
rootdir.c (09.11.10)
|
||||
Root directory creation code.
|
||||
|
||||
Copyright (C) 2011, 2012 Andrew Nayenko
|
||||
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include "rootdir.h"
|
||||
#include "uct.h"
|
||||
#include "cbm.h"
|
||||
#include "uctc.h"
|
||||
|
||||
static off64_t rootdir_alignment(void)
|
||||
{
|
||||
return get_cluster_size();
|
||||
}
|
||||
|
||||
static off64_t rootdir_size(void)
|
||||
{
|
||||
return get_cluster_size();
|
||||
}
|
||||
|
||||
static void init_label_entry(struct exfat_entry_label* label_entry)
|
||||
{
|
||||
memset(label_entry, 0, sizeof(struct exfat_entry_label));
|
||||
label_entry->type = EXFAT_ENTRY_LABEL ^ EXFAT_ENTRY_VALID;
|
||||
|
||||
if (utf16_length(get_volume_label()) == 0)
|
||||
return;
|
||||
|
||||
memcpy(label_entry->name, get_volume_label(),
|
||||
EXFAT_ENAME_MAX * sizeof(le16_t));
|
||||
label_entry->length = utf16_length(get_volume_label());
|
||||
label_entry->type |= EXFAT_ENTRY_VALID;
|
||||
}
|
||||
|
||||
static void init_bitmap_entry(struct exfat_entry_bitmap* bitmap_entry)
|
||||
{
|
||||
memset(bitmap_entry, 0, sizeof(struct exfat_entry_bitmap));
|
||||
bitmap_entry->type = EXFAT_ENTRY_BITMAP;
|
||||
bitmap_entry->start_cluster = cpu_to_le32(EXFAT_FIRST_DATA_CLUSTER);
|
||||
bitmap_entry->size = cpu_to_le64(cbm.get_size());
|
||||
}
|
||||
|
||||
static void init_upcase_entry(struct exfat_entry_upcase* upcase_entry)
|
||||
{
|
||||
size_t i;
|
||||
uint32_t sum = 0;
|
||||
|
||||
for (i = 0; i < sizeof(upcase_table); i++)
|
||||
sum = ((sum << 31) | (sum >> 1)) + upcase_table[i];
|
||||
|
||||
memset(upcase_entry, 0, sizeof(struct exfat_entry_upcase));
|
||||
upcase_entry->type = EXFAT_ENTRY_UPCASE;
|
||||
upcase_entry->checksum = cpu_to_le32(sum);
|
||||
upcase_entry->start_cluster = cpu_to_le32(
|
||||
(get_position(&uct) - get_position(&cbm)) / get_cluster_size() +
|
||||
EXFAT_FIRST_DATA_CLUSTER);
|
||||
upcase_entry->size = cpu_to_le64(sizeof(upcase_table));
|
||||
}
|
||||
|
||||
static int rootdir_write(struct exfat_dev* dev)
|
||||
{
|
||||
struct exfat_entry_label label_entry;
|
||||
struct exfat_entry_bitmap bitmap_entry;
|
||||
struct exfat_entry_upcase upcase_entry;
|
||||
|
||||
init_label_entry(&label_entry);
|
||||
init_bitmap_entry(&bitmap_entry);
|
||||
init_upcase_entry(&upcase_entry);
|
||||
|
||||
if (exfat_write(dev, &label_entry, sizeof(struct exfat_entry)) < 0)
|
||||
return 1;
|
||||
if (exfat_write(dev, &bitmap_entry, sizeof(struct exfat_entry)) < 0)
|
||||
return 1;
|
||||
if (exfat_write(dev, &upcase_entry, sizeof(struct exfat_entry)) < 0)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
const struct fs_object rootdir =
|
||||
{
|
||||
.get_alignment = rootdir_alignment,
|
||||
.get_size = rootdir_size,
|
||||
.write = rootdir_write,
|
||||
};
|
28
exfat/mkfs/rootdir.h
Normal file
28
exfat/mkfs/rootdir.h
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
rootdir.h (09.11.10)
|
||||
Root directory creation code.
|
||||
|
||||
Copyright (C) 2011, 2012 Andrew Nayenko
|
||||
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#ifndef MKFS_ROOTDIR_H_INCLUDED
|
||||
#define MKFS_ROOTDIR_H_INCLUDED
|
||||
|
||||
#include "mkexfat.h"
|
||||
|
||||
extern const struct fs_object rootdir;
|
||||
|
||||
#endif /* ifndef MKFS_ROOTDIR_H_INCLUDED */
|
50
exfat/mkfs/uct.c
Normal file
50
exfat/mkfs/uct.c
Normal file
@ -0,0 +1,50 @@
|
||||
/*
|
||||
uct.c (09.11.10)
|
||||
Upper Case Table creation code.
|
||||
|
||||
Copyright (C) 2011, 2012 Andrew Nayenko
|
||||
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#include "uct.h"
|
||||
#include "uctc.h"
|
||||
|
||||
static off64_t uct_alignment(void)
|
||||
{
|
||||
return get_cluster_size();
|
||||
}
|
||||
|
||||
static off64_t uct_size(void)
|
||||
{
|
||||
return sizeof(upcase_table);
|
||||
}
|
||||
|
||||
static int uct_write(struct exfat_dev* dev)
|
||||
{
|
||||
if (exfat_write(dev, upcase_table, sizeof(upcase_table)) < 0)
|
||||
{
|
||||
exfat_error("failed to write upcase table of %zu bytes",
|
||||
sizeof(upcase_table));
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
const struct fs_object uct =
|
||||
{
|
||||
.get_alignment = uct_alignment,
|
||||
.get_size = uct_size,
|
||||
.write = uct_write,
|
||||
};
|
28
exfat/mkfs/uct.h
Normal file
28
exfat/mkfs/uct.h
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
uct.h (09.11.10)
|
||||
Upper Case Table creation code.
|
||||
|
||||
Copyright (C) 2011, 2012 Andrew Nayenko
|
||||
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#ifndef MKFS_UCT_H_INCLUDED
|
||||
#define MKFS_UCT_H_INCLUDED
|
||||
|
||||
#include "mkexfat.h"
|
||||
|
||||
extern const struct fs_object uct;
|
||||
|
||||
#endif /* ifndef MKFS_UCT_H_INCLUDED */
|
755
exfat/mkfs/uctc.c
Normal file
755
exfat/mkfs/uctc.c
Normal file
@ -0,0 +1,755 @@
|
||||
/*
|
||||
uctc.c (30.04.12)
|
||||
Upper Case Table contents.
|
||||
|
||||
Copyright (C) 2011, 2012 Andrew Nayenko
|
||||
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#include "uctc.h"
|
||||
|
||||
uint8_t upcase_table[5836] =
|
||||
{
|
||||
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, 0x02, 0xb7, 0x01, 0x93, 0x02,
|
||||
0x94, 0x02, 0x95, 0x02, 0x96, 0x02, 0x97, 0x02,
|
||||
0x98, 0x02, 0x99, 0x02, 0x9a, 0x02, 0x9b, 0x02,
|
||||
0x9c, 0x02, 0x9d, 0x02, 0x9e, 0x02, 0x9f, 0x02,
|
||||
0xa0, 0x02, 0xa1, 0x02, 0xa2, 0x02, 0xa3, 0x02,
|
||||
0xa4, 0x02, 0xa5, 0x02, 0xa6, 0x02, 0xa7, 0x02,
|
||||
0xa8, 0x02, 0xa9, 0x02, 0xaa, 0x02, 0xab, 0x02,
|
||||
0xac, 0x02, 0xad, 0x02, 0xae, 0x02, 0xaf, 0x02,
|
||||
0xb0, 0x02, 0xb1, 0x02, 0xb2, 0x02, 0xb3, 0x02,
|
||||
0xb4, 0x02, 0xb5, 0x02, 0xb6, 0x02, 0xb7, 0x02,
|
||||
0xb8, 0x02, 0xb9, 0x02, 0xba, 0x02, 0xbb, 0x02,
|
||||
0xbc, 0x02, 0xbd, 0x02, 0xbe, 0x02, 0xbf, 0x02,
|
||||
0xc0, 0x02, 0xc1, 0x02, 0xc2, 0x02, 0xc3, 0x02,
|
||||
0xc4, 0x02, 0xc5, 0x02, 0xc6, 0x02, 0xc7, 0x02,
|
||||
0xc8, 0x02, 0xc9, 0x02, 0xca, 0x02, 0xcb, 0x02,
|
||||
0xcc, 0x02, 0xcd, 0x02, 0xce, 0x02, 0xcf, 0x02,
|
||||
0xd0, 0x02, 0xd1, 0x02, 0xd2, 0x02, 0xd3, 0x02,
|
||||
0xd4, 0x02, 0xd5, 0x02, 0xd6, 0x02, 0xd7, 0x02,
|
||||
0xd8, 0x02, 0xd9, 0x02, 0xda, 0x02, 0xdb, 0x02,
|
||||
0xdc, 0x02, 0xdd, 0x02, 0xde, 0x02, 0xdf, 0x02,
|
||||
0xe0, 0x02, 0xe1, 0x02, 0xe2, 0x02, 0xe3, 0x02,
|
||||
0xe4, 0x02, 0xe5, 0x02, 0xe6, 0x02, 0xe7, 0x02,
|
||||
0xe8, 0x02, 0xe9, 0x02, 0xea, 0x02, 0xeb, 0x02,
|
||||
0xec, 0x02, 0xed, 0x02, 0xee, 0x02, 0xef, 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, 0x8a, 0x1d, 0x8b, 0x1d,
|
||||
0x8c, 0x1d, 0x8d, 0x1d, 0x8e, 0x1d, 0x8f, 0x1d,
|
||||
0x90, 0x1d, 0x91, 0x1d, 0x92, 0x1d, 0x93, 0x1d,
|
||||
0x94, 0x1d, 0x95, 0x1d, 0x96, 0x1d, 0x97, 0x1d,
|
||||
0x98, 0x1d, 0x99, 0x1d, 0x9a, 0x1d, 0x9b, 0x1d,
|
||||
0x9c, 0x1d, 0x9d, 0x1d, 0x9e, 0x1d, 0x9f, 0x1d,
|
||||
0xa0, 0x1d, 0xa1, 0x1d, 0xa2, 0x1d, 0xa3, 0x1d,
|
||||
0xa4, 0x1d, 0xa5, 0x1d, 0xa6, 0x1d, 0xa7, 0x1d,
|
||||
0xa8, 0x1d, 0xa9, 0x1d, 0xaa, 0x1d, 0xab, 0x1d,
|
||||
0xac, 0x1d, 0xad, 0x1d, 0xae, 0x1d, 0xaf, 0x1d,
|
||||
0xb0, 0x1d, 0xb1, 0x1d, 0xb2, 0x1d, 0xb3, 0x1d,
|
||||
0xb4, 0x1d, 0xb5, 0x1d, 0xb6, 0x1d, 0xb7, 0x1d,
|
||||
0xb8, 0x1d, 0xb9, 0x1d, 0xba, 0x1d, 0xbb, 0x1d,
|
||||
0xbc, 0x1d, 0xbd, 0x1d, 0xbe, 0x1d, 0xbf, 0x1d,
|
||||
0xc0, 0x1d, 0xc1, 0x1d, 0xc2, 0x1d, 0xc3, 0x1d,
|
||||
0xc4, 0x1d, 0xc5, 0x1d, 0xc6, 0x1d, 0xc7, 0x1d,
|
||||
0xc8, 0x1d, 0xc9, 0x1d, 0xca, 0x1d, 0xcb, 0x1d,
|
||||
0xcc, 0x1d, 0xcd, 0x1d, 0xce, 0x1d, 0xcf, 0x1d,
|
||||
0xd0, 0x1d, 0xd1, 0x1d, 0xd2, 0x1d, 0xd3, 0x1d,
|
||||
0xd4, 0x1d, 0xd5, 0x1d, 0xd6, 0x1d, 0xd7, 0x1d,
|
||||
0xd8, 0x1d, 0xd9, 0x1d, 0xda, 0x1d, 0xdb, 0x1d,
|
||||
0xdc, 0x1d, 0xdd, 0x1d, 0xde, 0x1d, 0xdf, 0x1d,
|
||||
0xe0, 0x1d, 0xe1, 0x1d, 0xe2, 0x1d, 0xe3, 0x1d,
|
||||
0xe4, 0x1d, 0xe5, 0x1d, 0xe6, 0x1d, 0xe7, 0x1d,
|
||||
0xe8, 0x1d, 0xe9, 0x1d, 0xea, 0x1d, 0xeb, 0x1d,
|
||||
0xec, 0x1d, 0xed, 0x1d, 0xee, 0x1d, 0xef, 0x1d,
|
||||
0xf0, 0x1d, 0xf1, 0x1d, 0xf2, 0x1d, 0xf3, 0x1d,
|
||||
0xf4, 0x1d, 0xf5, 0x1d, 0xf6, 0x1d, 0xf7, 0x1d,
|
||||
0xf8, 0x1d, 0xf9, 0x1d, 0xfa, 0x1d, 0xfb, 0x1d,
|
||||
0xfc, 0x1d, 0xfd, 0x1d, 0xfe, 0x1d, 0xff, 0x1d,
|
||||
0x00, 0x1e, 0x00, 0x1e, 0x02, 0x1e, 0x02, 0x1e,
|
||||
0x04, 0x1e, 0x04, 0x1e, 0x06, 0x1e, 0x06, 0x1e,
|
||||
0x08, 0x1e, 0x08, 0x1e, 0x0a, 0x1e, 0x0a, 0x1e,
|
||||
0x0c, 0x1e, 0x0c, 0x1e, 0x0e, 0x1e, 0x0e, 0x1e,
|
||||
0x10, 0x1e, 0x10, 0x1e, 0x12, 0x1e, 0x12, 0x1e,
|
||||
0x14, 0x1e, 0x14, 0x1e, 0x16, 0x1e, 0x16, 0x1e,
|
||||
0x18, 0x1e, 0x18, 0x1e, 0x1a, 0x1e, 0x1a, 0x1e,
|
||||
0x1c, 0x1e, 0x1c, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e,
|
||||
0x20, 0x1e, 0x20, 0x1e, 0x22, 0x1e, 0x22, 0x1e,
|
||||
0x24, 0x1e, 0x24, 0x1e, 0x26, 0x1e, 0x26, 0x1e,
|
||||
0x28, 0x1e, 0x28, 0x1e, 0x2a, 0x1e, 0x2a, 0x1e,
|
||||
0x2c, 0x1e, 0x2c, 0x1e, 0x2e, 0x1e, 0x2e, 0x1e,
|
||||
0x30, 0x1e, 0x30, 0x1e, 0x32, 0x1e, 0x32, 0x1e,
|
||||
0x34, 0x1e, 0x34, 0x1e, 0x36, 0x1e, 0x36, 0x1e,
|
||||
0x38, 0x1e, 0x38, 0x1e, 0x3a, 0x1e, 0x3a, 0x1e,
|
||||
0x3c, 0x1e, 0x3c, 0x1e, 0x3e, 0x1e, 0x3e, 0x1e,
|
||||
0x40, 0x1e, 0x40, 0x1e, 0x42, 0x1e, 0x42, 0x1e,
|
||||
0x44, 0x1e, 0x44, 0x1e, 0x46, 0x1e, 0x46, 0x1e,
|
||||
0x48, 0x1e, 0x48, 0x1e, 0x4a, 0x1e, 0x4a, 0x1e,
|
||||
0x4c, 0x1e, 0x4c, 0x1e, 0x4e, 0x1e, 0x4e, 0x1e,
|
||||
0x50, 0x1e, 0x50, 0x1e, 0x52, 0x1e, 0x52, 0x1e,
|
||||
0x54, 0x1e, 0x54, 0x1e, 0x56, 0x1e, 0x56, 0x1e,
|
||||
0x58, 0x1e, 0x58, 0x1e, 0x5a, 0x1e, 0x5a, 0x1e,
|
||||
0x5c, 0x1e, 0x5c, 0x1e, 0x5e, 0x1e, 0x5e, 0x1e,
|
||||
0x60, 0x1e, 0x60, 0x1e, 0x62, 0x1e, 0x62, 0x1e,
|
||||
0x64, 0x1e, 0x64, 0x1e, 0x66, 0x1e, 0x66, 0x1e,
|
||||
0x68, 0x1e, 0x68, 0x1e, 0x6a, 0x1e, 0x6a, 0x1e,
|
||||
0x6c, 0x1e, 0x6c, 0x1e, 0x6e, 0x1e, 0x6e, 0x1e,
|
||||
0x70, 0x1e, 0x70, 0x1e, 0x72, 0x1e, 0x72, 0x1e,
|
||||
0x74, 0x1e, 0x74, 0x1e, 0x76, 0x1e, 0x76, 0x1e,
|
||||
0x78, 0x1e, 0x78, 0x1e, 0x7a, 0x1e, 0x7a, 0x1e,
|
||||
0x7c, 0x1e, 0x7c, 0x1e, 0x7e, 0x1e, 0x7e, 0x1e,
|
||||
0x80, 0x1e, 0x80, 0x1e, 0x82, 0x1e, 0x82, 0x1e,
|
||||
0x84, 0x1e, 0x84, 0x1e, 0x86, 0x1e, 0x86, 0x1e,
|
||||
0x88, 0x1e, 0x88, 0x1e, 0x8a, 0x1e, 0x8a, 0x1e,
|
||||
0x8c, 0x1e, 0x8c, 0x1e, 0x8e, 0x1e, 0x8e, 0x1e,
|
||||
0x90, 0x1e, 0x90, 0x1e, 0x92, 0x1e, 0x92, 0x1e,
|
||||
0x94, 0x1e, 0x94, 0x1e, 0x96, 0x1e, 0x97, 0x1e,
|
||||
0x98, 0x1e, 0x99, 0x1e, 0x9a, 0x1e, 0x9b, 0x1e,
|
||||
0x9c, 0x1e, 0x9d, 0x1e, 0x9e, 0x1e, 0x9f, 0x1e,
|
||||
0xa0, 0x1e, 0xa0, 0x1e, 0xa2, 0x1e, 0xa2, 0x1e,
|
||||
0xa4, 0x1e, 0xa4, 0x1e, 0xa6, 0x1e, 0xa6, 0x1e,
|
||||
0xa8, 0x1e, 0xa8, 0x1e, 0xaa, 0x1e, 0xaa, 0x1e,
|
||||
0xac, 0x1e, 0xac, 0x1e, 0xae, 0x1e, 0xae, 0x1e,
|
||||
0xb0, 0x1e, 0xb0, 0x1e, 0xb2, 0x1e, 0xb2, 0x1e,
|
||||
0xb4, 0x1e, 0xb4, 0x1e, 0xb6, 0x1e, 0xb6, 0x1e,
|
||||
0xb8, 0x1e, 0xb8, 0x1e, 0xba, 0x1e, 0xba, 0x1e,
|
||||
0xbc, 0x1e, 0xbc, 0x1e, 0xbe, 0x1e, 0xbe, 0x1e,
|
||||
0xc0, 0x1e, 0xc0, 0x1e, 0xc2, 0x1e, 0xc2, 0x1e,
|
||||
0xc4, 0x1e, 0xc4, 0x1e, 0xc6, 0x1e, 0xc6, 0x1e,
|
||||
0xc8, 0x1e, 0xc8, 0x1e, 0xca, 0x1e, 0xca, 0x1e,
|
||||
0xcc, 0x1e, 0xcc, 0x1e, 0xce, 0x1e, 0xce, 0x1e,
|
||||
0xd0, 0x1e, 0xd0, 0x1e, 0xd2, 0x1e, 0xd2, 0x1e,
|
||||
0xd4, 0x1e, 0xd4, 0x1e, 0xd6, 0x1e, 0xd6, 0x1e,
|
||||
0xd8, 0x1e, 0xd8, 0x1e, 0xda, 0x1e, 0xda, 0x1e,
|
||||
0xdc, 0x1e, 0xdc, 0x1e, 0xde, 0x1e, 0xde, 0x1e,
|
||||
0xe0, 0x1e, 0xe0, 0x1e, 0xe2, 0x1e, 0xe2, 0x1e,
|
||||
0xe4, 0x1e, 0xe4, 0x1e, 0xe6, 0x1e, 0xe6, 0x1e,
|
||||
0xe8, 0x1e, 0xe8, 0x1e, 0xea, 0x1e, 0xea, 0x1e,
|
||||
0xec, 0x1e, 0xec, 0x1e, 0xee, 0x1e, 0xee, 0x1e,
|
||||
0xf0, 0x1e, 0xf0, 0x1e, 0xf2, 0x1e, 0xf2, 0x1e,
|
||||
0xf4, 0x1e, 0xf4, 0x1e, 0xf6, 0x1e, 0xf6, 0x1e,
|
||||
0xf8, 0x1e, 0xf8, 0x1e, 0xfa, 0x1e, 0xfb, 0x1e,
|
||||
0xfc, 0x1e, 0xfd, 0x1e, 0xfe, 0x1e, 0xff, 0x1e,
|
||||
0x08, 0x1f, 0x09, 0x1f, 0x0a, 0x1f, 0x0b, 0x1f,
|
||||
0x0c, 0x1f, 0x0d, 0x1f, 0x0e, 0x1f, 0x0f, 0x1f,
|
||||
0x08, 0x1f, 0x09, 0x1f, 0x0a, 0x1f, 0x0b, 0x1f,
|
||||
0x0c, 0x1f, 0x0d, 0x1f, 0x0e, 0x1f, 0x0f, 0x1f,
|
||||
0x18, 0x1f, 0x19, 0x1f, 0x1a, 0x1f, 0x1b, 0x1f,
|
||||
0x1c, 0x1f, 0x1d, 0x1f, 0x16, 0x1f, 0x17, 0x1f,
|
||||
0x18, 0x1f, 0x19, 0x1f, 0x1a, 0x1f, 0x1b, 0x1f,
|
||||
0x1c, 0x1f, 0x1d, 0x1f, 0x1e, 0x1f, 0x1f, 0x1f,
|
||||
0x28, 0x1f, 0x29, 0x1f, 0x2a, 0x1f, 0x2b, 0x1f,
|
||||
0x2c, 0x1f, 0x2d, 0x1f, 0x2e, 0x1f, 0x2f, 0x1f,
|
||||
0x28, 0x1f, 0x29, 0x1f, 0x2a, 0x1f, 0x2b, 0x1f,
|
||||
0x2c, 0x1f, 0x2d, 0x1f, 0x2e, 0x1f, 0x2f, 0x1f,
|
||||
0x38, 0x1f, 0x39, 0x1f, 0x3a, 0x1f, 0x3b, 0x1f,
|
||||
0x3c, 0x1f, 0x3d, 0x1f, 0x3e, 0x1f, 0x3f, 0x1f,
|
||||
0x38, 0x1f, 0x39, 0x1f, 0x3a, 0x1f, 0x3b, 0x1f,
|
||||
0x3c, 0x1f, 0x3d, 0x1f, 0x3e, 0x1f, 0x3f, 0x1f,
|
||||
0x48, 0x1f, 0x49, 0x1f, 0x4a, 0x1f, 0x4b, 0x1f,
|
||||
0x4c, 0x1f, 0x4d, 0x1f, 0x46, 0x1f, 0x47, 0x1f,
|
||||
0x48, 0x1f, 0x49, 0x1f, 0x4a, 0x1f, 0x4b, 0x1f,
|
||||
0x4c, 0x1f, 0x4d, 0x1f, 0x4e, 0x1f, 0x4f, 0x1f,
|
||||
0x50, 0x1f, 0x59, 0x1f, 0x52, 0x1f, 0x5b, 0x1f,
|
||||
0x54, 0x1f, 0x5d, 0x1f, 0x56, 0x1f, 0x5f, 0x1f,
|
||||
0x58, 0x1f, 0x59, 0x1f, 0x5a, 0x1f, 0x5b, 0x1f,
|
||||
0x5c, 0x1f, 0x5d, 0x1f, 0x5e, 0x1f, 0x5f, 0x1f,
|
||||
0x68, 0x1f, 0x69, 0x1f, 0x6a, 0x1f, 0x6b, 0x1f,
|
||||
0x6c, 0x1f, 0x6d, 0x1f, 0x6e, 0x1f, 0x6f, 0x1f,
|
||||
0x68, 0x1f, 0x69, 0x1f, 0x6a, 0x1f, 0x6b, 0x1f,
|
||||
0x6c, 0x1f, 0x6d, 0x1f, 0x6e, 0x1f, 0x6f, 0x1f,
|
||||
0xba, 0x1f, 0xbb, 0x1f, 0xc8, 0x1f, 0xc9, 0x1f,
|
||||
0xca, 0x1f, 0xcb, 0x1f, 0xda, 0x1f, 0xdb, 0x1f,
|
||||
0xf8, 0x1f, 0xf9, 0x1f, 0xea, 0x1f, 0xeb, 0x1f,
|
||||
0xfa, 0x1f, 0xfb, 0x1f, 0x7e, 0x1f, 0x7f, 0x1f,
|
||||
0x88, 0x1f, 0x89, 0x1f, 0x8a, 0x1f, 0x8b, 0x1f,
|
||||
0x8c, 0x1f, 0x8d, 0x1f, 0x8e, 0x1f, 0x8f, 0x1f,
|
||||
0x88, 0x1f, 0x89, 0x1f, 0x8a, 0x1f, 0x8b, 0x1f,
|
||||
0x8c, 0x1f, 0x8d, 0x1f, 0x8e, 0x1f, 0x8f, 0x1f,
|
||||
0x98, 0x1f, 0x99, 0x1f, 0x9a, 0x1f, 0x9b, 0x1f,
|
||||
0x9c, 0x1f, 0x9d, 0x1f, 0x9e, 0x1f, 0x9f, 0x1f,
|
||||
0x98, 0x1f, 0x99, 0x1f, 0x9a, 0x1f, 0x9b, 0x1f,
|
||||
0x9c, 0x1f, 0x9d, 0x1f, 0x9e, 0x1f, 0x9f, 0x1f,
|
||||
0xa8, 0x1f, 0xa9, 0x1f, 0xaa, 0x1f, 0xab, 0x1f,
|
||||
0xac, 0x1f, 0xad, 0x1f, 0xae, 0x1f, 0xaf, 0x1f,
|
||||
0xa8, 0x1f, 0xa9, 0x1f, 0xaa, 0x1f, 0xab, 0x1f,
|
||||
0xac, 0x1f, 0xad, 0x1f, 0xae, 0x1f, 0xaf, 0x1f,
|
||||
0xb8, 0x1f, 0xb9, 0x1f, 0xb2, 0x1f, 0xbc, 0x1f,
|
||||
0xb4, 0x1f, 0xb5, 0x1f, 0xb6, 0x1f, 0xb7, 0x1f,
|
||||
0xb8, 0x1f, 0xb9, 0x1f, 0xba, 0x1f, 0xbb, 0x1f,
|
||||
0xbc, 0x1f, 0xbd, 0x1f, 0xbe, 0x1f, 0xbf, 0x1f,
|
||||
0xc0, 0x1f, 0xc1, 0x1f, 0xc2, 0x1f, 0xc3, 0x1f,
|
||||
0xc4, 0x1f, 0xc5, 0x1f, 0xc6, 0x1f, 0xc7, 0x1f,
|
||||
0xc8, 0x1f, 0xc9, 0x1f, 0xca, 0x1f, 0xcb, 0x1f,
|
||||
0xc3, 0x1f, 0xcd, 0x1f, 0xce, 0x1f, 0xcf, 0x1f,
|
||||
0xd8, 0x1f, 0xd9, 0x1f, 0xd2, 0x1f, 0xd3, 0x1f,
|
||||
0xd4, 0x1f, 0xd5, 0x1f, 0xd6, 0x1f, 0xd7, 0x1f,
|
||||
0xd8, 0x1f, 0xd9, 0x1f, 0xda, 0x1f, 0xdb, 0x1f,
|
||||
0xdc, 0x1f, 0xdd, 0x1f, 0xde, 0x1f, 0xdf, 0x1f,
|
||||
0xe8, 0x1f, 0xe9, 0x1f, 0xe2, 0x1f, 0xe3, 0x1f,
|
||||
0xe4, 0x1f, 0xec, 0x1f, 0xe6, 0x1f, 0xe7, 0x1f,
|
||||
0xe8, 0x1f, 0xe9, 0x1f, 0xea, 0x1f, 0xeb, 0x1f,
|
||||
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, 0x6e, 0x21, 0x6f, 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, 0x6e, 0x21, 0x6f, 0x21,
|
||||
0x80, 0x21, 0x81, 0x21, 0x82, 0x21, 0x83, 0x21,
|
||||
0x83, 0x21, 0xff, 0xff, 0x4b, 0x03, 0xb6, 0x24,
|
||||
0xb7, 0x24, 0xb8, 0x24, 0xb9, 0x24, 0xba, 0x24,
|
||||
0xbb, 0x24, 0xbc, 0x24, 0xbd, 0x24, 0xbe, 0x24,
|
||||
0xbf, 0x24, 0xc0, 0x24, 0xc1, 0x24, 0xc2, 0x24,
|
||||
0xc3, 0x24, 0xc4, 0x24, 0xc5, 0x24, 0xc6, 0x24,
|
||||
0xc7, 0x24, 0xc8, 0x24, 0xc9, 0x24, 0xca, 0x24,
|
||||
0xcb, 0x24, 0xcc, 0x24, 0xcd, 0x24, 0xce, 0x24,
|
||||
0xcf, 0x24, 0xff, 0xff, 0x46, 0x07, 0x00, 0x2c,
|
||||
0x01, 0x2c, 0x02, 0x2c, 0x03, 0x2c, 0x04, 0x2c,
|
||||
0x05, 0x2c, 0x06, 0x2c, 0x07, 0x2c, 0x08, 0x2c,
|
||||
0x09, 0x2c, 0x0a, 0x2c, 0x0b, 0x2c, 0x0c, 0x2c,
|
||||
0x0d, 0x2c, 0x0e, 0x2c, 0x0f, 0x2c, 0x10, 0x2c,
|
||||
0x11, 0x2c, 0x12, 0x2c, 0x13, 0x2c, 0x14, 0x2c,
|
||||
0x15, 0x2c, 0x16, 0x2c, 0x17, 0x2c, 0x18, 0x2c,
|
||||
0x19, 0x2c, 0x1a, 0x2c, 0x1b, 0x2c, 0x1c, 0x2c,
|
||||
0x1d, 0x2c, 0x1e, 0x2c, 0x1f, 0x2c, 0x20, 0x2c,
|
||||
0x21, 0x2c, 0x22, 0x2c, 0x23, 0x2c, 0x24, 0x2c,
|
||||
0x25, 0x2c, 0x26, 0x2c, 0x27, 0x2c, 0x28, 0x2c,
|
||||
0x29, 0x2c, 0x2a, 0x2c, 0x2b, 0x2c, 0x2c, 0x2c,
|
||||
0x2d, 0x2c, 0x2e, 0x2c, 0x5f, 0x2c, 0x60, 0x2c,
|
||||
0x60, 0x2c, 0x62, 0x2c, 0x63, 0x2c, 0x64, 0x2c,
|
||||
0x65, 0x2c, 0x66, 0x2c, 0x67, 0x2c, 0x67, 0x2c,
|
||||
0x69, 0x2c, 0x69, 0x2c, 0x6b, 0x2c, 0x6b, 0x2c,
|
||||
0x6d, 0x2c, 0x6e, 0x2c, 0x6f, 0x2c, 0x70, 0x2c,
|
||||
0x71, 0x2c, 0x72, 0x2c, 0x73, 0x2c, 0x74, 0x2c,
|
||||
0x75, 0x2c, 0x75, 0x2c, 0x77, 0x2c, 0x78, 0x2c,
|
||||
0x79, 0x2c, 0x7a, 0x2c, 0x7b, 0x2c, 0x7c, 0x2c,
|
||||
0x7d, 0x2c, 0x7e, 0x2c, 0x7f, 0x2c, 0x80, 0x2c,
|
||||
0x80, 0x2c, 0x82, 0x2c, 0x82, 0x2c, 0x84, 0x2c,
|
||||
0x84, 0x2c, 0x86, 0x2c, 0x86, 0x2c, 0x88, 0x2c,
|
||||
0x88, 0x2c, 0x8a, 0x2c, 0x8a, 0x2c, 0x8c, 0x2c,
|
||||
0x8c, 0x2c, 0x8e, 0x2c, 0x8e, 0x2c, 0x90, 0x2c,
|
||||
0x90, 0x2c, 0x92, 0x2c, 0x92, 0x2c, 0x94, 0x2c,
|
||||
0x94, 0x2c, 0x96, 0x2c, 0x96, 0x2c, 0x98, 0x2c,
|
||||
0x98, 0x2c, 0x9a, 0x2c, 0x9a, 0x2c, 0x9c, 0x2c,
|
||||
0x9c, 0x2c, 0x9e, 0x2c, 0x9e, 0x2c, 0xa0, 0x2c,
|
||||
0xa0, 0x2c, 0xa2, 0x2c, 0xa2, 0x2c, 0xa4, 0x2c,
|
||||
0xa4, 0x2c, 0xa6, 0x2c, 0xa6, 0x2c, 0xa8, 0x2c,
|
||||
0xa8, 0x2c, 0xaa, 0x2c, 0xaa, 0x2c, 0xac, 0x2c,
|
||||
0xac, 0x2c, 0xae, 0x2c, 0xae, 0x2c, 0xb0, 0x2c,
|
||||
0xb0, 0x2c, 0xb2, 0x2c, 0xb2, 0x2c, 0xb4, 0x2c,
|
||||
0xb4, 0x2c, 0xb6, 0x2c, 0xb6, 0x2c, 0xb8, 0x2c,
|
||||
0xb8, 0x2c, 0xba, 0x2c, 0xba, 0x2c, 0xbc, 0x2c,
|
||||
0xbc, 0x2c, 0xbe, 0x2c, 0xbe, 0x2c, 0xc0, 0x2c,
|
||||
0xc0, 0x2c, 0xc2, 0x2c, 0xc2, 0x2c, 0xc4, 0x2c,
|
||||
0xc4, 0x2c, 0xc6, 0x2c, 0xc6, 0x2c, 0xc8, 0x2c,
|
||||
0xc8, 0x2c, 0xca, 0x2c, 0xca, 0x2c, 0xcc, 0x2c,
|
||||
0xcc, 0x2c, 0xce, 0x2c, 0xce, 0x2c, 0xd0, 0x2c,
|
||||
0xd0, 0x2c, 0xd2, 0x2c, 0xd2, 0x2c, 0xd4, 0x2c,
|
||||
0xd4, 0x2c, 0xd6, 0x2c, 0xd6, 0x2c, 0xd8, 0x2c,
|
||||
0xd8, 0x2c, 0xda, 0x2c, 0xda, 0x2c, 0xdc, 0x2c,
|
||||
0xdc, 0x2c, 0xde, 0x2c, 0xde, 0x2c, 0xe0, 0x2c,
|
||||
0xe0, 0x2c, 0xe2, 0x2c, 0xe2, 0x2c, 0xe4, 0x2c,
|
||||
0xe5, 0x2c, 0xe6, 0x2c, 0xe7, 0x2c, 0xe8, 0x2c,
|
||||
0xe9, 0x2c, 0xea, 0x2c, 0xeb, 0x2c, 0xec, 0x2c,
|
||||
0xed, 0x2c, 0xee, 0x2c, 0xef, 0x2c, 0xf0, 0x2c,
|
||||
0xf1, 0x2c, 0xf2, 0x2c, 0xf3, 0x2c, 0xf4, 0x2c,
|
||||
0xf5, 0x2c, 0xf6, 0x2c, 0xf7, 0x2c, 0xf8, 0x2c,
|
||||
0xf9, 0x2c, 0xfa, 0x2c, 0xfb, 0x2c, 0xfc, 0x2c,
|
||||
0xfd, 0x2c, 0xfe, 0x2c, 0xff, 0x2c, 0xa0, 0x10,
|
||||
0xa1, 0x10, 0xa2, 0x10, 0xa3, 0x10, 0xa4, 0x10,
|
||||
0xa5, 0x10, 0xa6, 0x10, 0xa7, 0x10, 0xa8, 0x10,
|
||||
0xa9, 0x10, 0xaa, 0x10, 0xab, 0x10, 0xac, 0x10,
|
||||
0xad, 0x10, 0xae, 0x10, 0xaf, 0x10, 0xb0, 0x10,
|
||||
0xb1, 0x10, 0xb2, 0x10, 0xb3, 0x10, 0xb4, 0x10,
|
||||
0xb5, 0x10, 0xb6, 0x10, 0xb7, 0x10, 0xb8, 0x10,
|
||||
0xb9, 0x10, 0xba, 0x10, 0xbb, 0x10, 0xbc, 0x10,
|
||||
0xbd, 0x10, 0xbe, 0x10, 0xbf, 0x10, 0xc0, 0x10,
|
||||
0xc1, 0x10, 0xc2, 0x10, 0xc3, 0x10, 0xc4, 0x10,
|
||||
0xc5, 0x10, 0xff, 0xff, 0x1b, 0xd2, 0x21, 0xff,
|
||||
0x22, 0xff, 0x23, 0xff, 0x24, 0xff, 0x25, 0xff,
|
||||
0x26, 0xff, 0x27, 0xff, 0x28, 0xff, 0x29, 0xff,
|
||||
0x2a, 0xff, 0x2b, 0xff, 0x2c, 0xff, 0x2d, 0xff,
|
||||
0x2e, 0xff, 0x2f, 0xff, 0x30, 0xff, 0x31, 0xff,
|
||||
0x32, 0xff, 0x33, 0xff, 0x34, 0xff, 0x35, 0xff,
|
||||
0x36, 0xff, 0x37, 0xff, 0x38, 0xff, 0x39, 0xff,
|
||||
0x3a, 0xff, 0x5b, 0xff, 0x5c, 0xff, 0x5d, 0xff,
|
||||
0x5e, 0xff, 0x5f, 0xff, 0x60, 0xff, 0x61, 0xff,
|
||||
0x62, 0xff, 0x63, 0xff, 0x64, 0xff, 0x65, 0xff,
|
||||
0x66, 0xff, 0x67, 0xff, 0x68, 0xff, 0x69, 0xff,
|
||||
0x6a, 0xff, 0x6b, 0xff, 0x6c, 0xff, 0x6d, 0xff,
|
||||
0x6e, 0xff, 0x6f, 0xff, 0x70, 0xff, 0x71, 0xff,
|
||||
0x72, 0xff, 0x73, 0xff, 0x74, 0xff, 0x75, 0xff,
|
||||
0x76, 0xff, 0x77, 0xff, 0x78, 0xff, 0x79, 0xff,
|
||||
0x7a, 0xff, 0x7b, 0xff, 0x7c, 0xff, 0x7d, 0xff,
|
||||
0x7e, 0xff, 0x7f, 0xff, 0x80, 0xff, 0x81, 0xff,
|
||||
0x82, 0xff, 0x83, 0xff, 0x84, 0xff, 0x85, 0xff,
|
||||
0x86, 0xff, 0x87, 0xff, 0x88, 0xff, 0x89, 0xff,
|
||||
0x8a, 0xff, 0x8b, 0xff, 0x8c, 0xff, 0x8d, 0xff,
|
||||
0x8e, 0xff, 0x8f, 0xff, 0x90, 0xff, 0x91, 0xff,
|
||||
0x92, 0xff, 0x93, 0xff, 0x94, 0xff, 0x95, 0xff,
|
||||
0x96, 0xff, 0x97, 0xff, 0x98, 0xff, 0x99, 0xff,
|
||||
0x9a, 0xff, 0x9b, 0xff, 0x9c, 0xff, 0x9d, 0xff,
|
||||
0x9e, 0xff, 0x9f, 0xff, 0xa0, 0xff, 0xa1, 0xff,
|
||||
0xa2, 0xff, 0xa3, 0xff, 0xa4, 0xff, 0xa5, 0xff,
|
||||
0xa6, 0xff, 0xa7, 0xff, 0xa8, 0xff, 0xa9, 0xff,
|
||||
0xaa, 0xff, 0xab, 0xff, 0xac, 0xff, 0xad, 0xff,
|
||||
0xae, 0xff, 0xaf, 0xff, 0xb0, 0xff, 0xb1, 0xff,
|
||||
0xb2, 0xff, 0xb3, 0xff, 0xb4, 0xff, 0xb5, 0xff,
|
||||
0xb6, 0xff, 0xb7, 0xff, 0xb8, 0xff, 0xb9, 0xff,
|
||||
0xba, 0xff, 0xbb, 0xff, 0xbc, 0xff, 0xbd, 0xff,
|
||||
0xbe, 0xff, 0xbf, 0xff, 0xc0, 0xff, 0xc1, 0xff,
|
||||
0xc2, 0xff, 0xc3, 0xff, 0xc4, 0xff, 0xc5, 0xff,
|
||||
0xc6, 0xff, 0xc7, 0xff, 0xc8, 0xff, 0xc9, 0xff,
|
||||
0xca, 0xff, 0xcb, 0xff, 0xcc, 0xff, 0xcd, 0xff,
|
||||
0xce, 0xff, 0xcf, 0xff, 0xd0, 0xff, 0xd1, 0xff,
|
||||
0xd2, 0xff, 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
|
||||
};
|
28
exfat/mkfs/uctc.h
Normal file
28
exfat/mkfs/uctc.h
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
uctc.h (30.10.10)
|
||||
Upper Case Table declaration.
|
||||
|
||||
Copyright (C) 2011, 2012 Andrew Nayenko
|
||||
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#ifndef MKFS_UCTC_H_INCLUDED
|
||||
#define MKFS_UCTC_H_INCLUDED
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
extern uint8_t upcase_table[5836];
|
||||
|
||||
#endif /* ifndef MKFS_UCTC_H_INCLUDED */
|
146
exfat/mkfs/vbr.c
Normal file
146
exfat/mkfs/vbr.c
Normal file
@ -0,0 +1,146 @@
|
||||
/*
|
||||
vbr.c (09.11.10)
|
||||
Volume Boot Record creation code.
|
||||
|
||||
Copyright (C) 2011, 2012 Andrew Nayenko
|
||||
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include "vbr.h"
|
||||
#include "fat.h"
|
||||
#include "cbm.h"
|
||||
#include "uct.h"
|
||||
#include "rootdir.h"
|
||||
|
||||
static off64_t vbr_alignment(void)
|
||||
{
|
||||
return get_sector_size();
|
||||
}
|
||||
|
||||
static off64_t vbr_size(void)
|
||||
{
|
||||
return 12 * get_sector_size();
|
||||
}
|
||||
|
||||
static void init_sb(struct exfat_super_block* sb)
|
||||
{
|
||||
uint32_t clusters_max;
|
||||
uint32_t fat_sectors;
|
||||
|
||||
clusters_max = get_volume_size() / get_cluster_size();
|
||||
fat_sectors = DIV_ROUND_UP((off64_t) clusters_max * sizeof(cluster_t),
|
||||
get_sector_size());
|
||||
|
||||
memset(sb, 0, sizeof(struct exfat_super_block));
|
||||
sb->jump[0] = 0xeb;
|
||||
sb->jump[1] = 0x76;
|
||||
sb->jump[2] = 0x90;
|
||||
memcpy(sb->oem_name, "EXFAT ", sizeof(sb->oem_name));
|
||||
sb->sector_start = cpu_to_le64(get_first_sector());
|
||||
sb->sector_count = cpu_to_le64(get_volume_size() / get_sector_size());
|
||||
sb->fat_sector_start = cpu_to_le32(
|
||||
fat.get_alignment() / get_sector_size());
|
||||
sb->fat_sector_count = cpu_to_le32(ROUND_UP(
|
||||
le32_to_cpu(sb->fat_sector_start) + fat_sectors,
|
||||
1 << get_spc_bits()) -
|
||||
le32_to_cpu(sb->fat_sector_start));
|
||||
sb->cluster_sector_start = cpu_to_le32(
|
||||
get_position(&cbm) / get_sector_size());
|
||||
sb->cluster_count = cpu_to_le32(clusters_max -
|
||||
((le32_to_cpu(sb->fat_sector_start) +
|
||||
le32_to_cpu(sb->fat_sector_count)) >> get_spc_bits()));
|
||||
sb->rootdir_cluster = cpu_to_le32(
|
||||
(get_position(&rootdir) - get_position(&cbm)) / get_cluster_size()
|
||||
+ EXFAT_FIRST_DATA_CLUSTER);
|
||||
sb->volume_serial = cpu_to_le32(get_volume_serial());
|
||||
sb->version.major = 1;
|
||||
sb->version.minor = 0;
|
||||
sb->volume_state = cpu_to_le16(0);
|
||||
sb->sector_bits = get_sector_bits();
|
||||
sb->spc_bits = get_spc_bits();
|
||||
sb->fat_count = 1;
|
||||
sb->drive_no = 0x80;
|
||||
sb->allocated_percent = 0;
|
||||
sb->boot_signature = cpu_to_le16(0xaa55);
|
||||
}
|
||||
|
||||
static int vbr_write(struct exfat_dev* dev)
|
||||
{
|
||||
struct exfat_super_block sb;
|
||||
uint32_t checksum;
|
||||
le32_t* sector = malloc(get_sector_size());
|
||||
size_t i;
|
||||
|
||||
if (sector == NULL)
|
||||
{
|
||||
exfat_error("failed to allocate sector-sized block of memory");
|
||||
return 1;
|
||||
}
|
||||
|
||||
init_sb(&sb);
|
||||
if (exfat_write(dev, &sb, sizeof(struct exfat_super_block)) < 0)
|
||||
{
|
||||
free(sector);
|
||||
exfat_error("failed to write super block sector");
|
||||
return 1;
|
||||
}
|
||||
checksum = exfat_vbr_start_checksum(&sb, sizeof(struct exfat_super_block));
|
||||
|
||||
memset(sector, 0, get_sector_size());
|
||||
sector[get_sector_size() / sizeof(sector[0]) - 1] =
|
||||
cpu_to_le32(0xaa550000);
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
if (exfat_write(dev, sector, get_sector_size()) < 0)
|
||||
{
|
||||
free(sector);
|
||||
exfat_error("failed to write a sector with boot signature");
|
||||
return 1;
|
||||
}
|
||||
checksum = exfat_vbr_add_checksum(sector, get_sector_size(), checksum);
|
||||
}
|
||||
|
||||
memset(sector, 0, get_sector_size());
|
||||
for (i = 0; i < 2; i++)
|
||||
{
|
||||
if (exfat_write(dev, sector, get_sector_size()) < 0)
|
||||
{
|
||||
free(sector);
|
||||
exfat_error("failed to write an empty sector");
|
||||
return 1;
|
||||
}
|
||||
checksum = exfat_vbr_add_checksum(sector, get_sector_size(), checksum);
|
||||
}
|
||||
|
||||
for (i = 0; i < get_sector_size() / sizeof(sector[0]); i++)
|
||||
sector[i] = cpu_to_le32(checksum);
|
||||
if (exfat_write(dev, sector, get_sector_size()) < 0)
|
||||
{
|
||||
free(sector);
|
||||
exfat_error("failed to write checksum sector");
|
||||
return 1;
|
||||
}
|
||||
|
||||
free(sector);
|
||||
return 0;
|
||||
}
|
||||
|
||||
const struct fs_object vbr =
|
||||
{
|
||||
.get_alignment = vbr_alignment,
|
||||
.get_size = vbr_size,
|
||||
.write = vbr_write,
|
||||
};
|
28
exfat/mkfs/vbr.h
Normal file
28
exfat/mkfs/vbr.h
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
vbr.h (09.11.10)
|
||||
Volume Boot Record creation code.
|
||||
|
||||
Copyright (C) 2011, 2012 Andrew Nayenko
|
||||
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#ifndef MKFS_VBR_H_INCLUDED
|
||||
#define MKFS_VBR_H_INCLUDED
|
||||
|
||||
#include "mkexfat.h"
|
||||
|
||||
extern const struct fs_object vbr;
|
||||
|
||||
#endif /* ifndef MKFS_VBR_H_INCLUDED */
|
@ -220,44 +220,6 @@ int fixPermissions::pchmod(string fn, string mode) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fixPermissions::removeDir(const string path) {
|
||||
DIR *d = opendir(path.c_str());
|
||||
int r = 0;
|
||||
string new_path;
|
||||
|
||||
if (d == NULL) {
|
||||
LOGE("Error opening '%s'\n", path.c_str());
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (d) {
|
||||
struct dirent *p;
|
||||
while (!r && (p = readdir(d))) {
|
||||
if (!strcmp(p->d_name, ".") || !strcmp(p->d_name, ".."))
|
||||
continue;
|
||||
|
||||
new_path = path + "/";
|
||||
new_path.append(p->d_name);
|
||||
if (p->d_type == DT_DIR) {
|
||||
r = removeDir(new_path);
|
||||
if (!r)
|
||||
LOGI("Unable to removeDir '%s'\n", new_path.c_str());
|
||||
} else {
|
||||
r = unlink(new_path.c_str());
|
||||
if (!r)
|
||||
LOGI("Unable to unlink '%s'\n", new_path.c_str());
|
||||
}
|
||||
}
|
||||
closedir(d);
|
||||
}
|
||||
if (!r)
|
||||
r = rmdir(path.c_str());
|
||||
if (!r)
|
||||
LOGI("Unable to rmdir '%s'\n", path.c_str());
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
int fixPermissions::fixSystemApps() {
|
||||
temp = head;
|
||||
while (temp != NULL) {
|
||||
@ -279,7 +241,7 @@ int fixPermissions::fixSystemApps() {
|
||||
if (remove_data && TWFunc::Path_Exists(temp->dDir) && temp->appDir.size() >= 9 && temp->appDir.substr(0, 9) != "/mnt/asec") {
|
||||
if (debug)
|
||||
LOGI("Looking at '%s', removing data dir: '%s', appDir: '%s'", temp->codePath.c_str(), temp->dDir.c_str(), temp->appDir.c_str());
|
||||
if (removeDir(temp->dDir) != 0) {
|
||||
if (TWFunc::removeDir(temp->dDir, false) != 0) {
|
||||
LOGI("Unable to removeDir '%s'\n", temp->dDir.c_str());
|
||||
return -1;
|
||||
}
|
||||
@ -325,7 +287,7 @@ int fixPermissions::fixDataApps() {
|
||||
if (remove_data && TWFunc::Path_Exists(temp->dDir) && temp->appDir.size() >= 9 && temp->appDir.substr(0, 9) != "/mnt/asec") {
|
||||
if (debug)
|
||||
LOGI("Looking at '%s', removing data dir: '%s', appDir: '%s'", temp->codePath.c_str(), temp->dDir.c_str(), temp->appDir.c_str());
|
||||
if (removeDir(temp->dDir) != 0) {
|
||||
if (TWFunc::removeDir(temp->dDir, false) != 0) {
|
||||
LOGI("Unable to removeDir '%s'\n", temp->dDir.c_str());
|
||||
return -1;
|
||||
}
|
||||
|
@ -22,7 +22,6 @@ class fixPermissions {
|
||||
int pchmod(std::string fn, string mode);
|
||||
vector <string> listAllDirectories(std::string path);
|
||||
vector <string> listAllFiles(std::string path);
|
||||
int removeDir(const std::string path);
|
||||
int getPackages();
|
||||
int fixSystemApps();
|
||||
int fixDataApps();
|
||||
|
65
fuse/Android.mk
Normal file
65
fuse/Android.mk
Normal file
@ -0,0 +1,65 @@
|
||||
# Copyright (C) 2009 The Android Open Source Project
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_SRC_FILES := \
|
||||
cuse_lowlevel.c \
|
||||
fuse.c \
|
||||
fuse_kern_chan.c \
|
||||
fuse_loop.c \
|
||||
fuse_loop_mt.c \
|
||||
fuse_lowlevel.c \
|
||||
fuse_mt.c fuse_opt.c \
|
||||
fuse_session.c \
|
||||
fuse_signals.c \
|
||||
helper.c \
|
||||
mount.c \
|
||||
mount_util.c \
|
||||
ulockmgr.c
|
||||
|
||||
LOCAL_C_INCLUDES := \
|
||||
$(LOCAL_PATH)/include
|
||||
|
||||
LOCAL_SHARED_LIBRARIES := \
|
||||
libutils libdl
|
||||
|
||||
LOCAL_CFLAGS := \
|
||||
-D_FILE_OFFSET_BITS=64 \
|
||||
-DFUSE_USE_VERSION=26
|
||||
|
||||
LOCAL_MODULE := libfuse
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
|
||||
include $(BUILD_STATIC_LIBRARY)
|
||||
#include $(BUILD_SHARED_LIBRARY)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_SRC_FILES := \
|
||||
fusexmp.c
|
||||
|
||||
LOCAL_C_INCLUDES := \
|
||||
$(LOCAL_PATH)/include
|
||||
|
||||
LOCAL_CFLAGS := -D_FILE_OFFSET_BITS=64
|
||||
|
||||
LOCAL_MODULE := fusexmp
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
|
||||
LOCAL_STATIC_LIBRARIES := libfuse
|
||||
|
||||
include $(BUILD_EXECUTABLE)
|
12
fuse/README
Normal file
12
fuse/README
Normal file
@ -0,0 +1,12 @@
|
||||
Libfuse for Android
|
||||
|
||||
FUSE[1] is a framework to develop userspace file systems for linux. Since Android is based on linux, it won't be too difficult to port libfuse to Android.
|
||||
|
||||
The main problem of building and running libfuse on Android is that the bionic c library lacks support for pthread_cancel(), which is necessary for libfuse multi-thread code. This stackoverflow entry[2] has suggested a solution, which uses SIGUSR1 as an alternative. It seems to work.
|
||||
|
||||
Libfuse can be build with Android NDK[3]. If success, you will get libfuse.a and an example program fusexmp. To run the example, the android kernel should be built with FUSE kernel support.
|
||||
|
||||
References:
|
||||
[1]. http://fuse.sourceforge.net
|
||||
[2]. http://stackoverflow.com/questions/4610086/pthread-cancel-alternatives-in-android-ndk
|
||||
[3]. http://developer.android.com/sdk/ndk/index.html
|
371
fuse/cuse_lowlevel.c
Normal file
371
fuse/cuse_lowlevel.c
Normal file
@ -0,0 +1,371 @@
|
||||
/*
|
||||
CUSE: Character device in Userspace
|
||||
Copyright (C) 2008 SUSE Linux Products GmbH
|
||||
Copyright (C) 2008 Tejun Heo <teheo@suse.de>
|
||||
|
||||
This program can be distributed under the terms of the GNU LGPLv2.
|
||||
See the file COPYING.LIB.
|
||||
*/
|
||||
|
||||
#include "cuse_lowlevel.h"
|
||||
#include "fuse_kernel.h"
|
||||
#include "fuse_i.h"
|
||||
#include "fuse_opt.h"
|
||||
#include "fuse_misc.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
|
||||
struct cuse_data {
|
||||
struct cuse_lowlevel_ops clop;
|
||||
unsigned max_read;
|
||||
unsigned dev_major;
|
||||
unsigned dev_minor;
|
||||
unsigned flags;
|
||||
unsigned dev_info_len;
|
||||
char dev_info[];
|
||||
};
|
||||
|
||||
static struct cuse_lowlevel_ops *req_clop(fuse_req_t req)
|
||||
{
|
||||
return &req->f->cuse_data->clop;
|
||||
}
|
||||
|
||||
static void cuse_fll_open(fuse_req_t req, fuse_ino_t ino,
|
||||
struct fuse_file_info *fi)
|
||||
{
|
||||
(void)ino;
|
||||
req_clop(req)->open(req, fi);
|
||||
}
|
||||
|
||||
static void cuse_fll_read(fuse_req_t req, fuse_ino_t ino, size_t size,
|
||||
off64_t off, struct fuse_file_info *fi)
|
||||
{
|
||||
(void)ino;
|
||||
req_clop(req)->read(req, size, off, fi);
|
||||
}
|
||||
|
||||
static void cuse_fll_write(fuse_req_t req, fuse_ino_t ino, const char *buf,
|
||||
size_t size, off64_t off, struct fuse_file_info *fi)
|
||||
{
|
||||
(void)ino;
|
||||
req_clop(req)->write(req, buf, size, off, fi);
|
||||
}
|
||||
|
||||
static void cuse_fll_flush(fuse_req_t req, fuse_ino_t ino,
|
||||
struct fuse_file_info *fi)
|
||||
{
|
||||
(void)ino;
|
||||
req_clop(req)->flush(req, fi);
|
||||
}
|
||||
|
||||
static void cuse_fll_release(fuse_req_t req, fuse_ino_t ino,
|
||||
struct fuse_file_info *fi)
|
||||
{
|
||||
(void)ino;
|
||||
req_clop(req)->release(req, fi);
|
||||
}
|
||||
|
||||
static void cuse_fll_fsync(fuse_req_t req, fuse_ino_t ino, int datasync,
|
||||
struct fuse_file_info *fi)
|
||||
{
|
||||
(void)ino;
|
||||
req_clop(req)->fsync(req, datasync, fi);
|
||||
}
|
||||
|
||||
static void cuse_fll_ioctl(fuse_req_t req, fuse_ino_t ino, int cmd, void *arg,
|
||||
struct fuse_file_info *fi, unsigned int flags,
|
||||
const void *in_buf, size_t in_bufsz, size_t out_bufsz)
|
||||
{
|
||||
(void)ino;
|
||||
req_clop(req)->ioctl(req, cmd, arg, fi, flags, in_buf, in_bufsz,
|
||||
out_bufsz);
|
||||
}
|
||||
|
||||
static void cuse_fll_poll(fuse_req_t req, fuse_ino_t ino,
|
||||
struct fuse_file_info *fi, struct fuse_pollhandle *ph)
|
||||
{
|
||||
(void)ino;
|
||||
req_clop(req)->poll(req, fi, ph);
|
||||
}
|
||||
|
||||
static size_t cuse_pack_info(int argc, const char **argv, char *buf)
|
||||
{
|
||||
size_t size = 0;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < argc; i++) {
|
||||
size_t len;
|
||||
|
||||
len = strlen(argv[i]) + 1;
|
||||
size += len;
|
||||
if (buf) {
|
||||
memcpy(buf, argv[i], len);
|
||||
buf += len;
|
||||
}
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
static struct cuse_data *cuse_prep_data(const struct cuse_info *ci,
|
||||
const struct cuse_lowlevel_ops *clop)
|
||||
{
|
||||
struct cuse_data *cd;
|
||||
size_t dev_info_len;
|
||||
|
||||
dev_info_len = cuse_pack_info(ci->dev_info_argc, ci->dev_info_argv,
|
||||
NULL);
|
||||
|
||||
if (dev_info_len > CUSE_INIT_INFO_MAX) {
|
||||
fprintf(stderr, "cuse: dev_info (%zu) too large, limit=%u\n",
|
||||
dev_info_len, CUSE_INIT_INFO_MAX);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cd = calloc(1, sizeof(*cd) + dev_info_len);
|
||||
if (!cd) {
|
||||
fprintf(stderr, "cuse: failed to allocate cuse_data\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memcpy(&cd->clop, clop, sizeof(cd->clop));
|
||||
cd->max_read = 131072;
|
||||
cd->dev_major = ci->dev_major;
|
||||
cd->dev_minor = ci->dev_minor;
|
||||
cd->dev_info_len = dev_info_len;
|
||||
cd->flags = ci->flags;
|
||||
cuse_pack_info(ci->dev_info_argc, ci->dev_info_argv, cd->dev_info);
|
||||
|
||||
return cd;
|
||||
}
|
||||
|
||||
struct fuse_session *cuse_lowlevel_new(struct fuse_args *args,
|
||||
const struct cuse_info *ci,
|
||||
const struct cuse_lowlevel_ops *clop,
|
||||
void *userdata)
|
||||
{
|
||||
struct fuse_lowlevel_ops lop;
|
||||
struct cuse_data *cd;
|
||||
struct fuse_session *se;
|
||||
struct fuse_ll *ll;
|
||||
|
||||
cd = cuse_prep_data(ci, clop);
|
||||
if (!cd)
|
||||
return NULL;
|
||||
|
||||
memset(&lop, 0, sizeof(lop));
|
||||
lop.init = clop->init;
|
||||
lop.destroy = clop->destroy;
|
||||
lop.open = clop->open ? cuse_fll_open : NULL;
|
||||
lop.read = clop->read ? cuse_fll_read : NULL;
|
||||
lop.write = clop->write ? cuse_fll_write : NULL;
|
||||
lop.flush = clop->flush ? cuse_fll_flush : NULL;
|
||||
lop.release = clop->release ? cuse_fll_release : NULL;
|
||||
lop.fsync = clop->fsync ? cuse_fll_fsync : NULL;
|
||||
lop.ioctl = clop->ioctl ? cuse_fll_ioctl : NULL;
|
||||
lop.poll = clop->poll ? cuse_fll_poll : NULL;
|
||||
|
||||
se = fuse_lowlevel_new_common(args, &lop, sizeof(lop), userdata);
|
||||
if (!se) {
|
||||
free(cd);
|
||||
return NULL;
|
||||
}
|
||||
ll = se->data;
|
||||
ll->cuse_data = cd;
|
||||
|
||||
return se;
|
||||
}
|
||||
|
||||
static int cuse_reply_init(fuse_req_t req, struct cuse_init_out *arg,
|
||||
char *dev_info, unsigned dev_info_len)
|
||||
{
|
||||
struct iovec iov[3];
|
||||
|
||||
iov[1].iov_base = arg;
|
||||
iov[1].iov_len = sizeof(struct cuse_init_out);
|
||||
iov[2].iov_base = dev_info;
|
||||
iov[2].iov_len = dev_info_len;
|
||||
|
||||
return fuse_send_reply_iov_nofree(req, 0, iov, 3);
|
||||
}
|
||||
|
||||
void cuse_lowlevel_init(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
|
||||
{
|
||||
struct fuse_init_in *arg = (struct fuse_init_in *) inarg;
|
||||
struct cuse_init_out outarg;
|
||||
struct fuse_ll *f = req->f;
|
||||
struct cuse_data *cd = f->cuse_data;
|
||||
size_t bufsize = fuse_chan_bufsize(req->ch);
|
||||
struct cuse_lowlevel_ops *clop = req_clop(req);
|
||||
|
||||
(void) nodeid;
|
||||
if (f->debug) {
|
||||
fprintf(stderr, "CUSE_INIT: %u.%u\n", arg->major, arg->minor);
|
||||
fprintf(stderr, "flags=0x%08x\n", arg->flags);
|
||||
}
|
||||
f->conn.proto_major = arg->major;
|
||||
f->conn.proto_minor = arg->minor;
|
||||
f->conn.capable = 0;
|
||||
f->conn.want = 0;
|
||||
|
||||
if (arg->major < 7) {
|
||||
fprintf(stderr, "fuse: unsupported protocol version: %u.%u\n",
|
||||
arg->major, arg->minor);
|
||||
fuse_reply_err(req, EPROTO);
|
||||
return;
|
||||
}
|
||||
|
||||
if (bufsize < FUSE_MIN_READ_BUFFER) {
|
||||
fprintf(stderr, "fuse: warning: buffer size too small: %zu\n",
|
||||
bufsize);
|
||||
bufsize = FUSE_MIN_READ_BUFFER;
|
||||
}
|
||||
|
||||
bufsize -= 4096;
|
||||
if (bufsize < f->conn.max_write)
|
||||
f->conn.max_write = bufsize;
|
||||
|
||||
f->got_init = 1;
|
||||
if (f->op.init)
|
||||
f->op.init(f->userdata, &f->conn);
|
||||
|
||||
memset(&outarg, 0, sizeof(outarg));
|
||||
outarg.major = FUSE_KERNEL_VERSION;
|
||||
outarg.minor = FUSE_KERNEL_MINOR_VERSION;
|
||||
outarg.flags = cd->flags;
|
||||
outarg.max_read = cd->max_read;
|
||||
outarg.max_write = f->conn.max_write;
|
||||
outarg.dev_major = cd->dev_major;
|
||||
outarg.dev_minor = cd->dev_minor;
|
||||
|
||||
if (f->debug) {
|
||||
fprintf(stderr, " CUSE_INIT: %u.%u\n",
|
||||
outarg.major, outarg.minor);
|
||||
fprintf(stderr, " flags=0x%08x\n", outarg.flags);
|
||||
fprintf(stderr, " max_read=0x%08x\n", outarg.max_read);
|
||||
fprintf(stderr, " max_write=0x%08x\n", outarg.max_write);
|
||||
fprintf(stderr, " dev_major=%u\n", outarg.dev_major);
|
||||
fprintf(stderr, " dev_minor=%u\n", outarg.dev_minor);
|
||||
fprintf(stderr, " dev_info: %.*s\n", cd->dev_info_len,
|
||||
cd->dev_info);
|
||||
}
|
||||
|
||||
cuse_reply_init(req, &outarg, cd->dev_info, cd->dev_info_len);
|
||||
|
||||
if (clop->init_done)
|
||||
clop->init_done(f->userdata);
|
||||
|
||||
fuse_free_req(req);
|
||||
}
|
||||
|
||||
struct fuse_session *cuse_lowlevel_setup(int argc, char *argv[],
|
||||
const struct cuse_info *ci,
|
||||
const struct cuse_lowlevel_ops *clop,
|
||||
int *multithreaded, void *userdata)
|
||||
{
|
||||
const char *devname = "/dev/cuse";
|
||||
static const struct fuse_opt kill_subtype_opts[] = {
|
||||
FUSE_OPT_KEY("subtype=", FUSE_OPT_KEY_DISCARD),
|
||||
FUSE_OPT_END
|
||||
};
|
||||
struct fuse_args args = FUSE_ARGS_INIT(argc, argv);
|
||||
struct fuse_session *se;
|
||||
struct fuse_chan *ch;
|
||||
int fd;
|
||||
int foreground;
|
||||
int res;
|
||||
|
||||
res = fuse_parse_cmdline(&args, NULL, multithreaded, &foreground);
|
||||
if (res == -1)
|
||||
goto err_args;
|
||||
|
||||
res = fuse_opt_parse(&args, NULL, kill_subtype_opts, NULL);
|
||||
if (res == -1)
|
||||
goto err_args;
|
||||
|
||||
/*
|
||||
* Make sure file descriptors 0, 1 and 2 are open, otherwise chaos
|
||||
* would ensue.
|
||||
*/
|
||||
do {
|
||||
fd = open("/dev/null", O_RDWR);
|
||||
if (fd > 2)
|
||||
close(fd);
|
||||
} while (fd >= 0 && fd <= 2);
|
||||
|
||||
se = cuse_lowlevel_new(&args, ci, clop, userdata);
|
||||
fuse_opt_free_args(&args);
|
||||
if (se == NULL)
|
||||
goto err_args;
|
||||
|
||||
fd = open(devname, O_RDWR);
|
||||
if (fd == -1) {
|
||||
if (errno == ENODEV || errno == ENOENT)
|
||||
fprintf(stderr, "fuse: device not found, try 'modprobe cuse' first\n");
|
||||
else
|
||||
fprintf(stderr, "fuse: failed to open %s: %s\n",
|
||||
devname, strerror(errno));
|
||||
goto err_se;
|
||||
}
|
||||
|
||||
ch = fuse_kern_chan_new(fd);
|
||||
if (!ch) {
|
||||
close(fd);
|
||||
goto err_se;
|
||||
}
|
||||
|
||||
fuse_session_add_chan(se, ch);
|
||||
|
||||
res = fuse_set_signal_handlers(se);
|
||||
if (res == -1)
|
||||
goto err_se;
|
||||
|
||||
res = fuse_daemonize(foreground);
|
||||
if (res == -1)
|
||||
goto err_sig;
|
||||
|
||||
return se;
|
||||
|
||||
err_sig:
|
||||
fuse_remove_signal_handlers(se);
|
||||
err_se:
|
||||
fuse_session_destroy(se);
|
||||
err_args:
|
||||
fuse_opt_free_args(&args);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void cuse_lowlevel_teardown(struct fuse_session *se)
|
||||
{
|
||||
fuse_remove_signal_handlers(se);
|
||||
fuse_session_destroy(se);
|
||||
}
|
||||
|
||||
int cuse_lowlevel_main(int argc, char *argv[], const struct cuse_info *ci,
|
||||
const struct cuse_lowlevel_ops *clop, void *userdata)
|
||||
{
|
||||
struct fuse_session *se;
|
||||
int multithreaded;
|
||||
int res;
|
||||
|
||||
se = cuse_lowlevel_setup(argc, argv, ci, clop, &multithreaded,
|
||||
userdata);
|
||||
if (se == NULL)
|
||||
return 1;
|
||||
|
||||
if (multithreaded)
|
||||
res = fuse_session_loop_mt(se);
|
||||
else
|
||||
res = fuse_session_loop(se);
|
||||
|
||||
cuse_lowlevel_teardown(se);
|
||||
if (res == -1)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
3968
fuse/fuse.c
Normal file
3968
fuse/fuse.c
Normal file
File diff suppressed because it is too large
Load Diff
101
fuse/fuse_i.h
Normal file
101
fuse/fuse_i.h
Normal file
@ -0,0 +1,101 @@
|
||||
/*
|
||||
FUSE: Filesystem in Userspace
|
||||
Copyright (C) 2001-2007 Miklos Szeredi <miklos@szeredi.hu>
|
||||
|
||||
This program can be distributed under the terms of the GNU LGPLv2.
|
||||
See the file COPYING.LIB
|
||||
*/
|
||||
|
||||
#include "fuse.h"
|
||||
#include "fuse_lowlevel.h"
|
||||
#include <pthread.h>
|
||||
|
||||
struct fuse_chan;
|
||||
struct fuse_ll;
|
||||
|
||||
struct fuse_session {
|
||||
struct fuse_session_ops op;
|
||||
|
||||
void *data;
|
||||
|
||||
volatile int exited;
|
||||
|
||||
struct fuse_chan *ch;
|
||||
};
|
||||
|
||||
struct fuse_req {
|
||||
struct fuse_ll *f;
|
||||
uint64_t unique;
|
||||
int ctr;
|
||||
pthread_mutex_t lock;
|
||||
struct fuse_ctx ctx;
|
||||
struct fuse_chan *ch;
|
||||
int interrupted;
|
||||
union {
|
||||
struct {
|
||||
uint64_t unique;
|
||||
} i;
|
||||
struct {
|
||||
fuse_interrupt_func_t func;
|
||||
void *data;
|
||||
} ni;
|
||||
} u;
|
||||
struct fuse_req *next;
|
||||
struct fuse_req *prev;
|
||||
};
|
||||
|
||||
struct fuse_ll {
|
||||
int debug;
|
||||
int allow_root;
|
||||
int atomic_o_trunc;
|
||||
int no_remote_lock;
|
||||
int big_writes;
|
||||
struct fuse_lowlevel_ops op;
|
||||
int got_init;
|
||||
struct cuse_data *cuse_data;
|
||||
void *userdata;
|
||||
uid_t owner;
|
||||
struct fuse_conn_info conn;
|
||||
struct fuse_req list;
|
||||
struct fuse_req interrupts;
|
||||
pthread_mutex_t lock;
|
||||
int got_destroy;
|
||||
};
|
||||
|
||||
struct fuse_cmd {
|
||||
char *buf;
|
||||
size_t buflen;
|
||||
struct fuse_chan *ch;
|
||||
};
|
||||
|
||||
struct fuse *fuse_new_common(struct fuse_chan *ch, struct fuse_args *args,
|
||||
const struct fuse_operations *op,
|
||||
size_t op_size, void *user_data, int compat);
|
||||
|
||||
int fuse_sync_compat_args(struct fuse_args *args);
|
||||
|
||||
struct fuse_chan *fuse_kern_chan_new(int fd);
|
||||
|
||||
struct fuse_session *fuse_lowlevel_new_common(struct fuse_args *args,
|
||||
const struct fuse_lowlevel_ops *op,
|
||||
size_t op_size, void *userdata);
|
||||
|
||||
void fuse_kern_unmount_compat22(const char *mountpoint);
|
||||
void fuse_kern_unmount(const char *mountpoint, int fd);
|
||||
int fuse_kern_mount(const char *mountpoint, struct fuse_args *args);
|
||||
|
||||
int fuse_send_reply_iov_nofree(fuse_req_t req, int error, struct iovec *iov,
|
||||
int count);
|
||||
void fuse_free_req(fuse_req_t req);
|
||||
|
||||
|
||||
struct fuse *fuse_setup_common(int argc, char *argv[],
|
||||
const struct fuse_operations *op,
|
||||
size_t op_size,
|
||||
char **mountpoint,
|
||||
int *multithreaded,
|
||||
int *fd,
|
||||
void *user_data,
|
||||
int compat);
|
||||
|
||||
void cuse_lowlevel_init(fuse_req_t req, fuse_ino_t nodeide, const void *inarg);
|
95
fuse/fuse_kern_chan.c
Normal file
95
fuse/fuse_kern_chan.c
Normal file
@ -0,0 +1,95 @@
|
||||
/*
|
||||
FUSE: Filesystem in Userspace
|
||||
Copyright (C) 2001-2007 Miklos Szeredi <miklos@szeredi.hu>
|
||||
|
||||
This program can be distributed under the terms of the GNU LGPLv2.
|
||||
See the file COPYING.LIB
|
||||
*/
|
||||
|
||||
#include "fuse_lowlevel.h"
|
||||
#include "fuse_kernel.h"
|
||||
#include "fuse_i.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <assert.h>
|
||||
|
||||
static int fuse_kern_chan_receive(struct fuse_chan **chp, char *buf,
|
||||
size_t size)
|
||||
{
|
||||
struct fuse_chan *ch = *chp;
|
||||
int err;
|
||||
ssize_t res;
|
||||
struct fuse_session *se = fuse_chan_session(ch);
|
||||
assert(se != NULL);
|
||||
|
||||
restart:
|
||||
res = read(fuse_chan_fd(ch), buf, size);
|
||||
err = errno;
|
||||
|
||||
if (fuse_session_exited(se))
|
||||
return 0;
|
||||
if (res == -1) {
|
||||
/* ENOENT means the operation was interrupted, it's safe
|
||||
to restart */
|
||||
if (err == ENOENT)
|
||||
goto restart;
|
||||
|
||||
if (err == ENODEV) {
|
||||
fuse_session_exit(se);
|
||||
return 0;
|
||||
}
|
||||
/* Errors occuring during normal operation: EINTR (read
|
||||
interrupted), EAGAIN (nonblocking I/O), ENODEV (filesystem
|
||||
umounted) */
|
||||
if (err != EINTR && err != EAGAIN)
|
||||
perror("fuse: reading device");
|
||||
return -err;
|
||||
}
|
||||
if ((size_t) res < sizeof(struct fuse_in_header)) {
|
||||
fprintf(stderr, "short read on fuse device\n");
|
||||
return -EIO;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
static int fuse_kern_chan_send(struct fuse_chan *ch, const struct iovec iov[],
|
||||
size_t count)
|
||||
{
|
||||
if (iov) {
|
||||
ssize_t res = writev(fuse_chan_fd(ch), iov, count);
|
||||
int err = errno;
|
||||
|
||||
if (res == -1) {
|
||||
struct fuse_session *se = fuse_chan_session(ch);
|
||||
|
||||
assert(se != NULL);
|
||||
|
||||
/* ENOENT means the operation was interrupted */
|
||||
if (!fuse_session_exited(se) && err != ENOENT)
|
||||
perror("fuse: writing device");
|
||||
return -err;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void fuse_kern_chan_destroy(struct fuse_chan *ch)
|
||||
{
|
||||
close(fuse_chan_fd(ch));
|
||||
}
|
||||
|
||||
#define MIN_BUFSIZE 0x21000
|
||||
|
||||
struct fuse_chan *fuse_kern_chan_new(int fd)
|
||||
{
|
||||
struct fuse_chan_ops op = {
|
||||
.receive = fuse_kern_chan_receive,
|
||||
.send = fuse_kern_chan_send,
|
||||
.destroy = fuse_kern_chan_destroy,
|
||||
};
|
||||
size_t bufsize = getpagesize() + 0x1000;
|
||||
bufsize = bufsize < MIN_BUFSIZE ? MIN_BUFSIZE : bufsize;
|
||||
return fuse_chan_new(&op, fd, bufsize, NULL);
|
||||
}
|
39
fuse/fuse_loop.c
Normal file
39
fuse/fuse_loop.c
Normal file
@ -0,0 +1,39 @@
|
||||
/*
|
||||
FUSE: Filesystem in Userspace
|
||||
Copyright (C) 2001-2007 Miklos Szeredi <miklos@szeredi.hu>
|
||||
|
||||
This program can be distributed under the terms of the GNU LGPLv2.
|
||||
See the file COPYING.LIB
|
||||
*/
|
||||
|
||||
#include "fuse_lowlevel.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
|
||||
int fuse_session_loop(struct fuse_session *se)
|
||||
{
|
||||
int res = 0;
|
||||
struct fuse_chan *ch = fuse_session_next_chan(se, NULL);
|
||||
size_t bufsize = fuse_chan_bufsize(ch);
|
||||
char *buf = (char *) malloc(bufsize);
|
||||
if (!buf) {
|
||||
fprintf(stderr, "fuse: failed to allocate read buffer\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
while (!fuse_session_exited(se)) {
|
||||
struct fuse_chan *tmpch = ch;
|
||||
res = fuse_chan_recv(&tmpch, buf, bufsize);
|
||||
if (res == -EINTR)
|
||||
continue;
|
||||
if (res <= 0)
|
||||
break;
|
||||
fuse_session_process(se, buf, res, tmpch);
|
||||
}
|
||||
|
||||
free(buf);
|
||||
fuse_session_reset(se);
|
||||
return res < 0 ? -1 : 0;
|
||||
}
|
246
fuse/fuse_loop_mt.c
Normal file
246
fuse/fuse_loop_mt.c
Normal file
@ -0,0 +1,246 @@
|
||||
/*
|
||||
FUSE: Filesystem in Userspace
|
||||
Copyright (C) 2001-2007 Miklos Szeredi <miklos@szeredi.hu>
|
||||
|
||||
This program can be distributed under the terms of the GNU LGPLv2.
|
||||
See the file COPYING.LIB.
|
||||
*/
|
||||
|
||||
#include "fuse_lowlevel.h"
|
||||
#include "fuse_misc.h"
|
||||
#include "fuse_kernel.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include <semaphore.h>
|
||||
#include <errno.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#ifdef __MULTI_THREAD
|
||||
|
||||
/* Environment var controlling the thread stack size */
|
||||
#define ENVNAME_THREAD_STACK "FUSE_THREAD_STACK"
|
||||
|
||||
struct fuse_worker {
|
||||
struct fuse_worker *prev;
|
||||
struct fuse_worker *next;
|
||||
pthread_t thread_id;
|
||||
size_t bufsize;
|
||||
char *buf;
|
||||
struct fuse_mt *mt;
|
||||
};
|
||||
|
||||
struct fuse_mt {
|
||||
pthread_mutex_t lock;
|
||||
int numworker;
|
||||
int numavail;
|
||||
struct fuse_session *se;
|
||||
struct fuse_chan *prevch;
|
||||
struct fuse_worker main;
|
||||
sem_t finish;
|
||||
int exit;
|
||||
int error;
|
||||
};
|
||||
|
||||
static void list_add_worker(struct fuse_worker *w, struct fuse_worker *next)
|
||||
{
|
||||
struct fuse_worker *prev = next->prev;
|
||||
w->next = next;
|
||||
w->prev = prev;
|
||||
prev->next = w;
|
||||
next->prev = w;
|
||||
}
|
||||
|
||||
static void list_del_worker(struct fuse_worker *w)
|
||||
{
|
||||
struct fuse_worker *prev = w->prev;
|
||||
struct fuse_worker *next = w->next;
|
||||
prev->next = next;
|
||||
next->prev = prev;
|
||||
}
|
||||
|
||||
#define PTHREAD_CANCEL_ENABLE 0
|
||||
#define PTHREAD_CANCEL_DISABLE 1
|
||||
|
||||
static int fuse_start_thread(struct fuse_mt *mt);
|
||||
|
||||
static void *fuse_do_work(void *data)
|
||||
{
|
||||
struct fuse_worker *w = (struct fuse_worker *) data;
|
||||
struct fuse_mt *mt = w->mt;
|
||||
|
||||
while (!fuse_session_exited(mt->se)) {
|
||||
int isforget = 0;
|
||||
struct fuse_chan *ch = mt->prevch;
|
||||
int res;
|
||||
|
||||
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
|
||||
res = fuse_chan_recv(&ch, w->buf, w->bufsize);
|
||||
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
|
||||
if (res == -EINTR)
|
||||
continue;
|
||||
if (res <= 0) {
|
||||
if (res < 0) {
|
||||
fuse_session_exit(mt->se);
|
||||
mt->error = -1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
pthread_mutex_lock(&mt->lock);
|
||||
if (mt->exit) {
|
||||
pthread_mutex_unlock(&mt->lock);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* This disgusting hack is needed so that zillions of threads
|
||||
* are not created on a burst of FORGET messages
|
||||
*/
|
||||
if (((struct fuse_in_header *) w->buf)->opcode == FUSE_FORGET)
|
||||
isforget = 1;
|
||||
|
||||
if (!isforget)
|
||||
mt->numavail--;
|
||||
if (mt->numavail == 0)
|
||||
fuse_start_thread(mt);
|
||||
pthread_mutex_unlock(&mt->lock);
|
||||
|
||||
fuse_session_process(mt->se, w->buf, res, ch);
|
||||
|
||||
pthread_mutex_lock(&mt->lock);
|
||||
if (!isforget)
|
||||
mt->numavail++;
|
||||
if (mt->numavail > 10) {
|
||||
if (mt->exit) {
|
||||
pthread_mutex_unlock(&mt->lock);
|
||||
return NULL;
|
||||
}
|
||||
list_del_worker(w);
|
||||
mt->numavail--;
|
||||
mt->numworker--;
|
||||
pthread_mutex_unlock(&mt->lock);
|
||||
|
||||
pthread_detach(w->thread_id);
|
||||
free(w->buf);
|
||||
free(w);
|
||||
return NULL;
|
||||
}
|
||||
pthread_mutex_unlock(&mt->lock);
|
||||
}
|
||||
|
||||
sem_post(&mt->finish);
|
||||
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
|
||||
pause();
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int fuse_start_thread(struct fuse_mt *mt)
|
||||
{
|
||||
sigset_t oldset;
|
||||
sigset_t newset;
|
||||
int res;
|
||||
pthread_attr_t attr;
|
||||
char *stack_size;
|
||||
struct fuse_worker *w = malloc(sizeof(struct fuse_worker));
|
||||
if (!w) {
|
||||
fprintf(stderr, "fuse: failed to allocate worker structure\n");
|
||||
return -1;
|
||||
}
|
||||
memset(w, 0, sizeof(struct fuse_worker));
|
||||
w->bufsize = fuse_chan_bufsize(mt->prevch);
|
||||
w->buf = malloc(w->bufsize);
|
||||
w->mt = mt;
|
||||
if (!w->buf) {
|
||||
fprintf(stderr, "fuse: failed to allocate read buffer\n");
|
||||
free(w);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Override default stack size */
|
||||
pthread_attr_init(&attr);
|
||||
stack_size = getenv(ENVNAME_THREAD_STACK);
|
||||
if (stack_size && pthread_attr_setstacksize(&attr, atoi(stack_size)))
|
||||
fprintf(stderr, "fuse: invalid stack size: %s\n", stack_size);
|
||||
|
||||
/* Disallow signal reception in worker threads */
|
||||
sigemptyset(&newset);
|
||||
sigaddset(&newset, SIGTERM);
|
||||
sigaddset(&newset, SIGINT);
|
||||
sigaddset(&newset, SIGHUP);
|
||||
sigaddset(&newset, SIGQUIT);
|
||||
pthread_sigmask(SIG_BLOCK, &newset, &oldset);
|
||||
res = pthread_create(&w->thread_id, &attr, fuse_do_work, w);
|
||||
pthread_sigmask(SIG_SETMASK, &oldset, NULL);
|
||||
pthread_attr_destroy(&attr);
|
||||
if (res != 0) {
|
||||
fprintf(stderr, "fuse: error creating thread: %s\n",
|
||||
strerror(res));
|
||||
free(w->buf);
|
||||
free(w);
|
||||
return -1;
|
||||
}
|
||||
list_add_worker(w, &mt->main);
|
||||
mt->numavail ++;
|
||||
mt->numworker ++;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void fuse_join_worker(struct fuse_mt *mt, struct fuse_worker *w)
|
||||
{
|
||||
pthread_join(w->thread_id, NULL);
|
||||
pthread_mutex_lock(&mt->lock);
|
||||
list_del_worker(w);
|
||||
pthread_mutex_unlock(&mt->lock);
|
||||
free(w->buf);
|
||||
free(w);
|
||||
}
|
||||
|
||||
int fuse_session_loop_mt(struct fuse_session *se)
|
||||
{
|
||||
int err;
|
||||
struct fuse_mt mt;
|
||||
struct fuse_worker *w;
|
||||
|
||||
memset(&mt, 0, sizeof(struct fuse_mt));
|
||||
mt.se = se;
|
||||
mt.prevch = fuse_session_next_chan(se, NULL);
|
||||
mt.error = 0;
|
||||
mt.numworker = 0;
|
||||
mt.numavail = 0;
|
||||
mt.main.thread_id = pthread_self();
|
||||
mt.main.prev = mt.main.next = &mt.main;
|
||||
sem_init(&mt.finish, 0, 0);
|
||||
fuse_mutex_init(&mt.lock);
|
||||
|
||||
pthread_mutex_lock(&mt.lock);
|
||||
err = fuse_start_thread(&mt);
|
||||
pthread_mutex_unlock(&mt.lock);
|
||||
if (!err) {
|
||||
/* sem_wait() is interruptible */
|
||||
while (!fuse_session_exited(se))
|
||||
sem_wait(&mt.finish);
|
||||
|
||||
for (w = mt.main.next; w != &mt.main; w = w->next)
|
||||
pthread_cancel(w->thread_id);
|
||||
mt.exit = 1;
|
||||
pthread_mutex_unlock(&mt.lock);
|
||||
|
||||
while (mt.main.next != &mt.main)
|
||||
fuse_join_worker(&mt, mt.main.next);
|
||||
|
||||
err = mt.error;
|
||||
}
|
||||
|
||||
pthread_mutex_destroy(&mt.lock);
|
||||
sem_destroy(&mt.finish);
|
||||
fuse_session_reset(se);
|
||||
return err;
|
||||
}
|
||||
|
||||
#endif
|
1862
fuse/fuse_lowlevel.c
Normal file
1862
fuse/fuse_lowlevel.c
Normal file
File diff suppressed because it is too large
Load Diff
53
fuse/fuse_misc.h
Normal file
53
fuse/fuse_misc.h
Normal file
@ -0,0 +1,53 @@
|
||||
/*
|
||||
FUSE: Filesystem in Userspace
|
||||
Copyright (C) 2001-2007 Miklos Szeredi <miklos@szeredi.hu>
|
||||
|
||||
This program can be distributed under the terms of the GNU LGPLv2.
|
||||
See the file COPYING.LIB
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <pthread.h>
|
||||
|
||||
/* Versioned symbols confuse the dynamic linker in uClibc */
|
||||
#ifndef __UCLIBC__
|
||||
#define FUSE_SYMVER(x) __asm__(x)
|
||||
#else
|
||||
#define FUSE_SYMVER(x)
|
||||
#endif
|
||||
|
||||
#ifndef USE_UCLIBC
|
||||
#define fuse_mutex_init(mut) pthread_mutex_init(mut, NULL)
|
||||
#else
|
||||
/* Is this hack still needed? */
|
||||
static inline void fuse_mutex_init(pthread_mutex_t *mut)
|
||||
{
|
||||
pthread_mutexattr_t attr;
|
||||
pthread_mutexattr_init(&attr);
|
||||
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ADAPTIVE_NP);
|
||||
pthread_mutex_init(mut, &attr);
|
||||
pthread_mutexattr_destroy(&attr);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRUCT_STAT_ST_ATIM
|
||||
/* Linux */
|
||||
#define ST_ATIM_NSEC(stbuf) ((stbuf)->st_atim.tv_nsec)
|
||||
#define ST_CTIM_NSEC(stbuf) ((stbuf)->st_ctim.tv_nsec)
|
||||
#define ST_MTIM_NSEC(stbuf) ((stbuf)->st_mtim.tv_nsec)
|
||||
#define ST_ATIM_NSEC_SET(stbuf, val) (stbuf)->st_atim.tv_nsec = (val)
|
||||
#define ST_MTIM_NSEC_SET(stbuf, val) (stbuf)->st_mtim.tv_nsec = (val)
|
||||
#elif defined(HAVE_STRUCT_STAT_ST_ATIMESPEC)
|
||||
/* FreeBSD */
|
||||
#define ST_ATIM_NSEC(stbuf) ((stbuf)->st_atimespec.tv_nsec)
|
||||
#define ST_CTIM_NSEC(stbuf) ((stbuf)->st_ctimespec.tv_nsec)
|
||||
#define ST_MTIM_NSEC(stbuf) ((stbuf)->st_mtimespec.tv_nsec)
|
||||
#define ST_ATIM_NSEC_SET(stbuf, val) (stbuf)->st_atimespec.tv_nsec = (val)
|
||||
#define ST_MTIM_NSEC_SET(stbuf, val) (stbuf)->st_mtimespec.tv_nsec = (val)
|
||||
#else
|
||||
#define ST_ATIM_NSEC(stbuf) 0
|
||||
#define ST_CTIM_NSEC(stbuf) 0
|
||||
#define ST_MTIM_NSEC(stbuf) 0
|
||||
#define ST_ATIM_NSEC_SET(stbuf, val) do { } while (0)
|
||||
#define ST_MTIM_NSEC_SET(stbuf, val) do { } while (0)
|
||||
#endif
|
120
fuse/fuse_mt.c
Normal file
120
fuse/fuse_mt.c
Normal file
@ -0,0 +1,120 @@
|
||||
/*
|
||||
FUSE: Filesystem in Userspace
|
||||
Copyright (C) 2001-2007 Miklos Szeredi <miklos@szeredi.hu>
|
||||
|
||||
This program can be distributed under the terms of the GNU LGPLv2.
|
||||
See the file COPYING.LIB.
|
||||
*/
|
||||
|
||||
#include "fuse_i.h"
|
||||
#include "fuse_misc.h"
|
||||
#include "fuse_lowlevel.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <pthread.h>
|
||||
#include <assert.h>
|
||||
|
||||
struct procdata {
|
||||
struct fuse *f;
|
||||
struct fuse_chan *prevch;
|
||||
struct fuse_session *prevse;
|
||||
fuse_processor_t proc;
|
||||
void *data;
|
||||
};
|
||||
|
||||
#ifdef __MULTI_THREAD
|
||||
|
||||
static void mt_session_proc(void *data, const char *buf, size_t len,
|
||||
struct fuse_chan *ch)
|
||||
{
|
||||
struct procdata *pd = (struct procdata *) data;
|
||||
struct fuse_cmd *cmd = *(struct fuse_cmd **) buf;
|
||||
|
||||
(void) len;
|
||||
(void) ch;
|
||||
pd->proc(pd->f, cmd, pd->data);
|
||||
}
|
||||
|
||||
static void mt_session_exit(void *data, int val)
|
||||
{
|
||||
struct procdata *pd = (struct procdata *) data;
|
||||
if (val)
|
||||
fuse_session_exit(pd->prevse);
|
||||
else
|
||||
fuse_session_reset(pd->prevse);
|
||||
}
|
||||
|
||||
static int mt_session_exited(void *data)
|
||||
{
|
||||
struct procdata *pd = (struct procdata *) data;
|
||||
return fuse_session_exited(pd->prevse);
|
||||
}
|
||||
|
||||
static int mt_chan_receive(struct fuse_chan **chp, char *buf, size_t size)
|
||||
{
|
||||
struct fuse_cmd *cmd;
|
||||
struct procdata *pd = (struct procdata *) fuse_chan_data(*chp);
|
||||
|
||||
assert(size >= sizeof(cmd));
|
||||
|
||||
cmd = fuse_read_cmd(pd->f);
|
||||
if (cmd == NULL)
|
||||
return 0;
|
||||
|
||||
*(struct fuse_cmd **) buf = cmd;
|
||||
|
||||
return sizeof(cmd);
|
||||
}
|
||||
|
||||
int fuse_loop_mt_proc(struct fuse *f, fuse_processor_t proc, void *data)
|
||||
{
|
||||
int res;
|
||||
struct procdata pd;
|
||||
struct fuse_session *prevse = fuse_get_session(f);
|
||||
struct fuse_session *se;
|
||||
struct fuse_chan *prevch = fuse_session_next_chan(prevse, NULL);
|
||||
struct fuse_chan *ch;
|
||||
struct fuse_session_ops sop = {
|
||||
.exit = mt_session_exit,
|
||||
.exited = mt_session_exited,
|
||||
.process = mt_session_proc,
|
||||
};
|
||||
struct fuse_chan_ops cop = {
|
||||
.receive = mt_chan_receive,
|
||||
};
|
||||
|
||||
pd.f = f;
|
||||
pd.prevch = prevch;
|
||||
pd.prevse = prevse;
|
||||
pd.proc = proc;
|
||||
pd.data = data;
|
||||
|
||||
se = fuse_session_new(&sop, &pd);
|
||||
if (se == NULL)
|
||||
return -1;
|
||||
|
||||
ch = fuse_chan_new(&cop, fuse_chan_fd(prevch),
|
||||
sizeof(struct fuse_cmd *), &pd);
|
||||
if (ch == NULL) {
|
||||
fuse_session_destroy(se);
|
||||
return -1;
|
||||
}
|
||||
fuse_session_add_chan(se, ch);
|
||||
res = fuse_session_loop_mt(se);
|
||||
fuse_session_destroy(se);
|
||||
return res;
|
||||
}
|
||||
|
||||
int fuse_loop_mt(struct fuse *f)
|
||||
{
|
||||
if (f == NULL)
|
||||
return -1;
|
||||
|
||||
return fuse_session_loop_mt(fuse_get_session(f));
|
||||
}
|
||||
|
||||
FUSE_SYMVER(".symver fuse_loop_mt_proc,__fuse_loop_mt@");
|
||||
|
||||
#endif
|
409
fuse/fuse_opt.c
Normal file
409
fuse/fuse_opt.c
Normal file
@ -0,0 +1,409 @@
|
||||
/*
|
||||
FUSE: Filesystem in Userspace
|
||||
Copyright (C) 2001-2007 Miklos Szeredi <miklos@szeredi.hu>
|
||||
|
||||
This program can be distributed under the terms of the GNU LGPLv2.
|
||||
See the file COPYING.LIB
|
||||
*/
|
||||
|
||||
#include "fuse_opt.h"
|
||||
#include "fuse_misc.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
struct fuse_opt_context {
|
||||
void *data;
|
||||
const struct fuse_opt *opt;
|
||||
fuse_opt_proc_t proc;
|
||||
int argctr;
|
||||
int argc;
|
||||
char **argv;
|
||||
struct fuse_args outargs;
|
||||
char *opts;
|
||||
int nonopt;
|
||||
};
|
||||
|
||||
void fuse_opt_free_args(struct fuse_args *args)
|
||||
{
|
||||
if (args) {
|
||||
if (args->argv && args->allocated) {
|
||||
int i;
|
||||
for (i = 0; i < args->argc; i++)
|
||||
free(args->argv[i]);
|
||||
free(args->argv);
|
||||
}
|
||||
args->argc = 0;
|
||||
args->argv = NULL;
|
||||
args->allocated = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static int alloc_failed(void)
|
||||
{
|
||||
fprintf(stderr, "fuse: memory allocation failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
int fuse_opt_add_arg(struct fuse_args *args, const char *arg)
|
||||
{
|
||||
char **newargv;
|
||||
char *newarg;
|
||||
|
||||
assert(!args->argv || args->allocated);
|
||||
|
||||
newargv = realloc(args->argv, (args->argc + 2) * sizeof(char *));
|
||||
newarg = newargv ? strdup(arg) : NULL;
|
||||
if (!newargv || !newarg)
|
||||
return alloc_failed();
|
||||
|
||||
args->argv = newargv;
|
||||
args->allocated = 1;
|
||||
args->argv[args->argc++] = newarg;
|
||||
args->argv[args->argc] = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int fuse_opt_insert_arg_common(struct fuse_args *args, int pos,
|
||||
const char *arg)
|
||||
{
|
||||
assert(pos <= args->argc);
|
||||
if (fuse_opt_add_arg(args, arg) == -1)
|
||||
return -1;
|
||||
|
||||
if (pos != args->argc - 1) {
|
||||
char *newarg = args->argv[args->argc - 1];
|
||||
memmove(&args->argv[pos + 1], &args->argv[pos],
|
||||
sizeof(char *) * (args->argc - pos - 1));
|
||||
args->argv[pos] = newarg;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fuse_opt_insert_arg(struct fuse_args *args, int pos, const char *arg)
|
||||
{
|
||||
return fuse_opt_insert_arg_common(args, pos, arg);
|
||||
}
|
||||
|
||||
int fuse_opt_insert_arg_compat(struct fuse_args *args, int pos,
|
||||
const char *arg);
|
||||
int fuse_opt_insert_arg_compat(struct fuse_args *args, int pos, const char *arg)
|
||||
{
|
||||
return fuse_opt_insert_arg_common(args, pos, arg);
|
||||
}
|
||||
|
||||
static int next_arg(struct fuse_opt_context *ctx, const char *opt)
|
||||
{
|
||||
if (ctx->argctr + 1 >= ctx->argc) {
|
||||
fprintf(stderr, "fuse: missing argument after `%s'\n", opt);
|
||||
return -1;
|
||||
}
|
||||
ctx->argctr++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int add_arg(struct fuse_opt_context *ctx, const char *arg)
|
||||
{
|
||||
return fuse_opt_add_arg(&ctx->outargs, arg);
|
||||
}
|
||||
|
||||
static int add_opt_common(char **opts, const char *opt, int esc)
|
||||
{
|
||||
unsigned oldlen = *opts ? strlen(*opts) : 0;
|
||||
char *d = realloc(*opts, oldlen + 1 + strlen(opt) * 2 + 1);
|
||||
|
||||
if (!d)
|
||||
return alloc_failed();
|
||||
|
||||
*opts = d;
|
||||
if (oldlen) {
|
||||
d += oldlen;
|
||||
*d++ = ',';
|
||||
}
|
||||
|
||||
for (; *opt; opt++) {
|
||||
if (esc && (*opt == ',' || *opt == '\\'))
|
||||
*d++ = '\\';
|
||||
*d++ = *opt;
|
||||
}
|
||||
*d = '\0';
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fuse_opt_add_opt(char **opts, const char *opt)
|
||||
{
|
||||
return add_opt_common(opts, opt, 0);
|
||||
}
|
||||
|
||||
int fuse_opt_add_opt_escaped(char **opts, const char *opt)
|
||||
{
|
||||
return add_opt_common(opts, opt, 1);
|
||||
}
|
||||
|
||||
static int add_opt(struct fuse_opt_context *ctx, const char *opt)
|
||||
{
|
||||
return add_opt_common(&ctx->opts, opt, 1);
|
||||
}
|
||||
|
||||
static int call_proc(struct fuse_opt_context *ctx, const char *arg, int key,
|
||||
int iso)
|
||||
{
|
||||
if (key == FUSE_OPT_KEY_DISCARD)
|
||||
return 0;
|
||||
|
||||
if (key != FUSE_OPT_KEY_KEEP && ctx->proc) {
|
||||
int res = ctx->proc(ctx->data, arg, key, &ctx->outargs);
|
||||
if (res == -1 || !res)
|
||||
return res;
|
||||
}
|
||||
if (iso)
|
||||
return add_opt(ctx, arg);
|
||||
else
|
||||
return add_arg(ctx, arg);
|
||||
}
|
||||
|
||||
static int match_template(const char *t, const char *arg, unsigned *sepp)
|
||||
{
|
||||
int arglen = strlen(arg);
|
||||
const char *sep = strchr(t, '=');
|
||||
sep = sep ? sep : strchr(t, ' ');
|
||||
if (sep && (!sep[1] || sep[1] == '%')) {
|
||||
int tlen = sep - t;
|
||||
if (sep[0] == '=')
|
||||
tlen ++;
|
||||
if (arglen >= tlen && strncmp(arg, t, tlen) == 0) {
|
||||
*sepp = sep - t;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
if (strcmp(t, arg) == 0) {
|
||||
*sepp = 0;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct fuse_opt *find_opt(const struct fuse_opt *opt,
|
||||
const char *arg, unsigned *sepp)
|
||||
{
|
||||
for (; opt && opt->templ; opt++)
|
||||
if (match_template(opt->templ, arg, sepp))
|
||||
return opt;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int fuse_opt_match(const struct fuse_opt *opts, const char *opt)
|
||||
{
|
||||
unsigned dummy;
|
||||
return find_opt(opts, opt, &dummy) ? 1 : 0;
|
||||
}
|
||||
|
||||
static int process_opt_param(void *var, const char *format, const char *param,
|
||||
const char *arg)
|
||||
{
|
||||
assert(format[0] == '%');
|
||||
if (format[1] == 's') {
|
||||
char *copy = strdup(param);
|
||||
if (!copy)
|
||||
return alloc_failed();
|
||||
|
||||
*(char **) var = copy;
|
||||
} else {
|
||||
if (sscanf(param, format, var) != 1) {
|
||||
fprintf(stderr, "fuse: invalid parameter in option `%s'\n", arg);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int process_opt(struct fuse_opt_context *ctx,
|
||||
const struct fuse_opt *opt, unsigned sep,
|
||||
const char *arg, int iso)
|
||||
{
|
||||
if (opt->offset == -1U) {
|
||||
if (call_proc(ctx, arg, opt->value, iso) == -1)
|
||||
return -1;
|
||||
} else {
|
||||
void *var = ctx->data + opt->offset;
|
||||
if (sep && opt->templ[sep + 1]) {
|
||||
const char *param = arg + sep;
|
||||
if (opt->templ[sep] == '=')
|
||||
param ++;
|
||||
if (process_opt_param(var, opt->templ + sep + 1,
|
||||
param, arg) == -1)
|
||||
return -1;
|
||||
} else
|
||||
*(int *)var = opt->value;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int process_opt_sep_arg(struct fuse_opt_context *ctx,
|
||||
const struct fuse_opt *opt, unsigned sep,
|
||||
const char *arg, int iso)
|
||||
{
|
||||
int res;
|
||||
char *newarg;
|
||||
char *param;
|
||||
|
||||
if (next_arg(ctx, arg) == -1)
|
||||
return -1;
|
||||
|
||||
param = ctx->argv[ctx->argctr];
|
||||
newarg = malloc(sep + strlen(param) + 1);
|
||||
if (!newarg)
|
||||
return alloc_failed();
|
||||
|
||||
memcpy(newarg, arg, sep);
|
||||
strcpy(newarg + sep, param);
|
||||
res = process_opt(ctx, opt, sep, newarg, iso);
|
||||
free(newarg);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static int process_gopt(struct fuse_opt_context *ctx, const char *arg, int iso)
|
||||
{
|
||||
unsigned sep;
|
||||
const struct fuse_opt *opt = find_opt(ctx->opt, arg, &sep);
|
||||
if (opt) {
|
||||
for (; opt; opt = find_opt(opt + 1, arg, &sep)) {
|
||||
int res;
|
||||
if (sep && opt->templ[sep] == ' ' && !arg[sep])
|
||||
res = process_opt_sep_arg(ctx, opt, sep, arg,
|
||||
iso);
|
||||
else
|
||||
res = process_opt(ctx, opt, sep, arg, iso);
|
||||
if (res == -1)
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
} else
|
||||
return call_proc(ctx, arg, FUSE_OPT_KEY_OPT, iso);
|
||||
}
|
||||
|
||||
static int process_real_option_group(struct fuse_opt_context *ctx, char *opts)
|
||||
{
|
||||
char *s = opts;
|
||||
char *d = s;
|
||||
int end = 0;
|
||||
|
||||
while (!end) {
|
||||
if (*s == '\0')
|
||||
end = 1;
|
||||
if (*s == ',' || end) {
|
||||
int res;
|
||||
|
||||
*d = '\0';
|
||||
res = process_gopt(ctx, opts, 1);
|
||||
if (res == -1)
|
||||
return -1;
|
||||
d = opts;
|
||||
} else {
|
||||
if (s[0] == '\\' && s[1] != '\0')
|
||||
s++;
|
||||
*d++ = *s;
|
||||
}
|
||||
s++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int process_option_group(struct fuse_opt_context *ctx, const char *opts)
|
||||
{
|
||||
int res;
|
||||
char *copy = strdup(opts);
|
||||
|
||||
if (!copy) {
|
||||
fprintf(stderr, "fuse: memory allocation failed\n");
|
||||
return -1;
|
||||
}
|
||||
res = process_real_option_group(ctx, copy);
|
||||
free(copy);
|
||||
return res;
|
||||
}
|
||||
|
||||
static int process_one(struct fuse_opt_context *ctx, const char *arg)
|
||||
{
|
||||
if (ctx->nonopt || arg[0] != '-')
|
||||
return call_proc(ctx, arg, FUSE_OPT_KEY_NONOPT, 0);
|
||||
else if (arg[1] == 'o') {
|
||||
if (arg[2])
|
||||
return process_option_group(ctx, arg + 2);
|
||||
else {
|
||||
if (next_arg(ctx, arg) == -1)
|
||||
return -1;
|
||||
|
||||
return process_option_group(ctx,
|
||||
ctx->argv[ctx->argctr]);
|
||||
}
|
||||
} else if (arg[1] == '-' && !arg[2]) {
|
||||
if (add_arg(ctx, arg) == -1)
|
||||
return -1;
|
||||
ctx->nonopt = ctx->outargs.argc;
|
||||
return 0;
|
||||
} else
|
||||
return process_gopt(ctx, arg, 0);
|
||||
}
|
||||
|
||||
static int opt_parse(struct fuse_opt_context *ctx)
|
||||
{
|
||||
if (ctx->argc) {
|
||||
if (add_arg(ctx, ctx->argv[0]) == -1)
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (ctx->argctr = 1; ctx->argctr < ctx->argc; ctx->argctr++)
|
||||
if (process_one(ctx, ctx->argv[ctx->argctr]) == -1)
|
||||
return -1;
|
||||
|
||||
if (ctx->opts) {
|
||||
if (fuse_opt_insert_arg(&ctx->outargs, 1, "-o") == -1 ||
|
||||
fuse_opt_insert_arg(&ctx->outargs, 2, ctx->opts) == -1)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* If option separator ("--") is the last argument, remove it */
|
||||
if (ctx->nonopt && ctx->nonopt == ctx->outargs.argc &&
|
||||
strcmp(ctx->outargs.argv[ctx->outargs.argc - 1], "--") == 0) {
|
||||
free(ctx->outargs.argv[ctx->outargs.argc - 1]);
|
||||
ctx->outargs.argv[--ctx->outargs.argc] = NULL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fuse_opt_parse(struct fuse_args *args, void *data,
|
||||
const struct fuse_opt opts[], fuse_opt_proc_t proc)
|
||||
{
|
||||
int res;
|
||||
struct fuse_opt_context ctx = {
|
||||
.data = data,
|
||||
.opt = opts,
|
||||
.proc = proc,
|
||||
};
|
||||
|
||||
if (!args || !args->argv || !args->argc)
|
||||
return 0;
|
||||
|
||||
ctx.argc = args->argc;
|
||||
ctx.argv = args->argv;
|
||||
|
||||
res = opt_parse(&ctx);
|
||||
if (res != -1) {
|
||||
struct fuse_args tmp = *args;
|
||||
*args = ctx.outargs;
|
||||
ctx.outargs = tmp;
|
||||
}
|
||||
free(ctx.opts);
|
||||
fuse_opt_free_args(&ctx.outargs);
|
||||
return res;
|
||||
}
|
||||
|
||||
/* This symbol version was mistakenly added to the version script */
|
||||
FUSE_SYMVER(".symver fuse_opt_insert_arg_compat,fuse_opt_insert_arg@FUSE_2.5");
|
205
fuse/fuse_session.c
Normal file
205
fuse/fuse_session.c
Normal file
@ -0,0 +1,205 @@
|
||||
/*
|
||||
FUSE: Filesystem in Userspace
|
||||
Copyright (C) 2001-2007 Miklos Szeredi <miklos@szeredi.hu>
|
||||
|
||||
This program can be distributed under the terms of the GNU LGPLv2.
|
||||
See the file COPYING.LIB
|
||||
*/
|
||||
|
||||
#include "fuse_i.h"
|
||||
#include "fuse_misc.h"
|
||||
#include "fuse_common_compat.h"
|
||||
#include "fuse_lowlevel_compat.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
|
||||
struct fuse_chan {
|
||||
struct fuse_chan_ops op;
|
||||
|
||||
struct fuse_session *se;
|
||||
|
||||
int fd;
|
||||
|
||||
size_t bufsize;
|
||||
|
||||
void *data;
|
||||
|
||||
int compat;
|
||||
};
|
||||
|
||||
struct fuse_session *fuse_session_new(struct fuse_session_ops *op, void *data)
|
||||
{
|
||||
struct fuse_session *se = (struct fuse_session *) malloc(sizeof(*se));
|
||||
if (se == NULL) {
|
||||
fprintf(stderr, "fuse: failed to allocate session\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(se, 0, sizeof(*se));
|
||||
se->op = *op;
|
||||
se->data = data;
|
||||
|
||||
return se;
|
||||
}
|
||||
|
||||
void fuse_session_add_chan(struct fuse_session *se, struct fuse_chan *ch)
|
||||
{
|
||||
assert(se->ch == NULL);
|
||||
assert(ch->se == NULL);
|
||||
se->ch = ch;
|
||||
ch->se = se;
|
||||
}
|
||||
|
||||
void fuse_session_remove_chan(struct fuse_chan *ch)
|
||||
{
|
||||
struct fuse_session *se = ch->se;
|
||||
if (se) {
|
||||
assert(se->ch == ch);
|
||||
se->ch = NULL;
|
||||
ch->se = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
struct fuse_chan *fuse_session_next_chan(struct fuse_session *se,
|
||||
struct fuse_chan *ch)
|
||||
{
|
||||
assert(ch == NULL || ch == se->ch);
|
||||
if (ch == NULL)
|
||||
return se->ch;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void fuse_session_process(struct fuse_session *se, const char *buf, size_t len,
|
||||
struct fuse_chan *ch)
|
||||
{
|
||||
se->op.process(se->data, buf, len, ch);
|
||||
}
|
||||
|
||||
void fuse_session_destroy(struct fuse_session *se)
|
||||
{
|
||||
if (se->op.destroy)
|
||||
se->op.destroy(se->data);
|
||||
if (se->ch != NULL)
|
||||
fuse_chan_destroy(se->ch);
|
||||
free(se);
|
||||
}
|
||||
|
||||
void fuse_session_exit(struct fuse_session *se)
|
||||
{
|
||||
if (se->op.exit)
|
||||
se->op.exit(se->data, 1);
|
||||
se->exited = 1;
|
||||
}
|
||||
|
||||
void fuse_session_reset(struct fuse_session *se)
|
||||
{
|
||||
if (se->op.exit)
|
||||
se->op.exit(se->data, 0);
|
||||
se->exited = 0;
|
||||
}
|
||||
|
||||
int fuse_session_exited(struct fuse_session *se)
|
||||
{
|
||||
if (se->op.exited)
|
||||
return se->op.exited(se->data);
|
||||
else
|
||||
return se->exited;
|
||||
}
|
||||
|
||||
void *fuse_session_data(struct fuse_session *se)
|
||||
{
|
||||
return se->data;
|
||||
}
|
||||
|
||||
static struct fuse_chan *fuse_chan_new_common(struct fuse_chan_ops *op, int fd,
|
||||
size_t bufsize, void *data,
|
||||
int compat)
|
||||
{
|
||||
struct fuse_chan *ch = (struct fuse_chan *) malloc(sizeof(*ch));
|
||||
if (ch == NULL) {
|
||||
fprintf(stderr, "fuse: failed to allocate channel\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(ch, 0, sizeof(*ch));
|
||||
ch->op = *op;
|
||||
ch->fd = fd;
|
||||
ch->bufsize = bufsize;
|
||||
ch->data = data;
|
||||
ch->compat = compat;
|
||||
|
||||
return ch;
|
||||
}
|
||||
|
||||
struct fuse_chan *fuse_chan_new(struct fuse_chan_ops *op, int fd,
|
||||
size_t bufsize, void *data)
|
||||
{
|
||||
return fuse_chan_new_common(op, fd, bufsize, data, 0);
|
||||
}
|
||||
|
||||
struct fuse_chan *fuse_chan_new_compat24(struct fuse_chan_ops_compat24 *op,
|
||||
int fd, size_t bufsize, void *data)
|
||||
{
|
||||
return fuse_chan_new_common((struct fuse_chan_ops *) op, fd, bufsize,
|
||||
data, 24);
|
||||
}
|
||||
|
||||
int fuse_chan_fd(struct fuse_chan *ch)
|
||||
{
|
||||
return ch->fd;
|
||||
}
|
||||
|
||||
size_t fuse_chan_bufsize(struct fuse_chan *ch)
|
||||
{
|
||||
return ch->bufsize;
|
||||
}
|
||||
|
||||
void *fuse_chan_data(struct fuse_chan *ch)
|
||||
{
|
||||
return ch->data;
|
||||
}
|
||||
|
||||
struct fuse_session *fuse_chan_session(struct fuse_chan *ch)
|
||||
{
|
||||
return ch->se;
|
||||
}
|
||||
|
||||
int fuse_chan_recv(struct fuse_chan **chp, char *buf, size_t size)
|
||||
{
|
||||
struct fuse_chan *ch = *chp;
|
||||
if (ch->compat)
|
||||
return ((struct fuse_chan_ops_compat24 *) &ch->op)
|
||||
->receive(ch, buf, size);
|
||||
else
|
||||
return ch->op.receive(chp, buf, size);
|
||||
}
|
||||
|
||||
int fuse_chan_receive(struct fuse_chan *ch, char *buf, size_t size)
|
||||
{
|
||||
int res;
|
||||
|
||||
res = fuse_chan_recv(&ch, buf, size);
|
||||
return res >= 0 ? res : (res != -EINTR && res != -EAGAIN) ? -1 : 0;
|
||||
}
|
||||
|
||||
int fuse_chan_send(struct fuse_chan *ch, const struct iovec iov[], size_t count)
|
||||
{
|
||||
return ch->op.send(ch, iov, count);
|
||||
}
|
||||
|
||||
void fuse_chan_destroy(struct fuse_chan *ch)
|
||||
{
|
||||
fuse_session_remove_chan(ch);
|
||||
if (ch->op.destroy)
|
||||
ch->op.destroy(ch);
|
||||
free(ch);
|
||||
}
|
||||
|
||||
#ifndef __FreeBSD__
|
||||
FUSE_SYMVER(".symver fuse_chan_new_compat24,fuse_chan_new@FUSE_2.4");
|
||||
#endif
|
72
fuse/fuse_signals.c
Normal file
72
fuse/fuse_signals.c
Normal file
@ -0,0 +1,72 @@
|
||||
/*
|
||||
FUSE: Filesystem in Userspace
|
||||
Copyright (C) 2001-2007 Miklos Szeredi <miklos@szeredi.hu>
|
||||
|
||||
This program can be distributed under the terms of the GNU LGPLv2.
|
||||
See the file COPYING.LIB
|
||||
*/
|
||||
|
||||
#include "fuse_lowlevel.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
|
||||
static struct fuse_session *fuse_instance;
|
||||
|
||||
static void exit_handler(int sig)
|
||||
{
|
||||
(void) sig;
|
||||
if (fuse_instance)
|
||||
fuse_session_exit(fuse_instance);
|
||||
}
|
||||
|
||||
static int set_one_signal_handler(int sig, void (*handler)(int))
|
||||
{
|
||||
struct sigaction sa;
|
||||
struct sigaction old_sa;
|
||||
|
||||
memset(&sa, 0, sizeof(struct sigaction));
|
||||
sa.sa_handler = handler;
|
||||
sigemptyset(&(sa.sa_mask));
|
||||
sa.sa_flags = 0;
|
||||
|
||||
if (sigaction(sig, NULL, &old_sa) == -1) {
|
||||
perror("fuse: cannot get old signal handler");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (old_sa.sa_handler == SIG_DFL &&
|
||||
sigaction(sig, &sa, NULL) == -1) {
|
||||
perror("fuse: cannot set signal handler");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fuse_set_signal_handlers(struct fuse_session *se)
|
||||
{
|
||||
if (set_one_signal_handler(SIGHUP, exit_handler) == -1 ||
|
||||
set_one_signal_handler(SIGINT, exit_handler) == -1 ||
|
||||
set_one_signal_handler(SIGTERM, exit_handler) == -1 ||
|
||||
set_one_signal_handler(SIGPIPE, SIG_IGN) == -1)
|
||||
return -1;
|
||||
|
||||
fuse_instance = se;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void fuse_remove_signal_handlers(struct fuse_session *se)
|
||||
{
|
||||
if (fuse_instance != se)
|
||||
fprintf(stderr,
|
||||
"fuse: fuse_remove_signal_handlers: unknown session\n");
|
||||
else
|
||||
fuse_instance = NULL;
|
||||
|
||||
set_one_signal_handler(SIGHUP, SIG_DFL);
|
||||
set_one_signal_handler(SIGINT, SIG_DFL);
|
||||
set_one_signal_handler(SIGTERM, SIG_DFL);
|
||||
set_one_signal_handler(SIGPIPE, SIG_DFL);
|
||||
}
|
||||
|
385
fuse/fusexmp.c
Normal file
385
fuse/fusexmp.c
Normal file
@ -0,0 +1,385 @@
|
||||
/*
|
||||
FUSE: Filesystem in Userspace
|
||||
Copyright (C) 2001-2007 Miklos Szeredi <miklos@szeredi.hu>
|
||||
|
||||
This program can be distributed under the terms of the GNU GPL.
|
||||
See the file COPYING.
|
||||
|
||||
gcc -Wall `pkg-config fuse --cflags --libs` fusexmp.c -o fusexmp
|
||||
*/
|
||||
|
||||
#define FUSE_USE_VERSION 26
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#ifdef linux
|
||||
/* For pread()/pwrite() */
|
||||
#define _XOPEN_SOURCE 500
|
||||
#endif
|
||||
|
||||
#include <fuse.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <sys/time.h>
|
||||
#ifdef HAVE_SETXATTR
|
||||
#include <sys/xattr.h>
|
||||
#endif
|
||||
|
||||
static int xmp_getattr(const char *path, struct stat *stbuf)
|
||||
{
|
||||
int res;
|
||||
|
||||
res = lstat(path, stbuf);
|
||||
if (res == -1)
|
||||
return -errno;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int xmp_access(const char *path, int mask)
|
||||
{
|
||||
int res;
|
||||
|
||||
res = access(path, mask);
|
||||
if (res == -1)
|
||||
return -errno;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int xmp_readlink(const char *path, char *buf, size_t size)
|
||||
{
|
||||
int res;
|
||||
|
||||
res = readlink(path, buf, size - 1);
|
||||
if (res == -1)
|
||||
return -errno;
|
||||
|
||||
buf[res] = '\0';
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int xmp_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
|
||||
off64_t offset, struct fuse_file_info *fi)
|
||||
{
|
||||
DIR *dp;
|
||||
struct dirent *de;
|
||||
|
||||
(void) offset;
|
||||
(void) fi;
|
||||
|
||||
dp = opendir(path);
|
||||
if (dp == NULL)
|
||||
return -errno;
|
||||
|
||||
while ((de = readdir(dp)) != NULL) {
|
||||
struct stat st;
|
||||
memset(&st, 0, sizeof(st));
|
||||
st.st_ino = de->d_ino;
|
||||
st.st_mode = de->d_type << 12;
|
||||
if (filler(buf, de->d_name, &st, 0))
|
||||
break;
|
||||
}
|
||||
|
||||
closedir(dp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int xmp_mknod(const char *path, mode_t mode, dev_t rdev)
|
||||
{
|
||||
int res;
|
||||
|
||||
/* On Linux this could just be 'mknod(path, mode, rdev)' but this
|
||||
is more portable */
|
||||
if (S_ISREG(mode)) {
|
||||
res = open(path, O_CREAT | O_EXCL | O_WRONLY, mode);
|
||||
if (res >= 0)
|
||||
res = close(res);
|
||||
} else if (S_ISFIFO(mode))
|
||||
res = mkfifo(path, mode);
|
||||
else
|
||||
res = mknod(path, mode, rdev);
|
||||
if (res == -1)
|
||||
return -errno;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int xmp_mkdir(const char *path, mode_t mode)
|
||||
{
|
||||
int res;
|
||||
|
||||
res = mkdir(path, mode);
|
||||
if (res == -1)
|
||||
return -errno;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int xmp_unlink(const char *path)
|
||||
{
|
||||
int res;
|
||||
|
||||
res = unlink(path);
|
||||
if (res == -1)
|
||||
return -errno;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int xmp_rmdir(const char *path)
|
||||
{
|
||||
int res;
|
||||
|
||||
res = rmdir(path);
|
||||
if (res == -1)
|
||||
return -errno;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int xmp_symlink(const char *from, const char *to)
|
||||
{
|
||||
int res;
|
||||
|
||||
res = symlink(from, to);
|
||||
if (res == -1)
|
||||
return -errno;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int xmp_rename(const char *from, const char *to)
|
||||
{
|
||||
int res;
|
||||
|
||||
res = rename(from, to);
|
||||
if (res == -1)
|
||||
return -errno;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int xmp_link(const char *from, const char *to)
|
||||
{
|
||||
int res;
|
||||
|
||||
res = link(from, to);
|
||||
if (res == -1)
|
||||
return -errno;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int xmp_chmod(const char *path, mode_t mode)
|
||||
{
|
||||
int res;
|
||||
|
||||
res = chmod(path, mode);
|
||||
if (res == -1)
|
||||
return -errno;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int xmp_chown(const char *path, uid_t uid, gid_t gid)
|
||||
{
|
||||
int res;
|
||||
|
||||
res = lchown(path, uid, gid);
|
||||
if (res == -1)
|
||||
return -errno;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int xmp_truncate(const char *path, off64_t size)
|
||||
{
|
||||
int res;
|
||||
|
||||
res = truncate(path, size);
|
||||
if (res == -1)
|
||||
return -errno;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int xmp_utimens(const char *path, const struct timespec ts[2])
|
||||
{
|
||||
int res;
|
||||
struct timeval tv[2];
|
||||
|
||||
tv[0].tv_sec = ts[0].tv_sec;
|
||||
tv[0].tv_usec = ts[0].tv_nsec / 1000;
|
||||
tv[1].tv_sec = ts[1].tv_sec;
|
||||
tv[1].tv_usec = ts[1].tv_nsec / 1000;
|
||||
|
||||
res = utimes(path, tv);
|
||||
if (res == -1)
|
||||
return -errno;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int xmp_open(const char *path, struct fuse_file_info *fi)
|
||||
{
|
||||
int res;
|
||||
|
||||
res = open(path, fi->flags);
|
||||
if (res == -1)
|
||||
return -errno;
|
||||
|
||||
close(res);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int xmp_read(const char *path, char *buf, size_t size, off64_t offset,
|
||||
struct fuse_file_info *fi)
|
||||
{
|
||||
int fd;
|
||||
int res;
|
||||
|
||||
(void) fi;
|
||||
fd = open(path, O_RDONLY);
|
||||
if (fd == -1)
|
||||
return -errno;
|
||||
|
||||
res = pread(fd, buf, size, offset);
|
||||
if (res == -1)
|
||||
res = -errno;
|
||||
|
||||
close(fd);
|
||||
return res;
|
||||
}
|
||||
|
||||
static int xmp_write(const char *path, const char *buf, size_t size,
|
||||
off64_t offset, struct fuse_file_info *fi)
|
||||
{
|
||||
int fd;
|
||||
int res;
|
||||
|
||||
(void) fi;
|
||||
fd = open(path, O_WRONLY);
|
||||
if (fd == -1)
|
||||
return -errno;
|
||||
|
||||
res = pwrite(fd, buf, size, offset);
|
||||
if (res == -1)
|
||||
res = -errno;
|
||||
|
||||
close(fd);
|
||||
return res;
|
||||
}
|
||||
|
||||
static int xmp_statfs(const char *path, struct statvfs *stbuf)
|
||||
{
|
||||
int res;
|
||||
|
||||
//res = statvfs(path, stbuf);
|
||||
if (res == -1)
|
||||
return -errno;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int xmp_release(const char *path, struct fuse_file_info *fi)
|
||||
{
|
||||
/* Just a stub. This method is optional and can safely be left
|
||||
unimplemented */
|
||||
|
||||
(void) path;
|
||||
(void) fi;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int xmp_fsync(const char *path, int isdatasync,
|
||||
struct fuse_file_info *fi)
|
||||
{
|
||||
/* Just a stub. This method is optional and can safely be left
|
||||
unimplemented */
|
||||
|
||||
(void) path;
|
||||
(void) isdatasync;
|
||||
(void) fi;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef HAVE_SETXATTR
|
||||
/* xattr operations are optional and can safely be left unimplemented */
|
||||
static int xmp_setxattr(const char *path, const char *name, const char *value,
|
||||
size_t size, int flags)
|
||||
{
|
||||
int res = lsetxattr(path, name, value, size, flags);
|
||||
if (res == -1)
|
||||
return -errno;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int xmp_getxattr(const char *path, const char *name, char *value,
|
||||
size_t size)
|
||||
{
|
||||
int res = lgetxattr(path, name, value, size);
|
||||
if (res == -1)
|
||||
return -errno;
|
||||
return res;
|
||||
}
|
||||
|
||||
static int xmp_listxattr(const char *path, char *list, size_t size)
|
||||
{
|
||||
int res = llistxattr(path, list, size);
|
||||
if (res == -1)
|
||||
return -errno;
|
||||
return res;
|
||||
}
|
||||
|
||||
static int xmp_removexattr(const char *path, const char *name)
|
||||
{
|
||||
int res = lremovexattr(path, name);
|
||||
if (res == -1)
|
||||
return -errno;
|
||||
return 0;
|
||||
}
|
||||
#endif /* HAVE_SETXATTR */
|
||||
|
||||
static struct fuse_operations xmp_oper = {
|
||||
.getattr = xmp_getattr,
|
||||
.access = xmp_access,
|
||||
.readlink = xmp_readlink,
|
||||
.readdir = xmp_readdir,
|
||||
.mknod = xmp_mknod,
|
||||
.mkdir = xmp_mkdir,
|
||||
.symlink = xmp_symlink,
|
||||
.unlink = xmp_unlink,
|
||||
.rmdir = xmp_rmdir,
|
||||
.rename = xmp_rename,
|
||||
.link = xmp_link,
|
||||
.chmod = xmp_chmod,
|
||||
.chown = xmp_chown,
|
||||
.truncate = xmp_truncate,
|
||||
.utimens = xmp_utimens,
|
||||
.open = xmp_open,
|
||||
.read = xmp_read,
|
||||
.write = xmp_write,
|
||||
.statfs = xmp_statfs,
|
||||
.release = xmp_release,
|
||||
.fsync = xmp_fsync,
|
||||
#ifdef HAVE_SETXATTR
|
||||
.setxattr = xmp_setxattr,
|
||||
.getxattr = xmp_getxattr,
|
||||
.listxattr = xmp_listxattr,
|
||||
.removexattr = xmp_removexattr,
|
||||
#endif
|
||||
};
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
umask(0);
|
||||
return fuse_main(argc, argv, &xmp_oper, NULL);
|
||||
}
|
455
fuse/helper.c
Normal file
455
fuse/helper.c
Normal file
@ -0,0 +1,455 @@
|
||||
/*
|
||||
FUSE: Filesystem in Userspace
|
||||
Copyright (C) 2001-2007 Miklos Szeredi <miklos@szeredi.hu>
|
||||
|
||||
This program can be distributed under the terms of the GNU LGPLv2.
|
||||
See the file COPYING.LIB.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "fuse_i.h"
|
||||
#include "fuse_misc.h"
|
||||
#include "fuse_opt.h"
|
||||
#include "fuse_lowlevel.h"
|
||||
#include "fuse_common_compat.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
#include <errno.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
enum {
|
||||
KEY_HELP,
|
||||
KEY_HELP_NOHEADER,
|
||||
KEY_VERSION,
|
||||
};
|
||||
|
||||
struct helper_opts {
|
||||
int singlethread;
|
||||
int foreground;
|
||||
int nodefault_subtype;
|
||||
char *mountpoint;
|
||||
};
|
||||
|
||||
#define FUSE_HELPER_OPT(t, p) { t, offsetof(struct helper_opts, p), 1 }
|
||||
|
||||
static const struct fuse_opt fuse_helper_opts[] = {
|
||||
FUSE_HELPER_OPT("-d", foreground),
|
||||
FUSE_HELPER_OPT("debug", foreground),
|
||||
FUSE_HELPER_OPT("-f", foreground),
|
||||
FUSE_HELPER_OPT("-s", singlethread),
|
||||
FUSE_HELPER_OPT("fsname=", nodefault_subtype),
|
||||
FUSE_HELPER_OPT("subtype=", nodefault_subtype),
|
||||
|
||||
FUSE_OPT_KEY("-h", KEY_HELP),
|
||||
FUSE_OPT_KEY("--help", KEY_HELP),
|
||||
FUSE_OPT_KEY("-ho", KEY_HELP_NOHEADER),
|
||||
FUSE_OPT_KEY("-V", KEY_VERSION),
|
||||
FUSE_OPT_KEY("--version", KEY_VERSION),
|
||||
FUSE_OPT_KEY("-d", FUSE_OPT_KEY_KEEP),
|
||||
FUSE_OPT_KEY("debug", FUSE_OPT_KEY_KEEP),
|
||||
FUSE_OPT_KEY("fsname=", FUSE_OPT_KEY_KEEP),
|
||||
FUSE_OPT_KEY("subtype=", FUSE_OPT_KEY_KEEP),
|
||||
FUSE_OPT_END
|
||||
};
|
||||
|
||||
static void usage(const char *progname)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"usage: %s mountpoint [options]\n\n", progname);
|
||||
fprintf(stderr,
|
||||
"general options:\n"
|
||||
" -o opt,[opt...] mount options\n"
|
||||
" -h --help print help\n"
|
||||
" -V --version print version\n"
|
||||
"\n");
|
||||
}
|
||||
|
||||
static void helper_help(void)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"FUSE options:\n"
|
||||
" -d -o debug enable debug output (implies -f)\n"
|
||||
" -f foreground operation\n"
|
||||
" -s disable multi-threaded operation\n"
|
||||
"\n"
|
||||
);
|
||||
}
|
||||
|
||||
static void helper_version(void)
|
||||
{
|
||||
fprintf(stderr, "FUSE library version: %s\n", PACKAGE_VERSION);
|
||||
}
|
||||
|
||||
static int fuse_helper_opt_proc(void *data, const char *arg, int key,
|
||||
struct fuse_args *outargs)
|
||||
{
|
||||
struct helper_opts *hopts = data;
|
||||
|
||||
switch (key) {
|
||||
case KEY_HELP:
|
||||
usage(outargs->argv[0]);
|
||||
/* fall through */
|
||||
|
||||
case KEY_HELP_NOHEADER:
|
||||
helper_help();
|
||||
return fuse_opt_add_arg(outargs, "-h");
|
||||
|
||||
case KEY_VERSION:
|
||||
helper_version();
|
||||
return 1;
|
||||
|
||||
case FUSE_OPT_KEY_NONOPT:
|
||||
if (!hopts->mountpoint) {
|
||||
char mountpoint[PATH_MAX];
|
||||
if (realpath(arg, mountpoint) == NULL) {
|
||||
fprintf(stderr,
|
||||
"fuse: bad mount point `%s': %s\n",
|
||||
arg, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
return fuse_opt_add_opt(&hopts->mountpoint, mountpoint);
|
||||
} else {
|
||||
fprintf(stderr, "fuse: invalid argument `%s'\n", arg);
|
||||
return -1;
|
||||
}
|
||||
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
static int add_default_subtype(const char *progname, struct fuse_args *args)
|
||||
{
|
||||
int res;
|
||||
char *subtype_opt;
|
||||
const char *basename = strrchr(progname, '/');
|
||||
if (basename == NULL)
|
||||
basename = progname;
|
||||
else if (basename[1] != '\0')
|
||||
basename++;
|
||||
|
||||
subtype_opt = (char *) malloc(strlen(basename) + 64);
|
||||
if (subtype_opt == NULL) {
|
||||
fprintf(stderr, "fuse: memory allocation failed\n");
|
||||
return -1;
|
||||
}
|
||||
sprintf(subtype_opt, "-osubtype=%s", basename);
|
||||
res = fuse_opt_add_arg(args, subtype_opt);
|
||||
free(subtype_opt);
|
||||
return res;
|
||||
}
|
||||
|
||||
int fuse_parse_cmdline(struct fuse_args *args, char **mountpoint,
|
||||
int *multithreaded, int *foreground)
|
||||
{
|
||||
int res;
|
||||
struct helper_opts hopts;
|
||||
|
||||
memset(&hopts, 0, sizeof(hopts));
|
||||
res = fuse_opt_parse(args, &hopts, fuse_helper_opts,
|
||||
fuse_helper_opt_proc);
|
||||
if (res == -1)
|
||||
return -1;
|
||||
|
||||
if (!hopts.nodefault_subtype) {
|
||||
res = add_default_subtype(args->argv[0], args);
|
||||
if (res == -1)
|
||||
goto err;
|
||||
}
|
||||
if (mountpoint)
|
||||
*mountpoint = hopts.mountpoint;
|
||||
else
|
||||
free(hopts.mountpoint);
|
||||
|
||||
if (multithreaded)
|
||||
*multithreaded = !hopts.singlethread;
|
||||
if (foreground)
|
||||
*foreground = hopts.foreground;
|
||||
return 0;
|
||||
|
||||
err:
|
||||
free(hopts.mountpoint);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int fuse_daemonize(int foreground)
|
||||
{
|
||||
int res;
|
||||
|
||||
if (!foreground) {
|
||||
res = daemon(0, 0);
|
||||
if (res == -1) {
|
||||
perror("fuse: failed to daemonize program\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct fuse_chan *fuse_mount_common(const char *mountpoint,
|
||||
struct fuse_args *args)
|
||||
{
|
||||
struct fuse_chan *ch;
|
||||
int fd;
|
||||
|
||||
/*
|
||||
* Make sure file descriptors 0, 1 and 2 are open, otherwise chaos
|
||||
* would ensue.
|
||||
*/
|
||||
do {
|
||||
fd = open("/dev/null", O_RDWR);
|
||||
if (fd > 2)
|
||||
close(fd);
|
||||
} while (fd >= 0 && fd <= 2);
|
||||
|
||||
fd = fuse_mount_compat25(mountpoint, args);
|
||||
if (fd == -1)
|
||||
return NULL;
|
||||
|
||||
ch = fuse_kern_chan_new(fd);
|
||||
if (!ch)
|
||||
fuse_kern_unmount(mountpoint, fd);
|
||||
|
||||
return ch;
|
||||
}
|
||||
|
||||
struct fuse_chan *fuse_mount(const char *mountpoint, struct fuse_args *args)
|
||||
{
|
||||
return fuse_mount_common(mountpoint, args);
|
||||
}
|
||||
|
||||
static void fuse_unmount_common(const char *mountpoint, struct fuse_chan *ch)
|
||||
{
|
||||
int fd = ch ? fuse_chan_fd(ch) : -1;
|
||||
fuse_kern_unmount(mountpoint, fd);
|
||||
fuse_chan_destroy(ch);
|
||||
}
|
||||
|
||||
void fuse_unmount(const char *mountpoint, struct fuse_chan *ch)
|
||||
{
|
||||
fuse_unmount_common(mountpoint, ch);
|
||||
}
|
||||
|
||||
struct fuse *fuse_setup_common(int argc, char *argv[],
|
||||
const struct fuse_operations *op,
|
||||
size_t op_size,
|
||||
char **mountpoint,
|
||||
int *multithreaded,
|
||||
int *fd,
|
||||
void *user_data,
|
||||
int compat)
|
||||
{
|
||||
struct fuse_args args = FUSE_ARGS_INIT(argc, argv);
|
||||
struct fuse_chan *ch;
|
||||
struct fuse *fuse;
|
||||
int foreground;
|
||||
int res;
|
||||
|
||||
res = fuse_parse_cmdline(&args, mountpoint, multithreaded, &foreground);
|
||||
if (res == -1)
|
||||
return NULL;
|
||||
|
||||
ch = fuse_mount_common(*mountpoint, &args);
|
||||
if (!ch) {
|
||||
fuse_opt_free_args(&args);
|
||||
goto err_free;
|
||||
}
|
||||
|
||||
fuse = fuse_new_common(ch, &args, op, op_size, user_data, compat);
|
||||
fuse_opt_free_args(&args);
|
||||
if (fuse == NULL)
|
||||
goto err_unmount;
|
||||
|
||||
res = fuse_daemonize(foreground);
|
||||
if (res == -1)
|
||||
goto err_unmount;
|
||||
|
||||
res = fuse_set_signal_handlers(fuse_get_session(fuse));
|
||||
if (res == -1)
|
||||
goto err_unmount;
|
||||
|
||||
if (fd)
|
||||
*fd = fuse_chan_fd(ch);
|
||||
|
||||
return fuse;
|
||||
|
||||
err_unmount:
|
||||
fuse_unmount_common(*mountpoint, ch);
|
||||
if (fuse)
|
||||
fuse_destroy(fuse);
|
||||
err_free:
|
||||
free(*mountpoint);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct fuse *fuse_setup(int argc, char *argv[],
|
||||
const struct fuse_operations *op, size_t op_size,
|
||||
char **mountpoint, int *multithreaded, void *user_data)
|
||||
{
|
||||
return fuse_setup_common(argc, argv, op, op_size, mountpoint,
|
||||
multithreaded, NULL, user_data, 0);
|
||||
}
|
||||
|
||||
static void fuse_teardown_common(struct fuse *fuse, char *mountpoint)
|
||||
{
|
||||
struct fuse_session *se = fuse_get_session(fuse);
|
||||
struct fuse_chan *ch = fuse_session_next_chan(se, NULL);
|
||||
fuse_remove_signal_handlers(se);
|
||||
fuse_unmount_common(mountpoint, ch);
|
||||
fuse_destroy(fuse);
|
||||
free(mountpoint);
|
||||
}
|
||||
|
||||
void fuse_teardown(struct fuse *fuse, char *mountpoint)
|
||||
{
|
||||
fuse_teardown_common(fuse, mountpoint);
|
||||
}
|
||||
|
||||
static int fuse_main_common(int argc, char *argv[],
|
||||
const struct fuse_operations *op, size_t op_size,
|
||||
void *user_data, int compat)
|
||||
{
|
||||
struct fuse *fuse;
|
||||
char *mountpoint;
|
||||
int multithreaded;
|
||||
int res;
|
||||
|
||||
fuse = fuse_setup_common(argc, argv, op, op_size, &mountpoint,
|
||||
&multithreaded, NULL, user_data, compat);
|
||||
if (fuse == NULL)
|
||||
return 1;
|
||||
|
||||
#ifdef __MULTI_THREAD
|
||||
if (multithreaded)
|
||||
res = fuse_loop_mt(fuse);
|
||||
else
|
||||
#endif
|
||||
res = fuse_loop(fuse);
|
||||
|
||||
fuse_teardown_common(fuse, mountpoint);
|
||||
if (res == -1)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fuse_main_real(int argc, char *argv[], const struct fuse_operations *op,
|
||||
size_t op_size, void *user_data)
|
||||
{
|
||||
return fuse_main_common(argc, argv, op, op_size, user_data, 0);
|
||||
}
|
||||
|
||||
#undef fuse_main
|
||||
int fuse_main(void);
|
||||
int fuse_main(void)
|
||||
{
|
||||
fprintf(stderr, "fuse_main(): This function does not exist\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
int fuse_version(void)
|
||||
{
|
||||
return FUSE_VERSION;
|
||||
}
|
||||
|
||||
#include "fuse_compat.h"
|
||||
|
||||
#ifndef __FreeBSD__
|
||||
|
||||
struct fuse *fuse_setup_compat22(int argc, char *argv[],
|
||||
const struct fuse_operations_compat22 *op,
|
||||
size_t op_size, char **mountpoint,
|
||||
int *multithreaded, int *fd)
|
||||
{
|
||||
return fuse_setup_common(argc, argv, (struct fuse_operations *) op,
|
||||
op_size, mountpoint, multithreaded, fd, NULL,
|
||||
22);
|
||||
}
|
||||
|
||||
struct fuse *fuse_setup_compat2(int argc, char *argv[],
|
||||
const struct fuse_operations_compat2 *op,
|
||||
char **mountpoint, int *multithreaded,
|
||||
int *fd)
|
||||
{
|
||||
return fuse_setup_common(argc, argv, (struct fuse_operations *) op,
|
||||
sizeof(struct fuse_operations_compat2),
|
||||
mountpoint, multithreaded, fd, NULL, 21);
|
||||
}
|
||||
|
||||
int fuse_main_real_compat22(int argc, char *argv[],
|
||||
const struct fuse_operations_compat22 *op,
|
||||
size_t op_size)
|
||||
{
|
||||
return fuse_main_common(argc, argv, (struct fuse_operations *) op,
|
||||
op_size, NULL, 22);
|
||||
}
|
||||
|
||||
void fuse_main_compat1(int argc, char *argv[],
|
||||
const struct fuse_operations_compat1 *op)
|
||||
{
|
||||
fuse_main_common(argc, argv, (struct fuse_operations *) op,
|
||||
sizeof(struct fuse_operations_compat1), NULL, 11);
|
||||
}
|
||||
|
||||
int fuse_main_compat2(int argc, char *argv[],
|
||||
const struct fuse_operations_compat2 *op)
|
||||
{
|
||||
return fuse_main_common(argc, argv, (struct fuse_operations *) op,
|
||||
sizeof(struct fuse_operations_compat2), NULL,
|
||||
21);
|
||||
}
|
||||
|
||||
int fuse_mount_compat1(const char *mountpoint, const char *args[])
|
||||
{
|
||||
/* just ignore mount args for now */
|
||||
(void) args;
|
||||
return fuse_mount_compat22(mountpoint, NULL);
|
||||
}
|
||||
|
||||
FUSE_SYMVER(".symver fuse_setup_compat2,__fuse_setup@");
|
||||
FUSE_SYMVER(".symver fuse_setup_compat22,fuse_setup@FUSE_2.2");
|
||||
FUSE_SYMVER(".symver fuse_teardown,__fuse_teardown@");
|
||||
FUSE_SYMVER(".symver fuse_main_compat2,fuse_main@");
|
||||
FUSE_SYMVER(".symver fuse_main_real_compat22,fuse_main_real@FUSE_2.2");
|
||||
|
||||
#endif /* __FreeBSD__ */
|
||||
|
||||
|
||||
struct fuse *fuse_setup_compat25(int argc, char *argv[],
|
||||
const struct fuse_operations_compat25 *op,
|
||||
size_t op_size, char **mountpoint,
|
||||
int *multithreaded, int *fd)
|
||||
{
|
||||
return fuse_setup_common(argc, argv, (struct fuse_operations *) op,
|
||||
op_size, mountpoint, multithreaded, fd, NULL,
|
||||
25);
|
||||
}
|
||||
|
||||
int fuse_main_real_compat25(int argc, char *argv[],
|
||||
const struct fuse_operations_compat25 *op,
|
||||
size_t op_size)
|
||||
{
|
||||
return fuse_main_common(argc, argv, (struct fuse_operations *) op,
|
||||
op_size, NULL, 25);
|
||||
}
|
||||
|
||||
void fuse_teardown_compat22(struct fuse *fuse, int fd, char *mountpoint)
|
||||
{
|
||||
(void) fd;
|
||||
fuse_teardown_common(fuse, mountpoint);
|
||||
}
|
||||
|
||||
int fuse_mount_compat25(const char *mountpoint, struct fuse_args *args)
|
||||
{
|
||||
return fuse_kern_mount(mountpoint, args);
|
||||
}
|
||||
|
||||
FUSE_SYMVER(".symver fuse_setup_compat25,fuse_setup@FUSE_2.5");
|
||||
FUSE_SYMVER(".symver fuse_teardown_compat22,fuse_teardown@FUSE_2.2");
|
||||
FUSE_SYMVER(".symver fuse_main_real_compat25,fuse_main_real@FUSE_2.5");
|
||||
FUSE_SYMVER(".symver fuse_mount_compat25,fuse_mount@FUSE_2.5");
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user