summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--commands/environment.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/commands/environment.c b/commands/environment.c
index 9fc9f4e1d5..d4f80c6465 100644
--- a/commands/environment.c
+++ b/commands/environment.c
@@ -138,6 +138,14 @@ int do_saveenv(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
return 1;
}
+ ret = protect(fd, ~0, 0, 0);
+ /* ENOSYS is no error here, many devices do not need it */
+ if (ret && errno != -ENOSYS) {
+ printf("could not unprotect %s: %s\n", filename, errno_str());
+ close(fd);
+ return 1;
+ }
+
ret = erase(fd, ~0, 0);
/* ENOSYS is no error here, many devices do not need it */
@@ -151,6 +159,14 @@ int do_saveenv(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
if (ret)
printf("saveenv failed\n");
+ ret = protect(fd, ~0, 0, 1);
+ /* ENOSYS is no error here, many devices do not need it */
+ if (ret && errno != -ENOSYS) {
+ printf("could not protect %s: %s\n", filename, errno_str());
+ close(fd);
+ return 1;
+ }
+
close(fd);
return ret;
}