From f6e214c7418f43af38bd8c3a557e3d0a1d311cfa Mon Sep 17 00:00:00 2001 From: Gavin Maltby Date: Fri, 30 Jul 2010 17:04:17 +1000 Subject: PSARC/2009/617 Software Events Notification Parameters CLI PSARC/2009/618 snmp-notify: SNMP Notification Daemon for Software Events PSARC/2009/619 smtp-notify: Email Notification Daemon for Software Events PSARC/2010/225 fmd for non-global Solaris zones PSARC/2010/226 Solaris Instance UUID PSARC/2010/227 nvlist_nvflag(3NVPAIR) PSARC/2010/228 libfmevent additions PSARC/2010/257 sysevent_evc_setpropnvl and sysevent_evc_getpropnvl PSARC/2010/265 FMRI and FMA Event Stabilty, 'ireport' category 1 event class, and the 'sw' FMRI scheme PSARC/2010/278 FMA/SMF integration: instance state transitions PSARC/2010/279 Modelling panics within FMA PSARC/2010/290 logadm.conf upgrade 6392476 fmdump needs to pretty-print 6393375 userland ereport/ireport event generation interfaces 6445732 Add email notification agent for FMA and software events 6804168 RFE: Allow an efficient means to monitor SMF services status changes 6866661 scf_values_destroy(3SCF) will segfault if is passed NULL 6884709 Add snmp notification agent for FMA and software events 6884712 Add private interface to tap into libfmd_msg macro expansion capabilities 6897919 fmd to run in a non-global zone 6897937 fmd use of non-private doors is not safe 6900081 add a UUID to Solaris kernel image for use in crashdump identification 6914884 model panic events as a defect diagnosis in FMA 6944862 fmd_case_open_uuid, fmd_case_uuisresolved, fmd_nvl_create_defect 6944866 log legacy sysevents in fmd 6944867 enumerate svc scheme in topo 6944868 software-diagnosis and software-response fmd modules 6944870 model SMF maintenance state as a defect diagnosis in FMA 6944876 savecore runs in foreground for systems with zfs root and dedicated dump 6965796 Implement notification parameters for SMF state transitions and FMA events 6968287 SUN-FM-MIB.mib needs to be updated to reflect Oracle information 6972331 logadm.conf upgrade PSARC/2010/290 --- usr/src/lib/libsysevent/libevchannel.c | 95 ++++++++++++++++++++++++++++++++-- 1 file changed, 91 insertions(+), 4 deletions(-) (limited to 'usr/src/lib/libsysevent/libevchannel.c') diff --git a/usr/src/lib/libsysevent/libevchannel.c b/usr/src/lib/libsysevent/libevchannel.c index 52f9b4641c..8e6743d314 100644 --- a/usr/src/lib/libsysevent/libevchannel.c +++ b/usr/src/lib/libsysevent/libevchannel.c @@ -19,8 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. */ #include @@ -435,7 +434,6 @@ static void kill_door_servers(evchan_subscr_t *subp) { door_arg_t da; - int i; bzero(&da, sizeof (da)); subp->evsub_state = EVCHAN_SUB_STATE_CLOSING; @@ -603,7 +601,6 @@ sysevent_evc_xsubscribe(evchan_t *scp, const char *sid, const char *class, int (*event_handler)(sysevent_t *ev, void *cookie), void *cookie, uint32_t flags, sysevent_subattr_t *attr) { - struct sysevent_subattr_impl sa; struct sysevent_subattr_impl *xsa; if (attr != NULL) { @@ -809,11 +806,13 @@ sysevent_evc_control(evchan_t *scp, int cmd, /* arg */ ...) rc = ioctl(EV_FD(scp), SEV_CHAN_CONTROL, (intptr_t)&uargs); *chlenp = uargs.value; break; + case EVCH_SET_CHAN_LEN: /* Range change will be handled in framework */ uargs.value = va_arg(ap, uint32_t); rc = ioctl(EV_FD(scp), SEV_CHAN_CONTROL, (intptr_t)&uargs); break; + default: rc = EINVAL; } @@ -828,3 +827,91 @@ sysevent_evc_control(evchan_t *scp, int cmd, /* arg */ ...) return (errno = rc); } + +int +sysevent_evc_setpropnvl(evchan_t *scp, nvlist_t *nvl) +{ + sev_propnvl_args_t uargs; + char *buf = NULL; + size_t nvlsz = 0; + int rc; + + if (scp == NULL || misaligned(scp)) + return (errno = EINVAL); + + if (nvl != NULL && + nvlist_pack(nvl, &buf, &nvlsz, NV_ENCODE_NATIVE, 0) != 0) + return (errno); + + uargs.packednvl.name = (uint64_t)(uintptr_t)buf; + uargs.packednvl.len = (uint32_t)nvlsz; + + rc = ioctl(EV_FD(scp), SEV_SETPROPNVL, (intptr_t)&uargs); + + if (buf) + free(buf); + + return (rc); +} + +int +sysevent_evc_getpropnvl(evchan_t *scp, nvlist_t **nvlp) +{ + sev_propnvl_args_t uargs; + char buf[1024], *bufp = buf; /* stack buffer */ + size_t sz = sizeof (buf); + char *buf2 = NULL; /* allocated if stack buf too small */ + int64_t expgen = -1; + int rc; + + if (scp == NULL || misaligned(scp) || nvlp == NULL) + return (errno = EINVAL); + + *nvlp = NULL; + +again: + uargs.packednvl.name = (uint64_t)(uintptr_t)bufp; + uargs.packednvl.len = (uint32_t)sz; + + rc = ioctl(EV_FD(scp), SEV_GETPROPNVL, (intptr_t)&uargs); + + if (rc == E2BIG) + return (errno = E2BIG); /* driver refuses to copyout */ + + /* + * If the packed nvlist is too big for the buffer size we offered + * then the ioctl returns EOVERFLOW and indicates in the 'len' + * the size required for the current property nvlist generation + * (itself returned in the generation member). + */ + if (rc == EOVERFLOW && + (buf2 == NULL || uargs.generation != expgen)) { + if (buf2 != NULL) + free(buf2); + + if ((sz = uargs.packednvl.len) > 1024 * 1024) + return (E2BIG); + + bufp = buf2 = malloc(sz); + + if (buf2 == NULL) + return (errno = ENOMEM); + + expgen = uargs.generation; + goto again; + } + + /* + * The chan prop nvlist can be absent, in which case the ioctl + * returns success and uargs.packednvl.len of 0; we have already + * set *nvlp to NULL. Otherwise we must unpack the nvl. + */ + if (rc == 0 && uargs.packednvl.len != 0 && + nvlist_unpack(bufp, uargs.packednvl.len, nvlp, 0) != 0) + rc = EINVAL; + + if (buf2 != NULL) + free(buf2); + + return (rc ? errno = rc : 0); +} -- cgit v1.2.3