Leaked source code of windows server 2003
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.

214 lines
6.0 KiB

  1. /******************************************************************************
  2. *
  3. * Copyright (c) 2000 Microsoft Corporation
  4. *
  5. * Module Name:
  6. * datastor.h
  7. *
  8. * Abstract:
  9. * CDataStore class definition
  10. *
  11. * Revision History:
  12. * Brijesh Krishnaswami (brijeshk) 03/17/2000
  13. * created
  14. *
  15. *****************************************************************************/
  16. #ifndef _DATASTOR_H_
  17. #define _DATASTOR_H_
  18. #include <nt.h>
  19. #include <ntrtl.h>
  20. #include <nturtl.h>
  21. #include <windows.h>
  22. #include <dbgtrace.h>
  23. #include "srdefs.h"
  24. #include "utils.h"
  25. #include "enumlogs.h"
  26. //
  27. // Note: NTFS does not support volume compression,
  28. // but only compression on individual files and directories
  29. // So SR_DRIVE_COMPRESSED is not supported for FAT or NTFS
  30. //
  31. #define SR_DRIVE_ACTIVE 0x01
  32. #define SR_DRIVE_SYSTEM 0x02
  33. #define SR_DRIVE_COMPRESSED 0x04
  34. #define SR_DRIVE_MONITORED 0x08
  35. #define SR_DRIVE_NTFS 0x10
  36. #define SR_DRIVE_PARTICIPATE 0x20
  37. #define SR_DRIVE_FROZEN 0x40
  38. #define SR_DRIVE_READONLY 0x80
  39. #define SR_DRIVE_ERROR 0x100
  40. class CDriveTable;
  41. //+-------------------------------------------------------------------------
  42. //
  43. // Class: CDataStore
  44. //
  45. // Synopsis: maintains and operates on a drive's _restore directory
  46. //
  47. // History: 13-Apr-2000 BrijeshK Created
  48. //
  49. //--------------------------------------------------------------------------
  50. class CDataStore : public CSRAlloc
  51. {
  52. public:
  53. // constants
  54. enum { LABEL_STRLEN = 256 }; // On NTFS, you can have long volume labels
  55. CDataStore(CDriveTable *pdt);
  56. ~CDataStore();
  57. DWORD LoadDataStore (WCHAR *pwszDrive,
  58. WCHAR *pwszGuid,
  59. WCHAR *pwszLabel,
  60. DWORD dwFlags,
  61. int iChangeLogs,
  62. INT64 llSizeLimit);
  63. WCHAR * GetDrive() // return the drive letter or mount point
  64. {
  65. return _pwszDrive;
  66. }
  67. WCHAR * GetNTName(); // return the NT object name
  68. WCHAR * GetLabel() // return the volume label
  69. {
  70. return _pwszLabel;
  71. }
  72. WCHAR * GetGuid () // return the mount mananger GUID
  73. {
  74. return _pwszGuid;
  75. }
  76. DWORD GetFlags () // return the status bits
  77. {
  78. return _dwFlags;
  79. }
  80. int GetNumChangeLogs () // number of change logs
  81. {
  82. return _iChangeLogs;
  83. }
  84. DWORD SetNumChangeLogs (LONG_PTR iChangeLogs) // number of change logs
  85. {
  86. _iChangeLogs = (int) iChangeLogs;
  87. return DirtyDriveTable();
  88. }
  89. void SetDrive (WCHAR *pwszDrive) // for drive renames
  90. {
  91. lstrcpyW (_pwszDrive, pwszDrive);
  92. }
  93. INT64 GetSizeLimit ()
  94. {
  95. return _llDataStoreSizeBytes;
  96. }
  97. void SetSizeLimit (INT64 llSizeLimit)
  98. {
  99. _llDataStoreSizeBytes = llSizeLimit;
  100. }
  101. INT64 GetDiskFree()
  102. {
  103. return _llDiskFreeBytes;
  104. }
  105. DWORD DirtyDriveTable ();
  106. DWORD Initialize(WCHAR *pwszDrive, WCHAR *pwszGuid);
  107. DWORD UpdateDataStoreUsage(INT64 llDelta, BOOL fCurrent);
  108. DWORD GetUsagePercent(int * nPercent);
  109. DWORD UpdateDiskFree(LONG_PTR lReserved);
  110. DWORD UpdateParticipate(LONG_PTR pwszDir);
  111. //
  112. // The methods can be callbacks in CDriveTable::ForAllDrives
  113. //
  114. DWORD SetActive (LONG_PTR fActive) // BOOL fActive
  115. {
  116. if (FALSE == fActive)
  117. _dwFlags &= ~SR_DRIVE_ACTIVE;
  118. else
  119. _dwFlags |= SR_DRIVE_ACTIVE;
  120. return DirtyDriveTable();
  121. }
  122. DWORD SetParticipate (LONG_PTR fParticipate) // BOOL fParticipate
  123. {
  124. if (FALSE == fParticipate)
  125. _dwFlags &= ~SR_DRIVE_PARTICIPATE;
  126. else
  127. _dwFlags |= SR_DRIVE_PARTICIPATE;
  128. return DirtyDriveTable();
  129. }
  130. DWORD SetError (LONG_PTR lReserved) // BOOL fParticipate
  131. {
  132. _dwFlags |= SR_DRIVE_ERROR;
  133. return DirtyDriveTable();
  134. }
  135. DWORD ResetFlags (LONG_PTR lReserved) // reset flags for new restore point
  136. {
  137. _iChangeLogs = 0;
  138. _dwFlags &= ~SR_DRIVE_PARTICIPATE;
  139. _dwFlags &= ~SR_DRIVE_ERROR;
  140. return DirtyDriveTable();
  141. }
  142. DWORD SaveDataStore (LONG_PTR hFile); // HANDLE hFile
  143. DWORD MonitorDrive (LONG_PTR fSet); // BOOL fSet
  144. DWORD FreezeDrive (LONG_PTR lReserved);
  145. DWORD ThawDrive (LONG_PTR fCheckOnly); // BOOL fCheckOnly
  146. DWORD CreateDataStore (LONG_PTR lReserved);
  147. DWORD DestroyDataStore (LONG_PTR fDeleteDir); // BOOL fDeleteDir
  148. DWORD CalculateDataStoreUsage(LONG_PTR lReserved);
  149. DWORD CalculateRpUsage(CRestorePoint * prp,
  150. INT64 * pllSize,
  151. BOOL fForce,
  152. BOOL fSnapshotOnly);
  153. DWORD Compress (INT64 llAllocatedTime, INT64 *pllUsed);
  154. DWORD FifoRestorePoint(CRestorePoint &rp);
  155. DWORD CountChangeLogs (LONG_PTR pRestorePoint);
  156. DWORD SwitchRestorePoint(LONG_PTR pRestorePoint);
  157. DWORD GetVolumeInfo ();
  158. BOOL IsVolumeDeleted ();
  159. DWORD Print(LONG_PTR lptr);
  160. private:
  161. CDriveTable * _pdt; // parent drive table
  162. int _iChangeLogs; // number of change logs
  163. // variables
  164. INT64 _llDataStoreSizeBytes; // maximum data store size
  165. INT64 _llDiskFreeBytes; // dynamic free space
  166. INT64 _llDataStoreUsageBytes; // non-current restore point usage
  167. INT64 _llCurrentRpUsageBytes; // current restore point usage
  168. CRestorePointEnum * _prpe; // enum restore point to compress
  169. CRestorePoint * _prp; // current restore point to compress
  170. WCHAR _pwszDrive[MAX_PATH]; // logical DOS device name
  171. WCHAR _pwszLabel[LABEL_STRLEN]; // volume label
  172. WCHAR _pwszGuid[GUID_STRLEN]; // mount manager volume name
  173. WORD _dwFlags; // volume flags
  174. };
  175. #endif