Gunnar Mills | 19e4ce5 | 2017-04-27 11:24:19 -0500 | [diff] [blame] | 1 | #include "config.h" |
Gunnar Mills | b0ce996 | 2018-09-07 13:39:10 -0500 | [diff] [blame] | 2 | |
| 3 | #include "image_manager.hpp" |
| 4 | |
Gunnar Mills | 19e4ce5 | 2017-04-27 11:24:19 -0500 | [diff] [blame] | 5 | #include "version.hpp" |
Gunnar Mills | 3027bba | 2017-04-27 15:49:03 -0500 | [diff] [blame] | 6 | #include "watch.hpp" |
Gunnar Mills | b0ce996 | 2018-09-07 13:39:10 -0500 | [diff] [blame] | 7 | |
| 8 | #include <stdio.h> |
| 9 | #include <stdlib.h> |
| 10 | #include <sys/stat.h> |
| 11 | #include <sys/wait.h> |
| 12 | #include <unistd.h> |
| 13 | |
Gunnar Mills | b0ce996 | 2018-09-07 13:39:10 -0500 | [diff] [blame] | 14 | #include <elog-errors.hpp> |
Gunnar Mills | b0ce996 | 2018-09-07 13:39:10 -0500 | [diff] [blame] | 15 | #include <phosphor-logging/elog.hpp> |
Patrick Williams | c9bb642 | 2021-08-27 06:18:35 -0500 | [diff] [blame] | 16 | #include <phosphor-logging/lg2.hpp> |
Adriana Kobylak | 43699ca | 2018-10-17 14:56:29 -0500 | [diff] [blame] | 17 | #include <xyz/openbmc_project/Software/Image/error.hpp> |
Gunnar Mills | e91d321 | 2017-04-19 15:42:47 -0500 | [diff] [blame] | 18 | |
Adriana Kobylak | 58aa750 | 2020-06-08 11:12:11 -0500 | [diff] [blame] | 19 | #include <algorithm> |
| 20 | #include <cstring> |
Adriana Kobylak | 59b640b | 2022-01-21 19:45:22 +0000 | [diff] [blame] | 21 | #include <ctime> |
Adriana Kobylak | 58aa750 | 2020-06-08 11:12:11 -0500 | [diff] [blame] | 22 | #include <filesystem> |
Adriana Kobylak | 59b640b | 2022-01-21 19:45:22 +0000 | [diff] [blame] | 23 | #include <random> |
Adriana Kobylak | 58aa750 | 2020-06-08 11:12:11 -0500 | [diff] [blame] | 24 | #include <string> |
| 25 | |
Gunnar Mills | e91d321 | 2017-04-19 15:42:47 -0500 | [diff] [blame] | 26 | namespace phosphor |
| 27 | { |
| 28 | namespace software |
| 29 | { |
| 30 | namespace manager |
| 31 | { |
| 32 | |
Patrick Williams | c9bb642 | 2021-08-27 06:18:35 -0500 | [diff] [blame] | 33 | PHOSPHOR_LOG2_USING; |
Gunnar Mills | 19e4ce5 | 2017-04-27 11:24:19 -0500 | [diff] [blame] | 34 | using namespace phosphor::logging; |
Adriana Kobylak | 43699ca | 2018-10-17 14:56:29 -0500 | [diff] [blame] | 35 | using namespace sdbusplus::xyz::openbmc_project::Software::Image::Error; |
Gunnar Mills | b30cadd | 2017-10-06 16:07:32 -0500 | [diff] [blame] | 36 | namespace Software = phosphor::logging::xyz::openbmc_project::Software; |
Adriana Kobylak | 43699ca | 2018-10-17 14:56:29 -0500 | [diff] [blame] | 37 | using ManifestFail = Software::Image::ManifestFileFailure; |
| 38 | using UnTarFail = Software::Image::UnTarFailure; |
| 39 | using InternalFail = Software::Image::InternalFailure; |
Adriana Kobylak | 447d0da | 2021-03-15 13:40:52 -0500 | [diff] [blame] | 40 | using ImageFail = Software::Image::ImageFailure; |
Adriana Kobylak | c98d912 | 2020-05-05 10:36:01 -0500 | [diff] [blame] | 41 | namespace fs = std::filesystem; |
Gunnar Mills | 19e4ce5 | 2017-04-27 11:24:19 -0500 | [diff] [blame] | 42 | |
| 43 | struct RemovablePath |
| 44 | { |
| 45 | fs::path path; |
| 46 | |
Lei YU | 0cd6d84 | 2021-12-27 11:56:02 +0800 | [diff] [blame] | 47 | explicit RemovablePath(const fs::path& path) : path(path) |
Adriana Kobylak | 58aa750 | 2020-06-08 11:12:11 -0500 | [diff] [blame] | 48 | {} |
Gunnar Mills | 19e4ce5 | 2017-04-27 11:24:19 -0500 | [diff] [blame] | 49 | ~RemovablePath() |
| 50 | { |
Lei YU | 5d93028 | 2019-03-08 16:41:51 +0800 | [diff] [blame] | 51 | if (!path.empty()) |
Adriana Kobylak | 2b2cd9f | 2018-02-12 16:20:13 -0600 | [diff] [blame] | 52 | { |
Lei YU | 5d93028 | 2019-03-08 16:41:51 +0800 | [diff] [blame] | 53 | std::error_code ec; |
| 54 | fs::remove_all(path, ec); |
Adriana Kobylak | 2b2cd9f | 2018-02-12 16:20:13 -0600 | [diff] [blame] | 55 | } |
Gunnar Mills | 19e4ce5 | 2017-04-27 11:24:19 -0500 | [diff] [blame] | 56 | } |
| 57 | }; |
| 58 | |
Lei YU | f6144e9 | 2019-10-18 17:13:49 +0800 | [diff] [blame] | 59 | namespace // anonymous |
| 60 | { |
| 61 | |
| 62 | std::vector<std::string> getSoftwareObjects(sdbusplus::bus::bus& bus) |
| 63 | { |
| 64 | std::vector<std::string> paths; |
| 65 | auto method = bus.new_method_call(MAPPER_BUSNAME, MAPPER_PATH, |
| 66 | MAPPER_INTERFACE, "GetSubTreePaths"); |
| 67 | method.append(SOFTWARE_OBJPATH); |
| 68 | method.append(0); // Depth 0 to search all |
| 69 | method.append(std::vector<std::string>({VERSION_BUSNAME})); |
| 70 | auto reply = bus.call(method); |
| 71 | reply.read(paths); |
| 72 | return paths; |
| 73 | } |
| 74 | |
| 75 | } // namespace |
| 76 | |
Gunnar Mills | 3027bba | 2017-04-27 15:49:03 -0500 | [diff] [blame] | 77 | int Manager::processImage(const std::string& tarFilePath) |
Gunnar Mills | e91d321 | 2017-04-19 15:42:47 -0500 | [diff] [blame] | 78 | { |
Gunnar Mills | 19e4ce5 | 2017-04-27 11:24:19 -0500 | [diff] [blame] | 79 | if (!fs::is_regular_file(tarFilePath)) |
| 80 | { |
Patrick Williams | c9bb642 | 2021-08-27 06:18:35 -0500 | [diff] [blame] | 81 | error("Tarball {PATH} does not exist", "PATH", tarFilePath); |
Gunnar Mills | b30cadd | 2017-10-06 16:07:32 -0500 | [diff] [blame] | 82 | report<ManifestFileFailure>(ManifestFail::PATH(tarFilePath.c_str())); |
Gunnar Mills | 19e4ce5 | 2017-04-27 11:24:19 -0500 | [diff] [blame] | 83 | return -1; |
Gunnar Mills | 19e4ce5 | 2017-04-27 11:24:19 -0500 | [diff] [blame] | 84 | } |
| 85 | RemovablePath tarPathRemove(tarFilePath); |
| 86 | fs::path tmpDirPath(std::string{IMG_UPLOAD_DIR}); |
| 87 | tmpDirPath /= "imageXXXXXX"; |
Lei YU | 5d93028 | 2019-03-08 16:41:51 +0800 | [diff] [blame] | 88 | auto tmpDir = tmpDirPath.string(); |
Gunnar Mills | 19e4ce5 | 2017-04-27 11:24:19 -0500 | [diff] [blame] | 89 | |
Lei YU | 5d93028 | 2019-03-08 16:41:51 +0800 | [diff] [blame] | 90 | // Create a tmp dir to extract tarball. |
| 91 | if (!mkdtemp(tmpDir.data())) |
Gunnar Mills | 19e4ce5 | 2017-04-27 11:24:19 -0500 | [diff] [blame] | 92 | { |
Patrick Williams | c9bb642 | 2021-08-27 06:18:35 -0500 | [diff] [blame] | 93 | error("Error ({ERRNO}) occurred during mkdtemp", "ERRNO", errno); |
Gunnar Mills | b30cadd | 2017-10-06 16:07:32 -0500 | [diff] [blame] | 94 | report<InternalFailure>(InternalFail::FAIL("mkdtemp")); |
Gunnar Mills | 19e4ce5 | 2017-04-27 11:24:19 -0500 | [diff] [blame] | 95 | return -1; |
| 96 | } |
| 97 | |
Lei YU | 5d93028 | 2019-03-08 16:41:51 +0800 | [diff] [blame] | 98 | tmpDirPath = tmpDir; |
| 99 | RemovablePath tmpDirToRemove(tmpDirPath); |
Gunnar Mills | 19e4ce5 | 2017-04-27 11:24:19 -0500 | [diff] [blame] | 100 | fs::path manifestPath = tmpDirPath; |
| 101 | manifestPath /= MANIFEST_FILE_NAME; |
Gunnar Mills | 19e4ce5 | 2017-04-27 11:24:19 -0500 | [diff] [blame] | 102 | |
Lei YU | 5d93028 | 2019-03-08 16:41:51 +0800 | [diff] [blame] | 103 | // Untar tarball into the tmp dir |
| 104 | auto rc = unTar(tarFilePath, tmpDirPath.string()); |
| 105 | if (rc < 0) |
Gunnar Mills | 19e4ce5 | 2017-04-27 11:24:19 -0500 | [diff] [blame] | 106 | { |
Patrick Williams | c9bb642 | 2021-08-27 06:18:35 -0500 | [diff] [blame] | 107 | error("Error ({RC}) occurred during untar", "RC", rc); |
Gunnar Mills | 19e4ce5 | 2017-04-27 11:24:19 -0500 | [diff] [blame] | 108 | return -1; |
| 109 | } |
| 110 | |
| 111 | // Verify the manifest file |
| 112 | if (!fs::is_regular_file(manifestPath)) |
| 113 | { |
Patrick Williams | c9bb642 | 2021-08-27 06:18:35 -0500 | [diff] [blame] | 114 | error("No manifest file {PATH}", "PATH", tarFilePath); |
Adriana Kobylak | 596466b | 2018-02-13 14:48:53 -0600 | [diff] [blame] | 115 | report<ManifestFileFailure>(ManifestFail::PATH(tarFilePath.c_str())); |
Gunnar Mills | 19e4ce5 | 2017-04-27 11:24:19 -0500 | [diff] [blame] | 116 | return -1; |
| 117 | } |
| 118 | |
| 119 | // Get version |
| 120 | auto version = Version::getValue(manifestPath.string(), "version"); |
| 121 | if (version.empty()) |
| 122 | { |
Patrick Williams | c9bb642 | 2021-08-27 06:18:35 -0500 | [diff] [blame] | 123 | error("Unable to read version from manifest file {PATH}", "PATH", |
| 124 | tarFilePath); |
Adriana Kobylak | 596466b | 2018-02-13 14:48:53 -0600 | [diff] [blame] | 125 | report<ManifestFileFailure>(ManifestFail::PATH(tarFilePath.c_str())); |
Gunnar Mills | 19e4ce5 | 2017-04-27 11:24:19 -0500 | [diff] [blame] | 126 | return -1; |
| 127 | } |
| 128 | |
Vijay Khemka | b7c062e | 2019-09-18 17:15:57 -0700 | [diff] [blame] | 129 | // Get running machine name |
| 130 | std::string currMachine = Version::getBMCMachine(OS_RELEASE_FILE); |
| 131 | if (currMachine.empty()) |
| 132 | { |
Patrick Williams | c9bb642 | 2021-08-27 06:18:35 -0500 | [diff] [blame] | 133 | auto path = OS_RELEASE_FILE; |
| 134 | error("Failed to read machine name from osRelease: {PATH}", "PATH", |
| 135 | path); |
Adriana Kobylak | 447d0da | 2021-03-15 13:40:52 -0500 | [diff] [blame] | 136 | report<ImageFailure>(ImageFail::FAIL("Failed to read machine name"), |
Patrick Williams | c9bb642 | 2021-08-27 06:18:35 -0500 | [diff] [blame] | 137 | ImageFail::PATH(path)); |
Vijay Khemka | b7c062e | 2019-09-18 17:15:57 -0700 | [diff] [blame] | 138 | return -1; |
| 139 | } |
| 140 | |
| 141 | // Get machine name for image to be upgraded |
| 142 | std::string machineStr = |
| 143 | Version::getValue(manifestPath.string(), "MachineName"); |
| 144 | if (!machineStr.empty()) |
| 145 | { |
| 146 | if (machineStr != currMachine) |
| 147 | { |
Patrick Williams | c9bb642 | 2021-08-27 06:18:35 -0500 | [diff] [blame] | 148 | error( |
| 149 | "BMC upgrade: Machine name doesn't match: {CURRENT_MACHINE} vs {NEW_MACHINE}", |
| 150 | "CURRENT_MACHINE", currMachine, "NEW_MACHINE", machineStr); |
Adriana Kobylak | 447d0da | 2021-03-15 13:40:52 -0500 | [diff] [blame] | 151 | report<ImageFailure>( |
| 152 | ImageFail::FAIL("Machine name does not match"), |
| 153 | ImageFail::PATH(manifestPath.string().c_str())); |
Vijay Khemka | b7c062e | 2019-09-18 17:15:57 -0700 | [diff] [blame] | 154 | return -1; |
| 155 | } |
| 156 | } |
| 157 | else |
| 158 | { |
Patrick Williams | c9bb642 | 2021-08-27 06:18:35 -0500 | [diff] [blame] | 159 | warning("No machine name in Manifest file"); |
Adriana Kobylak | 447d0da | 2021-03-15 13:40:52 -0500 | [diff] [blame] | 160 | report<ImageFailure>( |
| 161 | ImageFail::FAIL("MANIFEST is missing machine name"), |
| 162 | ImageFail::PATH(manifestPath.string().c_str())); |
Vijay Khemka | b7c062e | 2019-09-18 17:15:57 -0700 | [diff] [blame] | 163 | } |
| 164 | |
Gunnar Mills | 3027bba | 2017-04-27 15:49:03 -0500 | [diff] [blame] | 165 | // Get purpose |
| 166 | auto purposeString = Version::getValue(manifestPath.string(), "purpose"); |
| 167 | if (purposeString.empty()) |
| 168 | { |
Patrick Williams | c9bb642 | 2021-08-27 06:18:35 -0500 | [diff] [blame] | 169 | error("Unable to read purpose from manifest file {PATH}", "PATH", |
| 170 | tarFilePath); |
Adriana Kobylak | 596466b | 2018-02-13 14:48:53 -0600 | [diff] [blame] | 171 | report<ManifestFileFailure>(ManifestFail::PATH(tarFilePath.c_str())); |
Gunnar Mills | 3027bba | 2017-04-27 15:49:03 -0500 | [diff] [blame] | 172 | return -1; |
| 173 | } |
| 174 | |
Patrick Williams | c9bb642 | 2021-08-27 06:18:35 -0500 | [diff] [blame] | 175 | auto convertedPurpose = |
| 176 | sdbusplus::message::convert_from_string<Version::VersionPurpose>( |
| 177 | purposeString); |
| 178 | |
| 179 | if (!convertedPurpose) |
Gunnar Mills | b30cadd | 2017-10-06 16:07:32 -0500 | [diff] [blame] | 180 | { |
Patrick Williams | c9bb642 | 2021-08-27 06:18:35 -0500 | [diff] [blame] | 181 | error( |
| 182 | "Failed to convert manifest purpose ({PURPOSE}) to enum; setting to Unknown.", |
| 183 | "PURPOSE", purposeString); |
Gunnar Mills | b30cadd | 2017-10-06 16:07:32 -0500 | [diff] [blame] | 184 | } |
Patrick Williams | c9bb642 | 2021-08-27 06:18:35 -0500 | [diff] [blame] | 185 | auto purpose = convertedPurpose.value_or(Version::VersionPurpose::Unknown); |
Gunnar Mills | 3027bba | 2017-04-27 15:49:03 -0500 | [diff] [blame] | 186 | |
Chanh Nguyen | 1fd6ddd | 2021-01-06 11:09:09 +0700 | [diff] [blame] | 187 | // Get ExtendedVersion |
| 188 | std::string extendedVersion = |
| 189 | Version::getValue(manifestPath.string(), "ExtendedVersion"); |
| 190 | |
Gunnar Mills | 19e4ce5 | 2017-04-27 11:24:19 -0500 | [diff] [blame] | 191 | // Compute id |
Adriana Kobylak | 59b640b | 2022-01-21 19:45:22 +0000 | [diff] [blame] | 192 | auto salt = std::to_string(randomGen()); |
| 193 | auto id = Version::getId(version + salt); |
Gunnar Mills | 19e4ce5 | 2017-04-27 11:24:19 -0500 | [diff] [blame] | 194 | |
| 195 | fs::path imageDirPath = std::string{IMG_UPLOAD_DIR}; |
| 196 | imageDirPath /= id; |
| 197 | |
Adriana Kobylak | 2285fe0 | 2018-02-27 15:36:59 -0600 | [diff] [blame] | 198 | auto objPath = std::string{SOFTWARE_OBJPATH} + '/' + id; |
Gunnar Mills | 3027bba | 2017-04-27 15:49:03 -0500 | [diff] [blame] | 199 | |
Lei YU | f6144e9 | 2019-10-18 17:13:49 +0800 | [diff] [blame] | 200 | // This service only manages the uploaded versions, and there could be |
| 201 | // active versions on D-Bus that is not managed by this service. |
| 202 | // So check D-Bus if there is an existing version. |
| 203 | auto allSoftwareObjs = getSoftwareObjects(bus); |
| 204 | auto it = |
| 205 | std::find(allSoftwareObjs.begin(), allSoftwareObjs.end(), objPath); |
| 206 | if (versions.find(id) == versions.end() && it == allSoftwareObjs.end()) |
Saqib Khan | d377ba1 | 2017-10-16 14:32:30 -0500 | [diff] [blame] | 207 | { |
selvaganapathim | 3ea1e87 | 2021-09-09 22:55:30 +0530 | [diff] [blame] | 208 | // Rename the temp dir to image dir |
| 209 | fs::rename(tmpDirPath, imageDirPath); |
| 210 | // Clear the path, so it does not attemp to remove a non-existing path |
| 211 | tmpDirToRemove.path.clear(); |
| 212 | |
Lei YU | f6144e9 | 2019-10-18 17:13:49 +0800 | [diff] [blame] | 213 | // Create Version object |
Saqib Khan | ee13e83 | 2017-10-23 12:53:11 -0500 | [diff] [blame] | 214 | auto versionPtr = std::make_unique<Version>( |
Chanh Nguyen | 1fd6ddd | 2021-01-06 11:09:09 +0700 | [diff] [blame] | 215 | bus, objPath, version, purpose, extendedVersion, |
| 216 | imageDirPath.string(), |
Adriana Kobylak | 59b640b | 2022-01-21 19:45:22 +0000 | [diff] [blame] | 217 | std::bind(&Manager::erase, this, std::placeholders::_1), id); |
Saqib Khan | ee13e83 | 2017-10-23 12:53:11 -0500 | [diff] [blame] | 218 | versionPtr->deleteObject = |
Adriana Kobylak | 2285fe0 | 2018-02-27 15:36:59 -0600 | [diff] [blame] | 219 | std::make_unique<phosphor::software::manager::Delete>(bus, objPath, |
| 220 | *versionPtr); |
Saqib Khan | ee13e83 | 2017-10-23 12:53:11 -0500 | [diff] [blame] | 221 | versions.insert(std::make_pair(id, std::move(versionPtr))); |
Saqib Khan | d377ba1 | 2017-10-16 14:32:30 -0500 | [diff] [blame] | 222 | } |
| 223 | else |
| 224 | { |
Patrick Williams | c9bb642 | 2021-08-27 06:18:35 -0500 | [diff] [blame] | 225 | info("Software Object with the same version ({VERSION}) already exists", |
| 226 | "VERSION", id); |
Saqib Khan | d377ba1 | 2017-10-16 14:32:30 -0500 | [diff] [blame] | 227 | } |
Gunnar Mills | e91d321 | 2017-04-19 15:42:47 -0500 | [diff] [blame] | 228 | return 0; |
| 229 | } |
| 230 | |
Leonel Gonzalez | 50d559c | 2017-07-07 14:38:25 -0500 | [diff] [blame] | 231 | void Manager::erase(std::string entryId) |
| 232 | { |
| 233 | auto it = versions.find(entryId); |
| 234 | if (it == versions.end()) |
| 235 | { |
| 236 | return; |
| 237 | } |
Eddie James | 6d87371 | 2017-09-01 11:29:07 -0500 | [diff] [blame] | 238 | |
Leonel Gonzalez | 50d559c | 2017-07-07 14:38:25 -0500 | [diff] [blame] | 239 | // Delete image dir |
| 240 | fs::path imageDirPath = (*(it->second)).path(); |
| 241 | if (fs::exists(imageDirPath)) |
| 242 | { |
| 243 | fs::remove_all(imageDirPath); |
| 244 | } |
| 245 | this->versions.erase(entryId); |
| 246 | } |
| 247 | |
Gunnar Mills | 3027bba | 2017-04-27 15:49:03 -0500 | [diff] [blame] | 248 | int Manager::unTar(const std::string& tarFilePath, |
| 249 | const std::string& extractDirPath) |
Gunnar Mills | 19e4ce5 | 2017-04-27 11:24:19 -0500 | [diff] [blame] | 250 | { |
| 251 | if (tarFilePath.empty()) |
| 252 | { |
Patrick Williams | c9bb642 | 2021-08-27 06:18:35 -0500 | [diff] [blame] | 253 | error("TarFilePath is empty"); |
Gunnar Mills | b30cadd | 2017-10-06 16:07:32 -0500 | [diff] [blame] | 254 | report<UnTarFailure>(UnTarFail::PATH(tarFilePath.c_str())); |
Gunnar Mills | 19e4ce5 | 2017-04-27 11:24:19 -0500 | [diff] [blame] | 255 | return -1; |
| 256 | } |
| 257 | if (extractDirPath.empty()) |
| 258 | { |
Patrick Williams | c9bb642 | 2021-08-27 06:18:35 -0500 | [diff] [blame] | 259 | error("ExtractDirPath is empty"); |
Adriana Kobylak | 596466b | 2018-02-13 14:48:53 -0600 | [diff] [blame] | 260 | report<UnTarFailure>(UnTarFail::PATH(extractDirPath.c_str())); |
Gunnar Mills | 19e4ce5 | 2017-04-27 11:24:19 -0500 | [diff] [blame] | 261 | return -1; |
| 262 | } |
| 263 | |
Patrick Williams | c9bb642 | 2021-08-27 06:18:35 -0500 | [diff] [blame] | 264 | info("Untaring {PATH} to {EXTRACTIONDIR}", "PATH", tarFilePath, |
| 265 | "EXTRACTIONDIR", extractDirPath); |
Gunnar Mills | 19e4ce5 | 2017-04-27 11:24:19 -0500 | [diff] [blame] | 266 | int status = 0; |
| 267 | pid_t pid = fork(); |
| 268 | |
| 269 | if (pid == 0) |
| 270 | { |
| 271 | // child process |
Adriana Kobylak | 2285fe0 | 2018-02-27 15:36:59 -0600 | [diff] [blame] | 272 | execl("/bin/tar", "tar", "-xf", tarFilePath.c_str(), "-C", |
| 273 | extractDirPath.c_str(), (char*)0); |
Gunnar Mills | 19e4ce5 | 2017-04-27 11:24:19 -0500 | [diff] [blame] | 274 | // execl only returns on fail |
Patrick Williams | c9bb642 | 2021-08-27 06:18:35 -0500 | [diff] [blame] | 275 | error("Failed to execute untar on {PATH}", "PATH", tarFilePath); |
Gunnar Mills | b30cadd | 2017-10-06 16:07:32 -0500 | [diff] [blame] | 276 | report<UnTarFailure>(UnTarFail::PATH(tarFilePath.c_str())); |
Gunnar Mills | 19e4ce5 | 2017-04-27 11:24:19 -0500 | [diff] [blame] | 277 | return -1; |
| 278 | } |
| 279 | else if (pid > 0) |
| 280 | { |
| 281 | waitpid(pid, &status, 0); |
Adriana Kobylak | 596466b | 2018-02-13 14:48:53 -0600 | [diff] [blame] | 282 | if (WEXITSTATUS(status)) |
| 283 | { |
Patrick Williams | c9bb642 | 2021-08-27 06:18:35 -0500 | [diff] [blame] | 284 | error("Failed ({STATUS}) to untar file {PATH}", "STATUS", status, |
| 285 | "PATH", tarFilePath); |
Adriana Kobylak | 596466b | 2018-02-13 14:48:53 -0600 | [diff] [blame] | 286 | report<UnTarFailure>(UnTarFail::PATH(tarFilePath.c_str())); |
| 287 | return -1; |
| 288 | } |
Gunnar Mills | 19e4ce5 | 2017-04-27 11:24:19 -0500 | [diff] [blame] | 289 | } |
| 290 | else |
| 291 | { |
Patrick Williams | c9bb642 | 2021-08-27 06:18:35 -0500 | [diff] [blame] | 292 | error("fork() failed: {ERRNO}", "ERRNO", errno); |
Gunnar Mills | b30cadd | 2017-10-06 16:07:32 -0500 | [diff] [blame] | 293 | report<UnTarFailure>(UnTarFail::PATH(tarFilePath.c_str())); |
Gunnar Mills | 19e4ce5 | 2017-04-27 11:24:19 -0500 | [diff] [blame] | 294 | return -1; |
| 295 | } |
| 296 | |
| 297 | return 0; |
| 298 | } |
Gunnar Mills | 3027bba | 2017-04-27 15:49:03 -0500 | [diff] [blame] | 299 | |
Gunnar Mills | e91d321 | 2017-04-19 15:42:47 -0500 | [diff] [blame] | 300 | } // namespace manager |
| 301 | } // namespace software |
Gunnar Mills | fa34e02 | 2018-09-04 10:05:45 -0500 | [diff] [blame] | 302 | } // namespace phosphor |