/*
* 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 (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include <limits.h>
#include <wait.h>
#include <zone.h>
#include <sys/priocntl.h>
#include "dispadmin.h"
/*
* This file contains the code implementing the class independent part
* of the dispadmin command. Most of the functionality of the dispadmin
* command is provided by the class specific sub-commands, the code for
* which is elsewhere. The class independent part of the command is
* responsible for switching out to the appropriate class specific
* sub-command based on the user supplied class argument.
* Code in this file should never assume any knowledge of any specific
* scheduler class (other than the SYS class).
*/
extern char *basename();
static char usage[] =
"usage: dispadmin -l\n\
dispadmin -c class [class-specific options]\n\
dispadmin -d [class]\n";
static void print_classlist();
static void exec_cscmd(char *, char **);
static void set_scheduler(char *);
static void class_info(pcinfo_t *);
static void set_default_class();
int
{
extern char *optarg;
int c;
char *clname;
opterr = 0;
switch (c) {
case 'c':
cflag++;
break;
case 'd':
dflag++;
break;
case 'l':
lflag++;
break;
case 'u':
uflag++;
break;
case '?':
/*
* We assume for now that any option that
* getopt() doesn't recognize is intended for a
* class specific subcommand.
*/
csoptsflag++;
/*
* Class specific option takes an
* argument which we skip over for now.
*/
optind++;
}
break;
default:
break;
}
}
if (lflag) {
exit(0);
} else if (uflag) {
} else if (cflag) {
} else if (dflag) {
exit(0);
} else {
}
return (1);
}
/*
* Print the heading for the class list and execute the
* class specific sub-command with the -l option for each
* configured class.
*/
static void
{
int nclass;
fatalerr("%s: Can't get number of configured classes\n",
cmdpath);
(void) printf("CONFIGURED CLASSES\n==================\n\n");
(void) printf("SYS\t(System Class)\n");
fatalerr("%s: Can't get class name (class ID = %d)\n",
class_info(&pcinfo);
}
}
/*
* Execute the appropriate class specific sub-command for the class
* specified by clname, passing it the arguments in subcmdargv.
*/
static void
{
/*
* Do a quick check to make sure clname is valid.
* We could just wait and see if the exec below
* succeeds but we wouldn't know much about the reason.
* This way we can give the user a more meaningful error
* message.
*/
clname);
subcmdargv[0] = subcmdpath;
}
static void
{
int pid;
fatalerr("%s\n\tCan't execute %s specific subcommand\n",
"%s\nCan't execute %s specific subcommand)\n",
} else {
}
}
/*
* Return the current default scheduling class as specified in
* /etc/dispadmin.conf.
*/
static char *
{
int line;
int len;
continue;
/* LINTED - unbounded string specifier */
fatalerr("\"%s\", line %d: invalid "
} else {
line);
}
}
if (line == 1)
return (NULL);
}
/*
* Set the default scheduling class for the system.
* Update /etc/dispadmin.conf if necessary.
*/
static void
{
int fd;
if (getzoneid() != GLOBAL_ZONEID)
fatalerr("%s: Operation not supported in non-global zones\n",
cmdpath);
fatalerr("%s: Default scheduling class "
"is not set\n", cmdpath);
else
fatalerr("%s: Failed to open %s (%s)\n",
}
fatalerr("%s: Failed to open stream for %s (%s)\n",
fatalerr("\"%s\", scheduling class %s is not "
else
class_info(&pcinfo);
return;
}
/*
* Do a quick check to make sure clname is valid class name.
*/
clname);
(void) fputs("#\n# /etc/dispadmin.conf\n#\n"
"# Do NOT edit this file by hand -- use dispadmin(1m) instead.\n"
"#\n", fp);
"%s: warning: failed to flush config file\n",
cmdpath);
"%s: warning: failed to sync config file to disk\n",
cmdpath);
"%s: warning: failed to reset config file mode\n",
cmdpath);
"%s: warning: failed to reset config file owner\n",
cmdpath);
fatalerr("%s: failed to set default class %s in kernel: %s\n",
}
static void
{
char *clname;
int fd;
/* silently succeed, there is nothing to do */
return;
else
fatalerr("%s: Failed to open %s (%s)\n",
}
fatalerr("%s: Failed to open stream for %s (%s)\n",
fatalerr("%s: failed to set default class %s in "
}
}