Skip to content

VFS Module does not reserve file descriptors 0, 1, and 2 #8309

Closed
@samkumar

Description

@samkumar

Description

The VFS module does not reserve file descriptors 0, 1, and 2 for stdin, stdout, and stderr. As a result, the following bugs exist:

  • Opening a file could be assigned to one of these descriptors.
  • Utilities in newlib such as printf do not work. The output is written to file descriptor 1 and uart_stdio_write never gets called.

More generally, there seems to be no vfs_init procedure, so it seems that all the _vfs_open_files array is unintialized. In my opinion, the correct solution is to add a vfs_init procedure that initializes the _vfs_open_files array and reserves file descriptors 0, 1, and 2.

Steps to reproduce the issue

Method 1: Call printf().
Method 2: Open a socket with the posix_sockets module.

Expected results

Expected Results for Method 1: The output is written to the screen.
Expected Results for Method 2: The resulting file descriptor is greater than 2.

Actual results

Actual Results for Method 1: Nothing is written to the screen.
Actual Results for Method 2: The resulting file descriptor is 0.

Versions

I am building the code from a Linux computer running Ubuntu 16.04.
The platform I am targeting is HAMILTON (@immesys).

Output from print_toolchain_versions.sh:

./print_toolchain_versions.sh 
Installed toolchain versions
----------------------------
          native gcc: gcc (Ubuntu 5.4.0-6ubuntu1~16.04.5) 5.4.0 20160609
          msp430-gcc: msp430-gcc (GCC) 4.6.3 20120301 (mspgcc LTS 20120406 unpatched)
             avr-gcc: missing/error
   arm-none-eabi-gcc: arm-none-eabi-gcc (15:4.9.3+svn231177-1) 4.9.3 20150529 (prerelease)
    mips-mti-elf-gcc: missing/error
               clang: clang version 3.8.0-2ubuntu4 (tags/RELEASE_380/final)
arm-none-eabi-newlib: "2.2.0"
 mips-mti-elf-newlib: missing/error
            avr-libc: missing/error (missing/error)
            cppcheck: missing
          coccinelle: missing

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: fsArea: File systemsType: bugThe issue reports a bug / The PR fixes a bug (including spelling errors)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions