diff options
author | Howard Chen <howardsoc@google.com> | 2019-11-08 11:57:47 +0800 |
---|---|---|
committer | Howard Chen <howardsoc@google.com> | 2020-01-14 03:56:41 +0000 |
commit | ee5c2b14b2f7c1ffbbcc7c6261aa3b5f79362959 (patch) | |
tree | 3a6a46fa5a3e6353feabdf15de005586748e2d12 /include/libgsi | |
parent | af1a6ad869b508c28768c15ac3abb15580b7a03e (diff) | |
download | gsid-ee5c2b14b2f7c1ffbbcc7c6261aa3b5f79362959.tar.gz |
Support multiple DSU installations
Bug: 144247097
Test: adb shell gsi_tool install --gsi-size $(du -b system.raw|cut -f1) < system.raw
Change-Id: I17f4292fc3038040cc5848ce00081e96c79ae769
Diffstat (limited to 'include/libgsi')
-rw-r--r-- | include/libgsi/libgsi.h | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/include/libgsi/libgsi.h b/include/libgsi/libgsi.h index 9b24f47..987797a 100644 --- a/include/libgsi/libgsi.h +++ b/include/libgsi/libgsi.h @@ -23,11 +23,25 @@ namespace gsi { static constexpr char kGsiServiceName[] = "gsiservice"; -static constexpr char kGsiBootedIndicatorFile[] = "/metadata/gsi/dsu/booted"; +#define DSU_METADATA_PREFIX "/metadata/gsi/dsu/" -static constexpr char kGsiLpNamesFile[] = "/metadata/gsi/dsu/lp_names"; +static constexpr char kGsiBootedIndicatorFile[] = DSU_METADATA_PREFIX "booted"; -static constexpr char kDsuLpMetadataFile[] = "/metadata/gsi/dsu/lp_metadata"; +static constexpr char kGsiLpNamesFile[] = DSU_METADATA_PREFIX "lp_names"; + +static constexpr char kDsuActiveFile[] = DSU_METADATA_PREFIX "active"; + +static inline std::string DsuLpMetadataFile(const std::string& dsu_slot) { + return DSU_METADATA_PREFIX + dsu_slot + "/lp_metadata"; +} + +static inline std::string DsuInstallDirFile(const std::string& dsu_slot) { + return DSU_METADATA_PREFIX + dsu_slot + "/install_dir"; +} + +// install_dir "/data/gsi/dsu/dsu" has a slot name "dsu" +// install_dir "/data/gsi/dsu/dsu2" has a slot name "dsu2" +std::string GetDsuSlot(const std::string& install_dir); static constexpr char kGsiBootedProp[] = "ro.gsid.image_running"; @@ -35,6 +49,10 @@ static constexpr char kDsuPostfix[] = "_gsi"; static constexpr int kMaxBootAttempts = 1; +// Get the currently active dsu slot +// Return true on success +bool GetActiveDsu(std::string* active_dsu); + // Returns true if the currently running system image is a live GSI. bool IsGsiRunning(); |