Merge "Use logical path to handle different dm target per boot" into main
diff --git a/MetadataCrypt.cpp b/MetadataCrypt.cpp
index 395cc02..0e2cad1 100644
--- a/MetadataCrypt.cpp
+++ b/MetadataCrypt.cpp
@@ -200,6 +200,13 @@
         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;
 }