1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-18 12:52:44 +01:00

sys/vfs: Exclude stdio file numbers from auto allocation

Fixes #8309 (https://github.com/RIOT-OS/RIOT/issues/8309)
This commit is contained in:
Joakim Nohlgård 2018-02-13 18:02:06 +01:00
parent 88e79fb825
commit be14d2eace

View File

@ -21,6 +21,7 @@
#include <sys/stat.h> /* for struct stat */
#include <sys/statvfs.h> /* for struct statvfs */
#include <fcntl.h> /* for O_ACCMODE, ..., fcntl */
#include <unistd.h> /* for STDIN_FILENO, STDOUT_FILENO, STDERR_FILENO */
#include "vfs.h"
#include "mutex.h"
@ -867,6 +868,13 @@ static inline int _allocate_fd(int fd)
{
if (fd < 0) {
for (fd = 0; fd < VFS_MAX_OPEN_FILES; ++fd) {
if ((fd == STDIN_FILENO) || (fd == STDOUT_FILENO) || (fd == STDERR_FILENO)) {
/* Do not auto-allocate the stdio file descriptor numbers to
* avoid conflicts between normal file system users and stdio
* drivers such as uart_stdio, rtt_stdio which need to be able
* to bind to these specific file descriptor numbers. */
continue;
}
if (_vfs_open_files[fd].pid == KERNEL_PID_UNDEF) {
break;
}