Fixed byte swapped esel log name so logs are saved
diff --git a/oemhandler.C b/oemhandler.C
index c62958d..c19d9ce 100644
--- a/oemhandler.C
+++ b/oemhandler.C
@@ -25,22 +25,29 @@
// storage. Likely via the ipmi add_sel command.
///////////////////////////////////////////////////////////////////////////////
ipmi_ret_t ipmi_ibm_oem_partial_esel(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
- ipmi_request_t request, ipmi_response_t response,
- ipmi_data_len_t data_len, ipmi_context_t context)
+ ipmi_request_t request, ipmi_response_t response,
+ ipmi_data_len_t data_len, ipmi_context_t context)
{
esel_request_t *reqptr = (esel_request_t*) request;
FILE *fp;
- short offset = 0;
+ short recid, offset = 0;
uint8_t rlen;
ipmi_ret_t rc = IPMI_CC_OK;
char string[64];
const char *pio;
-
+ recid = LSMSSWAP(reqptr->selrecordls, reqptr->selrecordms);
offset = LSMSSWAP(reqptr->offsetls, reqptr->offsetms);
- snprintf(string, sizeof(string), "%s%s%02x%02x", g_esel_path, "esel", reqptr->selrecordms, reqptr->selrecordls);
-
+ if (!recid && !offset) {
+ // OpenPOWER Host Interface spec says if RecordID and Offset are
+ // 0 then then this is a new request
+ pio = "wb";
+ snprintf(string, sizeof(string), "%s%s%02x%02x", g_esel_path, "esel", (g_record_id&0xFF00>>8), (g_record_id&0xFF));
+ } else {
+ pio = "rb+";
+ snprintf(string, sizeof(string), "%s%s%02x%02x", g_esel_path, "esel", reqptr->selrecordms, reqptr->selrecordls);
+ }
// Length is the number of request bytes minus the header itself.
// The header contains an extra byte to indicate the start of
@@ -53,26 +60,13 @@
string, offset, rlen);
- // Rules state for a Partial eSel that the first write of a
- // new esel will be the sensor data record. We will use that
- // to indicate this is a new record rather then an ofset in
- // my next commit TODO
- if (offset == 0) {
- pio = "wb";
- } else {
- pio = "rb+";
- }
-
if ((fp = fopen(string, pio)) != NULL) {
fseek(fp, offset, SEEK_SET);
fwrite(reqptr+1,rlen,1,fp);
fclose(fp);
-
*data_len = sizeof(g_record_id);
memcpy(response, &g_record_id, *data_len);
-
-
} else {
fprintf(stderr, "Error trying to perform %s for esel%s\n",pio, string);
rc = IPMI_CC_INVALID;