No description
Find a file
Ville Juven b8e30b54ec fs/vfs: Separate file descriptors from file descriptions
This patch is a rework of the NuttX file descriptor implementation. The
goal is two-fold:

1. Improve POSIX compliance. The old implementation tied file description
to inode only, not the file struct. POSIX however dictates otherwise.
2. Fix a bug with descriptor duplication (dup2() and dup3()). There is
an existing race condition with this POSIX API that currently results
in a kernel side crash.

The crash occurs when a partially open / closed file descriptor is
duplicated. The reason for the crash is that even if the descriptor is
closed, the file might still be in use by the kernel (due to e.g. ongoing
write to file). The open file data is changed by file_dup3() and this
causes a crash in the device / drivers themselves as they lose access to
the inode and private data.

The fix is done by separating struct file into file and file descriptor
structs. The file struct can live on even if the descriptor is closed,
fixing the crash. This also fixes the POSIX issue, as two descriptors
can now point to the same file.

Signed-off-by: Ville Juven <ville.juven@unikie.com>
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2025-06-12 18:12:42 +08:00
.github build(deps): bump codelytv/pr-size-labeler from 1.10.2 to 1.10.3 2025-05-30 10:34:23 -03:00
arch arch/stm32f0l0g0/stm32_tim.c: fix compilation when TIM6/TIM7 is missing 2025-06-12 10:00:30 +08:00
audio fs/file: unify prefix about file_xxx api, like file_open, file_ioctl 2025-06-12 18:12:42 +08:00
binfmt libc/elf: rename modlib to libelf 2025-04-11 09:43:22 +08:00
boards fs/fs: remove unnecessary FS_REFCOUNT config 2025-06-12 18:12:42 +08:00
cmake style: fix spelling in code comments and strings 2025-05-23 10:48:41 +08:00
crypto fs/vfs: Separate file descriptors from file descriptions 2025-06-12 18:12:42 +08:00
Documentation docs: Fix pipenv lockfile for older Python versions 2025-06-11 23:11:08 +08:00
drivers fs/vfs: Separate file descriptors from file descriptions 2025-06-12 18:12:42 +08:00
dummy build: add initial cmake build system 2023-07-08 13:50:48 +08:00
fs fs/vfs: Separate file descriptors from file descriptions 2025-06-12 18:12:42 +08:00
graphics style: fix spelling in code comments and strings 2025-05-23 10:48:41 +08:00
include fs/vfs: Separate file descriptors from file descriptions 2025-06-12 18:12:42 +08:00
libs libs: unify Private Types banners 2025-05-28 10:17:15 +08:00
mm style: fix spelling in code comments and strings 2025-05-23 10:48:41 +08:00
net fs/file: unify prefix about file_xxx api, like file_open, file_ioctl 2025-06-12 18:12:42 +08:00
openamp style: fix spelling in code comments and strings 2025-05-23 10:48:41 +08:00
pass1 Revert "build depend:Revert Make.dep intermediate ddc file" 2024-09-15 19:29:47 +08:00
sched fs/vfs: Separate file descriptors from file descriptions 2025-06-12 18:12:42 +08:00
syscall sched/gettid: Move thread ID to TLS 2025-04-08 22:53:10 +08:00
tools fs/file: unify prefix f_ for member locked 2025-06-12 18:12:42 +08:00
video Revert "build depend:Revert Make.dep intermediate ddc file" 2024-09-15 19:29:47 +08:00
wireless Bluetooth SMP: added support for Legacy pairing (MITM) with passkey 2025-05-28 21:49:08 +08:00
.asf.yaml github: master branch protection tune. 2025-05-07 18:37:13 -05:00
.codespell-ignore-lines style: fix spelling in code comments and strings 2025-05-23 10:48:41 +08:00
.codespellrc style: fix spelling in code comments and strings 2025-05-23 10:48:41 +08:00
.gitignore gitignore: add Emacs auto-save files 2025-01-15 16:10:22 +08:00
.gitmessage docs/contributing: Add a commit message template 2025-06-03 17:33:24 +08:00
.pre-commit-config.yaml pre-commit: enable codespell checks 2025-05-05 12:34:39 +08:00
.yamllint
AUTHORS AUTHORS: add Matteo Golin 2025-05-27 20:34:16 +08:00
CMakeLists.txt style: fix spelling in code comments and strings 2025-05-23 10:48:41 +08:00
CONTRIBUTING.md style: fix spelling in code comments and strings 2025-05-23 10:48:41 +08:00
INVIOLABLES.md
Kconfig libc/elf: rename modlib to libelf 2025-04-11 09:43:22 +08:00
LICENSE style: fix spelling in code comments and strings 2025-05-23 10:48:41 +08:00
Makefile tools: migrate to SPDX identifier 2024-09-10 23:11:11 +08:00
NOTICE
README.md Gathering community recommendations 2023-10-28 13:55:56 +08:00
ReleaseNotes Documentation: move ReleaseNotes 2023-09-26 20:41:00 +08:00

POSIX Badge License Issues Tracking Badge Contributors GitHub Build Badge Documentation Badge

Apache NuttX is a real-time operating system (RTOS) with an emphasis on standards compliance and small footprint. Scalable from 8-bit to 64-bit microcontroller environments, the primary governing standards in NuttX are POSIX and ANSI standards. Additional standard APIs from Unix and other common RTOSs (such as VxWorks) are adopted for functionality not available under these standards, or for functionality that is not appropriate for deeply-embedded environments (such as fork()).

For brevity, many parts of the documentation will refer to Apache NuttX as simply NuttX.

Getting Started

First time on NuttX? Read the Getting Started guide! If you don't have a board available, NuttX has its own simulator that you can run on terminal.

Documentation

You can find the current NuttX documentation on the Documentation Page.

Alternatively, you can build the documentation yourself by following the Documentation Build Instructions.

The old NuttX documentation is still available in the Apache wiki.

Supported Boards

NuttX supports a wide variety of platforms. See the full list on the Supported Platforms page.

Contributing

If you wish to contribute to the NuttX project, read the Contributing guidelines for information on Git usage, coding standard, workflow and the NuttX principles.

License

The code in this repository is under either the Apache 2 license, or a license compatible with the Apache 2 license. See the License Page for more information.