github.com/cloud-foundations/dominator@v0.0.0-20221004181915-6e4fee580046/lib/mbr/api.go (about)

     1  package mbr
     2  
     3  import (
     4  	"os"
     5  )
     6  
     7  const (
     8  	_ = iota
     9  	TABLE_TYPE_AIX
    10  	TABLE_TYPE_AMIGA
    11  	TABLE_TYPE_BSD
    12  	TABLE_TYPE_DVH
    13  	TABLE_TYPE_GPT
    14  	TABLE_TYPE_LOOP
    15  	TABLE_TYPE_MAC
    16  	TABLE_TYPE_MSDOS
    17  	TABLE_TYPE_PC98
    18  	TABLE_TYPE_SUN
    19  )
    20  
    21  type Mbr struct {
    22  	raw [512]byte
    23  }
    24  
    25  type TableType uint
    26  
    27  func Decode(file *os.File) (*Mbr, error) {
    28  	return decode(file)
    29  }
    30  
    31  func (mbr *Mbr) GetNumPartitions() uint {
    32  	return 4
    33  }
    34  
    35  func (mbr *Mbr) GetPartitionOffset(index uint) uint64 {
    36  	return mbr.getPartitionOffset(index)
    37  }
    38  
    39  func (mbr *Mbr) GetPartitionSize(index uint) uint64 {
    40  	return mbr.getPartitionSize(index)
    41  }
    42  
    43  func (tt *TableType) Set(value string) error {
    44  	return tt.set(value)
    45  }
    46  
    47  func (tt TableType) String() string {
    48  	return tt.string()
    49  }
    50  
    51  func WriteDefault(filename string, tableType TableType) error {
    52  	return writeDefault(filename, tableType)
    53  }