Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2345VOR
rt-thread
提交
5a95d356
R
rt-thread
项目概览
2345VOR
/
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,发现更多精彩内容 >>
提交
5a95d356
编写于
12月 31, 2017
作者:
B
BernardXiong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[DFS] Add fcntl API (same with ioctl in RT-Thread).
上级
8246da64
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
56 addition
and
9 deletion
+56
-9
components/dfs/include/dfs_posix.h
components/dfs/include/dfs_posix.h
+2
-0
components/dfs/src/dfs_file.c
components/dfs/src/dfs_file.c
+21
-1
components/dfs/src/dfs_posix.c
components/dfs/src/dfs_posix.c
+26
-8
include/libc/libc_fcntl.h
include/libc/libc_fcntl.h
+7
-0
未找到文件。
components/dfs/include/dfs_posix.h
浏览文件 @
5a95d356
...
...
@@ -22,6 +22,7 @@
* 2009-05-27 Yi.qiu The first version.
* 2010-07-18 Bernard add stat and statfs structure definitions.
* 2011-05-16 Yi.qiu Change parameter name of rename, "new" is C++ key word.
* 2017-12-27 Bernard Add fcntl API.
*/
#ifndef __DFS_POSIX_H__
...
...
@@ -66,6 +67,7 @@ int unlink(const char *pathname);
int
stat
(
const
char
*
file
,
struct
stat
*
buf
);
int
fstat
(
int
fildes
,
struct
stat
*
buf
);
int
fsync
(
int
fildes
);
int
fcntl
(
int
fildes
,
int
cmd
,
void
*
data
);
int
ioctl
(
int
fildes
,
int
cmd
,
void
*
data
);
/* directory api*/
...
...
components/dfs/src/dfs_file.c
浏览文件 @
5a95d356
...
...
@@ -173,9 +173,29 @@ int dfs_file_close(struct dfs_fd *fd)
*/
int
dfs_file_ioctl
(
struct
dfs_fd
*
fd
,
int
cmd
,
void
*
args
)
{
if
(
fd
==
NULL
||
fd
->
type
!=
FT_REGULAR
)
if
(
fd
==
NULL
)
return
-
EINVAL
;
/* regular file system fd */
if
(
fd
->
type
==
FT_REGULAR
)
{
switch
(
cmd
)
{
case
F_GETFL
:
return
fd
->
flags
;
/* return flags */
case
F_SETFL
:
{
int
flags
=
(
int
)
args
;
int
mask
=
O_NONBLOCK
|
O_APPEND
;
flags
&=
mask
;
fd
->
flags
&=
mask
;
fd
->
flags
|=
flags
;
}
return
0
;
}
}
if
(
fd
->
fops
->
ioctl
!=
NULL
)
return
fd
->
fops
->
ioctl
(
fd
,
cmd
,
args
);
...
...
components/dfs/src/dfs_posix.c
浏览文件 @
5a95d356
...
...
@@ -428,28 +428,46 @@ RTM_EXPORT(fsync);
* @return 0 on successful completion. Otherwise, -1 shall be returned and errno
* set to indicate the error.
*/
int
ioc
tl
(
int
fildes
,
int
cmd
,
void
*
data
)
int
fcn
tl
(
int
fildes
,
int
cmd
,
void
*
data
)
{
int
ret
;
int
ret
=
-
1
;
struct
dfs_fd
*
d
;
/* get the fd */
d
=
fd_get
(
fildes
);
if
(
d
==
NULL
)
if
(
d
)
{
r
t_set_errno
(
-
EBADF
);
return
-
1
;
r
et
=
dfs_file_ioctl
(
d
,
cmd
,
data
);
fd_put
(
d
)
;
}
else
ret
=
-
EBADF
;
ret
=
dfs_file_ioctl
(
d
,
cmd
,
data
);
if
(
ret
!=
0
)
{
rt_set_errno
(
ret
);
ret
=
-
1
;
}
fd_put
(
d
);
return
ret
;
return
0
;
}
RTM_EXPORT
(
fcntl
);
/**
* this function is a POSIX compliant version, which shall perform a variety of
* control functions on devices.
*
* @param fildes the file description
* @param cmd the specified command
* @param data represents the additional information that is needed by this
* specific device to perform the requested function.
*
* @return 0 on successful completion. Otherwise, -1 shall be returned and errno
* set to indicate the error.
*/
int
ioctl
(
int
fildes
,
int
cmd
,
void
*
data
)
{
/* we use fcntl for this API. */
return
fcntl
(
fildes
,
cmd
,
data
);
}
RTM_EXPORT
(
ioctl
);
...
...
include/libc/libc_fcntl.h
浏览文件 @
5a95d356
...
...
@@ -16,6 +16,13 @@
#define O_ACCMODE (_O_RDONLY | _O_WRONLY | _O_RDWR)
#endif
#ifndef F_GETFL
#define F_GETFL 3
#endif
#ifndef F_SETFL
#define F_SETFL 4
#endif
#else
#define O_RDONLY 00
#define O_WRONLY 01
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录