Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f6bb9cd7 authored by Automerger Merge Worker's avatar Automerger Merge Worker
Browse files

Merge changes from topics "dm-default-key-v2", "metadata_cipher" am: cb1a8e7f

Change-Id: Iad7cbe4ac9b2be29f490e638465cfc28f8214d00
parents 0eefb290 cb1a8e7f
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -277,6 +277,9 @@ void ParseFsMgrFlags(const std::string& flags, FstabEntry* entry) {
        } else if (StartsWith(flag, "keydirectory=")) {
            // The metadata flag is followed by an = and the directory for the keys.
            entry->metadata_key_dir = arg;
        } else if (StartsWith(flag, "metadata_cipher=")) {
            // Specify the cipher to use for metadata encryption
            entry->metadata_cipher = arg;
        } else if (StartsWith(flag, "sysfs_path=")) {
            // The path to trigger device gc by idle-maint of vold.
            entry->sysfs_path = arg;
+1 −0
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ struct FstabEntry {
    std::string fs_options;
    std::string key_loc;
    std::string metadata_key_dir;
    std::string metadata_cipher;
    off64_t length = 0;
    std::string label;
    int partnum = -1;
+17 −0
Original line number Diff line number Diff line
@@ -895,6 +895,23 @@ source none0 swap defaults keydirectory=/dir/key
    EXPECT_EQ("/dir/key", entry->metadata_key_dir);
}

TEST(fs_mgr, ReadFstabFromFile_FsMgrOptions_MetadataCipher) {
    TemporaryFile tf;
    ASSERT_TRUE(tf.fd != -1);
    std::string fstab_contents = R"fs(
source none0       swap   defaults      keydirectory=/dir/key,metadata_cipher=adiantum
)fs";

    ASSERT_TRUE(android::base::WriteStringToFile(fstab_contents, tf.path));

    Fstab fstab;
    EXPECT_TRUE(ReadFstabFromFile(tf.path, &fstab));
    ASSERT_EQ(1U, fstab.size());

    auto entry = fstab.begin();
    EXPECT_EQ("adiantum", entry->metadata_cipher);
}

TEST(fs_mgr, ReadFstabFromFile_FsMgrOptions_SysfsPath) {
    TemporaryFile tf;
    ASSERT_TRUE(tf.fd != -1);