Make DSU to support multiple partitions

Make gsid to support multiple partitions in a generic way.

Bug: 139402092
Test: \
    adb shell gsi_tool install -n --gsi-size $(du -b system.raw|cut -f1) -w        < system.raw
    adb shell gsi_tool install -n --gsi-size $(du -b vendor.raw|cut -f1) -p vendor < vendor.raw

Change-Id: Iaf5259cc059daa61cf52efab20bf23a433909b7a
diff --git a/gsi_installer.h b/gsi_installer.h
index 33bebfb..3c9d39c 100644
--- a/gsi_installer.h
+++ b/gsi_installer.h
@@ -56,23 +56,21 @@
     int WipeUserdata();
 
     // Clean up install state if gsid crashed and restarted.
-    static void PostInstallCleanup();
-    static void PostInstallCleanup(ImageManager* manager);
+    void PostInstallCleanup();
+    void PostInstallCleanup(ImageManager* manager);
 
     const std::string& install_dir() const { return install_dir_; }
-    uint64_t userdata_size() const { return userdata_size_; }
 
   private:
     int PerformSanityChecks();
-    int PreallocateFiles();
-    int PreallocateUserdata();
-    int PreallocateSystem();
-    bool FormatUserdata();
-    bool CreateImage(const std::string& name, uint64_t size, bool readonly);
+    int Preallocate();
+    bool Format();
+    bool CreateImage(const std::string& name, uint64_t size);
     std::unique_ptr<MappedDevice> OpenPartition(const std::string& name);
     int CheckInstallState();
     bool CreateInstallStatusFile();
     bool SetBootMode(bool one_shot);
+    static const std::string GetBackingFile(std::string name);
     bool IsFinishedWriting();
     bool IsAshmemMapped();
     void UnmapAshmem();
@@ -80,11 +78,12 @@
     GsiService* service_;
 
     std::string install_dir_;
+    std::string name_;
     std::unique_ptr<ImageManager> images_;
-    uint64_t gsi_size_ = 0;
-    uint64_t userdata_size_ = 0;
-    bool wipe_userdata_ = false;
-    bool wipe_userdata_on_failure_ = false;
+    uint64_t size_ = 0;
+    bool readOnly_;
+    bool wipe_ = false;
+    bool wipe_on_failure_ = false;
     // Remaining data we're waiting to receive for the GSI image.
     uint64_t gsi_bytes_written_ = 0;
     bool succeeded_ = false;