summaryrefslogtreecommitdiffstats
path: root/usr.sbin/amd/fsinfo
diff options
context:
space:
mode:
authorcharnier <charnier@FreeBSD.org>1997-09-02 06:35:27 +0000
committercharnier <charnier@FreeBSD.org>1997-09-02 06:35:27 +0000
commite462c7e2d2b251f784226c19805bfb673f8250a5 (patch)
tree516d925e6e6954d049528f216533db733b9541b8 /usr.sbin/amd/fsinfo
parentcf23c9d2384fe8bac2270ab9b1c78fff96188fb8 (diff)
downloadFreeBSD-src-e462c7e2d2b251f784226c19805bfb673f8250a5.zip
FreeBSD-src-e462c7e2d2b251f784226c19805bfb673f8250a5.tar.gz
Add usage(), use err(3), remove `progname'.
Diffstat (limited to 'usr.sbin/amd/fsinfo')
-rw-r--r--usr.sbin/amd/fsinfo/fsi_util.c23
-rw-r--r--usr.sbin/amd/fsinfo/fsinfo.c68
-rw-r--r--usr.sbin/amd/fsinfo/fsinfo.h3
3 files changed, 44 insertions, 50 deletions
diff --git a/usr.sbin/amd/fsinfo/fsi_util.c b/usr.sbin/amd/fsinfo/fsi_util.c
index 0dd4fcc..b62b9b9 100644
--- a/usr.sbin/amd/fsinfo/fsi_util.c
+++ b/usr.sbin/amd/fsinfo/fsi_util.c
@@ -31,13 +31,16 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * @(#)fsi_util.c 8.1 (Berkeley) 6/6/93
- *
- * $Id$
- *
*/
+#ifndef lint
+#if 0
+static char sccsid[] = "@(#)fsi_util.c 8.1 (Berkeley) 6/6/93";
+#endif
+static const char rcsid[] =
+ "$Id$";
+#endif
+
#include "../fsinfo/fsinfo.h"
/*
@@ -47,7 +50,7 @@ void error(s, s1, s2, s3, s4)
char *s, *s1, *s2, *s3, *s4;
{
col_cleanup(0);
- fprintf(stderr, "%s: Error, ", progname);
+ fprintf(stderr, "fsinfo: error, ");
fprintf(stderr, s, s1, s2, s3, s4);
fputc('\n', stderr);
errors++;
@@ -79,7 +82,7 @@ void fatal(s, s1, s2, s3, s4)
char *s, *s1, *s2, *s3, *s4;
{
col_cleanup(1);
- fprintf(stderr, "%s: Fatal, ", progname);
+ fprintf(stderr, "fsinfo: fatal, ");
fprintf(stderr, s, s1, s2, s3, s4);
fputc('\n', stderr);
exit(1);
@@ -108,7 +111,7 @@ char *s, *s1, *s2, *s3, *s4;
{
if (verbose > 0) {
fputc('#', stdout);
- fprintf(stdout, "%s: ", progname);
+ fprintf(stdout, "fsinfo: ");
fprintf(stdout, s, s1, s2, s3, s4);
putc('\n', stdout);
}
@@ -137,10 +140,10 @@ FILE *fp;
fprintf(fp,
"\
# *** This file was automatically generated -- DO NOT EDIT HERE ***\n\
-# \"%s\" run by %s@%s on %s\
+# \"fsinfo\" run by %s@%s on %s\
#\n\
",
- progname, username, hostname, cp);
+ username, hostname, cp);
}
static int show_range = 10;
diff --git a/usr.sbin/amd/fsinfo/fsinfo.c b/usr.sbin/amd/fsinfo/fsinfo.c
index dcc6982..0fcb5b2 100644
--- a/usr.sbin/amd/fsinfo/fsinfo.c
+++ b/usr.sbin/amd/fsinfo/fsinfo.c
@@ -34,26 +34,31 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * @(#)fsinfo.c 8.1 (Berkeley) 6/6/93
- *
- * $Id: fsinfo.c,v 1.3 1997/02/22 16:03:20 peter Exp $
- *
*/
#ifndef lint
-static char copyright[] =
+static const char copyright[] =
"@(#) Copyright (c) 1989, 1993\n\
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
+#ifndef lint
+#if 0
+static char sccsid[] = "@(#)fsinfo.c 8.1 (Berkeley) 6/6/93";
+#endif
+static const char rcsid[] =
+ "$Id$";
+#endif /* not lint */
+
/*
* fsinfo
*/
#include "../fsinfo/fsinfo.h"
#include "fsi_gram.h"
+#include <err.h>
#include <pwd.h>
+#include <unistd.h>
qelem *list_of_hosts;
qelem *list_of_automounts;
@@ -69,7 +74,8 @@ int verbose;
char idvbuf[1024];
char **g_argv;
-char *progname;
+
+static void usage __P((void));
/*
* Output file prefixes
@@ -87,25 +93,10 @@ static void get_args(c, v)
int c;
char *v[];
{
- extern char *optarg;
- extern int optind;
int ch;
- int usage = 0;
+ int usageflg = 0;
char *iptr = idvbuf;
- /*
- * Determine program name
- */
- if (v[0]) {
- progname = strrchr(v[0], '/');
- if (progname && progname[1])
- progname++;
- else
- progname = v[0];
- }
- if (!progname)
- progname = "fsinfo";
-
while ((ch = getopt(c, v, "a:b:d:e:f:h:m:D:U:I:qv")) != -1)
switch (ch) {
case 'a':
@@ -150,7 +141,7 @@ char *v[];
iptr += strlen(iptr);
break;
default:
- usage++;
+ usageflg++;
break;
}
@@ -159,18 +150,11 @@ char *v[];
if (yywrap())
fatal("Cannot read any input files");
} else {
- usage++;
- }
-
- if (usage) {
- fprintf(stderr,
-"\
-Usage: %s [-v] [-a autodir] [-h hostname] [-b bootparams] [-d dumpsets]\n\
-\t[-e exports] [-f fstabs] [-m automounts]\n\
-\t[-I dir] [-D|-U string[=string]] config ...\n", progname);
- exit(1);
+ usageflg++;
}
+ if (usageflg)
+ usage();
if (g_argv[0])
log("g_argv[0] = %s", g_argv[0]);
@@ -178,6 +162,16 @@ Usage: %s [-v] [-a autodir] [-h hostname] [-b bootparams] [-d dumpsets]\n\
log("g_argv[0] = (nil)");
}
+static void
+usage()
+{
+ fprintf(stderr, "%s\n%s\n%s\n",
+"usage: fsinfo [-v] [-a autodir] [-h hostname] [-b bootparams] [-d dumpsets]",
+" [-e exports] [-f fstabs] [-m automounts]",
+" [-I dir] [-D|-U string[=string]] config ...");
+ exit(1);
+}
+
/*
* Determine username of caller
*/
@@ -216,10 +210,8 @@ char *argv[];
/*
* If no hostname given then use the local name
*/
- if (!*hostname && gethostname(hostname, sizeof(hostname)) < 0) {
- perror("gethostname");
- exit(1);
- }
+ if (!*hostname && gethostname(hostname, sizeof(hostname)) < 0)
+ err(1, "gethostname");
/*
* Get the username
diff --git a/usr.sbin/amd/fsinfo/fsinfo.h b/usr.sbin/amd/fsinfo/fsinfo.h
index 8d979a5..e74ea73 100644
--- a/usr.sbin/amd/fsinfo/fsinfo.h
+++ b/usr.sbin/amd/fsinfo/fsinfo.h
@@ -37,7 +37,7 @@
*
* @(#)fsinfo.h 8.1 (Berkeley) 6/6/93
*
- * $Id$
+ * $Id: fsinfo.h,v 1.5 1997/02/22 16:03:21 peter Exp $
*
*/
@@ -126,7 +126,6 @@ extern char *fsmount_strings[];
extern char *host_strings[];
extern char *ether_if_strings[];
extern char *autodir;
-extern char *progname;
extern char hostname[];
extern char *username;
extern char **g_argv;
OpenPOWER on IntegriCloud