nuttx/fs
Lingao Meng 5b9707cb5c fs/hostfs: Handle POSIX byte-range locks
fcntl(F_GETLK/F_SETLK/F_SETLKW) is handled by VFS and reaches file
systems as private FIOC_* ioctl commands. hostfs previously forwarded
those private ioctl command numbers to the host ioctl backend, which is
not the POSIX file-locking interface and cannot be interpreted by the
host OS.

Keep hostfs on the generic host_ioctl() path and define the FIOC_* lock
command values in the hostfs host ABI. The POSIX sim backend recognizes
those commands in host_ioctl() and translates struct flock fields to the
host ABI before calling host fcntl(). Other hostfs backends keep their
existing unsupported-host-ioctl behavior.

F_SETLKW is implemented in the POSIX sim backend by retrying
non-blocking host F_SETLK with a short sleep. This preserves the
blocking NuttX API without forwarding host F_SETLKW directly.

Testing:

  - Host: Ubuntu 22.04 x86_64.

  - Board/config: sim:nsh with CONFIG_FS_HOSTFS=y,
    CONFIG_SIM_HOSTFS=y and CONFIG_EXAMPLES_SIM_POSIX=y.

  - make -j16.

  - Ran examples/sim_posix from nuttx-apps. The test mounted a long
    /tmp hostfs path, opened a host-backed file, and verified
    fcntl(F_SETLK), fcntl(F_GETLK), fcntl(F_SETLKW), and unlocking with
    F_UNLCK. The app printed "sim_posix: hostfs locks ok" and
    "sim_posix: PASS".

Assisted-by: Claude:Claude-Fable-5
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2026-07-22 18:07:07 +08:00
..
aio !include/fcntl.h: align open flags with Linux values 2026-06-30 13:43:44 +08:00
binfs !include/fcntl.h: align open flags with Linux values 2026-06-30 13:43:44 +08:00
cromfs !include/fcntl.h: align open flags with Linux values 2026-06-30 13:43:44 +08:00
driver libs/libc: Fix divide-by-zero in stat() with large filesystem block sizes 2026-07-16 23:37:22 +08:00
event fs/event/open: fix the inode information update outside of lock 2026-01-28 10:03:06 +08:00
fat !include/fcntl.h: align open flags with Linux values 2026-06-30 13:43:44 +08:00
hostfs fs/hostfs: Handle POSIX byte-range locks 2026-07-22 18:07:07 +08:00
inode !include/fcntl.h: align open flags with Linux values 2026-06-30 13:43:44 +08:00
littlefs !include/fcntl.h: align open flags with Linux values 2026-06-30 13:43:44 +08:00
mmap !include/fcntl.h: align open flags with Linux values 2026-06-30 13:43:44 +08:00
mnemofs fs/mnemofs: Add mnemofs version 1 support. 2026-05-19 10:29:11 +08:00
mount drivers/: Multiple Drivers Are Registered With World Writable - Part 2 2026-07-15 15:27:28 +08:00
mqueue include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
nfs !include/fcntl.h: align open flags with Linux values 2026-06-30 13:43:44 +08:00
nxffs !include/fcntl.h: align open flags with Linux values 2026-06-30 13:43:44 +08:00
partition fs/partition: bound TXTABLE partition names 2026-07-06 07:51:46 +02:00
procfs fs/procfs: fix incorrect environ read for another task under CONFIG_ARCH_ADDRENV 2026-07-11 12:43:10 -03:00
romfs !include/fcntl.h: align open flags with Linux values 2026-06-30 13:43:44 +08:00
rpmsgfs !include/fcntl.h: align open flags with Linux values 2026-06-30 13:43:44 +08:00
semaphore fs/semaphore/open: fix the inode information update outside of lock 2026-01-28 10:03:06 +08:00
shm !include/fcntl.h: align open flags with Linux values 2026-06-30 13:43:44 +08:00
smartfs !include/fcntl.h: align open flags with Linux values 2026-06-30 13:43:44 +08:00
socket include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
spiffs !include/fcntl.h: align open flags with Linux values 2026-06-30 13:43:44 +08:00
tmpfs !include/fcntl.h: align open flags with Linux values 2026-06-30 13:43:44 +08:00
unionfs include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
userfs include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
v9fs include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
vfs drivers/eeprom: I2C EEPROM Read/Write Kernel Operations Cause a Device Crash 2026-07-20 10:02:21 +02: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 mm/mm_heap: use struct mm_heap_config_s to init the memory heap 2026-01-19 14:18:27 +08:00
fs_heap.h fs_heap:add fs_heap_mallinfo_task 2025-01-15 17:12:50 +08:00
fs_initialize.c fs: Move inotify.c from fs/notify/ to fs/vfs/ 2025-06-23 18:17:10 -03:00
Kconfig fs/Kconfig: add CONFIG_FS_PERMISSION option 2026-05-14 09:35:36 -03:00
Makefile Makefile: Remove make depend files by make distclean 2026-02-16 16:27:57 +01:00