Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
dgr6878
rt-thread
提交
4e41b057
R
rt-thread
项目概览
dgr6878
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
5
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
4e41b057
编写于
2月 07, 2018
作者:
B
Bernard Xiong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[libc] fix the fcntl issue in newlib
上级
64a20c0f
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
52 addition
and
30 deletion
+52
-30
components/dfs/include/dfs_posix.h
components/dfs/include/dfs_posix.h
+4
-3
components/dfs/src/dfs_posix.c
components/dfs/src/dfs_posix.c
+20
-6
components/libc/compilers/newlib/sys/fcntl.h
components/libc/compilers/newlib/sys/fcntl.h
+0
-16
include/libc/libc_fcntl.h
include/libc/libc_fcntl.h
+28
-5
未找到文件。
components/dfs/include/dfs_posix.h
浏览文件 @
4e41b057
...
...
@@ -23,6 +23,7 @@
* 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.
* 2018-02-07 Bernard Change the 3rd parameter of open/fcntl/ioctl to '...'
*/
#ifndef __DFS_POSIX_H__
...
...
@@ -52,7 +53,7 @@ void rewinddir(DIR *d);
int
closedir
(
DIR
*
d
);
/* file api*/
int
open
(
const
char
*
file
,
int
flags
,
int
mode
);
int
open
(
const
char
*
file
,
int
flags
,
...
);
int
close
(
int
d
);
#ifdef RT_USING_NEWLIB
_READ_WRITE_RETURN_TYPE
_EXFUN
(
read
,
(
int
__fd
,
void
*
__buf
,
size_t
__nbyte
));
...
...
@@ -67,8 +68,8 @@ 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
);
int
fcntl
(
int
fildes
,
int
cmd
,
...
);
int
ioctl
(
int
fildes
,
int
cmd
,
...
);
/* directory api*/
int
rmdir
(
const
char
*
path
);
...
...
components/dfs/src/dfs_posix.c
浏览文件 @
4e41b057
...
...
@@ -20,6 +20,7 @@
* Change Logs:
* Date Author Notes
* 2009-05-27 Yi.qiu The first version
* 2018-02-07 Bernard Change the 3rd parameter of open/fcntl/ioctl to '...'
*/
#include <dfs.h>
...
...
@@ -38,11 +39,10 @@
*
* @param file the path name of file.
* @param flags the file open flags.
* @param mode ignored parameter
*
* @return the non-negative integer on successful open, others for failed.
*/
int
open
(
const
char
*
file
,
int
flags
,
int
mode
)
int
open
(
const
char
*
file
,
int
flags
,
...
)
{
int
fd
,
result
;
struct
dfs_fd
*
d
;
...
...
@@ -428,7 +428,7 @@ RTM_EXPORT(fsync);
* @return 0 on successful completion. Otherwise, -1 shall be returned and errno
* set to indicate the error.
*/
int
fcntl
(
int
fildes
,
int
cmd
,
void
*
data
)
int
fcntl
(
int
fildes
,
int
cmd
,
...
)
{
int
ret
=
-
1
;
struct
dfs_fd
*
d
;
...
...
@@ -437,7 +437,14 @@ int fcntl(int fildes, int cmd, void *data)
d
=
fd_get
(
fildes
);
if
(
d
)
{
ret
=
dfs_file_ioctl
(
d
,
cmd
,
data
);
void
*
arg
;
va_list
ap
;
va_start
(
ap
,
cmd
);
arg
=
va_arg
(
ap
,
void
*
);
va_end
(
ap
);
ret
=
dfs_file_ioctl
(
d
,
cmd
,
arg
);
fd_put
(
d
);
}
else
ret
=
-
EBADF
;
...
...
@@ -464,10 +471,17 @@ RTM_EXPORT(fcntl);
* @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
)
int
ioctl
(
int
fildes
,
int
cmd
,
...
)
{
void
*
arg
;
va_list
ap
;
va_start
(
ap
,
cmd
);
arg
=
va_arg
(
ap
,
void
*
);
va_end
(
ap
);
/* we use fcntl for this API. */
return
fcntl
(
fildes
,
cmd
,
data
);
return
fcntl
(
fildes
,
cmd
,
arg
);
}
RTM_EXPORT
(
ioctl
);
...
...
components/libc/compilers/newlib/sys/fcntl.h
已删除
100644 → 0
浏览文件 @
64a20c0f
#ifndef __RTT_FCNTL_H__
#define __RTT_FCNTL_H__
/* Operation flags */
#define O_RDONLY 0x0000000
#define O_WRONLY 0x0000001
#define O_RDWR 0x0000002
#define O_ACCMODE 0x0000003
#define O_CREAT 0x0000100
#define O_EXCL 0x0000200
#define O_TRUNC 0x0001000
#define O_APPEND 0x0002000
#define O_DIRECTORY 0x0200000
#define O_BINARY 0x0008000
#endif
include/libc/libc_fcntl.h
浏览文件 @
4e41b057
/*
* fcntl.h file in libc
*/
* File : libc_fcntl.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2017 - 2018, RT-Thread Development Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
* 2018-02-07 Bernard Add O_DIRECTORY definition in NEWLIB mode.
*/
#ifndef LIBC_FCNTL_H__
#define LIBC_FCNTL_H__
...
...
@@ -8,11 +29,10 @@
#include <fcntl.h>
#ifndef O_NONBLOCK
#define O_NONBLOCK
0
4000
#define O_NONBLOCK
0x
4000
#endif
#if defined(_WIN32)
#define O_DIRECTORY 0200000
#define O_ACCMODE (_O_RDONLY | _O_WRONLY | _O_RDWR)
#endif
...
...
@@ -23,6 +43,10 @@
#define F_SETFL 4
#endif
#ifndef O_DIRECTORY
#define O_DIRECTORY 0x200000
#endif
#else
#define O_RDONLY 00
#define O_WRONLY 01
...
...
@@ -77,4 +101,3 @@
#endif
#endif
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录