FreeBSD/sys/cddl/contrib/opensolaris/uts/common/os/fm.c
/*
 * Utility function to write all of the pending ereports to the dump device.
 * This function is called at either normal reboot or panic time, and simply
 * iterates over the in-transit messages in the ereport sysevent channel.
 */
Utility function to write all of the pending ereports to the dump device.
This function is called at either normal reboot or panic time, and simply
iterates over the in-transit messages in the ereport sysevent channel.
Utility function to write all of the pending ereports to the dump device . This function is called at either normal reboot or panic time and simply iterates over the in - transit messages in the ereport sysevent channel .
void
fm_ereport_dump(void)
{
	evchanq_t *chq;
	sysevent_t *sep;
	erpt_dump_t ed;
	timespec_t tod;
	hrtime_t now;
	char *buf;
	size_t len;
	if (panicstr) {
		tod = panic_hrestime;
		now = panic_hrtime;
	} else {
		if (ereport_errorq != NULL)
			errorq_drain(ereport_errorq);
		gethrestime(&tod);
		now = gethrtime_waitfree();
	}
	if ((chq = sysevent_evc_walk_init(ereport_chan, NULL)) == NULL &&
	    !panicstr)
		return; 
	while ((sep = sysevent_evc_walk_step(chq)) != NULL) {
		if ((buf = sysevent_evc_event_attr(sep, &len)) == NULL)
			break;
		ed.ed_magic = ERPT_MAGIC;
		ed.ed_chksum = checksum32(buf, len);
		ed.ed_size = (uint32_t)len;
		ed.ed_pad = 0;
		ed.ed_hrt_nsec = SE_TIME(sep);
		ed.ed_hrt_base = now;
		ed.ed_tod_base.sec = tod.tv_sec;
		ed.ed_tod_base.nsec = tod.tv_nsec;
		dumpvp_write(&ed, sizeof (ed));
		dumpvp_write(buf, len);
	}
	sysevent_evc_walk_fini(chq);
}
void fm_ereport_dump ( void ) { evchanq_t * chq ; sysevent_t * sep ; erpt_dump_t ed ; timespec_t tod ; hrtime_t now ; char * buf ; size_t len ; if ( panicstr ) { tod = panic_hrestime ; now = panic_hrtime ; } else { if ( ereport_errorq != NULL ) errorq_drain ( ereport_errorq ) ; gethrestime ( & tod ) ; now = gethrtime_waitfree ( ) ; } if ( ( chq = sysevent_evc_walk_init ( ereport_chan , NULL ) ) == NULL && ! panicstr ) return ; while ( ( sep = sysevent_evc_walk_step ( chq ) ) != NULL ) { if ( ( buf = sysevent_evc_event_attr ( sep , & len ) ) == NULL ) break ; ed . ed_magic = ERPT_MAGIC ; ed . ed_chksum = checksum32 ( buf , len ) ; ed . ed_size = ( uint32_t ) len ; ed . ed_pad = 0 ; ed . ed_hrt_nsec = SE_TIME ( sep ) ; ed . ed_hrt_base = now ; ed . ed_tod_base . sec = tod . tv_sec ; ed . ed_tod_base . nsec = tod . tv_nsec ; dumpvp_write ( & ed , sizeof ( ed ) ) ; dumpvp_write ( buf , len ) ; } sysevent_evc_walk_fini ( chq ) ; }
Utility function to write all of the pending ereports to the dump device.
Utility function to write all of the pending ereports to the dump device .
/*
	 * In the panic case, sysevent_evc_walk_init() will return NULL.
	 */ /* event channel isn't initialized yet */