9
0
Fork 0

add (un)protect to saveenv

This commit is contained in:
Sascha Hauer 2007-09-12 17:12:16 +02:00
parent e354093310
commit 99978d467a
1 changed files with 16 additions and 0 deletions

View File

@ -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;
}