Skip to content

Commit

Permalink
[bot] AutoMerging: merge all upstream's changes:
Browse files Browse the repository at this point in the history
* https://github.com/coolsnowwolf/lede:
  Bump mt76 from 2020-08-22 to 2020-08-25 (coolsnowwolf#5469)
  fstools-support-extroot-for-non-MTD-rootfs (coolsnowwolf#5472)
  • Loading branch information
github-actions[bot] committed Sep 16, 2020
2 parents 770a76d + a54f387 commit 986c9be
Show file tree
Hide file tree
Showing 3 changed files with 145 additions and 7 deletions.
7 changes: 4 additions & 3 deletions package/kernel/mt76/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ PKG_LICENSE_FILES:=

PKG_SOURCE_URL:=https://github.com/openwrt/mt76
PKG_SOURCE_PROTO:=git
PKG_SOURCE_DATE:=2020-08-22
PKG_SOURCE_VERSION:=8c7c1a207d25cd880c7f54d3fe86e82f14d6ecda
PKG_MIRROR_HASH:=0411bc634cb4065f748754e02758c172a4c65298696667f198c41d580d165d69
PKG_SOURCE_DATE:=2020-08-25
PKG_SOURCE_VERSION:=b36d7ae096a3d8c7d6a8a246f2e8a471a467041e
PKG_MIRROR_HASH:=da35e999f1bd50ce7061125ccb976129c8485e3593521206831380846953d3cf

PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name>
PKG_BUILD_PARALLEL:=1
Expand Down Expand Up @@ -333,6 +333,7 @@ define KernelPackage/mt76x2u/install
$(INSTALL_DIR) $(1)/lib/firmware/mediatek
ln -sf ../mt7662.bin $(1)/lib/firmware/mediatek/mt7662u.bin
ln -sf ../mt7662_rom_patch.bin $(1)/lib/firmware/mediatek/mt7662u_rom_patch.bin
echo mt76-usb disable_usb_sg=1 > $(1)/etc/modules.d/mt76-usb
endef

define KernelPackage/mt7603/install
Expand Down
8 changes: 4 additions & 4 deletions package/system/fstools/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ define Package/snapshot-tool
endef

define Package/block-mount
SECTION:=base
CATEGORY:=Base system
TITLE:=Block device mounting and checking
DEPENDS:=+ubox +libubox +libuci +libblobmsg-json +libjson-c
SECTION:=base
CATEGORY:=Base system
TITLE:=Block device mounting and checking
DEPENDS:=+fstools +ubox +libubox +libuci +libblobmsg-json +libjson-c
endef

define Package/blockd
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
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

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 <libubox/avl-cmp.h>
#include <libubus.h>

+#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);
+ 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);
+ 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,12 @@
+#ifndef _FS_TYPE_H__
+#define _FS_TYPE_H__
+enum {
+ FS_NONE,
+ FS_SNAPSHOT,
+ FS_JFFS2,
+ FS_DEADCODE,
+ FS_UBIFS,
+ FS_F2FS,
+ FS_EXT4,
+};
+#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,19 +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,
-};
-
enum fs_state {
FS_STATE_UNKNOWN,
FS_STATE_PENDING,

0 comments on commit 986c9be

Please sign in to comment.