Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sbin/scsictl Collect all little usage-messages spread around...
details: https://anonhg.NetBSD.org/src/rev/84bbdfa297b3
branches: trunk
changeset: 475041:84bbdfa297b3
user: hubertf <hubertf%NetBSD.org@localhost>
date: Fri Jul 30 02:29:04 1999 +0000
description:
Collect all little usage-messages spread around into one place,
and as a side effect, print the available commands (and their
usage) if no command is given on the command line.
Approved by Jason Thorpe.
diffstat:
sbin/scsictl/scsictl.8 | 8 ++++-
sbin/scsictl/scsictl.c | 74 ++++++++++++++++++++-----------------------------
2 files changed, 38 insertions(+), 44 deletions(-)
diffs (231 lines):
diff -r 1004bd687df1 -r 84bbdfa297b3 sbin/scsictl/scsictl.8
--- a/sbin/scsictl/scsictl.8 Fri Jul 30 02:23:27 1999 +0000
+++ b/sbin/scsictl/scsictl.8 Fri Jul 30 02:29:04 1999 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: scsictl.8,v 1.2 1998/10/15 21:51:23 thorpej Exp $
+.\" $NetBSD: scsictl.8,v 1.3 1999/07/30 02:29:04 hubertf Exp $
.\"
.\" Copyright (c) 1998 The NetBSD Foundation, Inc.
.\" All rights reserved.
@@ -68,6 +68,10 @@
.Sh DEVICE COMMANDS
The following commands are supported for SCSI devices:
.Pp
+.Nm format
+.Pp
+(Low level) format the named revice.
+.Pp
.Nm identify
.Pp
Identify the specified device, displaying the device's SCSI
@@ -114,6 +118,8 @@
arguments specify which SCSI target and lun on the bus is to be scanned.
Either may be wildcarded by specifying
.Dq any .
+.Sh FILES
+/dev/scsibus* - for commands operating on SCSI busses
.Sh SEE ALSO
.Xr ioctl 2 ,
.Xr cd 4 ,
diff -r 1004bd687df1 -r 84bbdfa297b3 sbin/scsictl/scsictl.c
--- a/sbin/scsictl/scsictl.c Fri Jul 30 02:23:27 1999 +0000
+++ b/sbin/scsictl/scsictl.c Fri Jul 30 02:29:04 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: scsictl.c,v 1.5 1999/02/24 18:51:39 jwise Exp $ */
+/* $NetBSD: scsictl.c,v 1.6 1999/07/30 02:29:04 hubertf Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -62,6 +62,7 @@
struct command {
const char *cmd_name;
+ const char *arg_names;
void (*cmd_func) __P((int, char *[]));
};
@@ -72,6 +73,7 @@
const char *dvname; /* device name */
char dvname_store[MAXPATHLEN]; /* for opendisk(3) */
const char *cmdname; /* command user issued */
+const char *argnames; /* helpstring: expected arguments */
struct scsi_addr dvaddr; /* SCSI device's address */
extern const char *__progname; /* from crt0.o */
@@ -82,20 +84,20 @@
void device_reset __P((int, char *[]));
struct command device_commands[] = {
- { "format", device_format },
- { "identify", device_identify },
- { "reassign", device_reassign },
- { "reset", device_reset },
- { NULL, NULL },
+ { "format", " device", device_format },
+ { "identify", " device", device_identify },
+ { "reassign", " device blkno [blkno [...]]", device_reassign },
+ { "reset", " device", device_reset },
+ { NULL, NULL, NULL },
};
void bus_reset __P((int, char *[]));
void bus_scan __P((int, char *[]));
struct command bus_commands[] = {
- { "reset", bus_reset },
- { "scan", bus_scan },
- { NULL, NULL },
+ { "reset", " bus", bus_reset },
+ { "scan", " bus target lun", bus_scan },
+ { NULL, NULL, NULL },
};
int
@@ -156,6 +158,8 @@
errx(1, "unknown %s command: %s\n",
commands == bus_commands ? "bus" : "device", cmdname);
+ argnames = commands[i].arg_names;
+
(*commands[i].cmd_func)(argc, argv);
exit(0);
}
@@ -163,9 +167,20 @@
void
usage()
{
+ int i;
- fprintf(stderr, "usage: %s device command [arg [...]]\n",
+ fprintf(stderr, "Usage: %s device command [arg [...]]\n",
__progname);
+ fprintf(stderr, "Where command (and args) are:\n");
+
+ for (i=0; device_commands[i].cmd_name != NULL; i++)
+ fprintf(stderr, "\t%s%s\n", device_commands[i].cmd_name,
+ device_commands[i].arg_names);
+ for (i=0; bus_commands[i].cmd_name != NULL; i++)
+ fprintf(stderr, "\t%s%s\n", bus_commands[i].cmd_name,
+ bus_commands[i].arg_names);
+ fprintf(stderr, "Use `any' to wildcard target or lun\n");
+
exit(1);
}
@@ -194,7 +209,7 @@
/* No arguments. */
if (argc != 0)
- goto usage;
+ usage();
/*
* Get the DISK FORMAT mode page. SCSI-2 recommends specifying the
@@ -211,10 +226,6 @@
scsi_command(fd, &cmd, sizeof(cmd), NULL, 0, 60000, 0);
return;
-
- usage:
- fprintf(stderr, "usage: %s device %s\n", __progname, cmdname);
- exit(1);
}
/*
@@ -238,7 +249,7 @@
/* No arguments. */
if (argc != 0)
- goto usage;
+ usage();
memset(&cmd, 0, sizeof(cmd));
memset(&inqbuf, 0, sizeof(inqbuf));
@@ -261,10 +272,6 @@
dvaddr.addr.scsi.lun, vendor, product, revision);
return;
-
- usage:
- fprintf(stderr, "usage: %s device %s\n", __progname, cmdname);
- exit(1);
}
/*
@@ -286,7 +293,7 @@
/* We get a list of block numbers. */
if (argc < 1)
- goto usage;
+ usage();
/*
* Allocate the reassign blocks descriptor. The 4 comes from the
@@ -315,11 +322,6 @@
free(data);
return;
-
- usage:
- fprintf(stderr, "usage: %s device %s blkno [blkno [...]]\n",
- __progname, cmdname);
- exit(1);
}
/*
@@ -335,16 +337,12 @@
/* No arguments. */
if (argc != 0)
- goto usage;
+ usage();
if (ioctl(fd, SCIOCRESET, NULL) != 0)
err(1, "SCIOCRESET");
return;
-
- usage:
- fprintf(stderr, "usage: %s device %s\n", __progname, cmdname);
- exit(1);
}
/*
@@ -364,16 +362,12 @@
/* No arguments. */
if (argc != 0)
- goto usage;
+ usage();
if (ioctl(fd, SCBUSIORESET, NULL) != 0)
err(1, "SCBUSIORESET");
return;
-
- usage:
- fprintf(stderr, "usage: %s device %s\n", __progname, cmdname);
- exit(1);
}
/*
@@ -391,7 +385,7 @@
/* Must have two args: target lun */
if (argc != 2)
- goto usage;
+ usage();
if (strcmp(argv[0], "any") == 0)
args.sa_target = -1;
@@ -413,10 +407,4 @@
err(1, "SCBUSIOSCAN");
return;
-
- usage:
- fprintf(stderr, "usage: %s device %s target lun\n", __progname,
- cmdname);
- fprintf(stderr, " use `any' to wildcard target or lun\n");
- exit(1);
}
Home |
Main Index |
Thread Index |
Old Index