fstools: update to Git HEAD (2024-01-22)

This commit is contained in:
coolsnowwolf 2024-07-02 12:33:45 +08:00
parent 02b1ec2525
commit f2d670b67f
2 changed files with 6 additions and 135 deletions

View File

@ -12,15 +12,15 @@ PKG_RELEASE:=1
PKG_SOURCE_PROTO:=git PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL=$(PROJECT_GIT)/project/fstools.git PKG_SOURCE_URL=$(PROJECT_GIT)/project/fstools.git
PKG_MIRROR_HASH:=edda9151c73c1adfe369f5e315347344727a540ad57d3e2b41b9f57f9d4313fe PKG_MIRROR_HASH:=cf9e09885954e0e43b58126ce4b6f5552462cf1495b89330ce4e66056249787e
PKG_SOURCE_DATE:=2023-01-22 PKG_SOURCE_DATE:=2024-01-22
PKG_SOURCE_VERSION:=1ea5855e980cd88766dd9f615e78e7dd6edfbb74 PKG_SOURCE_VERSION:=08cd7083cac4bddf88459efa0881ee52858e7d0a
CMAKE_INSTALL:=1 CMAKE_INSTALL:=1
PKG_LICENSE:=GPL-2.0 PKG_LICENSE:=GPL-2.0
PKG_LICENSE_FILES:= PKG_LICENSE_FILES:=
PKG_USE_MIPS16:=0 PKG_BUILD_FLAGS:=no-mips16
PKG_FLAGS:=nonshared PKG_FLAGS:=nonshared
PKG_BUILD_DEPENDS := util-linux PKG_BUILD_DEPENDS := util-linux
@ -48,7 +48,7 @@ define Package/fstools/config
depends on PACKAGE_fstools depends on PACKAGE_fstools
depends on NAND_SUPPORT depends on NAND_SUPPORT
bool "Support extroot functionality with UBIFS" bool "Support extroot functionality with UBIFS"
default n default y
help help
This option makes it possible to use extroot functionality if the root filesystem resides on an UBIFS partition This option makes it possible to use extroot functionality if the root filesystem resides on an UBIFS partition
@ -82,7 +82,7 @@ define Package/block-mount
SECTION:=base SECTION:=base
CATEGORY:=Base system CATEGORY:=Base system
TITLE:=Block device mounting and checking TITLE:=Block device mounting and checking
DEPENDS:=+fstools +ubox +libubox +libuci +libblobmsg-json +libjson-c DEPENDS:=+ubox +libubox +libuci +libblobmsg-json +libjson-c
endef endef
define Package/blockd define Package/blockd

View File

@ -1,129 +0,0 @@
From: Qi Liu <liuqi_colin@msn.com>
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 <liuqi_colin@msn.com>
---
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
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -78,9 +78,9 @@ INSTALL(TARGETS blockd RUNTIME DESTINATI
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)
--- a/block.c
+++ b/block.c
@@ -44,6 +44,8 @@
#include <libubox/vlist.h>
#include <libubus.h>
+#include "libfstools/fstype.h"
+#include "libfstools/volume.h"
#include "probe.h"
#define AUTOFS_MOUNT_PATH "/tmp/run/blockd/"
@@ -1696,6 +1698,44 @@ static int main_extroot(int argc, char *
}
#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);
}
--- /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
--- a/libfstools/libfstools.h
+++ b/libfstools/libfstools.h
@@ -18,20 +18,10 @@
#include <libubox/blob.h>
#include <libubox/ulog.h>
#include <libubox/utils.h>
+#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,