public DiskDevice(IDiskControllerDevice diskController, uint driveNbr, bool readOnly) { base.parent = (diskController as Device); base.name = base.parent.Name + "/Disk" + driveNbr.ToString(); base.deviceStatus = DeviceStatus.Online; this.totalSectors = diskController.GetTotalSectors(driveNbr); this.diskController = diskController; this.driveNbr = driveNbr; if (readOnly) { this.readOnly = false; } else { this.readOnly = this.diskController.CanWrite(driveNbr); } mbr = new MasterBootBlock(this); if (mbr.Valid) { for (uint i = 0; i < MasterBootBlock.MaxMBRPartitions; i++) { if (mbr[i].PartitionType != PartitionTypes.Empty) { new PartitionDevice(mbr[i], this, readOnly); } } } }
public override void Start() { totalSectors = diskController.GetTotalSectors(DriveNbr); if (!readOnly) { readOnly = !diskController.CanWrite(DriveNbr); } Device.Status = DeviceStatus.Online; }
/// <summary> /// Initializes a new instance of the <see cref="DiskDevice"/> class. /// </summary> /// <param name="diskController">The disk controller.</param> /// <param name="driveNbr">The drive number.</param> /// <param name="readOnly">if set to <c>true</c> [read only].</param> public DiskDevice(IDiskControllerDevice diskController, uint driveNbr, bool readOnly) { base.parent = diskController as Device; base.name = base.parent.Name + "/Disk" + driveNbr.ToString(); base.deviceStatus = DeviceStatus.Online; this.totalSectors = diskController.GetTotalSectors(driveNbr); this.diskController = diskController; this.driveNbr = driveNbr; if (readOnly) this.readOnly = true; else this.readOnly = this.diskController.CanWrite(driveNbr); }
/// <summary> /// Initializes a new instance of the <see cref="DiskDevice"/> class. /// </summary> /// <param name="diskController">The disk controller.</param> /// <param name="driveNbr">The drive number.</param> /// <param name="readOnly">if set to <c>true</c> [read only].</param> public DiskDevice(IDiskControllerDevice diskController, uint driveNbr, bool readOnly) { base.parent = diskController as Device; base.name = base.parent.Name + "/Disk" + driveNbr.ToString(); base.deviceStatus = DeviceStatus.Online; this.totalSectors = diskController.GetTotalSectors(driveNbr); this.diskController = diskController; this.driveNbr = driveNbr; if (readOnly) { this.readOnly = true; } else { this.readOnly = this.diskController.CanWrite(driveNbr); } }
/// <summary> /// Creates the devices. /// </summary> /// <param name="diskControllerDevice">The disk controller device.</param> /// <returns></returns> private List <IDevice> CreateDevices(IDiskControllerDevice diskControllerDevice) { var devices = new List <IDevice>(); for (uint drive = 0; drive < diskControllerDevice.MaximunDriveCount; drive++) { if (diskControllerDevice.Open(drive)) { if (diskControllerDevice.GetTotalSectors(drive) == 0) { continue; } var diskDevice = new DiskDevice(diskControllerDevice, drive, false); devices.Add(diskDevice as IDevice); } } return(devices); }
public DiskDevice (IDiskControllerDevice diskController, uint driveNbr, bool readOnly) { base.parent = (diskController as Device); base.name = base.parent.Name + "/Disk" + driveNbr.ToString (); base.deviceStatus = DeviceStatus.Online; this.totalSectors = diskController.GetTotalSectors (driveNbr); this.diskController = diskController; this.driveNbr = driveNbr; if (readOnly) this.readOnly = false; else this.readOnly = this.diskController.CanWrite (driveNbr); mbr = new MasterBootBlock (this); if (mbr.Valid) for (uint i = 0; i < MasterBootBlock.MaxMBRPartitions; i++) if (mbr[i].PartitionType != PartitionTypes.Empty) new PartitionDevice (mbr[i], this, readOnly); }