Go to main content

man pages section 3: Extended Library Functions, Volume 4

Exit Print View

Updated: Thursday, June 13, 2019
 
 

sysevent_get_size(3SYSEVENT)

Name

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

Synopsis

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);

Parameters

ev

handle to event

etimep

pointer to high resolution event time variable

Description

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.

Examples

Example 1 Parse sysevent header information.

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

hrtime_t last_ev_time;
uint64_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);
}

Attributes

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

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

See Also

attributes(7)

Notes

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