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 a4c9fdc4472 fs/mmap/fs_msync.c: don't flush changes if MAP_PRIVATE
a4c9fdc4472 is described below

commit a4c9fdc4472e13ac0c6aee8c3c301d07f71f11cc
Author: p-szafonimateusz <[email protected]>
AuthorDate: Thu Sep 25 12:57:39 2025 +0200

    fs/mmap/fs_msync.c: don't flush changes if MAP_PRIVATE
    
    changes should not be flushed to the underlying file if memory mapping is
    marked as MAP_PRIVATE.
    
    Signed-off-by: p-szafonimateusz <[email protected]>
---
 fs/mmap/fs_msync.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/fs/mmap/fs_msync.c b/fs/mmap/fs_msync.c
index 823770fe2e2..93d7f675088 100644
--- a/fs/mmap/fs_msync.c
+++ b/fs/mmap/fs_msync.c
@@ -78,13 +78,19 @@ int msync(FAR void *start, size_t length, int flags)
       goto out;
     }
 
-  if (entry->msync == NULL)
+  /* Don't synchronize a file if this is private mapping or there is
+   * no msync handler for this file.
+   */
+
+  if (entry->msync && (entry->flags & MAP_PRIVATE) == 0)
+    {
+      ret = entry->msync(entry, start, length, flags);
+    }
+  else
     {
       ret = OK;
-      goto out;
     }
 
-  ret = entry->msync(entry, start, length, flags);
 out:
   mm_map_unlock();
   if (ret < 0)

Reply via email to