2 * Copyright (c) 1997-2004 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
40 * $Id: fsinfo.c,v 1.5.2.7 2004/05/12 15:54:31 ezk Exp $
51 #endif /* HAVE_CONFIG_H */
61 char hostname[MAXHOSTNAMELEN + 1];
65 dict *dict_of_volnames;
70 qelem *list_of_automounts;
74 * Output file prefixes
76 char *bootparams_pref;
84 * Argument cracking...
87 fsi_get_args(int c, char *v[])
94 * Determine program name
97 progname = strrchr(v[0], '/');
98 if (progname && progname[1])
107 while ((ch = getopt(c, v, "a:b:d:e:f:h:m:D:U:I:qv")) != -1)
117 fatal("-b option specified twice");
118 bootparams_pref = optarg;
123 fatal("-d option specified twice");
124 dumpset_pref = optarg;
128 strncpy(hostname, optarg, sizeof(hostname) - 1);
133 fatal("-e option specified twice");
134 exportfs_pref = optarg;
139 fatal("-f option specified twice");
145 fatal("-m option specified twice");
160 sprintf(iptr, "-%c%s ", ch, optarg);
161 iptr += strlen(iptr);
170 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 fsi_log("g_argv[0] = %s", g_argv[0]);
191 fsi_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 */