halyssonJr commented on code in PR #3642:
URL: https://github.com/apache/nuttx-apps/pull/3642#discussion_r3637979487


##########
system/nxpkg/pkg_store.c:
##########
@@ -409,6 +545,22 @@ int pkg_store_write_text_atomic(FAR const char *path, FAR 
const char *text)
       return ret;
     }
 
+  /* Force the write through to disk before renaming.  nxpkg writes
+   * several small, unrelated files back-to-back during install (per-
+   * package txn state, then the shared installed-packages database);
+   * without an explicit sync here, the FAT driver's single shared
+   * sector cache can still hold a not-yet-committed buffer for this
+   * file when the very next atomic write starts touching a different
+   * file, corrupting one or both.
+   */
+
+  if (fsync(fd) < 0)

Review Comment:
   THe same here.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to