This is an automated email from the ASF dual-hosted git repository.

GUIDINGLI pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit b7a4dc0aa0534cf72d246b243ce30124d031ece7
Author: guohao15 <[email protected]>
AuthorDate: Thu Nov 12 12:49:53 2026 +0800

    fs/rpmsgfs: carry 64-bit lseek offsets
    
    struct rpmsgfs_lseek_s carries the offset as int32_t, and the server
    returns the new position in header.result, which is int32_t as well.
    With CONFIG_FS_LARGEFILE an offset at or beyond 2 GB is truncated on
    the way to the server, and a position at or beyond 2 GB is truncated
    on the way back.
    
    Widen the offset to int64_t and let the server return the new
    position in it, leaving header.result for the status.  This changes
    the layout of the lseek message, so the client and the server must be
    updated together.
    
    Signed-off-by: guohao15 <[email protected]>
    Signed-off-by: jingfei <[email protected]>
---
 fs/rpmsgfs/rpmsgfs.c        | 12 ++++++------
 fs/rpmsgfs/rpmsgfs.h        |  2 +-
 fs/rpmsgfs/rpmsgfs_client.c |  8 ++++++--
 fs/rpmsgfs/rpmsgfs_server.c |  5 ++++-
 4 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/fs/rpmsgfs/rpmsgfs.c b/fs/rpmsgfs/rpmsgfs.c
index 4e0bb56e68c..b0902b43ca7 100644
--- a/fs/rpmsgfs/rpmsgfs.c
+++ b/fs/rpmsgfs/rpmsgfs.c
@@ -328,15 +328,15 @@ static int rpmsgfs_open(FAR struct file *filep, FAR const 
char *relpath,
 
   if ((oflags & O_APPEND) && (oflags & O_ACCMODE) != O_RDONLY)
     {
-      ret = rpmsgfs_client_lseek(fs->handle, hf->fd, 0, SEEK_END);
-      if (ret >= 0)
-        {
-          filep->f_pos = ret;
-        }
-      else
+      off_t pos = rpmsgfs_client_lseek(fs->handle, hf->fd, 0, SEEK_END);
+
+      if (pos < 0)
         {
+          ret = pos;
           goto errout_with_fd;
         }
+
+      filep->f_pos = pos;
     }
 
   /* Attach the private date to the struct file instance */
diff --git a/fs/rpmsgfs/rpmsgfs.h b/fs/rpmsgfs/rpmsgfs.h
index 3539ce61dd2..f285e219985 100644
--- a/fs/rpmsgfs/rpmsgfs.h
+++ b/fs/rpmsgfs/rpmsgfs.h
@@ -106,7 +106,7 @@ begin_packed_struct struct rpmsgfs_lseek_s
   struct rpmsgfs_header_s header;
   int32_t                 fd;
   int32_t                 whence;
-  int32_t                 offset;
+  int64_t                 offset;
 } end_packed_struct;
 
 begin_packed_struct struct rpmsgfs_ioctl_s
diff --git a/fs/rpmsgfs/rpmsgfs_client.c b/fs/rpmsgfs/rpmsgfs_client.c
index 0cbe56f4af1..bf6f43f4924 100644
--- a/fs/rpmsgfs/rpmsgfs_client.c
+++ b/fs/rpmsgfs/rpmsgfs_client.c
@@ -649,8 +649,12 @@ off_t rpmsgfs_client_lseek(FAR void *handle, int fd,
     .whence = whence,
   };
 
-  return rpmsgfs_send_recv(handle, RPMSGFS_LSEEK, true,
-           (struct rpmsgfs_header_s *)&msg, sizeof(msg), NULL);
+  off_t ret;
+
+  ret = rpmsgfs_send_recv(handle, RPMSGFS_LSEEK, true,
+                          (struct rpmsgfs_header_s *)&msg, sizeof(msg),
+                          NULL);
+  return ret < 0 ? ret : msg.offset;
 }
 
 int rpmsgfs_client_ioctl(FAR void *handle, int fd,
diff --git a/fs/rpmsgfs/rpmsgfs_server.c b/fs/rpmsgfs/rpmsgfs_server.c
index 5f4af5e7ad7..c2f1a6bea93 100644
--- a/fs/rpmsgfs/rpmsgfs_server.c
+++ b/fs/rpmsgfs/rpmsgfs_server.c
@@ -528,7 +528,10 @@ static int rpmsgfs_lseek_handler(FAR struct rpmsg_endpoint 
*ept,
   filep = rpmsgfs_get_file(priv, msg->fd);
   if (filep != NULL)
     {
-      ret = file_seek(filep, msg->offset, msg->whence);
+      /* header.result is 32 bits, so return the position in offset */
+
+      msg->offset = file_seek(filep, msg->offset, msg->whence);
+      ret = msg->offset < 0 ? msg->offset : 0;
     }
 
   msg->header.result = ret;

Reply via email to