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);
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to