From 57130c45f85d68b4420e4dccb9c972c7f8946031 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Wed, 10 May 2017 12:11:21 -0700 Subject: [PATCH] recovery: Skip "/" in setup_install_mounts(). We don't want to do anything for "/" when preparing for an install. Bug: 36686818 Test: adb sideload on angler/marlin respectively. Change-Id: Id854dd0a743a0e163a8f13baf2514105091ddc67 --- roots.cpp | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/roots.cpp b/roots.cpp index 727736b7..9b427025 100644 --- a/roots.cpp +++ b/roots.cpp @@ -260,26 +260,29 @@ int format_volume(const char* volume) { } int setup_install_mounts() { - if (fstab == NULL) { - LOG(ERROR) << "can't set up install mounts: no fstab loaded"; + if (fstab == nullptr) { + LOG(ERROR) << "can't set up install mounts: no fstab loaded"; + return -1; + } + for (int i = 0; i < fstab->num_entries; ++i) { + const Volume* v = fstab->recs + i; + + // We don't want to do anything with "/". + if (strcmp(v->mount_point, "/") == 0) { + continue; + } + + if (strcmp(v->mount_point, "/tmp") == 0 || strcmp(v->mount_point, "/cache") == 0) { + if (ensure_path_mounted(v->mount_point) != 0) { + LOG(ERROR) << "failed to mount " << v->mount_point; return -1; + } + } else { + if (ensure_path_unmounted(v->mount_point) != 0) { + LOG(ERROR) << "failed to unmount " << v->mount_point; + return -1; + } } - for (int i = 0; i < fstab->num_entries; ++i) { - Volume* v = fstab->recs + i; - - if (strcmp(v->mount_point, "/tmp") == 0 || - strcmp(v->mount_point, "/cache") == 0) { - if (ensure_path_mounted(v->mount_point) != 0) { - LOG(ERROR) << "failed to mount " << v->mount_point; - return -1; - } - - } else { - if (ensure_path_unmounted(v->mount_point) != 0) { - LOG(ERROR) << "failed to unmount " << v->mount_point; - return -1; - } - } - } - return 0; + } + return 0; }