github.com/xyproto/u-root@v6.0.1-0.20200302025726-5528e0c77a3c+incompatible/pkg/scuzz/control.go (about)

     1  // Copyright 2019 the u-root Authors. All rights reserved
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package scuzz
     6  
     7  import (
     8  	"encoding/json"
     9  	"fmt"
    10  	"time"
    11  )
    12  
    13  // DefaultTimeout is the default timeout for disk operations.
    14  const DefaultTimeout time.Duration = 15 * time.Second
    15  
    16  // Info is information about a device.
    17  type Info struct {
    18  	NumberSectors    uint64
    19  	ECCBytes         uint
    20  	Serial           string
    21  	Model            string
    22  	FirmwareRevision string
    23  }
    24  
    25  // Disk is the interface to a disk, with operations
    26  // to create packets and operate on them.
    27  type Disk interface {
    28  	// Unlock unlocks the drive, given a password
    29  	// and an indication of whether it is the
    30  	// master (true) or user (false) password.
    31  	Unlock(password string, master bool) error
    32  	// Identify returns drive identity information
    33  	Identify() (*Info, error)
    34  }
    35  
    36  // String is a stringer for Info
    37  func (i *Info) String() string {
    38  	s, err := json.MarshalIndent(i, "", "\t")
    39  	if err != nil {
    40  		return fmt.Sprintf("%v", err)
    41  	}
    42  	return string(s)
    43  }