diff options
| author | BernardXiong <[email protected]> | 2018-02-11 13:57:51 +0800 |
|---|---|---|
| committer | BernardXiong <[email protected]> | 2018-02-11 13:57:51 +0800 |
| commit | 780c09e3e452568e7befb26c0ffd4ae7f6d1a0cb (patch) | |
| tree | 022d1ca8dd99174b4245bb323bf0d64d65a9bd06 | |
| parent | 011eb615bc036dececaafbf5d3526c508e0b61e2 (diff) | |
[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.
| -rw-r--r-- | components/dfs/filesystems/devfs/devfs.c | 4 | ||||
| -rw-r--r-- | components/libc/compilers/newlib/stdio.c | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/components/dfs/filesystems/devfs/devfs.c b/components/dfs/filesystems/devfs/devfs.c index 4f2f0ebcd9..4694b96c85 100644 --- a/components/dfs/filesystems/devfs/devfs.c +++ b/components/dfs/filesystems/devfs/devfs.c @@ -19,6 +19,7 @@ * * Change Logs: * Date Author Notes + * 2018-02-11 Bernard Ignore O_CREAT flag in open. */ #include <rtthread.h> @@ -137,9 +138,6 @@ int dfs_device_fs_open(struct dfs_fd *file) rt_err_t result; rt_device_t device; - if (file->flags & O_CREAT) - return -EINVAL; - /* open root directory */ if ((file->path[0] == '/') && (file->path[1] == '\0') && (file->flags & O_DIRECTORY)) diff --git a/components/libc/compilers/newlib/stdio.c b/components/libc/compilers/newlib/stdio.c index f28383818d..9a225622b5 100644 --- a/components/libc/compilers/newlib/stdio.c +++ b/components/libc/compilers/newlib/stdio.c @@ -81,7 +81,9 @@ int libc_stdio_set_console(const char* device_name, int mode) _GLOBAL_REENT->__sdidinit = 1; } - return fileno(std_console); + if (std_console) return fileno(std_console); + + return -1; } int libc_stdio_get_console(void) { |
