Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
rt-thread
提交
873a5de8
R
rt-thread
项目概览
BaiXuePrincess
/
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看板
提交
873a5de8
编写于
6月 29, 2013
作者:
Y
yiyue.fang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
reformat the coding style in dfs_ramfs.c
上级
03cf76e7
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
26 addition
and
14 deletion
+26
-14
components/dfs/filesystems/ramfs/dfs_ramfs.c
components/dfs/filesystems/ramfs/dfs_ramfs.c
+26
-14
未找到文件。
components/dfs/filesystems/ramfs/dfs_ramfs.c
浏览文件 @
873a5de8
...
@@ -38,7 +38,7 @@ int dfs_ramfs_mount(struct dfs_filesystem *fs,
...
@@ -38,7 +38,7 @@ int dfs_ramfs_mount(struct dfs_filesystem *fs,
if
(
data
==
RT_NULL
)
if
(
data
==
RT_NULL
)
return
-
DFS_STATUS_EIO
;
return
-
DFS_STATUS_EIO
;
ramfs
=
(
struct
dfs_ramfs
*
)
data
;
ramfs
=
(
struct
dfs_ramfs
*
)
data
;
fs
->
data
=
ramfs
;
fs
->
data
=
ramfs
;
return
DFS_STATUS_OK
;
return
DFS_STATUS_OK
;
...
@@ -47,6 +47,7 @@ int dfs_ramfs_mount(struct dfs_filesystem *fs,
...
@@ -47,6 +47,7 @@ int dfs_ramfs_mount(struct dfs_filesystem *fs,
int
dfs_ramfs_unmount
(
struct
dfs_filesystem
*
fs
)
int
dfs_ramfs_unmount
(
struct
dfs_filesystem
*
fs
)
{
{
fs
->
data
=
RT_NULL
;
fs
->
data
=
RT_NULL
;
return
DFS_STATUS_OK
;
return
DFS_STATUS_OK
;
}
}
...
@@ -58,9 +59,9 @@ int dfs_ramfs_statfs(struct dfs_filesystem *fs, struct statfs *buf)
...
@@ -58,9 +59,9 @@ int dfs_ramfs_statfs(struct dfs_filesystem *fs, struct statfs *buf)
RT_ASSERT
(
ramfs
!=
RT_NULL
);
RT_ASSERT
(
ramfs
!=
RT_NULL
);
RT_ASSERT
(
buf
!=
RT_NULL
);
RT_ASSERT
(
buf
!=
RT_NULL
);
buf
->
f_bsize
=
512
;
buf
->
f_bsize
=
512
;
buf
->
f_blocks
=
ramfs
->
memheap
.
pool_size
/
512
;
buf
->
f_blocks
=
ramfs
->
memheap
.
pool_size
/
512
;
buf
->
f_bfree
=
ramfs
->
memheap
.
available_size
/
512
;
buf
->
f_bfree
=
ramfs
->
memheap
.
available_size
/
512
;
return
DFS_STATUS_OK
;
return
DFS_STATUS_OK
;
}
}
...
@@ -78,7 +79,8 @@ struct ramfs_dirent *dfs_ramfs_lookup(struct dfs_ramfs *ramfs,
...
@@ -78,7 +79,8 @@ struct ramfs_dirent *dfs_ramfs_lookup(struct dfs_ramfs *ramfs,
struct
ramfs_dirent
*
dirent
;
struct
ramfs_dirent
*
dirent
;
subpath
=
path
;
subpath
=
path
;
while
(
*
subpath
==
'/'
&&
*
subpath
)
subpath
++
;
while
(
*
subpath
==
'/'
&&
*
subpath
)
subpath
++
;
if
(
!
*
subpath
)
/* is root directory */
if
(
!
*
subpath
)
/* is root directory */
{
{
*
size
=
0
;
*
size
=
0
;
...
@@ -222,7 +224,9 @@ int dfs_ramfs_open(struct dfs_fd *file)
...
@@ -222,7 +224,9 @@ int dfs_ramfs_open(struct dfs_fd *file)
char
*
name_ptr
;
char
*
name_ptr
;
/* create a file entry */
/* create a file entry */
dirent
=
(
struct
ramfs_dirent
*
)
rt_memheap_alloc
(
&
(
ramfs
->
memheap
),
sizeof
(
struct
ramfs_dirent
));
dirent
=
(
struct
ramfs_dirent
*
)
rt_memheap_alloc
(
&
(
ramfs
->
memheap
),
sizeof
(
struct
ramfs_dirent
));
if
(
dirent
==
RT_NULL
)
if
(
dirent
==
RT_NULL
)
{
{
return
-
DFS_STATUS_ENOMEM
;
return
-
DFS_STATUS_ENOMEM
;
...
@@ -244,7 +248,9 @@ int dfs_ramfs_open(struct dfs_fd *file)
...
@@ -244,7 +248,9 @@ int dfs_ramfs_open(struct dfs_fd *file)
return
-
DFS_STATUS_ENOENT
;
return
-
DFS_STATUS_ENOENT
;
}
}
/* Creates a new file. If the file is existing, it is truncated and overwritten. */
/* Creates a new file.
* If the file is existing, it is truncated and overwritten.
*/
if
(
file
->
flags
&
DFS_O_TRUNC
)
if
(
file
->
flags
&
DFS_O_TRUNC
)
{
{
dirent
->
size
=
0
;
dirent
->
size
=
0
;
...
@@ -263,7 +269,9 @@ int dfs_ramfs_open(struct dfs_fd *file)
...
@@ -263,7 +269,9 @@ int dfs_ramfs_open(struct dfs_fd *file)
return
DFS_STATUS_OK
;
return
DFS_STATUS_OK
;
}
}
int
dfs_ramfs_stat
(
struct
dfs_filesystem
*
fs
,
const
char
*
path
,
struct
stat
*
st
)
int
dfs_ramfs_stat
(
struct
dfs_filesystem
*
fs
,
const
char
*
path
,
struct
stat
*
st
)
{
{
rt_size_t
size
;
rt_size_t
size
;
struct
ramfs_dirent
*
dirent
;
struct
ramfs_dirent
*
dirent
;
...
@@ -286,20 +294,24 @@ int dfs_ramfs_stat(struct dfs_filesystem *fs, const char *path, struct stat *st)
...
@@ -286,20 +294,24 @@ int dfs_ramfs_stat(struct dfs_filesystem *fs, const char *path, struct stat *st)
return
DFS_STATUS_OK
;
return
DFS_STATUS_OK
;
}
}
int
dfs_ramfs_getdents
(
struct
dfs_fd
*
file
,
struct
dirent
*
dirp
,
rt_uint32_t
count
)
int
dfs_ramfs_getdents
(
struct
dfs_fd
*
file
,
struct
dirent
*
dirp
,
rt_uint32_t
count
)
{
{
rt_size_t
index
,
end
;
rt_size_t
index
,
end
;
struct
dirent
*
d
;
struct
dirent
*
d
;
struct
ramfs_dirent
*
dirent
;
struct
ramfs_dirent
*
dirent
;
struct
dfs_ramfs
*
ramfs
;
struct
dfs_ramfs
*
ramfs
;
ramfs
=
(
struct
dfs_ramfs
*
)
file
->
fs
->
data
;
ramfs
=
(
struct
dfs_ramfs
*
)
file
->
fs
->
data
;
dirent
=
(
struct
ramfs_dirent
*
)
file
->
data
;
dirent
=
(
struct
ramfs_dirent
*
)
file
->
data
;
if
(
dirent
!=
&
(
ramfs
->
root
))
return
-
DFS_STATUS_EINVAL
;
if
(
dirent
!=
&
(
ramfs
->
root
))
return
-
DFS_STATUS_EINVAL
;
/* make integer count */
/* make integer count */
count
=
(
count
/
sizeof
(
struct
dirent
));
count
=
(
count
/
sizeof
(
struct
dirent
));
if
(
count
==
0
)
return
-
DFS_STATUS_EINVAL
;
if
(
count
==
0
)
return
-
DFS_STATUS_EINVAL
;
end
=
file
->
pos
+
count
;
end
=
file
->
pos
+
count
;
index
=
0
;
index
=
0
;
...
@@ -406,8 +418,8 @@ struct dfs_ramfs* dfs_ramfs_create(rt_uint8_t *pool, rt_size_t size)
...
@@ -406,8 +418,8 @@ struct dfs_ramfs* dfs_ramfs_create(rt_uint8_t *pool, rt_size_t size)
rt_uint8_t
*
data_ptr
;
rt_uint8_t
*
data_ptr
;
rt_err_t
result
;
rt_err_t
result
;
size
=
RT_ALIGN_DOWN
(
size
,
RT_ALIGN_SIZE
);
size
=
RT_ALIGN_DOWN
(
size
,
RT_ALIGN_SIZE
);
ramfs
=
(
struct
dfs_ramfs
*
)
pool
;
ramfs
=
(
struct
dfs_ramfs
*
)
pool
;
data_ptr
=
(
rt_uint8_t
*
)(
ramfs
+
1
);
data_ptr
=
(
rt_uint8_t
*
)(
ramfs
+
1
);
size
=
size
-
sizeof
(
struct
dfs_ramfs
);
size
=
size
-
sizeof
(
struct
dfs_ramfs
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录