Commit | Line | Data |
---|---|---|
caa65da1 | 1 | /* |
caa65da1 JSP |
2 | * Copyright (c) 1989 Jan-Simon Pendry |
3 | * Copyright (c) 1989 Imperial College of Science, Technology & Medicine | |
4 | * Copyright (c) 1989 The Regents of the University of California. | |
5 | * All rights reserved. | |
6 | * | |
7 | * This code is derived from software contributed to Berkeley by | |
8 | * Jan-Simon Pendry at Imperial College, London. | |
9 | * | |
2f619045 | 10 | * %sccs.include.redist.c% |
caa65da1 | 11 | * |
332f0791 | 12 | * @(#)wr_bparam.c 5.4 (Berkeley) %G% |
8d2991d5 | 13 | * |
332f0791 | 14 | * $Id: wr_bparam.c,v 5.2.2.1 1992/02/09 15:09:46 jsp beta $ |
8d2991d5 | 15 | * |
caa65da1 JSP |
16 | */ |
17 | ||
18 | #include "../fsinfo/fsinfo.h" | |
19 | ||
20 | /* | |
21 | * Write a host/path in NFS format | |
22 | */ | |
23 | static int write_nfsname(ef, fp, hn) | |
24 | FILE *ef; | |
25 | fsmount *fp; | |
26 | char *hn; | |
27 | { | |
28 | int errors = 0; | |
29 | char *h = strdup(fp->f_ref->m_dk->d_host->h_hostname); | |
30 | domain_strip(h, hn); | |
31 | fprintf(ef, "%s:%s", h, fp->f_volname); | |
32 | free(h); | |
33 | return errors; | |
34 | } | |
35 | ||
36 | /* | |
37 | * Write a bootparams entry for a host | |
38 | */ | |
39 | static int write_boot_info(ef, hp) | |
40 | FILE *ef; | |
41 | host *hp; | |
42 | { | |
43 | int errors = 0; | |
44 | fprintf(ef, "%s\troot=", hp->h_hostname); | |
45 | errors += write_nfsname(ef, hp->h_netroot, hp->h_hostname); | |
46 | fputs(" swap=", ef); | |
47 | errors += write_nfsname(ef, hp->h_netswap, hp->h_hostname); | |
48 | fputs("\n", ef); | |
49 | ||
50 | return 0; | |
51 | } | |
52 | ||
53 | /* | |
54 | * Output a bootparams file | |
55 | */ | |
56 | int write_bootparams(q) | |
57 | qelem *q; | |
58 | { | |
59 | int errors = 0; | |
60 | ||
61 | if (bootparams_pref) { | |
62 | FILE *ef = pref_open(bootparams_pref, "bootparams", info_hdr, "bootparams"); | |
63 | if (ef) { | |
64 | host *hp; | |
65 | ITER(hp, host, q) | |
66 | if (hp->h_netroot && hp->h_netswap) | |
67 | errors += write_boot_info(ef, hp); | |
68 | errors += pref_close(ef); | |
69 | } else { | |
70 | errors++; | |
71 | } | |
72 | } | |
73 | ||
74 | return errors; | |
75 | } |