nuttx/fs/vfs
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
..
CMakeLists.txt fs: Move inotify.c from fs/notify/ to fs/vfs/ 2025-06-23 18:17:10 -03:00
fs_chstat.c
fs_close.c fs: Move inotify.c from fs/notify/ to fs/vfs/ 2025-06-23 18:17:10 -03:00
fs_dir.c
fs_dup.c
fs_dup2.c fs/vfs: fix bug about lost dup oflags in dup2 2025-07-15 19:46:24 +08:00
fs_dup3.c
fs_epoll.c fs/epoll: add TLS cleanup handler to release epoll fd reference on thread exit 2025-12-31 08:49:04 -03:00
fs_eventfd.c fs/eventfd/timerfd: update sem next to avoid busy loop 2026-01-02 07:55:37 -03:00
fs_fchstat.c fs: Move inotify.c from fs/notify/ to fs/vfs/ 2025-06-23 18:17:10 -03:00
fs_fcntl.c
fs_fstat.c
fs_fstatfs.c
fs_fsync.c
fs_inotify.c fs: Move inotify.c from fs/notify/ to fs/vfs/ 2025-06-23 18:17:10 -03:00
fs_ioctl.c fs/vfs: Rename lock.h to vfs.h 2025-06-23 18:17:10 -03:00
fs_link.c
fs_lock.c fs/lock: Allow driver lock 2025-08-12 20:17:06 +08:00
fs_lseek.c
fs_mkdir.c fs: Move inotify.c from fs/notify/ to fs/vfs/ 2025-06-23 18:17:10 -03:00
fs_open.c fs/inode: use file_allocate,file_dup to avoid racecondition to allocate fd 2026-01-09 17:11:25 +08:00
fs_poll.c poll: fix covertify issue about out-of-bound access fds 2025-12-15 10:16:05 +08:00
fs_pread.c
fs_pseudofile.c fs: Move inotify.c from fs/notify/ to fs/vfs/ 2025-06-23 18:17:10 -03:00
fs_pwrite.c
fs_read.c fs: Move inotify.c from fs/notify/ to fs/vfs/ 2025-06-23 18:17:10 -03:00
fs_readlink.c
fs_rename.c fs/vfs/fs_rename: fix directory move operation. 2025-07-31 01:53:59 +08:00
fs_rmdir.c fs: Move inotify.c from fs/notify/ to fs/vfs/ 2025-06-23 18:17:10 -03:00
fs_select.c select: fix too small timeout will be counted as 0 2025-12-06 17:46:20 +08:00
fs_sendfile.c
fs_signalfd.c sched/signal: Fix nxsig_ismember() return value behavior 2025-11-25 10:02:52 +08:00
fs_stat.c fs/fs.h: Add register_driver_with_size function 2025-11-13 08:57:52 -03:00
fs_statfs.c
fs_symlink.c fs/vfs/symlink: fix the inode information update outside of lock 2026-01-28 10:03:06 +08:00
fs_syncfs.c
fs_timerfd.c fs/timerfd: implement TFD_TIMER_CANCEL_ON_SET to detect clock changes 2026-01-30 17:20:24 +08:00
fs_truncate.c fs: Move inotify.c from fs/notify/ to fs/vfs/ 2025-06-23 18:17:10 -03:00
fs_uio.c
fs_unlink.c fs: Move inotify.c from fs/notify/ to fs/vfs/ 2025-06-23 18:17:10 -03:00
fs_write.c bugfix/fs:write Bad buf addr should return EINVAL 2025-12-16 19:41:19 +08:00
Kconfig sched/signal: Add support for disabling all signal functions 2026-01-18 08:24:13 -03:00
Make.defs fs: Move inotify.c from fs/notify/ to fs/vfs/ 2025-06-23 18:17:10 -03:00
vfs.h fs: Move inotify.c from fs/notify/ to fs/vfs/ 2025-06-23 18:17:10 -03:00