Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
RT-Thread
rt-thread
提交
cfa9a791
R
rt-thread
项目概览
RT-Thread
/
rt-thread
8 个月 前同步成功
通知
750
Star
8909
Fork
4735
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
cfa9a791
编写于
11月 21, 2022
作者:
G
guozhanxin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
同步 elmfs,stm32h750测试通过
上级
0e0e5151
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
242 addition
and
76 deletion
+242
-76
bsp/stm32/stm32h750-artpi/board/Kconfig
bsp/stm32/stm32h750-artpi/board/Kconfig
+1
-0
components/dfs/filesystems/elmfat/dfs_elm.c
components/dfs/filesystems/elmfat/dfs_elm.c
+37
-15
components/dfs/filesystems/nfs/dfs_nfs.c
components/dfs/filesystems/nfs/dfs_nfs.c
+53
-28
components/dfs/filesystems/nfs/rpc/types.h
components/dfs/filesystems/nfs/rpc/types.h
+16
-0
components/dfs/filesystems/ramfs/dfs_ramfs.c
components/dfs/filesystems/ramfs/dfs_ramfs.c
+43
-17
components/dfs/filesystems/romfs/dfs_romfs.c
components/dfs/filesystems/romfs/dfs_romfs.c
+73
-15
libcpu/Kconfig
libcpu/Kconfig
+5
-0
libcpu/arm/cortex-m7/cpuport.h
libcpu/arm/cortex-m7/cpuport.h
+13
-0
src/object.c
src/object.c
+1
-1
未找到文件。
bsp/stm32/stm32h750-artpi/board/Kconfig
浏览文件 @
cfa9a791
...
...
@@ -5,6 +5,7 @@ config SOC_STM32H750XB
select SOC_SERIES_STM32H7
select RT_USING_COMPONENTS_INIT
select RT_USING_USER_MAIN
select RT_USING_CACHE
default y
config BOARD_STM32H750_ARTPI
...
...
components/dfs/filesystems/elmfat/dfs_elm.c
浏览文件 @
cfa9a791
...
...
@@ -191,7 +191,7 @@ int dfs_elm_unmount(struct dfs_filesystem *fs)
return
RT_EOK
;
}
int
dfs_elm_mkfs
(
rt_device_t
dev_id
)
int
dfs_elm_mkfs
(
rt_device_t
dev_id
,
const
char
*
fs_name
)
{
#define FSM_STATUS_INIT 0
#define FSM_STATUS_USE_TEMP_DRIVER 1
...
...
@@ -330,9 +330,21 @@ int dfs_elm_open(struct dfs_fd *file)
#if (FF_VOLUMES > 1)
int
vol
;
struct
dfs_filesystem
*
fs
=
(
struct
dfs_filesystem
*
)
file
->
data
;
struct
dfs_filesystem
*
fs
=
file
->
fnode
->
fs
;
extern
int
elm_get_vol
(
FATFS
*
fat
);
RT_ASSERT
(
file
->
fnode
->
ref_count
>
0
);
if
(
file
->
fnode
->
ref_count
>
1
)
{
if
(
file
->
fnode
->
type
==
FT_DIRECTORY
&&
!
(
file
->
flags
&
O_DIRECTORY
))
{
return
-
ENOENT
;
}
file
->
pos
=
0
;
return
0
;
}
if
(
fs
==
NULL
)
return
-
ENOENT
;
...
...
@@ -344,9 +356,9 @@ int dfs_elm_open(struct dfs_fd *file)
if
(
drivers_fn
==
RT_NULL
)
return
-
ENOMEM
;
rt_snprintf
(
drivers_fn
,
256
,
"%d:%s"
,
vol
,
file
->
path
);
rt_snprintf
(
drivers_fn
,
256
,
"%d:%s"
,
vol
,
file
->
fnode
->
path
);
#else
drivers_fn
=
file
->
path
;
drivers_fn
=
file
->
fnode
->
path
;
#endif
if
(
file
->
flags
&
O_DIRECTORY
)
...
...
@@ -423,7 +435,8 @@ int dfs_elm_open(struct dfs_fd *file)
if
(
result
==
FR_OK
)
{
file
->
pos
=
fd
->
fptr
;
file
->
size
=
f_size
(
fd
);
file
->
fnode
->
size
=
f_size
(
fd
);
file
->
fnode
->
type
=
FT_REGULAR
;
file
->
data
=
fd
;
if
(
file
->
flags
&
O_APPEND
)
...
...
@@ -448,10 +461,15 @@ int dfs_elm_close(struct dfs_fd *file)
{
FRESULT
result
;
RT_ASSERT
(
file
->
fnode
->
ref_count
>
0
);
if
(
file
->
fnode
->
ref_count
>
1
)
{
return
0
;
}
result
=
FR_OK
;
if
(
file
->
type
==
FT_DIRECTORY
)
if
(
file
->
fnode
->
type
==
FT_DIRECTORY
)
{
DIR
*
dir
;
DIR
*
dir
=
RT_NULL
;
dir
=
(
DIR
*
)(
file
->
data
);
RT_ASSERT
(
dir
!=
RT_NULL
);
...
...
@@ -459,9 +477,9 @@ int dfs_elm_close(struct dfs_fd *file)
/* release memory */
rt_free
(
dir
);
}
else
if
(
file
->
type
==
FT_REGULAR
)
else
if
(
file
->
fnode
->
type
==
FT_REGULAR
)
{
FIL
*
fd
;
FIL
*
fd
=
RT_NULL
;
fd
=
(
FIL
*
)(
file
->
data
);
RT_ASSERT
(
fd
!=
RT_NULL
);
...
...
@@ -504,6 +522,10 @@ int dfs_elm_ioctl(struct dfs_fd *file, int cmd, void *args)
fd
->
fptr
=
fptr
;
return
elm_result_to_dfs
(
result
);
}
case
F_GETLK
:
return
0
;
case
F_SETLK
:
return
0
;
}
return
-
ENOSYS
;
}
...
...
@@ -514,7 +536,7 @@ int dfs_elm_read(struct dfs_fd *file, void *buf, size_t len)
FRESULT
result
;
UINT
byte_read
;
if
(
file
->
type
==
FT_DIRECTORY
)
if
(
file
->
fnode
->
type
==
FT_DIRECTORY
)
{
return
-
EISDIR
;
}
...
...
@@ -537,7 +559,7 @@ int dfs_elm_write(struct dfs_fd *file, const void *buf, size_t len)
FRESULT
result
;
UINT
byte_write
;
if
(
file
->
type
==
FT_DIRECTORY
)
if
(
file
->
fnode
->
type
==
FT_DIRECTORY
)
{
return
-
EISDIR
;
}
...
...
@@ -548,7 +570,7 @@ int dfs_elm_write(struct dfs_fd *file, const void *buf, size_t len)
result
=
f_write
(
fd
,
buf
,
len
,
&
byte_write
);
/* update position and file size */
file
->
pos
=
fd
->
fptr
;
file
->
size
=
f_size
(
fd
);
file
->
fnode
->
size
=
f_size
(
fd
);
if
(
result
==
FR_OK
)
return
byte_write
;
...
...
@@ -570,7 +592,7 @@ int dfs_elm_flush(struct dfs_fd *file)
int
dfs_elm_lseek
(
struct
dfs_fd
*
file
,
rt_off_t
offset
)
{
FRESULT
result
=
FR_OK
;
if
(
file
->
type
==
FT_REGULAR
)
if
(
file
->
fnode
->
type
==
FT_REGULAR
)
{
FIL
*
fd
;
...
...
@@ -586,10 +608,10 @@ int dfs_elm_lseek(struct dfs_fd *file, rt_off_t offset)
return
fd
->
fptr
;
}
}
else
if
(
file
->
type
==
FT_DIRECTORY
)
else
if
(
file
->
fnode
->
type
==
FT_DIRECTORY
)
{
/* which is a directory */
DIR
*
dir
;
DIR
*
dir
=
RT_NULL
;
dir
=
(
DIR
*
)(
file
->
data
);
RT_ASSERT
(
dir
!=
RT_NULL
);
...
...
components/dfs/filesystems/nfs/dfs_nfs.c
浏览文件 @
cfa9a791
...
...
@@ -559,12 +559,11 @@ int nfs_read(struct dfs_fd *file, void *buf, size_t count)
nfs_file
*
fd
;
nfs_filesystem
*
nfs
;
if
(
file
->
type
==
FT_DIRECTORY
)
if
(
file
->
fnode
->
type
==
FT_DIRECTORY
)
return
-
EISDIR
;
RT_ASSERT
(
file
->
data
!=
NULL
);
struct
dfs_filesystem
*
dfs_nfs
=
((
struct
dfs_filesystem
*
)(
file
->
data
));
RT_ASSERT
(
file
->
fnode
->
data
!=
NULL
);
struct
dfs_filesystem
*
dfs_nfs
=
((
struct
dfs_filesystem
*
)(
file
->
fnode
->
data
));
nfs
=
(
struct
nfs_filesystem
*
)(
dfs_nfs
->
data
);
fd
=
(
nfs_file
*
)(
nfs
->
data
);
RT_ASSERT
(
fd
!=
NULL
);
...
...
@@ -629,11 +628,11 @@ int nfs_write(struct dfs_fd *file, const void *buf, size_t count)
nfs_file
*
fd
;
nfs_filesystem
*
nfs
;
if
(
file
->
type
==
FT_DIRECTORY
)
if
(
file
->
fnode
->
type
==
FT_DIRECTORY
)
return
-
EISDIR
;
RT_ASSERT
(
file
->
data
!=
NULL
);
struct
dfs_filesystem
*
dfs_nfs
=
((
struct
dfs_filesystem
*
)(
file
->
data
));
RT_ASSERT
(
file
->
fnode
->
data
!=
NULL
);
struct
dfs_filesystem
*
dfs_nfs
=
((
struct
dfs_filesystem
*
)(
file
->
fnode
->
data
));
nfs
=
(
struct
nfs_filesystem
*
)(
dfs_nfs
->
data
);
fd
=
(
nfs_file
*
)(
nfs
->
data
);
RT_ASSERT
(
fd
!=
NULL
);
...
...
@@ -676,11 +675,10 @@ int nfs_write(struct dfs_fd *file, const void *buf, size_t count)
file
->
pos
=
fd
->
offset
;
/* update file size */
if
(
fd
->
size
<
fd
->
offset
)
fd
->
size
=
fd
->
offset
;
file
->
size
=
fd
->
size
;
file
->
fnode
->
size
=
fd
->
size
;
}
xdr_free
((
xdrproc_t
)
xdr_WRITE3res
,
(
char
*
)
&
res
);
}
while
(
count
>
0
);
}
while
(
count
>
0
);
xdr_free
((
xdrproc_t
)
xdr_WRITE3res
,
(
char
*
)
&
res
);
...
...
@@ -692,11 +690,11 @@ int nfs_lseek(struct dfs_fd *file, off_t offset)
nfs_file
*
fd
;
nfs_filesystem
*
nfs
;
if
(
file
->
type
==
FT_DIRECTORY
)
if
(
file
->
fnode
->
type
==
FT_DIRECTORY
)
return
-
EISDIR
;
RT_ASSERT
(
file
->
data
!=
NULL
);
struct
dfs_filesystem
*
dfs_nfs
=
((
struct
dfs_filesystem
*
)(
file
->
data
));
RT_ASSERT
(
file
->
fnode
->
data
!=
NULL
);
struct
dfs_filesystem
*
dfs_nfs
=
((
struct
dfs_filesystem
*
)(
file
->
fnode
->
data
));
nfs
=
(
struct
nfs_filesystem
*
)(
dfs_nfs
->
data
);
fd
=
(
nfs_file
*
)(
nfs
->
data
);
RT_ASSERT
(
fd
!=
NULL
);
...
...
@@ -714,11 +712,18 @@ int nfs_lseek(struct dfs_fd *file, off_t offset)
int
nfs_close
(
struct
dfs_fd
*
file
)
{
nfs_filesystem
*
nfs
;
RT_ASSERT
(
file
->
data
!=
NULL
);
struct
dfs_filesystem
*
dfs_nfs
=
((
struct
dfs_filesystem
*
)(
file
->
data
));
RT_ASSERT
(
file
->
fnode
->
data
!=
NULL
);
struct
dfs_filesystem
*
dfs_nfs
=
((
struct
dfs_filesystem
*
)(
file
->
fnode
->
data
));
RT_ASSERT
(
file
->
fnode
->
ref_count
>
0
);
if
(
file
->
fnode
->
ref_count
>
1
)
{
return
0
;
}
nfs
=
(
struct
nfs_filesystem
*
)(
dfs_nfs
->
data
);
if
(
file
->
type
==
FT_DIRECTORY
)
if
(
file
->
fnode
->
type
==
FT_DIRECTORY
)
{
struct
nfs_dir
*
dir
;
...
...
@@ -727,7 +732,7 @@ int nfs_close(struct dfs_fd *file)
xdr_free
((
xdrproc_t
)
xdr_READDIR3res
,
(
char
*
)
&
dir
->
res
);
rt_free
(
dir
);
}
else
if
(
file
->
type
==
FT_REGULAR
)
else
if
(
file
->
fnode
->
type
==
FT_REGULAR
)
{
struct
nfs_file
*
fd
;
...
...
@@ -744,24 +749,42 @@ int nfs_close(struct dfs_fd *file)
int
nfs_open
(
struct
dfs_fd
*
file
)
{
nfs_filesystem
*
nfs
;
RT_ASSERT
(
file
->
data
!=
NULL
);
struct
dfs_filesystem
*
dfs_nfs
=
((
struct
dfs_filesystem
*
)(
file
->
data
))
;
RT_ASSERT
(
file
->
fnode
->
data
!=
NULL
);
struct
dfs_filesystem
*
dfs_nfs
=
file
->
fnode
->
fs
;
nfs
=
(
struct
nfs_filesystem
*
)(
dfs_nfs
->
data
);
RT_ASSERT
(
nfs
!=
NULL
);
RT_ASSERT
(
file
->
fnode
->
ref_count
>
0
);
if
(
file
->
fnode
->
ref_count
>
1
)
{
if
(
file
->
fnode
->
type
==
FT_DIRECTORY
&&
!
(
file
->
flags
&
O_DIRECTORY
))
{
return
-
ENOENT
;
}
file
->
pos
=
0
;
return
0
;
}
if
(
file
->
flags
&
O_DIRECTORY
)
{
nfs_dir
*
dir
;
if
(
file
->
flags
&
O_CREAT
)
{
if
(
nfs_mkdir
(
nfs
,
file
->
path
,
0755
)
<
0
)
if
(
nfs_mkdir
(
nfs
,
file
->
fnode
->
path
,
0755
)
<
0
)
{
return
-
EAGAIN
;
}
}
/* open directory */
dir
=
nfs_opendir
(
nfs
,
file
->
path
);
if
(
dir
==
NULL
)
return
-
ENOENT
;
dir
=
nfs_opendir
(
nfs
,
file
->
fnode
->
path
);
if
(
dir
==
NULL
)
{
return
-
ENOENT
;
}
file
->
fnode
->
type
=
FT_DIRECTORY
;
nfs
->
data
=
dir
;
}
else
...
...
@@ -772,8 +795,10 @@ int nfs_open(struct dfs_fd *file)
/* create file */
if
(
file
->
flags
&
O_CREAT
)
{
if
(
nfs_create
(
nfs
,
file
->
path
,
0664
)
<
0
)
if
(
nfs_create
(
nfs
,
file
->
fnode
->
path
,
0664
)
<
0
)
{
return
-
EAGAIN
;
}
}
/* open file (get file handle ) */
...
...
@@ -781,7 +806,7 @@ int nfs_open(struct dfs_fd *file)
if
(
fp
==
NULL
)
return
-
ENOMEM
;
handle
=
get_handle
(
nfs
,
file
->
path
);
handle
=
get_handle
(
nfs
,
file
->
fnode
->
path
);
if
(
handle
==
NULL
)
{
rt_free
(
fp
);
...
...
@@ -805,7 +830,8 @@ int nfs_open(struct dfs_fd *file)
/* set private file */
nfs
->
data
=
fp
;
file
->
size
=
fp
->
size
;
file
->
fnode
->
size
=
fp
->
size
;
file
->
fnode
->
type
=
FT_REGULAR
;
}
return
0
;
...
...
@@ -1085,9 +1111,8 @@ int nfs_getdents(struct dfs_fd *file, struct dirent *dirp, uint32_t count)
nfs_filesystem
*
nfs
;
char
*
name
;
RT_ASSERT
(
file
->
data
!=
NULL
);
struct
dfs_filesystem
*
dfs_nfs
=
((
struct
dfs_filesystem
*
)(
file
->
data
));
RT_ASSERT
(
file
->
fnode
->
data
!=
NULL
);
struct
dfs_filesystem
*
dfs_nfs
=
((
struct
dfs_filesystem
*
)(
file
->
fnode
->
data
));
nfs
=
(
struct
nfs_filesystem
*
)(
dfs_nfs
->
data
);
dir
=
(
nfs_dir
*
)(
nfs
->
data
);
RT_ASSERT
(
dir
!=
NULL
);
...
...
components/dfs/filesystems/nfs/rpc/types.h
浏览文件 @
cfa9a791
...
...
@@ -47,7 +47,15 @@
#include <string.h>
#include <stdint.h>
#ifndef RT_USING_MINILIBC
typedef
unsigned
int
u_int
;
typedef
unsigned
char
u_char
;
typedef
unsigned
long
u_long
;
#else
#include <sys/types.h>
#include <stdint.h>
#endif
typedef
long
long
int64_t
;
typedef
unsigned
long
long
uint64_t
;
...
...
@@ -55,6 +63,14 @@ typedef unsigned long long uint64_t;
typedef
int
bool_t
;
typedef
int
enum_t
;
#if !defined(RT_USING_NEWLIB) && !defined(RT_USING_MUSL)
typedef
unsigned
long
dev_t
;
#endif
#if !defined(RT_USING_NEWLIB) && !defined(RT_USING_MINILIBC) && !defined(RT_USING_MUSL)
typedef
rt_int32_t
ssize_t
;
#endif
/* This needs to be changed to uint32_t in the future */
typedef
unsigned
long
rpcprog_t
;
typedef
unsigned
long
rpcvers_t
;
...
...
components/dfs/filesystems/ramfs/dfs_ramfs.c
浏览文件 @
cfa9a791
...
...
@@ -97,13 +97,13 @@ int dfs_ramfs_read(struct dfs_fd *file, void *buf, size_t count)
rt_size_t
length
;
struct
ramfs_dirent
*
dirent
;
dirent
=
(
struct
ramfs_dirent
*
)
file
->
data
;
dirent
=
(
struct
ramfs_dirent
*
)
file
->
fnode
->
data
;
RT_ASSERT
(
dirent
!=
NULL
);
if
(
count
<
file
->
size
-
file
->
pos
)
if
(
count
<
file
->
fnode
->
size
-
file
->
pos
)
length
=
count
;
else
length
=
file
->
size
-
file
->
pos
;
length
=
file
->
fnode
->
size
-
file
->
pos
;
if
(
length
>
0
)
rt_memcpy
(
buf
,
&
(
dirent
->
data
[
file
->
pos
]),
length
);
...
...
@@ -119,13 +119,13 @@ int dfs_ramfs_write(struct dfs_fd *fd, const void *buf, size_t count)
struct
ramfs_dirent
*
dirent
;
struct
dfs_ramfs
*
ramfs
;
dirent
=
(
struct
ramfs_dirent
*
)
fd
->
data
;
dirent
=
(
struct
ramfs_dirent
*
)
fd
->
fnode
->
data
;
RT_ASSERT
(
dirent
!=
NULL
);
ramfs
=
dirent
->
fs
;
RT_ASSERT
(
ramfs
!=
NULL
);
if
(
count
+
fd
->
pos
>
fd
->
size
)
if
(
count
+
fd
->
pos
>
fd
->
fnode
->
size
)
{
rt_uint8_t
*
ptr
;
ptr
=
rt_memheap_realloc
(
&
(
ramfs
->
memheap
),
dirent
->
data
,
fd
->
pos
+
count
);
...
...
@@ -139,7 +139,7 @@ int dfs_ramfs_write(struct dfs_fd *fd, const void *buf, size_t count)
/* update dirent and file size */
dirent
->
data
=
ptr
;
dirent
->
size
=
fd
->
pos
+
count
;
fd
->
size
=
dirent
->
size
;
fd
->
fnode
->
size
=
dirent
->
size
;
}
if
(
count
>
0
)
...
...
@@ -153,7 +153,7 @@ int dfs_ramfs_write(struct dfs_fd *fd, const void *buf, size_t count)
int
dfs_ramfs_lseek
(
struct
dfs_fd
*
file
,
off_t
offset
)
{
if
(
offset
<=
(
off_t
)
file
->
size
)
if
(
offset
<=
(
off_t
)
file
->
fnode
->
size
)
{
file
->
pos
=
offset
;
...
...
@@ -165,7 +165,13 @@ int dfs_ramfs_lseek(struct dfs_fd *file, off_t offset)
int
dfs_ramfs_close
(
struct
dfs_fd
*
file
)
{
file
->
data
=
NULL
;
RT_ASSERT
(
file
->
fnode
->
ref_count
>
0
);
if
(
file
->
fnode
->
ref_count
>
1
)
{
return
0
;
}
file
->
fnode
->
data
=
NULL
;
return
RT_EOK
;
}
...
...
@@ -177,7 +183,19 @@ int dfs_ramfs_open(struct dfs_fd *file)
struct
ramfs_dirent
*
dirent
;
struct
dfs_filesystem
*
fs
;
fs
=
(
struct
dfs_filesystem
*
)
file
->
data
;
RT_ASSERT
(
file
->
fnode
->
ref_count
>
0
);
if
(
file
->
fnode
->
ref_count
>
1
)
{
if
(
file
->
fnode
->
type
==
FT_DIRECTORY
&&
!
(
file
->
flags
&
O_DIRECTORY
))
{
return
-
ENOENT
;
}
file
->
pos
=
0
;
return
0
;
}
fs
=
file
->
fnode
->
fs
;
ramfs
=
(
struct
dfs_ramfs
*
)
fs
->
data
;
RT_ASSERT
(
ramfs
!=
NULL
);
...
...
@@ -190,7 +208,7 @@ int dfs_ramfs_open(struct dfs_fd *file)
}
/* open directory */
dirent
=
dfs_ramfs_lookup
(
ramfs
,
file
->
path
,
&
size
);
dirent
=
dfs_ramfs_lookup
(
ramfs
,
file
->
fnode
->
path
,
&
size
);
if
(
dirent
==
NULL
)
return
-
ENOENT
;
if
(
dirent
==
&
(
ramfs
->
root
))
/* it's root directory */
...
...
@@ -200,10 +218,11 @@ int dfs_ramfs_open(struct dfs_fd *file)
return
-
ENOENT
;
}
}
file
->
fnode
->
type
=
FT_DIRECTORY
;
}
else
{
dirent
=
dfs_ramfs_lookup
(
ramfs
,
file
->
path
,
&
size
);
dirent
=
dfs_ramfs_lookup
(
ramfs
,
file
->
fnode
->
path
,
&
size
);
if
(
dirent
==
&
(
ramfs
->
root
))
/* it's root directory */
{
return
-
ENOENT
;
...
...
@@ -225,15 +244,18 @@ int dfs_ramfs_open(struct dfs_fd *file)
}
/* remove '/' separator */
name_ptr
=
file
->
path
;
name_ptr
=
file
->
fnode
->
path
;
while
(
*
name_ptr
==
'/'
&&
*
name_ptr
)
name_ptr
++
;
{
name_ptr
++
;
}
strncpy
(
dirent
->
name
,
name_ptr
,
RAMFS_NAME_MAX
);
rt_list_init
(
&
(
dirent
->
list
));
dirent
->
data
=
NULL
;
dirent
->
size
=
0
;
dirent
->
fs
=
ramfs
;
file
->
fnode
->
type
=
FT_DIRECTORY
;
/* add to the root directory */
rt_list_insert_after
(
&
(
ramfs
->
root
.
list
),
&
(
dirent
->
list
));
...
...
@@ -256,12 +278,16 @@ int dfs_ramfs_open(struct dfs_fd *file)
}
}
file
->
data
=
dirent
;
file
->
size
=
dirent
->
size
;
file
->
fnode
->
data
=
dirent
;
file
->
fnode
->
size
=
dirent
->
size
;
if
(
file
->
flags
&
O_APPEND
)
file
->
pos
=
file
->
size
;
{
file
->
pos
=
file
->
fnode
->
size
;
}
else
{
file
->
pos
=
0
;
}
return
0
;
}
...
...
@@ -299,7 +325,7 @@ int dfs_ramfs_getdents(struct dfs_fd *file,
struct
ramfs_dirent
*
dirent
;
struct
dfs_ramfs
*
ramfs
;
dirent
=
(
struct
ramfs_dirent
*
)
file
->
data
;
dirent
=
(
struct
ramfs_dirent
*
)
file
->
fnode
->
data
;
ramfs
=
dirent
->
fs
;
RT_ASSERT
(
ramfs
!=
RT_NULL
);
...
...
components/dfs/filesystems/romfs/dfs_romfs.c
浏览文件 @
cfa9a791
...
...
@@ -34,7 +34,28 @@ int dfs_romfs_unmount(struct dfs_filesystem *fs)
int
dfs_romfs_ioctl
(
struct
dfs_fd
*
file
,
int
cmd
,
void
*
args
)
{
return
-
EIO
;
int
ret
=
RT_EOK
;
struct
romfs_dirent
*
dirent
;
dirent
=
(
struct
romfs_dirent
*
)
file
->
fnode
->
data
;
RT_ASSERT
(
dirent
!=
NULL
);
switch
(
cmd
)
{
case
RT_FIOGETADDR
:
{
*
(
rt_ubase_t
*
)
args
=
(
rt_ubase_t
)
dirent
->
data
;
break
;
}
case
RT_FIOFTRUNCATE
:
{
break
;
}
default:
ret
=
-
RT_EINVAL
;
break
;
}
return
ret
;
}
rt_inline
int
check_dirent
(
struct
romfs_dirent
*
dirent
)
...
...
@@ -112,9 +133,6 @@ struct romfs_dirent *dfs_romfs_lookup(struct romfs_dirent *root_dirent, const ch
else
{
/* return file dirent */
if
(
subpath
!=
NULL
)
break
;
/* not the end of path */
return
&
dirent
[
index
];
}
}
...
...
@@ -133,7 +151,7 @@ int dfs_romfs_read(struct dfs_fd *file, void *buf, size_t count)
rt_size_t
length
;
struct
romfs_dirent
*
dirent
;
dirent
=
(
struct
romfs_dirent
*
)
file
->
data
;
dirent
=
(
struct
romfs_dirent
*
)
file
->
fnode
->
data
;
RT_ASSERT
(
dirent
!=
NULL
);
if
(
check_dirent
(
dirent
)
!=
0
)
...
...
@@ -141,10 +159,10 @@ int dfs_romfs_read(struct dfs_fd *file, void *buf, size_t count)
return
-
EIO
;
}
if
(
count
<
file
->
size
-
file
->
pos
)
if
(
count
<
file
->
fnode
->
size
-
file
->
pos
)
length
=
count
;
else
length
=
file
->
size
-
file
->
pos
;
length
=
file
->
fnode
->
size
-
file
->
pos
;
if
(
length
>
0
)
rt_memcpy
(
buf
,
&
(
dirent
->
data
[
file
->
pos
]),
length
);
...
...
@@ -157,7 +175,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
>=
0
&&
(
rt_size_t
)
offset
<=
fil
e
->
size
)
if
(
offset
<=
file
->
fnod
e
->
size
)
{
file
->
pos
=
offset
;
return
file
->
pos
;
...
...
@@ -168,7 +186,12 @@ int dfs_romfs_lseek(struct dfs_fd *file, off_t offset)
int
dfs_romfs_close
(
struct
dfs_fd
*
file
)
{
file
->
data
=
NULL
;
RT_ASSERT
(
file
->
fnode
->
ref_count
>
0
);
if
(
file
->
fnode
->
ref_count
>
1
)
{
return
RT_EOK
;
}
file
->
fnode
->
data
=
NULL
;
return
RT_EOK
;
}
...
...
@@ -179,34 +202,63 @@ int dfs_romfs_open(struct dfs_fd *file)
struct
romfs_dirent
*
root_dirent
;
struct
dfs_filesystem
*
fs
;
fs
=
(
struct
dfs_filesystem
*
)
file
->
data
;
if
(
file
->
flags
&
(
O_CREAT
|
O_WRONLY
|
O_APPEND
|
O_TRUNC
|
O_RDWR
))
{
return
-
EINVAL
;
}
RT_ASSERT
(
file
->
fnode
->
ref_count
>
0
);
if
(
file
->
fnode
->
ref_count
>
1
)
{
if
(
file
->
fnode
->
type
==
FT_DIRECTORY
&&
!
(
file
->
flags
&
O_DIRECTORY
))
{
return
-
ENOENT
;
}
file
->
pos
=
0
;
return
0
;
}
fs
=
file
->
fnode
->
fs
;
root_dirent
=
(
struct
romfs_dirent
*
)
fs
->
data
;
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_dirent
,
file
->
path
,
&
size
);
dirent
=
dfs_romfs_lookup
(
root_dirent
,
file
->
fnode
->
path
,
&
size
);
if
(
dirent
==
NULL
)
{
return
-
ENOENT
;
}
/* entry is a directory file type */
if
(
dirent
->
type
==
ROMFS_DIRENT_DIR
)
{
if
(
!
(
file
->
flags
&
O_DIRECTORY
))
{
return
-
ENOENT
;
}
file
->
fnode
->
type
=
FT_DIRECTORY
;
}
else
{
/* entry is a file, but open it as a directory */
if
(
file
->
flags
&
O_DIRECTORY
)
{
return
-
ENOENT
;
}
file
->
fnode
->
type
=
FT_REGULAR
;
}
file
->
data
=
dirent
;
file
->
size
=
size
;
file
->
fnode
->
data
=
dirent
;
file
->
fnode
->
size
=
size
;
file
->
pos
=
0
;
return
RT_EOK
;
...
...
@@ -222,7 +274,9 @@ int dfs_romfs_stat(struct dfs_filesystem *fs, const char *path, struct stat *st)
dirent
=
dfs_romfs_lookup
(
root_dirent
,
path
,
&
size
);
if
(
dirent
==
NULL
)
{
return
-
ENOENT
;
}
st
->
st_dev
=
0
;
st
->
st_mode
=
S_IFREG
|
S_IRUSR
|
S_IRGRP
|
S_IROTH
|
...
...
@@ -248,9 +302,11 @@ int dfs_romfs_getdents(struct dfs_fd *file, struct dirent *dirp, uint32_t count)
struct
dirent
*
d
;
struct
romfs_dirent
*
dirent
,
*
sub_dirent
;
dirent
=
(
struct
romfs_dirent
*
)
file
->
data
;
dirent
=
(
struct
romfs_dirent
*
)
file
->
fnode
->
data
;
if
(
check_dirent
(
dirent
)
!=
0
)
{
return
-
EIO
;
}
RT_ASSERT
(
dirent
->
type
==
ROMFS_DIRENT_DIR
);
/* enter directory */
...
...
@@ -259,10 +315,12 @@ int dfs_romfs_getdents(struct dfs_fd *file, struct dirent *dirp, uint32_t count)
/* make integer count */
count
=
(
count
/
sizeof
(
struct
dirent
));
if
(
count
==
0
)
{
return
-
EINVAL
;
}
index
=
0
;
for
(
index
=
0
;
index
<
count
&&
(
rt_size_t
)
file
->
pos
<
file
->
size
;
index
++
)
for
(
index
=
0
;
index
<
count
&&
file
->
pos
<
file
->
fnode
->
size
;
index
++
)
{
d
=
dirp
+
index
;
...
...
libcpu/Kconfig
浏览文件 @
cfa9a791
config ARCH_CPU_64BIT
bool
config RT_USING_CACHE
bool
default n
config ARCH_CPU_BIG_ENDIAN
bool
...
...
@@ -33,6 +37,7 @@ config ARCH_ARM_CORTEX_M3
config ARCH_ARM_MPU
bool
depends on ARCH_ARM
select ARCH_MM_MPU
config ARCH_ARM_CORTEX_M4
bool
...
...
libcpu/arm/cortex-m7/cpuport.h
0 → 100644
浏览文件 @
cfa9a791
/*
* Copyright (c) 2006-2020, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
*/
#ifndef CPUPORT_H__
#define CPUPORT_H__
#endif
/*CPUPORT_H__*/
src/object.c
浏览文件 @
cfa9a791
...
...
@@ -615,7 +615,7 @@ rt_object_t rt_object_find(const char *name, rt_uint8_t type)
rt_list_for_each
(
node
,
&
(
information
->
object_list
))
{
object
=
rt_list_entry
(
node
,
struct
rt_object
,
list
);
if
(
rt_strncmp
(
object
->
name
,
name
,
RT_NAME_MAX
)
==
0
)
if
(
rt_strncmp
(
object
->
name
,
name
,
RT_NAME_MAX
-
1
)
==
0
)
{
/* leave critical */
rt_exit_critical
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录