From 3173b1fb08fa9f2a8b197b676daa773607e475d9 Mon Sep 17 00:00:00 2001 From: Juergen Beisert Date: Wed, 18 Nov 2009 16:00:54 +0100 Subject: 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 Signed-off-by: Sascha Hauer --- commands/saveenv.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'commands/saveenv.c') diff --git a/commands/saveenv.c b/commands/saveenv.c index d28b4d338c..fadd6747f6 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"); -- cgit v1.2.3