提交 7e871b0d 编写于 作者: B bernard

[LIBC] fix the open mode when using fopen in arm libc.

上级 a00cc574
...@@ -48,6 +48,7 @@ FILEHANDLE _sys_open(const char *name, int openmode) ...@@ -48,6 +48,7 @@ FILEHANDLE _sys_open(const char *name, int openmode)
{ {
#ifdef RT_USING_DFS #ifdef RT_USING_DFS
int fd; int fd;
int mode = O_RDONLY;
#endif #endif
/* Register standard Input Output devices. */ /* Register standard Input Output devices. */
...@@ -61,8 +62,33 @@ FILEHANDLE _sys_open(const char *name, int openmode) ...@@ -61,8 +62,33 @@ FILEHANDLE _sys_open(const char *name, int openmode)
#ifndef RT_USING_DFS #ifndef RT_USING_DFS
return -1; return -1;
#else #else
/* TODO: adjust open file mode */ /* Correct openmode from fopen to open */
fd = open(name, openmode, 0); if (openmode & OPEN_PLUS)
{
if (openmode & OPEN_W)
{
mode |= (O_RDWR | O_TRUNC | O_CREAT);
}
else if (openmode & OPEN_A)
{
mode |= (O_RDWR | O_APPEND | O_CREAT);
}
else
mode |= O_RDWR;
}
else
{
if (openmode & OPEN_W)
{
mode |= (O_WRONLY | O_TRUNC | O_CREAT);
}
else if (openmode & OPEN_A)
{
mode |= (O_WRONLY | O_APPEND | O_CREAT);
}
}
fd = open(name, mode, 0);
if(fd < 0) if(fd < 0)
return -1; return -1;
else else
...@@ -196,7 +222,10 @@ char *_sys_command_string(char *cmd, int len) ...@@ -196,7 +222,10 @@ char *_sys_command_string(char *cmd, int len)
void _ttywrch(int ch) void _ttywrch(int ch)
{ {
/* TODO */ char c;
c = (char)ch;
rt_kprintf(&c);
} }
void _sys_exit(int return_code) void _sys_exit(int return_code)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册