VolumeDisk.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using Utilities;
  5. namespace ISCSIConsole
  6. {
  7. public class VolumeDisk : Disk // a fake disk that serves a single volume
  8. {
  9. private Volume m_volume;
  10. private bool m_isReadOnly;
  11. public VolumeDisk(Volume volume, bool isReadOnly)
  12. {
  13. m_volume = volume;
  14. m_isReadOnly = volume.IsReadOnly || isReadOnly;
  15. }
  16. public override byte[] ReadSectors(long sectorIndex, int sectorCount)
  17. {
  18. return m_volume.ReadSectors(sectorIndex, sectorCount);
  19. }
  20. public override void WriteSectors(long sectorIndex, byte[] data)
  21. {
  22. if (!IsReadOnly)
  23. {
  24. m_volume.WriteSectors(sectorIndex, data);
  25. }
  26. }
  27. public override int BytesPerSector
  28. {
  29. get
  30. {
  31. return m_volume.BytesPerSector;
  32. }
  33. }
  34. public override long Size
  35. {
  36. get
  37. {
  38. return m_volume.Size;
  39. }
  40. }
  41. public override bool IsReadOnly
  42. {
  43. get
  44. {
  45. return m_isReadOnly;
  46. }
  47. }
  48. public Volume Volume
  49. {
  50. get
  51. {
  52. return m_volume;
  53. }
  54. }
  55. }
  56. }