github.com/Microsoft/azure-vhd-utils@v0.0.0-20230613175315-7c30a3748a1b/vhdcore/footer/footer.go (about) 1 package footer 2 3 import ( 4 "bytes" 5 "time" 6 7 "github.com/Microsoft/azure-vhd-utils/vhdcore" 8 "github.com/Microsoft/azure-vhd-utils/vhdcore/common" 9 ) 10 11 // Footer represents the footer of the vhd, the size of the footer is 512 bytes. 12 // The last 512 bytes of the disk is footer. In case of dynamic and differential 13 // vhds, the footer is replicated at the beginning of the disk as well. 14 // 15 type Footer struct { 16 // Offset = 0, Size = 8 17 Cookie *vhdcore.Cookie 18 // Offset = 8, Size = 4 19 Features VhdFeature 20 // Offset = 12, Size = 4 21 FileFormatVersion VhdFileFormatVersion 22 // Offset = 16, Size = 8 23 // Absolute byte offset to the header structure, this is used for dynamic disks 24 // and differencing disks. Fixed disk does not have header this field is set to 25 // 0xFFFFFFFF for fixed disk. 26 HeaderOffset int64 27 // Offset = 24, Size = 4 28 TimeStamp *time.Time 29 // Offset = 28, Size = 4 30 CreatorApplication string 31 // Offset = 32, Size = 4 32 CreatorVersion VhdCreatorVersion 33 // Offset = 36, Size = 4 34 CreatorHostOsType HostOsType 35 // Offset = 40, Size = 8 36 PhysicalSize int64 37 // Offset = 48, Size = 8 38 VirtualSize int64 39 // Offset = 56, Size = 4 40 DiskGeometry *DiskGeometry 41 // Offset = 60, Size = 4 42 DiskType DiskType 43 // Offset = 64, Size = 4 44 CheckSum uint32 45 // Offset = 68, Size = 16 46 UniqueID *common.UUID 47 // Offset = 84, Size = 1 48 SavedState bool 49 // Offset = 85, Size = 427 50 Reserved []byte 51 // Offset = 0, Size = 512 52 RawData []byte 53 } 54 55 // CreateCopy creates and returns a deep copy of this instance. 56 // 57 func (v *Footer) CreateCopy() *Footer { 58 return &Footer{ 59 Cookie: v.Cookie.CreateCopy(), 60 Features: v.Features, 61 FileFormatVersion: v.FileFormatVersion, 62 HeaderOffset: v.HeaderOffset, 63 TimeStamp: v.TimeStamp, 64 CreatorApplication: v.CreatorApplication, 65 CreatorVersion: v.CreatorVersion, 66 CreatorHostOsType: v.CreatorHostOsType, 67 PhysicalSize: v.PhysicalSize, 68 VirtualSize: v.VirtualSize, 69 DiskGeometry: v.DiskGeometry.CreateCopy(), 70 DiskType: v.DiskType, 71 CheckSum: v.CheckSum, 72 UniqueID: v.UniqueID, 73 SavedState: v.SavedState, 74 Reserved: common.CreateByteSliceCopy(v.Reserved), 75 RawData: common.CreateByteSliceCopy(v.RawData), 76 } 77 } 78 79 // Equal returns true if this and other points to the same instance or if contents 80 // of the fields of these two instances are same. 81 // 82 func (v *Footer) Equal(other *Footer) bool { 83 if other == nil { 84 return false 85 } 86 87 if v == other { 88 return true 89 } 90 91 return v.Cookie.Equal(other.Cookie) && 92 v.Features == other.Features && 93 v.FileFormatVersion == other.FileFormatVersion && 94 v.HeaderOffset == other.HeaderOffset && 95 v.TimeStamp == other.TimeStamp && 96 v.CreatorApplication == other.CreatorApplication && 97 v.CreatorVersion == other.CreatorVersion && 98 v.CreatorHostOsType == other.CreatorHostOsType && 99 v.PhysicalSize == other.PhysicalSize && 100 v.VirtualSize == other.VirtualSize && 101 v.DiskGeometry.Equals(other.DiskGeometry) && 102 v.DiskType == other.DiskType && 103 v.CheckSum == other.CheckSum && 104 v.UniqueID == other.UniqueID && 105 v.SavedState == other.SavedState && 106 bytes.Equal(v.Reserved, other.Reserved) && 107 bytes.Equal(v.RawData, other.RawData) 108 }