public static bool isGFS(Partition part) { byte[] array = new byte[512]; part.ReadBlock(1uL, 1u, array); return new BinaryReader(new MemoryStream(512)) { BaseStream = { Data = array } }.ReadString() == "GFS SC"; }
public GLNFS(Partition p) { this.a = p; byte[] array = new byte[512]; this.a.ReadBlock(1uL, 1u, array); BinaryReader binaryReader = new BinaryReader(new MemoryStream(512)); binaryReader.BaseStream.Data = array; if (!(binaryReader.ReadString() != "GFS SC")) { this.DriveLabel = binaryReader.ReadString(); } }
static void InitAta(BlockDevice.Ata.ControllerIdEnum aControllerID, BlockDevice.Ata.BusPositionEnum aBusPosition) { var xIO = aControllerID == BlockDevice.Ata.ControllerIdEnum.Primary ? Cosmos.Core.Global.BaseIOGroups.ATA1 : Cosmos.Core.Global.BaseIOGroups.ATA2; var xATA = new BlockDevice.AtaPio(xIO, aControllerID, aBusPosition); if (xATA.DriveType != BlockDevice.AtaPio.SpecLevel.Null) { BlockDevice.BlockDevice.Devices.Add(xATA); var xMbrData = new byte[512]; xATA.ReadBlock(0UL, 1U, xMbrData); var xMBR = new BlockDevice.MBR(xMbrData); if (xMBR.EBRLocation != 0) { //EBR Detected var xEbrData = new byte[512]; xATA.ReadBlock(xMBR.EBRLocation, 1U, xEbrData); var xEBR = new BlockDevice.EBR(xEbrData); for (int i = 0; i < xEBR.Partitions.Count; i++) { //var xPart = xEBR.Partitions[i]; //var xPartDevice = new BlockDevice.Partition(xATA, xPart.StartSector, xPart.SectorCount); //BlockDevice.BlockDevice.Devices.Add(xPartDevice); } } // TODO Change this to foreach when foreach is supported Console.WriteLine("Number of MBR partitions found: " + xMBR.Partitions.Count); for (int i = 0; i < xMBR.Partitions.Count; i++) { var xPart = xMBR.Partitions[i]; if (xPart == null) { Console.WriteLine("Null partition found at idx " + i); } else { var xPartDevice = new BlockDevice.Partition(xATA, xPart.StartSector, xPart.SectorCount); BlockDevice.BlockDevice.Devices.Add(xPartDevice); Console.WriteLine("Found partition at idx " + i); } } } }
public static void ReadMBR(AtaPio dev) { BinaryReader binaryReader = new BinaryReader(ATA.a); for (int i = 0; i < 4; i++) { binaryReader.BaseStream.Position = 446 + i * 16 + 8; uint num = binaryReader.ReadUInt32(); uint num2 = binaryReader.ReadUInt32(); if (num2 != 0u) { Partition dev2 = new Partition(dev, (ulong)num, (ulong)num2); Devices.device device = new Devices.device(); device.dev = dev2; device.name = "/dev/sd" + ATA.b.ToString() + (i + 1).ToString(); Devices.dev.Add(device); } } }
static void InitAta(BlockDevice.Ata.ControllerIdEnum aControllerID, BlockDevice.Ata.BusPositionEnum aBusPosition) { var xIO = aControllerID == BlockDevice.Ata.ControllerIdEnum.Primary ? Cosmos.Core.Global.BaseIOGroups.ATA1 : Cosmos.Core.Global.BaseIOGroups.ATA2; var xATA = new BlockDevice.AtaPio(xIO, aControllerID, aBusPosition); if (xATA.DriveType != BlockDevice.AtaPio.SpecLevel.Null) { BlockDevice.BlockDevice.Devices.Add(xATA); var xMbrData = new byte[512]; xATA.ReadBlock(0UL, 1U, xMbrData); var xMBR = new BlockDevice.MBR(xMbrData); if (xMBR.EBRLocation != 0) { //EBR Detected var xEbrData = new byte[512]; xATA.ReadBlock(xMBR.EBRLocation, 1U, xEbrData); var xEBR = new BlockDevice.EBR(xEbrData); for (int i = 0; i < xEBR.Partitions.Count; i++) { //var xPart = xEBR.Partitions[i]; //var xPartDevice = new BlockDevice.Partition(xATA, xPart.StartSector, xPart.SectorCount); //BlockDevice.BlockDevice.Devices.Add(xPartDevice); } } // TODO Change this to foreach when foreach is supported Console.WriteLine("Number of MBR partitions found: " + xMBR.Partitions.Count); for (int i = 0; i < xMBR.Partitions.Count; i++) { var xPart = xMBR.Partitions[i]; if (xPart == null) { Console.WriteLine("Null partition found at idx " + i); } else { var xPartDevice = new BlockDevice.Partition(xATA, xPart.StartSector, xPart.SectorCount); BlockDevice.BlockDevice.Devices.Add(xPartDevice); Console.WriteLine("Found partition at idx " + i); } } } }
public static bool CheckIfFS(Cosmos.Hardware.BlockDevice.Partition p) { throw new NotImplementedException(); }
public FAT32(Cosmos.Hardware.BlockDevice.Partition p) : base(p) { xFS = new FAT.FatFileSystem(p); }