mirror of
https://github.com/ipmitool/ipmitool.git
synced 2025-05-10 18:47:22 +00:00
fru: Fix processing of unspecified board mfg. date
FRU board mfg. date uses a different value for 'unspecified' timestamp than the general IPMI specification. This commit makes ekanalyzer and fru commands process unspecified FRU dates properly, displaying 'Unspecified' instead of 'Mon Jan 1 03:00:00 1996'. Resolves ipmitool/ipmitool#57 Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
This commit is contained in:
parent
576d4855d9
commit
a4c1040420
@ -36,6 +36,7 @@
|
|||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <ipmitool/ipmi.h>
|
#include <ipmitool/ipmi.h>
|
||||||
#include <ipmitool/ipmi_sdr.h>
|
#include <ipmitool/ipmi_sdr.h>
|
||||||
|
#include <ipmitool/ipmi_time.h>
|
||||||
|
|
||||||
#if HAVE_CONFIG_H
|
#if HAVE_CONFIG_H
|
||||||
# include <config.h>
|
# include <config.h>
|
||||||
@ -591,9 +592,21 @@ struct fru_picmgext_amc_link_desc_record {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* FRU Board manufacturing date */
|
/* FRU Board manufacturing date */
|
||||||
|
#define FRU_BOARD_DATE_UNSPEC 0 /* IPMI FRU Information Storage Definition
|
||||||
|
v1.0 rev 1.3, Table 11-1 */
|
||||||
static inline time_t ipmi_fru2time_t(void *mfg_date) {
|
static inline time_t ipmi_fru2time_t(void *mfg_date) {
|
||||||
const uint64_t secs_from_1970_1996 = 820454400;
|
const uint64_t secs_from_1970_1996 = 820454400;
|
||||||
return ipmi24toh(mfg_date) * 60 + secs_from_1970_1996;
|
uint32_t fru_ts = ipmi24toh(mfg_date);
|
||||||
|
time_t ts;
|
||||||
|
|
||||||
|
if (FRU_BOARD_DATE_UNSPEC == fru_ts) {
|
||||||
|
ts = IPMI_TIME_UNSPECIFIED;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ts = fru_ts * 60 + secs_from_1970_1996;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ts;
|
||||||
}
|
}
|
||||||
static const char * chassis_type_desc[] __attribute__((unused)) = {
|
static const char * chassis_type_desc[] __attribute__((unused)) = {
|
||||||
"Unspecified", "Other", "Unknown",
|
"Unspecified", "Other", "Unknown",
|
||||||
|
@ -2546,7 +2546,11 @@ ipmi_ek_display_fru_header_detail(char *filename)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ts = ipmi_fru2time_t(mfg_date);
|
ts = ipmi_fru2time_t(mfg_date);
|
||||||
printf("Board Mfg Date: %ld, %s\n", ts, ipmi_timestamp_numeric(ts));
|
printf("Board Mfg Date: %ld, %s\n",
|
||||||
|
(IPMI_TIME_UNSPECIFIED == ts)
|
||||||
|
? FRU_BOARD_DATE_UNSPEC
|
||||||
|
: ts,
|
||||||
|
ipmi_timestamp_numeric(ts));
|
||||||
board_length -= SIZE_MFG_DATE;
|
board_length -= SIZE_MFG_DATE;
|
||||||
|
|
||||||
/* Board Mfg */
|
/* Board Mfg */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user