Ratan Gupta | 0b77cfa | 2017-01-31 17:32:31 +0530 | [diff] [blame] | 1 | #include <exception> |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 2 | #include <vector> |
| 3 | #include <stdlib.h> |
| 4 | #include <dlfcn.h> |
| 5 | #include <errno.h> |
| 6 | #include <stdio.h> |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 7 | #include <systemd/sd-bus.h> |
Chris Austen | b45c4cb | 2015-11-01 06:34:56 -0600 | [diff] [blame] | 8 | #include <unistd.h> |
vishwa | 13555bd | 2015-11-10 12:10:38 -0600 | [diff] [blame] | 9 | #include <host-ipmid/ipmid-api.h> |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 10 | #include <iostream> |
| 11 | #include <memory> |
| 12 | #include <algorithm> |
| 13 | #include <fstream> |
Yi Li | 75c2d46 | 2016-04-11 16:57:46 +0800 | [diff] [blame] | 14 | #include <sstream> |
Brad Bishop | de6a379 | 2016-07-25 17:09:12 -0400 | [diff] [blame] | 15 | #include <mapper.h> |
Deepak Kodihalli | 788bd1f | 2017-02-20 01:21:59 -0600 | [diff] [blame] | 16 | #include "types.hpp" |
Ratan Gupta | 19c617b | 2017-02-10 15:39:40 +0530 | [diff] [blame] | 17 | #include "frup.hpp" |
Matthew Barth | 155c34f | 2016-10-18 14:33:17 -0500 | [diff] [blame] | 18 | #include "fru-area.hpp" |
Ratan Gupta | 0b77cfa | 2017-01-31 17:32:31 +0530 | [diff] [blame] | 19 | #include <sdbusplus/server.hpp> |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 20 | |
Deepak Kodihalli | 788bd1f | 2017-02-20 01:21:59 -0600 | [diff] [blame] | 21 | using namespace ipmi::vpd; |
| 22 | |
Ratan Gupta | cb0d4e5 | 2016-12-22 19:05:57 +0530 | [diff] [blame] | 23 | extern const FruMap frus; |
Deepak Kodihalli | 788bd1f | 2017-02-20 01:21:59 -0600 | [diff] [blame] | 24 | extern const std::map<Path, InterfaceMap> extras; |
Ratan Gupta | cb0d4e5 | 2016-12-22 19:05:57 +0530 | [diff] [blame] | 25 | |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 26 | //---------------------------------------------------------------- |
| 27 | // Constructor |
| 28 | //---------------------------------------------------------------- |
| 29 | ipmi_fru::ipmi_fru(const uint8_t fruid, const ipmi_fru_area_type type, |
| 30 | sd_bus *bus_type, bool bmc_fru) |
| 31 | { |
| 32 | iv_fruid = fruid; |
| 33 | iv_type = type; |
| 34 | iv_bmc_fru = bmc_fru; |
| 35 | iv_bus_type = bus_type; |
| 36 | iv_valid = false; |
| 37 | iv_data = NULL; |
| 38 | iv_present = false; |
| 39 | |
| 40 | if(iv_type == IPMI_FRU_AREA_INTERNAL_USE) |
| 41 | { |
| 42 | iv_name = "INTERNAL_"; |
| 43 | } |
| 44 | else if(iv_type == IPMI_FRU_AREA_CHASSIS_INFO) |
| 45 | { |
| 46 | iv_name = "CHASSIS_"; |
| 47 | } |
| 48 | else if(iv_type == IPMI_FRU_AREA_BOARD_INFO) |
| 49 | { |
| 50 | iv_name = "BOARD_"; |
| 51 | } |
| 52 | else if(iv_type == IPMI_FRU_AREA_PRODUCT_INFO) |
| 53 | { |
| 54 | iv_name = "PRODUCT_"; |
| 55 | } |
| 56 | else if(iv_type == IPMI_FRU_AREA_MULTI_RECORD) |
| 57 | { |
| 58 | iv_name = "MULTI_"; |
| 59 | } |
| 60 | else |
| 61 | { |
| 62 | iv_name = IPMI_FRU_AREA_TYPE_MAX; |
| 63 | fprintf(stderr, "ERROR: Invalid Area type :[%d]\n",iv_type); |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | //----------------------------------------------------- |
| 68 | // For a FRU area type, accepts the data and updates |
| 69 | // area specific data. |
| 70 | //----------------------------------------------------- |
| 71 | void ipmi_fru::set_data(const uint8_t *data, const size_t len) |
| 72 | { |
| 73 | iv_len = len; |
| 74 | iv_data = new uint8_t[len]; |
| 75 | memcpy(iv_data, data, len); |
| 76 | } |
| 77 | |
| 78 | //----------------------------------------------------- |
| 79 | // Sets the dbus parameters |
| 80 | //----------------------------------------------------- |
| 81 | void ipmi_fru::update_dbus_paths(const char *bus_name, |
| 82 | const char *obj_path, const char *intf_name) |
| 83 | { |
| 84 | iv_bus_name = bus_name; |
| 85 | iv_obj_path = obj_path; |
| 86 | iv_intf_name = intf_name; |
| 87 | } |
| 88 | |
| 89 | //------------------- |
| 90 | // Destructor |
| 91 | //------------------- |
| 92 | ipmi_fru::~ipmi_fru() |
| 93 | { |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 94 | if(iv_data != NULL) |
| 95 | { |
| 96 | delete [] iv_data; |
| 97 | iv_data = NULL; |
| 98 | } |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 99 | } |
| 100 | |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 101 | //------------------------------------------------ |
vishwa | f3ca352 | 2015-12-02 10:35:13 -0600 | [diff] [blame] | 102 | // Takes the pointer to stream of bytes and length |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 103 | // and returns the 8 bit checksum |
| 104 | // This algo is per IPMI V2.0 spec |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 105 | //------------------------------------------------- |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 106 | unsigned char calculate_crc(const unsigned char *data, size_t len) |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 107 | { |
| 108 | char crc = 0; |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 109 | size_t byte = 0; |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 110 | |
| 111 | for(byte = 0; byte < len; byte++) |
| 112 | { |
| 113 | crc += *data++; |
| 114 | } |
vishwa | f3ca352 | 2015-12-02 10:35:13 -0600 | [diff] [blame] | 115 | |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 116 | return(-crc); |
| 117 | } |
| 118 | |
| 119 | //--------------------------------------------------------------------- |
| 120 | // Accepts a fru area offset in commom hdr and tells which area it is. |
| 121 | //--------------------------------------------------------------------- |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 122 | ipmi_fru_area_type get_fru_area_type(uint8_t area_offset) |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 123 | { |
| 124 | ipmi_fru_area_type type = IPMI_FRU_AREA_TYPE_MAX; |
| 125 | |
| 126 | switch(area_offset) |
| 127 | { |
| 128 | case IPMI_FRU_INTERNAL_OFFSET: |
| 129 | type = IPMI_FRU_AREA_INTERNAL_USE; |
| 130 | break; |
| 131 | |
| 132 | case IPMI_FRU_CHASSIS_OFFSET: |
| 133 | type = IPMI_FRU_AREA_CHASSIS_INFO; |
| 134 | break; |
| 135 | |
| 136 | case IPMI_FRU_BOARD_OFFSET: |
| 137 | type = IPMI_FRU_AREA_BOARD_INFO; |
| 138 | break; |
| 139 | |
| 140 | case IPMI_FRU_PRODUCT_OFFSET: |
| 141 | type = IPMI_FRU_AREA_PRODUCT_INFO; |
| 142 | break; |
| 143 | |
| 144 | case IPMI_FRU_MULTI_OFFSET: |
| 145 | type = IPMI_FRU_AREA_MULTI_RECORD; |
| 146 | break; |
| 147 | |
| 148 | default: |
| 149 | type = IPMI_FRU_AREA_TYPE_MAX; |
| 150 | } |
| 151 | |
| 152 | return type; |
| 153 | } |
| 154 | |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 155 | ///----------------------------------------------- |
| 156 | // Validates the data for crc and mandatory fields |
| 157 | ///----------------------------------------------- |
| 158 | int verify_fru_data(const uint8_t *data, const size_t len) |
| 159 | { |
| 160 | uint8_t checksum = 0; |
| 161 | int rc = -1; |
| 162 | |
| 163 | // Validate for first byte to always have a value of [1] |
| 164 | if(data[0] != IPMI_FRU_HDR_BYTE_ZERO) |
| 165 | { |
| 166 | fprintf(stderr, "Invalid entry:[%d] in byte-0\n",data[0]); |
| 167 | return rc; |
| 168 | } |
| 169 | #ifdef __IPMI_DEBUG__ |
| 170 | else |
| 171 | { |
| 172 | printf("SUCCESS: Validated [0x%X] in entry_1 of fru_data\n",data[0]); |
| 173 | } |
| 174 | #endif |
| 175 | |
| 176 | // See if the calculated CRC matches with the embedded one. |
| 177 | // CRC to be calculated on all except the last one that is CRC itself. |
| 178 | checksum = calculate_crc(data, len - 1); |
| 179 | if(checksum != data[len-1]) |
| 180 | { |
| 181 | #ifdef __IPMI_DEBUG__ |
| 182 | fprintf(stderr, "Checksum mismatch." |
| 183 | " Calculated:[0x%X], Embedded:[0x%X]\n", |
| 184 | checksum, data[len]); |
| 185 | #endif |
| 186 | return rc; |
| 187 | } |
| 188 | #ifdef __IPMI_DEBUG__ |
| 189 | else |
| 190 | { |
| 191 | printf("SUCCESS: Checksum matches:[0x%X]\n",checksum); |
| 192 | } |
| 193 | #endif |
| 194 | |
| 195 | return EXIT_SUCCESS; |
| 196 | } |
| 197 | |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 198 | //------------------------------------------------------------------------ |
Ratan Gupta | cb0d4e5 | 2016-12-22 19:05:57 +0530 | [diff] [blame] | 199 | // Gets the value of the key from the fru dictionary of the given section. |
| 200 | // FRU dictionary is parsed fru data for all the sections. |
| 201 | //------------------------------------------------------------------------ |
| 202 | |
| 203 | std::string getFRUValue(const std::string& section, |
| 204 | const std::string& key, |
Ratan Gupta | cdde23d | 2017-02-15 09:29:54 +0530 | [diff] [blame] | 205 | const std::string& delimiter, |
Ratan Gupta | cb0d4e5 | 2016-12-22 19:05:57 +0530 | [diff] [blame] | 206 | IPMIFruInfo& fruData) |
| 207 | { |
| 208 | |
| 209 | auto minIndexValue = 0; |
| 210 | auto maxIndexValue = 0; |
| 211 | std::string fruValue = ""; |
| 212 | if (section == "Board") |
| 213 | { |
| 214 | minIndexValue = OPENBMC_VPD_KEY_BOARD_MFG_DATE; |
| 215 | maxIndexValue = OPENBMC_VPD_KEY_BOARD_MAX; |
| 216 | } |
| 217 | else if (section == "Product") |
| 218 | { |
| 219 | minIndexValue = OPENBMC_VPD_KEY_PRODUCT_MFR; |
| 220 | maxIndexValue = OPENBMC_VPD_KEY_PRODUCT_MAX; |
| 221 | |
| 222 | } |
| 223 | else if (section == "Chassis") |
| 224 | { |
| 225 | minIndexValue = OPENBMC_VPD_KEY_CHASSIS_TYPE; |
| 226 | maxIndexValue = OPENBMC_VPD_KEY_CHASSIS_MAX; |
| 227 | } |
| 228 | |
| 229 | auto first = fruData.cbegin() + minIndexValue; |
| 230 | auto last = first + (maxIndexValue - minIndexValue) + 1; |
| 231 | |
| 232 | auto itr = std::find_if(first, last, |
| 233 | [&key](auto& e){ return key == e.first; }); |
| 234 | |
| 235 | if (itr != last) |
| 236 | { |
| 237 | fruValue = itr->second; |
| 238 | } |
Ratan Gupta | cdde23d | 2017-02-15 09:29:54 +0530 | [diff] [blame] | 239 | |
| 240 | //if the key is custom property then the value could be in two formats. |
| 241 | //1) custom field 2 = "value". |
| 242 | //2) custom field 2 = "key:value". |
| 243 | //if delimeter length = 0 i.e custom field 2 = "value" |
| 244 | |
| 245 | constexpr auto customProp = "Custom Field"; |
| 246 | if (key.find(customProp) != std::string::npos) |
| 247 | { |
| 248 | if (delimiter.length() > 0) |
| 249 | { |
| 250 | size_t delimiterpos = fruValue.find(delimiter); |
| 251 | if (delimiterpos != std::string::npos) |
| 252 | fruValue = fruValue.substr(delimiterpos + 1); |
| 253 | } |
| 254 | } |
Ratan Gupta | cb0d4e5 | 2016-12-22 19:05:57 +0530 | [diff] [blame] | 255 | return fruValue; |
| 256 | |
| 257 | } |
Ratan Gupta | 0b77cfa | 2017-01-31 17:32:31 +0530 | [diff] [blame] | 258 | //Get the inventory service from the mapper. |
| 259 | auto getService(sdbusplus::bus::bus& bus, |
| 260 | const std::string& intf, |
| 261 | const std::string& path) |
Ratan Gupta | cb0d4e5 | 2016-12-22 19:05:57 +0530 | [diff] [blame] | 262 | { |
Ratan Gupta | 0b77cfa | 2017-01-31 17:32:31 +0530 | [diff] [blame] | 263 | auto mapperCall = bus.new_method_call( |
| 264 | "xyz.openbmc_project.ObjectMapper", |
Leonel Gonzalez | c0e5134 | 2017-03-16 13:47:44 -0500 | [diff] [blame] | 265 | "/xyz/openbmc_project/object_mapper", |
Ratan Gupta | 0b77cfa | 2017-01-31 17:32:31 +0530 | [diff] [blame] | 266 | "xyz.openbmc_project.ObjectMapper", |
| 267 | "GetObject"); |
| 268 | |
| 269 | mapperCall.append(path); |
| 270 | mapperCall.append(std::vector<std::string>({intf})); |
| 271 | |
| 272 | auto mapperResponseMsg = bus.call(mapperCall); |
| 273 | if (mapperResponseMsg.is_method_error()) |
Ratan Gupta | cb0d4e5 | 2016-12-22 19:05:57 +0530 | [diff] [blame] | 274 | { |
Ratan Gupta | 0b77cfa | 2017-01-31 17:32:31 +0530 | [diff] [blame] | 275 | throw std::runtime_error("ERROR in mapper call"); |
Ratan Gupta | cb0d4e5 | 2016-12-22 19:05:57 +0530 | [diff] [blame] | 276 | } |
Ratan Gupta | 0b77cfa | 2017-01-31 17:32:31 +0530 | [diff] [blame] | 277 | |
| 278 | std::map<std::string, std::vector<std::string>> mapperResponse; |
| 279 | mapperResponseMsg.read(mapperResponse); |
| 280 | |
| 281 | if (mapperResponse.begin() == mapperResponse.end()) |
| 282 | { |
| 283 | throw std::runtime_error("ERROR in reading the mapper response"); |
| 284 | } |
| 285 | |
| 286 | return mapperResponse.begin()->first; |
| 287 | } |
Ratan Gupta | cb0d4e5 | 2016-12-22 19:05:57 +0530 | [diff] [blame] | 288 | |
| 289 | //------------------------------------------------------------------------ |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 290 | // Takes FRU data, invokes Parser for each fru record area and updates |
| 291 | // Inventory |
| 292 | //------------------------------------------------------------------------ |
Patrick Williams | 21eb043 | 2017-03-31 11:40:48 -0500 | [diff] [blame] | 293 | int ipmi_update_inventory(fru_area_vec_t& area_vec, sd_bus* bus_sd) |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 294 | { |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 295 | // Generic error reporter |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 296 | int rc = 0; |
Ratan Gupta | cb0d4e5 | 2016-12-22 19:05:57 +0530 | [diff] [blame] | 297 | uint8_t fruid = 0; |
| 298 | IPMIFruInfo fruData; |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 299 | |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 300 | // For each FRU area, extract the needed data , get it parsed and update |
| 301 | // the Inventory. |
Ratan Gupta | cb0d4e5 | 2016-12-22 19:05:57 +0530 | [diff] [blame] | 302 | for (const auto& fruArea : area_vec) |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 303 | { |
Ratan Gupta | cb0d4e5 | 2016-12-22 19:05:57 +0530 | [diff] [blame] | 304 | fruid = fruArea->get_fruid(); |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 305 | // Fill the container with information |
Ratan Gupta | cb0d4e5 | 2016-12-22 19:05:57 +0530 | [diff] [blame] | 306 | rc = parse_fru_area((fruArea)->get_type(), (void*)(fruArea)->get_data(), |
| 307 | (fruArea)->get_len(), fruData); |
| 308 | if (rc < 0) |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 309 | { |
Ratan Gupta | cb0d4e5 | 2016-12-22 19:05:57 +0530 | [diff] [blame] | 310 | std::cerr << "ERROR parsing FRU records\n"; |
| 311 | return rc; |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 312 | } |
| 313 | } // END walking the vector of areas and updating |
| 314 | |
Ratan Gupta | cb0d4e5 | 2016-12-22 19:05:57 +0530 | [diff] [blame] | 315 | // For each Fru we have the list of instances which needs to be updated. |
| 316 | // Each instance object implements certain interfaces. |
| 317 | // Each Interface is having Dbus properties. |
| 318 | // Each Dbus Property would be having metaData(eg section,VpdPropertyName). |
| 319 | |
| 320 | // Here we are just printing the object,interface and the properties. |
| 321 | // which needs to be called with the new inventory manager implementation. |
Patrick Williams | 49a6fcd | 2017-04-18 11:49:07 -0500 | [diff] [blame] | 322 | sdbusplus::bus::bus bus{bus_sd}; |
Ratan Gupta | 0b77cfa | 2017-01-31 17:32:31 +0530 | [diff] [blame] | 323 | using namespace std::string_literals; |
| 324 | static const auto intf = "xyz.openbmc_project.Inventory.Manager"s; |
Brad Bishop | ec7648d | 2017-02-23 11:30:16 -0500 | [diff] [blame] | 325 | static const auto path = "/xyz/openbmc_project/inventory"s; |
Ratan Gupta | 0b77cfa | 2017-01-31 17:32:31 +0530 | [diff] [blame] | 326 | std::string service; |
| 327 | try |
| 328 | { |
| 329 | service = getService(bus,intf,path); |
| 330 | } |
| 331 | catch (const std::runtime_error& e) |
| 332 | { |
| 333 | std::cerr << e.what() << "\n"; |
| 334 | return -1; |
| 335 | } |
Ratan Gupta | 0b77cfa | 2017-01-31 17:32:31 +0530 | [diff] [blame] | 336 | |
Ratan Gupta | cb0d4e5 | 2016-12-22 19:05:57 +0530 | [diff] [blame] | 337 | auto iter = frus.find(fruid); |
| 338 | if (iter == frus.end()) |
| 339 | { |
Ratan Gupta | 0fc20ed | 2017-02-06 19:59:12 +0530 | [diff] [blame] | 340 | std::cerr << "ERROR Unable to get the fru info for FRU=" |
| 341 | << static_cast<int>(fruid) << "\n"; |
Ratan Gupta | cb0d4e5 | 2016-12-22 19:05:57 +0530 | [diff] [blame] | 342 | return -1; |
| 343 | } |
Ratan Gupta | cb0d4e5 | 2016-12-22 19:05:57 +0530 | [diff] [blame] | 344 | |
Ratan Gupta | 0b77cfa | 2017-01-31 17:32:31 +0530 | [diff] [blame] | 345 | auto& instanceList = iter->second; |
Ratan Gupta | cb0d4e5 | 2016-12-22 19:05:57 +0530 | [diff] [blame] | 346 | if (instanceList.size() <= 0) |
| 347 | { |
Ratan Gupta | 0fc20ed | 2017-02-06 19:59:12 +0530 | [diff] [blame] | 348 | std::cout << "Object List empty for this FRU=" |
| 349 | << static_cast<int>(fruid) << "\n"; |
Ratan Gupta | cb0d4e5 | 2016-12-22 19:05:57 +0530 | [diff] [blame] | 350 | } |
Ratan Gupta | 0fc20ed | 2017-02-06 19:59:12 +0530 | [diff] [blame] | 351 | |
| 352 | ObjectMap objects; |
Ratan Gupta | cb0d4e5 | 2016-12-22 19:05:57 +0530 | [diff] [blame] | 353 | for (auto& instance : instanceList) |
| 354 | { |
Ratan Gupta | 0fc20ed | 2017-02-06 19:59:12 +0530 | [diff] [blame] | 355 | InterfaceMap interfaces; |
Deepak Kodihalli | 788bd1f | 2017-02-20 01:21:59 -0600 | [diff] [blame] | 356 | const auto& extrasIter = extras.find(instance.first); |
Ratan Gupta | cb0d4e5 | 2016-12-22 19:05:57 +0530 | [diff] [blame] | 357 | |
| 358 | for (auto& interfaceList : instance.second) |
| 359 | { |
Ratan Gupta | 0fc20ed | 2017-02-06 19:59:12 +0530 | [diff] [blame] | 360 | PropertyMap props;//store all the properties |
Ratan Gupta | cb0d4e5 | 2016-12-22 19:05:57 +0530 | [diff] [blame] | 361 | for (auto& properties : interfaceList.second) |
| 362 | { |
Ratan Gupta | cdde23d | 2017-02-15 09:29:54 +0530 | [diff] [blame] | 363 | std::string section, property, delimiter, value; |
Ratan Gupta | cb0d4e5 | 2016-12-22 19:05:57 +0530 | [diff] [blame] | 364 | for (auto& info : properties.second) |
| 365 | { |
| 366 | if (info.first == "IPMIFruSection") |
| 367 | { |
| 368 | section = std::move(info.second); |
| 369 | } |
| 370 | if (info.first == "IPMIFruProperty") |
| 371 | { |
| 372 | property = std::move(info.second); |
| 373 | } |
Ratan Gupta | cdde23d | 2017-02-15 09:29:54 +0530 | [diff] [blame] | 374 | if (info.first == "IPMIFruValueDelimiter") |
| 375 | { |
| 376 | //Read the delimeter as ascii value |
| 377 | //convert it into char |
| 378 | if( info.second.length() > 0 ) |
| 379 | { |
| 380 | char dlm = ' '; |
| 381 | rc = sscanf(info.second.c_str(),"%hhd",&dlm); |
| 382 | if (rc > 0) |
| 383 | { |
| 384 | delimiter = std::string(1,dlm); |
| 385 | } |
| 386 | } |
| 387 | } |
| 388 | |
Ratan Gupta | cb0d4e5 | 2016-12-22 19:05:57 +0530 | [diff] [blame] | 389 | } |
| 390 | |
| 391 | if (!section.empty() && !property.empty()) |
| 392 | { |
Ratan Gupta | cdde23d | 2017-02-15 09:29:54 +0530 | [diff] [blame] | 393 | value = getFRUValue(section, property, delimiter, fruData); |
Ratan Gupta | cb0d4e5 | 2016-12-22 19:05:57 +0530 | [diff] [blame] | 394 | } |
Ratan Gupta | 0fc20ed | 2017-02-06 19:59:12 +0530 | [diff] [blame] | 395 | props.emplace(std::move(properties.first), std::move(value)); |
Ratan Gupta | cb0d4e5 | 2016-12-22 19:05:57 +0530 | [diff] [blame] | 396 | } |
Deepak Kodihalli | 788bd1f | 2017-02-20 01:21:59 -0600 | [diff] [blame] | 397 | // Check and update extra properties |
| 398 | if(extras.end() != extrasIter) |
| 399 | { |
| 400 | const auto& propsIter = |
| 401 | (extrasIter->second).find(interfaceList.first); |
| 402 | if((extrasIter->second).end() != propsIter) |
| 403 | { |
| 404 | for(const auto& map : propsIter->second) |
| 405 | { |
| 406 | props.emplace(map.first, map.second); |
| 407 | } |
| 408 | } |
| 409 | } |
| 410 | interfaces.emplace(std::move(interfaceList.first), |
| 411 | std::move(props)); |
Ratan Gupta | cb0d4e5 | 2016-12-22 19:05:57 +0530 | [diff] [blame] | 412 | } |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 413 | |
Deepak Kodihalli | 788bd1f | 2017-02-20 01:21:59 -0600 | [diff] [blame] | 414 | // Call the inventory manager |
Ratan Gupta | 0fc20ed | 2017-02-06 19:59:12 +0530 | [diff] [blame] | 415 | sdbusplus::message::object_path path = instance.first; |
Deepak Kodihalli | 788bd1f | 2017-02-20 01:21:59 -0600 | [diff] [blame] | 416 | // Check and update extra properties |
| 417 | if(extras.end() != extrasIter) |
| 418 | { |
| 419 | for(const auto& entry : extrasIter->second) |
| 420 | { |
| 421 | if(interfaces.end() == interfaces.find(entry.first)) |
| 422 | { |
| 423 | interfaces.emplace(entry.first, entry.second); |
| 424 | } |
| 425 | } |
| 426 | } |
Ratan Gupta | 0fc20ed | 2017-02-06 19:59:12 +0530 | [diff] [blame] | 427 | objects.emplace(path,interfaces); |
| 428 | } |
| 429 | |
| 430 | auto pimMsg = bus.new_method_call( |
| 431 | service.c_str(), |
| 432 | path.c_str(), |
| 433 | intf.c_str(), |
| 434 | "Notify"); |
| 435 | pimMsg.append(std::move(objects)); |
| 436 | auto inventoryMgrResponseMsg = bus.call(pimMsg); |
| 437 | if (inventoryMgrResponseMsg.is_method_error()) |
| 438 | { |
| 439 | std::cerr << "Error in notify call\n"; |
| 440 | return -1; |
Ratan Gupta | 0b77cfa | 2017-01-31 17:32:31 +0530 | [diff] [blame] | 441 | } |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 442 | return rc; |
| 443 | } |
| 444 | |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 445 | ///---------------------------------------------------- |
| 446 | // Checks if a particular fru area is populated or not |
| 447 | ///---------------------------------------------------- |
| 448 | bool remove_invalid_area(const std::unique_ptr<ipmi_fru> &fru_area) |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 449 | { |
Deepak Kodihalli | 89ededd | 2017-02-11 01:59:32 -0600 | [diff] [blame] | 450 | // Filter the ones that are empty |
| 451 | if(!(fru_area->get_len())) |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 452 | { |
| 453 | return true; |
| 454 | } |
| 455 | return false; |
| 456 | } |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 457 | |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 458 | ///---------------------------------------------------------------------------------- |
| 459 | // Populates various FRU areas |
| 460 | // @prereq : This must be called only after validating common header. |
| 461 | ///---------------------------------------------------------------------------------- |
| 462 | int ipmi_populate_fru_areas(uint8_t *fru_data, const size_t data_len, |
| 463 | fru_area_vec_t & fru_area_vec) |
| 464 | { |
vishwa | 13555bd | 2015-11-10 12:10:38 -0600 | [diff] [blame] | 465 | size_t area_offset = 0; |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 466 | int rc = -1; |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 467 | |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 468 | // Now walk the common header and see if the file size has atleast the last |
| 469 | // offset mentioned by the common_hdr. If the file size is less than the |
| 470 | // offset of any if the fru areas mentioned in the common header, then we do |
| 471 | // not have a complete file. |
| 472 | for(uint8_t fru_entry = IPMI_FRU_INTERNAL_OFFSET; |
| 473 | fru_entry < (sizeof(struct common_header) -2); fru_entry++) |
| 474 | { |
Yi Li | 75c2d46 | 2016-04-11 16:57:46 +0800 | [diff] [blame] | 475 | rc = -1; |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 476 | // Actual offset in the payload is the offset mentioned in common header |
| 477 | // multipled by 8. Common header is always the first 8 bytes. |
| 478 | area_offset = fru_data[fru_entry] * IPMI_EIGHT_BYTES; |
| 479 | if(area_offset && (data_len < (area_offset + 2))) |
| 480 | { |
| 481 | // Our file size is less than what it needs to be. +2 because we are |
| 482 | // using area len that is at 2 byte off area_offset |
Patrick Williams | 3365ec8 | 2016-08-17 17:45:18 -0500 | [diff] [blame] | 483 | fprintf(stderr, "fru file is incomplete. Size:[%zd]\n",data_len); |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 484 | return rc; |
| 485 | } |
| 486 | else if(area_offset) |
| 487 | { |
| 488 | // Read 2 bytes to know the actual size of area. |
| 489 | uint8_t area_hdr[2] = {0}; |
| 490 | memcpy(area_hdr, &((uint8_t *)fru_data)[area_offset], sizeof(area_hdr)); |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 491 | |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 492 | // Size of this area will be the 2nd byte in the fru area header. |
| 493 | size_t area_len = area_hdr[1] * IPMI_EIGHT_BYTES; |
| 494 | uint8_t area_data[area_len] = {0}; |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 495 | |
Patrick Williams | 3365ec8 | 2016-08-17 17:45:18 -0500 | [diff] [blame] | 496 | printf("fru data size:[%zd], area offset:[%zd], area_size:[%zd]\n", |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 497 | data_len, area_offset, area_len); |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 498 | |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 499 | // See if we really have that much buffer. We have area offset amd |
| 500 | // from there, the actual len. |
| 501 | if(data_len < (area_len + area_offset)) |
| 502 | { |
Patrick Williams | 3365ec8 | 2016-08-17 17:45:18 -0500 | [diff] [blame] | 503 | fprintf(stderr, "Incomplete Fru file.. Size:[%zd]\n",data_len); |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 504 | return rc; |
| 505 | } |
| 506 | |
| 507 | // Save off the data. |
| 508 | memcpy(area_data, &((uint8_t *)fru_data)[area_offset], area_len); |
| 509 | |
| 510 | // Validate the crc |
| 511 | rc = verify_fru_data(area_data, area_len); |
| 512 | if(rc < 0) |
| 513 | { |
Patrick Williams | 3365ec8 | 2016-08-17 17:45:18 -0500 | [diff] [blame] | 514 | fprintf(stderr, "Error validating fru area. offset:[%zd]\n",area_offset); |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 515 | return rc; |
| 516 | } |
| 517 | else |
| 518 | { |
Patrick Williams | 3365ec8 | 2016-08-17 17:45:18 -0500 | [diff] [blame] | 519 | printf("Successfully verified area checksum. offset:[%zd]\n",area_offset); |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 520 | } |
| 521 | |
| 522 | // We already have a vector that is passed to us containing all |
| 523 | // of the fields populated. Update the data portion now. |
| 524 | for(auto& iter : fru_area_vec) |
| 525 | { |
| 526 | if((iter)->get_type() == get_fru_area_type(fru_entry)) |
| 527 | { |
| 528 | (iter)->set_data(area_data, area_len); |
| 529 | } |
| 530 | } |
| 531 | } // If we have fru data present |
| 532 | } // Walk common_hdr |
| 533 | |
| 534 | // Not all the fields will be populated in a fru data. Mostly all cases will |
| 535 | // not have more than 2 or 3. |
| 536 | fru_area_vec.erase(std::remove_if(fru_area_vec.begin(), fru_area_vec.end(), |
| 537 | remove_invalid_area), fru_area_vec.end()); |
| 538 | |
| 539 | return EXIT_SUCCESS; |
| 540 | } |
| 541 | |
| 542 | ///--------------------------------------------------------- |
| 543 | // Validates the fru data per ipmi common header constructs. |
| 544 | // Returns with updated common_hdr and also file_size |
| 545 | //---------------------------------------------------------- |
| 546 | int ipmi_validate_common_hdr(const uint8_t *fru_data, const size_t data_len) |
| 547 | { |
| 548 | int rc = -1; |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 549 | |
| 550 | uint8_t common_hdr[sizeof(struct common_header)] = {0}; |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 551 | if(data_len >= sizeof(common_hdr)) |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 552 | { |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 553 | memcpy(common_hdr, fru_data, sizeof(common_hdr)); |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 554 | } |
| 555 | else |
| 556 | { |
Patrick Williams | 3365ec8 | 2016-08-17 17:45:18 -0500 | [diff] [blame] | 557 | fprintf(stderr, "Incomplete fru data file. Size:[%zd]\n", data_len); |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 558 | return rc; |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 559 | } |
| 560 | |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 561 | // Verify the crc and size |
| 562 | rc = verify_fru_data(common_hdr, sizeof(common_hdr)); |
| 563 | if(rc < 0) |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 564 | { |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 565 | fprintf(stderr, "Failed to validate common header\n"); |
| 566 | return rc; |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 567 | } |
| 568 | |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 569 | return EXIT_SUCCESS; |
| 570 | } |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 571 | |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 572 | //------------------------------------------------------------ |
| 573 | // Cleanup routine |
| 574 | //------------------------------------------------------------ |
| 575 | int cleanup_error(FILE *fru_fp, fru_area_vec_t & fru_area_vec) |
| 576 | { |
| 577 | if(fru_fp != NULL) |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 578 | { |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 579 | fclose(fru_fp); |
| 580 | fru_fp = NULL; |
| 581 | } |
vishwa | f3ca352 | 2015-12-02 10:35:13 -0600 | [diff] [blame] | 582 | |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 583 | if(!(fru_area_vec.empty())) |
| 584 | { |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 585 | fru_area_vec.clear(); |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 586 | } |
vishwa | f3ca352 | 2015-12-02 10:35:13 -0600 | [diff] [blame] | 587 | |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 588 | return -1; |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 589 | } |
| 590 | |
| 591 | ///----------------------------------------------------- |
| 592 | // Accepts the filename and validates per IPMI FRU spec |
| 593 | //---------------------------------------------------- |
vishwa | f3ca352 | 2015-12-02 10:35:13 -0600 | [diff] [blame] | 594 | int ipmi_validate_fru_area(const uint8_t fruid, const char *fru_file_name, |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 595 | sd_bus *bus_type, const bool bmc_fru) |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 596 | { |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 597 | size_t data_len = 0; |
| 598 | size_t bytes_read = 0; |
| 599 | int rc = -1; |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 600 | |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 601 | // Vector that holds individual IPMI FRU AREAs. Although MULTI and INTERNAL |
| 602 | // are not used, keeping it here for completeness. |
| 603 | fru_area_vec_t fru_area_vec; |
Yi Li | 75c2d46 | 2016-04-11 16:57:46 +0800 | [diff] [blame] | 604 | std::vector<std::string> defined_fru_area; |
| 605 | |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 606 | for(uint8_t fru_entry = IPMI_FRU_INTERNAL_OFFSET; |
| 607 | fru_entry < (sizeof(struct common_header) -2); fru_entry++) |
| 608 | { |
| 609 | // Create an object and push onto a vector. |
| 610 | std::unique_ptr<ipmi_fru> fru_area = std::make_unique<ipmi_fru> |
| 611 | (fruid, get_fru_area_type(fru_entry), bus_type, bmc_fru); |
| 612 | |
| 613 | // Physically being present |
vishwa | 2f5a3cf | 2016-05-30 02:25:21 -0500 | [diff] [blame] | 614 | bool present = access(fru_file_name, F_OK) == 0; |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 615 | fru_area->set_present(present); |
| 616 | |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 617 | fru_area_vec.emplace_back(std::move(fru_area)); |
| 618 | } |
| 619 | |
| 620 | FILE *fru_fp = fopen(fru_file_name,"rb"); |
| 621 | if(fru_fp == NULL) |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 622 | { |
| 623 | fprintf(stderr, "ERROR: opening:[%s]\n",fru_file_name); |
| 624 | perror("Error:"); |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 625 | return cleanup_error(fru_fp, fru_area_vec); |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 626 | } |
| 627 | |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 628 | // Get the size of the file to see if it meets minimum requirement |
| 629 | if(fseek(fru_fp, 0, SEEK_END)) |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 630 | { |
| 631 | perror("Error:"); |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 632 | return cleanup_error(fru_fp, fru_area_vec); |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 633 | } |
| 634 | |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 635 | // Allocate a buffer to hold entire file content |
| 636 | data_len = ftell(fru_fp); |
| 637 | uint8_t fru_data[data_len] = {0}; |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 638 | |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 639 | rewind(fru_fp); |
| 640 | bytes_read = fread(fru_data, data_len, 1, fru_fp); |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 641 | if(bytes_read != 1) |
| 642 | { |
Patrick Williams | 3365ec8 | 2016-08-17 17:45:18 -0500 | [diff] [blame] | 643 | fprintf(stderr, "Failed reading fru data. Bytes_read=[%zd]\n",bytes_read); |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 644 | perror("Error:"); |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 645 | return cleanup_error(fru_fp, fru_area_vec); |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 646 | } |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 647 | |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 648 | // We are done reading. |
| 649 | fclose(fru_fp); |
| 650 | fru_fp = NULL; |
| 651 | |
| 652 | rc = ipmi_validate_common_hdr(fru_data, data_len); |
vishwa | f3ca352 | 2015-12-02 10:35:13 -0600 | [diff] [blame] | 653 | if(rc < 0) |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 654 | { |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 655 | return cleanup_error(fru_fp, fru_area_vec); |
| 656 | } |
| 657 | |
| 658 | // Now that we validated the common header, populate various fru sections if we have them here. |
| 659 | rc = ipmi_populate_fru_areas(fru_data, data_len, fru_area_vec); |
| 660 | if(rc < 0) |
| 661 | { |
| 662 | fprintf(stderr,"Populating FRU areas failed for:[%d]\n",fruid); |
| 663 | return cleanup_error(fru_fp, fru_area_vec); |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 664 | } |
| 665 | else |
| 666 | { |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 667 | printf("SUCCESS: Populated FRU areas for:[%s]\n",fru_file_name); |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 668 | } |
| 669 | |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 670 | #ifdef __IPMI_DEBUG__ |
| 671 | for(auto& iter : fru_area_vec) |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 672 | { |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 673 | printf("FRU ID : [%d]\n",(iter)->get_fruid()); |
| 674 | printf("AREA NAME : [%s]\n",(iter)->get_name()); |
| 675 | printf("TYPE : [%d]\n",(iter)->get_type()); |
| 676 | printf("LEN : [%d]\n",(iter)->get_len()); |
| 677 | printf("BUS NAME : [%s]\n", (iter)->get_bus_name()); |
| 678 | printf("OBJ PATH : [%s]\n", (iter)->get_obj_path()); |
| 679 | printf("INTF NAME :[%s]\n", (iter)->get_intf_name()); |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 680 | } |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 681 | #endif |
| 682 | |
| 683 | // If the vector is populated with everything, then go ahead and update the |
| 684 | // inventory. |
| 685 | if(!(fru_area_vec.empty())) |
| 686 | { |
| 687 | |
| 688 | #ifdef __IPMI_DEBUG__ |
| 689 | printf("\n SIZE of vector is : [%d] \n",fru_area_vec.size()); |
| 690 | #endif |
Patrick Williams | 21eb043 | 2017-03-31 11:40:48 -0500 | [diff] [blame] | 691 | rc = ipmi_update_inventory(fru_area_vec, bus_type); |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 692 | if(rc <0) |
| 693 | { |
| 694 | fprintf(stderr, "Error updating inventory\n"); |
| 695 | } |
| 696 | } |
| 697 | |
| 698 | // we are done with all that we wanted to do. This will do the job of |
| 699 | // calling any destructors too. |
| 700 | fru_area_vec.clear(); |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 701 | |
| 702 | return rc; |
| 703 | } |