147488Spendry /* 247488Spendry * $Id: wr_bparam.c,v 5.2.1.2 90/12/21 16:46:49 jsp Alpha $ 347488Spendry * 447488Spendry * Copyright (c) 1989 Jan-Simon Pendry 547488Spendry * Copyright (c) 1989 Imperial College of Science, Technology & Medicine 647488Spendry * Copyright (c) 1989 The Regents of the University of California. 747488Spendry * All rights reserved. 847488Spendry * 947488Spendry * This code is derived from software contributed to Berkeley by 1047488Spendry * Jan-Simon Pendry at Imperial College, London. 1147488Spendry * 12*47530Spendry * %sccs.include.redist.c% 1347488Spendry * 14*47530Spendry * @(#)wr_bparam.c 5.2 (Berkeley) 03/17/91 1547488Spendry */ 1647488Spendry 1747488Spendry #include "../fsinfo/fsinfo.h" 1847488Spendry 1947488Spendry /* 2047488Spendry * Write a host/path in NFS format 2147488Spendry */ 2247488Spendry static int write_nfsname(ef, fp, hn) 2347488Spendry FILE *ef; 2447488Spendry fsmount *fp; 2547488Spendry char *hn; 2647488Spendry { 2747488Spendry int errors = 0; 2847488Spendry char *h = strdup(fp->f_ref->m_dk->d_host->h_hostname); 2947488Spendry domain_strip(h, hn); 3047488Spendry fprintf(ef, "%s:%s", h, fp->f_volname); 3147488Spendry free(h); 3247488Spendry return errors; 3347488Spendry } 3447488Spendry 3547488Spendry /* 3647488Spendry * Write a bootparams entry for a host 3747488Spendry */ 3847488Spendry static int write_boot_info(ef, hp) 3947488Spendry FILE *ef; 4047488Spendry host *hp; 4147488Spendry { 4247488Spendry int errors = 0; 4347488Spendry fprintf(ef, "%s\troot=", hp->h_hostname); 4447488Spendry errors += write_nfsname(ef, hp->h_netroot, hp->h_hostname); 4547488Spendry fputs(" swap=", ef); 4647488Spendry errors += write_nfsname(ef, hp->h_netswap, hp->h_hostname); 4747488Spendry fputs("\n", ef); 4847488Spendry 4947488Spendry return 0; 5047488Spendry } 5147488Spendry 5247488Spendry /* 5347488Spendry * Output a bootparams file 5447488Spendry */ 5547488Spendry int write_bootparams(q) 5647488Spendry qelem *q; 5747488Spendry { 5847488Spendry int errors = 0; 5947488Spendry 6047488Spendry if (bootparams_pref) { 6147488Spendry FILE *ef = pref_open(bootparams_pref, "bootparams", info_hdr, "bootparams"); 6247488Spendry if (ef) { 6347488Spendry host *hp; 6447488Spendry ITER(hp, host, q) 6547488Spendry if (hp->h_netroot && hp->h_netswap) 6647488Spendry errors += write_boot_info(ef, hp); 6747488Spendry errors += pref_close(ef); 6847488Spendry } else { 6947488Spendry errors++; 7047488Spendry } 7147488Spendry } 7247488Spendry 7347488Spendry return errors; 7447488Spendry } 75