fastboot: support f2fs format
+ quota support This patch fixes broken f2fs_format by replacing the existing flow with calling legacy mkfs.f2fs binary explicitly likewise ext4. This removes obsolete ext4 stuffs as well. Bug: 67009570 Change-Id: Ia81bcbc7adc3a8b57ada860f7f7871602ac1c6e9 Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
This commit is contained in:
parent
d0d7346dc7
commit
d872118d88
2 changed files with 22 additions and 18 deletions
|
@ -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.
|
||||
|
|
|
@ -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 */)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
|
|
Loading…
Reference in a new issue