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