mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2025-02-21 00:27:19 +08:00
[libc] Fix the O_CREAT issue.
libc_stdio_set_console/newlib uses fopen to open console device, which has O_CREAT flag and cause fault.
This commit is contained in:
parent
011eb615bc
commit
780c09e3e4
@ -19,6 +19,7 @@
|
|||||||
*
|
*
|
||||||
* Change Logs:
|
* Change Logs:
|
||||||
* Date Author Notes
|
* Date Author Notes
|
||||||
|
* 2018-02-11 Bernard Ignore O_CREAT flag in open.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <rtthread.h>
|
#include <rtthread.h>
|
||||||
@ -137,9 +138,6 @@ int dfs_device_fs_open(struct dfs_fd *file)
|
|||||||
rt_err_t result;
|
rt_err_t result;
|
||||||
rt_device_t device;
|
rt_device_t device;
|
||||||
|
|
||||||
if (file->flags & O_CREAT)
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
/* open root directory */
|
/* open root directory */
|
||||||
if ((file->path[0] == '/') && (file->path[1] == '\0') &&
|
if ((file->path[0] == '/') && (file->path[1] == '\0') &&
|
||||||
(file->flags & O_DIRECTORY))
|
(file->flags & O_DIRECTORY))
|
||||||
|
@ -81,7 +81,9 @@ int libc_stdio_set_console(const char* device_name, int mode)
|
|||||||
_GLOBAL_REENT->__sdidinit = 1;
|
_GLOBAL_REENT->__sdidinit = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return fileno(std_console);
|
if (std_console) return fileno(std_console);
|
||||||
|
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int libc_stdio_get_console(void) {
|
int libc_stdio_get_console(void) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user