xref: /titanic_50/usr/src/cmd/zonecfg/zonecfg_grammar.y (revision c77a61a72b5ecdc507d6cf104142edd371a16c84)
1 %{
2 /*
3  * CDDL HEADER START
4  *
5  * The contents of this file are subject to the terms of the
6  * Common Development and Distribution License (the "License").
7  * You may not use this file except in compliance with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 
23 /*
24  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
25  * Use is subject to license terms.
26  */
27 
28 #pragma ident	"%Z%%M%	%I%	%E% SMI"
29 
30 #include <stdio.h>
31 
32 #include "zonecfg.h"
33 
34 static cmd_t *cmd = NULL;		/* Command being processed */
35 static complex_property_ptr_t complex = NULL;
36 static list_property_ptr_t new_list = NULL, tmp_list, last,
37     list[MAX_EQ_PROP_PAIRS];
38 static property_value_t property[MAX_EQ_PROP_PAIRS];
39 
40 extern bool newline_terminated;
41 extern int num_prop_vals;		/* # of property values */
42 
43 /* yacc externals */
44 extern int yydebug;
45 extern void yyerror(char *s);
46 
47 %}
48 
49 %union {
50 	int ival;
51 	char *strval;
52 	cmd_t *cmd;
53 	complex_property_ptr_t complex;
54 	list_property_ptr_t list;
55 }
56 
57 %start commands
58 
59 %token HELP CREATE EXPORT ADD DELETE REMOVE SELECT SET INFO CANCEL END VERIFY
60 %token COMMIT REVERT EXIT SEMICOLON TOKEN ZONENAME ZONEPATH AUTOBOOT POOL NET
61 %token FS IPD ATTR DEVICE RCTL SPECIAL RAW DIR OPTIONS TYPE ADDRESS PHYSICAL
62 %token NAME MATCH PRIV LIMIT ACTION VALUE EQUAL OPEN_SQ_BRACKET CLOSE_SQ_BRACKET
63 %token OPEN_PAREN CLOSE_PAREN COMMA DATASET LIMITPRIV BOOTARGS BRAND PSET
64 %token MCAP NCPUS IMPORTANCE SHARES MAXLWPS MAXSHMMEM MAXSHMIDS MAXMSGIDS
65 %token MAXSEMIDS LOCKED SWAP SCHED CLEAR
66 
67 %type <strval> TOKEN EQUAL OPEN_SQ_BRACKET CLOSE_SQ_BRACKET
68     property_value OPEN_PAREN CLOSE_PAREN COMMA simple_prop_val
69 %type <complex> complex_piece complex_prop_val
70 %type <ival> resource_type NET FS IPD DEVICE RCTL ATTR DATASET PSET MCAP
71 %type <ival> property_name SPECIAL RAW DIR OPTIONS TYPE ADDRESS PHYSICAL NAME
72     MATCH ZONENAME ZONEPATH AUTOBOOT POOL LIMITPRIV BOOTARGS VALUE PRIV LIMIT
73     ACTION BRAND SCHED
74 %type <cmd> command
75 %type <cmd> add_command ADD
76 %type <cmd> cancel_command CANCEL
77 %type <cmd> commit_command COMMIT
78 %type <cmd> create_command CREATE
79 %type <cmd> delete_command DELETE
80 %type <cmd> end_command END
81 %type <cmd> exit_command EXIT
82 %type <cmd> export_command EXPORT
83 %type <cmd> help_command HELP
84 %type <cmd> info_command INFO
85 %type <cmd> remove_command REMOVE
86 %type <cmd> revert_command REVERT
87 %type <cmd> select_command SELECT
88 %type <cmd> set_command SET
89 %type <cmd> clear_command CLEAR
90 %type <cmd> verify_command VERIFY
91 %type <cmd> terminator
92 
93 %%
94 
95 commands: command terminator
96 	{
97 		if ($1 != NULL) {
98 			if ($1->cmd_handler != NULL)
99 				$1->cmd_handler($1);
100 			free_cmd($1);
101 			bzero(list, sizeof (list_property_t));
102 			num_prop_vals = 0;
103 		}
104 		return (0);
105 	}
106 	| command error terminator
107 	{
108 		if ($1 != NULL) {
109 			free_cmd($1);
110 			bzero(list, sizeof (list_property_t));
111 			num_prop_vals = 0;
112 		}
113 		if (YYRECOVERING())
114 			YYABORT;
115 		yyclearin;
116 		yyerrok;
117 	}
118 	| error terminator
119 	{
120 		if (YYRECOVERING())
121 			YYABORT;
122 		yyclearin;
123 		yyerrok;
124 	}
125 	| terminator
126 	{
127 		return (0);
128 	}
129 
130 command: add_command
131 	| cancel_command
132 	| clear_command
133 	| create_command
134 	| commit_command
135 	| delete_command
136 	| end_command
137 	| exit_command
138 	| export_command
139 	| help_command
140 	| info_command
141 	| remove_command
142 	| revert_command
143 	| select_command
144 	| set_command
145 	| verify_command
146 
147 terminator:	'\n'	{ newline_terminated = TRUE; }
148 	|	';'	{ newline_terminated = FALSE; }
149 
150 add_command: ADD
151 	{
152 		short_usage(CMD_ADD);
153 		(void) fputs("\n", stderr);
154 		usage(FALSE, HELP_RES_PROPS);
155 		YYERROR;
156 	}
157 	| ADD TOKEN
158 	{
159 		if (($$ = alloc_cmd()) == NULL)
160 			YYERROR;
161 		cmd = $$;
162 		$$->cmd_handler = &add_func;
163 		$$->cmd_argc = 1;
164 		$$->cmd_argv[0] = $2;
165 		$$->cmd_argv[1] = NULL;
166 	}
167 	| ADD resource_type
168 	{
169 		if (($$ = alloc_cmd()) == NULL)
170 			YYERROR;
171 		cmd = $$;
172 		$$->cmd_handler = &add_func;
173 		$$->cmd_argc = 0;
174 		$$->cmd_res_type = $2;
175 		$$->cmd_prop_nv_pairs = 0;
176 	}
177 	| ADD property_name property_value
178 	{
179 		if (($$ = alloc_cmd()) == NULL)
180 			YYERROR;
181 		cmd = $$;
182 		$$->cmd_handler = &add_func;
183 		$$->cmd_argc = 0;
184 		$$->cmd_prop_nv_pairs = 1;
185 		$$->cmd_prop_name[0] = $2;
186 		$$->cmd_property_ptr[0] = &property[0];
187 	}
188 
189 cancel_command: CANCEL
190 	{
191 		if (($$ = alloc_cmd()) == NULL)
192 			YYERROR;
193 		cmd = $$;
194 		$$->cmd_handler = &cancel_func;
195 		$$->cmd_argc = 0;
196 		$$->cmd_argv[0] = NULL;
197 	}
198 	| CANCEL TOKEN
199 	{
200 		if (($$ = alloc_cmd()) == NULL)
201 			YYERROR;
202 		cmd = $$;
203 		$$->cmd_handler = &cancel_func;
204 		$$->cmd_argc = 1;
205 		$$->cmd_argv[0] = $2;
206 		$$->cmd_argv[1] = NULL;
207 	}
208 
209 create_command: CREATE
210 	{
211 		if (($$ = alloc_cmd()) == NULL)
212 			YYERROR;
213 		cmd = $$;
214 		$$->cmd_handler = &create_func;
215 		$$->cmd_argc = 0;
216 		$$->cmd_argv[0] = NULL;
217 	}
218 	| CREATE TOKEN
219 	{
220 		if (($$ = alloc_cmd()) == NULL)
221 			YYERROR;
222 		cmd = $$;
223 		$$->cmd_handler = &create_func;
224 		$$->cmd_argc = 1;
225 		$$->cmd_argv[0] = $2;
226 		$$->cmd_argv[1] = NULL;
227 	}
228 	| CREATE TOKEN TOKEN
229 	{
230 		if (($$ = alloc_cmd()) == NULL)
231 			YYERROR;
232 		cmd = $$;
233 		$$->cmd_handler = &create_func;
234 		$$->cmd_argc = 2;
235 		$$->cmd_argv[0] = $2;
236 		$$->cmd_argv[1] = $3;
237 		$$->cmd_argv[2] = NULL;
238 	}
239 	| CREATE TOKEN TOKEN TOKEN
240 	{
241 		if (($$ = alloc_cmd()) == NULL)
242 			YYERROR;
243 		cmd = $$;
244 		$$->cmd_handler = &create_func;
245 		$$->cmd_argc = 3;
246 		$$->cmd_argv[0] = $2;
247 		$$->cmd_argv[1] = $3;
248 		$$->cmd_argv[2] = $4;
249 		$$->cmd_argv[3] = NULL;
250 	}
251 
252 commit_command: COMMIT
253 	{
254 		if (($$ = alloc_cmd()) == NULL)
255 			YYERROR;
256 		cmd = $$;
257 		$$->cmd_handler = &commit_func;
258 		$$->cmd_argc = 0;
259 		$$->cmd_argv[0] = NULL;
260 	}
261 	| COMMIT TOKEN
262 	{
263 		if (($$ = alloc_cmd()) == NULL)
264 			YYERROR;
265 		cmd = $$;
266 		$$->cmd_handler = &commit_func;
267 		$$->cmd_argc = 1;
268 		$$->cmd_argv[0] = $2;
269 		$$->cmd_argv[1] = NULL;
270 	}
271 
272 delete_command: DELETE
273 	{
274 		if (($$ = alloc_cmd()) == NULL)
275 			YYERROR;
276 		cmd = $$;
277 		$$->cmd_handler = &delete_func;
278 		$$->cmd_argc = 0;
279 		$$->cmd_argv[0] = NULL;
280 	}
281 	|	DELETE TOKEN
282 	{
283 		if (($$ = alloc_cmd()) == NULL)
284 			YYERROR;
285 		cmd = $$;
286 		$$->cmd_handler = &delete_func;
287 		$$->cmd_argc = 1;
288 		$$->cmd_argv[0] = $2;
289 		$$->cmd_argv[1] = NULL;
290 	}
291 
292 end_command: END
293 	{
294 		if (($$ = alloc_cmd()) == NULL)
295 			YYERROR;
296 		cmd = $$;
297 		$$->cmd_handler = &end_func;
298 		$$->cmd_argc = 0;
299 		$$->cmd_argv[0] = NULL;
300 	}
301 	| END TOKEN
302 	{
303 		if (($$ = alloc_cmd()) == NULL)
304 			YYERROR;
305 		cmd = $$;
306 		$$->cmd_handler = &end_func;
307 		$$->cmd_argc = 1;
308 		$$->cmd_argv[0] = $2;
309 		$$->cmd_argv[1] = NULL;
310 	}
311 
312 exit_command: EXIT
313 	{
314 		if (($$ = alloc_cmd()) == NULL)
315 			YYERROR;
316 		cmd = $$;
317 		$$->cmd_handler = &exit_func;
318 		$$->cmd_argc = 0;
319 		$$->cmd_argv[0] = NULL;
320 	}
321 	| EXIT TOKEN
322 	{
323 		if (($$ = alloc_cmd()) == NULL)
324 			YYERROR;
325 		cmd = $$;
326 		$$->cmd_handler = &exit_func;
327 		$$->cmd_argc = 1;
328 		$$->cmd_argv[0] = $2;
329 		$$->cmd_argv[1] = NULL;
330 	}
331 
332 export_command: EXPORT
333 	{
334 		if (($$ = alloc_cmd()) == NULL)
335 			YYERROR;
336 		cmd = $$;
337 		$$->cmd_handler = &export_func;
338 		$$->cmd_argc = 0;
339 		$$->cmd_argv[0] = NULL;
340 	}
341 	| EXPORT TOKEN
342 	{
343 		if (($$ = alloc_cmd()) == NULL)
344 			YYERROR;
345 		cmd = $$;
346 		$$->cmd_handler = &export_func;
347 		$$->cmd_argc = 1;
348 		$$->cmd_argv[0] = $2;
349 		$$->cmd_argv[1] = NULL;
350 	}
351 	| EXPORT TOKEN TOKEN
352 	{
353 		if (($$ = alloc_cmd()) == NULL)
354 			YYERROR;
355 		cmd = $$;
356 		$$->cmd_handler = &export_func;
357 		$$->cmd_argc = 2;
358 		$$->cmd_argv[0] = $2;
359 		$$->cmd_argv[1] = $3;
360 		$$->cmd_argv[2] = NULL;
361 	}
362 
363 help_command:	HELP
364 	{
365 		if (($$ = alloc_cmd()) == NULL)
366 			YYERROR;
367 		cmd = $$;
368 		$$->cmd_handler = &help_func;
369 		$$->cmd_argc = 0;
370 		$$->cmd_argv[0] = NULL;
371 	}
372 	|	HELP TOKEN
373 	{
374 		if (($$ = alloc_cmd()) == NULL)
375 			YYERROR;
376 		cmd = $$;
377 		$$->cmd_handler = &help_func;
378 		$$->cmd_argc = 1;
379 		$$->cmd_argv[0] = $2;
380 		$$->cmd_argv[1] = NULL;
381 	}
382 
383 info_command:	INFO
384 	{
385 		if (($$ = alloc_cmd()) == NULL)
386 			YYERROR;
387 		cmd = $$;
388 		$$->cmd_handler = &info_func;
389 		$$->cmd_res_type = RT_UNKNOWN;
390 		$$->cmd_prop_nv_pairs = 0;
391 	}
392 	|	INFO TOKEN
393 	{
394 		short_usage(CMD_INFO);
395 		(void) fputs("\n", stderr);
396 		usage(FALSE, HELP_RES_PROPS);
397 		free($2);
398 		YYERROR;
399 	}
400 	|	INFO resource_type
401 	{
402 		if (($$ = alloc_cmd()) == NULL)
403 			YYERROR;
404 		cmd = $$;
405 		$$->cmd_handler = &info_func;
406 		$$->cmd_res_type = $2;
407 		$$->cmd_prop_nv_pairs = 0;
408 	}
409 	|	INFO ZONENAME
410 	{
411 		if (($$ = alloc_cmd()) == NULL)
412 			YYERROR;
413 		cmd = $$;
414 		$$->cmd_handler = &info_func;
415 		$$->cmd_res_type = RT_ZONENAME;
416 		$$->cmd_prop_nv_pairs = 0;
417 	}
418 	|	INFO ZONEPATH
419 	{
420 		if (($$ = alloc_cmd()) == NULL)
421 			YYERROR;
422 		cmd = $$;
423 		$$->cmd_handler = &info_func;
424 		$$->cmd_res_type = RT_ZONEPATH;
425 		$$->cmd_prop_nv_pairs = 0;
426 	}
427 	|	INFO BRAND
428 	{
429 		if (($$ = alloc_cmd()) == NULL)
430 			YYERROR;
431 		cmd = $$;
432 		$$->cmd_handler = &info_func;
433 		$$->cmd_res_type = RT_BRAND;
434 		$$->cmd_prop_nv_pairs = 0;
435 	}
436 	|	INFO AUTOBOOT
437 	{
438 		if (($$ = alloc_cmd()) == NULL)
439 			YYERROR;
440 		cmd = $$;
441 		$$->cmd_handler = &info_func;
442 		$$->cmd_res_type = RT_AUTOBOOT;
443 		$$->cmd_prop_nv_pairs = 0;
444 	}
445 	|	INFO POOL
446 	{
447 		if (($$ = alloc_cmd()) == NULL)
448 			YYERROR;
449 		cmd = $$;
450 		$$->cmd_handler = &info_func;
451 		$$->cmd_res_type = RT_POOL;
452 		$$->cmd_prop_nv_pairs = 0;
453 	}
454 	|	INFO LIMITPRIV
455 	{
456 		if (($$ = alloc_cmd()) == NULL)
457 			YYERROR;
458 		cmd = $$;
459 		$$->cmd_handler = &info_func;
460 		$$->cmd_res_type = RT_LIMITPRIV;
461 		$$->cmd_prop_nv_pairs = 0;
462 	}
463 	|	INFO BOOTARGS
464 	{
465 		if (($$ = alloc_cmd()) == NULL)
466 			YYERROR;
467 		cmd = $$;
468 		$$->cmd_handler = &info_func;
469 		$$->cmd_res_type = RT_BOOTARGS;
470 		$$->cmd_prop_nv_pairs = 0;
471 	}
472 	|	INFO SCHED
473 	{
474 		if (($$ = alloc_cmd()) == NULL)
475 			YYERROR;
476 		cmd = $$;
477 		$$->cmd_handler = &info_func;
478 		$$->cmd_res_type = RT_SCHED;
479 		$$->cmd_prop_nv_pairs = 0;
480 	}
481 	|	INFO SHARES
482 	{
483 		if (($$ = alloc_cmd()) == NULL)
484 			YYERROR;
485 		cmd = $$;
486 		$$->cmd_handler = &info_func;
487 		$$->cmd_res_type = RT_SHARES;
488 		$$->cmd_prop_nv_pairs = 0;
489 	}
490 	|	INFO MAXLWPS
491 	{
492 		if (($$ = alloc_cmd()) == NULL)
493 			YYERROR;
494 		cmd = $$;
495 		$$->cmd_handler = &info_func;
496 		$$->cmd_res_type = RT_MAXLWPS;
497 		$$->cmd_prop_nv_pairs = 0;
498 	}
499 	|	INFO MAXSHMMEM
500 	{
501 		if (($$ = alloc_cmd()) == NULL)
502 			YYERROR;
503 		cmd = $$;
504 		$$->cmd_handler = &info_func;
505 		$$->cmd_res_type = RT_MAXSHMMEM;
506 		$$->cmd_prop_nv_pairs = 0;
507 	}
508 	|	INFO MAXSHMIDS
509 	{
510 		if (($$ = alloc_cmd()) == NULL)
511 			YYERROR;
512 		cmd = $$;
513 		$$->cmd_handler = &info_func;
514 		$$->cmd_res_type = RT_MAXSHMIDS;
515 		$$->cmd_prop_nv_pairs = 0;
516 	}
517 	|	INFO MAXMSGIDS
518 	{
519 		if (($$ = alloc_cmd()) == NULL)
520 			YYERROR;
521 		cmd = $$;
522 		$$->cmd_handler = &info_func;
523 		$$->cmd_res_type = RT_MAXMSGIDS;
524 		$$->cmd_prop_nv_pairs = 0;
525 	}
526 	|	INFO MAXSEMIDS
527 	{
528 		if (($$ = alloc_cmd()) == NULL)
529 			YYERROR;
530 		cmd = $$;
531 		$$->cmd_handler = &info_func;
532 		$$->cmd_res_type = RT_MAXSEMIDS;
533 		$$->cmd_prop_nv_pairs = 0;
534 	}
535 	|	INFO resource_type property_name EQUAL property_value
536 	{
537 		if (($$ = alloc_cmd()) == NULL)
538 			YYERROR;
539 		cmd = $$;
540 		$$->cmd_handler = &info_func;
541 		$$->cmd_res_type = $2;
542 		$$->cmd_prop_nv_pairs = 1;
543 		$$->cmd_prop_name[0] = $3;
544 		$$->cmd_property_ptr[0] = &property[0];
545 	}
546 	|	INFO resource_type property_name EQUAL property_value property_name EQUAL property_value
547 	{
548 		if (($$ = alloc_cmd()) == NULL)
549 			YYERROR;
550 		cmd = $$;
551 		$$->cmd_handler = &info_func;
552 		$$->cmd_res_type = $2;
553 		$$->cmd_prop_nv_pairs = 2;
554 		$$->cmd_prop_name[0] = $3;
555 		$$->cmd_property_ptr[0] = &property[0];
556 		$$->cmd_prop_name[1] = $6;
557 		$$->cmd_property_ptr[1] = &property[1];
558 	}
559 	|	INFO resource_type property_name EQUAL property_value property_name EQUAL property_value property_name EQUAL property_value
560 	{
561 		if (($$ = alloc_cmd()) == NULL)
562 			YYERROR;
563 		cmd = $$;
564 		$$->cmd_handler = &info_func;
565 		$$->cmd_res_type = $2;
566 		$$->cmd_prop_nv_pairs = 3;
567 		$$->cmd_prop_name[0] = $3;
568 		$$->cmd_property_ptr[0] = &property[0];
569 		$$->cmd_prop_name[1] = $6;
570 		$$->cmd_property_ptr[1] = &property[1];
571 		$$->cmd_prop_name[2] = $9;
572 		$$->cmd_property_ptr[2] = &property[2];
573 	}
574 
575 remove_command: REMOVE
576 	{
577 		short_usage(CMD_REMOVE);
578 		(void) fputs("\n", stderr);
579 		usage(FALSE, HELP_RES_PROPS);
580 		YYERROR;
581 	}
582 	| REMOVE TOKEN
583 	{
584 		short_usage(CMD_REMOVE);
585 		(void) fputs("\n", stderr);
586 		usage(FALSE, HELP_RES_PROPS);
587 		YYERROR;
588 	}
589 	| REMOVE resource_type
590 	{
591 		if (($$ = alloc_cmd()) == NULL)
592 			YYERROR;
593 		cmd = $$;
594 		$$->cmd_handler = &remove_func;
595 		$$->cmd_res_type = $2;
596 	}
597 	| REMOVE TOKEN resource_type
598 	{
599 		if (($$ = alloc_cmd()) == NULL)
600 			YYERROR;
601 		cmd = $$;
602 		$$->cmd_handler = &remove_func;
603 		$$->cmd_res_type = $3;
604 		$$->cmd_argc = 1;
605 		$$->cmd_argv[0] = $2;
606 		$$->cmd_argv[1] = NULL;
607 	}
608 	| REMOVE property_name property_value
609 	{
610 		if (($$ = alloc_cmd()) == NULL)
611 			YYERROR;
612 		cmd = $$;
613 		$$->cmd_handler = &remove_func;
614 		$$->cmd_prop_nv_pairs = 1;
615 		$$->cmd_prop_name[0] = $2;
616 		$$->cmd_property_ptr[0] = &property[0];
617 	}
618 	| REMOVE resource_type property_name EQUAL property_value
619 	{
620 		if (($$ = alloc_cmd()) == NULL)
621 			YYERROR;
622 		cmd = $$;
623 		$$->cmd_handler = &remove_func;
624 		$$->cmd_res_type = $2;
625 		$$->cmd_prop_nv_pairs = 1;
626 		$$->cmd_prop_name[0] = $3;
627 		$$->cmd_property_ptr[0] = &property[0];
628 	}
629 	| REMOVE resource_type property_name EQUAL property_value property_name EQUAL property_value
630 	{
631 		if (($$ = alloc_cmd()) == NULL)
632 			YYERROR;
633 		cmd = $$;
634 		$$->cmd_handler = &remove_func;
635 		$$->cmd_res_type = $2;
636 		$$->cmd_prop_nv_pairs = 2;
637 		$$->cmd_prop_name[0] = $3;
638 		$$->cmd_property_ptr[0] = &property[0];
639 		$$->cmd_prop_name[1] = $6;
640 		$$->cmd_property_ptr[1] = &property[1];
641 	}
642 	| REMOVE resource_type property_name EQUAL property_value property_name EQUAL property_value property_name EQUAL property_value
643 	{
644 		if (($$ = alloc_cmd()) == NULL)
645 			YYERROR;
646 		cmd = $$;
647 		$$->cmd_handler = &remove_func;
648 		$$->cmd_res_type = $2;
649 		$$->cmd_prop_nv_pairs = 3;
650 		$$->cmd_prop_name[0] = $3;
651 		$$->cmd_property_ptr[0] = &property[0];
652 		$$->cmd_prop_name[1] = $6;
653 		$$->cmd_property_ptr[1] = &property[1];
654 		$$->cmd_prop_name[2] = $9;
655 		$$->cmd_property_ptr[2] = &property[2];
656 	}
657 
658 revert_command: REVERT
659 	{
660 		if (($$ = alloc_cmd()) == NULL)
661 			YYERROR;
662 		cmd = $$;
663 		$$->cmd_handler = &revert_func;
664 		$$->cmd_argc = 0;
665 		$$->cmd_argv[0] = NULL;
666 	}
667 	| REVERT TOKEN
668 	{
669 		if (($$ = alloc_cmd()) == NULL)
670 			YYERROR;
671 		cmd = $$;
672 		$$->cmd_handler = &revert_func;
673 		$$->cmd_argc = 1;
674 		$$->cmd_argv[0] = $2;
675 		$$->cmd_argv[1] = NULL;
676 	}
677 
678 select_command: SELECT
679 	{
680 		short_usage(CMD_SELECT);
681 		(void) fputs("\n", stderr);
682 		usage(FALSE, HELP_RES_PROPS);
683 		YYERROR;
684 	}
685 	| SELECT PSET
686 	{
687 		if (($$ = alloc_cmd()) == NULL)
688 			YYERROR;
689 		cmd = $$;
690 		$$->cmd_handler = &select_func;
691 		$$->cmd_res_type = RT_DCPU;
692 	}
693 	| SELECT MCAP
694 	{
695 		if (($$ = alloc_cmd()) == NULL)
696 			YYERROR;
697 		cmd = $$;
698 		$$->cmd_handler = &select_func;
699 		$$->cmd_res_type = RT_MCAP;
700 	}
701 	| SELECT resource_type
702 	{
703 		short_usage(CMD_SELECT);
704 		YYERROR;
705 	}
706 	| SELECT resource_type property_name EQUAL property_value
707 	{
708 		if (($$ = alloc_cmd()) == NULL)
709 			YYERROR;
710 		cmd = $$;
711 		$$->cmd_handler = &select_func;
712 		$$->cmd_res_type = $2;
713 		$$->cmd_prop_nv_pairs = 1;
714 		$$->cmd_prop_name[0] = $3;
715 		$$->cmd_property_ptr[0] = &property[0];
716 	}
717 	| SELECT resource_type property_name EQUAL property_value property_name EQUAL property_value
718 	{
719 		if (($$ = alloc_cmd()) == NULL)
720 			YYERROR;
721 		cmd = $$;
722 		$$->cmd_handler = &select_func;
723 		$$->cmd_res_type = $2;
724 		$$->cmd_prop_nv_pairs = 2;
725 		$$->cmd_prop_name[0] = $3;
726 		$$->cmd_property_ptr[0] = &property[0];
727 		$$->cmd_prop_name[1] = $6;
728 		$$->cmd_property_ptr[1] = &property[1];
729 	}
730 	| SELECT resource_type property_name EQUAL property_value property_name EQUAL property_value property_name EQUAL property_value
731 	{
732 		if (($$ = alloc_cmd()) == NULL)
733 			YYERROR;
734 		cmd = $$;
735 		$$->cmd_handler = &select_func;
736 		$$->cmd_res_type = $2;
737 		$$->cmd_prop_nv_pairs = 3;
738 		$$->cmd_prop_name[0] = $3;
739 		$$->cmd_property_ptr[0] = &property[0];
740 		$$->cmd_prop_name[1] = $6;
741 		$$->cmd_property_ptr[1] = &property[1];
742 		$$->cmd_prop_name[2] = $9;
743 		$$->cmd_property_ptr[2] = &property[2];
744 	}
745 
746 set_command: SET
747 	{
748 		short_usage(CMD_SET);
749 		(void) fputs("\n", stderr);
750 		usage(FALSE, HELP_PROPS);
751 		YYERROR;
752 	}
753 	| SET property_name EQUAL OPEN_SQ_BRACKET CLOSE_SQ_BRACKET
754 	{
755 		if (($$ = alloc_cmd()) == NULL)
756 			YYERROR;
757 		cmd = $$;
758 		$$->cmd_handler = &set_func;
759 		$$->cmd_prop_nv_pairs = 0;
760 		$$->cmd_prop_name[0] = $2;
761 		property[0].pv_type = PROP_VAL_LIST;
762 		property[0].pv_list = NULL;
763 		$$->cmd_property_ptr[0] = &property[0];
764 	}
765 	| SET property_name EQUAL property_value
766 	{
767 		if (($$ = alloc_cmd()) == NULL)
768 			YYERROR;
769 		cmd = $$;
770 		$$->cmd_handler = &set_func;
771 		$$->cmd_prop_nv_pairs = 1;
772 		$$->cmd_prop_name[0] = $2;
773 		$$->cmd_property_ptr[0] = &property[0];
774 	}
775 	| SET TOKEN ZONEPATH EQUAL property_value
776 	{
777 		if (($$ = alloc_cmd()) == NULL)
778 			YYERROR;
779 		cmd = $$;
780 		$$->cmd_argc = 1;
781 		$$->cmd_argv[0] = $2;
782 		$$->cmd_argv[1] = NULL;
783 		$$->cmd_handler = &set_func;
784 		$$->cmd_prop_nv_pairs = 1;
785 		$$->cmd_prop_name[0] = PT_ZONEPATH;
786 		$$->cmd_property_ptr[0] = &property[0];
787 	}
788 
789 clear_command: CLEAR
790 	{
791 		short_usage(CMD_CLEAR);
792 		(void) fputs("\n", stderr);
793 		usage(FALSE, HELP_PROPS);
794 		YYERROR;
795 	}
796 	| CLEAR property_name
797 	{
798 		if (($$ = alloc_cmd()) == NULL)
799 			YYERROR;
800 		cmd = $$;
801 		$$->cmd_handler = &clear_func;
802 		$$->cmd_res_type = $2;
803 	}
804 
805 verify_command: VERIFY
806 	{
807 		if (($$ = alloc_cmd()) == NULL)
808 			YYERROR;
809 		cmd = $$;
810 		$$->cmd_handler = &verify_func;
811 		$$->cmd_argc = 0;
812 		$$->cmd_argv[0] = NULL;
813 	}
814 	| VERIFY TOKEN
815 	{
816 		if (($$ = alloc_cmd()) == NULL)
817 			YYERROR;
818 		cmd = $$;
819 		$$->cmd_handler = &verify_func;
820 		$$->cmd_argc = 1;
821 		$$->cmd_argv[0] = $2;
822 		$$->cmd_argv[1] = NULL;
823 	}
824 
825 resource_type: NET	{ $$ = RT_NET; }
826 	| FS		{ $$ = RT_FS; }
827 	| IPD		{ $$ = RT_IPD; }
828 	| DEVICE	{ $$ = RT_DEVICE; }
829 	| RCTL		{ $$ = RT_RCTL; }
830 	| ATTR		{ $$ = RT_ATTR; }
831 	| DATASET	{ $$ = RT_DATASET; }
832 	| PSET		{ $$ = RT_DCPU; }
833 	| MCAP		{ $$ = RT_MCAP; }
834 
835 property_name: SPECIAL	{ $$ = PT_SPECIAL; }
836 	| RAW		{ $$ = PT_RAW; }
837 	| DIR		{ $$ = PT_DIR; }
838 	| TYPE		{ $$ = PT_TYPE; }
839 	| OPTIONS	{ $$ = PT_OPTIONS; }
840 	| ZONENAME	{ $$ = PT_ZONENAME; }
841 	| ZONEPATH	{ $$ = PT_ZONEPATH; }
842 	| AUTOBOOT	{ $$ = PT_AUTOBOOT; }
843 	| POOL		{ $$ = PT_POOL; }
844 	| LIMITPRIV	{ $$ = PT_LIMITPRIV; }
845 	| BOOTARGS	{ $$ = PT_BOOTARGS; }
846 	| ADDRESS	{ $$ = PT_ADDRESS; }
847 	| PHYSICAL	{ $$ = PT_PHYSICAL; }
848 	| NAME		{ $$ = PT_NAME; }
849 	| VALUE		{ $$ = PT_VALUE; }
850 	| MATCH		{ $$ = PT_MATCH; }
851 	| PRIV		{ $$ = PT_PRIV; }
852 	| LIMIT		{ $$ = PT_LIMIT; }
853 	| ACTION	{ $$ = PT_ACTION; }
854 	| BRAND		{ $$ = PT_BRAND; }
855 	| NCPUS		{ $$ = PT_NCPUS; }
856 	| LOCKED	{ $$ = PT_LOCKED; }
857 	| SWAP		{ $$ = PT_SWAP; }
858 	| IMPORTANCE	{ $$ = PT_IMPORTANCE; }
859 	| SHARES	{ $$ = PT_SHARES; }
860 	| MAXLWPS	{ $$ = PT_MAXLWPS; }
861 	| MAXSHMMEM	{ $$ = PT_MAXSHMMEM; }
862 	| MAXSHMIDS	{ $$ = PT_MAXSHMIDS; }
863 	| MAXMSGIDS	{ $$ = PT_MAXMSGIDS; }
864 	| MAXSEMIDS	{ $$ = PT_MAXSEMIDS; }
865 	| SCHED		{ $$ = PT_SCHED; }
866 
867 /*
868  * The grammar builds data structures from the bottom up.  Thus various
869  * strings are lexed into TOKENs or commands or resource or property values.
870  * Below is where the resource and property values are built up into more
871  * complex data structures.
872  *
873  * There are three kinds of properties: simple (single valued), complex
874  * (one or more name=value pairs) and list (concatenation of one or more
875  * simple or complex properties).
876  *
877  * So the property structure has a type which is one of these, and the
878  * corresponding _simple, _complex or _list is set to the corresponding
879  * lower-level data structure.
880  */
881 
882 property_value: simple_prop_val
883 	{
884 		property[num_prop_vals].pv_type = PROP_VAL_SIMPLE;
885 		property[num_prop_vals].pv_simple = $1;
886 		if (list[num_prop_vals] != NULL) {
887 			free_outer_list(list[num_prop_vals]);
888 			list[num_prop_vals] = NULL;
889 		}
890 		num_prop_vals++;
891 	}
892 	| complex_prop_val
893 	{
894 		property[num_prop_vals].pv_type = PROP_VAL_COMPLEX;
895 		property[num_prop_vals].pv_complex = complex;
896 		if (list[num_prop_vals] != NULL) {
897 			free_outer_list(list[num_prop_vals]);
898 			list[num_prop_vals] = NULL;
899 		}
900 		num_prop_vals++;
901 	}
902 	| list_prop_val
903 	{
904 		property[num_prop_vals].pv_type = PROP_VAL_LIST;
905 		property[num_prop_vals].pv_list = list[num_prop_vals];
906 		num_prop_vals++;
907 	}
908 
909 /*
910  * One level lower, lists are made up of simple or complex values, so
911  * simple_prop_val and complex_prop_val fill in a list structure and
912  * insert it into the linked list which is built up.  And because
913  * complex properties can have multiple name=value pairs, we keep
914  * track of them in another linked list.
915  *
916  * The complex and list structures for the linked lists are allocated
917  * below, and freed by recursive functions which are ultimately called
918  * by free_cmd(), which is called from the top-most "commands" part of
919  * the grammar.
920  */
921 
922 simple_prop_val: TOKEN
923 	{
924 		if ((new_list = alloc_list()) == NULL)
925 			YYERROR;
926 		new_list->lp_simple = $1;
927 		new_list->lp_complex = NULL;
928 		new_list->lp_next = NULL;
929 		if (list[num_prop_vals] == NULL) {
930 			list[num_prop_vals] = new_list;
931 		} else {
932 			for (tmp_list = list[num_prop_vals]; tmp_list != NULL;
933 			    tmp_list = tmp_list->lp_next)
934 				last = tmp_list;
935 			last->lp_next = new_list;
936 		}
937 	}
938 
939 complex_prop_val: OPEN_PAREN complex_piece CLOSE_PAREN
940 	{
941 		if ((new_list = alloc_list()) == NULL)
942 			YYERROR;
943 		new_list->lp_simple = NULL;
944 		new_list->lp_complex = complex;
945 		new_list->lp_next = NULL;
946 		if (list[num_prop_vals] == NULL) {
947 			list[num_prop_vals] = new_list;
948 		} else {
949 			for (tmp_list = list[num_prop_vals]; tmp_list != NULL;
950 			    tmp_list = tmp_list->lp_next)
951 				last = tmp_list;
952 			last->lp_next = new_list;
953 		}
954 	}
955 
956 complex_piece: property_name EQUAL TOKEN
957 	{
958 		if (($$ = alloc_complex()) == NULL)
959 			YYERROR;
960 		$$->cp_type = $1;
961 		$$->cp_value = $3;
962 		$$->cp_next = NULL;
963 		complex = $$;
964 	}
965 	| property_name EQUAL TOKEN COMMA complex_piece
966 	{
967 		if (($$ = alloc_complex()) == NULL)
968 			YYERROR;
969 		$$->cp_type = $1;
970 		$$->cp_value = $3;
971 		$$->cp_next = complex;
972 		complex = $$;
973 	}
974 
975 list_piece: simple_prop_val
976 	| complex_prop_val
977 	| simple_prop_val COMMA list_piece
978 	| complex_prop_val COMMA list_piece
979 
980 list_prop_val: OPEN_SQ_BRACKET list_piece CLOSE_SQ_BRACKET
981 %%
982