QueryFSInfoAllocation.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /* Copyright (C) 2014 Tal Aloni <tal.aloni.il@gmail.com>. All rights reserved.
  2. *
  3. * You can redistribute this program and/or modify it under the terms of
  4. * the GNU Lesser Public License as published by the Free Software Foundation,
  5. * either version 3 of the License, or (at your option) any later version.
  6. */
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Text;
  10. using Utilities;
  11. namespace SMBLibrary.SMB1
  12. {
  13. /// <summary>
  14. /// SMB_INFO_ALLOCATION
  15. /// </summary>
  16. public class QueryFSInfoAllocation : QueryFSInformation
  17. {
  18. public const int Length = 18;
  19. public uint FileSystemID; // File system identifier, Windows Server will set it to 0
  20. public uint SectorUnit; // Number of sectors per allocation unit
  21. public uint UnitsTotal; // Total number of allocation units
  22. public uint UnitsAvailable; // Total number of available allocation units
  23. public ushort Sector; // Number of bytes per sector
  24. public QueryFSInfoAllocation()
  25. {
  26. }
  27. public QueryFSInfoAllocation(byte[] buffer, int offset)
  28. {
  29. FileSystemID = LittleEndianConverter.ToUInt32(buffer, offset + 0);
  30. SectorUnit = LittleEndianConverter.ToUInt32(buffer, offset + 4);
  31. UnitsTotal = LittleEndianConverter.ToUInt32(buffer, offset + 8);
  32. UnitsAvailable = LittleEndianConverter.ToUInt32(buffer, offset + 12);
  33. Sector = LittleEndianConverter.ToUInt16(buffer, offset + 16);
  34. }
  35. public override byte[] GetBytes(bool isUnicode)
  36. {
  37. byte[] buffer = new byte[Length];
  38. LittleEndianWriter.WriteUInt32(buffer, 0, FileSystemID);
  39. LittleEndianWriter.WriteUInt32(buffer, 4, SectorUnit);
  40. LittleEndianWriter.WriteUInt32(buffer, 8, UnitsTotal);
  41. LittleEndianWriter.WriteUInt32(buffer, 12, UnitsAvailable);
  42. LittleEndianWriter.WriteUInt16(buffer, 16, Sector);
  43. return buffer;
  44. }
  45. }
  46. }