/// <inheritdoc />
 public int ReadFrom(byte[] buffer, int offset)
 {
     Label         = EndianUtilities.BytesToString(buffer, offset, 0x8);
     Sector        = EndianUtilities.ToUInt64LittleEndian(buffer, offset + 0x8);
     Crc           = EndianUtilities.ToUInt32LittleEndian(buffer, offset + 0x10);
     CalculatedCrc = PhysicalVolume.CalcCrc(buffer, offset + 0x14, PhysicalVolume.SECTOR_SIZE - 0x14);
     Offset        = EndianUtilities.ToUInt32LittleEndian(buffer, offset + 0x14);
     Label2        = EndianUtilities.BytesToString(buffer, offset + 0x18, 0x8);
     return(Size);
 }
        /// <inheritdoc />
        public int ReadFrom(byte[] buffer, int offset)
        {
            Crc           = Utilities.ToUInt32LittleEndian(buffer, offset);
            CalculatedCrc = PhysicalVolume.CalcCrc(buffer, offset + 0x4, PhysicalVolume.SECTOR_SIZE - 0x4);
            Magic         = Utilities.BytesToString(buffer, offset + 0x4, 0x10);
            Version       = Utilities.ToUInt32LittleEndian(buffer, offset + 0x14);
            Start         = Utilities.ToUInt64LittleEndian(buffer, offset + 0x18);
            Length        = Utilities.ToUInt64LittleEndian(buffer, offset + 0x20);

            var locations      = new List <RawLocation>();
            var locationOffset = offset + 0x28;

            while (true)
            {
                var location = new RawLocation();
                locationOffset += location.ReadFrom(buffer, locationOffset);
                if (location.Offset == 0 && location.Length == 0 && location.Checksum == 0 && location.Flags == 0)
                {
                    break;
                }
                locations.Add(location);
            }
            RawLocations = locations.ToArray();
            foreach (var location in RawLocations)
            {
                if ((location.Flags & RawLocationFlags.Ignored) != 0)
                {
                    continue;
                }
                var checksum = PhysicalVolume.CalcCrc(buffer, (int)location.Offset, (int)location.Length);
                if (location.Checksum != checksum)
                {
                    throw new IOException("invalid metadata checksum");
                }
                Metadata       = Utilities.BytesToString(buffer, (int)location.Offset, (int)location.Length);
                ParsedMetadata = Lvm.Metadata.Parse(Metadata);
                break;
            }
            return(Size);
        }