mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-02-18 17:43:54 +08:00
system reset improvements (#21844)
* reset improvements * cleanup Co-authored-by: Comma Device <device@comma.ai>
This commit is contained in:
@@ -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",
|
||||
};
|
||||
// best effort to wipe nvme
|
||||
std::system("sudo umount " NVME);
|
||||
std::system("yes | sudo mkfs.ext4 " NVME);
|
||||
|
||||
for (auto &cmd : cmds) {
|
||||
int ret = std::system(cmd);
|
||||
if (ret != 0) {
|
||||
body->setText("Reset failed. Reboot to try again.");
|
||||
rebootBtn->show();
|
||||
return;
|
||||
}
|
||||
// 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() {
|
||||
|
||||
Reference in New Issue
Block a user