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. 28
      selfdrive/ui/qt/setup/reset.cc

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

Loading…
Cancel
Save