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.

324 lines
9.0 KiB

  1. #ifndef _INC_DSKQUOTA_FSOBJECT_H
  2. #define _INC_DSKQUOTA_FSOBJECT_H
  3. ///////////////////////////////////////////////////////////////////////////////
  4. /* File: fsobject.h
  5. Description: Contains declarations for file system objects used in the
  6. quota management library. Abstractions are provided for NTFS
  7. volumes, directories and local/remote versions of both. The idea
  8. is to hide any peculiarities of these variations behind a common
  9. FSObject interface.
  10. The holder of a pointer to an FSObject can call the member functions
  11. IsLocal() and Type() to determine the exact type and locality of
  12. the object.
  13. Revision History:
  14. Date Description Programmer
  15. -------- --------------------------------------------------- ----------
  16. 05/22/96 Initial creation. BrianAu
  17. */
  18. ///////////////////////////////////////////////////////////////////////////////
  19. class FSObject
  20. {
  21. private:
  22. LONG m_cRef; // Instance ref counter.
  23. //
  24. // Prevent copy construction.
  25. //
  26. FSObject(const FSObject& obj);
  27. void operator = (const FSObject& obj);
  28. protected:
  29. CPath m_strFSObjName;
  30. DWORD m_dwAccessRights; // Access rights granted to client.
  31. // 0 = None.
  32. // GENERIC_READ = Read
  33. // GENRIC_READ | GENERIC_WRITE = Read/Write.
  34. static HRESULT HResultFromNtStatus(NTSTATUS status);
  35. public:
  36. //
  37. // Types of FS Objects.
  38. //
  39. enum { TypeUnknown, Volume, Directory };
  40. //
  41. // Flags used to indicate what data is to be updated in calls to
  42. // SetObjectQuotaInformation() and SetUserQuotaInformation().
  43. //
  44. enum {
  45. ChangeState = 0x01,
  46. ChangeLogFlags = 0x02,
  47. ChangeThreshold = 0x04,
  48. ChangeLimit = 0x08
  49. };
  50. FSObject(LPCTSTR pszObjName)
  51. : m_cRef(0),
  52. m_dwAccessRights(0),
  53. m_strFSObjName(pszObjName)
  54. { DBGTRACE((DM_CONTROL, DL_MID, TEXT("FSObject::FSObject"))); }
  55. virtual ~FSObject(void);
  56. ULONG AddRef(VOID);
  57. ULONG Release(VOID);
  58. //
  59. // Pure virtual interface for opening volume/directory.
  60. //
  61. virtual HRESULT Initialize(DWORD dwAccess) = 0;
  62. static HRESULT
  63. Create(
  64. LPCTSTR pszFSObjName,
  65. DWORD dwAccess,
  66. FSObject **ppNewObject);
  67. static HRESULT
  68. Create(
  69. const FSObject& obj,
  70. FSObject **ppNewObject);
  71. static HRESULT
  72. ObjectSupportsQuotas(
  73. LPCTSTR pszFSObjName);
  74. HRESULT GetName(LPTSTR pszBuffer, ULONG cchBuffer) const;
  75. virtual HRESULT QueryUserQuotaInformation(
  76. PVOID pBuffer,
  77. ULONG cBufferLength,
  78. BOOL bReturnSingleEntry,
  79. PVOID pSidList,
  80. ULONG cSidListLength,
  81. PSID pStartSid,
  82. BOOL bRestartScan
  83. ) = 0;
  84. virtual HRESULT SetUserQuotaInformation(
  85. PVOID pBuffer,
  86. ULONG cBufferLength
  87. ) const = 0;
  88. virtual HRESULT QueryObjectQuotaInformation(
  89. PDISKQUOTA_FSOBJECT_INFORMATION poi
  90. ) = 0;
  91. virtual HRESULT SetObjectQuotaInformation(
  92. PDISKQUOTA_FSOBJECT_INFORMATION poi,
  93. DWORD dwChangeMask
  94. ) const = 0;
  95. virtual BOOL IsLocal(VOID) const = 0;
  96. virtual UINT Type(VOID) const = 0;
  97. DWORD GetAccessRights(VOID) const
  98. { return m_dwAccessRights; }
  99. BOOL GrantedAccess(DWORD dwAccess) const
  100. { return (m_dwAccessRights & dwAccess) == dwAccess; }
  101. };
  102. class FSVolume : public FSObject
  103. {
  104. private:
  105. //
  106. // Prevent copying.
  107. //
  108. FSVolume(const FSVolume&);
  109. FSVolume& operator = (const FSVolume&);
  110. protected:
  111. HANDLE m_hVolume;
  112. public:
  113. FSVolume(LPCTSTR pszVolName)
  114. : FSObject(pszVolName),
  115. m_hVolume(INVALID_HANDLE_VALUE)
  116. { DBGTRACE((DM_CONTROL, DL_MID, TEXT("FSVolume::FSVolume"))); }
  117. virtual ~FSVolume(void);
  118. HRESULT Initialize(DWORD dwAccess);
  119. UINT Type(VOID) const
  120. { return FSObject::Volume; }
  121. virtual HRESULT QueryObjectQuotaInformation(
  122. PDISKQUOTA_FSOBJECT_INFORMATION poi
  123. );
  124. virtual HRESULT SetObjectQuotaInformation(
  125. PDISKQUOTA_FSOBJECT_INFORMATION poi,
  126. DWORD dwChangeMask
  127. ) const;
  128. virtual HRESULT QueryUserQuotaInformation(
  129. PVOID pBuffer,
  130. ULONG cBufferLength,
  131. BOOL bReturnSingleEntry,
  132. PVOID pSidList,
  133. ULONG cSidListLength,
  134. PSID pStartSid,
  135. BOOL bRestartScan
  136. );
  137. virtual HRESULT SetUserQuotaInformation(
  138. PVOID pBuffer,
  139. ULONG cBufferLength
  140. ) const;
  141. };
  142. class FSLocalVolume : public FSVolume
  143. {
  144. private:
  145. //
  146. // Prevent copying.
  147. //
  148. FSLocalVolume(const FSLocalVolume&);
  149. FSLocalVolume& operator = (const FSLocalVolume&);
  150. public:
  151. FSLocalVolume(LPCTSTR pszVolName)
  152. : FSVolume(pszVolName) { }
  153. BOOL IsLocal(VOID) const
  154. { return TRUE; }
  155. };
  156. HRESULT FSObject_CreateLocalVolume(LPCTSTR pszVolumeName, FSObject **ppObject);
  157. //
  158. // These next classes were originally designed when I thought we might
  159. // need a hierarchy of file system object "types". As it turns out,
  160. // we really only need FSVolume and FSLocalVolume. I'll leave these
  161. // in case the problem changes again sometime in the future. For now,
  162. // these are excluded from compilation. [brianau - 2/17/98]
  163. //
  164. #if 0
  165. /*
  166. class FSRemoteVolume : public FSVolume
  167. {
  168. private:
  169. //
  170. // Prevent copying.
  171. //
  172. FSRemoteVolume(const FSRemoteVolume&);
  173. void operator = (const FSRemoteVolume&);
  174. public:
  175. FSRemoteVolume(VOID)
  176. : FSVolume() { }
  177. BOOL IsLocal(VOID) const
  178. { return FALSE; }
  179. };
  180. class FSDirectory : public FSObject
  181. {
  182. private:
  183. //
  184. // Prevent copying.
  185. //
  186. FSDirectory(const FSDirectory&);
  187. void operator = (const FSDirectory&);
  188. protected:
  189. HANDLE m_hDirectory;
  190. public:
  191. FSDirectory(VOID)
  192. : FSObject(),
  193. m_hDirectory(NULL) { }
  194. HRESULT Initialize(DWORD dwAccess)
  195. { return E_NOTIMPL; }
  196. UINT Type(VOID) const
  197. { return FSObject::Directory; }
  198. virtual HRESULT QueryObjectQuotaInformation(
  199. PDISKQUOTA_FSOBJECT_INFORMATION poi
  200. ) { return E_NOTIMPL; }
  201. virtual HRESULT SetObjectQuotaInformation(
  202. PDISKQUOTA_FSOBJECT_INFORMATION poi,
  203. DWORD dwChangeMask
  204. ) const { return E_NOTIMPL; }
  205. virtual HRESULT QueryUserQuotaInformation(
  206. PVOID pUserInfoBuffer,
  207. ULONG uBufferLength,
  208. BOOL bReturnSingleEntry,
  209. PVOID pSidList,
  210. ULONG uSidListLength,
  211. PSID pStartSid,
  212. BOOL bRestartScan
  213. ) { return E_NOTIMPL; }
  214. virtual HRESULT SetUserQuotaInformation(
  215. PVOID pUserInfoBuffer,
  216. ULONG uBufferLength
  217. ) const { return E_NOTIMPL; }
  218. };
  219. class FSLocalDirectory : public FSDirectory
  220. {
  221. private:
  222. //
  223. // Prevent copying.
  224. //
  225. FSLocalDirectory(const FSLocalDirectory&);
  226. void operator = (const FSLocalDirectory&);
  227. public:
  228. FSLocalDirectory(VOID)
  229. : FSDirectory() { }
  230. BOOL IsLocal(VOID) const
  231. { return TRUE; }
  232. };
  233. class FSRemoteDirectory : public FSDirectory
  234. {
  235. private:
  236. //
  237. // Prevent copying.
  238. //
  239. FSRemoteDirectory(const FSRemoteDirectory&);
  240. void operator = (const FSRemoteDirectory&);
  241. public:
  242. FSRemoteDirectory(VOID)
  243. : FSDirectory() { }
  244. BOOL IsLocal(VOID) const
  245. { return FALSE; }
  246. };
  247. */
  248. #endif // #if 0
  249. #endif // DISKQUOTA_FSOBJECT_H