diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2008-08-13 14:29:23 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2008-08-13 16:52:15 +0200 |
commit | 6f680b638b95a88b871a2db994b5aabdef59feb1 (patch) | |
tree | 1f11d3b1cadbc719e2108929512fab1ec8ff78ae /commands | |
parent | 3b4fece6d5d73e129921f577857b32807fe05753 (diff) | |
download | barebox-6f680b638b95a88b871a2db994b5aabdef59feb1.tar.gz barebox-6f680b638b95a88b871a2db994b5aabdef59feb1.tar.xz |
saveenv: close file
Close the file in saveenv before calling envfs_save and reopen it
afterwards. NAND Bad block aware devices allow opening a file only
once.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'commands')
-rw-r--r-- | commands/saveenv.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/commands/saveenv.c b/commands/saveenv.c index e0aef54ae1..fc1eee7d06 100644 --- a/commands/saveenv.c +++ b/commands/saveenv.c @@ -47,7 +47,7 @@ static int do_saveenv(cmd_tbl_t *cmdtp, int argc, char *argv[]) fd = open(filename, O_WRONLY | O_CREAT); if (fd < 0) { - printf("could not open %s: %s", filename, errno_str()); + printf("could not open %s: %s\n", filename, errno_str()); return 1; } @@ -62,10 +62,11 @@ static int do_saveenv(cmd_tbl_t *cmdtp, int argc, char *argv[]) ret = erase(fd, ~0, 0); + close(fd); + /* ENOSYS is no error here, many devices do not need it */ if (ret && errno != -ENOSYS) { printf("could not erase %s: %s\n", filename, errno_str()); - close(fd); return 1; } @@ -75,6 +76,8 @@ static int do_saveenv(cmd_tbl_t *cmdtp, int argc, char *argv[]) goto out; } + fd = open(filename, O_WRONLY | O_CREAT); + ret = protect(fd, ~0, 0, 1); /* ENOSYS is no error here, many devices do not need it */ |