Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

135 lines
3.4 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Copyright (C) Microsoft Corporation, 1991 - 1998
  4. //
  5. // File: dellog.hxx
  6. //
  7. // Contents: Deletion logs for usns
  8. //
  9. // History: 28-Jul-97 SitaramR Created
  10. //
  11. //----------------------------------------------------------------------------
  12. #pragma once
  13. #include <dynstrm.hxx>
  14. #include "usnlist.hxx"
  15. //+-------------------------------------------------------------------------
  16. //
  17. // Class: CDelLogEntry
  18. //
  19. // Purpose: Entry in deletion log list
  20. //
  21. // History: 28-Jul-97 SitaramR Created
  22. //
  23. //--------------------------------------------------------------------------
  24. class CDelLogEntry : public CDoubleLink
  25. {
  26. public:
  27. CDelLogEntry( FILEID fileId, WORKID wid, USN usn )
  28. : _fileId(fileId),
  29. _wid(wid),
  30. _usn(usn)
  31. {
  32. }
  33. FILEID FileId() { return _fileId; }
  34. WORKID WorkId() { return _wid; }
  35. USN Usn() { return _usn; }
  36. private:
  37. FILEID _fileId;
  38. WORKID _wid;
  39. USN _usn;
  40. };
  41. typedef class TDoubleList<CDelLogEntry> CDelLogEntryList;
  42. typedef class TFwdListIter<CDelLogEntry, CDelLogEntryList> CDelLogEntryListIter;
  43. //+-------------------------------------------------------------------------
  44. //
  45. // Class: CFakeVolIdMap
  46. //
  47. // Purpose: Maps volume ids to fake volume ids in the range
  48. // 0..RTL_MAX_DRIVE_LETTERS-1
  49. //
  50. // History: 28-Jul-97 SitaramR Created
  51. //
  52. //--------------------------------------------------------------------------
  53. const VOLUMEID VolumeIdBase = L'a'; // For mapping 'a' to 'z' volume ids
  54. const COUNT_ALPHABETS = 26; // # letters in alphabet
  55. const COUNT_SPECIAL_CHARS = RTL_MAX_DRIVE_LETTERS - 26; // Count of non 'a' to 'z' drives
  56. class CFakeVolIdMap
  57. {
  58. public:
  59. CFakeVolIdMap();
  60. ULONG VolIdToFakeVolId( VOLUMEID volumeId );
  61. VOLUMEID FakeVolIdToVolId( ULONG fakeVolId );
  62. private:
  63. VOLUMEID _aVolIdSpecial[COUNT_SPECIAL_CHARS]; // Mapping for non 'a' to 'z' drives
  64. };
  65. class CFileIdMap;
  66. class CiCat;
  67. class CiStorage;
  68. //+-------------------------------------------------------------------------
  69. //
  70. // Class: CDeletionLog
  71. //
  72. // Purpose: Deletion log for keeping track of usn deletions until they
  73. // are no longer needed.
  74. //
  75. // History: 28-Jul-97 SitaramR Created
  76. //
  77. //--------------------------------------------------------------------------
  78. class CDeletionLog
  79. {
  80. public:
  81. CDeletionLog( CFileIdMap& fileIdMap, CiCat& cicat );
  82. void FastInit( CiStorage * pStorage, ULONG version );
  83. void ReInit( ULONG version );
  84. void Flush();
  85. void MarkForDeletion( VOLUMEID volumeId,
  86. FILEID fileId,
  87. WORKID wid,
  88. USN usn );
  89. void ProcessChangesFlush( CUsnFlushInfoList & usnFlushInfoList );
  90. private:
  91. ULONG GetSize();
  92. void FatalCorruption( ULONG cbRead, ULONG cbToRead );
  93. CiCat& _cicat; // Ci catalog
  94. CFileIdMap & _fileIdMap; // File id map
  95. CFakeVolIdMap _fakeVolIdMap; // Real vol id to fake vol id map
  96. CDelLogEntryList _aDelLogEntryList[RTL_MAX_DRIVE_LETTERS]; // List of marked deletions
  97. XPtr<CDynStream> _xPersStream; // Persistent linearized deletion log
  98. CMutexSem _mutex; // Lock to serialize scan(flush) and usn threads
  99. };