diff options
author | Howard Chen <howardsoc@google.com> | 2021-02-18 18:32:20 +0800 |
---|---|---|
committer | Howard Chen <howardsoc@google.com> | 2021-02-19 05:47:17 +0000 |
commit | e187074136c895d0b0649c66ace7f54e0936301e (patch) | |
tree | 8d32af1165486bcb573685acf76362458c909a22 | |
parent | 23a996fde114247e6f2f67df37d955a640e9775b (diff) | |
download | gsid-e187074136c895d0b0649c66ace7f54e0936301e.tar.gz |
Move external storage mkdir to ValidateInstallParams
Otherwise the Realpath will fail.
Bug: 179980369
Bug: 171861574
Test: A physical device with a SD card inserted and
CF local instance with an emulated SD
Change-Id: I829fb8f2afea86054a1162502914144eff787a37
-rw-r--r-- | gsi_service.cpp | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/gsi_service.cpp b/gsi_service.cpp index 66e01ee..b87b8bb 100644 --- a/gsi_service.cpp +++ b/gsi_service.cpp @@ -130,15 +130,6 @@ binder::Status GsiService::openInstall(const std::string& install_dir, int* _aid *_aidl_return = status; return binder::Status::ok(); } - if (access(install_dir_.c_str(), F_OK) != 0 && errno == ENOENT) { - if (IsExternalStoragePath(install_dir_)) { - if (mkdir(install_dir_.c_str(), 0755) != 0) { - PLOG(ERROR) << "Failed to create " << install_dir_; - *_aidl_return = IGsiService::INSTALL_ERROR_GENERIC; - return binder::Status::ok(); - } - } - } std::string message; auto dsu_slot = GetDsuSlot(install_dir_); if (!RemoveFileIfExists(GetCompleteIndication(dsu_slot), &message)) { @@ -852,6 +843,14 @@ int GsiService::ValidateInstallParams(std::string& install_dir) { install_dir = kDefaultDsuImageFolder; } + if (access(install_dir.c_str(), F_OK) != 0 && (errno == ENOENT)) { + if (android::base::StartsWith(install_dir, kDsuSDPrefix)) { + if (mkdir(install_dir.c_str(), 0755) != 0) { + PLOG(ERROR) << "Failed to create " << install_dir; + return INSTALL_ERROR_GENERIC; + } + } + } // Normalize the path and add a trailing slash. std::string origInstallDir = install_dir; if (!android::base::Realpath(origInstallDir, &install_dir)) { |