aboutsummaryrefslogtreecommitdiffstats
path: root/fstools
diff options
context:
space:
mode:
Diffstat (limited to 'fstools')
-rw-r--r--fstools/Android.mk69
-rw-r--r--fstools/fstools.cpp23
-rw-r--r--fstools/fstools.h78
3 files changed, 170 insertions, 0 deletions
diff --git a/fstools/Android.mk b/fstools/Android.mk
new file mode 100644
index 0000000..73dc0f0
--- /dev/null
+++ b/fstools/Android.mk
@@ -0,0 +1,69 @@
+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 += \
+ 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_WHOLE_STATIC_LIBRARIES += \
+ libsgdisk_static
+
+LOCAL_STATIC_LIBRARIES := \
+ libext2_blkid \
+ libext2_uuid \
+ libext2_profile \
+ libext2_quota \
+ libext2_com_err \
+ libext2_e2p \
+ libc++_static \
+ libc \
+ libm
+
+FSTOOLS_LINKS := \
+ e2fsck mke2fs tune2fs fsck.ext4 mkfs.ext4 \
+ fsck.ntfs mkfs.ntfs mount.ntfs \
+ mkfs.f2fs fsck.f2fs
+
+ifeq ($(TARGET_USES_EXFAT),true)
+LOCAL_CFLAGS += -DHAVE_EXFAT
+LOCAL_WHOLE_STATIC_LIBRARIES += \
+ libexfat_static \
+ libexfat_fsck_static \
+ libexfat_mkfs_static \
+ libexfat_mount_static
+FSTOOLS_LINKS += \
+ fsck.exfat mkfs.exfat mount.exfat
+endif
+
+FSTOOLS_LINKS += \
+ sgdisk
+
+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..d99b382
--- /dev/null
+++ b/fstools/fstools.h
@@ -0,0 +1,78 @@
+/*
+ * 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);
+
+#ifdef HAVE_EXFAT
+int fsck_exfat_main(int argc, char **argv);
+int mkfs_exfat_main(int argc, char **argv);
+int mount_exfat_main(int argc, char **argv);
+#endif
+
+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);
+
+int sgdisk_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 },
+#ifdef HAVE_EXFAT
+ { "fsck.exfat", fsck_exfat_main },
+ { "mkfs.exfat", mkfs_exfat_main },
+ { "mount.exfat", mount_exfat_main },
+#endif
+ { "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 },
+ { "sgdisk", sgdisk_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