This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 9427c4f43e63c66a060138e034e3c7cce894e129 Author: v-liuchenxu3 <[email protected]> AuthorDate: Thu Nov 12 14:56:36 2026 +0800 fs/inode: update the parent and link target times on unlink inode_unlink() removes a node from its pseudo file system directory without touching the directory's st_mtime and st_ctime, and removing a hard link leaves the st_ctime of the target unchanged although its link count drops. POSIX marks the directory times for update when an entry is removed, and the file's st_ctime when a link to it is. Signed-off-by: v-liuchenxu3 <[email protected]> Signed-off-by: jingfei <[email protected]> --- fs/inode/fs_inoderemove.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/fs/inode/fs_inoderemove.c b/fs/inode/fs_inoderemove.c index 098039fb2be..704c18f5527 100644 --- a/fs/inode/fs_inoderemove.c +++ b/fs/inode/fs_inoderemove.c @@ -123,6 +123,14 @@ static FAR struct inode *inode_unlink(FAR const char *path) inode->i_peer = NULL; inode->i_parent = NULL; atomic_sub(&inode->i_crefs, 1); +#ifdef CONFIG_PSEUDOFS_ATTRIBUTES + if (desc.parent != NULL) + { + clock_gettime(CLOCK_REALTIME, &desc.parent->i_ctime); + desc.parent->i_mtime = desc.parent->i_ctime; + } +#endif + #ifdef CONFIG_FS_LINKS if (INODE_IS_HARDLINK(inode)) { @@ -130,6 +138,12 @@ static FAR struct inode *inode_unlink(FAR const char *path) DEBUGASSERT(inode->i_private != NULL); target = inode->i_private; +# ifdef CONFIG_PSEUDOFS_ATTRIBUTES + /* The link count of the target changes */ + + clock_gettime(CLOCK_REALTIME, &target->i_ctime); +# endif + atomic_sub(&target->i_crefs, INODE_NLINK_INC); if (atomic_read(&target->i_crefs) == 0) {
