Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
红岛
rt-thread
提交
1aab3607
R
rt-thread
项目概览
红岛
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
1aab3607
编写于
4月 08, 2022
作者:
B
Bernard Xiong
提交者:
GitHub
4月 08, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Revert "[dfs][romfs]支持相对地址模式 (#5768)" (#5786)
This reverts commit
e68f934f
.
上级
e1ef28a7
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
32 addition
and
58 deletion
+32
-58
components/dfs/filesystems/romfs/dfs_romfs.c
components/dfs/filesystems/romfs/dfs_romfs.c
+29
-49
components/dfs/filesystems/romfs/dfs_romfs.h
components/dfs/filesystems/romfs/dfs_romfs.h
+0
-6
tools/mkromfs.py
tools/mkromfs.py
+3
-3
未找到文件。
components/dfs/filesystems/romfs/dfs_romfs.c
浏览文件 @
1aab3607
...
...
@@ -16,37 +16,19 @@
int
dfs_romfs_mount
(
struct
dfs_filesystem
*
fs
,
unsigned
long
rwflag
,
const
void
*
data
)
{
struct
ro
ot_data
*
root_data
;
struct
ro
mfs_dirent
*
root_dirent
;
if
(
data
==
NULL
)
return
-
EIO
;
root_data
=
(
struct
root_data
*
)
rt_malloc
(
sizeof
(
struct
root_data
));
if
(
root_data
)
{
long
long
size
=
sizeof
(
struct
romfs_dirent
);
root_data
->
dirent
=
(
struct
romfs_dirent
*
)
data
;
if
((
const
char
*
)
root_data
->
dirent
->
data
-
root_data
->
dirent
->
name
!=
0x04
)
root_data
->
offset
=
0
;
else
root_data
->
offset
=
(
long
long
)
root_data
->
dirent
->
name
!=
size
?
((
long
long
)
data
-
(
long
long
)
root_data
->
dirent
->
name
+
size
)
:
(
long
long
)
data
;
fs
->
data
=
root_data
;
}
else
{
return
-
RT_ENOMEM
;
}
root_dirent
=
(
struct
romfs_dirent
*
)
data
;
fs
->
data
=
root_dirent
;
return
RT_EOK
;
}
int
dfs_romfs_unmount
(
struct
dfs_filesystem
*
fs
)
{
if
(
fs
->
data
)
{
rt_free
(
fs
->
data
);
}
return
RT_EOK
;
}
...
...
@@ -63,7 +45,7 @@ rt_inline int check_dirent(struct romfs_dirent *dirent)
return
0
;
}
struct
romfs_dirent
*
dfs_romfs_lookup
(
struct
ro
ot_data
*
root_data
,
const
char
*
path
,
rt_size_t
*
size
)
struct
romfs_dirent
*
dfs_romfs_lookup
(
struct
ro
mfs_dirent
*
root_dirent
,
const
char
*
path
,
rt_size_t
*
size
)
{
rt_size_t
index
,
found
;
const
char
*
subpath
,
*
subpath_end
;
...
...
@@ -71,18 +53,18 @@ struct romfs_dirent *dfs_romfs_lookup(struct root_data *root_data, const char *p
rt_size_t
dirent_size
;
/* Check the root_dirent. */
if
(
check_dirent
(
root_d
ata
->
d
irent
)
!=
0
)
if
(
check_dirent
(
root_dirent
)
!=
0
)
return
NULL
;
if
(
path
[
0
]
==
'/'
&&
path
[
1
]
==
'\0'
)
{
*
size
=
root_d
ata
->
d
irent
->
size
;
return
root_d
ata
->
d
irent
;
*
size
=
root_dirent
->
size
;
return
root_dirent
;
}
/* goto root directy entries */
dirent
=
(
struct
romfs_dirent
*
)
(
root_data
->
dirent
->
data
+
root_data
->
offset
)
;
dirent_size
=
root_d
ata
->
d
irent
->
size
;
/* goto root direct
or
y entries */
dirent
=
(
struct
romfs_dirent
*
)
root_dirent
->
data
;
dirent_size
=
root_dirent
->
size
;
/* get the end position of this subpath */
subpath_end
=
path
;
...
...
@@ -102,8 +84,8 @@ struct romfs_dirent *dfs_romfs_lookup(struct root_data *root_data, const char *p
{
if
(
check_dirent
(
&
dirent
[
index
])
!=
0
)
return
NULL
;
if
(
rt_strlen
(
dirent
[
index
].
name
+
root_data
->
offset
)
==
(
subpath_end
-
subpath
)
&&
rt_strncmp
(
dirent
[
index
].
name
+
root_data
->
offset
,
subpath
,
(
subpath_end
-
subpath
))
==
0
)
if
(
rt_strlen
(
dirent
[
index
].
name
)
==
(
subpath_end
-
subpath
)
&&
rt_strncmp
(
dirent
[
index
].
name
,
subpath
,
(
subpath_end
-
subpath
))
==
0
)
{
dirent_size
=
dirent
[
index
].
size
;
...
...
@@ -123,7 +105,7 @@ struct romfs_dirent *dfs_romfs_lookup(struct root_data *root_data, const char *p
if
(
dirent
[
index
].
type
==
ROMFS_DIRENT_DIR
)
{
/* enter directory */
dirent
=
(
struct
romfs_dirent
*
)
(
dirent
[
index
].
data
+
root_data
->
offset
)
;
dirent
=
(
struct
romfs_dirent
*
)
dirent
[
index
].
data
;
found
=
1
;
break
;
}
...
...
@@ -150,9 +132,7 @@ int dfs_romfs_read(struct dfs_fd *file, void *buf, size_t count)
{
rt_size_t
length
;
struct
romfs_dirent
*
dirent
;
struct
root_data
*
root_data
;
root_data
=
(
struct
root_data
*
)
file
->
fs
->
data
;
dirent
=
(
struct
romfs_dirent
*
)
file
->
data
;
RT_ASSERT
(
dirent
!=
NULL
);
...
...
@@ -167,7 +147,7 @@ int dfs_romfs_read(struct dfs_fd *file, void *buf, size_t count)
length
=
file
->
size
-
file
->
pos
;
if
(
length
>
0
)
memcpy
(
buf
,
&
(
dirent
->
data
[
file
->
pos
])
+
root_data
->
offset
,
length
);
rt_memcpy
(
buf
,
&
(
dirent
->
data
[
file
->
pos
])
,
length
);
/* update file current position */
file
->
pos
+=
length
;
...
...
@@ -177,7 +157,7 @@ int dfs_romfs_read(struct dfs_fd *file, void *buf, size_t count)
int
dfs_romfs_lseek
(
struct
dfs_fd
*
file
,
off_t
offset
)
{
if
(
offset
<=
(
off_t
)
file
->
size
)
if
(
offset
<=
file
->
size
)
{
file
->
pos
=
offset
;
return
file
->
pos
;
...
...
@@ -196,17 +176,19 @@ int dfs_romfs_open(struct dfs_fd *file)
{
rt_size_t
size
;
struct
romfs_dirent
*
dirent
;
struct
root_data
*
root_data
;
struct
romfs_dirent
*
root_dirent
;
struct
dfs_filesystem
*
fs
;
root_data
=
(
struct
root_data
*
)
file
->
fs
->
data
;
fs
=
(
struct
dfs_filesystem
*
)
file
->
data
;
root_dirent
=
(
struct
romfs_dirent
*
)
fs
->
data
;
if
(
check_dirent
(
root_d
ata
->
d
irent
)
!=
0
)
if
(
check_dirent
(
root_dirent
)
!=
0
)
return
-
EIO
;
if
(
file
->
flags
&
(
O_CREAT
|
O_WRONLY
|
O_APPEND
|
O_TRUNC
|
O_RDWR
))
return
-
EINVAL
;
dirent
=
dfs_romfs_lookup
(
root_d
ata
,
file
->
path
,
&
size
);
dirent
=
dfs_romfs_lookup
(
root_d
irent
,
file
->
path
,
&
size
);
if
(
dirent
==
NULL
)
return
-
ENOENT
;
...
...
@@ -234,10 +216,10 @@ int dfs_romfs_stat(struct dfs_filesystem *fs, const char *path, struct stat *st)
{
rt_size_t
size
;
struct
romfs_dirent
*
dirent
;
struct
ro
ot_data
*
root_data
;
struct
ro
mfs_dirent
*
root_dirent
;
root_d
ata
=
(
struct
root_data
*
)
fs
->
data
;
dirent
=
dfs_romfs_lookup
(
root_d
ata
,
path
,
&
size
);
root_d
irent
=
(
struct
romfs_dirent
*
)
fs
->
data
;
dirent
=
dfs_romfs_lookup
(
root_d
irent
,
path
,
&
size
);
if
(
dirent
==
NULL
)
return
-
ENOENT
;
...
...
@@ -260,20 +242,18 @@ int dfs_romfs_stat(struct dfs_filesystem *fs, const char *path, struct stat *st)
int
dfs_romfs_getdents
(
struct
dfs_fd
*
file
,
struct
dirent
*
dirp
,
uint32_t
count
)
{
uint32
_t
index
;
rt_size
_t
index
;
const
char
*
name
;
struct
dirent
*
d
;
struct
romfs_dirent
*
dirent
,
*
sub_dirent
;
struct
root_data
*
root_data
;
root_data
=
(
struct
root_data
*
)
file
->
fs
->
data
;
dirent
=
(
struct
romfs_dirent
*
)
file
->
data
;
if
(
check_dirent
(
dirent
)
!=
0
)
return
-
EIO
;
RT_ASSERT
(
dirent
->
type
==
ROMFS_DIRENT_DIR
);
/* enter directory */
dirent
=
(
struct
romfs_dirent
*
)
(
dirent
->
data
+
root_data
->
offset
)
;
dirent
=
(
struct
romfs_dirent
*
)
dirent
->
data
;
/* make integer count */
count
=
(
count
/
sizeof
(
struct
dirent
));
...
...
@@ -281,12 +261,12 @@ int dfs_romfs_getdents(struct dfs_fd *file, struct dirent *dirp, uint32_t count)
return
-
EINVAL
;
index
=
0
;
for
(
index
=
0
;
index
<
count
&&
(
size_t
)
file
->
pos
<
file
->
size
;
index
++
)
for
(
index
=
0
;
index
<
count
&&
file
->
pos
<
file
->
size
;
index
++
)
{
d
=
dirp
+
index
;
sub_dirent
=
&
dirent
[
file
->
pos
];
name
=
sub_dirent
->
name
+
root_data
->
offset
;
name
=
sub_dirent
->
name
;
/* fill dirent */
if
(
sub_dirent
->
type
==
ROMFS_DIRENT_DIR
)
...
...
@@ -296,7 +276,7 @@ int dfs_romfs_getdents(struct dfs_fd *file, struct dirent *dirp, uint32_t count)
d
->
d_namlen
=
rt_strlen
(
name
);
d
->
d_reclen
=
(
rt_uint16_t
)
sizeof
(
struct
dirent
);
rt_strncpy
(
d
->
d_name
,
name
,
rt_strlen
(
name
)
+
1
);
rt_strncpy
(
d
->
d_name
,
name
,
DFS_PATH_MAX
);
/* move to next position */
++
file
->
pos
;
...
...
components/dfs/filesystems/romfs/dfs_romfs.h
浏览文件 @
1aab3607
...
...
@@ -25,12 +25,6 @@ struct romfs_dirent
rt_size_t
size
;
/* file size */
};
struct
root_data
{
struct
romfs_dirent
*
dirent
;
/* root dirent */
long
long
offset
;
};
int
dfs_romfs_init
(
void
);
extern
const
struct
romfs_dirent
romfs_root
;
...
...
tools/mkromfs.py
浏览文件 @
1aab3607
...
...
@@ -191,7 +191,7 @@ class Folder(object):
else
:
assert
False
,
'Unkown instance:%s'
%
str
(
c
)
name
=
bytes
(
c
.
bin_name
.
encode
(
'utf-8'
)
)
name
=
bytes
(
c
.
bin_name
)
name_addr
=
v_len
v_len
+=
len
(
name
)
...
...
@@ -200,7 +200,7 @@ class Folder(object):
# pad the data to 4 bytes boundary
pad_len
=
4
if
len
(
data
)
%
pad_len
!=
0
:
data
+=
(
'
\0
'
*
(
pad_len
-
len
(
data
)
%
pad_len
)).
encode
(
'utf-8'
)
data
+=
'
\0
'
*
(
pad_len
-
len
(
data
)
%
pad_len
)
v_len
+=
len
(
data
)
d_li
.
append
(
self
.
bin_fmt
.
pack
(
*
self
.
bin_item
(
...
...
@@ -232,7 +232,7 @@ const struct romfs_dirent {name} = {{
def
get_bin_data
(
tree
,
base_addr
):
v_len
=
base_addr
+
Folder
.
bin_fmt
.
size
name
=
bytes
(
'/
\0\0\0
'
.
encode
(
"utf-8"
)
)
name
=
bytes
(
'/
\0\0\0
'
)
name_addr
=
v_len
v_len
+=
len
(
name
)
data_addr
=
v_len
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录