summaryrefslogtreecommitdiffstats
path: root/commands/saveenv.c
diff options
context:
space:
mode:
authorJuergen Beisert <jbe@pengutronix.de>2009-11-18 16:00:54 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2009-11-19 09:42:38 +0100
commit3173b1fb08fa9f2a8b197b676daa773607e475d9 (patch)
tree8ed988d008e234b40d1ee0fc232763c349b7a59e /commands/saveenv.c
parentb00a6d357e04dc04b728bb58daeeafa1ee718d09 (diff)
downloadbarebox-3173b1fb08fa9f2a8b197b676daa773607e475d9.tar.gz
Enable 'saveenv' for non eraseable media
'close()' clobbers the 'errno' value from the erase command. So it must be done *after* the check for ENOSYS to ingnore it correctly. Signed-off by: Juergen Beisert <j.beisert@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'commands/saveenv.c')
-rw-r--r--commands/saveenv.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/commands/saveenv.c b/commands/saveenv.c
index d28b4d3..fadd674 100644
--- a/commands/saveenv.c
+++ b/commands/saveenv.c
@@ -62,14 +62,15 @@ 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;
}
+ close(fd);
+
ret = envfs_save(filename, dirname);
if (ret) {
printf("saveenv failed\n");