Skip to content

Commit

Permalink
Merge "fs_mgr: deprecate check for ro.build.system_root_image"
Browse files Browse the repository at this point in the history
  • Loading branch information
Treehugger Robot authored and Gerrit Code Review committed Oct 11, 2018
2 parents 86554e9 + d556c41 commit 8ef3fe1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 26 deletions.
4 changes: 1 addition & 3 deletions fs_mgr/fs_mgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1546,16 +1546,14 @@ bool fs_mgr_update_verity_state(std::function<fs_mgr_verity_state_callback> call

DeviceMapper& dm = DeviceMapper::Instance();

bool system_root = android::base::GetProperty("ro.build.system_root_image", "") == "true";

for (int i = 0; i < fstab->num_entries; i++) {
auto fsrec = &fstab->recs[i];
if (!fs_mgr_is_verified(fsrec) && !fs_mgr_is_avb(fsrec)) {
continue;
}

std::string mount_point;
if (system_root && !strcmp(fsrec->mount_point, "/")) {
if (!strcmp(fsrec->mount_point, "/")) {
// In AVB, the dm device name is vroot instead of system.
mount_point = fs_mgr_is_avb(fsrec) ? "vroot" : "system";
} else {
Expand Down
27 changes: 4 additions & 23 deletions fs_mgr/fs_mgr_overlayfs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,25 +167,9 @@ std::string fs_mgr_get_overlayfs_options(const std::string& mount_point) {
candidate + kUpperName + ",workdir=" + candidate + kWorkName;
}

bool fs_mgr_system_root_image(const fstab* fstab) {
if (!fstab) { // can not happen?
// This will return empty on init first_stage_mount,
// hence why we prefer checking the fstab instead.
return android::base::GetBoolProperty("ro.build.system_root_image", false);
}
for (auto i = 0; i < fstab->num_entries; i++) {
const auto fsrec = &fstab->recs[i];
auto fsrec_mount_point = fsrec->mount_point;
if (!fsrec_mount_point) continue;
if ("/system"s == fsrec_mount_point) return false;
}
return true;
}

const char* fs_mgr_mount_point(const fstab* fstab, const char* mount_point) {
const char* fs_mgr_mount_point(const char* mount_point) {
if (!mount_point) return mount_point;
if ("/"s != mount_point) return mount_point;
if (!fs_mgr_system_root_image(fstab)) return mount_point;
return "/system";
}

Expand Down Expand Up @@ -533,7 +517,7 @@ std::vector<std::string> fs_mgr_candidate_list(const fstab* fstab,
for (auto i = 0; i < fstab->num_entries; i++) {
const auto fsrec = &fstab->recs[i];
if (!fs_mgr_wants_overlayfs(fsrec)) continue;
std::string new_mount_point(fs_mgr_mount_point(fstab, fsrec->mount_point));
std::string new_mount_point(fs_mgr_mount_point(fsrec->mount_point));
if (mount_point && (new_mount_point != mount_point)) continue;
if (std::find(verity.begin(), verity.end(), android::base::Basename(new_mount_point)) !=
verity.end()) {
Expand Down Expand Up @@ -776,7 +760,7 @@ bool fs_mgr_overlayfs_setup(const char* backing, const char* mount_point, bool*
std::unique_ptr<fstab, decltype(&fs_mgr_free_fstab)> fstab(fs_mgr_read_fstab_default(),
fs_mgr_free_fstab);
if (!fstab) return ret;
auto mounts = fs_mgr_candidate_list(fstab.get(), fs_mgr_mount_point(fstab.get(), mount_point));
auto mounts = fs_mgr_candidate_list(fstab.get(), fs_mgr_mount_point(mount_point));
if (mounts.empty()) return ret;

std::string dir;
Expand Down Expand Up @@ -811,10 +795,7 @@ bool fs_mgr_overlayfs_setup(const char* backing, const char* mount_point, bool*
// If something is altered, set *change.
bool fs_mgr_overlayfs_teardown(const char* mount_point, bool* change) {
if (change) *change = false;
mount_point = fs_mgr_mount_point(std::unique_ptr<fstab, decltype(&fs_mgr_free_fstab)>(
fs_mgr_read_fstab_default(), fs_mgr_free_fstab)
.get(),
mount_point);
mount_point = fs_mgr_mount_point(mount_point);
auto ret = true;
for (const auto& overlay_mount_point : kOverlayMountPoints) {
ret &= fs_mgr_overlayfs_teardown_one(overlay_mount_point, mount_point ?: "", change);
Expand Down

0 comments on commit 8ef3fe1

Please sign in to comment.