2 * Copyright (c) 1997-1999 Erez Zadok
3 * Copyright (c) 1989 Jan-Simon Pendry
4 * Copyright (c) 1989 Imperial College of Science, Technology & Medicine
5 * Copyright (c) 1989 The Regents of the University of California.
8 * This code is derived from software contributed to Berkeley by
9 * Jan-Simon Pendry at Imperial College, London.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. All advertising materials mentioning features or use of this software
20 * must display the following acknowledgment:
21 * This product includes software developed by the University of
22 * California, Berkeley and its contributors.
23 * 4. Neither the name of the University nor the names of its contributors
24 * may be used to endorse or promote products derived from this software
25 * without specific prior written permission.
27 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
28 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
31 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
41 * $Id: fsinfo.c,v 1.4 1999/02/04 07:24:44 ezk Exp $
42 * $FreeBSD: src/contrib/amd/fsinfo/fsinfo.c,v 1.4 1999/09/15 05:45:15 obrien Exp $
43 * $DragonFly: src/contrib/amd/fsinfo/fsinfo.c,v 1.2 2003/06/17 04:23:57 dillon Exp $
53 #endif /* HAVE_CONFIG_H */
63 char hostname
[MAXHOSTNAMELEN
+ 1];
67 dict
*dict_of_volnames
;
72 qelem
*list_of_automounts
;
76 * Output file prefixes
78 char *bootparams_pref
;
86 * Argument cracking...
89 fsi_get_args(int c
, char *v
[])
96 * Determine program name
99 progname
= strrchr(v
[0], '/');
100 if (progname
&& progname
[1])
109 while ((ch
= getopt(c
, v
, "a:b:d:e:f:h:m:D:U:I:qv")) != -1)
119 fatal("-b option specified twice");
120 bootparams_pref
= optarg
;
125 fatal("-d option specified twice");
126 dumpset_pref
= optarg
;
130 strncpy(hostname
, optarg
, sizeof(hostname
) - 1);
135 fatal("-e option specified twice");
136 exportfs_pref
= optarg
;
141 fatal("-f option specified twice");
147 fatal("-m option specified twice");
162 sprintf(iptr
, "-%c%s ", ch
, optarg
);
163 iptr
+= strlen(iptr
);
172 g_argv
= v
+ optind
- 1;
174 fatal("Cannot read any input files");
182 Usage: %s [-v] [-a autodir] [-h hostname] [-b bootparams] [-d dumpsets]\n\
183 \t[-e exports] [-f fstabs] [-m automounts]\n\
184 \t[-I dir] [-D|-U string[=string]] config ...\n", progname
);
189 log("g_argv[0] = %s", g_argv
[0]);
191 log("g_argv[0] = (nil)");
196 * Determine username of caller
201 char *u
= getlogin();
204 struct passwd
*pw
= getpwuid(getuid());
212 u
= getenv("LOGNAME");
224 main(int argc
, char *argv
[])
229 fsi_get_args(argc
, argv
);
232 * If no hostname given then use the local name
234 if (!*hostname
&& gethostname(hostname
, sizeof(hostname
)) < 0) {
235 perror("gethostname");
242 username
= find_username();
245 * New hosts and automounts
247 list_of_hosts
= new_que();
248 list_of_automounts
= new_que();
253 dict_of_volnames
= new_dict();
254 dict_of_hosts
= new_dict();
259 show_area_being_processed("read config", 11);
262 errors
+= file_io_errors
+ parse_errors
;
266 * Do semantic analysis of input
268 analyze_hosts(list_of_hosts
);
269 analyze_automounts(list_of_automounts
);
280 write_atab(list_of_automounts
);
281 write_bootparams(list_of_hosts
);
282 write_dumpset(list_of_hosts
);
283 write_exportfs(list_of_hosts
);
284 write_fstab(list_of_hosts
);
289 return errors
; /* should never reach here */