Add length parameter to format /data f2fs filesystem

With metadata encryption, if partition is wiped (or) cryptfs failed ,
it will do format without length which make partition size is grown
large to occupy remaining space instead of restricting the Android
defined partition size.

Bug: 343159184
Test: Add length flag in fstab && fastboot erase userdata &&
      fastboot reboot && df -h /data

Change-Id: Iad041e960c9337ab1b9d51b115db3c5f3f1f75e2
Signed-off-by: Ashok Mutyala <quic_amutyala@quicinc.com>
diff --git a/vdc.cpp b/vdc.cpp
index ee8cf9e..9764b1a 100644
--- a/vdc.cpp
+++ b/vdc.cpp
@@ -109,13 +109,15 @@
     if (isZoned == android::base::ParseBoolResult::kError) exit(EINVAL);
 
     std::vector<std::string> userDevices = {};
-    if (args[7] != "") {
-        userDevices = android::base::Split(args[7], " ");
+    int64_t length;
+    if (!android::base::ParseInt(args[7], &length)) exit(EINVAL);
+    if (args[8] != "") {
+        userDevices = android::base::Split(args[8], " ");
     }
-    checkStatus(args,
-                vold->encryptFstab(args[2], args[3],
-                                   shouldFormat == android::base::ParseBoolResult::kTrue, args[5],
-                                   isZoned == android::base::ParseBoolResult::kTrue, userDevices));
+    checkStatus(args, vold->encryptFstab(args[2], args[3],
+                                         shouldFormat == android::base::ParseBoolResult::kTrue,
+                                         args[5], isZoned == android::base::ParseBoolResult::kTrue,
+                                         userDevices, length));
 }
 
 int main(int argc, char** argv) {
@@ -162,7 +164,7 @@
         bindkeys(args, vold);
     } else if (args[0] == "cryptfs" && args[1] == "mountFstab" && args.size() == 6) {
         mountFstab(args, vold);
-    } else if (args[0] == "cryptfs" && args[1] == "encryptFstab" && args.size() == 8) {
+    } else if (args[0] == "cryptfs" && args[1] == "encryptFstab" && args.size() == 9) {
         encryptFstab(args, vold);
     } else if (args[0] == "checkpoint" && args[1] == "supportsCheckpoint" && args.size() == 2) {
         bool supported = false;