SYSEVENT_GET_CLASS_NAME(3SYSEVENT) System Event Library Functions SYSEVENT_GET_CLASS_NAME(3SYSEVENT)

sysevent_get_class_name, sysevent_get_subclass_name, sysevent_get_size, sysevent_get_seq, sysevent_get_time - get class name, subclass name, ID or buffer size of event

cc [flag...]  file... -lsysevent [library...]
#include <libsysevent.h>
char *sysevent_get_class_name(sysevent_t *ev);

char *sysevent_get_subclass_name(sysevent_t *ev);

int sysevent_get_size(sysevent_t *ev);

uint64_t sysevent_get_seq(sysevent_t *ev);

void sysevent_get_time(sysevent_t *ev, hrtime_t *etimep);

ev
handle to event

etimep

pointer to high resolution event time variable

The sysevent_get_class_name() and sysevent_get_subclass_name() functions return, respectively, the class and subclass names for the provided event ev.

The sysevent_get_size() function returns the size of the event buffer, ev.

The sysevent_get_seq() function returns a unique event sequence number of event ev. The sequence number is reset on every system boot.

The sysevent_get_time() function writes the time the event was published into the variable pointed to by etimep. The event time is added to the event just before it is put into the kernel internal event queue.

Example 1 Parse sysevent header information.

The following example parses sysevent header information from an application's event handler.


hrtime_t last_ev_time;
unit64_t last_ev_seq;
void
event_handler(sysevent_t *ev)
{
         sysevent_t *new_ev;
         int ev_sz;
         hrtime_t ev_time;
         uint64_t ev_seq;
         /* Filter on class and subclass */
         if (strcmp(EC_PRIV, sysevent_get_class_name(ev)) != 0) {
                 return;
         } else if (strcmp("ESC_MYSUBCLASS,
             sysevent_get_subclass_name(ev)) != 0) {
                 return;
         }
         /*
          * Check for replayed sysevent, time must
          * be greater than previously recorded.
          */
         sysevent_get_event_time(ev, &ev_time);
         ev_seq = sysevent_get_seq(ev);
         if (ev_time < last_ev_time ||
             (ev_time == last_ev_time && ev_seq <=
             last_ev_seq)) {
                 return;
         }
         last_ev_time = ev_time;
         last_ev_seq = ev_seq;
         /* Store event for later processing */
         ev_sz = sysevent_get_size(ev):
         new_ev (sysevent_t *)malloc(ev_sz);
         bcopy(ev, new_ev, ev_sz);
         queue_event(new_ev);
}

See attributes(7) for descriptions of the following attributes:

ATTRIBUTE TYPE ATTRIBUTE VALUE
Interface Stability Committed
MT-Level MT-Safe

attributes(7)

The libsysevent interfaces do not work at all in non-global zones.

July 24, 2009 OmniOS