diff --git a/examples/diskwipe/main.go b/examples/diskwipe/main.go index afdb314e..9bbf959f 100644 --- a/examples/diskwipe/main.go +++ b/examples/diskwipe/main.go @@ -66,18 +66,30 @@ func main() { case "nvme": wiper = utils.NewNvmeCmd(*verbose) case "sata": - // Lets see if drive supports TRIM, if so we'll use blkdiscard + // Lets figure out the drive capabilities in an easier format + var sanitize bool + var esee bool + var trim bool for _, cap := range drive.Capabilities { - if strings.HasPrefix(cap.Description, "Data Set Management TRIM supported") { - if cap.Enabled { - wiper = utils.NewBlkdiscardCmd(*verbose) - } - break + switch { + case cap.Description == "encryption supports enhanced erase": + esee = cap.Enabled + case cap.Description == "SANITIZE feature": + sanitize = cap.Enabled + case strings.HasPrefix(cap.Description, "Data Set Management TRIM supported"): + trim = cap.Enabled } } - // drive does not support TRIM so we fall back to filling it up with zero - if wiper == nil { + switch { + case sanitize || esee: + // Drive supports Sanitize or Enhanced Erase, so we use hdparm + wiper = utils.NewHdparmCmd(*verbose) + case trim: + // Drive supports TRIM, so we use blkdiscard + wiper = utils.NewBlkdiscardCmd(*verbose) + default: + // Drive does not support any preferred wipe method so we fall back to filling it up with zero wiper = utils.NewFillZeroCmd(*verbose) // If the user supplied a non-default timeout then we'll honor it, otherwise we just go with a huge timeout. diff --git a/utils/hdparm.go b/utils/hdparm.go index 4d9a3af5..4a465bd2 100644 --- a/utils/hdparm.go +++ b/utils/hdparm.go @@ -223,13 +223,13 @@ func (h *Hdparm) WipeDrive(ctx context.Context, logger *logrus.Logger, drive *co ) for _, cap := range drive.Capabilities { switch { - case cap.Name == "esee": + case cap.Description == "encryption supports enhanced erase": esee = cap.Enabled - case cap.Name == "bee": + case cap.Description == "BLOCK ERASE EXT": bee = cap.Enabled - case cap.Name == "cse": + case cap.Description == "CRYPTO SCRAMBLE EXT": cse = cap.Enabled - case cap.Name == "sf": + case cap.Description == "SANITIZE feature": sanitize = cap.Enabled case strings.HasPrefix(cap.Description, "erase time:"): eseu = strings.Contains(cap.Description, "enhanced")