You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2016/07/19 23:22:00 UTC

[2/4] incubator-mynewt-core git commit: Don't automatically truncate files in fsutil_write_file()

Don't automatically truncate files in fsutil_write_file()

Prior to this change, fsutil_write_file() opened files for writing with the
truncate flag.  This caused all writes to delete the old version of the file,
create a new file and then update the file with the newly written data.
This caused 3 times the records written to the flash device (ie, the delete
record for the old file, the creation record for the new file, and the update
for the lastblock when the data was actually written).  Now only a new block is
generated and written to flash (with a higher sequence number if appropriate).
fsutil_write_file() is used extensively in the boot upgrade process.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/76193b94
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/76193b94
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/76193b94

Branch: refs/heads/develop
Commit: 76193b94adf4aeb3f40b2fb6e1898575629c4147
Parents: 84b4302
Author: Peter Snyder <gi...@peterfs.com>
Authored: Mon Jul 18 21:54:40 2016 -0700
Committer: Peter Snyder <gi...@peterfs.com>
Committed: Mon Jul 18 21:54:40 2016 -0700

----------------------------------------------------------------------
 fs/fs/src/fsutil.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/76193b94/fs/fs/src/fsutil.c
----------------------------------------------------------------------
diff --git a/fs/fs/src/fsutil.c b/fs/fs/src/fsutil.c
index 1754130..ad3a063 100644
--- a/fs/fs/src/fsutil.c
+++ b/fs/fs/src/fsutil.c
@@ -49,7 +49,7 @@ fsutil_write_file(const char *path, const void *data, uint32_t len)
     struct fs_file *file;
     int rc;
 
-    rc = fs_open(path, FS_ACCESS_WRITE | FS_ACCESS_TRUNCATE, &file);
+    rc = fs_open(path, FS_ACCESS_WRITE, &file);
     if (rc != 0) {
         goto done;
     }