Whamcloud - gitweb
tune2fs: allow tune2fs to be built as a static library for Android
authorTheodore Ts'o <tytso@mit.edu>
Sun, 12 Jul 2015 21:39:26 +0000 (17:39 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 13 Jul 2015 00:21:17 +0000 (20:21 -0400)
Sync up with aosp's e2fsprogs commits:

    d25948b9b4a9e361ef071dc8175df0407f60b7e0
    e59f7c7cedb1e07eb4dbbb66e115c14faea19f19

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
lib/blkid/Android.mk
lib/e2p/Android.mk
lib/et/Android.mk
lib/ext2fs/Android.mk
lib/support/Android.mk
misc/Android.mk
misc/tune2fs.c
misc/tune2fs.h [new file with mode: 0644]

index 95fe681..8a7bdd2 100644 (file)
@@ -19,6 +19,10 @@ libext2_blkid_shared_libraries := libext2_uuid
 
 libext2_blkid_system_shared_libraries := libc
 
+libext2_blkid_static_libraries := libext2_uuid_static
+
+libext2_blkid_system_static_libraries := libc
+
 libext2_blkid_c_includes := external/e2fsprogs/lib
 
 libext2_blkid_cflags := -O2 -g -W -Wall -fno-strict-aliasing
@@ -38,6 +42,18 @@ include $(BUILD_SHARED_LIBRARY)
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES := $(libext2_blkid_src_files)
+LOCAL_STATIC_LIBRARIES := $(libext2_blkid_static_libraries) $(libext2_blkid_system_static_libraries)
+LOCAL_C_INCLUDES := $(libext2_blkid_c_includes)
+LOCAL_CFLAGS := $(libext2_blkid_cflags) $(libext2_blkid_cflags_linux) -fno-strict-aliasing
+LOCAL_PRELINK_MODULE := false
+LOCAL_MODULE := libext2_blkid
+LOCAL_MODULE_TAGS := optional
+
+include $(BUILD_STATIC_LIBRARY)
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(libext2_blkid_src_files)
 LOCAL_SHARED_LIBRARIES := $(addsuffix _host, $(libext2_blkid_shared_libraries))
 LOCAL_C_INCLUDES := $(libext2_blkid_c_includes)
 LOCAL_CFLAGS := $(libext2_blkid_cflags)
index 87a57ff..3d7aad5 100644 (file)
@@ -28,6 +28,8 @@ libext2_e2p_cflags := -O2 -g -W -Wall
 
 libext2_e2p_system_shared_libraries := libc
 
+libext2_e2p_system_static_libraries := libc
+
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES := $(libext2_e2p_src_files)
@@ -44,6 +46,18 @@ include $(CLEAR_VARS)
 LOCAL_SRC_FILES := $(libext2_e2p_src_files)
 LOCAL_C_INCLUDES := $(libext2_e2p_c_includes)
 LOCAL_CFLAGS := $(libext2_e2p_cflags)
+LOCAL_STATIC_LIBRARIES := $(libext2_e2p_system_static_libraries)
+LOCAL_PRELINK_MODULE := false
+LOCAL_MODULE := libext2_e2p
+LOCAL_MODULE_TAGS := optional
+
+include $(BUILD_STATIC_LIBRARY)
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(libext2_e2p_src_files)
+LOCAL_C_INCLUDES := $(libext2_e2p_c_includes)
+LOCAL_CFLAGS := $(libext2_e2p_cflags)
 LOCAL_MODULE := libext2_e2p_host
 LOCAL_MODULE_TAGS := optional
 
index c69eca3..5b6c969 100644 (file)
@@ -29,6 +29,18 @@ include $(CLEAR_VARS)
 LOCAL_SRC_FILES := $(libext2_com_err_src_files)
 LOCAL_C_INCLUDES := $(libext2_com_err_c_includes)
 LOCAL_CFLAGS := $(libext2_com_err_cflags)
+LOCAL_STATIC_LIBRARIES := libc
+LOCAL_MODULE := libext2_com_err
+LOCAL_MODULE_TAGS := optional
+LOCAL_PRELINK_MODULE := false
+
+include $(BUILD_STATIC_LIBRARY)
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(libext2_com_err_src_files)
+LOCAL_C_INCLUDES := $(libext2_com_err_c_includes)
+LOCAL_CFLAGS := $(libext2_com_err_cflags)
 LOCAL_MODULE := libext2_com_err_host
 LOCAL_MODULE_TAGS := optional
 
index 0e87943..cbfbe65 100644 (file)
@@ -92,6 +92,14 @@ libext2fs_shared_libraries := \
 
 libext2fs_system_shared_libraries := libc
 
+libext2fs_static_libraries := \
+       libext2_com_err \
+       libext2_uuid_static \
+       libext2_blkid \
+       libext2_e2p
+
+libext2fs_system_static_libraries := libc
+
 libext2fs_c_includes := external/e2fsprogs/lib
 
 libext2fs_cflags := -O2 -g -W -Wall
@@ -111,6 +119,18 @@ include $(BUILD_SHARED_LIBRARY)
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES := $(libext2fs_src_files)
+LOCAL_STATIC_LIBRARIES := $(libext2fs_static_libraries) $(libext2fs_system_static_libraries)
+LOCAL_C_INCLUDES := $(libext2fs_c_includes)
+LOCAL_CFLAGS := $(libext2fs_cflags) $(libext2fs_cflags_linux)
+LOCAL_PRELINK_MODULE := false
+LOCAL_MODULE := libext2fs
+LOCAL_MODULE_TAGS := optional
+
+include $(BUILD_STATIC_LIBRARY)
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(libext2fs_src_files)
 LOCAL_SHARED_LIBRARIES := $(addsuffix _host, $(libext2fs_shared_libraries))
 LOCAL_C_INCLUDES := $(libext2fs_c_includes)
 LOCAL_CFLAGS := $(libext2fs_cflags)
index 7aa82cb..e657edb 100644 (file)
@@ -27,6 +27,20 @@ LOCAL_MODULE_TAGS := optional
 
 include $(BUILD_SHARED_LIBRARY)
 
+libext2_quota_static_libraries := libext2fs libext2_com_err
+
+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_PRELINK_MODULE := false
+LOCAL_MODULE := libext2_quota
+LOCAL_MODULE_TAGS := optional
+
+include $(BUILD_STATIC_LIBRARY)
+
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES := $(libext2_quota_src_files)
index 689e127..b328e14 100644 (file)
@@ -74,6 +74,17 @@ tune2fs_shared_libraries := \
 
 tune2fs_system_shared_libraries := libc
 
+
+tune2fs_static_libraries := \
+       libext2_com_err \
+       libext2_blkid \
+       libext2_quota \
+       libext2_uuid_static \
+       libext2_e2p \
+       libext2fs
+
+tune2fs_system_static_libraries := libc
+
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES := $(tune2fs_src_files)
@@ -91,6 +102,29 @@ include $(CLEAR_VARS)
 LOCAL_SRC_FILES := $(tune2fs_src_files)
 LOCAL_C_INCLUDES := $(tune2fs_c_includes)
 LOCAL_CFLAGS := $(tune2fs_cflags)
+LOCAL_STATIC_LIBRARIES := $(tune2fs_static_libraries) $(tune2fs_system_static_libraries)
+LOCAL_FORCE_STATIC_EXECUTABLE := true
+LOCAL_MODULE := tune2fs_static
+LOCAL_MODULE_TAGS := optional
+
+include $(BUILD_EXECUTABLE)
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(tune2fs_src_files)
+LOCAL_C_INCLUDES := $(tune2fs_c_includes)
+LOCAL_CFLAGS := $(tune2fs_cflags) -DBUILD_AS_LIB
+LOCAL_STATIC_LIBRARIES := $(tune2fs_static_libraries) $(tune2fs_system_static_libraries)
+LOCAL_MODULE := libtune2fs
+LOCAL_MODULE_TAGS := optional
+
+include $(BUILD_STATIC_LIBRARY)
+
+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
index f462516..73f4bb6 100644 (file)
@@ -2650,7 +2650,11 @@ fs_update_journal_user(struct ext2_super_block *sb, __u8 old_uuid[UUID_SIZE])
        return 0;
 }
 
+#ifndef BUILD_AS_LIB
 int main(int argc, char **argv)
+#else
+int tune2fs_main(int argc, char **argv)
+#endif  /* BUILD_AS_LIB */
 {
        errcode_t retval;
        ext2_filsys fs;
@@ -3095,7 +3099,9 @@ retry_open:
 closefs:
        if (rc) {
                ext2fs_mmp_stop(fs);
+#ifndef BUILD_AS_LIB
                exit(1);
+#endif
        }
 
        convert_64bit(fs, feature_64bit);
diff --git a/misc/tune2fs.h b/misc/tune2fs.h
new file mode 100644 (file)
index 0000000..897e336
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * tune2fs.h - Change the file system parameters on an ext2 file system
+ *
+ * %Begin-Header%
+ * This file may be redistributed under the terms of the GNU Public
+ * License.
+ * %End-Header%
+ */
+
+/* Takes exactly the same args as the tune2fs exectuable.
+ * Is the entrypoint for libtune2fs.
+ */
+int tune2fs_main(int argc, char **argv);