summaryrefslogtreecommitdiffstats
path: root/sbin/camcontrol
diff options
context:
space:
mode:
authorken <ken@FreeBSD.org>2005-03-26 05:34:54 +0000
committerken <ken@FreeBSD.org>2005-03-26 05:34:54 +0000
commita856c3c2dfa2f5002877592007990d980e989d5a (patch)
tree5b853754c28e5311875a9c0b0259ffa1aba2e54d /sbin/camcontrol
parenta59a08fc46cdc92dca6428a64996cff6677507df (diff)
downloadFreeBSD-src-a856c3c2dfa2f5002877592007990d980e989d5a.zip
FreeBSD-src-a856c3c2dfa2f5002877592007990d980e989d5a.tar.gz
Add "report only" functionality to 'camcontrol format', so users can get a
report on the status of a format already running on a drive. Fix status reporting for 'camcontrol format'. This was broken in rev 1.34 of camcontrol.c, almost 4 years ago! Submitted by: joerg (most of the reportonly changes) MFC after: 3 days
Diffstat (limited to 'sbin/camcontrol')
-rw-r--r--sbin/camcontrol/camcontrol.88
-rw-r--r--sbin/camcontrol/camcontrol.c17
2 files changed, 20 insertions, 5 deletions
diff --git a/sbin/camcontrol/camcontrol.8 b/sbin/camcontrol/camcontrol.8
index abd30e0..aad34e1 100644
--- a/sbin/camcontrol/camcontrol.8
+++ b/sbin/camcontrol/camcontrol.8
@@ -1,5 +1,5 @@
.\"
-.\" Copyright (c) 1998, 1999, 2000, 2002 Kenneth D. Merry.
+.\" Copyright (c) 1998, 1999, 2000, 2002, 2005 Kenneth D. Merry.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
@@ -138,6 +138,7 @@
.Op device id
.Op generic args
.Op Fl q
+.Op Fl r
.Op Fl w
.Op Fl y
.Nm
@@ -675,6 +676,11 @@ the questions, however.
To disable questions, use the
.Fl y
argument, below.
+.It Fl r
+Run in
+.Dq report only
+mode.
+This will report status on a format that is already running on the drive.
.It Fl w
Issue a non-immediate format command.
By default,
diff --git a/sbin/camcontrol/camcontrol.c b/sbin/camcontrol/camcontrol.c
index acf9ae1..a8447ee 100644
--- a/sbin/camcontrol/camcontrol.c
+++ b/sbin/camcontrol/camcontrol.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 1998, 1999, 2000, 2001, 2002 Kenneth D. Merry
+ * Copyright (c) 1997, 1998, 1999, 2000, 2001, 2002, 2005 Kenneth D. Merry
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -144,7 +144,7 @@ struct camcontrol_opts option_table[] = {
{"negotiate", CAM_CMD_RATE, CAM_ARG_NONE, negotiate_opts},
{"rate", CAM_CMD_RATE, CAM_ARG_NONE, negotiate_opts},
{"debug", CAM_CMD_DEBUG, CAM_ARG_NONE, "IPTSXc"},
- {"format", CAM_CMD_FORMAT, CAM_ARG_NONE, "qwy"},
+ {"format", CAM_CMD_FORMAT, CAM_ARG_NONE, "qrwy"},
#endif /* MINIMALISTIC */
{"help", CAM_CMD_USAGE, CAM_ARG_NONE, NULL},
{"-?", CAM_CMD_USAGE, CAM_ARG_NONE, NULL},
@@ -2857,6 +2857,7 @@ scsiformat(struct cam_device *device, int argc, char **argv,
u_int32_t dxfer_len = 0;
u_int8_t byte2 = 0;
int num_warnings = 0;
+ int reportonly = 0;
ccb = cam_getccb(device);
@@ -2873,6 +2874,9 @@ scsiformat(struct cam_device *device, int argc, char **argv,
case 'q':
quiet++;
break;
+ case 'r':
+ reportonly = 1;
+ break;
case 'w':
immediate = 0;
break;
@@ -2882,6 +2886,9 @@ scsiformat(struct cam_device *device, int argc, char **argv,
}
}
+ if (reportonly)
+ goto doreport;
+
if (quiet == 0) {
fprintf(stdout, "You are about to REMOVE ALL DATA from the "
"following device:\n");
@@ -3024,6 +3031,7 @@ scsiformat(struct cam_device *device, int argc, char **argv,
goto scsiformat_bailout;
}
+doreport:
do {
cam_status status;
@@ -3065,7 +3073,7 @@ scsiformat(struct cam_device *device, int argc, char **argv,
if ((status != CAM_REQ_CMP)
&& (status == CAM_SCSI_STATUS_ERROR)
- && ((status & CAM_AUTOSNS_VALID) != 0)) {
+ && ((ccb->ccb_h.status & CAM_AUTOSNS_VALID) != 0)) {
struct scsi_sense_data *sense;
int error_code, sense_key, asc, ascq;
@@ -3176,7 +3184,7 @@ usage(int verbose)
" [-D <enable|disable>][-O offset][-q]\n"
" [-R syncrate][-v][-T <enable|disable>]\n"
" [-U][-W bus_width]\n"
-" camcontrol format [dev_id][generic args][-q][-w][-y]\n"
+" camcontrol format [dev_id][generic args][-q][-r][-w][-y]\n"
#endif /* MINIMALISTIC */
" camcontrol help\n");
if (!verbose)
@@ -3254,6 +3262,7 @@ usage(int verbose)
"-v also print a Path Inquiry CCB for the controller\n"
"format arguments:\n"
"-q be quiet, don't print status messages\n"
+"-r run in report only mode\n"
"-w don't send immediate format command\n"
"-y don't ask any questions\n");
#endif /* MINIMALISTIC */
OpenPOWER on IntegriCloud