Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 15 Dec 2019 23:28:53 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r355788 - head/sbin/camcontrol
Message-ID:  <201912152328.xBFNSr2f008379@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Sun Dec 15 23:28:53 2019
New Revision: 355788
URL: https://svnweb.freebsd.org/changeset/base/355788

Log:
  Properly detect ATA sanitize errors.
  
  It seems I read specifications not careful enough.  There are devices not
  setting successful completion bit, causing previous code report false error.
  
  MFC after:	1 week

Modified:
  head/sbin/camcontrol/camcontrol.c

Modified: head/sbin/camcontrol/camcontrol.c
==============================================================================
--- head/sbin/camcontrol/camcontrol.c	Sun Dec 15 22:41:57 2019	(r355787)
+++ head/sbin/camcontrol/camcontrol.c	Sun Dec 15 23:28:53 2019	(r355788)
@@ -6667,6 +6667,25 @@ sanitize_wait_ata(struct cam_device *device, union ccb
 			return (retval);
 		}
 		if (status & ATA_STATUS_ERROR) {
+			if (error & ATA_ERROR_ABORT) {
+				switch (lba & 0xff) {
+				case 0x00:
+					warnx("Reason not reported or sanitize failed.");
+					return (1);
+				case 0x01:
+					warnx("Sanitize command unsuccessful.       ");
+					return (1);
+				case 0x02:
+					warnx("Unsupported sanitize device command. ");
+					return (1);
+				case 0x03:
+					warnx("Device is in sanitize frozen state.  ");
+					return (1);
+				case 0x04:
+					warnx("Sanitize antifreeze lock is enabled. ");
+					return (1);
+				}
+			}
 			warnx("SANITIZE STATUS EXT failed, "
 			    "sanitize may still run.");
 			return (1);
@@ -6683,9 +6702,6 @@ sanitize_wait_ata(struct cam_device *device, union ccb
 				fflush(stdout);
 			}
 			sleep(1);
-		} else if ((count & 0x8000) == 0) {
-			warnx("Sanitize complete with an error.     ");
-			return (1);
 		} else
 			break;
 	} while (1);



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