return st;
}
+ static Status ok(const std::string &message) {
+ Status st = {0, message};
+ return st;
+ }
+
static Status error(int value, const std::string &message) {
Status st = {value, message};
return st;
std::string &message() { return _msg; };
bool isOk() { return _status == 0; }
+ bool hasMessage() { return !_msg.empty(); }
};
Status error(int value, const std::string &message) {
return Status::error(message);
}
+Status ok(const std::string &message) {
+ return Status::ok(message);
+}
+
// END
const int kSectorSize = 512;
action = "Restoring";
} else if (original_ls.magic != kMagic) {
close(device_fd);
- return error(EINVAL, "No magic");
+ if (validating) {
+ // "No magic" during validating means that that there is simply no
+ // checkpoint to restore. This is not an error, we are simply not
+ // in the process of OS upgrade.
+ return ok("No magic (It is ok if OS Upgrade is not in progress or has been successful)");
+ } else {
+ // If there was "Magic" during validation, and now there is
+ // not, then we have reason to worry.
+ return error(EINVAL, "No magic");
+ }
}
-
LOG(INFO) << action << " " << original_ls.sequence << " log sectors" << "\n";
for (int sequence = original_ls.sequence; sequence >= 0 && status.isOk(); sequence--) {
LOG(ERROR) << "bow-restore error: " << status.message() << "\n";
return EXIT_FAILURE;
}
+ if (status.hasMessage()) {
+ LOG(INFO) << "bow-restore info: " << status.message() << "\n";
+ }
return EXIT_SUCCESS;
}