[HACK]fs_mgr+init: Format via recovery if encryptable /data is wiped
If the encryptable partition is wiped (4KB worth of 0 or 0xff), then reboot into recovery to format /data+/cache This is while waiting for the Mac OS support to format f2fs. The flashstation running on Mac OS will currently just erase userdata and not format it with f2fs. Bug: 15720406 Bug: 15747366 Change-Id: Ib7cca3e1701483a09573457a835750f34da71ee0
This commit is contained in:
parent
f22b745294
commit
cee206880e
3 changed files with 34 additions and 4 deletions
|
|
@ -387,10 +387,12 @@ int fs_mgr_mount_all(struct fstab *fstab)
|
|||
|
||||
/* mount(2) returned an error, check if it's encryptable and deal with it */
|
||||
if (mret && mount_errno != EBUSY && mount_errno != EACCES &&
|
||||
fs_mgr_is_encryptable(&fstab->recs[i])) {
|
||||
if (partition_wiped(fstab->recs[i].blk_device)) {
|
||||
ERROR("%s(): Encryptable wiped partition %s. Recommend wiping via recovery. Fail for now.\n", __func__, fstab->recs[i].mount_point);
|
||||
++error_count;
|
||||
fs_mgr_is_encryptable(&fstab->recs[attempted_idx])) {
|
||||
if(partition_wiped(fstab->recs[attempted_idx].blk_device)) {
|
||||
ERROR("%s(): %s is wiped and %s %s is encryptable. Suggest recovery...\n", __func__,
|
||||
fstab->recs[attempted_idx].blk_device, fstab->recs[attempted_idx].mount_point,
|
||||
fstab->recs[attempted_idx].fs_type);
|
||||
encryptable = FS_MGR_MNTALL_DEV_NEEDS_RECOVERY;
|
||||
continue;
|
||||
} else {
|
||||
/* Need to mount a tmpfs at this mountpoint for now, and set
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ struct fstab_rec {
|
|||
struct fstab *fs_mgr_read_fstab(const char *fstab_path);
|
||||
void fs_mgr_free_fstab(struct fstab *fstab);
|
||||
|
||||
#define FS_MGR_MNTALL_DEV_NEEDS_RECOVERY 3
|
||||
#define FS_MGR_MNTALL_DEV_NEEDS_ENCRYPTION 2
|
||||
#define FS_MGR_MNTALL_DEV_MIGHT_BE_ENCRYPTED 1
|
||||
#define FS_MGR_MNTALL_DEV_NOT_ENCRYPTED 0
|
||||
|
|
|
|||
|
|
@ -474,6 +474,26 @@ exit_success:
|
|||
|
||||
}
|
||||
|
||||
static int wipe_data_via_recovery()
|
||||
{
|
||||
mkdir("/cache/recovery", 0700);
|
||||
int fd = open("/cache/recovery/command", O_RDWR|O_CREAT|O_TRUNC, 0600);
|
||||
if (fd >= 0) {
|
||||
write(fd, "--wipe_data", strlen("--wipe_data") + 1);
|
||||
close(fd);
|
||||
} else {
|
||||
ERROR("could not open /cache/recovery/command\n");
|
||||
return -1;
|
||||
}
|
||||
android_reboot(ANDROID_RB_RESTART2, 0, "recovery");
|
||||
while (1) { pause(); } // never reached
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* This function might request a reboot, in which case it will
|
||||
* not return.
|
||||
*/
|
||||
int do_mount_all(int nargs, char **args)
|
||||
{
|
||||
pid_t pid;
|
||||
|
|
@ -529,6 +549,13 @@ int do_mount_all(int nargs, char **args)
|
|||
* that action.
|
||||
*/
|
||||
action_for_each_trigger("nonencrypted", action_add_queue_tail);
|
||||
} else if (ret == FS_MGR_MNTALL_DEV_NEEDS_RECOVERY) {
|
||||
/* Setup a wipe via recovery, and reboot into recovery */
|
||||
ERROR("fs_mgr_mount_all suggested recovery, so wiping data via recovery.\n");
|
||||
ret = wipe_data_via_recovery();
|
||||
/* If reboot worked, there is no return. */
|
||||
} else if (ret > 0) {
|
||||
ERROR("fs_mgr_mount_all returned unexpected error %d\n", ret);
|
||||
}
|
||||
/* else ... < 0: error */
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue