nuttx/fs
dongjiuzhu1 3c486b98dd fs/timerfd: implement TFD_TIMER_CANCEL_ON_SET to detect clock changes
Implement Linux-compatible TFD_TIMER_CANCEL_ON_SET flag for timerfd to
allow applications to detect discontinuous changes to CLOCK_REALTIME.

Background:
According to Linux timerfd_create(2) man page, when a timerfd is created
with CLOCK_REALTIME and TFD_TIMER_CANCEL_ON_SET flag is specified, the
read() operation should fail with ECANCELED if the real-time clock
undergoes a discontinuous change. This allows applications to detect
and respond to system time changes.

Implementation:
1. Add clock notifier infrastructure (clock_notifier.h/c) to notify
   interested parties when system time changes
2. Implement TFD_TIMER_CANCEL_ON_SET flag support in timerfd
3. Register timerfd with clock notifier when flag is set
4. Cancel timer and return ECANCELED when clock change is detected
5. Notify clock changes in:
   - clock_settime()
   - clock_initialize()
   - clock_timekeeping_set_wall_time()
   - rpmsg_rtc time synchronization

Changes include:
- New files: include/nuttx/clock_notifier.h, sched/clock/clock_notifier.c
- Modified: fs/vfs/fs_timerfd.c to handle TFD_TIMER_CANCEL_ON_SET
- Modified: clock subsystem to call notifier chain on time changes
- Modified: rpmsg_rtc to notify time changes during sync

Use case example:
Applications using timerfd with absolute time can now detect when
system time is adjusted (e.g., NTP sync, manual time change) and
take appropriate action such as recalculating timeouts or updating
scheduled events.

Reference: https://man7.org/linux/man-pages/man2/timerfd_create.2.html

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2026-01-30 17:20:24 +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/mtd/proxy:Replaced heap allocation of temporary device names 2026-01-14 09:25:08 +08:00
event fs/event/open: fix the inode information update outside of lock 2026-01-28 10:03:06 +08:00
fat fs/fat: add support for FIOC_FILEPATH ioctl 2026-01-27 10:37:37 +08:00
hostfs style: fix spelling in code comments and strings 2025-05-23 10:48:41 +08:00
inode fs/inode: use file_allocate,file_dup to avoid racecondition to allocate fd 2026-01-09 17:11:25 +08:00
littlefs fs: add fs dump in ROMFS/LITTLEFS 2026-01-19 16:40:57 +08:00
mmap fs/mmap/Kconfig: fix reference to non-existent readme 2025-10-11 17:07:51 -04:00
mnemofs style: fix spelling in code comments and strings 2025-05-23 10:48:41 +08:00
mount fs: Move inotify.c from fs/notify/ to fs/vfs/ 2025-06-23 18:17:10 -03:00
mqueue fs/inode: use file_allocate,file_dup to avoid racecondition to allocate fd 2026-01-09 17:11:25 +08:00
nfs style: fix spelling in code comments and strings 2025-05-23 10:48:41 +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 sched/spinlock: Update the information of critmon in docu. 2026-01-27 21:59:14 +08:00
romfs fs: Fix the incorrect return value of the lseek interface. 2026-01-22 17:15:16 +08:00
rpmsgfs sched/sleep: replace all Signal-based sleep implement to Scheduled sleep 2025-10-17 14:05:02 +08:00
semaphore fs/semaphore/open: fix the inode information update outside of lock 2026-01-28 10:03:06 +08:00
shm fs/inode: use file_allocate,file_dup to avoid racecondition to allocate fd 2026-01-09 17:11:25 +08:00
smartfs fs/smartfs: Fix a fatal bug about sector writing after seek 2025-06-13 20:42:36 +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 tmpfs:fix memoryleak of tmpfs_opendir 2025-12-22 11:02:10 -05:00
unionfs style: fix spelling in code comments and strings 2025-05-23 10:48:41 +08:00
userfs fs/userfs: keep lock while reading iobuffer 2026-01-11 09:01:45 -03:00
v9fs refactor: fix spelling in private field names 2025-05-24 09:44:22 -03:00
vfs fs/timerfd: implement TFD_TIMER_CANCEL_ON_SET to detect clock changes 2026-01-30 17:20:24 +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 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: Move inotify.c from fs/notify/ to fs/vfs/ 2025-06-23 18:17:10 -03:00
Makefile fs: Move inotify.c from fs/notify/ to fs/vfs/ 2025-06-23 18:17:10 -03:00