Author: mav
Date: Sun Dec 22 17:01:44 2019
New Revision: 356010
URL: https://svnweb.freebsd.org/changeset/base/356010

Log:
  MFC r355788: 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.

Modified:
  stable/11/sbin/camcontrol/camcontrol.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sbin/camcontrol/camcontrol.c
==============================================================================
--- stable/11/sbin/camcontrol/camcontrol.c      Sun Dec 22 17:00:53 2019        
(r356009)
+++ stable/11/sbin/camcontrol/camcontrol.c      Sun Dec 22 17:01:44 2019        
(r356010)
@@ -6490,6 +6490,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);
@@ -6506,9 +6525,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