diff --git a/commands/saveenv.c b/commands/saveenv.c index e0aef54..fc1eee7 100644 --- a/commands/saveenv.c +++ b/commands/saveenv.c @@ -47,7 +47,7 @@ fd = open(filename, O_WRONLY | O_CREAT); if (fd < 0) { - printf("could not open %s: %s", filename, errno_str()); + printf("could not open %s: %s\n", filename, errno_str()); return 1; } @@ -62,10 +62,11 @@ 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; } @@ -75,6 +76,8 @@ goto out; } + fd = open(filename, O_WRONLY | O_CREAT); + ret = protect(fd, ~0, 0, 1); /* ENOSYS is no error here, many devices do not need it */