From f96fa524262b4ab45a7028ac8c336ed4073caec9 Mon Sep 17 00:00:00 2001 From: coolsnowwolf Date: Fri, 6 Aug 2021 15:16:56 +0800 Subject: [PATCH] block-mount: fix nand ecc booting delay --- package/system/fstools/Makefile | 8 +- package/system/fstools/files/blockd.init | 1 + ...port-extroot-for-non-MTD-rootfs_data.patch | 139 ------------------ 3 files changed, 5 insertions(+), 143 deletions(-) delete mode 100644 package/system/fstools/patches/0001-fstools-support-extroot-for-non-MTD-rootfs_data.patch diff --git a/package/system/fstools/Makefile b/package/system/fstools/Makefile index af6ce8b03..8914c7c9b 100644 --- a/package/system/fstools/Makefile +++ b/package/system/fstools/Makefile @@ -12,9 +12,9 @@ PKG_RELEASE:=$(AUTORELEASE) PKG_SOURCE_PROTO:=git PKG_SOURCE_URL=$(PROJECT_GIT)/project/fstools.git -PKG_MIRROR_HASH:=41c9c51d193f5150db67fcd898b6ea904b88476c94cdfd021d81e2711441b430 -PKG_SOURCE_DATE:=2021-05-16 -PKG_SOURCE_VERSION:=3d40a1b591cd569f95891116cd033b496de0f92b +PKG_MIRROR_HASH:=9cf9b4fd5951196813deb5c71dd24ad7af89348f7e647545b38760332953a8dc +PKG_SOURCE_DATE:=2021-08-05 +PKG_SOURCE_VERSION:=d4f01298105bb8c97e7ac0cad0e78f0ffe261354 CMAKE_INSTALL:=1 PKG_LICENSE:=GPL-2.0 @@ -79,7 +79,7 @@ define Package/block-mount SECTION:=base CATEGORY:=Base system TITLE:=Block device mounting and checking - DEPENDS:=+fstools +ubox +libubox +libuci +libblobmsg-json +libjson-c + DEPENDS:=+ubox +libubox +libuci +libblobmsg-json +libjson-c endef define Package/blockd diff --git a/package/system/fstools/files/blockd.init b/package/system/fstools/files/blockd.init index a4ce57d40..bdd8bbf62 100755 --- a/package/system/fstools/files/blockd.init +++ b/package/system/fstools/files/blockd.init @@ -16,6 +16,7 @@ reload_service() { start_service() { procd_open_instance procd_set_param command "$PROG" + procd_set_param watch block procd_set_param respawn procd_close_instance } diff --git a/package/system/fstools/patches/0001-fstools-support-extroot-for-non-MTD-rootfs_data.patch b/package/system/fstools/patches/0001-fstools-support-extroot-for-non-MTD-rootfs_data.patch deleted file mode 100644 index 65d1a087c..000000000 --- a/package/system/fstools/patches/0001-fstools-support-extroot-for-non-MTD-rootfs_data.patch +++ /dev/null @@ -1,139 +0,0 @@ -From: Qi Liu - -In order to support extroot, block extroot command has to be able to -discover and properly mount the rootfs_data volume in order to discover -the extroot volume. Currently this process can only discover MTD devices. -This patch leverages libfstools in a similar way as mount_root to -discover, initialize, and mount rootfs_data volume. It would enable any -device with non-MTD rootfs_data volume to support extroot, including x86. - -Signed-off-by: Qi Liu ---- - CMakeLists.txt | 4 ++-- - block.c | 40 ++++++++++++++++++++++++++++++++++++++++ - libfstools/fstype.h | 12 ++++++++++++ - libfstools/libfstools.h | 11 +---------- - 4 files changed, 55 insertions(+), 12 deletions(-) - create mode 100644 libfstools/fstype.h - -diff --git a/CMakeLists.txt b/CMakeLists.txt -index a586577..4b6e3e7 100644 - ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -75,9 +75,9 @@ INSTALL(TARGETS blockd RUNTIME DESTINATION sbin) - ADD_EXECUTABLE(block block.c probe.c probe-libblkid.c) - IF(DEFINED CMAKE_UBIFS_EXTROOT) - ADD_DEFINITIONS(-DUBIFS_EXTROOT) -- TARGET_LINK_LIBRARIES(block blkid-tiny dl uci ubox ubus blobmsg_json ubi-utils ${json}) -+ TARGET_LINK_LIBRARIES(block fstools blkid-tiny dl uci ubox ubus blobmsg_json ubi-utils ${json}) - ELSE(DEFINED CMAKE_UBIFS_EXTROOT) -- TARGET_LINK_LIBRARIES(block blkid-tiny dl uci ubox ubus blobmsg_json ${json}) -+ TARGET_LINK_LIBRARIES(block fstools blkid-tiny dl uci ubox ubus blobmsg_json ${json}) - ENDIF(DEFINED CMAKE_UBIFS_EXTROOT) - INSTALL(TARGETS block RUNTIME DESTINATION sbin) - -diff --git a/block.c b/block.c -index 569bf56..66cce46 100644 ---- a/block.c -+++ b/block.c -@@ -45,6 +45,8 @@ - #include - #include - -+#include "libfstools/fstype.h" -+#include "libfstools/volume.h" - #include "probe.h" - - #define AUTOFS_MOUNT_PATH "/tmp/run/blockd/" -@@ -1590,6 +1592,44 @@ static int main_extroot(int argc, char **argv) - } - #endif - -+ /* Find volume using libfstools */ -+ struct volume *data = volume_find("rootfs_data"); -+ if (data) { -+ volume_init(data); -+ -+ switch (volume_identify(data)) { -+ case FS_EXT4: { -+ char cfg[] = "/tmp/ext4_cfg"; -+ -+ /* Mount volume and try extroot (using fstab from that vol) */ -+ mkdir_p(cfg, 0755); -+ if (!mount(data->blk, cfg, "ext4", MS_NOATIME, NULL)) { -+ err = mount_extroot(cfg); -+ umount2(cfg, MNT_DETACH); -+ } -+ if (err < 0) -+ rmdir("/tmp/overlay"); -+ rmdir(cfg); -+ return err; -+ } -+ -+ case FS_F2FS: { -+ char cfg[] = "/tmp/f2fs_cfg"; -+ -+ /* Mount volume and try extroot (using fstab from that vol) */ -+ mkdir_p(cfg, 0755); -+ if (!mount(data->blk, cfg, "f2fs", MS_NOATIME, NULL)) { -+ err = mount_extroot(cfg); -+ umount2(cfg, MNT_DETACH); -+ } -+ if (err < 0) -+ rmdir("/tmp/overlay"); -+ rmdir(cfg); -+ return err; -+ } -+ } -+ } -+ - /* As a last resort look for /etc/config/fstab on "rootfs" partition */ - return mount_extroot(NULL); - } -diff --git a/libfstools/fstype.h b/libfstools/fstype.h -new file mode 100644 -index 0000000..8882343 ---- /dev/null -+++ b/libfstools/fstype.h -@@ -0,0 +1,13 @@ -+#ifndef _FS_TYPE_H__ -+#define _FS_TYPE_H__ -+enum { -+ FS_NONE, -+ FS_SNAPSHOT, -+ FS_JFFS2, -+ FS_DEADCODE, -+ FS_UBIFS, -+ FS_F2FS, -+ FS_EXT4, -+ FS_TARGZ, -+}; -+#endif -\ No newline at end of file -diff --git a/libfstools/libfstools.h b/libfstools/libfstools.h -index f27307a..8d3362f 100644 ---- a/libfstools/libfstools.h -+++ b/libfstools/libfstools.h -@@ -18,20 +18,10 @@ - #include - #include - #include -+#include "fstype.h" - - struct volume; - --enum { -- FS_NONE, -- FS_SNAPSHOT, -- FS_JFFS2, -- FS_DEADCODE, -- FS_UBIFS, -- FS_F2FS, -- FS_EXT4, -- FS_TARGZ, --}; -- - enum fs_state { - FS_STATE_UNKNOWN, - FS_STATE_PENDING,