Skip to content

Commit

Permalink
Move blkdiscard example into diskwipe
Browse files Browse the repository at this point in the history
Better off in diskwipe than solo.
  • Loading branch information
mmlb committed Jun 10, 2024
1 parent 98f315b commit b80f648
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 52 deletions.
46 changes: 0 additions & 46 deletions examples/blkdiscard/main.go

This file was deleted.

24 changes: 18 additions & 6 deletions examples/diskwipe/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"context"
"flag"
"strings"
"time"

"github.com/bmc-toolbox/common"
Expand Down Expand Up @@ -64,12 +65,23 @@ func main() {
case "nvme":
wiper = utils.NewNvmeCmd(*verbose)
case "sata":
wiper = utils.NewFillZeroCmd(*verbose)
if timeout == defaultTimeout {
timeout = 24 * time.Hour
l.WithField("timeout", timeout.String()).Info("increasing timeout")
ctx, cancel = context.WithTimeout(context.Background(), timeout)
defer cancel()
for _, cap := range drive.Capabilities {
if strings.HasPrefix(cap.Description, "Data Set Management TRIM supported") {
if cap.Enabled {
wiper = utils.NewBlkdiscardCmd(*verbose)
}
break
}
}

if wiper == nil {
wiper = utils.NewFillZeroCmd(*verbose)
if timeout == defaultTimeout {
timeout = 24 * time.Hour
l.WithField("timeout", timeout.String()).Info("increasing timeout")
ctx, cancel = context.WithTimeout(context.Background(), timeout)
defer cancel()
}
}
}

Expand Down

0 comments on commit b80f648

Please sign in to comment.