highlevel.c revision 57b30532f440463cfdc0decec0c4b07e9c0991f6
/*
* 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
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* This file contains high level functions used by multiple utilities.
*/
#include "libscf_impl.h"
#include <assert.h>
#include <libuutil.h>
#include <string.h>
#include <stdlib.h>
#include <sys/systeminfo.h>
#ifdef __x86
#include <smbios.h>
/*
* Check whether the platform is on the fastreboot_blacklist.
* Return 1 if the platform has been blacklisted, 0 otherwise.
*/
static int
scf_is_fb_blacklisted(void)
{
int err;
int i;
char *platform_name;
int blacklisted = 0;
/*
* If there's no SMBIOS, assume it's blacklisted.
*/
return (1);
/*
* If we can't read system info, assume it's blacklisted.
*/
blacklisted = 1;
goto fb_out;
}
/*
* If we can't read the "platforms" property from property group
* BOOT_CONFIG_PG_FBBLACKLIST, assume no platforms have
* been blacklisted.
*/
goto fb_out;
for (i = 0; i < numvals; i++) {
if (platform_name == NULL)
break;
blacklisted = 1;
break;
}
}
return (blacklisted);
}
/*
* Add or get a property group given an FMRI.
* Return SCF_SUCCESS on success, SCF_FAILED on failure.
*/
static int
{
int rc = SCF_FAILED;
int error;
scf_handle_bind(handle) != 0 ||
goto scferror;
if (add) {
/*
* If the property group already exists, return SCF_SUCCESS.
*/
rc = SCF_SUCCESS;
} else {
}
if (rc != SCF_SUCCESS)
if (handle)
(void) scf_handle_unbind(handle);
if (rc != SCF_SUCCESS)
(void) scf_set_error(error);
return (rc);
}
#endif /* __x86 */
/*
* Get config properties from svc:/system/boot-config:default.
* It prints errors with uu_warn().
*/
void
{
*boot_config = 0;
#ifndef __x86
return;
#else
{
/*
* Property vector for BOOT_CONFIG_PG_PARAMS property group.
*/
scf_propvec_t ua_boot_config[] = {
{ NULL }
};
/*
* Unset both flags if the platform has been
* blacklisted.
*/
if (scf_is_fb_blacklisted())
*boot_config &= ~(UA_FASTREBOOT_DEFAULT |
return;
}
#if defined(FASTREBOOT_DEBUG)
(void) uu_warn("Service %s property '%s/%s' "
"not found.\n", FMRI_BOOT_CONFIG,
} else {
(void) uu_warn("Unable to read service %s "
"property '%s': %s\n", FMRI_BOOT_CONFIG,
}
#endif /* FASTREBOOT_DEBUG */
}
#endif /* __x86 */
}
/*
* Get or set properties in non-persistent "config_ovr" property group
* in svc:/system/boot-config:default.
* It prints errors with uu_warn().
*/
/*ARGSUSED*/
static int
{
int rc = SCF_SUCCESS;
#ifndef __x86
return (rc);
#else
{
/*
* Property vector for BOOT_CONFIG_PG_OVR property group.
*/
{ NULL }
};
if (rc != SCF_SUCCESS) {
#if defined(FASTREBOOT_DEBUG)
if (set)
(void) uu_warn("Unable to add service %s "
"property group '%s'\n",
#endif /* FASTREBOOT_DEBUG */
return (rc);
}
if (set)
else
&prop);
#if defined(FASTREBOOT_DEBUG)
if (rc != SCF_SUCCESS) {
(void) uu_warn("Service %s property '%s/%s' "
"not found.\n", FMRI_BOOT_CONFIG,
} else {
(void) uu_warn("Unable to %s service %s "
scf_strerror(scf_error()));
}
}
#endif /* FASTREBOOT_DEBUG */
return (rc);
}
#endif /* __x86 */
}
/*
* Get values of properties in non-persistent "config_ovr" property group.
*/
static void
{
}
/*
* Set value of "config_ovr/fastreboot_default".
*/
int
{
}
/*
* Check whether Fast Reboot is the default operating mode.
* Return 0 if
* 1. the platform is xVM
* or
* 2. svc:/system/boot-config:default service doesn't exist,
* or
* 3. property "config/fastreboot_default" doesn't exist,
* or
* 4. value of property "config/fastreboot_default" is set to "false"
* and "config_ovr/fastreboot_default" is not set to "true",
* or
* 5. the platform has been blacklisted.
* or
* 6. value of property "config_ovr/fastreboot_default" is set to "false".
* Return non-zero otherwise.
*/
int
scf_is_fastboot_default(void)
{
/*
* If we are on xVM, do not fast reboot by default.
*/
return (0);
/*
* Get property values from "config" property group
*/
/*
* Get property values from non-persistent "config_ovr" property group
*/
}