1 /*
2  * $Id: wr_exportfs.c,v 5.2.1.2 90/12/21 16:46:51 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_exportfs.c	5.2 (Berkeley) 03/17/91
15  */
16 
17 #include "../fsinfo/fsinfo.h"
18 
19 static int write_export_info(ef, q, errors)
20 FILE *ef;
21 qelem *q;
22 int errors;
23 {
24 	mount *mp;
25 
26 	ITER(mp, mount, q) {
27 		if (mp->m_mask & (1<<DM_EXPORTFS))
28 			fprintf(ef, "%s\t%s\n", mp->m_volname, mp->m_exportfs);
29 		if (mp->m_mount)
30 			errors += write_export_info(ef, mp->m_mount, 0);
31 	}
32 
33 	return errors;
34 }
35 
36 static int write_dkexports(ef, q)
37 FILE *ef;
38 qelem *q;
39 {
40 	int errors = 0;
41 	disk_fs *dp;
42 
43 	ITER(dp, disk_fs, q) {
44 		if (dp->d_mount)
45 			errors += write_export_info(ef, dp->d_mount, 0);
46 	}
47 	return errors;
48 }
49 
50 int write_exportfs(q)
51 qelem *q;
52 {
53 	int errors = 0;
54 
55 	if (exportfs_pref) {
56 		host *hp;
57 		show_area_being_processed("write exportfs", "");
58 		ITER(hp, host, q) {
59 			if (hp->h_disk_fs) {
60 				FILE *ef = pref_open(exportfs_pref, hp->h_hostname, gen_hdr, hp->h_hostname);
61 				if (ef) {
62 					show_new(hp->h_hostname);
63 					errors += write_dkexports(ef, hp->h_disk_fs);
64 					errors += pref_close(ef);
65 				} else {
66 					errors++;
67 				}
68 			}
69 		}
70 	}
71 
72 	return errors;
73 }
74