walnux/fs
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
..
aio fs/file: unify prefix about file_xxx api, like file_open, file_ioctl 2025-06-12 18:12:42 +08:00
binfs fs: migrate to SPDX identifier 2024-11-06 01:58:54 +08:00
cromfs fs: migrate to SPDX identifier 2024-11-06 01:58:54 +08:00
driver fs: add merge partitions support 2024-11-07 14:59:23 +08:00
event Fix path error 2024-11-28 15:04:59 +08:00
fat style: fix spelling in code comments and strings 2025-05-23 10:48:41 +08:00
hostfs style: fix spelling in code comments and strings 2025-05-23 10:48:41 +08:00
inode fs/vfs: Separate file descriptors from file descriptions 2025-06-12 18:12:42 +08:00
littlefs style: fix spelling in code comments and strings 2025-05-23 10:48:41 +08:00
mmap fs/file: unify prefix about file_xxx api, like file_open, file_ioctl 2025-06-12 18:12:42 +08:00
mnemofs style: fix spelling in code comments and strings 2025-05-23 10:48:41 +08:00
mount wqueue: wqueue remove csection 2025-01-15 17:26:07 +08:00
mqueue fs/vfs: Separate file descriptors from file descriptions 2025-06-12 18:12:42 +08:00
nfs style: fix spelling in code comments and strings 2025-05-23 10:48:41 +08:00
notify fs/vfs: Separate file descriptors from file descriptions 2025-06-12 18:12:42 +08:00
nxffs style: fix spelling in code comments and strings 2025-05-23 10:48:41 +08:00
partition style: fix spelling in code comments and strings 2025-05-23 10:48:41 +08:00
procfs fs/vfs: Separate file descriptors from file descriptions 2025-06-12 18:12:42 +08:00
romfs style: fix spelling in code comments and strings 2025-05-23 10:48:41 +08:00
rpmsgfs Use lib_get_pathbuffer instead of stack variables 2024-11-12 17:21:42 +08:00
semaphore fs: migrate to SPDX identifier 2024-11-06 01:58:54 +08:00
shm fs/vfs: Separate file descriptors from file descriptions 2025-06-12 18:12:42 +08:00
smartfs fs: migrate to SPDX identifier 2024-11-06 01:58:54 +08:00
socket fs/vfs: Separate file descriptors from file descriptions 2025-06-12 18:12:42 +08:00
spiffs style: fix spelling in code comments and strings 2025-05-23 10:48:41 +08:00
tmpfs fs/tmpfs: Skip any slash at the beginning of relpath 2024-12-07 11:40:00 +08:00
unionfs style: fix spelling in code comments and strings 2025-05-23 10:48:41 +08:00
userfs fs: migrate to SPDX identifier 2024-11-06 01:58:54 +08:00
v9fs refactor: fix spelling in private field names 2025-05-24 09:44:22 -03:00
vfs fs/vfs: Separate file descriptors from file descriptions 2025-06-12 18:12:42 +08:00
zipfs fs: migrate to SPDX identifier 2024-11-06 01:58:54 +08:00
CMakeLists.txt fs: migrate to SPDX identifier 2024-11-06 01:58:54 +08:00
fs_heap.c fs_heap:add fs_heap_mallinfo_task 2025-01-15 17:12:50 +08:00
fs_heap.h fs_heap:add fs_heap_mallinfo_task 2025-01-15 17:12:50 +08:00
fs_initialize.c fs: migrate to SPDX identifier 2024-11-06 01:58:54 +08:00
Kconfig fs/fs: remove unnecessary FS_REFCOUNT config 2025-06-12 18:12:42 +08:00
Make.defs fs: migrate to SPDX identifier 2024-11-06 01:58:54 +08:00
Makefile fs: migrate to SPDX identifier 2024-11-06 01:58:54 +08:00