7 static void merge_props
(struct directory_prop
*out
, struct directory_prop
*a
,
8 struct directory_prop
*b
)
10 out
->got_storage
= a
->got_storage || b
->got_storage
;
12 if
(a
->got_storage
&& !b
->got_storage
)
13 out
->storage
= a
->storage
;
14 else if
(!a
->got_storage
&& b
->got_storage
)
15 out
->storage
= b
->storage
;
16 else if
(a
->got_storage
&& b
->got_storage
)
20 static struct directory_vdev
*__alloc_spool_vdev
(enum directory_vdevtype type
,
21 u64 devnum
, u64 typenum
)
23 struct directory_vdev
*vdev
;
25 assert
(devnum
<= 0xffff);
26 assert
(typenum
<= 0xffff);
27 assert
((type
== VDEV_CONS
) ||
(type
== VDEV_SPOOL
));
29 vdev
= malloc
(sizeof
(struct directory_vdev
), ZONE_NORMAL
);
35 if
(type
== VDEV_SPOOL
) {
36 vdev
->u.spool.type
= typenum
;
37 vdev
->u.spool.model
= 0;
43 static struct directory_vdev
*__alloc_mdisk_vdev
(u64 devnum
, u64 typenum
,
44 u64 start
, u64 len
, u64 rdev
)
46 struct directory_vdev
*vdev
;
48 assert
(devnum
<= 0xffff);
49 assert
(typenum
<= 0xffff);
50 assert
(start
<= 0xffff);
51 assert
(len
<= 0xffff);
52 assert
(rdev
<= 0xffff);
54 vdev
= malloc
(sizeof
(struct directory_vdev
), ZONE_NORMAL
);
57 vdev
->type
= VDEV_MDISK
;
59 vdev
->u.mdisk.cyloff
= start
;
60 vdev
->u.mdisk.cylcnt
= len
;
61 vdev
->u.mdisk.rdev
= rdev
;
66 static int __auth_str
(char *in
)
92 static int __auth_int
(u64 in
)
101 struct directory_vdev
*vdev
;
102 struct list_head list
;
103 struct directory_prop prop
;
109 %token
<num
> STORSPEC NUM
110 %token USER MACHINE STORAGE CONSOLE SPOOL READER PUNCH PRINT MDISK
113 %type
<prop
> props prop
119 users
: users NLINE user
121 | NLINE
/* an empty line */
124 user
: USER WORD WORD NLINE props vdevs
{ directory_alloc_user
($2, __auth_str
($3), &$5, &$6); }
125 | USER WORD NUM NLINE props vdevs
{ directory_alloc_user
($2, __auth_int
($3), &$5, &$6); }
128 props
: props prop
{ merge_props
(&$$
, &$1, &$2); }
129 | prop
{ memcpy
(&$$
, &$1, sizeof
($$
)); }
132 vdevs
: vdevs vdev
{ INIT_LIST_HEAD
(&$$
);
133 list_splice
(&$1, &$$
);
134 list_add
(&$2->list
, &$$
);
136 | vdev
{ INIT_LIST_HEAD
(&$$
);
137 list_add
(&$1->list
, &$$
);
141 prop
: MACHINE WORD NUM NLINE
{ memset
(&$$
, 0, sizeof
($$
));
144 | STORAGE STORSPEC NLINE
{ $$.got_storage
= 1;
146 | STORAGE NUM NLINE
{ $$.got_storage
= 1;
147 assert
(!bcd2dec
($2, &$$.storage
));
151 vdev
: CONSOLE NUM NUM NLINE
{ $$
= __alloc_spool_vdev
(VDEV_CONS
, $2, $3); }
152 | SPOOL NUM NUM READER NLINE
{ $$
= __alloc_spool_vdev
(VDEV_SPOOL
, $2, $3); }
153 | SPOOL NUM NUM PUNCH NLINE
{ $$
= __alloc_spool_vdev
(VDEV_SPOOL
, $2, $3); }
154 | SPOOL NUM NUM PRINT NLINE
{ $$
= __alloc_spool_vdev
(VDEV_SPOOL
, $2, $3); }
155 | MDISK NUM NUM NUM NUM NUM NLINE
{ $$
= __alloc_mdisk_vdev
($2, $3, $4, $5, $6); }