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.

357 lines
12 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Abstract:
  4. @doc
  5. @module commandverifier.cpp | definition for the command verifier
  6. @end
  7. Author:
  8. Reuven Lax [reuvenl] 11/20/2001
  9. Revision History:
  10. Name Date Comments
  11. reuvenl 11/20/2001 Created
  12. --*/
  13. #include "vssadmin.h"
  14. #include "commandverifier.h"
  15. ////////////////////////////////////////////////////////////////////////
  16. // Standard foo for file name aliasing. This code block must be after
  17. // all includes of VSS header files.
  18. //
  19. #ifdef VSS_FILE_ALIAS
  20. #undef VSS_FILE_ALIAS
  21. #endif
  22. #define VSS_FILE_ALIAS "ADMVERFR"
  23. //
  24. ////////////////////////////////////////////////////////////////////////
  25. #define VSSADM_ONE_MB ( 1024 * 1024 )
  26. #define VSSADM_HUNDRED_MB (100 * VSSADM_ONE_MB)
  27. ////////////////////////////////////////////////////////////////////////
  28. // Implementation of the CInternalVerifier class
  29. void CInternalVerifier::CreateSnapshot (long type, LPCWSTR forVolume, VSS_ID idProvider, ULONGLONG autoRetry,
  30. CVssFunctionTracer& ft)
  31. {
  32. UNREFERENCED_PARAMETER(type);
  33. UNREFERENCED_PARAMETER(idProvider);
  34. UNREFERENCED_PARAMETER(autoRetry);
  35. UNREFERENCED_PARAMETER(ft);
  36. UNREFERENCED_PARAMETER(forVolume);
  37. BS_ASSERT (forVolume != NULL);
  38. }
  39. void CInternalVerifier::ListProviders (CVssFunctionTracer& ft)
  40. {
  41. UNREFERENCED_PARAMETER(ft);
  42. }
  43. void CInternalVerifier::ListSnapshots (long type, VSS_ID idProvider, LPCWSTR forVolume, VSS_ID idShadow, VSS_ID idSet,
  44. CVssFunctionTracer& ft)
  45. {
  46. UNREFERENCED_PARAMETER(type);
  47. UNREFERENCED_PARAMETER(idProvider);
  48. if (!::IsEqualGUID (idShadow, GUID_NULL) && !::IsEqualGUID (idSet, GUID_NULL)) {
  49. ft.Throw( VSSDBG_VSSADMIN, VSSADM_E_INVALID_SET_OF_OPTIONS,
  50. L"CVssAdminCLI::ListSnapshots: Cannot specify both /Set and /Shadow options at the same time" );
  51. }
  52. if (forVolume != NULL && wcslen(forVolume) > x_nLengthOfVolMgmtVolumeName) {
  53. ft.Throw(VSSDBG_VSSADMIN, VSSADM_E_INVALID_OPTION_VALUE,
  54. L"CVssAdminCLI::ListSnapshots: Must specify a valid volume name for list snapshots");
  55. }
  56. }
  57. void CInternalVerifier::ListWriters (CVssFunctionTracer& ft)
  58. {
  59. UNREFERENCED_PARAMETER(ft);
  60. }
  61. void CInternalVerifier::AddDiffArea (VSS_ID idProvider, LPCWSTR forVolume, LPCWSTR onVolume, ULONGLONG maxSize,
  62. CVssFunctionTracer& ft)
  63. {
  64. UNREFERENCED_PARAMETER(idProvider);
  65. UNREFERENCED_PARAMETER(forVolume);
  66. UNREFERENCED_PARAMETER(onVolume);
  67. BS_ASSERT (forVolume != NULL);
  68. BS_ASSERT (onVolume != NULL);
  69. if (maxSize < VSSADM_ONE_MB) {
  70. ft.Throw( VSSDBG_VSSADMIN, VSSADM_E_INVALID_NUMBER,
  71. L"CVssAdminCLI::AddDiffarea: A maxsize of less than 1 MB specified, invalid");
  72. }
  73. }
  74. void CInternalVerifier::ResizeDiffArea (VSS_ID idProvider, LPCWSTR forVolume, LPCWSTR onVolume, ULONGLONG maxSize,
  75. CVssFunctionTracer& ft)
  76. {
  77. UNREFERENCED_PARAMETER(idProvider);
  78. UNREFERENCED_PARAMETER(forVolume);
  79. UNREFERENCED_PARAMETER(onVolume);
  80. BS_ASSERT (forVolume != NULL);
  81. BS_ASSERT (onVolume != NULL);
  82. if (maxSize < VSSADM_ONE_MB) {
  83. ft.Throw( VSSDBG_VSSADMIN, VSSADM_E_INVALID_NUMBER,
  84. L"CVssAdminCLI::ResizeDiffarea: maxsize of less than 1 MB specified, invalid");
  85. }
  86. }
  87. void CInternalVerifier::DeleteDiffAreas (VSS_ID idProvider, LPCWSTR forVolume, LPCWSTR onVolume, bool quiet,
  88. CVssFunctionTracer& ft)
  89. {
  90. UNREFERENCED_PARAMETER(idProvider);
  91. UNREFERENCED_PARAMETER(onVolume);
  92. UNREFERENCED_PARAMETER(forVolume);
  93. UNREFERENCED_PARAMETER(quiet);
  94. UNREFERENCED_PARAMETER(ft);
  95. BS_ASSERT (forVolume != NULL);
  96. }
  97. void CInternalVerifier::ListDiffAreas (VSS_ID idProvider, LPCWSTR forVolume, LPCWSTR onVolume,
  98. CVssFunctionTracer& ft)
  99. {
  100. UNREFERENCED_PARAMETER(idProvider);
  101. if ((forVolume != NULL) && (onVolume != NULL)) {
  102. ft.Throw( VSSDBG_VSSADMIN, VSSADM_E_INVALID_SET_OF_OPTIONS,
  103. L"CVssAdminCLI::ListDiffAreas: Can't specify both ON and FOR volume options" );
  104. }
  105. }
  106. void CInternalVerifier::DeleteSnapshots (long type, LPCWSTR forVolume, bool all, bool oldest, VSS_ID idShadow, bool quiet,
  107. CVssFunctionTracer& ft)
  108. {
  109. UNREFERENCED_PARAMETER(quiet);
  110. if (!::IsEqualGUID (idShadow, GUID_NULL)) {
  111. if (forVolume != NULL || type != VSS_CTX_ALL || oldest || all) {
  112. ft.Throw( VSSDBG_VSSADMIN, VSSADM_E_INVALID_SET_OF_OPTIONS,
  113. L"CVssAdminCLI::DeleteSnapshots: Invalid set of options" );
  114. }
  115. } else {
  116. if ((forVolume == NULL && type == VSS_CTX_ALL && !all && !oldest) ||
  117. (type != VSS_CTX_ALL && forVolume == NULL) ||
  118. (oldest && forVolume == NULL)) {
  119. ft.Throw( VSSDBG_VSSADMIN, VSSADM_E_REQUIRED_OPTION_MISSING,
  120. L"CVssAdminCLI::DeleteSnapshots: Required option missing" );
  121. }
  122. if ((type != VSS_CTX_ALL && all) ||
  123. (all && oldest)) {
  124. ft.Throw (VSSDBG_VSSADMIN, VSSADM_E_INVALID_SET_OF_OPTIONS,
  125. L"CVssAdminCLI::DeleteSnapshots: Invalid set of options:");
  126. }
  127. }
  128. if (forVolume != NULL && wcslen(forVolume) > x_nLengthOfVolMgmtVolumeName) {
  129. ft.Throw(VSSDBG_VSSADMIN, VSSADM_E_INVALID_OPTION_VALUE,
  130. L"CVssAdminCLI::DeleteSnapshots: invalid volume name");
  131. }
  132. }
  133. void CInternalVerifier::ExposeSnapshot (VSS_ID idShadow, LPCWSTR exposeUsing, LPCWSTR sharePath, bool locally,
  134. CVssFunctionTracer& ft)
  135. {
  136. UNREFERENCED_PARAMETER(idShadow);
  137. UNREFERENCED_PARAMETER(exposeUsing);
  138. BS_ASSERT (!locally || (::wcslen(exposeUsing) >= 2 && exposeUsing[1] == L':' ));
  139. if (locally && sharePath != NULL) {
  140. ft.Throw( VSSDBG_VSSADMIN, VSSADM_E_INVALID_SET_OF_OPTIONS,
  141. L"CVssAdminCLI::ExposeSnapshot: Specified a ShareUsing option with an expose locally command" );
  142. }
  143. if (sharePath != NULL && sharePath[0] != L'\\') {
  144. ft.Throw( VSSDBG_VSSADMIN, VSSADM_E_INVALID_OPTION_VALUE,
  145. L"CVssAdminCLI::ExposeSnapshot: Specified SharePath doesn't start with '\\'" );
  146. }
  147. }
  148. void CInternalVerifier::ListVolumes (VSS_ID idProvider, long type, CVssFunctionTracer& ft)
  149. {
  150. UNREFERENCED_PARAMETER(idProvider);
  151. UNREFERENCED_PARAMETER(type);
  152. UNREFERENCED_PARAMETER(ft);
  153. }
  154. ////////////////////////////////////////////////////////////////////////
  155. // Implementation of the CExternalVerifier class
  156. void CExternalVerifier::CreateSnapshot (long type, LPCWSTR forVolume, VSS_ID idProvider, ULONGLONG autoRetry,
  157. CVssFunctionTracer& ft)
  158. {
  159. UNREFERENCED_PARAMETER(type);
  160. UNREFERENCED_PARAMETER(forVolume);
  161. UNREFERENCED_PARAMETER(idProvider);
  162. UNREFERENCED_PARAMETER(autoRetry);
  163. UNREFERENCED_PARAMETER(ft);
  164. BS_ASSERT (forVolume != NULL);
  165. BS_ASSERT (type == VSS_CTX_CLIENT_ACCESSIBLE);
  166. BS_ASSERT (::IsEqualGUID (idProvider, VSS_SWPRV_ProviderId));
  167. }
  168. void CExternalVerifier::ListProviders (CVssFunctionTracer& ft)
  169. {
  170. UNREFERENCED_PARAMETER(ft);
  171. }
  172. void CExternalVerifier::ListSnapshots (long type, VSS_ID idProvider, LPCWSTR forVolume, VSS_ID idShadow, VSS_ID idSet,
  173. CVssFunctionTracer& ft)
  174. {
  175. UNREFERENCED_PARAMETER(type);
  176. UNREFERENCED_PARAMETER(idProvider);
  177. BS_ASSERT (type == VSS_CTX_ALL);
  178. BS_ASSERT (::IsEqualGUID (idProvider, VSS_SWPRV_ProviderId));
  179. if (!::IsEqualGUID (idShadow, GUID_NULL) && !::IsEqualGUID (idSet, GUID_NULL)) {
  180. ft.Throw( VSSDBG_VSSADMIN, VSSADM_E_INVALID_SET_OF_OPTIONS,
  181. L"CVssAdminCLI::ListSnapshots: Cannot specify both /Set and /Shadow options at the same time" );
  182. }
  183. if (forVolume != NULL && wcslen(forVolume) > x_nLengthOfVolMgmtVolumeName) {
  184. ft.Throw(VSSDBG_VSSADMIN, VSSADM_E_INVALID_OPTION_VALUE,
  185. L"CVssAdminCLI::ListSnapshots: Must specify a valid volume name for list snapshots");
  186. }
  187. }
  188. void CExternalVerifier::ListWriters (CVssFunctionTracer& ft)
  189. {
  190. UNREFERENCED_PARAMETER(ft);
  191. }
  192. void CExternalVerifier::AddDiffArea (VSS_ID idProvider, LPCWSTR forVolume, LPCWSTR onVolume, ULONGLONG maxSize,
  193. CVssFunctionTracer& ft)
  194. {
  195. UNREFERENCED_PARAMETER(idProvider);
  196. UNREFERENCED_PARAMETER(forVolume);
  197. UNREFERENCED_PARAMETER(onVolume);
  198. BS_ASSERT (::IsEqualGUID (idProvider, VSS_SWPRV_ProviderId));
  199. BS_ASSERT (forVolume != NULL);
  200. BS_ASSERT (onVolume != NULL);
  201. if (maxSize < VSSADM_HUNDRED_MB) {
  202. ft.Throw( VSSDBG_VSSADMIN, VSSADM_E_INVALID_NUMBER,
  203. L"CVssAdminCLI::AddDiffarea: A maxsize of less than 100 MB specified, invalid");
  204. }
  205. }
  206. void CExternalVerifier::ResizeDiffArea (VSS_ID idProvider, LPCWSTR forVolume, LPCWSTR onVolume, ULONGLONG maxSize,
  207. CVssFunctionTracer& ft)
  208. {
  209. UNREFERENCED_PARAMETER(idProvider);
  210. UNREFERENCED_PARAMETER(forVolume);
  211. UNREFERENCED_PARAMETER(onVolume);
  212. BS_ASSERT (::IsEqualGUID (idProvider, VSS_SWPRV_ProviderId));
  213. BS_ASSERT (forVolume != NULL);
  214. BS_ASSERT (onVolume != NULL);
  215. if (maxSize < VSSADM_HUNDRED_MB) {
  216. ft.Throw( VSSDBG_VSSADMIN, VSSADM_E_INVALID_NUMBER,
  217. L"CVssAdminCLI::ResizeDiffarea: maxsize of less than 100 MB specified, invalid");
  218. }
  219. }
  220. void CExternalVerifier::DeleteDiffAreas (VSS_ID idProvider, LPCWSTR forVolume, LPCWSTR onVolume, bool quiet,
  221. CVssFunctionTracer& ft)
  222. {
  223. UNREFERENCED_PARAMETER(idProvider);
  224. UNREFERENCED_PARAMETER(forVolume);
  225. UNREFERENCED_PARAMETER(onVolume);
  226. UNREFERENCED_PARAMETER(quiet);
  227. UNREFERENCED_PARAMETER(ft);
  228. BS_ASSERT (::IsEqualGUID (idProvider, VSS_SWPRV_ProviderId));
  229. BS_ASSERT (forVolume != NULL);
  230. }
  231. void CExternalVerifier::ListDiffAreas (VSS_ID idProvider, LPCWSTR forVolume, LPCWSTR onVolume,
  232. CVssFunctionTracer& ft)
  233. {
  234. UNREFERENCED_PARAMETER(idProvider);
  235. BS_ASSERT (::IsEqualGUID (idProvider, VSS_SWPRV_ProviderId));
  236. if ((forVolume != NULL) && (onVolume != NULL)) {
  237. ft.Throw( VSSDBG_VSSADMIN, VSSADM_E_INVALID_SET_OF_OPTIONS,
  238. L"CVssAdminCLI::ListDiffAreas: Can't specify both ON and FOR volume options" );
  239. }
  240. }
  241. void CExternalVerifier::DeleteSnapshots (long type, LPCWSTR forVolume, bool all, bool oldest, VSS_ID idShadow, bool quiet,
  242. CVssFunctionTracer& ft)
  243. {
  244. UNREFERENCED_PARAMETER(type);
  245. UNREFERENCED_PARAMETER(quiet);
  246. BS_ASSERT (type == VSS_CTX_CLIENT_ACCESSIBLE);
  247. if (!::IsEqualGUID (idShadow, GUID_NULL)) {
  248. if (forVolume != NULL || all || oldest) {
  249. ft.Throw( VSSDBG_VSSADMIN, VSSADM_E_INVALID_SET_OF_OPTIONS,
  250. L"CVssAdminCLI::DeleteSnapshots: Invalid set of options" );
  251. }
  252. } else {
  253. if ( (forVolume == NULL && !all && !oldest) ||
  254. (oldest && forVolume == NULL)) {
  255. ft.Throw( VSSDBG_VSSADMIN, VSSADM_E_REQUIRED_OPTION_MISSING,
  256. L"CVssAdminCLI::DeleteSnapshots: Required option missing" );
  257. }
  258. if (all && oldest) {
  259. ft.Throw(VSSDBG_VSSADMIN, VSSADM_E_INVALID_SET_OF_OPTIONS,
  260. L"CVssAdminCLI::DeleteSnapshots: Invalid set of options");
  261. }
  262. }
  263. if (forVolume != NULL && wcslen(forVolume) > x_nLengthOfVolMgmtVolumeName) {
  264. ft.Throw(VSSDBG_VSSADMIN, VSSADM_E_INVALID_OPTION_VALUE,
  265. L"CVssAdminCLI::DeleteSnapshots: invalid volume name");
  266. }
  267. }
  268. void CExternalVerifier::ExposeSnapshot (VSS_ID idShadow, LPCWSTR exposeUsing, LPCWSTR sharePath,
  269. bool locally, CVssFunctionTracer& ft)
  270. {
  271. UNREFERENCED_PARAMETER(idShadow);
  272. UNREFERENCED_PARAMETER(exposeUsing);
  273. UNREFERENCED_PARAMETER(sharePath);
  274. UNREFERENCED_PARAMETER(locally);
  275. UNREFERENCED_PARAMETER(ft);
  276. BS_ASSERT (false);
  277. }
  278. void CExternalVerifier::ListVolumes (VSS_ID idProvider, long type, CVssFunctionTracer& ft)
  279. {
  280. UNREFERENCED_PARAMETER(idProvider);
  281. UNREFERENCED_PARAMETER(type);
  282. UNREFERENCED_PARAMETER(ft);
  283. BS_ASSERT (::IsEqualGUID (idProvider, VSS_SWPRV_ProviderId));
  284. BS_ASSERT (type == VSS_CTX_CLIENT_ACCESSIBLE);
  285. }