walnux/sched
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
..
addrenv sem_waitirq: Use kmap interface to access the semaphore 2024-12-18 08:57:01 +08:00
clock sched/wdog: Replace periodcial timer with the wd_start_next. 2025-06-10 11:02:45 -03:00
environ sched/environ: There is no need to use sched_[un]lock 2024-10-11 02:43:11 +08:00
event sched/event: init deleted node to avoid null pointer reference 2024-12-26 23:28:37 +08:00
group fs/vfs: Separate file descriptors from file descriptions 2025-06-12 18:12:42 +08:00
init sched/init: Fix build error with CONFIG_BOARD_CRASHDUMP_CUSTOM 2025-03-08 00:18:25 +08:00
instrument gprof: move gprof function from sched to libbuiltin/libgcc 2024-11-13 02:42:31 +08:00
irq style: fix spelling in code comments and strings 2025-05-23 10:48:41 +08:00
misc fs/vfs: Separate file descriptors from file descriptions 2025-06-12 18:12:42 +08:00
module libc/elf: rename modlib to libelf 2025-04-11 09:43:22 +08:00
mqueue fs/file: unify prefix about file_xxx api, like file_open, file_ioctl 2025-06-12 18:12:42 +08:00
paging Remove duplicate includes across multiple files 2025-01-09 23:30:23 +08:00
pthread style: fix spelling in code comments and strings 2025-05-23 10:48:41 +08:00
sched fs/vfs: Separate file descriptors from file descriptions 2025-06-12 18:12:42 +08:00
semaphore sched: unify Private Types banners 2025-05-28 10:17:15 +08:00
signal sched: unify Private Types banners 2025-05-28 10:17:15 +08:00
task fs/vfs: Separate file descriptors from file descriptions 2025-06-12 18:12:42 +08:00
timer sched/wdog: Replace periodcial timer with the wd_start_next. 2025-06-10 11:02:45 -03:00
tls sched/gettid: Move thread ID to TLS 2025-04-08 22:53:10 +08:00
wdog sched/wdog: Remove the wd_start_period. 2025-06-10 11:02:45 -03:00
wqueue sched/wqueue: Remove the work_queue_period. 2025-06-10 11:02:45 -03:00
CMakeLists.txt sched: migrate to SPDX identifier 2024-09-12 01:10:14 +08:00
Kconfig sched: Correct word spelling mistakes. 2025-05-12 19:56:29 +08:00
Makefile Revert "build depend:Revert Make.dep intermediate ddc file" 2024-09-15 19:29:47 +08:00