123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- using System;
- using System.Collections.Generic;
- namespace SCSI.Win32
- {
- internal class LogicalUnit
- {
- public byte AssociatedLun;
- public byte PathId;
- public byte TargetId;
- public byte TargetLun;
- public PeripheralDeviceType DeviceType;
- public uint? BlockSize;
- }
- internal class LogicalUnitManager
- {
- private IDictionary<byte, LogicalUnit> m_luns = new Dictionary<byte, LogicalUnit>();
- public LogicalUnitManager()
- {
- }
- public void AddLogicalUnit(LogicalUnit logicalUnit)
- {
- m_luns.Add(logicalUnit.AssociatedLun, logicalUnit);
- }
- public LogicalUnit FindLogicalUnit(byte lun)
- {
- LogicalUnit result;
- m_luns.TryGetValue(lun, out result);
- return result;
- }
- public byte? FindAssociatedLUN(byte pathId, byte targetId, byte targetLun)
- {
- foreach (byte associatedLUN in m_luns.Keys)
- {
- if (m_luns[associatedLUN].PathId == pathId &&
- m_luns[associatedLUN].TargetId == targetId &&
- m_luns[associatedLUN].TargetLun == targetLun)
- {
- return associatedLUN;
- }
- }
- return null;
- }
- public byte? FindUnusedLUN()
- {
-
- for (byte lun = 0; lun < 255; lun++)
- {
- if (!m_luns.ContainsKey(lun))
- {
- return lun;
- }
- }
- return null;
- }
- }
- }
|