summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJaegeuk Kim <jaegeuk@google.com>2017-11-13 22:48:15 +0000
committerandroid-build-merger <android-build-merger@google.com>2017-11-13 22:48:15 +0000
commit6c2bfb95ee3826eefc970f5239c126c8f6f3d28b (patch)
tree7e5d57fef60508ecac62484db9ddb314f4865b01
parent8b03fd8441815dd94ce2ce23c80430dc8645a576 (diff)
parent21d3840eb39291bbc59f0dc5a33fc58b152994fe (diff)
downloadsystem_core-6c2bfb95ee3826eefc970f5239c126c8f6f3d28b.tar.gz
system_core-6c2bfb95ee3826eefc970f5239c126c8f6f3d28b.tar.bz2
system_core-6c2bfb95ee3826eefc970f5239c126c8f6f3d28b.zip
Merge "fastboot: support f2fs format"
am: 21d3840eb3 Change-Id: I348a523a7822a73a9905a747789571457d2f193e
-rw-r--r--fastboot/Android.mk10
-rw-r--r--fastboot/fs.cpp30
2 files changed, 22 insertions, 18 deletions
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 <errno.h>
#include <fcntl.h>
@@ -23,7 +22,6 @@
#include <android-base/file.h>
#include <android-base/stringprintf.h>
#include <android-base/unique_fd.h>
-#include <sparse/sparse.h>
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 */)
{
- if (!initial_dir.empty()) {
- fprintf(stderr, "Unable to set initial directory on F2FS filesystem: %s\n", strerror(errno));
+ const std::string exec_dir = android::base::GetExecutableDirectory();
+ const std::string mkf2fs_path = exec_dir + "/make_f2fs";
+ std::vector<const char*> 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<char**>(mkf2fs_args.data()));
+ if (ret != 0) {
+ fprintf(stderr, "mkf2fs failed: %d\n", ret);
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));
+
+ if (!initial_dir.empty()) {
+ fprintf(stderr, "Unable to set initial directory on F2FS filesystem: %s\n", strerror(errno));
return -1;
}
- return make_f2fs_sparse_fd(fd, partSize, NULL, NULL);
+ return 0;
}
#endif