Rename key_dir to metadata_key_dir and refactor
Bug: 147814592 Test: Crosshatch boots Change-Id: I18b03486d2e93c6103880d1af68d9f70147fde63
This commit is contained in:
parent
838b1a1f94
commit
7823e327c1
5 changed files with 23 additions and 11 deletions
|
@ -887,7 +887,7 @@ static bool needs_block_encryption(const FstabEntry& entry) {
|
|||
}
|
||||
|
||||
static bool should_use_metadata_encryption(const FstabEntry& entry) {
|
||||
return !entry.key_dir.empty() &&
|
||||
return !entry.metadata_key_dir.empty() &&
|
||||
(entry.fs_mgr_flags.file_encryption || entry.fs_mgr_flags.force_fde_or_fbe);
|
||||
}
|
||||
|
||||
|
@ -1159,7 +1159,7 @@ static void WrapUserdata(FstabEntry* entry, dev_t dev, const std::string& block_
|
|||
static void WrapUserdataIfNeeded(FstabEntry* entry, const std::string& actual_block_device = {}) {
|
||||
const auto& block_device =
|
||||
actual_block_device.empty() ? entry->blk_device : actual_block_device;
|
||||
if (entry->mount_point != "/data" || !entry->key_dir.empty() ||
|
||||
if (entry->mount_point != "/data" || !entry->metadata_key_dir.empty() ||
|
||||
android::base::StartsWith(block_device, "/dev/block/dm-")) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -276,7 +276,7 @@ void ParseFsMgrFlags(const std::string& flags, FstabEntry* entry) {
|
|||
entry->vbmeta_partition = arg;
|
||||
} else if (StartsWith(flag, "keydirectory=")) {
|
||||
// The metadata flag is followed by an = and the directory for the keys.
|
||||
entry->key_dir = arg;
|
||||
entry->metadata_key_dir = arg;
|
||||
} else if (StartsWith(flag, "sysfs_path=")) {
|
||||
// The path to trigger device gc by idle-maint of vold.
|
||||
entry->sysfs_path = arg;
|
||||
|
@ -591,8 +591,8 @@ void TransformFstabForDsu(Fstab* fstab, const std::vector<std::string>& dsu_part
|
|||
userdata.blk_device = "userdata_gsi";
|
||||
userdata.fs_mgr_flags.logical = true;
|
||||
userdata.fs_mgr_flags.formattable = true;
|
||||
if (!userdata.key_dir.empty()) {
|
||||
userdata.key_dir += "/gsi";
|
||||
if (!userdata.metadata_key_dir.empty()) {
|
||||
userdata.metadata_key_dir += "/gsi";
|
||||
}
|
||||
} else {
|
||||
userdata = BuildDsuUserdataFstabEntry();
|
||||
|
|
|
@ -37,7 +37,7 @@ struct FstabEntry {
|
|||
unsigned long flags = 0;
|
||||
std::string fs_options;
|
||||
std::string key_loc;
|
||||
std::string key_dir;
|
||||
std::string metadata_key_dir;
|
||||
off64_t length = 0;
|
||||
std::string label;
|
||||
int partnum = -1;
|
||||
|
|
|
@ -244,8 +244,20 @@ std::string DmTargetCrypt::GetParameterString() const {
|
|||
}
|
||||
|
||||
std::string DmTargetDefaultKey::GetParameterString() const {
|
||||
return cipher_ + " " + key_ + " " + blockdev_ + " " + std::to_string(start_sector_) +
|
||||
(set_dun_ ? " 1 set_dun" : "");
|
||||
std::vector<std::string> argv;
|
||||
argv.emplace_back(cipher_);
|
||||
argv.emplace_back(key_);
|
||||
argv.emplace_back(blockdev_);
|
||||
argv.push_back(std::to_string(start_sector_));
|
||||
std::vector<std::string> extra_argv;
|
||||
if (set_dun_) {
|
||||
extra_argv.emplace_back("set_dun");
|
||||
}
|
||||
if (!extra_argv.empty()) {
|
||||
argv.emplace_back(std::to_string(extra_argv.size()));
|
||||
argv.insert(argv.end(), extra_argv.begin(), extra_argv.end());
|
||||
}
|
||||
return android::base::Join(argv, " ");
|
||||
}
|
||||
|
||||
} // namespace dm
|
||||
|
|
|
@ -413,7 +413,7 @@ source none2 swap defaults forcefdeorfbe=
|
|||
EXPECT_TRUE(CompareFlags(flags, entry->fs_mgr_flags));
|
||||
}
|
||||
EXPECT_EQ("", entry->key_loc);
|
||||
EXPECT_EQ("", entry->key_dir);
|
||||
EXPECT_EQ("", entry->metadata_key_dir);
|
||||
EXPECT_EQ(0, entry->length);
|
||||
EXPECT_EQ("", entry->label);
|
||||
EXPECT_EQ(-1, entry->partnum);
|
||||
|
@ -440,7 +440,7 @@ source none2 swap defaults forcefdeorfbe=
|
|||
EXPECT_TRUE(CompareFlags(flags, entry->fs_mgr_flags));
|
||||
}
|
||||
EXPECT_EQ("", entry->key_loc);
|
||||
EXPECT_EQ("", entry->key_dir);
|
||||
EXPECT_EQ("", entry->metadata_key_dir);
|
||||
EXPECT_EQ(0, entry->length);
|
||||
EXPECT_EQ("", entry->label);
|
||||
EXPECT_EQ(-1, entry->partnum);
|
||||
|
@ -892,7 +892,7 @@ source none0 swap defaults keydirectory=/dir/key
|
|||
FstabEntry::FsMgrFlags flags = {};
|
||||
EXPECT_TRUE(CompareFlags(flags, entry->fs_mgr_flags));
|
||||
|
||||
EXPECT_EQ("/dir/key", entry->key_dir);
|
||||
EXPECT_EQ("/dir/key", entry->metadata_key_dir);
|
||||
}
|
||||
|
||||
TEST(fs_mgr, ReadFstabFromFile_FsMgrOptions_SysfsPath) {
|
||||
|
|
Loading…
Reference in a new issue