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.
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.
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]
24 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
28 * This file defines zonecfg(1M)'s grammar.
30 * Reduction rules that consume TOKENs must invoke claim_token() immediately
31 * before freeing the TOKENs or adding them to data structures (e.g., cmd) that
32 * will be cleaned up when the parser finishes or encounters errors.
40 static cmd_t
*cmd
= NULL
; /* Command being processed */
41 static complex_property_ptr_t
complex = NULL
;
42 static list_property_ptr_t new_list
= NULL
, tmp_list
, last
,
43 list
[MAX_EQ_PROP_PAIRS
];
44 static property_value_t property
[MAX_EQ_PROP_PAIRS
];
46 extern boolean_t newline_terminated
;
47 extern
int num_prop_vals
; /* # of property values */
51 extern
void yyerror(char *s
);
54 * This function is used by the simple_prop_val reduction rules to set up
55 * a list_property_ptr_t and adjust the above global variables appropriately.
56 * Note that this function duplicates the specified string and makes
57 * the new list's lp_simple field point to the duplicate. This function does
58 * not free the original string.
60 * This function returns a pointer to the duplicated string or NULL if an error
61 * occurred. The simple_prop_val reduction rules that invoke this function
62 * should set $$ to the returned pointer.
65 simple_prop_val_func
(const char *str
)
69 if
((new_list
= alloc_list
()) == NULL
)
71 if
((retstr
= strdup
(str
)) == NULL
) {
75 new_list
->lp_simple
= retstr
;
76 new_list
->lp_complex
= NULL
;
77 new_list
->lp_next
= NULL
;
78 if
(list
[num_prop_vals
] == NULL
) {
79 list
[num_prop_vals
] = new_list
;
81 for
(tmp_list
= list
[num_prop_vals
]; tmp_list
!= NULL
;
82 tmp_list
= tmp_list
->lp_next
)
84 last
->lp_next
= new_list
;
90 * This function is used by the complex_piece reduction rules to set up a
91 * complex_property_prt_t and adjust the above global variables appropriately.
92 * Note that this function duplicates the specified string and makes the new
93 * complex_property_ptr_t's cp_value field point to the duplicate. It also sets
94 * the complex_property_ptr_t's cp_type field to cp_type and its cp_next field
95 * to cp_next. This function does not free the original string.
97 * This function returns a pointer to the complex_property_t created for the
98 * complex_piece or NULL if an error occurred. The complex_piece reduction
99 * rules that invoke this function should set $$ to the returned pointer.
101 static complex_property_ptr_t
102 complex_piece_func
(int cp_type
, const char *str
, complex_property_ptr_t cp_next
)
104 complex_property_ptr_t retval
;
106 if
((retval
= alloc_complex
()) == NULL
)
108 if
((retval
->cp_value
= strdup
(str
)) == NULL
) {
109 free_complex
(retval
);
112 retval
->cp_type
= cp_type
;
113 retval
->cp_next
= cp_next
;
125 complex_property_ptr_t
complex;
126 list_property_ptr_t list
;
131 %token HELP CREATE EXPORT ADD DELETE REMOVE SELECT SET INFO CANCEL END VERIFY
132 %token COMMIT REVERT EXIT SEMICOLON TOKEN ZONENAME ZONEPATH AUTOBOOT POOL NET
133 %token FS ATTR DEVICE RCTL SPECIAL RAW
DIR OPTIONS TYPE ADDRESS PHYSICAL
134 %token IPTYPE HOSTID FS_ALLOWED ALLOWED_ADDRESS
135 %token NAME MATCH PRIV LIMIT ACTION VALUE EQUAL OPEN_SQ_BRACKET CLOSE_SQ_BRACKET
136 %token OPEN_PAREN CLOSE_PAREN COMMA DATASET LIMITPRIV BOOTARGS BRAND PSET PCAP
137 %token MCAP NCPUS IMPORTANCE SHARES MAXLWPS MAXSHMMEM MAXSHMIDS MAXMSGIDS
138 %token MAXSEMIDS LOCKED SWAP SCHED CLEAR DEFROUTER ADMIN SECFLAGS USER AUTHS MAXPROCS
139 %token DEFAULT UPPER LOWER
141 %type
<strval
> TOKEN EQUAL OPEN_SQ_BRACKET CLOSE_SQ_BRACKET
142 property_value OPEN_PAREN CLOSE_PAREN COMMA simple_prop_val
143 %type
<complex> complex_piece complex_prop_val
144 %type
<ival
> resource_type NET FS DEVICE RCTL ATTR DATASET PSET PCAP MCAP
146 %type
<ival
> property_name SPECIAL RAW
DIR OPTIONS TYPE ADDRESS PHYSICAL NAME
147 MATCH ZONENAME ZONEPATH AUTOBOOT POOL LIMITPRIV BOOTARGS VALUE PRIV LIMIT
148 ACTION BRAND SCHED IPTYPE DEFROUTER HOSTID USER AUTHS FS_ALLOWED
149 ALLOWED_ADDRESS DEFAULT UPPER LOWER
151 %type
<cmd
> add_command ADD
152 %type
<cmd
> cancel_command CANCEL
153 %type
<cmd
> commit_command COMMIT
154 %type
<cmd
> create_command CREATE
155 %type
<cmd
> delete_command DELETE
156 %type
<cmd
> end_command END
157 %type
<cmd
> exit_command EXIT
158 %type
<cmd
> export_command EXPORT
159 %type
<cmd
> help_command HELP
160 %type
<cmd
> info_command INFO
161 %type
<cmd
> remove_command REMOVE
162 %type
<cmd
> revert_command REVERT
163 %type
<cmd
> select_command SELECT
164 %type
<cmd
> set_command SET
165 %type
<cmd
> clear_command CLEAR
166 %type
<cmd
> verify_command VERIFY
167 %type
<cmd
> terminator
172 * NOTE: Each commands reduction rule must invoke assert_no_unclaimed_tokens()
173 * before it completes if it isn't processing an error. This ensures that
174 * reduction rules properly consume TOKENs.
176 commands: command terminator
179 if
($1->cmd_handler
!= NULL
)
182 bzero
(list
, sizeof
(list_property_t
));
185 assert_no_unclaimed_tokens
();
188 | command
error terminator
192 bzero
(list
, sizeof
(list_property_t
));
209 assert_no_unclaimed_tokens
();
230 terminator: '\n' { newline_terminated
= B_TRUE
; }
231 |
';' { newline_terminated
= B_FALSE
; }
235 short_usage
(CMD_ADD
);
236 (void) fputs
("\n", stderr
);
237 usage
(B_FALSE
, HELP_RES_PROPS
);
242 if
(($$
= alloc_cmd
()) == NULL
)
245 $$
->cmd_handler
= &add_func
;
247 $$
->cmd_argv
[0] = claim_token
($2);
248 $$
->cmd_argv
[1] = NULL
;
252 if
(($$
= alloc_cmd
()) == NULL
)
255 $$
->cmd_handler
= &add_func
;
257 $$
->cmd_res_type
= $2;
258 $$
->cmd_prop_nv_pairs
= 0;
260 | ADD property_name property_value
262 if
(($$
= alloc_cmd
()) == NULL
)
265 $$
->cmd_handler
= &add_func
;
267 $$
->cmd_prop_nv_pairs
= 1;
268 $$
->cmd_prop_name
[0] = $2;
269 $$
->cmd_property_ptr
[0] = &property
[0];
272 cancel_command: CANCEL
274 if
(($$
= alloc_cmd
()) == NULL
)
277 $$
->cmd_handler
= &cancel_func
;
279 $$
->cmd_argv
[0] = NULL
;
283 if
(($$
= alloc_cmd
()) == NULL
)
286 $$
->cmd_handler
= &cancel_func
;
288 $$
->cmd_argv
[0] = claim_token
($2);
289 $$
->cmd_argv
[1] = NULL
;
292 create_command: CREATE
294 if
(($$
= alloc_cmd
()) == NULL
)
297 $$
->cmd_handler
= &create_func
;
299 $$
->cmd_argv
[0] = NULL
;
303 if
(($$
= alloc_cmd
()) == NULL
)
306 $$
->cmd_handler
= &create_func
;
308 $$
->cmd_argv
[0] = claim_token
($2);
309 $$
->cmd_argv
[1] = NULL
;
313 if
(($$
= alloc_cmd
()) == NULL
)
316 $$
->cmd_handler
= &create_func
;
318 $$
->cmd_argv
[0] = claim_token
($2);
319 $$
->cmd_argv
[1] = claim_token
($3);
320 $$
->cmd_argv
[2] = NULL
;
322 | CREATE TOKEN TOKEN TOKEN
324 if
(($$
= alloc_cmd
()) == NULL
)
327 $$
->cmd_handler
= &create_func
;
329 $$
->cmd_argv
[0] = claim_token
($2);
330 $$
->cmd_argv
[1] = claim_token
($3);
331 $$
->cmd_argv
[2] = claim_token
($4);
332 $$
->cmd_argv
[3] = NULL
;
335 commit_command: COMMIT
337 if
(($$
= alloc_cmd
()) == NULL
)
340 $$
->cmd_handler
= &commit_func
;
342 $$
->cmd_argv
[0] = NULL
;
346 if
(($$
= alloc_cmd
()) == NULL
)
349 $$
->cmd_handler
= &commit_func
;
351 $$
->cmd_argv
[0] = claim_token
($2);
352 $$
->cmd_argv
[1] = NULL
;
355 delete_command: DELETE
357 if
(($$
= alloc_cmd
()) == NULL
)
360 $$
->cmd_handler
= &delete_func
;
362 $$
->cmd_argv
[0] = NULL
;
366 if
(($$
= alloc_cmd
()) == NULL
)
369 $$
->cmd_handler
= &delete_func
;
371 $$
->cmd_argv
[0] = claim_token
($2);
372 $$
->cmd_argv
[1] = NULL
;
377 if
(($$
= alloc_cmd
()) == NULL
)
380 $$
->cmd_handler
= &end_func
;
382 $$
->cmd_argv
[0] = NULL
;
386 if
(($$
= alloc_cmd
()) == NULL
)
389 $$
->cmd_handler
= &end_func
;
391 $$
->cmd_argv
[0] = claim_token
($2);
392 $$
->cmd_argv
[1] = NULL
;
397 if
(($$
= alloc_cmd
()) == NULL
)
400 $$
->cmd_handler
= &exit_func
;
402 $$
->cmd_argv
[0] = NULL
;
406 if
(($$
= alloc_cmd
()) == NULL
)
409 $$
->cmd_handler
= &exit_func
;
411 $$
->cmd_argv
[0] = claim_token
($2);
412 $$
->cmd_argv
[1] = NULL
;
415 export_command: EXPORT
417 if
(($$
= alloc_cmd
()) == NULL
)
420 $$
->cmd_handler
= &export_func
;
422 $$
->cmd_argv
[0] = NULL
;
426 if
(($$
= alloc_cmd
()) == NULL
)
429 $$
->cmd_handler
= &export_func
;
431 $$
->cmd_argv
[0] = claim_token
($2);
432 $$
->cmd_argv
[1] = NULL
;
436 if
(($$
= alloc_cmd
()) == NULL
)
439 $$
->cmd_handler
= &export_func
;
441 $$
->cmd_argv
[0] = claim_token
($2);
442 $$
->cmd_argv
[1] = claim_token
($3);
443 $$
->cmd_argv
[2] = NULL
;
448 if
(($$
= alloc_cmd
()) == NULL
)
451 $$
->cmd_handler
= &help_func
;
453 $$
->cmd_argv
[0] = NULL
;
457 if
(($$
= alloc_cmd
()) == NULL
)
460 $$
->cmd_handler
= &help_func
;
462 $$
->cmd_argv
[0] = claim_token
($2);
463 $$
->cmd_argv
[1] = NULL
;
468 if
(($$
= alloc_cmd
()) == NULL
)
471 $$
->cmd_handler
= &info_func
;
472 $$
->cmd_res_type
= RT_UNKNOWN
;
473 $$
->cmd_prop_nv_pairs
= 0;
477 short_usage
(CMD_INFO
);
478 (void) fputs
("\n", stderr
);
479 usage
(B_FALSE
, HELP_RES_PROPS
);
480 free
(claim_token
($2));
485 if
(($$
= alloc_cmd
()) == NULL
)
488 $$
->cmd_handler
= &info_func
;
489 $$
->cmd_res_type
= $2;
490 $$
->cmd_prop_nv_pairs
= 0;
494 if
(($$
= alloc_cmd
()) == NULL
)
497 $$
->cmd_handler
= &info_func
;
498 $$
->cmd_res_type
= RT_ZONENAME
;
499 $$
->cmd_prop_nv_pairs
= 0;
503 if
(($$
= alloc_cmd
()) == NULL
)
506 $$
->cmd_handler
= &info_func
;
507 $$
->cmd_res_type
= RT_ZONEPATH
;
508 $$
->cmd_prop_nv_pairs
= 0;
512 if
(($$
= alloc_cmd
()) == NULL
)
515 $$
->cmd_handler
= &info_func
;
516 $$
->cmd_res_type
= RT_BRAND
;
517 $$
->cmd_prop_nv_pairs
= 0;
521 if
(($$
= alloc_cmd
()) == NULL
)
524 $$
->cmd_handler
= &info_func
;
525 $$
->cmd_res_type
= RT_AUTOBOOT
;
526 $$
->cmd_prop_nv_pairs
= 0;
530 if
(($$
= alloc_cmd
()) == NULL
)
533 $$
->cmd_handler
= &info_func
;
534 $$
->cmd_res_type
= RT_IPTYPE
;
535 $$
->cmd_prop_nv_pairs
= 0;
539 if
(($$
= alloc_cmd
()) == NULL
)
542 $$
->cmd_handler
= &info_func
;
543 $$
->cmd_res_type
= RT_POOL
;
544 $$
->cmd_prop_nv_pairs
= 0;
548 if
(($$
= alloc_cmd
()) == NULL
)
551 $$
->cmd_handler
= &info_func
;
552 $$
->cmd_res_type
= RT_LIMITPRIV
;
553 $$
->cmd_prop_nv_pairs
= 0;
557 if
(($$
= alloc_cmd
()) == NULL
)
560 $$
->cmd_handler
= &info_func
;
561 $$
->cmd_res_type
= RT_BOOTARGS
;
562 $$
->cmd_prop_nv_pairs
= 0;
566 if
(($$
= alloc_cmd
()) == NULL
)
569 $$
->cmd_handler
= &info_func
;
570 $$
->cmd_res_type
= RT_SCHED
;
571 $$
->cmd_prop_nv_pairs
= 0;
575 if
(($$
= alloc_cmd
()) == NULL
)
578 $$
->cmd_handler
= &info_func
;
579 $$
->cmd_res_type
= RT_SHARES
;
580 $$
->cmd_prop_nv_pairs
= 0;
584 if
(($$
= alloc_cmd
()) == NULL
)
587 $$
->cmd_handler
= &info_func
;
588 $$
->cmd_res_type
= RT_MAXLWPS
;
589 $$
->cmd_prop_nv_pairs
= 0;
593 if
(($$
= alloc_cmd
()) == NULL
)
596 $$
->cmd_handler
= &info_func
;
597 $$
->cmd_res_type
= RT_MAXPROCS
;
598 $$
->cmd_prop_nv_pairs
= 0;
602 if
(($$
= alloc_cmd
()) == NULL
)
605 $$
->cmd_handler
= &info_func
;
606 $$
->cmd_res_type
= RT_MAXSHMMEM
;
607 $$
->cmd_prop_nv_pairs
= 0;
611 if
(($$
= alloc_cmd
()) == NULL
)
614 $$
->cmd_handler
= &info_func
;
615 $$
->cmd_res_type
= RT_MAXSHMIDS
;
616 $$
->cmd_prop_nv_pairs
= 0;
620 if
(($$
= alloc_cmd
()) == NULL
)
623 $$
->cmd_handler
= &info_func
;
624 $$
->cmd_res_type
= RT_MAXMSGIDS
;
625 $$
->cmd_prop_nv_pairs
= 0;
629 if
(($$
= alloc_cmd
()) == NULL
)
632 $$
->cmd_handler
= &info_func
;
633 $$
->cmd_res_type
= RT_MAXSEMIDS
;
634 $$
->cmd_prop_nv_pairs
= 0;
638 if
(($$
= alloc_cmd
()) == NULL
)
641 $$
->cmd_handler
= &info_func
;
642 $$
->cmd_res_type
= RT_HOSTID
;
643 $$
->cmd_prop_nv_pairs
= 0;
647 if
(($$
= alloc_cmd
()) == NULL
)
650 $$
->cmd_handler
= &info_func
;
651 $$
->cmd_res_type
= RT_FS_ALLOWED
;
652 $$
->cmd_prop_nv_pairs
= 0;
654 | INFO resource_type property_name EQUAL property_value
656 if
(($$
= alloc_cmd
()) == NULL
)
659 $$
->cmd_handler
= &info_func
;
660 $$
->cmd_res_type
= $2;
661 $$
->cmd_prop_nv_pairs
= 1;
662 $$
->cmd_prop_name
[0] = $3;
663 $$
->cmd_property_ptr
[0] = &property
[0];
665 | INFO resource_type property_name EQUAL property_value property_name EQUAL property_value
667 if
(($$
= alloc_cmd
()) == NULL
)
670 $$
->cmd_handler
= &info_func
;
671 $$
->cmd_res_type
= $2;
672 $$
->cmd_prop_nv_pairs
= 2;
673 $$
->cmd_prop_name
[0] = $3;
674 $$
->cmd_property_ptr
[0] = &property
[0];
675 $$
->cmd_prop_name
[1] = $6;
676 $$
->cmd_property_ptr
[1] = &property
[1];
678 | INFO resource_type property_name EQUAL property_value property_name EQUAL property_value property_name EQUAL property_value
680 if
(($$
= alloc_cmd
()) == NULL
)
683 $$
->cmd_handler
= &info_func
;
684 $$
->cmd_res_type
= $2;
685 $$
->cmd_prop_nv_pairs
= 3;
686 $$
->cmd_prop_name
[0] = $3;
687 $$
->cmd_property_ptr
[0] = &property
[0];
688 $$
->cmd_prop_name
[1] = $6;
689 $$
->cmd_property_ptr
[1] = &property
[1];
690 $$
->cmd_prop_name
[2] = $9;
691 $$
->cmd_property_ptr
[2] = &property
[2];
694 remove_command: REMOVE
696 short_usage
(CMD_REMOVE
);
697 (void) fputs
("\n", stderr
);
698 usage
(B_FALSE
, HELP_RES_PROPS
);
703 short_usage
(CMD_REMOVE
);
704 (void) fputs
("\n", stderr
);
705 usage
(B_FALSE
, HELP_RES_PROPS
);
706 free
(claim_token
($2));
709 | REMOVE resource_type
711 if
(($$
= alloc_cmd
()) == NULL
)
714 $$
->cmd_handler
= &remove_func
;
715 $$
->cmd_res_type
= $2;
717 | REMOVE TOKEN resource_type
719 if
(($$
= alloc_cmd
()) == NULL
)
722 $$
->cmd_handler
= &remove_func
;
723 $$
->cmd_res_type
= $3;
725 $$
->cmd_argv
[0] = claim_token
($2);
726 $$
->cmd_argv
[1] = NULL
;
728 | REMOVE property_name property_value
730 if
(($$
= alloc_cmd
()) == NULL
)
733 $$
->cmd_handler
= &remove_func
;
734 $$
->cmd_prop_nv_pairs
= 1;
735 $$
->cmd_prop_name
[0] = $2;
736 $$
->cmd_property_ptr
[0] = &property
[0];
738 | REMOVE resource_type property_name EQUAL property_value
740 if
(($$
= alloc_cmd
()) == NULL
)
743 $$
->cmd_handler
= &remove_func
;
744 $$
->cmd_res_type
= $2;
745 $$
->cmd_prop_nv_pairs
= 1;
746 $$
->cmd_prop_name
[0] = $3;
747 $$
->cmd_property_ptr
[0] = &property
[0];
749 | REMOVE resource_type property_name EQUAL property_value property_name EQUAL property_value
751 if
(($$
= alloc_cmd
()) == NULL
)
754 $$
->cmd_handler
= &remove_func
;
755 $$
->cmd_res_type
= $2;
756 $$
->cmd_prop_nv_pairs
= 2;
757 $$
->cmd_prop_name
[0] = $3;
758 $$
->cmd_property_ptr
[0] = &property
[0];
759 $$
->cmd_prop_name
[1] = $6;
760 $$
->cmd_property_ptr
[1] = &property
[1];
762 | REMOVE resource_type property_name EQUAL property_value property_name EQUAL property_value property_name EQUAL property_value
764 if
(($$
= alloc_cmd
()) == NULL
)
767 $$
->cmd_handler
= &remove_func
;
768 $$
->cmd_res_type
= $2;
769 $$
->cmd_prop_nv_pairs
= 3;
770 $$
->cmd_prop_name
[0] = $3;
771 $$
->cmd_property_ptr
[0] = &property
[0];
772 $$
->cmd_prop_name
[1] = $6;
773 $$
->cmd_property_ptr
[1] = &property
[1];
774 $$
->cmd_prop_name
[2] = $9;
775 $$
->cmd_property_ptr
[2] = &property
[2];
778 revert_command: REVERT
780 if
(($$
= alloc_cmd
()) == NULL
)
783 $$
->cmd_handler
= &revert_func
;
785 $$
->cmd_argv
[0] = NULL
;
789 if
(($$
= alloc_cmd
()) == NULL
)
792 $$
->cmd_handler
= &revert_func
;
794 $$
->cmd_argv
[0] = claim_token
($2);
795 $$
->cmd_argv
[1] = NULL
;
798 select_command: SELECT
800 short_usage
(CMD_SELECT
);
801 (void) fputs
("\n", stderr
);
802 usage
(B_FALSE
, HELP_RES_PROPS
);
807 if
(($$
= alloc_cmd
()) == NULL
)
810 $$
->cmd_handler
= &select_func
;
811 $$
->cmd_res_type
= RT_DCPU
;
815 if
(($$
= alloc_cmd
()) == NULL
)
818 $$
->cmd_handler
= &select_func
;
819 $$
->cmd_res_type
= RT_PCAP
;
823 if
(($$
= alloc_cmd
()) == NULL
)
826 $$
->cmd_handler
= &select_func
;
827 $$
->cmd_res_type
= RT_MCAP
;
829 | SELECT resource_type
831 short_usage
(CMD_SELECT
);
834 | SELECT resource_type property_name EQUAL property_value
836 if
(($$
= alloc_cmd
()) == NULL
)
839 $$
->cmd_handler
= &select_func
;
840 $$
->cmd_res_type
= $2;
841 $$
->cmd_prop_nv_pairs
= 1;
842 $$
->cmd_prop_name
[0] = $3;
843 $$
->cmd_property_ptr
[0] = &property
[0];
845 | SELECT resource_type property_name EQUAL property_value property_name EQUAL property_value
847 if
(($$
= alloc_cmd
()) == NULL
)
850 $$
->cmd_handler
= &select_func
;
851 $$
->cmd_res_type
= $2;
852 $$
->cmd_prop_nv_pairs
= 2;
853 $$
->cmd_prop_name
[0] = $3;
854 $$
->cmd_property_ptr
[0] = &property
[0];
855 $$
->cmd_prop_name
[1] = $6;
856 $$
->cmd_property_ptr
[1] = &property
[1];
858 | SELECT resource_type property_name EQUAL property_value property_name EQUAL property_value property_name EQUAL property_value
860 if
(($$
= alloc_cmd
()) == NULL
)
863 $$
->cmd_handler
= &select_func
;
864 $$
->cmd_res_type
= $2;
865 $$
->cmd_prop_nv_pairs
= 3;
866 $$
->cmd_prop_name
[0] = $3;
867 $$
->cmd_property_ptr
[0] = &property
[0];
868 $$
->cmd_prop_name
[1] = $6;
869 $$
->cmd_property_ptr
[1] = &property
[1];
870 $$
->cmd_prop_name
[2] = $9;
871 $$
->cmd_property_ptr
[2] = &property
[2];
876 short_usage
(CMD_SET
);
877 (void) fputs
("\n", stderr
);
878 usage
(B_FALSE
, HELP_PROPS
);
881 | SET property_name EQUAL OPEN_SQ_BRACKET CLOSE_SQ_BRACKET
883 if
(($$
= alloc_cmd
()) == NULL
)
886 $$
->cmd_handler
= &set_func
;
887 $$
->cmd_prop_nv_pairs
= 0;
888 $$
->cmd_prop_name
[0] = $2;
889 property
[0].pv_type
= PROP_VAL_LIST
;
890 property
[0].pv_list
= NULL
;
891 $$
->cmd_property_ptr
[0] = &property
[0];
893 | SET property_name EQUAL property_value
895 if
(($$
= alloc_cmd
()) == NULL
)
898 $$
->cmd_handler
= &set_func
;
899 $$
->cmd_prop_nv_pairs
= 1;
900 $$
->cmd_prop_name
[0] = $2;
901 $$
->cmd_property_ptr
[0] = &property
[0];
903 | SET TOKEN ZONEPATH EQUAL property_value
905 if
(($$
= alloc_cmd
()) == NULL
)
909 $$
->cmd_argv
[0] = claim_token
($2);
910 $$
->cmd_argv
[1] = NULL
;
911 $$
->cmd_handler
= &set_func
;
912 $$
->cmd_prop_nv_pairs
= 1;
913 $$
->cmd_prop_name
[0] = PT_ZONEPATH
;
914 $$
->cmd_property_ptr
[0] = &property
[0];
919 short_usage
(CMD_CLEAR
);
920 (void) fputs
("\n", stderr
);
921 usage
(B_FALSE
, HELP_PROPS
);
924 | CLEAR property_name
926 if
(($$
= alloc_cmd
()) == NULL
)
929 $$
->cmd_handler
= &clear_func
;
930 $$
->cmd_res_type
= $2;
933 verify_command: VERIFY
935 if
(($$
= alloc_cmd
()) == NULL
)
938 $$
->cmd_handler
= &verify_func
;
940 $$
->cmd_argv
[0] = NULL
;
944 if
(($$
= alloc_cmd
()) == NULL
)
947 $$
->cmd_handler
= &verify_func
;
949 $$
->cmd_argv
[0] = claim_token
($2);
950 $$
->cmd_argv
[1] = NULL
;
953 resource_type: NET
{ $$
= RT_NET
; }
955 | DEVICE
{ $$
= RT_DEVICE
; }
956 | RCTL
{ $$
= RT_RCTL
; }
957 | ATTR
{ $$
= RT_ATTR
; }
958 | DATASET
{ $$
= RT_DATASET
; }
959 | PSET
{ $$
= RT_DCPU
; }
960 | PCAP
{ $$
= RT_PCAP
; }
961 | MCAP
{ $$
= RT_MCAP
; }
962 | ADMIN
{ $$
= RT_ADMIN
; }
963 | SECFLAGS
{ $$
= RT_SECFLAGS
; }
965 property_name: SPECIAL
{ $$
= PT_SPECIAL
; }
966 | RAW
{ $$
= PT_RAW
; }
967 |
DIR { $$
= PT_DIR
; }
968 | TYPE
{ $$
= PT_TYPE
; }
969 | OPTIONS
{ $$
= PT_OPTIONS
; }
970 | ZONENAME
{ $$
= PT_ZONENAME
; }
971 | ZONEPATH
{ $$
= PT_ZONEPATH
; }
972 | AUTOBOOT
{ $$
= PT_AUTOBOOT
; }
973 | IPTYPE
{ $$
= PT_IPTYPE
; }
974 | POOL
{ $$
= PT_POOL
; }
975 | LIMITPRIV
{ $$
= PT_LIMITPRIV
; }
976 | BOOTARGS
{ $$
= PT_BOOTARGS
; }
977 | ADDRESS
{ $$
= PT_ADDRESS
; }
978 | ALLOWED_ADDRESS
{ $$
= PT_ALLOWED_ADDRESS
; }
979 | PHYSICAL
{ $$
= PT_PHYSICAL
; }
980 | DEFROUTER
{ $$
= PT_DEFROUTER
; }
981 | NAME
{ $$
= PT_NAME
; }
982 | VALUE
{ $$
= PT_VALUE
; }
983 | MATCH
{ $$
= PT_MATCH
; }
984 | PRIV
{ $$
= PT_PRIV
; }
985 | LIMIT
{ $$
= PT_LIMIT
; }
986 | ACTION
{ $$
= PT_ACTION
; }
987 | BRAND
{ $$
= PT_BRAND
; }
988 | NCPUS
{ $$
= PT_NCPUS
; }
989 | LOCKED
{ $$
= PT_LOCKED
; }
990 | SWAP
{ $$
= PT_SWAP
; }
991 | IMPORTANCE
{ $$
= PT_IMPORTANCE
; }
992 | SHARES
{ $$
= PT_SHARES
; }
993 | MAXLWPS
{ $$
= PT_MAXLWPS
; }
994 | MAXPROCS
{ $$
= PT_MAXPROCS
; }
995 | MAXSHMMEM
{ $$
= PT_MAXSHMMEM
; }
996 | MAXSHMIDS
{ $$
= PT_MAXSHMIDS
; }
997 | MAXMSGIDS
{ $$
= PT_MAXMSGIDS
; }
998 | MAXSEMIDS
{ $$
= PT_MAXSEMIDS
; }
999 | SCHED
{ $$
= PT_SCHED
; }
1000 | HOSTID
{ $$
= PT_HOSTID
; }
1001 | USER
{ $$
= PT_USER
; }
1002 | AUTHS
{ $$
= PT_AUTHS
; }
1003 | FS_ALLOWED
{ $$
= PT_FS_ALLOWED
; }
1004 | DEFAULT
{ $$
= PT_DEFAULT
; }
1005 | UPPER
{ $$
= PT_UPPER
; }
1006 | LOWER
{ $$
= PT_LOWER
; }
1009 * The grammar builds data structures from the bottom up. Thus various
1010 * strings are lexed into TOKENs or commands or resource or property values.
1011 * Below is where the resource and property values are built up into more
1012 * complex data structures.
1014 * There are three kinds of properties: simple (single valued), complex
1015 * (one or more name=value pairs) and list (concatenation of one or more
1016 * simple or complex properties).
1018 * So the property structure has a type which is one of these, and the
1019 * corresponding _simple, _complex or _list is set to the corresponding
1020 * lower-level data structure.
1023 property_value: simple_prop_val
1025 property
[num_prop_vals
].pv_type
= PROP_VAL_SIMPLE
;
1026 property
[num_prop_vals
].pv_simple
= $1;
1027 if
(list
[num_prop_vals
] != NULL
) {
1028 free_outer_list
(list
[num_prop_vals
]);
1029 list
[num_prop_vals
] = NULL
;
1035 property
[num_prop_vals
].pv_type
= PROP_VAL_COMPLEX
;
1036 property
[num_prop_vals
].pv_complex
= complex;
1037 if
(list
[num_prop_vals
] != NULL
) {
1038 free_outer_list
(list
[num_prop_vals
]);
1039 list
[num_prop_vals
] = NULL
;
1045 property
[num_prop_vals
].pv_type
= PROP_VAL_LIST
;
1046 property
[num_prop_vals
].pv_list
= list
[num_prop_vals
];
1051 * One level lower, lists are made up of simple or complex values, so
1052 * simple_prop_val and complex_prop_val fill in a list structure and
1053 * insert it into the linked list which is built up. And because
1054 * complex properties can have multiple name=value pairs, we keep
1055 * track of them in another linked list.
1057 * The complex and list structures for the linked lists are allocated
1058 * below, and freed by recursive functions which are ultimately called
1059 * by free_cmd(), which is called from the top-most "commands" part of
1062 * NOTE: simple_prop_val and complex_piece need reduction rules for
1063 * property_name and resource_type so that the parser will accept property names
1064 * and resource type names as property values.
1067 simple_prop_val: TOKEN
1069 $$
= simple_prop_val_func
($1);
1070 free
(claim_token
($1));
1076 if
(($$
= simple_prop_val_func
(res_types
[$1])) == NULL
)
1081 if
(($$
= simple_prop_val_func
(prop_types
[$1])) == NULL
)
1085 complex_prop_val: OPEN_PAREN complex_piece CLOSE_PAREN
1087 if
((new_list
= alloc_list
()) == NULL
)
1089 new_list
->lp_simple
= NULL
;
1090 new_list
->lp_complex
= complex;
1091 new_list
->lp_next
= NULL
;
1092 if
(list
[num_prop_vals
] == NULL
) {
1093 list
[num_prop_vals
] = new_list
;
1095 for
(tmp_list
= list
[num_prop_vals
]; tmp_list
!= NULL
;
1096 tmp_list
= tmp_list
->lp_next
)
1098 last
->lp_next
= new_list
;
1102 complex_piece: property_name EQUAL TOKEN
1104 $$
= complex_piece_func
($1, $3, NULL
);
1105 free
(claim_token
($3));
1109 | property_name EQUAL resource_type
1111 if
(($$
= complex_piece_func
($1, res_types
[$3], NULL
)) == NULL
)
1114 | property_name EQUAL property_name
1116 if
(($$
= complex_piece_func
($1, prop_types
[$3], NULL
)) == NULL
)
1119 | property_name EQUAL TOKEN COMMA complex_piece
1121 $$
= complex_piece_func
($1, $3, complex);
1122 free
(claim_token
($3));
1126 | property_name EQUAL resource_type COMMA complex_piece
1128 if
(($$
= complex_piece_func
($1, res_types
[$3], complex)) ==
1132 | property_name EQUAL property_name COMMA complex_piece
1134 if
(($$
= complex_piece_func
($1, prop_types
[$3], complex)) ==
1139 list_piece: simple_prop_val
1141 | simple_prop_val COMMA list_piece
1142 | complex_prop_val COMMA list_piece
1144 list_prop_val: OPEN_SQ_BRACKET list_piece CLOSE_SQ_BRACKET