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 2f0df1b5d1b53bce4a34a23f55dabe1218ad8c59
Author: Marco Casaroli <[email protected]>
AuthorDate: Mon Oct 19 17:38:52 2026 +0200

    fs/rpmsgfs: Honour CH_STAT_NOFOLLOW in the chstat request.
    
    The server called chmod(), chown() and utimens() for every chstat
    request, so lchown(), lchmod() and lutimens() on an rpmsgfs mount
    changed the file that the link points to.  Call lchmod(), lchown() and
    lutimens() when the client sets CH_STAT_NOFOLLOW.
    
    Assisted-by: Claude Code:claude-opus-5-5
    Signed-off-by: Marco Casaroli <[email protected]>
---
 fs/rpmsgfs/rpmsgfs_server.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/fs/rpmsgfs/rpmsgfs_server.c b/fs/rpmsgfs/rpmsgfs_server.c
index 5dfd5d2a78f..6d17db3e8c0 100644
--- a/fs/rpmsgfs/rpmsgfs_server.c
+++ b/fs/rpmsgfs/rpmsgfs_server.c
@@ -839,12 +839,14 @@ static int rpmsgfs_chstat_handler(FAR struct 
rpmsg_endpoint *ept,
                                   uint32_t src, FAR void *priv)
 {
   FAR struct rpmsgfs_chstat_s *msg = data;
+  bool nofollow = (msg->flags & CH_STAT_NOFOLLOW) != 0;
   struct timespec times[2];
   int ret = 0;
 
   if (msg->flags & CH_STAT_MODE)
     {
-      ret = chmod(msg->pathname, msg->buf.mode);
+      ret = nofollow ? lchmod(msg->pathname, msg->buf.mode) :
+                       chmod(msg->pathname, msg->buf.mode);
       if (ret < 0)
         {
           ret = -get_errno();
@@ -854,7 +856,8 @@ static int rpmsgfs_chstat_handler(FAR struct rpmsg_endpoint 
*ept,
 
   if (msg->flags & (CH_STAT_UID | CH_STAT_GID))
     {
-      ret = chown(msg->pathname, msg->buf.uid, msg->buf.gid);
+      ret = nofollow ? lchown(msg->pathname, msg->buf.uid, msg->buf.gid) :
+                       chown(msg->pathname, msg->buf.uid, msg->buf.gid);
       if (ret < 0)
         {
           ret = -get_errno();
@@ -886,7 +889,8 @@ static int rpmsgfs_chstat_handler(FAR struct rpmsg_endpoint 
*ept,
           times[1].tv_nsec = UTIME_OMIT;
         }
 
-      ret = utimens(msg->pathname, times);
+      ret = nofollow ? lutimens(msg->pathname, times) :
+                       utimens(msg->pathname, times);
       if (ret < 0)
         {
           ret = -get_errno();

Reply via email to