1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- using System;
- using System.Collections.Generic;
- using System.Text;
- using Utilities;
- namespace DiskAccessLibrary.LogicalDiskManager
- {
- public class DynamicDiskExtentHelper
- {
- public static int GetIndexOfExtentID(List<DynamicDiskExtent> extents, ulong extentID)
- {
- for (int index = 0; index < extents.Count; index++)
- {
- if (extents[index].ExtentID == extentID)
- {
- return index;
- }
- }
- return -1;
- }
- public static DynamicDiskExtent GetByExtentID(List<DynamicDiskExtent> extents, ulong extentID)
- {
- int index = GetIndexOfExtentID(extents, extentID);
- if (index >= 0)
- {
- return extents[index];
- }
- else
- {
- return null;
- }
- }
-
-
-
- public static DynamicDiskExtent GetDiskExtent(DynamicDisk dynamicDisk, ExtentRecord extentRecord)
- {
- long extentStartSector = GetExtentStartSector(dynamicDisk, extentRecord);
- long extentSize = (long)extentRecord.SizeLBA * PublicRegionHelper.BytesPerPublicRegionSector;
- Disk disk = null;
- Guid diskGuid = Guid.Empty;
- if (dynamicDisk != null)
- {
- disk = dynamicDisk.Disk;
- diskGuid = dynamicDisk.DiskGuid;
- }
- DynamicDiskExtent extent = new DynamicDiskExtent(disk, extentStartSector, extentSize, extentRecord.ExtentId);
- extent.Name = extentRecord.Name;
- extent.DiskGuid = diskGuid;
- return extent;
- }
-
-
-
- public static long GetExtentStartSector(DynamicDisk disk, ExtentRecord extentRecord)
- {
- long publicRegionStartLBA = 0;
- int bytesPerDiskSector = DynamicColumn.DefaultBytesPerSector;
- if (disk != null)
- {
- bytesPerDiskSector = disk.BytesPerSector;
- PrivateHeader privateHeader = disk.PrivateHeader;
- publicRegionStartLBA = (long)privateHeader.PublicRegionStartLBA;
- }
- return PublicRegionHelper.TranslateFromPublicRegionLBA((long)extentRecord.DiskOffsetLBA, publicRegionStartLBA, bytesPerDiskSector);
- }
- }
- }
|