diff options
author | Sascha Hauer <sha@octopus.labnet.pengutronix.de> | 2007-09-12 17:12:16 +0200 |
---|---|---|
committer | Sascha Hauer <sha@octopus.labnet.pengutronix.de> | 2007-09-12 17:12:16 +0200 |
commit | 99978d467aaad44b7d00062caf45a2fbac00e2cd (patch) | |
tree | 7651765203333b13ce695601a96c7ac50df239c5 /commands | |
parent | e3540933100760b146ed896149c83c9fcf4ee0f1 (diff) | |
download | barebox-99978d467aaad44b7d00062caf45a2fbac00e2cd.tar.gz barebox-99978d467aaad44b7d00062caf45a2fbac00e2cd.tar.xz |
add (un)protect to saveenv
Diffstat (limited to 'commands')
-rw-r--r-- | commands/environment.c | 16 |
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; } |