Esempio n. 1
0
static boolean_t
prop_exists(picl_nodehdl_t node, char *name)
{
	int status;
	picl_prophdl_t proph;

	status = ptree_get_prop_by_name(node, name, &proph);
	if (status == PICL_SUCCESS)
		return (B_TRUE);
	else
		return (B_FALSE);
}
Esempio n. 2
0
/*
 * Get PICL_PTYPE_CHARSTRING "UnitAddress" property
 */
static int
get_unit_address_prop(picl_nodehdl_t nodeh, void *buf, size_t len)
{
	int			err;
	picl_prophdl_t		proph;
	ptree_propinfo_t	pinfo;

	err = ptree_get_prop_by_name(nodeh, PICL_PROP_UNIT_ADDRESS, &proph);
	if (err == PICL_SUCCESS)
		err = ptree_get_propinfo(proph, &pinfo);

	if (err != PICL_SUCCESS)
		return (err);

	if (pinfo.piclinfo.type != PICL_PTYPE_CHARSTRING ||
	    pinfo.piclinfo.size > len)
		return (PICL_FAILURE);

	err = ptree_get_propval(proph, buf, pinfo.piclinfo.size);
	return (err);
}
Esempio n. 3
0
/*
 * This function returns the handle of a property specified by its name
 */
static void
picld_get_attr_by_name(picl_service_t *in)
{
	picl_retattrbyname_t	ret;
	int			err;
	picl_prophdl_t		ptreeh;

	err = cvt_picl2ptree(in->req_attrbyname.nodeh, &ptreeh);
	if (err != PICL_SUCCESS)
		picld_return_error(in->in.cnum, err);

	ret.cnum = PICL_CNUM_GETATTRBYNAME;
	ret.nodeh = in->req_attrbyname.nodeh;
	(void) strcpy(ret.propname, in->req_attrbyname.propname);

	err = ptree_get_prop_by_name(ptreeh, ret.propname, &ret.attr);
	if (err != PICL_SUCCESS)
		picld_return_error(in->in.cnum, err);

	cvt_ptree2picl(&ret.attr);
	(void) rw_unlock(&init_lk);
	(void) door_return((char *)&ret, sizeof (picl_retattrbyname_t), NULL,
	    0);
}
Esempio n. 4
0
static picl_errno_t
env_handle_chassis_configuring_event(char *state)
{
	picl_errno_t rc = PICL_SUCCESS;
	picl_prophdl_t proph;
	picl_nodehdl_t rtm_lnodehdl = 0;
	char *cpu_name = PICL_NODE_CPU;
	char *rtm_name = PICL_NODE_RTM;
	uint64_t status_time;

	if (strcmp(state, PICLEVENTARGVAL_CONFIGURING) != 0) {
		return (PICL_SUCCESS);
	}

	/* initialize cpu loc node handle */
	if (cpu_lnodehdl == 0) {
		if ((rc = ptree_find_node(chassis_nodehdl,
			PICL_PROP_NAME,	PICL_PTYPE_CHARSTRING,
			cpu_name, (strlen(cpu_name) + 1),
			&cpu_lnodehdl)) != PICL_SUCCESS) {
			syslog(LOG_ERR, gettext("SUNW_envmond: failed "
			" to get CPU nodehdl, error = %d"), rc);
			return (rc);
		}
	}

	/* create geo-addr prop under CPU location */
	if (ptree_get_prop_by_name(cpu_lnodehdl, PICL_PROP_GEO_ADDR,
		&proph) == PICL_PROPNOTFOUND) {
		if ((rc = env_create_property(PICL_PTYPE_UNSIGNED_INT,
			PICL_READ, sizeof (cpu_geo_addr),
			PICL_PROP_GEO_ADDR, NULLREAD, NULLWRITE,
			cpu_lnodehdl, &proph,
			(void *)&cpu_geo_addr)) != PICL_SUCCESS) {
			return (rc);
		}
	}
	if (ptree_get_prop_by_name(cpu_lnodehdl,
		PICL_PROP_STATUS_TIME, &proph) != PICL_SUCCESS) {
			status_time = (uint64_t)time(NULL);
			(void) env_create_property(PICL_PTYPE_TIMESTAMP,
				PICL_READ, sizeof (status_time),
				PICL_PROP_STATUS_TIME, NULLREAD, NULLWRITE,
				cpu_lnodehdl, &proph, &status_time);
	}

	/* create geo address property for RTM node (if present) */
	(void) ptree_find_node(chassis_nodehdl,
		PICL_PROP_NAME,	PICL_PTYPE_CHARSTRING, rtm_name,
		(strlen(rtm_name) + 1), &rtm_lnodehdl);

	if (rtm_lnodehdl == 0) {	/* RTM not present */
		return (PICL_SUCCESS);
	}

	if (ptree_get_prop_by_name(rtm_lnodehdl, PICL_PROP_GEO_ADDR,
		&proph) == PICL_PROPNOTFOUND) {
		if ((rc = env_create_property(PICL_PTYPE_UNSIGNED_INT,
			PICL_READ, sizeof (cpu_geo_addr), PICL_PROP_GEO_ADDR,
			NULLREAD, NULLWRITE, rtm_lnodehdl, &proph,
			&cpu_geo_addr)) != PICL_SUCCESS) {
			syslog(LOG_ERR, gettext("SUNW_envmond:Failed "
				"to create CPU geo-addr, error = %d"), rc);
			return (rc);
		}
	}
	if (ptree_get_prop_by_name(rtm_lnodehdl,
		PICL_PROP_STATUS_TIME, &proph) != PICL_SUCCESS) {
		status_time = (uint64_t)time(NULL);
		(void) env_create_property(PICL_PTYPE_TIMESTAMP,
			PICL_READ, sizeof (status_time), PICL_PROP_STATUS_TIME,
			NULLREAD, NULLWRITE, rtm_lnodehdl, &proph,
			&status_time);
	}

	/* start all the environment monitoring services */
	if ((rc = env_start_services()) != PICL_SUCCESS) {
		return (rc);
	}
	return (PICL_SUCCESS);
}