aboutsummaryrefslogtreecommitdiffstats
path: root/fstools
diff options
context:
space:
mode:
authorSteve Kondik <steve@cyngn.com>2015-11-10 14:18:38 +0100
committerTom Marshall <tdm@cyngn.com>2015-11-20 15:46:40 -0800
commit7eee7c2e8c653f41871b98e27b6fcbbed50e5bb8 (patch)
tree1158a4e25a426a78f572895e6ed52e11eb92f490 /fstools
parent9dc02b1f906832f2e741d7a73469e1f874dd52da (diff)
downloadbootable_recovery-7eee7c2e8c653f41871b98e27b6fcbbed50e5bb8.zip
bootable_recovery-7eee7c2e8c653f41871b98e27b6fcbbed50e5bb8.tar.gz
bootable_recovery-7eee7c2e8c653f41871b98e27b6fcbbed50e5bb8.tar.bz2
sr: Add fstools, update build configuration
* Make sure we create any dirs before trying to put symlinks in them * Create a new "fstools" target which aggregates all of our filesystem tools into a single multi-call binary. This reduces the overall recovery image size by a megabyte, and also removes GPL code from the main recovery binary. Change-Id: I5fc2a61d564915085071ccbbcb3136f45c640a60
Diffstat (limited to 'fstools')
-rw-r--r--fstools/Android.mk58
-rw-r--r--fstools/fstools.cpp23
-rw-r--r--fstools/fstools.h71
3 files changed, 152 insertions, 0 deletions
diff --git a/fstools/Android.mk b/fstools/Android.mk
new file mode 100644
index 0000000..787a382
--- /dev/null
+++ b/fstools/Android.mk
@@ -0,0 +1,58 @@
+LOCAL_PATH := $(call my-dir)
+
+# This is a multi-call static binary which contains the
+# GPL filesystem tools.
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := fstools
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin
+LOCAL_SRC_FILES := fstools.cpp
+LOCAL_FORCE_STATIC_EXECUTABLE := true
+
+LOCAL_WHOLE_STATIC_LIBRARIES += \
+ libfuse_static
+
+LOCAL_WHOLE_STATIC_LIBRARIES += \
+ libexfat_static \
+ libexfat_fsck_static \
+ libexfat_mkfs_static \
+ libexfat_mount_static
+
+LOCAL_WHOLE_STATIC_LIBRARIES += \
+ libntfs-3g_static \
+ libntfs3g_fsck_static \
+ libntfs3g_mkfs_main \
+ libntfs3g_mount_static
+
+LOCAL_WHOLE_STATIC_LIBRARIES += \
+ libext2fs \
+ libe2fsck_static \
+ libmke2fs_static \
+ libtune2fs
+
+LOCAL_WHOLE_STATIC_LIBRARIES += \
+ libf2fs_static \
+ libf2fs_fsck_static \
+ libf2fs_mkfs_static
+
+LOCAL_STATIC_LIBRARIES := \
+ libext2_blkid \
+ libext2_uuid \
+ libext2_profile \
+ libext2_quota \
+ libext2_com_err \
+ libext2_e2p \
+ libc++_static \
+ libc
+
+FSTOOLS_LINKS := \
+ e2fsck mke2fs tune2fs fsck.ext4 mkfs.ext4 \
+ fsck.exfat mkfs.exfat mount.exfat \
+ fsck.ntfs mkfs.ntfs mount.ntfs \
+ mkfs.f2fs fsck.f2fs
+
+LOCAL_POST_INSTALL_CMD := \
+ $(hide) $(foreach t,$(FSTOOLS_LINKS),ln -sf fstools $(TARGET_RECOVERY_ROOT_OUT)/sbin/$(t);)
+include $(BUILD_EXECUTABLE)
+
diff --git a/fstools/fstools.cpp b/fstools/fstools.cpp
new file mode 100644
index 0000000..b1cc7ad
--- /dev/null
+++ b/fstools/fstools.cpp
@@ -0,0 +1,23 @@
+#include <stdlib.h>
+
+extern "C" {
+#include "fstools.h"
+}
+
+
+int
+main(int argc, char **argv) {
+
+ // Handle alternative invocations
+ char* command = argv[0];
+ char* stripped = strrchr(argv[0], '/');
+ if (stripped)
+ command = stripped + 1;
+
+ if (strcmp(command, "fstools") != 0) {
+ struct fstools_cmd cmd = get_command(command);
+ if (cmd.name)
+ return cmd.main_func(argc, argv);
+ }
+ return -1;
+}
diff --git a/fstools/fstools.h b/fstools/fstools.h
new file mode 100644
index 0000000..2d666bd
--- /dev/null
+++ b/fstools/fstools.h
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2013 The CyanogenMod 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.
+ */
+
+#ifndef _FSTOOLS_CMDS_H
+#define _FSTOOLS_CMDS_H
+
+#include <stdio.h>
+#include <string.h>
+
+int e2fsck_main(int argc, char **argv);
+int mke2fs_main(int argc, char **argv);
+int tune2fs_main(int argc, char **argv);
+
+int fsck_exfat_main(int argc, char **argv);
+int mkfs_exfat_main(int argc, char **argv);
+int mount_exfat_main(int argc, char **argv);
+
+int fsck_ntfs3g_main(int argc, char **argv);
+int mkfs_ntfs3g_main(int argc, char **argv);
+int mount_ntfs3g_main(int argc, char **argv);
+
+int mkfs_f2fs_main(int argc, char **argv);
+int fsck_f2fs_main(int argc, char **argv);
+int fibmap_main(int argc, char **argv);
+
+struct fstools_cmd {
+ const char *name;
+ int (*main_func)(int argc, char **argv);
+};
+
+static const struct fstools_cmd fstools_cmds[] = {
+ { "e2fsck", e2fsck_main },
+ { "mke2fs", mke2fs_main },
+ { "tune2fs", tune2fs_main },
+ { "fsck.ext4", e2fsck_main },
+ { "mkfs.ext4", mke2fs_main },
+ { "fsck.exfat", fsck_exfat_main },
+ { "mkfs.exfat", mkfs_exfat_main },
+ { "mount.exfat", mount_exfat_main },
+ { "fsck.ntfs", fsck_ntfs3g_main },
+ { "mkfs.ntfs", mkfs_ntfs3g_main },
+ { "mount.ntfs", mount_ntfs3g_main },
+ { "mkfs.f2fs", mkfs_f2fs_main },
+ { "fsck.f2fs", fsck_f2fs_main },
+ { NULL, NULL },
+};
+
+struct fstools_cmd get_command(char* command) {
+ int i;
+
+ for (i = 0; fstools_cmds[i].name; i++) {
+ if (strcmp(command, fstools_cmds[i].name) == 0)
+ break;
+ }
+
+ return fstools_cmds[i];
+}
+#endif