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

xiaoxiang 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 53e8c008f5e fs: Fix the incorrect return value of the lseek interface.
53e8c008f5e is described below

commit 53e8c008f5e87e3f9db8da14174931706d5114be
Author: yukangzhi <[email protected]>
AuthorDate: Mon Aug 4 10:58:42 2025 +0800

    fs: Fix the incorrect return value of the lseek interface.
    
    The lseek interface needs to return the new offset in file.
    
    Signed-off-by: yukangzhi <[email protected]>
---
 fs/fat/fs_fat32.c   | 4 ++--
 fs/romfs/fs_romfs.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/fat/fs_fat32.c b/fs/fat/fs_fat32.c
index 22db4a97869..fc10b867a1a 100644
--- a/fs/fat/fs_fat32.c
+++ b/fs/fat/fs_fat32.c
@@ -1288,7 +1288,7 @@ static off_t fat_seek(FAR struct file *filep, off_t 
offset, int whence)
   if (position / fs->fs_hwsectorsize == filep->f_pos / fs->fs_hwsectorsize)
     {
       filep->f_pos = position;
-      return OK;
+      return position;
     }
 
   /* Make sure that the mount is still healthy */
@@ -1316,7 +1316,7 @@ static off_t fat_seek(FAR struct file *filep, off_t 
offset, int whence)
   filep->f_pos = position;
 
   nxmutex_unlock(&fs->fs_lock);
-  return OK;
+  return position;
 
 errout_with_lock:
   nxmutex_unlock(&fs->fs_lock);
diff --git a/fs/romfs/fs_romfs.c b/fs/romfs/fs_romfs.c
index fbe9ba87fcf..c97092016d3 100644
--- a/fs/romfs/fs_romfs.c
+++ b/fs/romfs/fs_romfs.c
@@ -579,7 +579,7 @@ static off_t romfs_seek(FAR struct file *filep, off_t 
offset, int whence)
 
 errout_with_lock:
   nxrmutex_unlock(&rm->rm_lock);
-  return ret;
+  return ret < 0 ? ret : position;
 }
 
 /****************************************************************************

Reply via email to