fsi_analyze.c (82794) | fsi_analyze.c (119679) |
---|---|
1/* | 1/* |
2 * Copyright (c) 1997-2001 Erez Zadok | 2 * Copyright (c) 1997-2003 Erez Zadok |
3 * Copyright (c) 1989 Jan-Simon Pendry 4 * Copyright (c) 1989 Imperial College of Science, Technology & Medicine 5 * Copyright (c) 1989 The Regents of the University of California. 6 * All rights reserved. 7 * 8 * This code is derived from software contributed to Berkeley by 9 * Jan-Simon Pendry at Imperial College, London. 10 * --- 22 unchanged lines hidden (view full) --- 33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 37 * SUCH DAMAGE. 38 * 39 * %W% (Berkeley) %G% 40 * | 3 * Copyright (c) 1989 Jan-Simon Pendry 4 * Copyright (c) 1989 Imperial College of Science, Technology & Medicine 5 * Copyright (c) 1989 The Regents of the University of California. 6 * All rights reserved. 7 * 8 * This code is derived from software contributed to Berkeley by 9 * Jan-Simon Pendry at Imperial College, London. 10 * --- 22 unchanged lines hidden (view full) --- 33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 37 * SUCH DAMAGE. 38 * 39 * %W% (Berkeley) %G% 40 * |
41 * $Id: fsi_analyze.c,v 1.3.2.1 2001/01/10 03:23:32 ezk Exp $ | 41 * $Id: fsi_analyze.c,v 1.3.2.4 2003/07/18 04:50:19 ezk Exp $ |
42 * 43 */ 44 45/* 46 * Analyze filesystem declarations 47 * 48 * Note: most of this is magic! 49 */ --- 75 unchanged lines hidden (view full) --- 125 *d = 0; 126 strcat(path, d + 1); 127 strcat(path, "/"); 128 } else { 129 strcat(path, p); 130 } 131 } while (d); 132 | 42 * 43 */ 44 45/* 46 * Analyze filesystem declarations 47 * 48 * Note: most of this is magic! 49 */ --- 75 unchanged lines hidden (view full) --- 125 *d = 0; 126 strcat(path, d + 1); 127 strcat(path, "/"); 128 } else { 129 strcat(path, p); 130 } 131 } while (d); 132 |
133 log("hostpath of '%s' is '%s'", hn, path); | 133 fsi_log("hostpath of '%s' is '%s'", hn, path); |
134 135 strcpy(p, path); 136 return p; 137} 138 139 140static dict_ent * 141find_volname(char *nn) 142{ 143 dict_ent *de; 144 char *p = strdup(nn); 145 char *q; 146 147 do { | 134 135 strcpy(p, path); 136 return p; 137} 138 139 140static dict_ent * 141find_volname(char *nn) 142{ 143 dict_ent *de; 144 char *p = strdup(nn); 145 char *q; 146 147 do { |
148 log("Searching for volname %s", p); | 148 fsi_log("Searching for volname %s", p); |
149 de = dict_locate(dict_of_volnames, p); 150 q = strrchr(p, '/'); 151 if (q) 152 *q = '\0'; 153 } while (!de && q); 154 155 XFREE(p); 156 return de; 157} 158 159 160static void 161show_required(ioloc *l, int mask, char *info, char *hostname, char *strings[]) 162{ 163 int i; | 149 de = dict_locate(dict_of_volnames, p); 150 q = strrchr(p, '/'); 151 if (q) 152 *q = '\0'; 153 } while (!de && q); 154 155 XFREE(p); 156 return de; 157} 158 159 160static void 161show_required(ioloc *l, int mask, char *info, char *hostname, char *strings[]) 162{ 163 int i; |
164 log("mask left for %s:%s is %#x", hostname, info, mask); | 164 fsi_log("mask left for %s:%s is %#x", hostname, info, mask); |
165 166 for (i = 0; strings[i]; i++) 167 if (ISSET(mask, i)) 168 lerror(l, "%s:%s needs field \"%s\"", hostname, info, strings[i]); 169} 170 171 172/* --- 40 unchanged lines hidden (view full) --- 213 214static int 215analyze_dkmount_tree(qelem *q, fsi_mount *parent, disk_fs *dk) 216{ 217 fsi_mount *mp; 218 int errors = 0; 219 220 ITER(mp, fsi_mount, q) { | 165 166 for (i = 0; strings[i]; i++) 167 if (ISSET(mask, i)) 168 lerror(l, "%s:%s needs field \"%s\"", hostname, info, strings[i]); 169} 170 171 172/* --- 40 unchanged lines hidden (view full) --- 213 214static int 215analyze_dkmount_tree(qelem *q, fsi_mount *parent, disk_fs *dk) 216{ 217 fsi_mount *mp; 218 int errors = 0; 219 220 ITER(mp, fsi_mount, q) { |
221 log("Mount %s:", mp->m_name); | 221 fsi_log("Mount %s:", mp->m_name); |
222 if (parent) { 223 char n[MAXPATHLEN]; 224 sprintf(n, "%s/%s", parent->m_name, mp->m_name); 225 if (*mp->m_name == '/') 226 lerror(mp->m_ioloc, "sub-directory %s of %s starts with '/'", mp->m_name, parent->m_name); 227 else if (STREQ(mp->m_name, "default")) 228 lwarning(mp->m_ioloc, "sub-directory of %s is named \"default\"", parent->m_name); | 222 if (parent) { 223 char n[MAXPATHLEN]; 224 sprintf(n, "%s/%s", parent->m_name, mp->m_name); 225 if (*mp->m_name == '/') 226 lerror(mp->m_ioloc, "sub-directory %s of %s starts with '/'", mp->m_name, parent->m_name); 227 else if (STREQ(mp->m_name, "default")) 228 lwarning(mp->m_ioloc, "sub-directory of %s is named \"default\"", parent->m_name); |
229 log("Changing name %s to %s", mp->m_name, n); | 229 fsi_log("Changing name %s to %s", mp->m_name, n); |
230 XFREE(mp->m_name); 231 mp->m_name = strdup(n); 232 } 233 234 mp->m_name_len = strlen(mp->m_name); 235 mp->m_parent = parent; 236 mp->m_dk = dk; 237 if (mp->m_mount) --- 44 unchanged lines hidden (view full) --- 282 * Now see if a default mount point is required 283 */ 284 if (STREQ(mp2->m_name, "default")) { 285 if (ISSET(mp2->m_mask, DM_VOLNAME)) { 286 char nbuf[1024]; 287 compute_automount_point(nbuf, dk->d_host, mp2->m_volname); 288 XFREE(mp2->m_name); 289 mp2->m_name = strdup(nbuf); | 230 XFREE(mp->m_name); 231 mp->m_name = strdup(n); 232 } 233 234 mp->m_name_len = strlen(mp->m_name); 235 mp->m_parent = parent; 236 mp->m_dk = dk; 237 if (mp->m_mount) --- 44 unchanged lines hidden (view full) --- 282 * Now see if a default mount point is required 283 */ 284 if (STREQ(mp2->m_name, "default")) { 285 if (ISSET(mp2->m_mask, DM_VOLNAME)) { 286 char nbuf[1024]; 287 compute_automount_point(nbuf, dk->d_host, mp2->m_volname); 288 XFREE(mp2->m_name); 289 mp2->m_name = strdup(nbuf); |
290 log("%s:%s has default mount on %s", dk->d_host->h_hostname, dk->d_dev, mp2->m_name); | 290 fsi_log("%s:%s has default mount on %s", dk->d_host->h_hostname, dk->d_dev, mp2->m_name); |
291 } else { 292 lerror(dk->d_ioloc, "no volname given for %s:%s", dk->d_host->h_hostname, dk->d_dev); 293 errors++; 294 } 295 } 296 297 /* 298 * Fill in the disk mount point --- 118 unchanged lines hidden (view full) --- 417 dict_data *dd; 418 fsi_mount *mp = 0; 419 dd = AM_FIRST(dict_data, &de->de_q); 420 mp = (fsi_mount *) dd->dd_data; 421 if (!mp) 422 abort(); 423 fp->f_ref = mp; 424 set_fsmount(fp, FM_FROM, mp->m_dk->d_host->h_hostname); | 291 } else { 292 lerror(dk->d_ioloc, "no volname given for %s:%s", dk->d_host->h_hostname, dk->d_dev); 293 errors++; 294 } 295 } 296 297 /* 298 * Fill in the disk mount point --- 118 unchanged lines hidden (view full) --- 417 dict_data *dd; 418 fsi_mount *mp = 0; 419 dd = AM_FIRST(dict_data, &de->de_q); 420 mp = (fsi_mount *) dd->dd_data; 421 if (!mp) 422 abort(); 423 fp->f_ref = mp; 424 set_fsmount(fp, FM_FROM, mp->m_dk->d_host->h_hostname); |
425 log("set: %s comes from %s", fp->f_volname, fp->f_from); | 425 fsi_log("set: %s comes from %s", fp->f_volname, fp->f_from); |
426 } 427 } 428 429 if (!ISSET(fp->f_mask, FM_FSTYPE)) { 430 set_fsmount(fp, FM_FSTYPE, strdup("nfs")); | 426 } 427 } 428 429 if (!ISSET(fp->f_mask, FM_FSTYPE)) { 430 set_fsmount(fp, FM_FSTYPE, strdup("nfs")); |
431 log("set: fstype is %s", fp->f_fstype); | 431 fsi_log("set: fstype is %s", fp->f_fstype); |
432 } 433 434 if (!ISSET(fp->f_mask, FM_OPTS)) { 435 set_fsmount(fp, FM_OPTS, strdup("rw,nosuid,grpid,defaults")); | 432 } 433 434 if (!ISSET(fp->f_mask, FM_OPTS)) { 435 set_fsmount(fp, FM_OPTS, strdup("rw,nosuid,grpid,defaults")); |
436 log("set: opts are %s", fp->f_opts); | 436 fsi_log("set: opts are %s", fp->f_opts); |
437 } 438 439 if (!ISSET(fp->f_mask, FM_LOCALNAME)) { 440 if (fp->f_ref) { 441 set_fsmount(fp, FM_LOCALNAME, strdup(fp->f_volname)); | 437 } 438 439 if (!ISSET(fp->f_mask, FM_LOCALNAME)) { 440 if (fp->f_ref) { 441 set_fsmount(fp, FM_LOCALNAME, strdup(fp->f_volname)); |
442 log("set: localname is %s", fp->f_localname); | 442 fsi_log("set: localname is %s", fp->f_localname); |
443 } else { 444 lerror(fp->f_ioloc, "cannot determine localname since volname %s is not uniquely defined", fp->f_volname); 445 } 446 } 447} 448 449 450/* --- 5 unchanged lines hidden (view full) --- 456static void 457analyze_drives(host *hp) 458{ 459 qelem *q = hp->h_disk_fs; 460 disk_fs *dp; 461 462 ITER(dp, disk_fs, q) { 463 int req; | 443 } else { 444 lerror(fp->f_ioloc, "cannot determine localname since volname %s is not uniquely defined", fp->f_volname); 445 } 446 } 447} 448 449 450/* --- 5 unchanged lines hidden (view full) --- 456static void 457analyze_drives(host *hp) 458{ 459 qelem *q = hp->h_disk_fs; 460 disk_fs *dp; 461 462 ITER(dp, disk_fs, q) { 463 int req; |
464 log("Disk %s:", dp->d_dev); | 464 fsi_log("Disk %s:", dp->d_dev); |
465 dp->d_host = hp; 466 fixup_required_disk_info(dp); 467 req = ~dp->d_mask & DF_REQUIRED; 468 if (req) 469 show_required(dp->d_ioloc, req, dp->d_dev, hp->h_hostname, disk_fs_strings); 470 analyze_dkmounts(dp, dp->d_mount); 471 } 472} --- 20 unchanged lines hidden (view full) --- 493 494 if (ISSET(fp->f_mask, FM_DIRECT)) { 495 found = 1; 496 matched = 1; 497 } else 498 do { 499 p = 0; 500 de = find_volname(nn); | 465 dp->d_host = hp; 466 fixup_required_disk_info(dp); 467 req = ~dp->d_mask & DF_REQUIRED; 468 if (req) 469 show_required(dp->d_ioloc, req, dp->d_dev, hp->h_hostname, disk_fs_strings); 470 analyze_dkmounts(dp, dp->d_mount); 471 } 472} --- 20 unchanged lines hidden (view full) --- 493 494 if (ISSET(fp->f_mask, FM_DIRECT)) { 495 found = 1; 496 matched = 1; 497 } else 498 do { 499 p = 0; 500 de = find_volname(nn); |
501 log("Mount: %s (trying %s)", fp->f_volname, nn); | 501 fsi_log("Mount: %s (trying %s)", fp->f_volname, nn); |
502 503 if (de) { 504 found = 1; 505 506 /* 507 * Check that the from field is really exporting 508 * the filesystem requested. 509 * LBL: If fake mount, then don't care about --- 62 unchanged lines hidden (view full) --- 572 host *hp; 573 574 show_area_being_processed("analyze hosts", 5); 575 576 /* 577 * Check all drives 578 */ 579 ITER(hp, host, q) { | 502 503 if (de) { 504 found = 1; 505 506 /* 507 * Check that the from field is really exporting 508 * the filesystem requested. 509 * LBL: If fake mount, then don't care about --- 62 unchanged lines hidden (view full) --- 572 host *hp; 573 574 show_area_being_processed("analyze hosts", 5); 575 576 /* 577 * Check all drives 578 */ 579 ITER(hp, host, q) { |
580 log("disks on host %s", hp->h_hostname); | 580 fsi_log("disks on host %s", hp->h_hostname); |
581 show_new("ana-host"); 582 hp->h_hostpath = compute_hostpath(hp->h_hostname); 583 584 if (hp->h_disk_fs) 585 analyze_drives(hp); 586 587 } 588 589 show_area_being_processed("analyze mounts", 5); 590 591 /* 592 * Check static mounts 593 */ 594 ITER(hp, host, q) { | 581 show_new("ana-host"); 582 hp->h_hostpath = compute_hostpath(hp->h_hostname); 583 584 if (hp->h_disk_fs) 585 analyze_drives(hp); 586 587 } 588 589 show_area_being_processed("analyze mounts", 5); 590 591 /* 592 * Check static mounts 593 */ 594 ITER(hp, host, q) { |
595 log("mounts on host %s", hp->h_hostname); | 595 fsi_log("mounts on host %s", hp->h_hostname); |
596 show_new("ana-mount"); 597 if (hp->h_mount) 598 analyze_mounts(hp); 599 600 } 601} 602 603 --- 25 unchanged lines hidden (view full) --- 629 char nname[1024]; 630 631 if (lvl > 0 || ap->a_mount) 632 if (ap->a_name[1] && strchr(ap->a_name + 1, '/')) 633 lerror(ap->a_ioloc, "not allowed '/' in a directory name"); 634 sprintf(nname, "%s/%s", pref, ap->a_name); 635 XFREE(ap->a_name); 636 ap->a_name = strdup(nname[1] == '/' ? nname + 1 : nname); | 596 show_new("ana-mount"); 597 if (hp->h_mount) 598 analyze_mounts(hp); 599 600 } 601} 602 603 --- 25 unchanged lines hidden (view full) --- 629 char nname[1024]; 630 631 if (lvl > 0 || ap->a_mount) 632 if (ap->a_name[1] && strchr(ap->a_name + 1, '/')) 633 lerror(ap->a_ioloc, "not allowed '/' in a directory name"); 634 sprintf(nname, "%s/%s", pref, ap->a_name); 635 XFREE(ap->a_name); 636 ap->a_name = strdup(nname[1] == '/' ? nname + 1 : nname); |
637 log("automount point %s:", ap->a_name); | 637 fsi_log("automount point %s:", ap->a_name); |
638 show_new("ana-automount"); 639 640 if (ap->a_mount) { 641 analyze_automount_tree(ap->a_mount, ap->a_name, lvl + 1); 642 } else if (ap->a_hardwiredfs) { | 638 show_new("ana-automount"); 639 640 if (ap->a_mount) { 641 analyze_automount_tree(ap->a_mount, ap->a_name, lvl + 1); 642 } else if (ap->a_hardwiredfs) { |
643 log("\thardwired from %s to %s", ap->a_volname, ap->a_hardwiredfs); | 643 fsi_log("\thardwired from %s to %s", ap->a_volname, ap->a_hardwiredfs); |
644 } else if (ap->a_volname) { | 644 } else if (ap->a_volname) { |
645 log("\tautomount from %s", ap->a_volname); | 645 fsi_log("\tautomount from %s", ap->a_volname); |
646 analyze_automount(ap); 647 } else if (ap->a_symlink) { | 646 analyze_automount(ap); 647 } else if (ap->a_symlink) { |
648 log("\tsymlink to %s", ap->a_symlink); | 648 fsi_log("\tsymlink to %s", ap->a_symlink); |
649 } else { 650 ap->a_volname = strdup(ap->a_name); | 649 } else { 650 ap->a_volname = strdup(ap->a_name); |
651 log("\timplicit automount from %s", ap->a_volname); | 651 fsi_log("\timplicit automount from %s", ap->a_volname); |
652 analyze_automount(ap); 653 } 654 } 655} 656 657 658void 659analyze_automounts(qelem *q) 660{ 661 auto_tree *tp; 662 663 show_area_being_processed("analyze automount", 5); 664 665 /* 666 * q is a list of automounts 667 */ 668 ITER(tp, auto_tree, q) 669 analyze_automount_tree(tp->t_mount, "", 0); 670} | 652 analyze_automount(ap); 653 } 654 } 655} 656 657 658void 659analyze_automounts(qelem *q) 660{ 661 auto_tree *tp; 662 663 show_area_being_processed("analyze automount", 5); 664 665 /* 666 * q is a list of automounts 667 */ 668 ITER(tp, auto_tree, q) 669 analyze_automount_tree(tp->t_mount, "", 0); 670} |