fs_mgr: overlayfs: pre-emptive filesystem setup
If we just disabled verity, take the step to setup the backing storage for overlayfs. Test: adb-remount-test.sh Bug: 130131892 Change-Id: Ic56569eaf363e4417a0ce5df11ee5480a07b8b03 Merged-In: Ic56569eaf363e4417a0ce5df11ee5480a07b8b03
This commit is contained in:
parent
b6d9fbddc6
commit
0dff785221
|
@ -90,7 +90,7 @@ std::vector<std::string> fs_mgr_overlayfs_required_devices(Fstab*) {
|
|||
return {};
|
||||
}
|
||||
|
||||
bool fs_mgr_overlayfs_setup(const char*, const char*, bool* change) {
|
||||
bool fs_mgr_overlayfs_setup(const char*, const char*, bool* change, bool) {
|
||||
if (change) *change = false;
|
||||
return false;
|
||||
}
|
||||
|
@ -873,7 +873,8 @@ std::vector<std::string> fs_mgr_overlayfs_required_devices(Fstab* fstab) {
|
|||
|
||||
// Returns false if setup not permitted, errno set to last error.
|
||||
// If something is altered, set *change.
|
||||
bool fs_mgr_overlayfs_setup(const char* backing, const char* mount_point, bool* change) {
|
||||
bool fs_mgr_overlayfs_setup(const char* backing, const char* mount_point, bool* change,
|
||||
bool force) {
|
||||
if (change) *change = false;
|
||||
auto ret = false;
|
||||
if (fs_mgr_overlayfs_valid() == OverlayfsValidResult::kNotSupported) return ret;
|
||||
|
@ -897,7 +898,7 @@ bool fs_mgr_overlayfs_setup(const char* backing, const char* mount_point, bool*
|
|||
continue;
|
||||
}
|
||||
save_errno = errno;
|
||||
auto verity_enabled = fs_mgr_is_verity_enabled(*it);
|
||||
auto verity_enabled = !force && fs_mgr_is_verity_enabled(*it);
|
||||
if (errno == ENOENT || errno == ENXIO) errno = save_errno;
|
||||
if (verity_enabled) {
|
||||
it = candidates.erase(it);
|
||||
|
|
|
@ -250,6 +250,7 @@ int main(int argc, char* argv[]) {
|
|||
// Check verity and optionally setup overlayfs backing.
|
||||
auto reboot_later = false;
|
||||
auto uses_overlayfs = fs_mgr_overlayfs_valid() != OverlayfsValidResult::kNotSupported;
|
||||
auto just_disabled_verity = false;
|
||||
for (auto it = partitions.begin(); it != partitions.end();) {
|
||||
auto& entry = *it;
|
||||
auto& mount_point = entry.mount_point;
|
||||
|
@ -262,7 +263,8 @@ int main(int argc, char* argv[]) {
|
|||
false);
|
||||
avb_ops_user_free(ops);
|
||||
if (ret) {
|
||||
LOG(WARNING) << "Disable verity for " << mount_point;
|
||||
LOG(WARNING) << "Disabling verity for " << mount_point;
|
||||
just_disabled_verity = true;
|
||||
reboot_later = can_reboot;
|
||||
if (reboot_later) {
|
||||
// w/o overlayfs available, also check for dedupe
|
||||
|
@ -275,7 +277,8 @@ int main(int argc, char* argv[]) {
|
|||
} else if (fs_mgr_set_blk_ro(entry.blk_device, false)) {
|
||||
fec::io fh(entry.blk_device.c_str(), O_RDWR);
|
||||
if (fh && fh.set_verity_status(false)) {
|
||||
LOG(WARNING) << "Disable verity for " << mount_point;
|
||||
LOG(WARNING) << "Disabling verity for " << mount_point;
|
||||
just_disabled_verity = true;
|
||||
reboot_later = can_reboot;
|
||||
if (reboot_later && !uses_overlayfs) {
|
||||
++it;
|
||||
|
@ -292,7 +295,7 @@ int main(int argc, char* argv[]) {
|
|||
|
||||
auto change = false;
|
||||
errno = 0;
|
||||
if (fs_mgr_overlayfs_setup(nullptr, mount_point.c_str(), &change)) {
|
||||
if (fs_mgr_overlayfs_setup(nullptr, mount_point.c_str(), &change, just_disabled_verity)) {
|
||||
if (change) {
|
||||
LOG(INFO) << "Using overlayfs for " << mount_point;
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ android::fs_mgr::Fstab fs_mgr_overlayfs_candidate_list(const android::fs_mgr::Fs
|
|||
bool fs_mgr_overlayfs_mount_all(android::fs_mgr::Fstab* fstab);
|
||||
std::vector<std::string> fs_mgr_overlayfs_required_devices(android::fs_mgr::Fstab* fstab);
|
||||
bool fs_mgr_overlayfs_setup(const char* backing = nullptr, const char* mount_point = nullptr,
|
||||
bool* change = nullptr);
|
||||
bool* change = nullptr, bool force = true);
|
||||
bool fs_mgr_overlayfs_teardown(const char* mount_point = nullptr, bool* change = nullptr);
|
||||
bool fs_mgr_overlayfs_is_setup();
|
||||
bool fs_mgr_has_shared_blocks(const std::string& mount_point, const std::string& dev);
|
||||
|
|
Loading…
Reference in New Issue