예제 #1
0
        private SparseStream OpenExtent(ExtentRecord extent)
        {
            DiskRecord disk = _database.GetDisk(extent.DiskId);

            DynamicDisk diskObj = _disks[new Guid(disk.DiskGuidString)];

            return(new SubStream(diskObj.Content, Ownership.None, (diskObj.DataOffset + extent.DiskOffsetLba) * Sizes.Sector, extent.SizeLba * Sizes.Sector));
        }
예제 #2
0
        private static int CompareExtentInterleaveOrder(ExtentRecord x, ExtentRecord y)
        {
            if (x.InterleaveOrder > y.InterleaveOrder)
            {
                return(1);
            }
            else if (x.InterleaveOrder < y.InterleaveOrder)
            {
                return(-1);
            }

            return(0);
        }
예제 #3
0
        private static int CompareExtentOffsets(ExtentRecord x, ExtentRecord y)
        {
            if (x.OffsetInVolumeLba > y.OffsetInVolumeLba)
            {
                return(1);
            }
            else if (x.OffsetInVolumeLba < y.OffsetInVolumeLba)
            {
                return(-1);
            }

            return(0);
        }
예제 #4
0
 internal IEnumerable <ExtentRecord> GetComponentExtents(ulong componentId)
 {
     foreach (var record in _records.Values)
     {
         if (record.RecordType == RecordType.Extent)
         {
             ExtentRecord extentRecord = (ExtentRecord)record;
             if (extentRecord.ComponentId == componentId)
             {
                 yield return(extentRecord);
             }
         }
     }
 }
예제 #5
0
        public static DatabaseRecord ReadFrom(byte[] buffer, int offset)
        {
            DatabaseRecord result = null;

            if (Utilities.ToInt32BigEndian(buffer, offset + 0xC) != 0)
            {
                switch ((RecordType)(buffer[offset + 0x13] & 0xF))
                {
                case RecordType.Volume:
                    result = new VolumeRecord();
                    break;

                case RecordType.Component:
                    result = new ComponentRecord();
                    break;

                case RecordType.Extent:
                    result = new ExtentRecord();
                    break;

                case RecordType.Disk:
                    result = new DiskRecord();
                    break;

                case RecordType.DiskGroup:
                    result = new DiskGroupRecord();
                    break;

                default:
                    throw new NotImplementedException("Unrecognized record type: " + buffer[offset + 0x13]);
                }

                result.DoReadFrom(buffer, offset);
            }

            return(result);
        }