Add a "-s" argument to specify the command timeout in seconds.

Now you should be able to format a disk with something like:
> scsi -f /dev/rsd?c -s 1200 -c "4 0 0 0 0 0"
assuming sd.c lets you open it.
This commit is contained in:
dufault 1995-05-01 12:35:05 +00:00
parent 6182b2e159
commit adef302b24
2 changed files with 23 additions and 12 deletions

View File

@ -39,10 +39,10 @@
.\" SUCH DAMAGE.
.\"
.\"
.\" $Id: scsi.8,v 1.2 1995/04/17 14:51:54 dufault Exp $
.\" $Id: scsi.8,v 1.3 1995/04/28 19:24:38 dufault Exp $
.\"
.Dd October 11, 1993
.Dt SCSI 1
.Dt SCSI 8
.Os BSD 4
.Sh NAME
.Nm scsi
@ -55,9 +55,9 @@ scsi -f device [-v] -z seconds # To freeze bus
scsi -f device -m page [-P pc] # To read mode pages
scsi -f device -p [-b bus] [-l lun] # To probe all devices
scsi -f device -r [-b bus] [-t targ] [-l lun] # To reprobe a device
scsi -f device [-v] -c cmd_fmt [arg0 ... argn] \\ # To send a command...
scsi -f device [-v] [-s seconds] -c cmd_fmt [arg0 ... argn] # A command...
-o count out_fmt [arg0 ... argn] # EITHER (for data out)
-i count in_fmt # OR (for data in)
-i count in_fmt # OR (for data in)
.Pp
"out_fmt" can be "-" to read output data from stdin;
"in_fmt" can be "-" to write input data to stdout;
@ -147,6 +147,9 @@ using the format arguments.
.Fr -v
turns on more verbose information.
.Pp
.Fr -s
sets the command timeout in seconds. The default is two seconds.
.Pp
.Fr "-c cmd_fmt"
specifies the command as described in
.Xr scsi 3 "."
@ -165,7 +168,6 @@ can be specified as a hyphen ("-") to indicate that the
.Fr count
bytes of data should be read from the standard input.
.Pp
.Fr "-o count out_fmt arg0 ... argn"
.Fr "-i count in_fmt"
indicates that this is a data in command (i.e., data will be read from
the device into the system) with

View File

@ -39,7 +39,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: scsi.c,v 1.3 1995/04/17 14:35:07 dufault Exp $
* $Id: scsi.c,v 1.4 1995/04/28 19:24:39 dufault Exp $
*/
#include <stdio.h>
@ -68,6 +68,7 @@ int modeflag;
int editflag;
int modepage = 0; /* Read this mode page */
int pagectl = 0; /* Mode sense page control */
int seconds = 2;
void usage(void)
{
@ -80,9 +81,9 @@ void usage(void)
" scsi -f device -m page [-P pc] # To read mode pages\n"
" scsi -f device -p [-b bus] [-l lun] # To probe all devices\n"
" scsi -f device -r [-b bus] [-t targ] [-l lun] # To reprobe a device\n"
" scsi -f device [-v] -c cmd_fmt [arg0 ... argn] \\ # To send a command...\n"
" -o count out_fmt [arg0 ... argn] # EITHER (for data out)\n"
" -i count in_fmt # OR (for data in)\n"
" scsi -f device [-v] [-s seconds] -c cmd_fmt [arg0 ... argn] # A command...\n"
" -o count out_fmt [arg0 ... argn] # EITHER (data out)\n"
" -i count in_fmt # OR (data in)\n"
"\n"
"\"out_fmt\" can be \"-\" to read output data from stdin;\n"
"\"in_fmt\" can be \"-\" to write input data to stdout;\n"
@ -106,7 +107,7 @@ void procargs(int *argc_p, char ***argv_p)
fflag = 0;
commandflag = 0;
debugflag = 0;
while ((ch = getopt(argc, argv, "ceprvf:d:b:t:l:z:m:P:")) != EOF) {
while ((ch = getopt(argc, argv, "ceprvf:d:b:t:l:z:m:P:s:")) != EOF) {
switch (ch) {
case 'p':
probe_all = 1;
@ -151,6 +152,9 @@ void procargs(int *argc_p, char ***argv_p)
case 'P':
pagectl = strtol(optarg, 0, 0);
break;
case 's':
seconds = strtol(optarg, 0, 0);
break;
case 'm':
modeflag = 1;
modepage = strtol(optarg, 0, 0);
@ -270,7 +274,8 @@ enum data_phase {none = 0, in, out};
/* do_cmd: Send a command to a SCSI device
*/
void do_cmd(int fd, char *fmt, int argc, char **argv)
static void
do_cmd(int fd, char *fmt, int argc, char **argv)
{
struct get_hook h;
scsireq_t *scsireq = scsireq_new();
@ -344,6 +349,9 @@ void do_cmd(int fd, char *fmt, int argc, char **argv)
}
}
scsireq->timeout = seconds * 1000;
if (scsireq_enter(fd, scsireq) == -1)
{
scsi_debug(stderr, -1, scsireq);
@ -371,7 +379,8 @@ void do_cmd(int fd, char *fmt, int argc, char **argv)
}
}
static void freeze_ioctl(int fd, int op, void *data)
static void
freeze_ioctl(int fd, int op, void *data)
{
if (ioctl(fd, SCIOCFREEZE, 0) == -1) {
if (errno == ENODEV) {