rcapd_conf.l revision f1710550bd8341486e7494e781335ba875c9b12c
%{
/*
* 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 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <strings.h>
#include <fcntl.h>
#include <unistd.h>
#include "rcapd.h"
#include "rcapd_conf.h"
#include "rcapd_stat.h"
#include "utils.h"
#define LINELEN 256
/*PRINTFLIKE1*/
static void
{
alist);
/*NOTREACHED*/
}
} \
}
typedef union {
int id;
} yystype_t;
%}
%x fn
%%
<fn>\= { return (RCT_EQUALS); }
<fn>[ \t] { break; }
"RCAPD_MODE" { return (RCT_MODE_VAR); }
"RCAPD_STATE" { return (RCT_STATE); }
"RCAPD_PROC_WALK_INTERVAL" { return (RCT_PROC_WALK_INTERVAL_VAR); }
"RCAPD_RECONFIGURATION_INTERVAL" { return
}
"RCAPD_REPORT_INTERVAL" \
{ return (RCT_REPORT_INTERVAL_VAR); }
"RCAPD_RSS_SAMPLE_INTERVAL" \
{ return (RCT_RSS_SAMPLE_INTERVAL_VAR); }
"RCAPD_MEMORY_CAP_ENFORCEMENT_PRESSURE" \
{ return (RCT_MEMORY_CAP_ENFORCEMENT_PRESSURE_VAR); }
\= { return (RCT_EQUALS); }
[0-9]+ { return (RCT_NUMBER); }
"project" { return (RCT_PROJECT); }
"lnode" { return (RCT_LNODE); }
"on" { return (RCT_ON); }
"off" { return (RCT_OFF); }
[ \t] { break; }
\#.* { break; }
\n { break; }
[^ \t\n]* { return (RCT_INVALID); }
%%
/*
* Read the supplied configuration file and set the fields of an rcfg_t
* correspondingly. Verify that the statistics file is writable, with the
* optional verify_stat_file_creation() callback.
*
* fd should be the number of a low-numbered (<256) file descriptor on 32-bit
* processes, as stdio requires them to be in that range. The actual
* descriptor will be recorded in rcfg and left open, and may be supplied in
* future calls to rcfg_read(), simplifying descriptor distribution.
*/
int
int(*verify_stat_file_creation)(void))
{
rctoken_t l;
FILE *f;
if (fd >= 0)
return (-1);
return (-1);
return (-1);
}
yyin = f;
l = 0;
for (; (l = yylex()) != 0; ) {
switch (l) {
case RCT_MODE_VAR:
l = yylex();
if (l == RCT_PROJECT) {
} else if (l == RCT_LNODE) {
/*
* Provided for compatibility with old
* configuration files. The consumer is
* expected to warn that the mode setting is
* ineffective when anything other than
* "project" is specified.
*/
} else
"\"project\", and is unused.\n");
break;
case RCT_STATE:
/* legacy variable is ignored */
l = yylex();
break;
case RCT_REPORT_INTERVAL_VAR:
"(seconds)\n");
break;
"(seconds)\n");
break;
case RCT_STAT_FILE_VAR:
if (yytext[0] != '/')
break;
"(seconds)\n");
debug("%s: reconfiguration interval: %d seconds\n",
break;
"(seconds)\n");
debug("%s: proc_walk interval: %d seconds\n",
break;
break;
default:
}
}
/*
* Set project mode, by default.
*/
}
if (verify_stat_file_creation != 0 && verify_stat_file_creation() != 0)
return (0);
}
void
{
}
/*
* Create the configuration file given the rcfg_t structure. If a rcfg_t
* structure is NULL, create the configuration file with default parameters.
*/
void
{
char *fname = RCAPD_DEFAULT_CONF_FILE;
char *template;
create_default = 1;
/* Initialize config file with default parameters */
}
template);
template);
}
"# Configuration parameters for resource capping daemon.\n"
"# Do NOT edit by hand -- use rcapadm(1m) instead.\n"
"#\n", fp);
template);
}
template);
}
if (create_default == 1)
}