github.com/Cloud-Foundations/Dominator@v0.3.4/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 (mbr *Mbr) SetPartitionOffset(index uint, offset uint64) error { 48 return mbr.setPartitionOffset(index, offset) 49 } 50 51 func (mbr *Mbr) SetPartitionSize(index uint, size uint64) error { 52 return mbr.setPartitionSize(index, size) 53 } 54 55 func (mbr *Mbr) Write(filename string) error { 56 return mbr.write(filename) 57 } 58 59 func (tt TableType) String() string { 60 return tt.string() 61 } 62 63 func WriteDefault(filename string, tableType TableType) error { 64 return writeDefault(filename, tableType) 65 }