zonecfg_grammar.y revision ff19e029e81c950f4e0f40f1f1ee1f7d8f8d8041
%{
/*
* 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
*/
/*
*/
#include <stdio.h>
#include <strings.h>
#include "zonecfg.h"
extern boolean_t newline_terminated;
extern int num_prop_vals; /* # of property values */
/* yacc externals */
extern int yydebug;
extern void yyerror(char *s);
/*
* This function is used by the simple_prop_val reduction rules to set up
* a list_property_ptr_t and adjust the above global variables appropriately.
* Note that this function duplicates the specified string and makes
* the new list's lp_simple field point to the duplicate. This function does
* not free the original string.
*
* This function returns a pointer to the duplicated string or NULL if an error
* occurred. The simple_prop_val reduction rules that invoke this function
* should set $$ to the returned pointer.
*/
static char *
simple_prop_val_func(const char *str)
{
char *retstr;
return (NULL);
return (NULL);
}
} else {
}
return (retstr);
}
/*
* This function is used by the complex_piece reduction rules to set up a
* complex_property_prt_t and adjust the above global variables appropriately.
* Note that this function duplicates the specified string and makes the new
* complex_property_ptr_t's cp_value field point to the duplicate. It also sets
* the complex_property_ptr_t's cp_type field to cp_type and its cp_next field
* to cp_next. This function does not free the original string.
*
* This function returns a pointer to the complex_property_t created for the
* complex_piece or NULL if an error occurred. The complex_piece reduction
* rules that invoke this function should set $$ to the returned pointer.
*/
static complex_property_ptr_t
{
return (NULL);
return (NULL);
}
return (retval);
}
%}
%union {
int ival;
char *strval;
}
%%
{
if ($1 != NULL) {
free_cmd($1);
num_prop_vals = 0;
}
return (0);
}
{
if ($1 != NULL) {
free_cmd($1);
num_prop_vals = 0;
}
if (YYRECOVERING())
}
{
if (YYRECOVERING())
}
{
return (0);
}
{
}
{
cmd = $$;
$$->cmd_handler = &add_func;
$$->cmd_argc = 1;
$$->cmd_argv[0] = $2;
}
{
cmd = $$;
$$->cmd_handler = &add_func;
$$->cmd_argc = 0;
$$->cmd_res_type = $2;
$$->cmd_prop_nv_pairs = 0;
}
{
cmd = $$;
$$->cmd_handler = &add_func;
$$->cmd_argc = 0;
$$->cmd_prop_nv_pairs = 1;
$$->cmd_prop_name[0] = $2;
$$->cmd_property_ptr[0] = &property[0];
}
{
cmd = $$;
$$->cmd_handler = &cancel_func;
$$->cmd_argc = 0;
}
{
cmd = $$;
$$->cmd_handler = &cancel_func;
$$->cmd_argc = 1;
$$->cmd_argv[0] = $2;
}
{
cmd = $$;
$$->cmd_handler = &create_func;
$$->cmd_argc = 0;
}
{
cmd = $$;
$$->cmd_handler = &create_func;
$$->cmd_argc = 1;
$$->cmd_argv[0] = $2;
}
{
cmd = $$;
$$->cmd_handler = &create_func;
$$->cmd_argc = 2;
$$->cmd_argv[0] = $2;
}
{
cmd = $$;
$$->cmd_handler = &create_func;
$$->cmd_argc = 3;
$$->cmd_argv[0] = $2;
}
{
cmd = $$;
$$->cmd_handler = &commit_func;
$$->cmd_argc = 0;
}
{
cmd = $$;
$$->cmd_handler = &commit_func;
$$->cmd_argc = 1;
$$->cmd_argv[0] = $2;
}
{
cmd = $$;
$$->cmd_handler = &delete_func;
$$->cmd_argc = 0;
}
{
cmd = $$;
$$->cmd_handler = &delete_func;
$$->cmd_argc = 1;
$$->cmd_argv[0] = $2;
}
{
cmd = $$;
$$->cmd_handler = &end_func;
$$->cmd_argc = 0;
}
{
cmd = $$;
$$->cmd_handler = &end_func;
$$->cmd_argc = 1;
$$->cmd_argv[0] = $2;
}
{
cmd = $$;
$$->cmd_handler = &exit_func;
$$->cmd_argc = 0;
}
{
cmd = $$;
$$->cmd_handler = &exit_func;
$$->cmd_argc = 1;
$$->cmd_argv[0] = $2;
}
{
cmd = $$;
$$->cmd_handler = &export_func;
$$->cmd_argc = 0;
}
{
cmd = $$;
$$->cmd_handler = &export_func;
$$->cmd_argc = 1;
$$->cmd_argv[0] = $2;
}
{
cmd = $$;
$$->cmd_handler = &export_func;
$$->cmd_argc = 2;
$$->cmd_argv[0] = $2;
}
{
cmd = $$;
$$->cmd_handler = &help_func;
$$->cmd_argc = 0;
}
{
cmd = $$;
$$->cmd_handler = &help_func;
$$->cmd_argc = 1;
$$->cmd_argv[0] = $2;
}
{
cmd = $$;
$$->cmd_handler = &info_func;
$$->cmd_res_type = RT_UNKNOWN;
$$->cmd_prop_nv_pairs = 0;
}
{
free($2);
}
{
cmd = $$;
$$->cmd_handler = &info_func;
$$->cmd_res_type = $2;
$$->cmd_prop_nv_pairs = 0;
}
{
cmd = $$;
$$->cmd_handler = &info_func;
$$->cmd_res_type = RT_ZONENAME;
$$->cmd_prop_nv_pairs = 0;
}
{
cmd = $$;
$$->cmd_handler = &info_func;
$$->cmd_res_type = RT_ZONEPATH;
$$->cmd_prop_nv_pairs = 0;
}
{
cmd = $$;
$$->cmd_handler = &info_func;
$$->cmd_res_type = RT_BRAND;
$$->cmd_prop_nv_pairs = 0;
}
{
cmd = $$;
$$->cmd_handler = &info_func;
$$->cmd_res_type = RT_AUTOBOOT;
$$->cmd_prop_nv_pairs = 0;
}
{
cmd = $$;
$$->cmd_handler = &info_func;
$$->cmd_res_type = RT_IPTYPE;
$$->cmd_prop_nv_pairs = 0;
}
{
cmd = $$;
$$->cmd_handler = &info_func;
$$->cmd_res_type = RT_POOL;
$$->cmd_prop_nv_pairs = 0;
}
{
cmd = $$;
$$->cmd_handler = &info_func;
$$->cmd_res_type = RT_LIMITPRIV;
$$->cmd_prop_nv_pairs = 0;
}
{
cmd = $$;
$$->cmd_handler = &info_func;
$$->cmd_res_type = RT_BOOTARGS;
$$->cmd_prop_nv_pairs = 0;
}
{
cmd = $$;
$$->cmd_handler = &info_func;
$$->cmd_res_type = RT_SCHED;
$$->cmd_prop_nv_pairs = 0;
}
{
cmd = $$;
$$->cmd_handler = &info_func;
$$->cmd_res_type = RT_SHARES;
$$->cmd_prop_nv_pairs = 0;
}
{
cmd = $$;
$$->cmd_handler = &info_func;
$$->cmd_res_type = RT_MAXLWPS;
$$->cmd_prop_nv_pairs = 0;
}
{
cmd = $$;
$$->cmd_handler = &info_func;
$$->cmd_res_type = RT_MAXPROCS;
$$->cmd_prop_nv_pairs = 0;
}
{
cmd = $$;
$$->cmd_handler = &info_func;
$$->cmd_res_type = RT_MAXSHMMEM;
$$->cmd_prop_nv_pairs = 0;
}
{
cmd = $$;
$$->cmd_handler = &info_func;
$$->cmd_res_type = RT_MAXSHMIDS;
$$->cmd_prop_nv_pairs = 0;
}
{
cmd = $$;
$$->cmd_handler = &info_func;
$$->cmd_res_type = RT_MAXMSGIDS;
$$->cmd_prop_nv_pairs = 0;
}
{
cmd = $$;
$$->cmd_handler = &info_func;
$$->cmd_res_type = RT_MAXSEMIDS;
$$->cmd_prop_nv_pairs = 0;
}
{
cmd = $$;
$$->cmd_handler = &info_func;
$$->cmd_res_type = RT_HOSTID;
$$->cmd_prop_nv_pairs = 0;
}
{
cmd = $$;
$$->cmd_handler = &info_func;
$$->cmd_res_type = RT_FS_ALLOWED;
$$->cmd_prop_nv_pairs = 0;
}
{
cmd = $$;
$$->cmd_handler = &info_func;
$$->cmd_res_type = $2;
$$->cmd_prop_nv_pairs = 1;
$$->cmd_prop_name[0] = $3;
$$->cmd_property_ptr[0] = &property[0];
}
{
cmd = $$;
$$->cmd_handler = &info_func;
$$->cmd_res_type = $2;
$$->cmd_prop_nv_pairs = 2;
$$->cmd_prop_name[0] = $3;
$$->cmd_property_ptr[0] = &property[0];
}
| INFO resource_type property_name EQUAL property_value property_name EQUAL property_value property_name EQUAL property_value
{
cmd = $$;
$$->cmd_handler = &info_func;
$$->cmd_res_type = $2;
$$->cmd_prop_nv_pairs = 3;
$$->cmd_prop_name[0] = $3;
$$->cmd_property_ptr[0] = &property[0];
}
{
}
{
}
{
cmd = $$;
$$->cmd_handler = &remove_func;
$$->cmd_res_type = $2;
}
{
cmd = $$;
$$->cmd_handler = &remove_func;
$$->cmd_res_type = $3;
$$->cmd_argc = 1;
$$->cmd_argv[0] = $2;
}
{
cmd = $$;
$$->cmd_handler = &remove_func;
$$->cmd_prop_nv_pairs = 1;
$$->cmd_prop_name[0] = $2;
$$->cmd_property_ptr[0] = &property[0];
}
{
cmd = $$;
$$->cmd_handler = &remove_func;
$$->cmd_res_type = $2;
$$->cmd_prop_nv_pairs = 1;
$$->cmd_prop_name[0] = $3;
$$->cmd_property_ptr[0] = &property[0];
}
{
cmd = $$;
$$->cmd_handler = &remove_func;
$$->cmd_res_type = $2;
$$->cmd_prop_nv_pairs = 2;
$$->cmd_prop_name[0] = $3;
$$->cmd_property_ptr[0] = &property[0];
}
| REMOVE resource_type property_name EQUAL property_value property_name EQUAL property_value property_name EQUAL property_value
{
cmd = $$;
$$->cmd_handler = &remove_func;
$$->cmd_res_type = $2;
$$->cmd_prop_nv_pairs = 3;
$$->cmd_prop_name[0] = $3;
$$->cmd_property_ptr[0] = &property[0];
}
{
cmd = $$;
$$->cmd_handler = &revert_func;
$$->cmd_argc = 0;
}
{
cmd = $$;
$$->cmd_handler = &revert_func;
$$->cmd_argc = 1;
$$->cmd_argv[0] = $2;
}
{
}
{
cmd = $$;
$$->cmd_handler = &select_func;
$$->cmd_res_type = RT_DCPU;
}
{
cmd = $$;
$$->cmd_handler = &select_func;
$$->cmd_res_type = RT_PCAP;
}
{
cmd = $$;
$$->cmd_handler = &select_func;
$$->cmd_res_type = RT_MCAP;
}
{
}
{
cmd = $$;
$$->cmd_handler = &select_func;
$$->cmd_res_type = $2;
$$->cmd_prop_nv_pairs = 1;
$$->cmd_prop_name[0] = $3;
$$->cmd_property_ptr[0] = &property[0];
}
{
cmd = $$;
$$->cmd_handler = &select_func;
$$->cmd_res_type = $2;
$$->cmd_prop_nv_pairs = 2;
$$->cmd_prop_name[0] = $3;
$$->cmd_property_ptr[0] = &property[0];
}
| SELECT resource_type property_name EQUAL property_value property_name EQUAL property_value property_name EQUAL property_value
{
cmd = $$;
$$->cmd_handler = &select_func;
$$->cmd_res_type = $2;
$$->cmd_prop_nv_pairs = 3;
$$->cmd_prop_name[0] = $3;
$$->cmd_property_ptr[0] = &property[0];
}
{
}
{
cmd = $$;
$$->cmd_handler = &set_func;
$$->cmd_prop_nv_pairs = 0;
$$->cmd_prop_name[0] = $2;
$$->cmd_property_ptr[0] = &property[0];
}
{
cmd = $$;
$$->cmd_handler = &set_func;
$$->cmd_prop_nv_pairs = 1;
$$->cmd_prop_name[0] = $2;
$$->cmd_property_ptr[0] = &property[0];
}
{
cmd = $$;
$$->cmd_argc = 1;
$$->cmd_argv[0] = $2;
$$->cmd_handler = &set_func;
$$->cmd_prop_nv_pairs = 1;
$$->cmd_prop_name[0] = PT_ZONEPATH;
$$->cmd_property_ptr[0] = &property[0];
}
{
}
{
cmd = $$;
$$->cmd_handler = &clear_func;
$$->cmd_res_type = $2;
}
{
cmd = $$;
$$->cmd_handler = &verify_func;
$$->cmd_argc = 0;
}
{
cmd = $$;
$$->cmd_handler = &verify_func;
$$->cmd_argc = 1;
$$->cmd_argv[0] = $2;
}
| DATASET { $$ = RT_DATASET; }
| OPTIONS { $$ = PT_OPTIONS; }
| ZONENAME { $$ = PT_ZONENAME; }
| ZONEPATH { $$ = PT_ZONEPATH; }
| AUTOBOOT { $$ = PT_AUTOBOOT; }
| LIMITPRIV { $$ = PT_LIMITPRIV; }
| BOOTARGS { $$ = PT_BOOTARGS; }
| ADDRESS { $$ = PT_ADDRESS; }
| PHYSICAL { $$ = PT_PHYSICAL; }
| DEFROUTER { $$ = PT_DEFROUTER; }
| IMPORTANCE { $$ = PT_IMPORTANCE; }
| MAXLWPS { $$ = PT_MAXLWPS; }
| MAXPROCS { $$ = PT_MAXPROCS; }
| MAXSHMMEM { $$ = PT_MAXSHMMEM; }
| MAXSHMIDS { $$ = PT_MAXSHMIDS; }
| MAXMSGIDS { $$ = PT_MAXMSGIDS; }
| MAXSEMIDS { $$ = PT_MAXSEMIDS; }
| FS_ALLOWED { $$ = PT_FS_ALLOWED; }
/*
* The grammar builds data structures from the bottom up. Thus various
* strings are lexed into TOKENs or commands or resource or property values.
* Below is where the resource and property values are built up into more
* complex data structures.
*
* There are three kinds of properties: simple (single valued), complex
* (one or more name=value pairs) and list (concatenation of one or more
* simple or complex properties).
*
* So the property structure has a type which is one of these, and the
* corresponding _simple, _complex or _list is set to the corresponding
* lower-level data structure.
*/
{
}
}
{
}
}
{
}
/*
* One level lower, lists are made up of simple or complex values, so
* simple_prop_val and complex_prop_val fill in a list structure and
* insert it into the linked list which is built up. And because
* complex properties can have multiple name=value pairs, we keep
* track of them in another linked list.
*
* The complex and list structures for the linked lists are allocated
* below, and freed by recursive functions which are ultimately called
* by free_cmd(), which is called from the top-most "commands" part of
* the grammar.
*
* NOTE: simple_prop_val and complex_piece need reduction rules for
* property_name and resource_type so that the parser will accept property names
* and resource type names as property values.
*/
{
$$ = simple_prop_val_func($1);
free($1);
if ($$ == NULL)
}
{
}
{
}
{
} else {
}
}
{
free($3);
if ($$ == NULL)
}
{
}
{
}
{
free($3);
if ($$ == NULL)
}
{
NULL)
}
{
NULL)
}
%%