Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 9 Nov 2014 18:13:09 +0000 (UTC)
From:      Bryan Venteicher <bryanv@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r274322 - head/sbin/camcontrol
Message-ID:  <201411091813.sA9ID9li009021@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: bryanv
Date: Sun Nov  9 18:13:08 2014
New Revision: 274322
URL: https://svnweb.freebsd.org/changeset/base/274322

Log:
  Attempt to report a better error if sanitize is not supported
  
  MFC after:	1 month

Modified:
  head/sbin/camcontrol/camcontrol.c

Modified: head/sbin/camcontrol/camcontrol.c
==============================================================================
--- head/sbin/camcontrol/camcontrol.c	Sun Nov  9 17:32:07 2014	(r274321)
+++ head/sbin/camcontrol/camcontrol.c	Sun Nov  9 18:13:08 2014	(r274322)
@@ -5827,15 +5827,31 @@ scsisanitize(struct cam_device *device, 
 	if (arglist & CAM_ARG_ERR_RECOVER)
 		ccb->ccb_h.flags |= CAM_PASS_ERR_RECOVER;
 
-	if (((retval = cam_send_ccb(device, ccb)) < 0)
-	 || ((immediate == 0)
-	   && ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP))) {
-		const char errstr[] = "error sending sanitize command";
+	if (cam_send_ccb(device, ccb) < 0) {
+		warn("error sending sanitize command");
+		error = 1;
+		goto scsisanitize_bailout;
+	}
 
-		if (retval < 0)
-			warn(errstr);
-		else
-			warnx(errstr);
+	if ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) {
+		struct scsi_sense_data *sense;
+		int error_code, sense_key, asc, ascq;
+
+		if ((ccb->ccb_h.status & CAM_STATUS_MASK) ==
+		    CAM_SCSI_STATUS_ERROR) {
+			sense = &ccb->csio.sense_data;
+			scsi_extract_sense_len(sense, ccb->csio.sense_len -
+			    ccb->csio.sense_resid, &error_code, &sense_key,
+			    &asc, &ascq, /*show_errors*/ 1);
+
+			if (sense_key == SSD_KEY_ILLEGAL_REQUEST &&
+			    asc == 0x20 && ascq == 0x00)
+				warnx("sanitize is not supported by "
+				      "this device");
+			else
+				warnx("error sanitizing this device");
+		} else
+			warnx("error sanitizing this device");
 
 		if (arglist & CAM_ARG_VERBOSE) {
 			cam_error_print(device, ccb, CAM_ESF_ALL,



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201411091813.sA9ID9li009021>