Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
tbblgm119
lede
提交
48b8c58d
L
lede
项目概览
tbblgm119
/
lede
与 Fork 源项目一致
从无法访问的项目Fork
通知
7
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
L
lede
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
48b8c58d
编写于
9月 16, 2020
作者:
E
eSir
提交者:
GitHub
9月 16, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fstools-support-extroot-for-non-MTD-rootfs (#5472)
上级
99222f49
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
141 addition
and
4 deletion
+141
-4
package/system/fstools/Makefile
package/system/fstools/Makefile
+4
-4
package/system/fstools/patches/0001-fstools-support-extroot-for-non-MTD-rootfs_data.patch
...001-fstools-support-extroot-for-non-MTD-rootfs_data.patch
+137
-0
未找到文件。
package/system/fstools/Makefile
浏览文件 @
48b8c58d
...
...
@@ -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
...
...
package/system/fstools/patches/0001-fstools-support-extroot-for-non-MTD-rootfs_data.patch
0 → 100755
浏览文件 @
48b8c58d
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,
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录