pooladm.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* 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.
*
* 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 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* pooladm - set, remove, or display active pool configurations.
*/
#include <stdio.h>
#include <stdlib.h>
#include <libintl.h>
#include <locale.h>
#include <string.h>
#include <priv.h>
#include <errno.h>
#include <zone.h>
#include <pool.h>
#include <unistd.h>
#include "utils.h"
#ifndef TEXT_DOMAIN
#define TEXT_DOMAIN "SYS_TEST"
#endif
static int Cflag;
static int Sflag;
static int Dflag;
static int Eflag;
static int Nflag;
static int Xflag;
static void
usage(void)
{
gettext("Usage:\tpooladm [-n] [-s] [-c] [filename]\n"));
gettext("Usage:\tpooladm [-n] -x\n"));
gettext("Usage:\tpooladm -d | -e\n"));
}
static void
{
char *buf;
const char *tgt;
!= PO_SUCCESS)
tgt, get_errstr());
(void) pool_conf_close(conf);
}
static void
{
!= PO_SUCCESS)
}
static void
{
if (!Nflag) {
get_errstr());
/*
* Dump the updated state to the specified location
*/
if (Sflag) {
}
}
(void) pool_conf_close(conf);
}
int
{
char c;
const char *static_conf_loc;
(void) textdomain(TEXT_DOMAIN);
switch (c) {
case 'c': /* Create (or modify) system configuration */
Cflag++;
break;
case 'd': /* Disable the pools facility */
Dflag++;
break;
case 'e': /* Enable the pools facility */
Eflag++;
break;
case 'n': /* Don't actually do anything */
Nflag++;
break;
case 's': /* Update the submitted configuration */
Sflag++;
break;
case 'x': /* Delete current system configuration */
Xflag++;
break;
case '?':
default:
usage();
/*NOTREACHED*/
}
}
/*
* Not all flags can be used at the same time.
*/
usage();
usage();
usage();
if (argc != 0)
usage();
} else {
if (argc == 0)
else if (argc == 1)
static_conf_loc = argv[0];
else
usage();
}
if (Dflag) {
} else if (Eflag) {
": System has active processor sets\n"));
else
}
} else {
/*
* No flags means print current system configuration
*/
/*
* Destroy active pools configuration and
* remove the state file.
*/
} else {
/*
* Commit a new configuration.
*/
if (Cflag)
else {
/*
* Dump the dynamic state to the
* specified location
*/
if (pool_conf_open(conf,
!= PO_SUCCESS)
get_errstr());
if (pool_conf_export(conf,
(void) pool_conf_close(conf);
}
}
}
}
return (E_PO_SUCCESS);
}