Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
职场007
rt-thread
提交
cc9667b7
R
rt-thread
项目概览
职场007
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
1
Star
0
Fork
0
代码
文件
提交
分支
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,发现更多精彩内容 >>
提交
cc9667b7
编写于
10月 25, 2017
作者:
B
bernard
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[DFS] Fix the RAMFS compiling issue.
上级
1f76e1b8
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
23 addition
and
12 deletion
+23
-12
components/dfs/filesystems/ramfs/dfs_ramfs.c
components/dfs/filesystems/ramfs/dfs_ramfs.c
+17
-9
components/dfs/filesystems/ramfs/dfs_ramfs.h
components/dfs/filesystems/ramfs/dfs_ramfs.h
+6
-3
未找到文件。
components/dfs/filesystems/ramfs/dfs_ramfs.c
浏览文件 @
cc9667b7
...
...
@@ -27,6 +27,8 @@
#include <rtthread.h>
#include <dfs.h>
#include <dfs_fs.h>
#include <dfs_file.h>
#include "dfs_ramfs.h"
int
dfs_ramfs_mount
(
struct
dfs_filesystem
*
fs
,
...
...
@@ -131,11 +133,12 @@ int dfs_ramfs_write(struct dfs_fd *fd, const void *buf, size_t count)
struct
ramfs_dirent
*
dirent
;
struct
dfs_ramfs
*
ramfs
;
ramfs
=
(
struct
dfs_ramfs
*
)
fd
->
fs
->
data
;
RT_ASSERT
(
ramfs
!=
NULL
);
dirent
=
(
struct
ramfs_dirent
*
)
fd
->
data
;
RT_ASSERT
(
dirent
!=
NULL
);
ramfs
=
dirent
->
fs
;
RT_ASSERT
(
ramfs
!=
NULL
);
if
(
count
+
fd
->
pos
>
fd
->
size
)
{
rt_uint8_t
*
ptr
;
...
...
@@ -187,7 +190,7 @@ int dfs_ramfs_open(struct dfs_fd *file)
struct
dfs_ramfs
*
ramfs
;
struct
ramfs_dirent
*
dirent
;
ramfs
=
(
struct
dfs_ramfs
*
)
file
->
fs
->
data
;
ramfs
=
(
struct
dfs_ramfs
*
)
file
->
data
;
RT_ASSERT
(
ramfs
!=
NULL
);
if
(
file
->
flags
&
O_DIRECTORY
)
...
...
@@ -241,6 +244,8 @@ int dfs_ramfs_open(struct dfs_fd *file)
rt_list_init
(
&
(
dirent
->
list
));
dirent
->
data
=
NULL
;
dirent
->
size
=
0
;
dirent
->
fs
=
ramfs
;
/* add to the root directory */
rt_list_insert_after
(
&
(
ramfs
->
root
.
list
),
&
(
dirent
->
list
));
}
...
...
@@ -264,10 +269,10 @@ int dfs_ramfs_open(struct dfs_fd *file)
file
->
data
=
dirent
;
file
->
size
=
dirent
->
size
;
if
(
file
->
flags
&
O_APPEND
)
file
->
pos
=
file
->
size
;
else
file
->
pos
=
0
;
if
(
file
->
flags
&
O_APPEND
)
file
->
pos
=
file
->
size
;
else
file
->
pos
=
0
;
return
0
;
}
...
...
@@ -305,11 +310,13 @@ int dfs_ramfs_getdents(struct dfs_fd *file,
struct
ramfs_dirent
*
dirent
;
struct
dfs_ramfs
*
ramfs
;
ramfs
=
(
struct
dfs_ramfs
*
)
file
->
fs
->
data
;
dirent
=
(
struct
ramfs_dirent
*
)
file
->
data
;
if
(
dirent
!=
&
(
ramfs
->
root
))
return
-
EINVAL
;
ramfs
=
dirent
->
fs
;
RT_ASSERT
(
ramfs
!=
RT_NULL
);
/* make integer count */
count
=
(
count
/
sizeof
(
struct
dirent
));
if
(
count
==
0
)
...
...
@@ -325,7 +332,7 @@ int dfs_ramfs_getdents(struct dfs_fd *file,
if
(
index
>=
(
rt_size_t
)
file
->
pos
)
{
d
=
dirp
+
count
;
d
->
d_type
=
D
FS_D
T_REG
;
d
->
d_type
=
DT_REG
;
d
->
d_namlen
=
RT_NAME_MAX
;
d
->
d_reclen
=
(
rt_uint16_t
)
sizeof
(
struct
dirent
);
rt_strncpy
(
d
->
d_name
,
dirent
->
name
,
RAMFS_NAME_MAX
);
...
...
@@ -451,3 +458,4 @@ struct dfs_ramfs* dfs_ramfs_create(rt_uint8_t *pool, rt_size_t size)
return
ramfs
;
}
components/dfs/filesystems/ramfs/dfs_ramfs.h
浏览文件 @
cc9667b7
...
...
@@ -30,15 +30,17 @@
#include <rtservice.h>
#define RAMFS_NAME_MAX 32
#define RAMFS_MAGIC
0x0A0A0A0A
#define RAMFS_MAGIC
0x0A0A0A0A
struct
ramfs_dirent
{
rt_list_t
list
;
char
name
[
RAMFS_NAME_MAX
];
/* dirent name */
struct
dfs_ramfs
*
fs
;
/* file system ref */
char
name
[
RAMFS_NAME_MAX
];
/* dirent name */
rt_uint8_t
*
data
;
rt_size_t
size
;
/* file size */
rt_size_t
size
;
/* file size */
};
/**
...
...
@@ -56,3 +58,4 @@ int dfs_ramfs_init(void);
struct
dfs_ramfs
*
dfs_ramfs_create
(
rt_uint8_t
*
pool
,
rt_size_t
size
);
#endif
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录