94 lines
2.9 KiB
Diff
Executable File
94 lines
2.9 KiB
Diff
Executable File
From fdcfa9e7ff6eb31fe77cd4032d202bb8f1a50f37 Mon Sep 17 00:00:00 2001
|
|
From: roly <Rolyli.Li@luxshare-ict.com>
|
|
Date: Thu, 21 Nov 2024 18:23:00 +0800
|
|
Subject: [PATCH] ipmi cmd support set sel time utc offset
|
|
|
|
---
|
|
storagehandler.cpp | 63 ++++++++++++++++++++++++++++++++++++++++++++++
|
|
1 file changed, 63 insertions(+)
|
|
|
|
diff --git a/storagehandler.cpp b/storagehandler.cpp
|
|
index 4fef019..67d76ea 100644
|
|
--- a/storagehandler.cpp
|
|
+++ b/storagehandler.cpp
|
|
@@ -696,6 +696,63 @@ ipmi::RspType<int16_t> ipmiStorageGetSelTimeUtcOffset()
|
|
return ipmi::responseSuccess(timeEquation);
|
|
}
|
|
|
|
+/** @brief implements the Set SEL timezone command
|
|
+ * @returns IPMI completion code plus response data
|
|
+ * -current timezone
|
|
+ */
|
|
+ipmi::RspType<> ipmiStorageSetSelTimeUtcOffset(int16_t UTCOffset)
|
|
+{
|
|
+ int hrs = 0;
|
|
+ char ZoneInfoFile[128] = {0}, file[32] = {0};
|
|
+ static constexpr int16_t SEL_UTC_MAX_RANGE = 1440;
|
|
+ static constexpr int16_t SEL_UTC_MIN_RANGE = -1440;
|
|
+ static constexpr int16_t UNSPECIFIED_UTC_OFFSET = 0x7ff;
|
|
+ constexpr auto LOCALTIME = "/etc/localtime";
|
|
+
|
|
+ if (((UTCOffset > SEL_UTC_MAX_RANGE ) || (UTCOffset < SEL_UTC_MIN_RANGE) || (UTCOffset % 60 != 0)) && UTCOffset != UNSPECIFIED_UTC_OFFSET)
|
|
+ {
|
|
+ return ipmi::responseParmOutOfRange();
|
|
+ }
|
|
+
|
|
+ hrs = UTCOffset / 60;
|
|
+ if(UTCOffset == UNSPECIFIED_UTC_OFFSET)
|
|
+ {
|
|
+ hrs = 0;
|
|
+ }
|
|
+
|
|
+ if (0 > UTCOffset)
|
|
+ {
|
|
+ if (snprintf(file,sizeof(file), "GMT+%d", -hrs) >= (long int)sizeof(file))
|
|
+ {
|
|
+ return ipmi::responseUnspecifiedError();
|
|
+ }
|
|
+ }
|
|
+ else
|
|
+ {
|
|
+ if (snprintf(file,sizeof(file), "GMT-%d", hrs) >= (long int)sizeof(file))
|
|
+ {
|
|
+ return ipmi::responseUnspecifiedError();
|
|
+ }
|
|
+ }
|
|
+
|
|
+ if (snprintf (ZoneInfoFile, sizeof(ZoneInfoFile), "%s/%s", "/usr/share/zoneinfo/Etc", file) >= (long int)sizeof(ZoneInfoFile))
|
|
+ {
|
|
+ return ipmi::responseUnspecifiedError();
|
|
+ }
|
|
+
|
|
+ if((0 > unlink(LOCALTIME)) && errno != ENOENT)
|
|
+ {
|
|
+ return ipmi::responseUnspecifiedError();
|
|
+ }
|
|
+
|
|
+ if(symlink(ZoneInfoFile, LOCALTIME) < 0)
|
|
+ {
|
|
+ return ipmi::responseUnspecifiedError();
|
|
+ }
|
|
+
|
|
+ return ipmi::responseSuccess();
|
|
+}
|
|
+
|
|
/** @brief implements the reserve SEL command
|
|
* @returns IPMI completion code plus response data
|
|
* - SEL reservation ID.
|
|
@@ -952,6 +1009,12 @@ void register_netfn_storage_functions()
|
|
ipmi::Privilege::User,
|
|
ipmiStorageGetSelTimeUtcOffset);
|
|
|
|
+ // <Set SEL Timezone>
|
|
+ ipmi::registerHandler(ipmi::prioOpenBmcBase, ipmi::netFnStorage,
|
|
+ ipmi::storage::cmdSetSelTimeUtcOffset,
|
|
+ ipmi::Privilege::Operator,
|
|
+ ipmiStorageSetSelTimeUtcOffset);
|
|
+
|
|
// <Get SEL Entry>
|
|
ipmi_register_callback(NETFUN_STORAGE, IPMI_CMD_GET_SEL_ENTRY, NULL,
|
|
getSELEntry, PRIVILEGE_USER);
|
|
--
|
|
2.25.1
|
|
|