1 /* 2 * $Id: wr_bparam.c,v 5.2.1.2 90/12/21 16:46:49 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 * @(#)wr_bparam.c 5.2 (Berkeley) 03/17/91 15 */ 16 17 #include "../fsinfo/fsinfo.h" 18 19 /* 20 * Write a host/path in NFS format 21 */ 22 static int write_nfsname(ef, fp, hn) 23 FILE *ef; 24 fsmount *fp; 25 char *hn; 26 { 27 int errors = 0; 28 char *h = strdup(fp->f_ref->m_dk->d_host->h_hostname); 29 domain_strip(h, hn); 30 fprintf(ef, "%s:%s", h, fp->f_volname); 31 free(h); 32 return errors; 33 } 34 35 /* 36 * Write a bootparams entry for a host 37 */ 38 static int write_boot_info(ef, hp) 39 FILE *ef; 40 host *hp; 41 { 42 int errors = 0; 43 fprintf(ef, "%s\troot=", hp->h_hostname); 44 errors += write_nfsname(ef, hp->h_netroot, hp->h_hostname); 45 fputs(" swap=", ef); 46 errors += write_nfsname(ef, hp->h_netswap, hp->h_hostname); 47 fputs("\n", ef); 48 49 return 0; 50 } 51 52 /* 53 * Output a bootparams file 54 */ 55 int write_bootparams(q) 56 qelem *q; 57 { 58 int errors = 0; 59 60 if (bootparams_pref) { 61 FILE *ef = pref_open(bootparams_pref, "bootparams", info_hdr, "bootparams"); 62 if (ef) { 63 host *hp; 64 ITER(hp, host, q) 65 if (hp->h_netroot && hp->h_netswap) 66 errors += write_boot_info(ef, hp); 67 errors += pref_close(ef); 68 } else { 69 errors++; 70 } 71 } 72 73 return errors; 74 } 75