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); } } } }
/// <summary> /// Creates the devices. /// </summary> /// <param name="diskControllerDevice">The disk controller device.</param> /// <returns></returns> private LinkedList<IDevice> CreateDevices(IDiskControllerDevice diskControllerDevice) { LinkedList<IDevice> devices = new LinkedList<IDevice>(); for (uint drive = 0; drive < diskControllerDevice.MaximunDriveCount; drive++) { if (diskControllerDevice.Open(drive)) { IDiskDevice diskDevice = new DiskDevice(diskControllerDevice, drive, false); devices.Add(diskDevice as IDevice); } } return devices; }
/// <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 LinkedList <IDevice> CreateDevices(IDiskControllerDevice diskControllerDevice) { LinkedList <IDevice> devices = new LinkedList <IDevice>(); for (uint drive = 0; drive < diskControllerDevice.MaximunDriveCount; drive++) { if (diskControllerDevice.Open(drive)) { IDiskDevice diskDevice = new DiskDevice(diskControllerDevice, drive, false); devices.AddLast(diskDevice as IDevice); } } return(devices); }
public override void Initialize() { var configuration = Device.Configuration as DiskDeviceConfiguration; DriveNbr = configuration.DriveNbr; readOnly = configuration.ReadOnly; Device.ComponentID = DriveNbr; Device.Name = Device.Parent.Name + "/Disk" + DriveNbr.ToString(); diskController = Device.Parent.DeviceDriver as IDiskControllerDevice; if (diskController == null) { Device.Status = DeviceStatus.Error; } }
/// <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); }
/// <summary> /// Creates the disk devices. /// </summary> public void CreateDiskDevices() { // FIXME: Do not create disk devices if this method executed more than once // Find disk controller devices LinkedList <IDevice> devices = deviceManager.GetDevices(new FindDevice.IsDiskControllerDevice(), new FindDevice.IsOnline()); // For each controller foreach (IDevice device in devices) { IDiskControllerDevice controller = device as IDiskControllerDevice; // Create disk devices LinkedList <IDevice> disks = CreateDevices(controller); // Add them to the device manager foreach (IDevice disk in disks) { deviceManager.Add(disk); } } }