system reset improvements (#21844)

* reset improvements

* cleanup

Co-authored-by: Comma Device <device@comma.ai>
old-commit-hash: 4f9e568019
commatwo_master
Adeeb Shihadeh 4 years ago committed by GitHub
parent 8172eb9e7f
commit b3f073a21b
  1. 30
      selfdrive/ui/qt/setup/reset.cc

@ -12,22 +12,22 @@
#define USERDATA "/dev/disk/by-partlabel/userdata"
void Reset::doReset() {
std::vector<const char*> cmds = {
"sudo umount " NVME " || true",
"yes | sudo mkfs.ext4 " NVME " || true",
"sudo umount " USERDATA " || true",
"yes | sudo mkfs.ext4 " USERDATA,
"sudo reboot",
};
for (auto &cmd : cmds) {
int ret = std::system(cmd);
if (ret != 0) {
body->setText("Reset failed. Reboot to try again.");
rebootBtn->show();
return;
}
// best effort to wipe nvme
std::system("sudo umount " NVME);
std::system("yes | sudo mkfs.ext4 " NVME);
// we handle two cases here
// * user-prompted factory reset
// * recovering from a corrupt userdata by formatting
int rm = std::system("sudo rm -rf /data/*");
std::system("sudo umount " USERDATA);
int fmt = std::system("yes | sudo mkfs.ext4 " USERDATA);
if (rm == 0 || fmt == 0) {
std::system("sudo reboot");
}
body->setText("Reset failed. Reboot to try again.");
rebootBtn->show();
}
void Reset::confirm() {

Loading…
Cancel
Save