default fstab: only read the fstab if it hasn't been read yet

Change-Id: I0d8d5cdda4da5486f51a80772f9d581bf549138c
This commit is contained in:
bigbiff
2021-10-02 09:50:58 -04:00
parent cefb0de23f
commit 543a928359
2 changed files with 25 additions and 16 deletions
+10 -7
View File
@@ -97,9 +97,11 @@ static bool mount_via_fs_mgr(const char* mount_point, const char* blk_device) {
return false;
}
if (!ReadDefaultFstab(&fstab_default)) {
PLOG(ERROR) << "Failed to open default fstab";
return -1;
if (fstab_default.empty()) {
if (!ReadDefaultFstab(&fstab_default)) {
PLOG(ERROR) << "Failed to open default fstab";
return -1;
}
}
auto mount_rc = fs_mgr_do_mount(&fstab_default, const_cast<char*>(mount_point),
const_cast<char*>(blk_device), nullptr,
@@ -284,9 +286,11 @@ bool fscrypt_mount_metadata_encrypted(const std::string& blk_device, const std::
LOG(ERROR) << "fscrypt_enable_crypto got unexpected starting state: " << encrypted_state;
return false;
}
if (!ReadDefaultFstab(&fstab_default)) {
PLOG(ERROR) << "Failed to open default fstab";
return -1;
if (fstab_default.empty()) {
if (!ReadDefaultFstab(&fstab_default)) {
PLOG(ERROR) << "Failed to open default fstab";
return -1;
}
}
auto data_rec = GetEntryForMountPoint(&fstab_default, mount_point);
if (!data_rec) {
@@ -323,7 +327,6 @@ bool fscrypt_mount_metadata_encrypted(const std::string& blk_device, const std::
LOG(ERROR) << "Unknown options_format_version: " << options_format_version;
return false;
}
auto gen = needs_encrypt ? makeGen(options) : neverGen();
KeyBuffer key;
if (!read_key(data_rec->metadata_key_dir, gen, &key)) return false;