changeset 3723:5f86ecf710b8

PSARC 2007/101 FMA libfmd_msg 6510717 syslog and snmp agents can both use setlocale() at the same time
author af
date Tue, 27 Feb 2007 05:23:54 -0800
parents 74c4ae0fed0e
children e9369c0865be
files usr/src/cmd/fm/modules/common/snmp-trapgen/Makefile usr/src/cmd/fm/modules/common/snmp-trapgen/snmp.c usr/src/cmd/fm/modules/common/syslog-msgs/Makefile usr/src/cmd/fm/modules/common/syslog-msgs/syslog.c usr/src/lib/fm/Makefile usr/src/lib/fm/libfmd_msg/Makefile usr/src/lib/fm/libfmd_msg/Makefile.com usr/src/lib/fm/libfmd_msg/amd64/Makefile usr/src/lib/fm/libfmd_msg/common/fmd_msg.c usr/src/lib/fm/libfmd_msg/common/fmd_msg.h usr/src/lib/fm/libfmd_msg/common/llib-lfmd_msg usr/src/lib/fm/libfmd_msg/common/mapfile-vers usr/src/lib/fm/libfmd_msg/i386/Makefile usr/src/lib/fm/libfmd_msg/sparc/Makefile usr/src/lib/fm/libfmd_msg/sparcv9/Makefile usr/src/pkgdefs/SUNWfmd/prototype_com usr/src/pkgdefs/SUNWfmd/prototype_i386 usr/src/pkgdefs/SUNWfmd/prototype_sparc
diffstat 18 files changed, 544 insertions(+), 42 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/cmd/fm/modules/common/snmp-trapgen/Makefile	Tue Feb 27 00:08:19 2007 -0800
+++ b/usr/src/cmd/fm/modules/common/snmp-trapgen/Makefile	Tue Feb 27 05:23:54 2007 -0800
@@ -20,7 +20,7 @@
 #
 
 #
-# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
 # ident	"%Z%%M%	%I%	%E% SMI"
@@ -40,8 +40,9 @@
 lint := SNMPLIBS =
 
 CPPFLAGS += -I/usr/sfw/include
-LDFLAGS += -L/usr/sfw/lib -R/usr/sfw/lib
-LDLIBS += $(SNMPLIBS)
+LDFLAGS += -L/usr/sfw/lib -L$(ROOT)/usr/lib/fm -R/usr/sfw/lib:/usr/lib/fm
+LINTFLAGS += -L$(ROOT)/usr/lib/fm
+LDLIBS += $(SNMPLIBS) -lfmd_msg
 
 $(ROOTSMASNMPCONFS) := FILEMODE = 0600
 
--- a/usr/src/cmd/fm/modules/common/snmp-trapgen/snmp.c	Tue Feb 27 00:08:19 2007 -0800
+++ b/usr/src/cmd/fm/modules/common/snmp-trapgen/snmp.c	Tue Feb 27 05:23:54 2007 -0800
@@ -20,7 +20,7 @@
  */
 
 /*
- * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -29,6 +29,7 @@
 #include <sys/fm/protocol.h>
 #include <fm/fmd_api.h>
 #include <fm/fmd_snmp.h>
+#include <fm/fmd_msg.h>
 #include <net-snmp/net-snmp-config.h>
 #include <net-snmp/net-snmp-includes.h>
 #include <net-snmp/agent/net-snmp-agent-includes.h>
@@ -166,11 +167,12 @@
 static void
 snmp_recv(fmd_hdl_t *hdl, fmd_event_t *ep, nvlist_t *nvl, const char *class)
 {
-	char *uuid, *code, *dict, *url, *urlcode, *p;
+	char *uuid, *code, *dict, *url, *urlcode, *locdir, *p;
 	boolean_t domsg;
 
 	uint8_t version;
 	char *olang = NULL;
+	int locale_c = 0;
 	size_t len;
 
 	if (nvlist_lookup_uint8(nvl, FM_VERSION, &version) != 0 ||
@@ -204,8 +206,10 @@
 	(void) strncpy(dict, code, (size_t)(p - code));
 	dict[(size_t)(p - code)] = '\0';
 
+	fmd_msg_lock();
+
 	if (snmp_locdir != NULL)
-		(void) bindtextdomain(dict, snmp_locdir);
+		locdir = bindtextdomain(dict, snmp_locdir);
 
 	if ((url = dgettext(dict, SNMP_URL)) == SNMP_URL) {
 		/*
@@ -213,8 +217,11 @@
 		 * current language.  Fall back to C and try again.
 		 */
 		olang = setlocale(LC_MESSAGES, NULL);
-		fmd_hdl_debug(hdl, "dgettext(%s, %s) in %s failed; trying C\n",
-		    dict, SNMP_URL, olang);
+		if (olang) {
+			p = alloca(strlen(olang) + 1);
+			olang = strcpy(p, olang);
+		}
+		locale_c = 1;
 		(void) setlocale(LC_MESSAGES, "C");
 		if ((url = dgettext(dict, SNMP_URL)) == SNMP_URL)
 			url = snmp_url;
@@ -243,6 +250,19 @@
 	 */
 	if (olang != NULL)
 		(void) setlocale(LC_MESSAGES, olang);
+
+	if (snmp_locdir != NULL)
+		(void) bindtextdomain(dict, locdir);
+
+	fmd_msg_unlock();
+
+	if (locale_c) {
+		fmd_hdl_debug(hdl,
+		    url == snmp_url ?
+		    "dgettext(%s, %s) in %s and C failed\n" :
+		    "dgettext(%s, %s) in %s failed; C used\n",
+		    dict, SNMP_URL, olang ? olang : "<null>");
+	}
 }
 
 static int
@@ -310,7 +330,7 @@
 void
 _fmd_init(fmd_hdl_t *hdl)
 {
-	char *rootdir, *locdir;
+	char *rootdir, *locdir, *locale, *p;
 
 	if (fmd_hdl_register(hdl, FMD_API_VERSION, &fmd_info) != 0)
 		return; /* invalid data in configuration file */
@@ -334,8 +354,17 @@
 	    "NLSPATH=/usr/lib/fm/fmd/fmd.cat", FMD_SLEEP)) != 0)
 		fmd_hdl_abort(hdl, "snmp-trapgen failed to set NLSPATH");
 
+	fmd_msg_lock();
 	(void) setlocale(LC_MESSAGES, "");
-	fmd_hdl_debug(hdl, "locale=%s\n", setlocale(LC_MESSAGES, NULL));
+	locale = setlocale(LC_MESSAGES, NULL);
+	if (locale) {
+		p = alloca(strlen(locale) + 1);
+		locale = strcpy(p, locale);
+	} else {
+		locale = "<null>";
+	}
+	fmd_msg_unlock();
+	fmd_hdl_debug(hdl, "locale=%s\n", locale);
 
 	/*
 	 * Cache any properties we use every time we receive an event and
@@ -352,13 +381,19 @@
 	 */
 	rootdir = fmd_prop_get_string(hdl, "fmd.rootdir");
 
-	if (*rootdir != '\0' && strcmp(rootdir, "/") != 0 &&
-	    (locdir = bindtextdomain(SNMP_DOMAIN, NULL)) != NULL) {
-		size_t len = strlen(rootdir) + strlen(locdir) + 1;
-		snmp_locdir = fmd_hdl_alloc(hdl, len, FMD_SLEEP);
-		(void) snprintf(snmp_locdir, len, "%s%s", rootdir, locdir);
-		(void) bindtextdomain(SNMP_DOMAIN, snmp_locdir);
-		fmd_hdl_debug(hdl, "binding textdomain to %s\n", snmp_locdir);
+	if (*rootdir != '\0' && strcmp(rootdir, "/") != 0) {
+		fmd_msg_lock();
+		locdir = bindtextdomain(SNMP_DOMAIN, NULL);
+		fmd_msg_unlock();
+		if (locdir != NULL) {
+			size_t len = strlen(rootdir) + strlen(locdir) + 1;
+			snmp_locdir = fmd_hdl_alloc(hdl, len, FMD_SLEEP);
+			(void) snprintf(snmp_locdir, len, "%s%s", rootdir,
+			    locdir);
+			fmd_hdl_debug(hdl,
+			    "binding textdomain to %s for snmp\n",
+			    snmp_locdir);
+		}
 	}
 
 	fmd_prop_free_string(hdl, rootdir);
--- a/usr/src/cmd/fm/modules/common/syslog-msgs/Makefile	Tue Feb 27 00:08:19 2007 -0800
+++ b/usr/src/cmd/fm/modules/common/syslog-msgs/Makefile	Tue Feb 27 05:23:54 2007 -0800
@@ -2,9 +2,8 @@
 # CDDL HEADER START
 #
 # The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License").  You may not use this file except in compliance
-# with the License.
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
 #
 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 # or http://www.opensolaris.org/os/licensing.
@@ -20,7 +19,7 @@
 # CDDL HEADER END
 #
 #
-# Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
 #ident	"%Z%%M%	%I%	%E% SMI"
@@ -30,3 +29,7 @@
 SRCS = syslog.c
 
 include ../../Makefile.plugin
+
+LDFLAGS += -L $(ROOT)/usr/lib/fm  -R/usr/lib/fm
+LINTFLAGS += -L$(ROOT)/usr/lib/fm
+LDLIBS += -lfmd_msg
--- a/usr/src/cmd/fm/modules/common/syslog-msgs/syslog.c	Tue Feb 27 00:08:19 2007 -0800
+++ b/usr/src/cmd/fm/modules/common/syslog-msgs/syslog.c	Tue Feb 27 05:23:54 2007 -0800
@@ -2,9 +2,8 @@
  * CDDL HEADER START
  *
  * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License").  You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
  *
  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  * or http://www.opensolaris.org/os/licensing.
@@ -20,7 +19,7 @@
  * CDDL HEADER END
  */
 /*
- * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -29,6 +28,7 @@
 #include <sys/fm/protocol.h>
 #include <sys/strlog.h>
 #include <fm/fmd_api.h>
+#include <fm/fmd_msg.h>
 
 #include <stropts.h>
 #include <syslog.h>
@@ -193,7 +193,7 @@
 {
 	char *uuid, *code, *dict, *url, *urlcode, *template, *p;
 	char *src_name, *src_vers, *platform, *chassis, *server;
-	char *typ, *sev, *fmt, *trfmt, *rsp, *imp, *act;
+	char *typ, *sev, *fmt, *trfmt, *rsp, *imp, *act, *locdir;
 	char msg[1024], desc[1024], date[64];
 	boolean_t domsg;
 
@@ -204,6 +204,7 @@
 	time_t sec;
 	uint_t tn = 0;
 	char *olang = NULL;
+	int locale_c = 0;
 	size_t len;
 
 	if (nvlist_lookup_uint8(nvl, FM_VERSION, &version) != 0 ||
@@ -281,8 +282,10 @@
 	act = imp + snprintf(imp, INT_MAX, "%s.impact", code) + 1;
 	(void) snprintf(act, INT_MAX, "%s.action", code);
 
+	fmd_msg_lock();
+
 	if (syslog_locdir != NULL)
-		(void) bindtextdomain(dict, syslog_locdir);
+		locdir =  bindtextdomain(dict, syslog_locdir);
 
 	if ((trfmt = dgettext(dict, fmt)) == fmt) {
 		/*
@@ -292,8 +295,11 @@
 		 * message.  Fall back to C and try again.
 		 */
 		olang = setlocale(LC_MESSAGES, NULL);
-		fmd_hdl_debug(hdl, "dgettext(%s, %s) in %s failed; trying C\n",
-		    dict, fmt, olang);
+		if (olang) {
+			p = alloca(strlen(olang) + 1);
+			olang = strcpy(p, olang);
+		}
+		locale_c = 1;
 		(void) setlocale(LC_MESSAGES, "C");
 		trfmt = dgettext(dict, fmt);
 	}
@@ -349,6 +355,19 @@
 	 */
 	if (olang != NULL)
 		(void) setlocale(LC_MESSAGES, olang);
+
+	if (syslog_locdir != NULL)
+		(void) bindtextdomain(dict, locdir);
+
+	fmd_msg_unlock();
+
+	if (locale_c) {
+		fmd_hdl_debug(hdl,
+		    trfmt == fmt ?
+		    "dgettext(%s, %s) in %s and C failed\n" :
+		    "dgettext(%s, %s) in %s failed; C used\n",
+		    dict, fmt, olang ? olang : "<null>");
+	}
 }
 
 static const fmd_prop_t fmd_props[] = {
@@ -377,7 +396,7 @@
 _fmd_init(fmd_hdl_t *hdl)
 {
 	const struct facility *fp;
-	char *facname, *tz, *rootdir, *locdir;
+	char *facname, *tz, *rootdir, *locdir, *locale, *p;
 
 	if (fmd_hdl_register(hdl, FMD_API_VERSION, &fmd_info) != 0)
 		return; /* invalid data in configuration file */
@@ -404,8 +423,17 @@
 	    "NLSPATH=/usr/lib/fm/fmd/fmd.cat", FMD_SLEEP)) != 0)
 		fmd_hdl_abort(hdl, "syslog-msgs failed to set NLSPATH");
 
+	fmd_msg_lock();
 	(void) setlocale(LC_MESSAGES, "");
-	fmd_hdl_debug(hdl, "locale=%s\n", setlocale(LC_MESSAGES, NULL));
+	locale = setlocale(LC_MESSAGES, NULL);
+	if (locale) {
+		p = alloca(strlen(locale) + 1);
+		locale = strcpy(p, locale);
+	} else {
+		locale = "<null>";
+	}
+	fmd_msg_unlock();
+	fmd_hdl_debug(hdl, "locale=%s\n", locale);
 
 	/*
 	 * If the "gmt" property is set to true, force our EVENT-TIME to be
@@ -454,13 +482,19 @@
 	 */
 	rootdir = fmd_prop_get_string(hdl, "fmd.rootdir");
 
-	if (*rootdir != '\0' && strcmp(rootdir, "/") != 0 &&
-	    (locdir = bindtextdomain(SYSLOG_DOMAIN, NULL)) != NULL) {
-		size_t len = strlen(rootdir) + strlen(locdir) + 1;
-		syslog_locdir = fmd_hdl_alloc(hdl, len, FMD_SLEEP);
-		(void) snprintf(syslog_locdir, len, "%s%s", rootdir, locdir);
-		(void) bindtextdomain(SYSLOG_DOMAIN, syslog_locdir);
-		fmd_hdl_debug(hdl, "binding textdomain to %s\n", syslog_locdir);
+	if (*rootdir != '\0' && strcmp(rootdir, "/") != 0) {
+		fmd_msg_lock();
+		locdir = bindtextdomain(SYSLOG_DOMAIN, NULL);
+		fmd_msg_unlock();
+		if (locdir != NULL) {
+			size_t len = strlen(rootdir) + strlen(locdir) + 1;
+			syslog_locdir = fmd_hdl_alloc(hdl, len, FMD_SLEEP);
+			(void) snprintf(syslog_locdir, len, "%s%s", rootdir,
+			    locdir);
+			fmd_hdl_debug(hdl,
+			    "binding textdomain to %s for syslog\n",
+			    syslog_locdir);
+		}
 	}
 
 	fmd_prop_free_string(hdl, rootdir);
--- a/usr/src/lib/fm/Makefile	Tue Feb 27 00:08:19 2007 -0800
+++ b/usr/src/lib/fm/Makefile	Tue Feb 27 05:23:54 2007 -0800
@@ -20,7 +20,7 @@
 #
 
 #
-# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
 # ident	"%Z%%M%	%I%	%E% SMI"
@@ -38,6 +38,7 @@
 	libdiagcode \
 	libfmd_adm \
 	libfmd_log \
+	libfmd_msg \
 	libfmd_snmp \
 	$($(MACH)_SUBDIRS) \
 	topo
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/lib/fm/libfmd_msg/Makefile	Tue Feb 27 05:23:54 2007 -0800
@@ -0,0 +1,59 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+#
+# ident	"%Z%%M%	%I%	%E% SMI"
+#
+
+include ../../Makefile.lib
+include ../Makefile.lib
+
+FMHDRS = fmd_msg.h
+HDRDIR = common
+
+SUBDIRS = $(MACH) 
+$(BUILD64)SUBDIRS += $(MACH64)
+
+all := TARGET = all
+clean := TARGET = clean
+clobber := TARGET = clobber
+install := TARGET = install
+lint := TARGET = lint
+
+.KEEP_STATE:
+
+all clean clobber lint: $(SUBDIRS)
+
+install: install_h .WAIT $(SUBDIRS)
+
+install_h: $(ROOTFMHDRS)
+
+check: $(CHECKHDRS)
+
+$(SUBDIRS): FRC
+	@cd $@; pwd; $(MAKE) $(TARGET)
+
+FRC:
+
+include ../../Makefile.targ
+include ../Makefile.targ
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/lib/fm/libfmd_msg/Makefile.com	Tue Feb 27 05:23:54 2007 -0800
@@ -0,0 +1,61 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+#
+# ident	"%Z%%M%	%I%	%E% SMI"
+#
+
+LIBRARY = libfmd_msg.a
+VERS = .1
+
+LIBSRCS = fmd_msg.c
+OBJECTS = $(LIBSRCS:%.c=%.o)
+
+include ../../../Makefile.lib
+include ../../Makefile.lib
+
+SRCS = $(LIBSRCS:%.c=../common/%.c)
+LIBS = $(DYNLIB) $(LINTLIB)
+
+SRCDIR =	../common
+
+CPPFLAGS += -I../common -I.
+CFLAGS += $(CCVERBOSE) $(C_BIGPICFLAGS)
+CFLAGS64 += $(CCVERBOSE) $(C_BIGPICFLAGS)
+LDLIBS += -lnvpair -lgen -lc
+
+LINTFLAGS = -msux
+LINTFLAGS64 = -msux -Xarch=$(MACH64:sparcv9=v9)
+
+$(LINTLIB) := SRCS = $(SRCDIR)/$(LINTSRC)
+$(LINTLIB) := LINTFLAGS = -nsvx
+$(LINTLIB) := LINTFLAGS64 = -nsvx -Xarch=$(MACH64:sparcv9=v9)
+
+.KEEP_STATE:
+
+all: $(LIBS)
+
+lint: $(LINTLIB) lintcheck
+
+include ../../../Makefile.targ
+include ../../Makefile.targ
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/lib/fm/libfmd_msg/amd64/Makefile	Tue Feb 27 05:23:54 2007 -0800
@@ -0,0 +1,31 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+#
+# ident	"%Z%%M%	%I%	%E% SMI"
+#
+
+include ../Makefile.com
+include ../../../Makefile.lib.64
+
+install: all $(ROOTLIBS64) $(ROOTLINKS64) $(ROOTLINT64)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/lib/fm/libfmd_msg/common/fmd_msg.c	Tue Feb 27 05:23:54 2007 -0800
@@ -0,0 +1,60 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident	"%Z%%M%	%I%	%E% SMI"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <synch.h>
+
+static rwlock_t fmd_msg_rwlock;
+
+#pragma init(fmd_msg_init)
+static void
+fmd_msg_init(void)
+{
+	(void) rwlock_init(&fmd_msg_rwlock, USYNC_THREAD, NULL);
+}
+
+#pragma fini(fmd_msg_fini)
+static void
+fmd_msg_fini(void)
+{
+	(void) rwlock_destroy(&fmd_msg_rwlock);
+}
+
+void
+fmd_msg_lock(void)
+{
+	if (rw_wrlock(&fmd_msg_rwlock) != 0)
+		abort();
+}
+
+void
+fmd_msg_unlock(void)
+{
+	if (rw_unlock(&fmd_msg_rwlock) != 0)
+		abort();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/lib/fm/libfmd_msg/common/fmd_msg.h	Tue Feb 27 05:23:54 2007 -0800
@@ -0,0 +1,52 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef	_FMD_MSG_H
+#define	_FMD_MSG_H
+
+#pragma ident	"%Z%%M%	%I%	%E% SMI"
+
+#ifdef	__cplusplus
+extern "C" {
+#endif
+
+/*
+ * Fault Management Daemon msg File Interfaces
+ *
+ * Note: The contents of this file are private to the implementation of the
+ * Solaris system and FMD subsystem and are subject to change at any time
+ * without notice.  Applications and drivers using these interfaces will fail
+ * to run on future releases.  These interfaces should not be used for any
+ * purpose until they are publicly documented for use outside of Sun.
+ */
+
+extern void fmd_msg_lock(void);
+extern void fmd_msg_unlock(void);
+
+#ifdef	__cplusplus
+}
+#endif
+
+#endif	/* _FMD_MSG_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/lib/fm/libfmd_msg/common/llib-lfmd_msg	Tue Feb 27 05:23:54 2007 -0800
@@ -0,0 +1,29 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident	"%Z%%M%	%I%	%E% SMI"
+
+/*LINTLIBRARY*/
+/*PROTOLIB1*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/lib/fm/libfmd_msg/common/mapfile-vers	Tue Feb 27 05:23:54 2007 -0800
@@ -0,0 +1,34 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+#
+# ident	"%Z%%M%	%I%	%E% SMI"
+#
+
+SUNWprivate {
+    global:
+	fmd_msg_lock;
+	fmd_msg_unlock;
+    local:
+	*;
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/lib/fm/libfmd_msg/i386/Makefile	Tue Feb 27 05:23:54 2007 -0800
@@ -0,0 +1,30 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+#
+# ident	"%Z%%M%	%I%	%E% SMI"
+#
+
+include ../Makefile.com
+
+install: all $(ROOTLIBS) $(ROOTLINKS) $(ROOTLINT)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/lib/fm/libfmd_msg/sparc/Makefile	Tue Feb 27 05:23:54 2007 -0800
@@ -0,0 +1,30 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+#
+# ident	"%Z%%M%	%I%	%E% SMI"
+#
+
+include ../Makefile.com
+
+install: all $(ROOTLIBS) $(ROOTLINKS) $(ROOTLINT)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/lib/fm/libfmd_msg/sparcv9/Makefile	Tue Feb 27 05:23:54 2007 -0800
@@ -0,0 +1,31 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+#
+# ident	"%Z%%M%	%I%	%E% SMI"
+#
+
+include ../Makefile.com
+include ../../../Makefile.lib.64
+
+install: all $(ROOTLIBS64) $(ROOTLINKS64) $(ROOTLINT64)
--- a/usr/src/pkgdefs/SUNWfmd/prototype_com	Tue Feb 27 00:08:19 2007 -0800
+++ b/usr/src/pkgdefs/SUNWfmd/prototype_com	Tue Feb 27 05:23:54 2007 -0800
@@ -20,7 +20,7 @@
 #
 
 #
-# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
 # ident	"%Z%%M%	%I%	%E% SMI"
@@ -38,6 +38,7 @@
 f none usr/include/fm/fmd_api.h 644 root bin
 f none usr/include/fm/fmd_fmri.h 644 root bin
 f none usr/include/fm/fmd_log.h 644 root bin
+f none usr/include/fm/fmd_msg.h 644 root bin
 f none usr/include/fm/fmd_snmp.h 644 root bin
 f none usr/include/fm/libtopo.h 644 root bin
 f none usr/include/fm/topo_mod.h 644 root bin
@@ -98,6 +99,10 @@
 s none usr/lib/fm/libfmd_log.so=libfmd_log.so.1
 f none usr/lib/fm/llib-lfmd_log 644 root bin
 f none usr/lib/fm/llib-lfmd_log.ln 644 root bin
+f none usr/lib/fm/libfmd_msg.so.1 755 root bin
+s none usr/lib/fm/libfmd_msg.so=libfmd_msg.so.1
+f none usr/lib/fm/llib-lfmd_msg 644 root bin
+f none usr/lib/fm/llib-lfmd_msg.ln 644 root bin
 f none usr/lib/fm/libfmd_snmp.so.1 755 root bin
 s none usr/lib/fm/libfmd_snmp.so=libfmd_snmp.so.1
 f none usr/lib/fm/llib-lfmd_snmp 644 root bin
--- a/usr/src/pkgdefs/SUNWfmd/prototype_i386	Tue Feb 27 00:08:19 2007 -0800
+++ b/usr/src/pkgdefs/SUNWfmd/prototype_i386	Tue Feb 27 05:23:54 2007 -0800
@@ -20,7 +20,7 @@
 #
 
 #
-# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
 # ident	"%Z%%M%	%I%	%E% SMI"
@@ -35,6 +35,8 @@
 s none usr/lib/fm/amd64/libfmd_adm.so=./libfmd_adm.so.1
 f none usr/lib/fm/amd64/libfmd_log.so.1 755 root bin
 s none usr/lib/fm/amd64/libfmd_log.so=./libfmd_log.so.1
+f none usr/lib/fm/amd64/libfmd_msg.so.1 755 root bin
+s none usr/lib/fm/amd64/libfmd_msg.so=./libfmd_msg.so.1
 f none usr/lib/fm/amd64/libfmd_snmp.so.1 755 root bin
 s none usr/lib/fm/amd64/libfmd_snmp.so=./libfmd_snmp.so.1
 f none usr/lib/fm/amd64/libtopo.so.1 755 root bin
@@ -42,6 +44,7 @@
 f none usr/lib/fm/amd64/llib-ldiagcode.ln 644 root bin
 f none usr/lib/fm/amd64/llib-lfmd_adm.ln 644 root bin
 f none usr/lib/fm/amd64/llib-lfmd_log.ln 644 root bin
+f none usr/lib/fm/amd64/llib-lfmd_msg.ln 644 root bin
 f none usr/lib/fm/amd64/llib-lfmd_snmp.ln 644 root bin
 f none usr/lib/fm/amd64/llib-ltopo.ln 644 root bin
 d none usr/lib/fm/fmd/schemes/amd64 755 root bin
--- a/usr/src/pkgdefs/SUNWfmd/prototype_sparc	Tue Feb 27 00:08:19 2007 -0800
+++ b/usr/src/pkgdefs/SUNWfmd/prototype_sparc	Tue Feb 27 05:23:54 2007 -0800
@@ -20,7 +20,7 @@
 #
 
 #
-# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
 # ident	"%Z%%M%	%I%	%E% SMI"
@@ -59,6 +59,9 @@
 f none usr/lib/fm/sparcv9/libfmd_log.so.1 755 root bin
 s none usr/lib/fm/sparcv9/libfmd_log.so=libfmd_log.so.1
 f none usr/lib/fm/sparcv9/llib-lfmd_log.ln 644 root bin
+f none usr/lib/fm/sparcv9/libfmd_msg.so.1 755 root bin
+s none usr/lib/fm/sparcv9/libfmd_msg.so=libfmd_msg.so.1
+f none usr/lib/fm/sparcv9/llib-lfmd_msg.ln 644 root bin
 f none usr/lib/fm/sparcv9/libmdesc.so.1 755 root bin
 s none usr/lib/fm/sparcv9/libmdesc.so=libmdesc.so.1 755 root bin
 f none usr/lib/fm/sparcv9/llib-lmdesc.ln 644 root bin