add f2fs device aliasing related arguments in vold

To support f2fs device aliasing feature, include related arguments in
vold.

Bug: 336319772
Test: add a device with "exp_alias" tag in fstab
Change-Id: Ibb8766f4c77d532a596f5581f3de8dfb334ba2fd
Signed-off-by: Daeho Jeong <daehojeong@google.com>
diff --git a/fs/F2fs.cpp b/fs/F2fs.cpp
index 3cdf574..4cdddec 100644
--- a/fs/F2fs.cpp
+++ b/fs/F2fs.cpp
@@ -27,6 +27,7 @@
 #include <vector>
 
 #include <sys/mount.h>
+#include <filesystem>
 
 using android::base::StringPrintf;
 
@@ -72,7 +73,8 @@
 }
 
 status_t Format(const std::string& source, bool is_zoned,
-                const std::vector<std::string>& user_devices, int64_t length) {
+                const std::vector<std::string>& user_devices,
+                const std::vector<bool>& device_aliased, int64_t length) {
     std::vector<char const*> cmd;
     /* '-g android' parameter passed here which defaults the sector size to 4096 */
     static constexpr int kSectorSize = 4096;
@@ -102,9 +104,15 @@
     if (is_zoned) {
         cmd.emplace_back("-m");
     }
-    for (auto& device : user_devices) {
+    for (size_t i = 0; i < user_devices.size(); i++) {
+        std::string device_name = user_devices[i];
+
         cmd.emplace_back("-c");
-        cmd.emplace_back(device.c_str());
+        if (device_aliased[i]) {
+            std::filesystem::path path = device_name;
+            device_name += "@" + path.filename().string();
+        }
+        cmd.emplace_back(device_name.c_str());
     }
     std::string block_size = std::to_string(getpagesize());
     cmd.emplace_back("-b");