OSDN Git Service

exfat: Recovery friendliness
authorSteve Kondik <shade@chemlab.org>
Sat, 17 Aug 2013 06:45:58 +0000 (23:45 -0700)
committerSteve Kondik <shade@chemlab.org>
Mon, 19 Aug 2013 02:07:39 +0000 (19:07 -0700)
 * We can't link this code with recovery due to the use of GPL, so let's
   build a multi-call binary to be space efficient.

Change-Id: I147e4a17422f0050426a8f996bdfeaf3f08feacf

Android.mk
fsck/Android.mk
fsck/main.c
fuse/Android.mk
fuse/main.c
main.c [new file with mode: 0644]
mkfs/Android.mk
mkfs/main.c

index 5053e7d..02da09f 100644 (file)
@@ -1 +1,56 @@
-include $(call all-subdir-makefiles)
+FUSE_ROOT := $(call my-dir)
+
+LINKS := fsck.exfat mkfs.exfat
+
+LOCAL_PATH := $(call my-dir)
+
+# multi-call binary
+include $(CLEAR_VARS)
+LOCAL_MODULE := mount.exfat
+LOCAL_MODULE_TAGS := optional
+LOCAL_SRC_FILES := main.c
+LOCAL_SHARED_LIBRARIES += libz libc
+LOCAL_STATIC_LIBRARIES += libexfat_mount libexfat_fsck libexfat_mkfs
+LOCAL_STATIC_LIBRARIES += libexfat libfuse
+include $(BUILD_EXECUTABLE)
+
+SYMLINKS := $(addprefix $(TARGET_OUT)/bin/,$(LINKS))
+$(SYMLINKS): EXFAT_BINARY := $(LOCAL_MODULE)
+$(SYMLINKS): $(LOCAL_INSTALLED_MODULE) $(LOCAL_PATH)/Android.mk
+       @echo "Symlink: $@ -> $(EXFAT_BINARY)"
+       @mkdir -p $(dir $@)
+       @rm -rf $@
+       $(hide) ln -sf $(EXFAT_BINARY) $@
+
+ALL_DEFAULT_INSTALLED_MODULES += $(SYMLINKS)
+
+
+# static multi-call binary for recovery
+include $(CLEAR_VARS)
+LOCAL_MODULE := mount.exfat_static
+LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES
+LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin
+LOCAL_MODULE_STEM := mount.exfat
+LOCAL_MODULE_TAGS := optional
+LOCAL_SRC_FILES := main.c
+LOCAL_STATIC_LIBRARIES += libz libc
+LOCAL_STATIC_LIBRARIES += libexfat_mount libexfat_fsck libexfat_mkfs
+LOCAL_STATIC_LIBRARIES += libexfat libfuse
+LOCAL_FORCE_STATIC_EXECUTABLE := true
+include $(BUILD_EXECUTABLE)
+
+RECOVERY_SYMLINKS := $(addprefix $(TARGET_RECOVERY_ROOT_OUT)/sbin/,$(LINKS))
+$(RECOVERY_SYMLINKS): EXFAT_BINARY := mount.exfat
+$(RECOVERY_SYMLINKS): $(LOCAL_INSTALLED_MODULE) $(LOCAL_PATH)/Android.mk
+       @echo "Symlink: $@ -> $(EXFAT_BINARY)"
+       @mkdir -p $(dir $@)
+       @rm -rf $@
+       $(hide) ln -sf $(EXFAT_BINARY) $@
+
+ALL_DEFAULT_INSTALLED_MODULES += $(RECOVERY_SYMLINKS)
+
+
+include $(FUSE_ROOT)/libexfat/Android.mk
+include $(FUSE_ROOT)/fuse/Android.mk
+include $(FUSE_ROOT)/mkfs/Android.mk
+include $(FUSE_ROOT)/fsck/Android.mk
index eab2d97..1c46dfc 100644 (file)
@@ -2,15 +2,12 @@ LOCAL_PATH := $(call my-dir)
 
 include $(CLEAR_VARS)
 
-LOCAL_MODULE := fsck.exfat
+LOCAL_MODULE := libexfat_fsck
 LOCAL_MODULE_TAGS := optional
 LOCAL_CFLAGS = -D_FILE_OFFSET_BITS=64
 LOCAL_SRC_FILES =  main.c
 LOCAL_C_INCLUDES += $(LOCAL_PATH) \
                                        external/exfat/libexfat \
                                        external/fuse/include
-LOCAL_SHARED_LIBRARIES += libz libc libdl
-LOCAL_STATIC_LIBRARIES += libexfat libfuse
-
-include $(BUILD_EXECUTABLE)
+include $(BUILD_STATIC_LIBRARY)
 
index 104b8af..cb0082a 100644 (file)
@@ -129,7 +129,7 @@ static void usage(const char* prog)
        exit(1);
 }
 
-int main(int argc, char* argv[])
+int exfatfsck_main(int argc, char* argv[])
 {
        int opt;
        const char* spec = NULL;
index ff35c78..7f53b46 100644 (file)
@@ -1,7 +1,7 @@
 LOCAL_PATH := $(call my-dir)
 include $(CLEAR_VARS)
 
-LOCAL_MODULE := mount.exfat
+LOCAL_MODULE := libexfat_mount
 LOCAL_MODULE_TAGS := optional
 LOCAL_CFLAGS = -D_FILE_OFFSET_BITS=64
 LOCAL_SRC_FILES = main.c 
@@ -9,7 +9,4 @@ LOCAL_C_INCLUDES += $(LOCAL_PATH) \
                                        external/exfat/libexfat \
                                        external/fuse/include \
                                        external/fuse/android
-LOCAL_SHARED_LIBRARIES += libz libc libdl
-LOCAL_STATIC_LIBRARIES += libexfat libfuse
-
-include $(BUILD_EXECUTABLE)
+include $(BUILD_STATIC_LIBRARY)
index 191ae93..f676f10 100644 (file)
@@ -397,7 +397,7 @@ static char* add_fuse_options(char* options, const char* spec)
        return options;
 }
 
-int main(int argc, char* argv[])
+int mount_exfat_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);
@@ -528,7 +528,7 @@ int main(int argc, char* argv[])
        }
 
        /* go to background (unless "-d" option is passed) and run FUSE
-          main loop */
+               main loop */
        if (fuse_daemonize(debug) == 0)
        {
                if (fuse_loop(fh) != 0)
diff --git a/main.c b/main.c
new file mode 100644 (file)
index 0000000..09124f7
--- /dev/null
+++ b/main.c
@@ -0,0 +1,35 @@
+/*
+       exFAT file system multi-call binary
+
+       Copyright (C) 2011-2013  Andrew Nayenko
+    Copyright (C) 2013 The CyanogenMod Project
+
+       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>
+
+extern int mkexfatfs_main(int argc, char* argv[]);
+extern int exfatfsck_main(int argc, char* argv[]);
+extern int mount_exfat_main(int argc, char* argv[]);
+
+int main(int argc, char* argv[])
+{
+    if (strstr(argv[0], "mkfs.exfat") != 0)
+        return mkexfatfs_main(argc, argv);
+    if (strstr(argv[0], "fsck.exfat") != 0)
+        return exfatfsck_main(argc, argv);
+    return mount_exfat_main(argc, argv);
+}
index dfaae73..ead8ba2 100644 (file)
@@ -1,15 +1,11 @@
 LOCAL_PATH := $(call my-dir)
 
 include $(CLEAR_VARS)
-
-LOCAL_MODULE := mkfs.exfat
+LOCAL_MODULE := libexfat_mkfs
 LOCAL_MODULE_TAGS := optional
 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) \
                                        external/exfat/libexfat \
                                        external/fuse/include
-LOCAL_SHARED_LIBRARIES += libz libc libdl
-LOCAL_STATIC_LIBRARIES += libexfat libfuse
-
-include $(BUILD_EXECUTABLE)
+include $(BUILD_STATIC_LIBRARY)
index 8a419f1..d39344c 100644 (file)
@@ -192,7 +192,7 @@ static void usage(const char* prog)
        exit(1);
 }
 
-int main(int argc, char* argv[])
+int mkexfatfs_main(int argc, char* argv[])
 {
        const char* spec = NULL;
        int opt;