From 95c61b339199ff703d43315b9dc3a2ab850ff172 Mon Sep 17 00:00:00 2001 From: Jaegeuk Kim Date: Fri, 10 Nov 2023 15:16:14 -0800 Subject: [PATCH] Use logical path to handle different dm target per boot When using multiple partitions, f2fs stores all the device paths, but we cannot guarantee the dm targets are all the same across boot cycles. Bug: 287247093 Change-Id: Ie4308a27548d4e814924afb656478cfa55fcf8b6 Signed-off-by: Jaegeuk Kim --- MetadataCrypt.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/MetadataCrypt.cpp b/MetadataCrypt.cpp index 395cc02..0e2cad1 100644 --- a/MetadataCrypt.cpp +++ b/MetadataCrypt.cpp @@ -200,6 +200,13 @@ static bool create_crypto_blk_dev(const std::string& dm_name, const std::string& LOG(ERROR) << "Could not create default-key device " << dm_name; return false; } + + // If there are multiple partitions used for a single mount, F2FS stores + // their partition paths in superblock. If the paths are dm targets, we + // cannot guarantee them across device boots. Let's use the logical paths. + if (dm_name == kDmNameUserdata || dm_name == kDmNameUserdataZoned) { + *crypto_blkdev = "/dev/block/mapper/" + dm_name; + } return true; }