1 /* 2 * $Id: fsi_gram.y,v 5.2.1.2 90/12/21 16:46:46 jsp Alpha $ 3 * 4 * Copyright (c) 1989 Jan-Simon Pendry 5 * Copyright (c) 1989 Imperial College of Science, Technology & Medicine 6 * Copyright (c) 1989 The Regents of the University of California. 7 * All rights reserved. 8 * 9 * This code is derived from software contributed to Berkeley by 10 * Jan-Simon Pendry at Imperial College, London. 11 * 12 * %sccs.include.redist.c% 13 * 14 * @(#)fsi_gram.y 5.2 (Berkeley) 03/17/91 15 */ 16 17 %{ 18 #include "../fsinfo/fsinfo.h" 19 #include <stdio.h> 20 21 extern qelem *list_of_hosts, *list_of_automounts; 22 %} 23 24 %union { 25 auto_tree *a; 26 disk_fs *d; 27 ether_if *e; 28 host *h; 29 qelem *q; 30 char *s; 31 mount *m; 32 fsmount *f; 33 } 34 35 %token tARCH 36 %token tAS 37 %token tAUTOMOUNT 38 %token tCLUSTER 39 %token tCONFIG 40 %token tDUMPSET 41 %token tEQ 42 %token tEXPORTFS 43 %token tFREQ 44 %token tFROM 45 %token tFS 46 %token tFSTYPE 47 %token tHWADDR 48 %token tINADDR 49 %token tHOST 50 %token tLOCALHOST 51 %token tLOG 52 %token tMOUNT 53 %token tNETMASK 54 %token tNETIF 55 %token tVOLNAME 56 %token tOPTS 57 %token tOS 58 %token tPASSNO 59 %token tSEL 60 %token <s> tSTR 61 62 %start list_of_hosts 63 64 %type <a> automount 65 %type <q> automount_tree 66 %type <e> ether_attr 67 %type <m> dir_tree_info 68 %type <d> filesystem fs_info_list 69 %type <h> host host_attr host_attr_list 70 %type <q> list_of_hosts list_of_filesystems list_of_mounts dir_tree 71 %type <f> localinfo_list 72 %type <s> opt_auto_opts 73 74 %% 75 76 list_of_hosts : 77 /* empty */ 78 { $$ = new_que(); } 79 80 | list_of_hosts host 81 { if ($2) ins_que((qelem *) $2, list_of_hosts->q_back); 82 $$ = $1; } 83 84 | list_of_hosts automount 85 { if ($2) ins_que((qelem *) $2, list_of_automounts->q_back); 86 $$ = $1; } 87 ; 88 89 /* 90 * A new host: 91 * 92 * host foo.domain 93 */ 94 host : 95 tHOST host_attr list_of_filesystems list_of_mounts 96 { $$ = $2; $$->h_disk_fs = $3; $$->h_mount = $4; } 97 98 | error tHOST host_attr list_of_filesystems list_of_mounts 99 { $$ = $3; $$->h_disk_fs = $4; $$->h_mount = $5; } 100 101 ; 102 103 host_attr : 104 tSTR 105 { $$ = new_host(); set_host($$, HF_HOST, $1); } 106 107 | '{' host_attr_list '}' tSTR 108 { $$ = $2; set_host($$, HF_HOST, $4); } 109 110 ; 111 112 host_attr_list : 113 /* empty */ 114 { $$ = new_host(); } 115 116 | host_attr_list tNETIF tSTR '{' ether_attr '}' 117 { if ($5) { 118 $5->e_if = $3; 119 $$ = $1; set_host($$, HF_ETHER, $5); } 120 } 121 122 | host_attr_list tCONFIG tSTR 123 { $$ = $1; set_host($$, HF_CONFIG, $3); } 124 125 | host_attr_list tARCH '=' tSTR 126 { $$ = $1; set_host($$, HF_ARCH, $4); } 127 128 | host_attr_list tOS '=' tSTR 129 { $$ = $1; set_host($$, HF_OS, $4); } 130 131 | host_attr_list tCLUSTER '=' tSTR 132 { $$ = $1; set_host($$, HF_CLUSTER, $4); } 133 134 | host_attr_list error '=' tSTR 135 { yyerror("unknown host attribute"); } 136 ; 137 138 ether_attr : 139 /* empty */ 140 { $$ = new_ether_if(); } 141 142 | ether_attr tINADDR '=' tSTR 143 { $$ = $1; set_ether_if($$, EF_INADDR, $4); } 144 | ether_attr tNETMASK '=' tSTR 145 { $$ = $1; set_ether_if($$, EF_NETMASK, $4); } 146 | ether_attr tHWADDR '=' tSTR 147 { $$ = $1; set_ether_if($$, EF_HWADDR, $4); } 148 ; 149 150 /* 151 * A new automount tree: 152 * 153 * automount /mountpoint { ... } 154 */ 155 automount : 156 tAUTOMOUNT opt_auto_opts automount_tree 157 { if ($3) { 158 $$ = new_auto_tree($2, $3); 159 } else { 160 $$ = 0; 161 } 162 } 163 164 | tAUTOMOUNT error 165 { $$ = 0; } 166 ; 167 168 opt_auto_opts : 169 /* empty */ 170 { $$ = strdup(""); } 171 172 | tOPTS tSTR 173 { $$ = $2; } 174 ; 175 176 list_of_filesystems : 177 /* empty */ 178 { $$ = 0; } 179 180 | list_of_filesystems filesystem 181 { if ($2) { 182 if ($1) 183 $$ = $1; 184 else 185 $$ = new_que(); 186 ins_que(&$2->d_q, $$->q_back); 187 } else { 188 $$ = $1; 189 } 190 } 191 ; 192 193 /* 194 * A new filesystem: 195 * 196 * fs /dev/whatever { ... } 197 */ 198 filesystem : 199 tFS tSTR '{' fs_info_list '}' 200 { $4->d_dev = $2; $$ = $4; } 201 202 | tFS error '}' 203 { $$ = (disk_fs *) 0; } 204 ; 205 206 /* 207 * Per-filesystem information: 208 * 209 * fstype - the type of the filesystem (4.2, nfs, swap, export) 210 * opts - the mount options ("rw,grpid") 211 * passno - fsck pass number 212 * freq - dump frequency 213 * dumpset - tape set for filesystem dumps 214 * mount - where to mount this filesystem 215 * log - log device 216 */ 217 fs_info_list : 218 /* empty */ 219 { $$ = new_disk_fs(); } 220 221 | fs_info_list tFSTYPE '=' tSTR 222 { $$ = $1; set_disk_fs($$, DF_FSTYPE, $4); } 223 224 | fs_info_list tOPTS '=' tSTR 225 { $$ = $1; set_disk_fs($$, DF_OPTS, $4); } 226 227 | fs_info_list tPASSNO '=' tSTR 228 { $$ = $1; set_disk_fs($$, DF_PASSNO, $4); } 229 230 | fs_info_list tFREQ '=' tSTR 231 { $$ = $1; set_disk_fs($$, DF_FREQ, $4); } 232 233 | fs_info_list tMOUNT dir_tree 234 { $$ = $1; set_disk_fs($$, DF_MOUNT, (char *) $3); } 235 236 | fs_info_list tDUMPSET '=' tSTR 237 { $$ = $1; set_disk_fs($$, DF_DUMPSET, $4); } 238 239 | fs_info_list tLOG '=' tSTR 240 { $$ = $1; set_disk_fs($$, DF_LOG, $4); } 241 242 | fs_info_list error '=' tSTR 243 { yyerror("unknown filesystem attribute"); } 244 ; 245 246 /* 247 * An automount tree: 248 * 249 * name = "volname" name is a reference to volname 250 * name -> "string" name is a link to "string" 251 * name { ... } name is an automount tree 252 */ 253 automount_tree : 254 /* empty */ 255 { $$ = 0; } 256 257 | automount_tree tSTR '=' tSTR 258 { automount *a = new_automount($2); 259 a->a_volname = $4; 260 if ($1) 261 $$ = $1; 262 else 263 $$ = new_que(); 264 ins_que(&a->a_q, $$->q_back); 265 } 266 267 | automount_tree tSTR tEQ tSTR 268 { automount *a = new_automount($2); 269 a->a_symlink = $4; 270 if ($1) 271 $$ = $1; 272 else 273 $$ = new_que(); 274 ins_que(&a->a_q, $$->q_back); 275 } 276 277 | automount_tree tSTR '{' automount_tree '}' 278 { automount *a = new_automount($2); 279 a->a_mount = $4; 280 if ($1) 281 $$ = $1; 282 else 283 $$ = new_que(); 284 ins_que(&a->a_q, $$->q_back); 285 } 286 ; 287 288 dir_tree : 289 /* empty */ 290 { $$ = 0; } 291 292 | dir_tree tSTR '{' dir_tree_info dir_tree '}' 293 { $4->m_mount = $5; 294 $4->m_name = $2; 295 if ($2[0] != '/' && $2[1] && strchr($2+1, '/')) 296 yyerror("not allowed '/' in a directory name"); 297 if ($1) 298 $$ = $1; 299 else 300 $$ = new_que(); 301 ins_que(&$4->m_q, $$->q_back); 302 } 303 ; 304 305 dir_tree_info : 306 /* empty */ 307 { $$ = new_mount(); } 308 309 | dir_tree_info tEXPORTFS tSTR 310 { $$ = $1; set_mount($$, DM_EXPORTFS, $3); } 311 312 | dir_tree_info tVOLNAME tSTR 313 { $$ = $1; set_mount($$, DM_VOLNAME, $3); } 314 315 | dir_tree_info tSEL tSTR 316 { $$ = $1; set_mount($$, DM_SEL, $3); } 317 318 | dir_tree_info error '=' tSTR 319 { yyerror("unknown directory attribute"); } 320 ; 321 322 /* 323 * Additional mounts on a host 324 * 325 * mount "volname" ... 326 */ 327 list_of_mounts : 328 /* empty */ 329 { $$ = 0; } 330 331 | list_of_mounts tMOUNT tSTR localinfo_list 332 { set_fsmount($4, FM_VOLNAME, $3); 333 if ($1) 334 $$ = $1; 335 else 336 $$ = new_que(); 337 ins_que(&$4->f_q, $$->q_back); 338 } 339 ; 340 341 /* 342 * Mount info: 343 * 344 * from "hostname" - obtain the object from the named host 345 * as "string" - where to mount, if different from the volname 346 * opts "string" - mount options 347 * fstype "type" - type of filesystem mount, if not nfs 348 */ 349 localinfo_list : 350 /* empty */ 351 { $$ = new_fsmount(); } 352 353 | localinfo_list tAS tSTR 354 { $$ = $1; set_fsmount($$, FM_LOCALNAME, $3); } 355 356 | localinfo_list tFROM tSTR 357 { $$ = $1; set_fsmount($$, FM_FROM, $3); } 358 359 | localinfo_list tFSTYPE tSTR 360 { $$ = $1; set_fsmount($$, FM_FSTYPE, $3); } 361 362 | localinfo_list tOPTS tSTR 363 { $$ = $1; set_fsmount($$, FM_OPTS, $3); } 364 365 | localinfo_list error '=' tSTR 366 { yyerror("unknown mount attribute"); } 367 ; 368