diff --git a/interfaces/kits/updaterkits/updaterkits.cpp b/interfaces/kits/updaterkits/updaterkits.cpp index cefbd0e53f67d325bd26b2399d5894d282f21531..f4e79b4905db59418c79777abde2b67a4edbde0a 100755 --- a/interfaces/kits/updaterkits/updaterkits.cpp +++ b/interfaces/kits/updaterkits/updaterkits.cpp @@ -134,6 +134,21 @@ static bool IsPackagePath(const std::string &path) return true; } +static void UpdateOptExpand(std::string& updateOpt) +{ + if (updateOpt.find("--shrink_info=") == std::string::npos && + updateOpt.find("--virtual_shrink_info=") == std::string::npos) { + return; + } + struct stat fileStat; + int ret = stat("/data/service/el1/0/hyperhold", &fileStat); + if (ret != 0) { + return; + } + std::string inode = std::to_string(fileStat.st_ino); + updateOpt += "," + inode; +} + static int AddPkgPath(struct UpdateMessage &msg, size_t updateOffset, const std::vector &packageName) { for (auto path : packageName) { @@ -146,6 +161,7 @@ static int AddPkgPath(struct UpdateMessage &msg, size_t updateOffset, const std: ret = snprintf_s(msg.update + updateOffset, sizeof(msg.update) - updateOffset, sizeof(msg.update) - 1 - updateOffset, "--update_package=%s\n", path.c_str()); } else { + UpdateOptExpand(path); ret = snprintf_s(msg.update + updateOffset, sizeof(msg.update) - updateOffset, sizeof(msg.update) - 1 - updateOffset, "%s\n", path.c_str()); } diff --git a/services/updater.cpp b/services/updater.cpp index c28933e0c196c17e4e90a852c0f3cead7cff989b..9e8e4a9542161a96460bae2507df788589202a53 100644 --- a/services/updater.cpp +++ b/services/updater.cpp @@ -117,11 +117,6 @@ UpdaterStatus IsSpaceCapacitySufficient(const UpdaterParams &upParams) uint64_t maxStashSize = *max_element(stashSizeList.begin(), stashSizeList.end()); LOG(INFO) << "get max stash size: " << maxStashSize; uint64_t totalPkgSize = maxStashSize + MIN_UPDATE_SPACE; - uint64_t shrinkSize = 0; - if (!upParams.virtualShrinkInfo.empty() && - Utils::ConvertToUnsignedLongLong(upParams.virtualShrinkInfo, shrinkSize)) { - totalPkgSize += shrinkSize * 3 / 2; // 3 / 2 = 1.5 - } LOG(INFO) << "needed totalPkgSize = " << totalPkgSize; if (CheckStatvfs(totalPkgSize) != UPDATE_SUCCESS) { LOG(ERROR) << "CheckStatvfs error"; diff --git a/utils/include/utils.h b/utils/include/utils.h index 0074fceb6c3d86618795a67258916680475dbb90..11170ddac0cabf48a86ecee9f8685adddfa3366c 100644 --- a/utils/include/utils.h +++ b/utils/include/utils.h @@ -106,7 +106,7 @@ bool IsEsDevice(); bool ConvertToUnsignedLongLong(const std::string &str, uint64_t &value); bool ConvertToLongLong(const std::string &str, int64_t &value); bool ConvertToLong(const std::string &str, int32_t &value); -bool ConvertToUnsignedLong(const std::string &str, uint32_t &value); +bool ConvertToUnsignedLong(const std::string &str, uint32_t &value, int base = 0); bool ConvertToDouble(const std::string &str, double &value); bool ConvertToFloat(const std::string &str, float &value); #ifndef __WIN32 diff --git a/utils/utils.cpp b/utils/utils.cpp index 0fdf150daebf37a9b3c727978cb1898ced505591..854e135cf1671e66e9cf9df74e783c1cbda47c17 100644 --- a/utils/utils.cpp +++ b/utils/utils.cpp @@ -1007,12 +1007,12 @@ bool ConvertToLong(const std::string &str, int32_t &value) return true; } -bool ConvertToUnsignedLong(const std::string &str, uint32_t &value) +bool ConvertToUnsignedLong(const std::string &str, uint32_t &value, int base) { char *endPtr = nullptr; errno = 0; - value = std::strtoul(str.c_str(), &endPtr, 16); // 16 : hexadecimal scale + value = std::strtoul(str.c_str(), &endPtr, base); #ifndef UPDATER_UT if (endPtr == str.c_str() || *endPtr != '\0' || errno == ERANGE) { LOG(ERROR) << "Convert string to uint32_t failed, str " << str << " converted to value " << value;