public MBTPartition(BlockDevice aBackend, uint aBlockStart, uint aBlockCount, string aName) { mBlockStart = aBlockStart; mBlockCount = aBlockCount; mBackend = aBackend; mName = aName; }
private static void DetectFilesystem(BlockDevice aDevice) { #region Ext2 if (Ext2.BlockDeviceContainsExt2(aDevice)) { aDevice.Used = true; var xFS = new Ext2(aDevice); mFilesystems.Add(xFS); } #endregion }
private static List<Device> getPartitions(BlockDevice xBlockDev) { if (xBlockDev == null) return default(List<Device>); List<Device> partitionList = new List<Device>(); int xContentsIndex = 0x1BE; //DebugUtil.SendMessage("MBT", "Found Device"); byte[] xBlockContents = new byte[xBlockDev.BlockSize]; xBlockDev.ReadBlock(0, xBlockContents); // detecting whether MBT or not //DebugUtil.SendNumber("MBT", "xBlockDev.BlockSize", xBlockDev.BlockSize, 32); //DebugUtil.SendDoubleNumber("MBT", "Last bytes of block", xBlockContents[510], 8, xBlockContents[511], 8); if (!(xBlockContents[xBlockDev.BlockSize - 2] == 0x55 && xBlockContents[xBlockDev.BlockSize - 1] == 0xAA)) { //DebugUtil.SendMessage("MBT", "Does not contain MBR"); //Hardware.DebugUtil.SendATA_BlockReceived(255, 255, 0, xBlockContents); return default(List<Device>); } for (byte j = 0; j < 4; j++) { //DebugUtil.SendNumber("MBT", "Partition Status", xBlockContents[xContentsIndex], 8); if (!(xBlockContents[xContentsIndex] == 0x80 || xBlockContents[xContentsIndex] == 0)) { xContentsIndex += 16; continue; } xContentsIndex += 8; uint xStart = BitConverter.ToUInt32(xBlockContents, xContentsIndex); xContentsIndex += 4; uint xLength = BitConverter.ToUInt32(xBlockContents, xContentsIndex); xContentsIndex += 4; if (xStart > 0 && xLength > 0) { //DebugUtil.SendDoubleNumber("MBT", "Entry Found. Start, Length in blocks", xStart, 32, xLength, 32); xStart += 2; Console.WriteLine("Add Partition to Device list"); partitionList.Add(new MBTPartition(xBlockDev, xStart, xLength, "Partition")); //Causes System Fault on the HTC Shift! //DebugUtil.SendMessage("MBT", "FoundPartition"); } } return partitionList; }
public MBRPartition(IBMPartitionInformation info, MBR mbr) { Mbr = mbr; Start = info.StartLBA; Length = info.LengthLBA; Identifier = info.PartitionType; blockDev = mbr.blockdevice; }
public static bool BlockDeviceContainsExt2(BlockDevice aDevice) { if (aDevice.BlockCount > 3) { byte[] xBuffer = new byte[aDevice.BlockSize]; // todo: implement better detection aDevice.ReadBlock(2, xBuffer); bool xResult = (xBuffer[56] == 0x53 && xBuffer[57] == 0xEF); return xResult; } return false; }
public Ext2(BlockDevice aBackend) { mBackend = aBackend; Initialize(); }