/*
* 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
* 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
*/
/*
*/
/*
* Consolidation Private libpower APIs
*/
#include <stdio.h>
#include <errno.h>
#include <libintl.h>
#include <locale.h>
#include <unistd.h>
#include <strings.h>
#include <libuutil.h>
#include <libnvpair.h>
#include <libscf.h>
#include <libpower.h>
#include <libpower_impl.h>
};
static void pm_fini_internal(void);
#pragma init(pm_init_internal)
static void
{
const char *debug;
if (!issetugid() &&
0, 0, 0) == -1) {
}
(void) atexit(pm_fini_internal);
}
static void
{
}
}
/*
* pm_getprop allows the caller to retrieve a specified list of
* property values from the kernel. The query may include an
* optional authority, which filters on the values stored from
* SMF, the PLATFORM, or the CURRENT values.
*
* A valid query list consists of 2 name value pairs:
*
* Name Description
* ------------------ ---------------------------------------
* PM_PROP_AUTHORITY The data source to query as a string.
* May include PM_AUTHORITY_ANY to query
* all available data sources.
* PM_PROP_QUERY An nvlist string array where each element
* in the array is the property to query.
* See below.
*
* A property may have the form:
* [property_group_name/]property_name
*
* where a property_group_name, if specified, indicates a particular
* set of managed properties. If the property_group_name is specified,
* only data sources within that managed group of properties that match
* the authority specifier will be queried.
*
* If the property_group_name is not specified, all specified data
* sources for all managed groups will be queried.
*/
{
char **propv;
char *authname;
err = PM_SUCCESS;
errno = 0;
&propc) != 0) {
/* One or more of the required arguments is invalid */
return (PM_ERROR_INVALID_ARGUMENT);
}
/* Validate the authority given in the query */
if (authority == PM_AUTHORITY_INVALID) {
"%s invalid authority %s in query\n", __FUNCTION__,
authname);
return (PM_ERROR_INVALID_AUTHORITY);
}
/*
* Retrieve all of the properties from the kernel and add in any
* new properties from SMF, which includes property group names and
* decorate the existing ones with current and platform values.
*/
if (err == PM_SUCCESS) {
if (err == PM_SUCCESS) {
/*
* Filter the results and pick out just what was
* requested
*/
}
}
return (err);
}
{
errno = 0;
return (PM_ERROR_INVALID_ARGUMENT);
}
err = PM_SUCCESS;
/*
* Attempt to write this property to SMF. Each property
* is written in it's own transaction. This means that
* if a property fails to write, the properties that came
* before it will succeed.
*
* This is less than ideal. However, property writes using
* the interface we are using requires all the properties to
* be in the same property group; we have multiple groups
* and this opens up the possibility of partial success
* anyway.
*/
/* prepare for the next iteration */
}
if (err == PM_SUCCESS) {
/*
* Request an SMF refresh to sync the updated values with
* the kernel. This will happen asynchronously, and if it
* fails the service will be put in to maintenance.
*/
switch (serr) {
case SCF_SUCCESS:
/* DO NOTHING */
break;
default:
/*
* Indicate to the caller than an SMF error has
* occurred.
*/
"%s unable to refresh %s: %s\n",
scf_strerror(scf_error()));
err = PM_ERROR_SCF;
break;
}
}
return (err);
}
{
errno = 0;
return (PM_ERROR_INVALID_ARGUMENT);
}
/*
* Retrieve properties from the kernel and decorate existing
* properties with current values.
*/
if (err == PM_SUCCESS) {
/*
* Add all properties from SMF. This will populate the result
* list with property group names automatically.
*/
}
return (err);
}
{
/* Retrieve all of the SMF properties for possible sync */
errno = 0;
if (err != PM_SUCCESS) {
/*
* An error occurred reading from SMF. Pass the error up
* to the caller to process.
*/
return (err);
}
/* Attempt to write the SMF properties to the kernel */
errno = 0;
/* Clean up */
/*
* Return an error that indicates that the proper exit code is
* stored in the error data so that the caller, assumed to be
* executed by SMF, can return the proper exit code.
*/
return (err);
}
{
int i;
int nauths;
/* No authority name was given. This is invalid */
return (PM_AUTHORITY_INVALID);
}
/* Scan the list of authorities for a matching entry */
for (i = 0; i < nauths; i++) {
const char *np;
continue;
}
/* Match. Return the current authority */
return (pm_authorities[i].a_auth);
}
}
return (PM_AUTHORITY_INVALID);
}
const char *
{
int i;
int nauths;
/* Scan the list of all authorities for the given value */
/* We have a match. Return the authority value. */
break;
}
}
return (result);
}
{
int i;
int nauths;
/* Use PM_AUTHORITY_INVALID to start a scan of authorities */
if (start == PM_AUTHORITY_INVALID) {
return (result);
}
i = 0;
while (i < nauths) {
i++;
break;
}
/* Check the next authority */
i++;
}
if (i < nauths) {
/* Get the authority to return */
}
/*
* Return the next authority. If the result is PM_AUTHORITY_INVALID,
* the end of the list has been encountered.
*/
return (result);
}