aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--e2fsck/Android.mk44
-rw-r--r--lib/blkid/Android.mk1
-rw-r--r--lib/blkid/probe.c10
-rw-r--r--lib/blkid/probe_exfat.c181
-rw-r--r--lib/quota/Android.mk3
-rw-r--r--lib/uuid/Android.mk12
-rw-r--r--misc/Android.mk66
-rw-r--r--resize/Android.mk13
8 files changed, 329 insertions, 1 deletions
diff --git a/e2fsck/Android.mk b/e2fsck/Android.mk
index b4b2aef9..01bca062 100644
--- a/e2fsck/Android.mk
+++ b/e2fsck/Android.mk
@@ -56,6 +56,18 @@ include $(BUILD_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(libext2_profile_src_files)
+LOCAL_STATIC_LIBRARIES := $(libext2_profile_system_shared_libraries) $(libext2_profile_shared_libraries)
+LOCAL_C_INCLUDES := $(libext2_profile_c_includes)
+LOCAL_CFLAGS := $(libext2_profile_cflags)
+LOCAL_PRELINK_MODULE := false
+LOCAL_MODULE := libext2_profile
+LOCAL_MODULE_TAGS := optional
+
+include $(BUILD_STATIC_LIBRARY)
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(libext2_profile_src_files)
LOCAL_SHARED_LIBRARIES := $(addsuffix _host, $(libext2_profile_shared_libraries))
LOCAL_C_INCLUDES := $(libext2_profile_c_includes)
LOCAL_CFLAGS := $(libext2_profile_cflags)
@@ -156,6 +168,38 @@ include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(e2fsck_src_files)
LOCAL_C_INCLUDES := $(e2fsck_c_includes)
LOCAL_CFLAGS := $(e2fsck_cflags)
+LOCAL_STATIC_LIBRARIES := $(e2fsck_system_shared_libraries) $(e2fsck_shared_libraries) libext2fs
+LOCAL_MODULE := recovery_e2fsck
+LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES
+LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin
+LOCAL_UNSTRIPPED_PATH := $(PRODUCT_OUT)/symbols/recovery
+LOCAL_MODULE_STEM := e2fsck
+LOCAL_FORCE_STATIC_EXECUTABLE := true
+LOCAL_PACK_MODULE_RELOCATIONS := false
+LOCAL_MODULE_TAGS := optional
+include $(BUILD_EXECUTABLE)
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(e2fsck_src_files)
+LOCAL_C_INCLUDES := $(e2fsck_c_includes)
+LOCAL_CFLAGS := $(e2fsck_cflags)
+LOCAL_STATIC_LIBRARIES := $(e2fsck_system_shared_libraries) $(e2fsck_shared_libraries) libext2fs
+LOCAL_MODULE := utility_e2fsck
+LOCAL_MODULE_CLASS := UTILITY_EXECUTABLES
+LOCAL_MODULE_PATH := $(PRODUCT_OUT)/utilities
+LOCAL_UNSTRIPPED_PATH := $(PRODUCT_OUT)/symbols/utilities
+LOCAL_MODULE_STEM := e2fsck
+LOCAL_FORCE_STATIC_EXECUTABLE := true
+LOCAL_MODULE_TAGS := optional
+LOCAL_PACK_MODULE_RELOCATIONS := false
+include $(BUILD_EXECUTABLE)
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(e2fsck_src_files)
+LOCAL_C_INCLUDES := $(e2fsck_c_includes)
+LOCAL_CFLAGS := $(e2fsck_cflags)
LOCAL_SHARED_LIBRARIES := $(addsuffix _host, $(e2fsck_shared_libraries))
LOCAL_MODULE := e2fsck_host
LOCAL_MODULE_STEM := e2fsck
diff --git a/lib/blkid/Android.mk b/lib/blkid/Android.mk
index 7682ce1a..8fdebe36 100644
--- a/lib/blkid/Android.mk
+++ b/lib/blkid/Android.mk
@@ -8,6 +8,7 @@ libext2_blkid_src_files := \
getsize.c \
llseek.c \
probe.c \
+ probe_exfat.c \
read.c \
resolve.c \
save.c \
diff --git a/lib/blkid/probe.c b/lib/blkid/probe.c
index 8215768d..b8922e3b 100644
--- a/lib/blkid/probe.c
+++ b/lib/blkid/probe.c
@@ -36,6 +36,10 @@
#include "uuid/uuid.h"
#include "probe.h"
+extern int probe_exfat(struct blkid_probe *probe,
+ struct blkid_magic *id __BLKID_ATTR((unused)),
+ unsigned char *buf);
+
static int figure_label_len(const unsigned char *label, int len)
{
const unsigned char *end = label + len - 1;
@@ -85,6 +89,11 @@ static unsigned char *get_buffer(struct blkid_probe *pr,
}
}
+unsigned char *blkid_probe_get_buffer(struct blkid_probe *pr,
+ blkid_loff_t off, size_t len)
+{
+ return get_buffer(pr, off, len);
+}
/*
* This is a special case code to check for an MDRAID device. We do
@@ -1407,6 +1416,7 @@ static struct blkid_magic type_array[] = {
/* type kboff sboff len magic probe */
{ "oracleasm", 0, 32, 8, "ORCLDISK", probe_oracleasm },
{ "ntfs", 0, 3, 8, "NTFS ", probe_ntfs },
+ { "exfat", 0, 3, 8, "EXFAT ", probe_exfat },
{ "jbd", 1, 0x38, 2, "\123\357", probe_jbd },
{ "ext4dev", 1, 0x38, 2, "\123\357", probe_ext4dev },
{ "ext4", 1, 0x38, 2, "\123\357", probe_ext4 },
diff --git a/lib/blkid/probe_exfat.c b/lib/blkid/probe_exfat.c
new file mode 100644
index 00000000..24ac03e1
--- /dev/null
+++ b/lib/blkid/probe_exfat.c
@@ -0,0 +1,181 @@
+/*
+ * Copyright (C) 2010 Andrew Nayenko <resver@gmail.com>
+ *
+ * This file may be redistributed under the terms of the
+ * GNU Lesser General Public License.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <math.h>
+#include "blkidP.h"
+#include "probe.h"
+
+#define le32_to_cpu(x) blkid_le32(x)
+
+typedef __u8 uint8_t;
+typedef __u16 uint16_t;
+typedef __u32 uint32_t;
+typedef __uint64_t uint64_t;
+
+typedef struct blkid_probe* blkid_probe;
+
+struct exfat_super_block {
+ __u8 jump[3];
+ __u8 oem_name[8];
+ __u8 __unused1[53];
+ __u64 block_start;
+ __u64 block_count;
+ __u32 fat_block_start;
+ __u32 fat_block_count;
+ __u32 cluster_block_start;
+ __u32 cluster_count;
+ __u32 rootdir_cluster;
+ __u8 volume_serial[4];
+ struct {
+ __u8 minor;
+ __u8 major;
+ } version;
+ __u16 volume_state;
+ __u8 block_bits;
+ __u8 bpc_bits;
+ __u8 fat_count;
+ __u8 drive_no;
+ __u8 allocated_percent;
+} __attribute__((__packed__));
+
+struct exfat_entry_label {
+ __u8 type;
+ __u8 length;
+ __u8 name[30];
+} __attribute__((__packed__));
+
+#define BLOCK_SIZE(sb) (1 << (sb)->block_bits)
+#define CLUSTER_SIZE(sb) (BLOCK_SIZE(sb) << (sb)->bpc_bits)
+#define EXFAT_FIRST_DATA_CLUSTER 2
+#define EXFAT_LAST_DATA_CLUSTER 0xffffff6
+#define EXFAT_ENTRY_SIZE 32
+
+#define EXFAT_ENTRY_EOD 0x00
+#define EXFAT_ENTRY_LABEL 0x83
+
+static blkid_loff_t block_to_offset(const struct exfat_super_block *sb,
+ blkid_loff_t block)
+{
+ return (blkid_loff_t) block << sb->block_bits;
+}
+
+static blkid_loff_t cluster_to_block(const struct exfat_super_block *sb,
+ uint32_t cluster)
+{
+ return le32_to_cpu(sb->cluster_block_start) +
+ ((blkid_loff_t) (cluster - EXFAT_FIRST_DATA_CLUSTER)
+ << sb->bpc_bits);
+}
+
+static blkid_loff_t cluster_to_offset(const struct exfat_super_block *sb,
+ uint32_t cluster)
+{
+ return block_to_offset(sb, cluster_to_block(sb, cluster));
+}
+
+extern unsigned char *blkid_probe_get_buffer(struct blkid_probe *pr,
+ blkid_loff_t off, size_t len);
+
+static uint32_t next_cluster(blkid_probe pr,
+ const struct exfat_super_block *sb, uint32_t cluster)
+{
+ uint32_t *next;
+ blkid_loff_t fat_offset;
+
+ fat_offset = block_to_offset(sb, le32_to_cpu(sb->fat_block_start))
+ + (blkid_loff_t) cluster * sizeof(cluster);
+ next = (uint32_t *) blkid_probe_get_buffer(pr, fat_offset,
+ sizeof(uint32_t));
+ if (!next)
+ return 0;
+ return le32_to_cpu(*next);
+}
+
+static struct exfat_entry_label *find_label(blkid_probe pr,
+ const struct exfat_super_block *sb)
+{
+ uint32_t cluster = le32_to_cpu(sb->rootdir_cluster);
+ blkid_loff_t offset = cluster_to_offset(sb, cluster);
+ uint8_t *entry;
+
+ for (;;) {
+ entry = (uint8_t *) blkid_probe_get_buffer(pr, offset,
+ EXFAT_ENTRY_SIZE);
+ if (!entry)
+ return NULL;
+ if (entry[0] == EXFAT_ENTRY_EOD)
+ return NULL;
+ if (entry[0] == EXFAT_ENTRY_LABEL)
+ return (struct exfat_entry_label *) entry;
+ offset += EXFAT_ENTRY_SIZE;
+ if (offset % CLUSTER_SIZE(sb) == 0) {
+ cluster = next_cluster(pr, sb, cluster);
+ if (cluster < EXFAT_FIRST_DATA_CLUSTER)
+ return NULL;
+ if (cluster > EXFAT_LAST_DATA_CLUSTER)
+ return NULL;
+ offset = cluster_to_offset(sb, cluster);
+ }
+ }
+}
+
+static void unicode_16le_to_utf8(unsigned char *str, int out_len,
+ const unsigned char *buf, int in_len)
+{
+ int i, j;
+ unsigned int c;
+
+ for (i = j = 0; i + 2 <= in_len; i += 2) {
+ c = (buf[i+1] << 8) | buf[i];
+ if (c == 0) {
+ str[j] = '\0';
+ break;
+ } else if (c < 0x80) {
+ if (j+1 >= out_len)
+ break;
+ str[j++] = (unsigned char) c;
+ } else if (c < 0x800) {
+ if (j+2 >= out_len)
+ break;
+ str[j++] = (unsigned char) (0xc0 | (c >> 6));
+ str[j++] = (unsigned char) (0x80 | (c & 0x3f));
+ } else {
+ if (j+3 >= out_len)
+ break;
+ str[j++] = (unsigned char) (0xe0 | (c >> 12));
+ str[j++] = (unsigned char) (0x80 | ((c >> 6) & 0x3f));
+ str[j++] = (unsigned char) (0x80 | (c & 0x3f));
+ }
+ }
+ str[j] = '\0';
+}
+
+int probe_exfat(struct blkid_probe *probe,
+ struct blkid_magic *id __BLKID_ATTR((unused)),
+ unsigned char *buf)
+{
+ struct exfat_super_block *sb;
+ struct exfat_entry_label *label;
+ char serno[10];
+
+ sb = (struct exfat_super_block *) buf;
+
+ sprintf(serno, "%02X%02X-%02X%02X",
+ sb->volume_serial[3], sb->volume_serial[2],
+ sb->volume_serial[1], sb->volume_serial[0]);
+
+ blkid_set_tag(probe->dev, "UUID", serno, sizeof(serno)-1);
+ label = find_label(probe, sb);
+ if (label) {
+ char utf8_label[128];
+ unicode_16le_to_utf8(utf8_label, sizeof(utf8_label), label->name, label->length * 2);
+ blkid_set_tag(probe->dev, "LABEL", utf8_label, 0);
+ }
+ return 0;
+}
diff --git a/lib/quota/Android.mk b/lib/quota/Android.mk
index ef599eab..c1b84b4a 100644
--- a/lib/quota/Android.mk
+++ b/lib/quota/Android.mk
@@ -55,7 +55,8 @@ include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(libext2_quota_src_files)
LOCAL_C_INCLUDES := $(libext2_quota_c_includes)
LOCAL_CFLAGS := $(libext2_quota_cflags)
-LOCAL_STATIC_LIBRARIES := libc $(libext2_quota_static_libraries)
+LOCAL_SYSTEM_STATIC_LIBRARIES := libc $(libext2_quota_shared_libraries) libext2fs
+LOCAL_PRELINK_MODULE := false
LOCAL_MODULE := libext2_quota
LOCAL_MODULE_TAGS := optional
diff --git a/lib/uuid/Android.mk b/lib/uuid/Android.mk
index a43a3619..2ce47c4d 100644
--- a/lib/uuid/Android.mk
+++ b/lib/uuid/Android.mk
@@ -62,6 +62,18 @@ LOCAL_SRC_FILES := $(libext2_uuid_src_files)
LOCAL_C_INCLUDES := $(libext2_uuid_c_includes)
LOCAL_CFLAGS := $(libext2_uuid_cflags)
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)
+LOCAL_STATIC_LIBRARIES := $(libext2_uuid_system_shared_libraries)
+LOCAL_MODULE := libext2_uuid
+LOCAL_MODULE_TAGS := eng
+LOCAL_PRELINK_MODULE := false
+
+include $(BUILD_STATIC_LIBRARY)
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(libext2_uuid_src_files)
+LOCAL_C_INCLUDES := $(libext2_uuid_c_includes)
+LOCAL_CFLAGS := $(libext2_uuid_cflags)
LOCAL_MODULE := libext2_uuid_host
LOCAL_MODULE_TAGS := optional
diff --git a/misc/Android.mk b/misc/Android.mk
index 645fc9cc..e70591d7 100644
--- a/misc/Android.mk
+++ b/misc/Android.mk
@@ -69,6 +69,40 @@ include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(mke2fs_src_files)
LOCAL_C_INCLUDES := $(mke2fs_c_includes)
+LOCAL_CFLAGS := $(mke2fs_cflags) $(mke2fs_cflags_linux)
+LOCAL_STATIC_LIBRARIES := $(mke2fs_shared_libraries)
+LOCAL_STATIC_LIBRARIES += $(mke2fs_system_shared_libraries) libext2fs
+LOCAL_MODULE := recovery_mke2fs
+LOCAL_MODULE_TAGS := eng
+LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES
+LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin
+LOCAL_UNSTRIPPED_PATH := $(PRODUCT_OUT)/symbols/recovery
+LOCAL_MODULE_STEM := mke2fs
+LOCAL_FORCE_STATIC_EXECUTABLE := true
+LOCAL_PACK_MODULE_RELOCATIONS := false
+include $(BUILD_EXECUTABLE)
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(mke2fs_src_files)
+LOCAL_C_INCLUDES := $(mke2fs_c_includes)
+LOCAL_CFLAGS := $(mke2fs_cflags) $(mke2fs_cflags_linux)
+LOCAL_STATIC_LIBRARIES := $(mke2fs_shared_libraries)
+LOCAL_STATIC_LIBRARIES += $(mke2fs_system_shared_libraries) libext2fs
+LOCAL_MODULE := utility_mke2fs
+LOCAL_MODULE_TAGS := eng
+LOCAL_MODULE_CLASS := UTILITY_EXECUTABLES
+LOCAL_MODULE_PATH := $(PRODUCT_OUT)/utilities
+LOCAL_UNSTRIPPED_PATH := $(PRODUCT_OUT)/symbols/utilities
+LOCAL_MODULE_STEM := mke2fs
+LOCAL_FORCE_STATIC_EXECUTABLE := true
+LOCAL_PACK_MODULE_RELOCATIONS := false
+include $(BUILD_EXECUTABLE)
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(mke2fs_src_files)
+LOCAL_C_INCLUDES := $(mke2fs_c_includes)
ifeq ($(HOST_OS),linux)
LOCAL_CFLAGS := $(mke2fs_cflags) $(mke2fs_cflags_linux)
else
@@ -183,6 +217,38 @@ include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(tune2fs_src_files)
LOCAL_C_INCLUDES := $(tune2fs_c_includes)
LOCAL_CFLAGS := $(tune2fs_cflags)
+LOCAL_STATIC_LIBRARIES := $(tune2fs_shared_libraries) $(tune2fs_system_shared_libraries) libext2fs
+LOCAL_MODULE := utility_tune2fs
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE_CLASS := UTILITY_EXECUTABLES
+LOCAL_MODULE_PATH := $(PRODUCT_OUT)/utilities
+LOCAL_UNSTRIPPED_PATH := $(PRODUCT_OUT)/symbols/utilities
+LOCAL_MODULE_STEM := tune2fs
+LOCAL_FORCE_STATIC_EXECUTABLE := true
+LOCAL_PACK_MODULE_RELOCATIONS := false
+include $(BUILD_EXECUTABLE)
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(tune2fs_src_files)
+LOCAL_C_INCLUDES := $(tune2fs_c_includes)
+LOCAL_CFLAGS := $(tune2fs_cflags)
+LOCAL_STATIC_LIBRARIES := $(tune2fs_shared_libraries) $(tune2fs_system_shared_libraries) libext2fs
+LOCAL_MODULE := recovery_tune2fs
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES
+LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin
+LOCAL_UNSTRIPPED_PATH := $(PRODUCT_OUT)/symbols/recovery
+LOCAL_MODULE_STEM := tune2fs
+LOCAL_FORCE_STATIC_EXECUTABLE := true
+LOCAL_PACK_MODULE_RELOCATIONS := false
+include $(BUILD_EXECUTABLE)
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(tune2fs_src_files)
+LOCAL_C_INCLUDES := $(tune2fs_c_includes)
+LOCAL_CFLAGS := $(tune2fs_cflags)
LOCAL_SHARED_LIBRARIES := $(addsuffix _host, $(tune2fs_shared_libraries))
LOCAL_MODULE := tune2fs_host
LOCAL_MODULE_STEM := tune2fs
diff --git a/resize/Android.mk b/resize/Android.mk
index 41f9fe08..81d609d8 100644
--- a/resize/Android.mk
+++ b/resize/Android.mk
@@ -61,6 +61,19 @@ include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(resize2fs_src_files)
LOCAL_C_INCLUDES := $(resize2fs_c_includes)
LOCAL_CFLAGS := $(resize2fs_cflags)
+LOCAL_STATIC_LIBRARIES := $(resize2fs_shared_libraries)
+LOCAL_STATIC_LIBRARIES += $(resize2fs_system_shared_libraries)
+LOCAL_MODULE := resize2fs_static
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE_PATH := $(PRODUCT_OUT)/install/bin
+LOCAL_FORCE_STATIC_EXECUTABLE := true
+include $(BUILD_EXECUTABLE)
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(resize2fs_src_files)
+LOCAL_C_INCLUDES := $(resize2fs_c_includes)
+LOCAL_CFLAGS := $(resize2fs_cflags)
LOCAL_SHARED_LIBRARIES := $(addsuffix _host, $(resize2fs_shared_libraries))
LOCAL_MODULE := resize2fs_host
LOCAL_MODULE_STEM := resize2fs