Ejemplo n.º 1
0
// Add a new entry in to SEL log
// IPMI/Section 31.6
int
sel_add_entry(sel_msg_t *msg, int *rec_id) {
  // If the SEL if full, roll over. To keep track of empty condition, use
  // one empty location less than the max records.
  if (sel_num_entries() == SEL_RECORDS_MAX) {
      syslog(LOG_ALERT, "sel_add_entry: SEL rollover\n");
    if (++g_sel_hdr.begin > SEL_INDEX_MAX) {
      g_sel_hdr.begin = SEL_INDEX_MIN;
    }
  }

  // Update message's time stamp starting at byte 4
  time_stamp_fill(&msg->msg[3]);

  // Add the enry at end
  memcpy(g_sel_data[g_sel_hdr.end].msg, msg->msg, sizeof(sel_msg_t));

  // Return the newly added record ID
  *rec_id = g_sel_hdr.end+1;

  if (file_store_sel_data(*rec_id, msg)) {
    syslog(LOG_ALERT, "sel_add_entry: file_store_sel_data\n");
    return -1;
  }

  // Increment the end pointer
  if (++g_sel_hdr.end > SEL_INDEX_MAX) {
    g_sel_hdr.end = SEL_INDEX_MIN;
  }

  // Update timestamp for add in header
  time_stamp_fill(g_sel_hdr.ts_add.ts);

  // Store the structure persistently
  if (file_store_sel_hdr()) {
    syslog(LOG_ALERT, "sel_add_entry: file_store_sel_hdr\n");
    return -1;
  }

  return 0;
}
Ejemplo n.º 2
0
static void
storage_get_sel_time (unsigned char *response, unsigned char *res_len)
{
  ipmi_res_t *res = (ipmi_res_t *) response;

  res->cc = CC_SUCCESS;

  time_stamp_fill(res->data);

  *res_len = SIZE_TIME_STAMP;

  return;
}
Ejemplo n.º 3
0
// Erase the SEL completely
// IPMI/Section 31.9
// Note: To reduce wear/tear, instead of erasing, manipulating the metadata
int
sel_erase(int rsv_id) {
  if (rsv_id != g_rsv_id) {
    return -1;
  }

  // Erase SEL Logs
  g_sel_hdr.begin = SEL_INDEX_MIN;
  g_sel_hdr.end = SEL_INDEX_MIN;

  // Update timestamp for erase in header
  time_stamp_fill(g_sel_hdr.ts_erase.ts);

  // Store the structure persistently
  if (file_store_sel_hdr()) {
    syslog(LOG_ALERT, "sel_erase: file_store_sel_hdr\n");
    return -1;
  }

  return 0;
}