changeset 5017:3e669302a3e8

PSARC 2007/455 /etc/{init,utmp}pipe to /var/run 6437243 initpipe and utmppipe fifos prevent efficient searching of /etc/* 6590291 libtopo's Makefile.plugin has a broken lint target 6590293 ipmi_close() doesn't free SDR repository
author eschrock
date Mon, 10 Sep 2007 08:13:47 -0700
parents 40ae92b9e799
children 9d2303147d54
files usr/src/cmd/init/init.c usr/src/cmd/svc/startd/specials.c usr/src/cmd/utmpd/svc-utmpd usr/src/cmd/utmpd/utmpd.c usr/src/lib/fm/topo/modules/Makefile.plugin usr/src/lib/fm/topo/modules/SUNW,SPARC-Enterprise/ioboard/opl_hostbridge.c usr/src/lib/fm/topo/modules/SUNW,SPARC-Enterprise/ioboard/opl_ioboard.c usr/src/lib/fm/topo/modules/common/disk/disk.c usr/src/lib/fm/topo/modules/common/pcibus/pcibus.c usr/src/lib/fm/topo/modules/sun4/ioboard/ioboard.c usr/src/lib/fm/topo/modules/sun4v/hostbridge/hb_sun4v.c usr/src/lib/fm/topo/modules/sun4v/motherboard/motherboard.c usr/src/lib/libc/port/gen/getutx.c usr/src/lib/libipmi/common/ipmi_impl.h usr/src/lib/libipmi/common/ipmi_sdr.c usr/src/lib/libipmi/common/libipmi.c
diffstat 16 files changed, 94 insertions(+), 53 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/cmd/init/init.c	Mon Sep 10 04:12:38 2007 -0700
+++ b/usr/src/cmd/init/init.c	Mon Sep 10 08:13:47 2007 -0700
@@ -457,8 +457,8 @@
  * Useful file and device names.
  */
 static char *CONSOLE	  = "/dev/console";	/* Real system console */
-static char *INITPIPE_DIR = "/etc";
-static char *INITPIPE	  = "/etc/initpipe";
+static char *INITPIPE_DIR = "/var/run";
+static char *INITPIPE	  = "/var/run/initpipe";
 
 #define	INIT_STATE_DIR "/etc/svc/volatile"
 static const char * const init_state_file = INIT_STATE_DIR "/init.state";
@@ -486,6 +486,7 @@
 static int	prior_state;
 static int	prev_state;	/* State "init" was in last time it woke */
 static int	new_state;	/* State user wants "init" to go to. */
+static int	lvlq_received;	/* Explicit request to examine state */
 static int	op_modes = BOOT_MODES; /* Current state of "init" */
 static int	Gchild = 0;	/* Flag to indicate "godchild" died, set in */
 				/*   childeath() and cleared in cleanaux() */
@@ -725,12 +726,16 @@
 
 	prev_state = prior_state = cur_state;
 
+	setup_pipe();
+
 	/*
 	 * Here is the beginning of the main process loop.
 	 */
 	for (;;) {
-		if (Pfd < 0)
+		if (lvlq_received) {
 			setup_pipe();
+			lvlq_received = B_FALSE;
+		}
 
 		/*
 		 * Clean up any accounting records for dead "godchildren".
@@ -2174,8 +2179,8 @@
 /*
  * Set up pipe for "godchildren". If the file exists and is a pipe just open
  * it. Else, if the file system is r/w create it.  Otherwise, defer its
- * creation and open until after the sysinit functions have had a chance to
- * make the root read/write.
+ * creation and open until after /var/run has been mounted.  This function is
+ * only called on startup and when explicitly requested via LVLQ.
  */
 void
 setup_pipe()
@@ -2184,6 +2189,13 @@
 	struct statvfs statvfs_buf;
 	struct sigaction act;
 
+	/*
+	 * Always close the previous pipe descriptor as the mounted filesystems
+	 * may have changed.
+	 */
+	if (Pfd >= 0)
+		(void) close(Pfd);
+
 	if ((stat(INITPIPE, &stat_buf) == 0) &&
 	    ((stat_buf.st_mode & (S_IFMT|S_IRUSR)) == (S_IFIFO|S_IRUSR)))
 		Pfd = open(INITPIPE, O_RDWR | O_NDELAY);
@@ -2254,10 +2266,12 @@
 	 * signal is not a LVLQ, set the new level to the signal
 	 * received.
 	 */
-	if (sig == LVLQ)
+	if (sig == LVLQ) {
 		new_state = cur_state;
-	else
+		lvlq_received = B_TRUE;
+	} else {
 		new_state = sig;
+	}
 
 	/*
 	 * Clear all times and repeat counts in the process table
--- a/usr/src/cmd/svc/startd/specials.c	Mon Sep 10 04:12:38 2007 -0700
+++ b/usr/src/cmd/svc/startd/specials.c	Mon Sep 10 08:13:47 2007 -0700
@@ -19,7 +19,7 @@
  * CDDL HEADER END
  */
 /*
- * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -119,7 +119,7 @@
 	case -1:
 	default:
 		log_error(LOG_WARNING, gettext("couldn't check status of "
-			"root filesystem: %s\n"), strerror(errno));
+		    "root filesystem: %s\n"), strerror(errno));
 		break;
 	}
 
@@ -130,7 +130,7 @@
 			    "read-only after system/filesystem/minimal\n");
 			if (fs_remount("/var"))
 				log_framework(LOG_WARNING, "/var "
-					"filesystem remount failed\n");
+				    "filesystem remount failed\n");
 		}
 		break;
 	case 0:
@@ -154,7 +154,7 @@
 	log_init();
 
 	/*
-	 * Poke init so it will create /etc/initpipe.
+	 * Poke init so it will create /var/run/initpipe.
 	 */
 	if (zone_getattr(getzoneid(), ZONE_ATTR_INITPID, &init_pid,
 	    sizeof (init_pid)) != sizeof (init_pid)) {
--- a/usr/src/cmd/utmpd/svc-utmpd	Mon Sep 10 04:12:38 2007 -0700
+++ b/usr/src/cmd/utmpd/svc-utmpd	Mon Sep 10 08:13:47 2007 -0700
@@ -20,7 +20,7 @@
 # CDDL HEADER END
 #
 #
-# 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"
@@ -32,12 +32,12 @@
 # If a utmppipe exists, check for a utmpd process and exit
 # if the daemon is already running.
 
-if [ -p /etc/utmppipe ]; then
+if [ -p /var/run/utmppipe ]; then
 	if /usr/bin/pgrep -x -u 0 -z `smf_zonename` utmpd >/dev/null 2>&1; then
 		echo "$0: utmpd is already running"
 		exit 1
 	fi
 fi
 
-/usr/bin/rm -f /etc/utmppipe
+/usr/bin/rm -f /var/run/utmppipe
 /usr/lib/utmpd &
--- a/usr/src/cmd/utmpd/utmpd.c	Mon Sep 10 04:12:38 2007 -0700
+++ b/usr/src/cmd/utmpd/utmpd.c	Mon Sep 10 08:13:47 2007 -0700
@@ -19,7 +19,7 @@
  * CDDL HEADER END
  */
 /*
- * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -134,8 +134,8 @@
 
 static int	pidcnt = 0;		/* Number of procs being watched */
 static char	*prog_name;		/* To save the invocation name away */
-static char	*UTMPPIPE_DIR =	"/etc";
-static char	*UTMPPIPE = "/etc/utmppipe";
+static char	*UTMPPIPE_DIR =	"/var/run";
+static char	*UTMPPIPE = "/var/run/utmppipe";
 static int	Pfd = -1;		/* File descriptor of named pipe */
 static int 	Poll_timeout = POLL_TIMEOUT;
 static int	WTMPXfd = -1;		/* File descriptor of WTMPX_FILE */
--- a/usr/src/lib/fm/topo/modules/Makefile.plugin	Mon Sep 10 04:12:38 2007 -0700
+++ b/usr/src/lib/fm/topo/modules/Makefile.plugin	Mon Sep 10 08:13:47 2007 -0700
@@ -55,7 +55,7 @@
 plat_ROOTCONF = $(PLATFORMS:%=$(ROOT)/usr/platform/%/lib/fm/topo/plugins/$(CONF))
 ROOTCONF = $($(CLASS)_ROOTCONF)
 
-LINTFLAGS += -mu
+LINTFLAGS = -msux
 LINTFILES = $(SRCS:%.c=%.ln)
 
 APIMAP = ../../../libtopo/common/topo_mod.map
@@ -67,7 +67,8 @@
 CPPFLAGS += -I.
 CPPFLAGS += -D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT
 LDFLAGS += $(ZIGNORE) -M$(APIMAP)
-LDLIBS += -L$(ROOTLIBDIR)/fm -R/usr/lib/fm -ltopo -lnvpair -lc
+LDLIBS += -L$(ROOTLIBDIR)/fm -ltopo -lnvpair -lc
+DYNFLAGS += -R/usr/lib/fm
 
 all: $(PROG)
 
--- a/usr/src/lib/fm/topo/modules/SUNW,SPARC-Enterprise/ioboard/opl_hostbridge.c	Mon Sep 10 04:12:38 2007 -0700
+++ b/usr/src/lib/fm/topo/modules/SUNW,SPARC-Enterprise/ioboard/opl_hostbridge.c	Mon Sep 10 08:13:47 2007 -0700
@@ -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.
  */
 
@@ -127,7 +127,7 @@
 		char fru_str[64];
 		nvlist_t *fru_fmri;
 		/* Add FRU fmri */
-		snprintf(fru_str, sizeof (fru_str), "hc:///component=%s",
+		(void) snprintf(fru_str, sizeof (fru_str), "hc:///component=%s",
 		    slot_name);
 		if (topo_mod_str2nvl(mp, fru_str, &fru_fmri) == 0) {
 			(void) topo_node_fru_set(rcn, fru_fmri, 0, &err);
--- a/usr/src/lib/fm/topo/modules/SUNW,SPARC-Enterprise/ioboard/opl_ioboard.c	Mon Sep 10 04:12:38 2007 -0700
+++ b/usr/src/lib/fm/topo/modules/SUNW,SPARC-Enterprise/ioboard/opl_ioboard.c	Mon Sep 10 08:13:47 2007 -0700
@@ -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.
  */
 
@@ -182,13 +182,13 @@
 	}
 	nvlist_free(fmri);
 	/* Create and add FRU fmri for this ioboard */
-	snprintf(fmri_str, sizeof (fmri_str), IOBDFRU, inst);
+	(void) snprintf(fmri_str, sizeof (fmri_str), IOBDFRU, inst);
 	if (topo_mod_str2nvl(mp, fmri_str, &fmri) == 0) {
 		(void) topo_node_fru_set(ion, fmri, 0, &err);
 		nvlist_free(fmri);
 	}
 	/* Add label for this ioboard */
-	snprintf(label, sizeof (label), LABEL, inst);
+	(void) snprintf(label, sizeof (label), LABEL, inst);
 	(void) topo_node_label_set(ion, label, &err);
 
 	/* Create range of hostbridges on this ioboard */
--- a/usr/src/lib/fm/topo/modules/common/disk/disk.c	Mon Sep 10 04:12:38 2007 -0700
+++ b/usr/src/lib/fm/topo/modules/common/disk/disk.c	Mon Sep 10 08:13:47 2007 -0700
@@ -201,7 +201,7 @@
 	}
 	nvlist_free(asru);
 
-	snprintf(label, sizeof (label), "HD_ID_%d", pinst);
+	(void) snprintf(label, sizeof (label), "HD_ID_%d", pinst);
 	if (topo_node_label_set(dtn, label, &err) != 0) {
 		topo_mod_dprintf(mod, "%s: label error %s\n", func,
 		    topo_strerror(err));
@@ -249,9 +249,6 @@
 	int	inst = topo_node_instance(parent);
 	disk_di_node_t	*dnode;
 
-	topo_prop_get_string(parent, TOPO_BINDING_PGROUP, TOPO_BINDING_OCCUPANT,
-	    &device, err);
-
 	dnode = topo_node_getspecific(dtn);
 
 	/* set the protocol group properties */
@@ -269,10 +266,14 @@
 
 	/* create/set the devfs-path in the io group */
 	(void) topo_pgroup_create(dtn, &io_pgroup, err);
-	(void) topo_prop_set_string(dtn, TOPO_PGROUP_IO,
-	    TOPO_IO_DEV_PATH, TOPO_PROP_IMMUTABLE, device, err);
 
-	topo_mod_strfree(mod, device);
+	if (topo_prop_get_string(parent, TOPO_BINDING_PGROUP,
+	    TOPO_BINDING_OCCUPANT, &device, err) == 0) {
+		(void) topo_prop_set_string(dtn, TOPO_PGROUP_IO,
+		    TOPO_IO_DEV_PATH, TOPO_PROP_IMMUTABLE, device, err);
+
+		topo_mod_strfree(mod, device);
+	}
 
 	/* create the storage group */
 	(void) topo_pgroup_create(dtn, &storage_pgroup, err);
@@ -449,8 +450,9 @@
 		return (-1);
 	}
 
-	topo_prop_get_string(rnode, TOPO_BINDING_PGROUP, TOPO_BINDING_OCCUPANT,
-	    &device, &err);
+	if (topo_prop_get_string(rnode, TOPO_BINDING_PGROUP,
+	    TOPO_BINDING_OCCUPANT, &device, &err) != 0)
+		return (-1);
 
 	if ((dnode = disk_di_node_match_device(device)) == NULL) {
 		topo_mod_dprintf(mod,
--- a/usr/src/lib/fm/topo/modules/common/pcibus/pcibus.c	Mon Sep 10 04:12:38 2007 -0700
+++ b/usr/src/lib/fm/topo/modules/common/pcibus/pcibus.c	Mon Sep 10 08:13:47 2007 -0700
@@ -293,7 +293,11 @@
 	 * from our parent node's private data.
 	 */
 
-	did_inherit(ppd, pd);
+	if (did_inherit(ppd, pd) != 0) {
+		topo_node_unbind(ntn);
+		return (NULL);
+	}
+
 	if (did_props_set(ntn, pd, Dev_common_props, Dev_propcnt) < 0) {
 		topo_node_unbind(ntn);
 		return (NULL);
@@ -507,7 +511,8 @@
 		    "Unable to proceed with %s enumeration.\n", pnm, PCIEX_BUS);
 		return (0);
 	}
-	did_hash_init(mp);
+	if (did_hash_init(mp) != 0)
+		return (-1);
 	if ((did_create(mp, pdn, 0, 0, rc, TRUST_BDF)) == NULL)
 		return (-1);	/* errno already set */
 
--- a/usr/src/lib/fm/topo/modules/sun4/ioboard/ioboard.c	Mon Sep 10 04:12:38 2007 -0700
+++ b/usr/src/lib/fm/topo/modules/sun4/ioboard/ioboard.c	Mon Sep 10 08:13:47 2007 -0700
@@ -133,7 +133,8 @@
 		return (-1);
 	}
 
-	did_hash_init(mp);
+	if (did_hash_init(mp) != 0)
+		return (-1);
 
 	rv = platform_iob_enum(mp, pn, imin, imax);
 
--- a/usr/src/lib/fm/topo/modules/sun4v/hostbridge/hb_sun4v.c	Mon Sep 10 04:12:38 2007 -0700
+++ b/usr/src/lib/fm/topo/modules/sun4v/hostbridge/hb_sun4v.c	Mon Sep 10 08:13:47 2007 -0700
@@ -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.
  */
 
@@ -77,7 +77,8 @@
 		}
 		pnode = di_drv_next_node(pnode);
 	}
-	rcs_process(mod, rcs, ptn);
+	if (rcs_process(mod, rcs, ptn) != 0)
+		return (-1);
 	busorrc_free(mod, rcs);
 	return (0);
 }
--- a/usr/src/lib/fm/topo/modules/sun4v/motherboard/motherboard.c	Mon Sep 10 04:12:38 2007 -0700
+++ b/usr/src/lib/fm/topo/modules/sun4v/motherboard/motherboard.c	Mon Sep 10 08:13:47 2007 -0700
@@ -274,8 +274,14 @@
 	(void) mb_get_pri_info(mod, &serial, &part, &csn);
 
 	if (nvlist_lookup_string(auth, FM_FMRI_AUTH_CHASSIS, &pstr) != 0 &&
-	    csn != NULL)
-		nvlist_add_string(auth, FM_FMRI_AUTH_CHASSIS, csn);
+	    csn != NULL) {
+		if (nvlist_add_string(auth, FM_FMRI_AUTH_CHASSIS, csn) != 0) {
+			topo_mod_dprintf(mod,
+			    "failed to add chassis to auth");
+			nvlist_free(auth);
+			return (NULL);
+		}
+	}
 
 	fmri = topo_mod_hcfmri(mod, NULL, FM_HC_SCHEME_VERSION, name, i,
 	    NULL, auth, part, NULL, serial);
--- a/usr/src/lib/libc/port/gen/getutx.c	Mon Sep 10 04:12:38 2007 -0700
+++ b/usr/src/lib/libc/port/gen/getutx.c	Mon Sep 10 08:13:47 2007 -0700
@@ -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.
  */
 
@@ -91,8 +91,8 @@
 #define	MAXFILE		79	/* Maximum pathname length for "utmpx" file */
 
 #define	MAXVAL		255		/* max value for an id `character' */
-#define	IPIPE		"/etc/initpipe"	/* FIFO to send pids to init */
-#define	UPIPE		"/etc/utmppipe"	/* FIFO to send pids to utmpd */
+#define	IPIPE		"/var/run/initpipe"	/* FIFO to send pids to init */
+#define	UPIPE		"/var/run/utmppipe"	/* FIFO to send pids to utmpd */
 
 #define	VAR_UTMPX_FILE	"/var/adm/utmpx" /* for sanity check only */
 
--- a/usr/src/lib/libipmi/common/ipmi_impl.h	Mon Sep 10 04:12:38 2007 -0700
+++ b/usr/src/lib/libipmi/common/ipmi_impl.h	Mon Sep 10 08:13:47 2007 -0700
@@ -83,6 +83,11 @@
  */
 extern ipmi_transport_t ipmi_transport_bmc;
 
+/*
+ * Miscellaneous routines
+ */
+extern void ipmi_sdr_clear(ipmi_handle_t *);
+
 #ifdef	__cplusplus
 }
 #endif
--- a/usr/src/lib/libipmi/common/ipmi_sdr.c	Mon Sep 10 04:12:38 2007 -0700
+++ b/usr/src/lib/libipmi/common/ipmi_sdr.c	Mon Sep 10 08:13:47 2007 -0700
@@ -78,16 +78,7 @@
 	ipmi_sdr_generic_locator_t *gen_src, *gen_dst;
 	ipmi_sdr_fru_locator_t *fru_src, *fru_dst;
 
-	/*
-	 * Free any existing SDRs.
-	 */
-	while (ihp->ih_sdr_cache != NULL) {
-		ent = ihp->ih_sdr_cache->isc_next;
-		ipmi_free(ihp, ent->isc_generic);
-		ipmi_free(ihp, ent->isc_fru);
-		ipmi_free(ihp, ent);
-		ihp->ih_sdr_cache = ent;
-	}
+	ipmi_sdr_clear(ihp);
 
 	/*
 	 * Iterate over all existing SDRs and add them to the cache.
@@ -147,6 +138,20 @@
 	return (0);
 }
 
+void
+ipmi_sdr_clear(ipmi_handle_t *ihp)
+{
+	ipmi_sdr_cache_ent_t *ent, *next;
+
+	while ((ent = ihp->ih_sdr_cache) != NULL) {
+		next = ent->isc_next;
+		ipmi_free(ihp, ent->isc_generic);
+		ipmi_free(ihp, ent->isc_fru);
+		ipmi_free(ihp, ent);
+		ihp->ih_sdr_cache = next;
+	}
+}
+
 ipmi_sdr_t *
 ipmi_sdr_get(ipmi_handle_t *ihp, uint16_t id, uint16_t *next)
 {
--- a/usr/src/lib/libipmi/common/libipmi.c	Mon Sep 10 04:12:38 2007 -0700
+++ b/usr/src/lib/libipmi/common/libipmi.c	Mon Sep 10 08:13:47 2007 -0700
@@ -70,6 +70,7 @@
 {
 	if (ihp->ih_transport && ihp->ih_tdata)
 		ihp->ih_transport->it_close(ihp->ih_tdata);
+	ipmi_sdr_clear(ihp);
 	free(ihp);
 }