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


The following commit(s) were added to refs/heads/master by this push:
     new a3122603342 vfs/link: update target ctime on link creation.
a3122603342 is described below

commit a31226033424a87086847a5593182dc3691a5f18
Author: v-liuchenxu3 <[email protected]>
AuthorDate: Mon Sep 29 10:22:12 2025 +0800

    vfs/link: update target ctime on link creation.
    
    link() on the pseudo file system increments the link count of the
    target inode, which is a status change, but leaves its st_ctime
    unchanged. POSIX requires link() to mark st_ctime of the file for
    update. Set it when CONFIG_PSEUDOFS_ATTRIBUTES is enabled.
    
    Signed-off-by: v-liuchenxu3 <[email protected]>
---
 fs/vfs/fs_link.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/vfs/fs_link.c b/fs/vfs/fs_link.c
index c142040af7e..b7e41fc976b 100644
--- a/fs/vfs/fs_link.c
+++ b/fs/vfs/fs_link.c
@@ -213,6 +213,9 @@ int link(FAR const char *path1, FAR const char *path2)
           INODE_SET_HARDLINK(newinode);
           newinode->i_private = target;
           atomic_add(&target->i_crefs, INODE_NLINK_INC);
+#ifdef CONFIG_PSEUDOFS_ATTRIBUTES
+          clock_gettime(CLOCK_REALTIME, &target->i_ctime);
+#endif
         }
 
       inode_unlock();

Reply via email to