Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1235158c authored by JP Abgrall's avatar JP Abgrall
Browse files

F2FS support for fastboot format and fsmgr



- Enables fsck.f2fs for partitions with type F2FS.
- Adds support for f2fs as format fs-type.
- f2fs is optional and support is dlopen()d when needed.

Needs changes in
  system/extras/f2fs_utils
  external/f2fs-tools

Change-Id: I8d141a0d4d14df9fe84d3b131484e9696fcd8870
Signed-off-by: default avatarJP Abgrall <jpa@google.com>
parent e1f7c176
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -17,7 +17,8 @@ LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)

LOCAL_C_INCLUDES := $(LOCAL_PATH)/../mkbootimg \
  $(LOCAL_PATH)/../../extras/ext4_utils
  $(LOCAL_PATH)/../../extras/ext4_utils \
  $(LOCAL_PATH)/../../extras/f2fs_utils
LOCAL_SRC_FILES := protocol.c engine.c bootimg.c fastboot.c util.c fs.c
LOCAL_MODULE := fastboot
LOCAL_MODULE_TAGS := debug
@@ -50,14 +51,20 @@ ifeq ($(HOST_OS),windows)
  LOCAL_C_INCLUDES += development/host/windows/usb/api
endif

# The following libf2fs_* are from system/extras/f2fs_utils,
# and do not use code in external/f2fs-tools.
LOCAL_STATIC_LIBRARIES := \
    $(EXTRA_STATIC_LIBS) \
    libzipfile \
    libunz \
    libext4_utils_host \
    libf2fs_utils_host \
    libf2fs_dlutils_host \
    libsparse_host \
    libz

# libf2fs_dlutils_host will dlopen("libf2fs_fmt_host_dyn")
LOCAL_LDLIBS := -ldl
LOCAL_SHARED_LIBRARIES := libf2fs_fmt_host_dyn
ifneq ($(HOST_OS),windows)
LOCAL_STATIC_LIBRARIES += libselinux
endif # HOST_OS != windows
+9 −3
Original line number Diff line number Diff line
#include "fastboot.h"
#include "make_ext4fs.h"
#include "make_f2fs.h"
#include "fs.h"

#include <errno.h>
@@ -28,15 +29,20 @@ static int generate_ext4_image(int fd, long long partSize)
    return 0;
}

int generate_f2fs_image(int fd, long long partSize)
{
    make_f2fs_sparse_fd(fd, partSize, NULL, NULL);
    return 0;
}

static const struct fs_generator {

    char *fs_type;  //must match what fastboot reports for partition type
    int (*generate)(int fd, long long partSize); //returns 0 or error value

} generators[] = {

    { "ext4", generate_ext4_image}

    { "ext4", generate_ext4_image},
    { "f2fs", generate_f2fs_image},
};

const struct fs_generator* fs_get_generator(const char *fs_type)
+15 −0
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@
#define KEY_IN_FOOTER  "footer"

#define E2FSCK_BIN      "/system/bin/e2fsck"
#define F2FS_FSCK_BIN  "/system/bin/fsck.f2fs"
#define MKSWAP_BIN      "/system/bin/mkswap"

#define FSCK_LOG_FILE   "/dev/fscklogs/log"
@@ -135,6 +136,20 @@ static void check_fs(char *blk_device, char *fs_type, char *target)
                ERROR("Failed trying to run %s\n", E2FSCK_BIN);
            }
        }
    } else if (!strcmp(fs_type, "f2fs")) {
            char *f2fs_fsck_argv[] = {
                    F2FS_FSCK_BIN,
                    blk_device
            };
        INFO("Running %s on %s\n", F2FS_FSCK_BIN, blk_device);

        ret = android_fork_execvp_ext(ARRAY_SIZE(f2fs_fsck_argv), f2fs_fsck_argv,
                                      &status, true, LOG_KLOG | LOG_FILE,
                                      true, FSCK_LOG_FILE);
        if (ret < 0) {
            /* No need to check for error in fork, we can't really handle it now */
            ERROR("Failed trying to run %s\n", F2FS_FSCK_BIN);
        }
    }

    return;