4 * Copyright (c) 1997-2009 Erez Zadok
5 * Copyright (c) 1989 Jan-Simon Pendry
6 * Copyright (c) 1989 Imperial College of Science, Technology & Medicine
7 * Copyright (c) 1989 The Regents of the University of California.
10 * This code is derived from software contributed to Berkeley by
11 * Jan-Simon Pendry at Imperial College, London.
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
16 * 1. Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution.
21 * 3. All advertising materials mentioning features or use of this software
22 * must display the following acknowledgment:
23 * This product includes software developed by the University of
24 * California, Berkeley and its contributors.
25 * 4. Neither the name of the University nor the names of its contributors
26 * may be used to endorse or promote products derived from this software
27 * without specific prior written permission.
29 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
30 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
31 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
32 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
33 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
34 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
35 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
36 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
37 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
38 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
42 * File: am-utils/fsinfo/fsinfo.c
52 #endif /* HAVE_CONFIG_H */
62 char hostname
[MAXHOSTNAMELEN
+ 1];
66 dict
*dict_of_volnames
;
71 qelem
*list_of_automounts
;
75 * Output file prefixes
77 char *bootparams_pref
;
85 * Argument cracking...
88 fsi_get_args(int c
, char *v
[])
95 * Determine program name
98 progname
= strrchr(v
[0], '/');
99 if (progname
&& progname
[1])
108 while ((ch
= getopt(c
, v
, "a:b:d:e:f:h:m:D:U:I:qv")) != -1)
118 fatal("-b option specified twice");
119 bootparams_pref
= optarg
;
124 fatal("-d option specified twice");
125 dumpset_pref
= optarg
;
129 xstrlcpy(hostname
, optarg
, sizeof(hostname
));
134 fatal("-e option specified twice");
135 exportfs_pref
= optarg
;
140 fatal("-f option specified twice");
146 fatal("-m option specified twice");
161 /* sizeof(iptr) is actually that of idvbuf. See declaration above */
162 xsnprintf(iptr
, sizeof(idvbuf
), "-%c%s ", ch
, optarg
);
163 iptr
+= strlen(iptr
);
172 g_argv
= v
+ optind
- 1;
176 fatal("Cannot read any input files");
184 Usage: %s [-v] [-a autodir] [-h hostname] [-b bootparams] [-d dumpsets]\n\
185 \t[-e exports] [-f fstabs] [-m automounts]\n\
186 \t[-I dir] [-D|-U string[=string]] config ...\n", progname
);
191 fsi_log("g_argv[0] = %s", g_argv
[0]);
193 fsi_log("g_argv[0] = (nil)");
198 * Determine username of caller
203 const char *u
= getlogin();
206 struct passwd
*pw
= getpwuid(getuid());
214 u
= getenv("LOGNAME");
226 main(int argc
, char *argv
[])
231 fsi_get_args(argc
, argv
);
234 * If no hostname given then use the local name
236 if (!*hostname
&& gethostname(hostname
, sizeof(hostname
)) < 0) {
237 perror("gethostname");
240 hostname
[sizeof(hostname
) - 1] = '\0';
245 username
= find_username();
248 * New hosts and automounts
250 list_of_hosts
= new_que();
251 list_of_automounts
= new_que();
256 dict_of_volnames
= new_dict();
257 dict_of_hosts
= new_dict();
262 show_area_being_processed("read config", 11);
265 errors
+= file_io_errors
+ parse_errors
;
269 * Do semantic analysis of input
271 analyze_hosts(list_of_hosts
);
272 analyze_automounts(list_of_automounts
);
283 write_atab(list_of_automounts
);
284 write_bootparams(list_of_hosts
);
285 write_dumpset(list_of_hosts
);
286 write_exportfs(list_of_hosts
);
287 write_fstab(list_of_hosts
);
292 return errors
; /* should never reach here */