Revert "recovery: Add the option to choose the filesystem for /data"

Revert "fixup! recovery: Add the option to choose the filesystem for /data"

This reverts commit 58dc3ce7bb7096b9371a17bfba39e306b646e521.

Change-Id: I903b8e546e7e92e1a3d225d225217dd4df26940b

Revert "recovery: Display current filesystem when going to format"

This reverts commit 53cb873b93db3769afb56c6919951630a0960341.

Revert "recovery: Add the option to choose the filesystem for /data"

This reverts commit 6883e54bea937224d7dee7cd8e78a08cd3e59203.

Reason for revert: Conflicts with QPR3

Change-Id: I483c260810b84aba2be1c508e1705df31fb7aa92
diff --git a/install/include/install/wipe_data.h b/install/include/install/wipe_data.h
index 91c264c..75b8d36 100644
--- a/install/include/install/wipe_data.h
+++ b/install/include/install/wipe_data.h
@@ -30,7 +30,4 @@
 bool WipeData(Device* device, bool keep_memtag_mode = false);
 
 // Returns true on success.
-bool WipeData(Device* device, std::string fs, bool keep_memtag_mode = false);
-
-// Returns true on success.
 bool WipeSystem(RecoveryUI* ui, const std::function<bool()>& confirm);
diff --git a/install/wipe_data.cpp b/install/wipe_data.cpp
index 56d3674..b10b0b8 100644
--- a/install/wipe_data.cpp
+++ b/install/wipe_data.cpp
@@ -21,7 +21,6 @@
 #include <linux/fs.h>
 #include <stdio.h>
 #include <string.h>
-#include <sys/stat.h>
 #include <sys/ioctl.h>
 #include <sys/stat.h>
 
@@ -45,9 +44,8 @@
 constexpr const char* DATA_ROOT = "/data";
 constexpr const char* METADATA_ROOT = "/metadata";
 
-static bool EraseVolume(const char* volume, RecoveryUI* ui, std::string fs) {
+static bool EraseVolume(const char* volume, RecoveryUI* ui) {
   bool is_cache = (strcmp(volume, CACHE_ROOT) == 0);
-  bool is_data = (strcmp(volume, DATA_ROOT) == 0);
 
   std::vector<saved_log_file> log_files;
   if (is_cache) {
@@ -56,7 +54,7 @@
     log_files = ReadLogFilesToMemory();
   }
 
-  ui->Print("Formatting %s to %s...\n", volume, fs.c_str());
+  ui->Print("Formatting %s...\n", volume);
 
   Volume* vol = volume_for_mount_point(volume);
   if (vol->fs_mgr_flags.logical) {
@@ -105,12 +103,7 @@
     return false;
   }
 
-  int result;
-  if (is_data) {
-    result = format_volume(volume, "", fs);
-  } else {
-    result = format_volume(volume);
-  }
+  int result = format_volume(volume);
 
   if (is_cache) {
     RestoreLogFilesAfterFormat(log_files);
@@ -119,10 +112,6 @@
   return (result == 0);
 }
 
-static bool EraseVolume(const char* volume, RecoveryUI* ui) {
-  return EraseVolume(volume, ui, volume_for_mount_point(volume)->fs_type);
-}
-
 bool WipeCache(RecoveryUI* ui, const std::function<bool()>& confirm_func) {
   bool has_cache = volume_for_mount_point("/cache") != nullptr;
   if (!has_cache) {
@@ -143,7 +132,7 @@
   return success;
 }
 
-bool WipeData(Device* device, std::string fs, bool keep_memtag_mode) {
+bool WipeData(Device* device, bool keep_memtag_mode) {
   RecoveryUI* ui = device->GetUI();
   ui->Print("\n-- Wiping data...\n");
   ui->SetBackground(RecoveryUI::ERASING);
@@ -156,7 +145,7 @@
 
   bool success = device->PreWipeData();
   if (success) {
-    success &= EraseVolume(DATA_ROOT, ui, fs);
+    success &= EraseVolume(DATA_ROOT, ui);
     bool has_cache = volume_for_mount_point("/cache") != nullptr;
     if (has_cache) {
       success &= EraseVolume(CACHE_ROOT, ui);
@@ -182,10 +171,6 @@
   return success;
 }
 
-bool WipeData(Device* device, bool keep_memtag_mode) {
-  return WipeData(device, volume_for_mount_point("/data")->fs_type, keep_memtag_mode);
-}
-
 bool WipeSystem(RecoveryUI* ui, const std::function<bool()>& confirm_func) {
   if (confirm_func && !confirm_func()) {
     return false;
diff --git a/recovery.cpp b/recovery.cpp
index 4477f4b..129af41 100644
--- a/recovery.cpp
+++ b/recovery.cpp
@@ -69,8 +69,6 @@
 using android::volmgr::VolumeManager;
 using android::volmgr::VolumeInfo;
 
-using android::fs_mgr::Fstab;
-
 static constexpr const char* COMMAND_FILE = "/cache/recovery/command";
 static constexpr const char* LAST_KMSG_FILE = "/cache/recovery/last_kmsg";
 static constexpr const char* LAST_LOG_FILE = "/cache/recovery/last_log";
@@ -197,28 +195,6 @@
   }
 }
 
-std::string get_preferred_fs(Device* device) {
-  Fstab fstab;
-  auto read_fstab = ReadFstabFromFile("/etc/fstab", &fstab);
-  std::vector<std::string> headers{ "Choose what filesystem you want to use on /data", "Entries here are supported by your device." };
-  std::string fs = volume_for_mount_point("/data")->fs_type;
-  if (read_fstab) {
-      std::string current_filesystem = android::fs_mgr::GetEntryForPath(&fstab, "/data")->fs_type;
-      headers.emplace_back("Current filesystem: " + current_filesystem);
-  }
-  std::vector<std::string> items = get_data_fs_items();
-
-  if (items.size() > 1) {
-      size_t chosen_item = device->GetUI()->ShowMenu(
-          headers, items, 0, true,
-          std::bind(&Device::HandleMenuKey, device, std::placeholders::_1, std::placeholders::_2));
-      if (chosen_item == Device::kGoBack)
-        return "";
-      fs = items[chosen_item];
-  }
-  return fs;
-}
-
 static bool ask_to_wipe_data(Device* device) {
   std::vector<std::string> headers{ "Format user data?", "This includes internal storage.", "THIS CANNOT BE UNDONE!" };
   std::vector<std::string> items{ " Cancel", " Format data" };
@@ -545,11 +521,8 @@
       case Device::WIPE_DATA:
         save_current_log = true;
         if (ui->IsTextVisible()) {
-          auto fs = get_preferred_fs(device);
-          if (fs == "")
-            break;
           if (ask_to_wipe_data(device)) {
-            WipeData(device, fs);
+            WipeData(device);
           }
         } else {
           WipeData(device);
diff --git a/recovery_utils/include/recovery_utils/roots.h b/recovery_utils/include/recovery_utils/roots.h
index 180e739..cbc8b07 100644
--- a/recovery_utils/include/recovery_utils/roots.h
+++ b/recovery_utils/include/recovery_utils/roots.h
@@ -54,13 +54,6 @@
 // Copies 'directory' to root of the newly formatted volume
 int format_volume(const std::string& volume, const std::string& directory);
 
-// Reformat the given volume (must be the mount point only, eg
-// "/cache"), no paths permitted.  Attempts to unmount the volume if
-// it is mounted.
-// Copies 'directory' to root of the newly formatted volume
-// Formats volume to fs
-int format_volume(const std::string& volume, const std::string& directory, const std::string fs);
-
 // Ensure that all and only the volumes that packages expect to find
 // mounted (/tmp and /cache) are mounted.  Returns 0 on success.
 int setup_install_mounts();
@@ -71,5 +64,3 @@
 void map_logical_partitions();
 
 bool logical_partitions_mapped();
-
-std::vector<std::string> get_data_fs_items();
diff --git a/recovery_utils/roots.cpp b/recovery_utils/roots.cpp
index 14fb98e..010b98c 100644
--- a/recovery_utils/roots.cpp
+++ b/recovery_utils/roots.cpp
@@ -114,16 +114,6 @@
   return 0;
 }
 
-std::vector<std::string> get_data_fs_items() {
-  std::vector<std::string> ret;
-  for (auto& entry : fstab) {
-    if (entry.mount_point == "/data") {
-      ret.emplace_back(entry.fs_type);
-    }
-  }
-  return ret;
-}
-
 static int exec_cmd(const std::vector<std::string>& args) {
   CHECK(!args.empty());
   auto argv = StringVectorToNullTerminatedArray(args);
@@ -165,7 +155,7 @@
   return computed_size;
 }
 
-int format_volume(const std::string& volume, const std::string& directory, const std::string fs) {
+int format_volume(const std::string& volume, const std::string& directory) {
   const FstabEntry* v = android::fs_mgr::GetEntryForPath(&fstab, volume);
   if (v == nullptr) {
     LOG(ERROR) << "unknown volume \"" << volume << "\"";
@@ -183,8 +173,8 @@
     LOG(ERROR) << "format_volume: Failed to unmount \"" << v->mount_point << "\"";
     return -1;
   }
-  if (fs != "ext4" && fs != "f2fs") {
-    LOG(ERROR) << "format_volume: fs_type \"" << fs << "\" unsupported";
+  if (v->fs_type != "ext4" && v->fs_type != "f2fs") {
+    LOG(ERROR) << "format_volume: fs_type \"" << v->fs_type << "\" unsupported";
     return -1;
   }
 
@@ -229,7 +219,7 @@
     }
   }
 
-  if (fs == "ext4") {
+  if (v->fs_type == "ext4") {
     static constexpr int kBlockSize = 4096;
     std::vector<std::string> mke2fs_args = {
       "/system/bin/mke2fs", "-F", "-t", "ext4", "-b", std::to_string(kBlockSize),
@@ -325,13 +315,7 @@
 }
 
 int format_volume(const std::string& volume) {
-  const FstabEntry* v = android::fs_mgr::GetEntryForPath(&fstab, volume);
-  return format_volume(volume, "", v->fs_type);
-}
-
-int format_volume(const std::string& volume, const std::string& directory) {
-  const FstabEntry* v = android::fs_mgr::GetEntryForPath(&fstab, volume);
-  return format_volume(volume, directory, v->fs_type);
+  return format_volume(volume, "");
 }
 
 int setup_install_mounts() {