1 /*
2  * Copyright (c) 1989 Jan-Simon Pendry
3  * Copyright (c) 1989 Imperial College of Science, Technology & Medicine
4  * Copyright (c) 1989, 1993
5  *	The Regents of the University of California.  All rights reserved.
6  *
7  * This code is derived from software contributed to Berkeley by
8  * Jan-Simon Pendry at Imperial College, London.
9  *
10  * %sccs.include.redist.c%
11  *
12  *	@(#)wr_exportfs.c	8.1 (Berkeley) 06/06/93
13  *
14  * $Id: wr_exportfs.c,v 5.2.2.1 1992/02/09 15:09:48 jsp beta $
15  *
16  */
17 
18 #include "../fsinfo/fsinfo.h"
19 
20 static int write_export_info(ef, q, errors)
21 FILE *ef;
22 qelem *q;
23 int errors;
24 {
25 	mount *mp;
26 
27 	ITER(mp, mount, q) {
28 		if (mp->m_mask & (1<<DM_EXPORTFS))
29 			fprintf(ef, "%s\t%s\n", mp->m_volname, mp->m_exportfs);
30 		if (mp->m_mount)
31 			errors += write_export_info(ef, mp->m_mount, 0);
32 	}
33 
34 	return errors;
35 }
36 
37 static int write_dkexports(ef, q)
38 FILE *ef;
39 qelem *q;
40 {
41 	int errors = 0;
42 	disk_fs *dp;
43 
44 	ITER(dp, disk_fs, q) {
45 		if (dp->d_mount)
46 			errors += write_export_info(ef, dp->d_mount, 0);
47 	}
48 	return errors;
49 }
50 
51 int write_exportfs(q)
52 qelem *q;
53 {
54 	int errors = 0;
55 
56 	if (exportfs_pref) {
57 		host *hp;
58 		show_area_being_processed("write exportfs", "");
59 		ITER(hp, host, q) {
60 			if (hp->h_disk_fs) {
61 				FILE *ef = pref_open(exportfs_pref, hp->h_hostname, gen_hdr, hp->h_hostname);
62 				if (ef) {
63 					show_new(hp->h_hostname);
64 					errors += write_dkexports(ef, hp->h_disk_fs);
65 					errors += pref_close(ef);
66 				} else {
67 					errors++;
68 				}
69 			}
70 		}
71 	}
72 
73 	return errors;
74 }
75