diff --git a/fastboot/Android.mk b/fastboot/Android.mk index bc8800296..7723ec678 100644 --- a/fastboot/Android.mk +++ b/fastboot/Android.mk @@ -23,7 +23,6 @@ LOCAL_CFLAGS += -DFASTBOOT_VERSION="\"$(tool_version)\"" LOCAL_C_INCLUDES := \ $(LOCAL_PATH)/../adb \ $(LOCAL_PATH)/../mkbootimg \ - $(LOCAL_PATH)/../../extras/f2fs_utils \ LOCAL_SRC_FILES := \ bootimg_utils.cpp \ @@ -67,13 +66,7 @@ LOCAL_STATIC_LIBRARIES := \ libcutils \ libgtest_host \ -# libf2fs_dlutils_host will dlopen("libf2fs_fmt_host_dyn") LOCAL_CFLAGS_linux := -DUSE_F2FS -LOCAL_LDFLAGS_linux := -ldl -rdynamic -Wl,-rpath,. -LOCAL_REQUIRED_MODULES_linux := libf2fs_fmt_host_dyn -# The following libf2fs_* are from system/extras/f2fs_utils, -# and do not use code in external/f2fs-tools. -LOCAL_STATIC_LIBRARIES_linux += libf2fs_utils_host libf2fs_ioutils_host libf2fs_dlutils_host LOCAL_CXX_STL := libc++_static @@ -87,9 +80,6 @@ include $(BUILD_HOST_EXECUTABLE) my_dist_files := $(LOCAL_BUILT_MODULE) my_dist_files += $(HOST_OUT_EXECUTABLES)/mke2fs$(HOST_EXECUTABLE_SUFFIX) my_dist_files += $(HOST_OUT_EXECUTABLES)/e2fsdroid$(HOST_EXECUTABLE_SUFFIX) -ifeq ($(HOST_OS),linux) -my_dist_files += $(HOST_LIBRARY_PATH)/libf2fs_fmt_host_dyn$(HOST_SHLIB_SUFFIX) -endif $(call dist-for-goals,dist_files sdk win_sdk,$(my_dist_files)) ifdef HOST_CROSS_OS # Archive fastboot.exe for win_sdk build. diff --git a/fastboot/fs.cpp b/fastboot/fs.cpp index 2d77dd6eb..8877b09b7 100644 --- a/fastboot/fs.cpp +++ b/fastboot/fs.cpp @@ -1,7 +1,6 @@ #include "fs.h" #include "fastboot.h" -#include "make_f2fs.h" #include #include @@ -23,7 +22,6 @@ #include #include #include -#include using android::base::StringPrintf; using android::base::unique_fd; @@ -160,16 +158,32 @@ static int generate_ext4_image(const char* fileName, long long partSize, static int generate_f2fs_image(const char* fileName, long long partSize, const std::string& initial_dir, unsigned /* unused */, unsigned /* unused */) { + const std::string exec_dir = android::base::GetExecutableDirectory(); + const std::string mkf2fs_path = exec_dir + "/make_f2fs"; + std::vector mkf2fs_args = {mkf2fs_path.c_str()}; + + mkf2fs_args.push_back("-S"); + std::string size_str = std::to_string(partSize); + mkf2fs_args.push_back(size_str.c_str()); + mkf2fs_args.push_back("-f"); + mkf2fs_args.push_back("-O"); + mkf2fs_args.push_back("encrypt"); + mkf2fs_args.push_back("-O"); + mkf2fs_args.push_back("quota"); + mkf2fs_args.push_back(fileName); + mkf2fs_args.push_back(nullptr); + + int ret = exec_e2fs_cmd(mkf2fs_args[0], const_cast(mkf2fs_args.data())); + if (ret != 0) { + fprintf(stderr, "mkf2fs failed: %d\n", ret); + return -1; + } + if (!initial_dir.empty()) { fprintf(stderr, "Unable to set initial directory on F2FS filesystem: %s\n", strerror(errno)); return -1; } - unique_fd fd(open(fileName, O_CREAT | O_RDWR | O_TRUNC, S_IRUSR | S_IWUSR)); - if (fd == -1) { - fprintf(stderr, "Unable to open output file for F2FS filesystem: %s\n", strerror(errno)); - return -1; - } - return make_f2fs_sparse_fd(fd, partSize, NULL, NULL); + return 0; } #endif