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.

427 lines
16 KiB

  1. /*++
  2. Copyright (c) 1997-1999 Microsoft Corporation
  3. Module Name:
  4. frserror.h
  5. Abstract:
  6. This header defines functions, messages and status codes for error
  7. processing.
  8. Author:
  9. David Orbits (davidor) - 10-Mar-1997
  10. Revision History:
  11. --*/
  12. #ifndef _FRSERROR_
  13. #define _FRSERROR_
  14. #define bugbug(_text_)
  15. #define bugmor(_text_)
  16. //
  17. // get the jet (aka ESENT) error codes.
  18. //
  19. #include <jet.h>
  20. //
  21. // FRS Error Codes
  22. //
  23. typedef enum _FRS_ERROR_SEVERITY {
  24. FrsSeverityServiceFatal = 0, // FRS Service is crashing.
  25. FrsSeverityReplicaFatal, // Service on just this replica set is stopping.
  26. FrsSeverityException, // More than a warning but less than fatal
  27. FrsSeverityWarning, // Warning errors e.g. Startup check failed doing verification.
  28. FrsSeverityInfo, // Informational status only
  29. FrsSeverityIgnore, // A way to filter out a class of jet errors.
  30. FRS_MAX_ERROR_SEVERITY
  31. } FRS_ERROR_SEVERITY;
  32. typedef enum _FRS_ERROR_CODE {
  33. FrsErrorSuccess = 0,
  34. FrsErrorDiskSpace, // out of disk space
  35. FrsErrorDatabaseNotFound, // no db or path to db is in error
  36. FrsErrorDatabaseCorrupted, // not a db or a scrambled db
  37. FrsErrorInternalError, // unexpected error occurred - catchall
  38. FrsErrorAccess, // couldn't access a file or the db
  39. FrsErrorNotFound, // Record or table not found.
  40. FrsErrorConflict, // Record or table create conflict
  41. FrsErrorResource, // Resource limit e.g. handles or memory hit.
  42. FrsErrorBadParam, // Bad parameter to a function.
  43. FrsErrorInfo, // informational error, e.g. JET_errObjectNotFound
  44. FrsErrorVvRevision, // Vers Vector revision mismatch
  45. FrsErrorVvLength, // vers vector length mismatch
  46. FrsErrorVvChecksum, // version vector checksum mismatch.
  47. FrsErrorEndOfTable, // No next record, end of table hit.
  48. FrsErrorInvalidRegistryParam, // Invalid registry parameter
  49. FrsErrorNoPrivileges, // Couldn't get the necessary privileges to run.
  50. FrsErrorNoOpenJournals, // Can't start replication because no journals were opened.
  51. FrsErrorCmdPktTimeOut, // Command packet timeout.
  52. FrsErrorInvalidHandle, // Invalid File Handle.
  53. FrsErrorInvalidOperation, // Invalid operation requested.
  54. FrsErrorInvalidChangeOrder, // Invalid change order.
  55. FrsErrorResourceInUse, // A resource required by this operation is in use.
  56. FrsErrorBufferOverflow, // Buffer overflow NTSTATUS.
  57. FrsErrorNotInitialized, // Function called without proper initialization
  58. FrsErrorReplicaPhase1Failed,// Phase 1 of replica set init failed.
  59. FrsErrorReplicaPhase2Failed,// Phase 2 of replica set init failed.
  60. FrsErrorJournalStateWrong, // The journal is in an unexpected state.
  61. FrsErrorJournalInitFailed, // The NTFS journal failed to initialize.
  62. FrsErrorJournalStartFailed, // The NTFS journal failed to start.
  63. FrsErrorJournalPauseFailed, // The NTFS journal failed to Pause, could be timeout.
  64. FrsErrorJournalReplicaStop, // Failed to detatch the replica from The journal.
  65. FrsErrorJournalWrapError, // Initial NTFS journal record not present. Journal has wrapped.
  66. FrsErrorChgOrderAbort, // Change order processing has been aborted.
  67. FrsErrorQueueIsRundown, // The request queue has been rundown.
  68. FrsErrorMoreWork, // There is more work to do on this command / operation.
  69. FrsErrorDampened, // This request is suppressed because it has already been seen.
  70. FrsErrorStageFileDelFailed, // An attempt to delete the staging file failed.
  71. FrsErrorKeyDuplicate, // An attempt to insert a record with a duplicate key
  72. FrsErrorBadOutLogPartnerData, // Either the data was corrupt, unavail or was wrong.
  73. FrsErrorPartnerActivateFailed, // Failed to activate an outbound partner.
  74. FrsErrorDirCreateFailed, // We failed to create a new DIR. This stops repl.
  75. FrsErrorSessionNotClosed, // Failed to close all RtCtx's in replica set.
  76. FrsErrorRecordLocked, // The record being accessed is locked.
  77. FrsErrorDeleteRequested, // Enum function status return to delete entry.
  78. FrsErrorTerminateEnum, // Enum function status return to end enumeration.
  79. FrsErrorIdtFileIsDeleted, // File is marked deleted in IDTable.
  80. FrsErrorVVSlotNotFound, // VVSlot not found on VVretire of Out of Order CO.
  81. FrsErrorJetSecIndexCorrupted, // Jet (upgrade, collating, jet err -1414)
  82. FrsErrorPreInstallDirectory, // creating preinstall directory
  83. FrsErrorUnjoining, // cxtion is still unjoining
  84. FrsErrorNameMorphConflict, // File name morph conflict was detected.
  85. FrsErrorInvalidGuid, // The generated Guid is missing the net address.
  86. FrsErrorDbWriteConflict, // DB update conflict if two sessions try to update the same record.
  87. FrsErrorCantMoveOut, // Request for a Moveout of a non-empty directory failed.
  88. FrsErrorFoundKey, // The Key being searched by QHashEnumerateTable was found
  89. FrsErrorTunnelConflict, // oid conflict with id table entry (resolved)
  90. FrsErrorTunnelConflictRejectCO, // oid conflict with id table entry (CO rejected)
  91. FrsErrorPrepareRoot, // Could not prepare the root dir for replication, bad path? share viol?
  92. FrsErrorCmdSrvFailed, // A command server request failed to get submitted
  93. FrsErrorPreinstallCreFail, // Failed to create the pre-install dir.
  94. FrsErrorStageDirOpenFail, // Failed to open the staging dir.
  95. FrsErrorReplicaRootDirOpenFail, // Failed to open the replica tree root dir.
  96. FrsErrorShuttingDown, // Shutdown in progress.
  97. FrsErrorReplicaSetTombstoned, // Replica set is marked for deletion.
  98. FrsErrorVolumeRootDirOpenFail, // Failed to open the volume root directory for this replica set
  99. FrsErrorUnsupportedFileSystem, // The file system on this volume does provide the features required by FRS.
  100. FrsErrorBadPathname, // ERROR_BAD_PATHNAME
  101. FrsErrorFileExists, // ERROR_FILE_EXISTS
  102. FrsErrorSharingViolation, // ERROR_SHARING_VIOLATION
  103. FrsErrorDirNotEmpty, // ERROR_DIR_NOT_EMPTY
  104. FrsErrorOplockNotGranted, // ERROR_OPLOCK_NOT_GRANTED
  105. FrsErrorRetry, // ERROR_RETRY
  106. FrsErrorRequestCancelled, // ERROR_OPERATION_ABORTED
  107. FRS_ERROR_LISTEN,
  108. FRS_ERROR_REGISTEREP,
  109. FRS_ERROR_REGISTERIF,
  110. FRS_ERROR_INQ_BINDINGS,
  111. FRS_ERROR_PROTSEQ,
  112. //
  113. // New error codes that trigger a non_auth restore.
  114. //
  115. FrsErrorMismatchedVolumeSerialNumber, // The Volume serial number from DB does not match the one from FileSystem.
  116. FrsErrorMismatchedReplicaRootObjectId, // The Replica root's ObjectID from DB does not match the one from FileSystem.
  117. FrsErrorMismatchedReplicaRootFileId, // The Replica root's FID from DB does not match the one from FileSystem.
  118. FrsErrorMismatchedJournalId, // The Journal ID from DB does not match the one from FileSystem.
  119. // Added in QFE after Win2K SP3.
  120. FrsErrorIdtFileIsDeleteDef, // File is marked delete deferred in IDTable.
  121. FRS_MAX_ERROR_CODE
  122. } FRS_ERROR_CODE;
  123. //
  124. // Useful WIN32 STATUS defines
  125. //
  126. #define WIN_SUCCESS(_Status) ((_Status) == ERROR_SUCCESS)
  127. #define WIN_NOT_IMPLEMENTED(_Status) ((_Status) == ERROR_INVALID_FUNCTION)
  128. #define WIN_ACCESS_DENIED(_Status) ((_Status) == ERROR_ACCESS_DENIED)
  129. #define WIN_INVALID_PARAMETER(_Status) ((_Status) == ERROR_INVALID_PARAMETER)
  130. #define WIN_DIR_NOT_EMPTY(_Status) ((_Status) == ERROR_DIR_NOT_EMPTY)
  131. #define WIN_BAD_PATH(_Status) ((_Status) == ERROR_BAD_PATHNAME)
  132. #define WIN_BUF_TOO_SMALL(_Status) (((_Status) == ERROR_MORE_DATA) || \
  133. ((_Status) == ERROR_INSUFFICIENT_BUFFER))
  134. #define RPC_SUCCESS(_Status) ((_Status) == RPC_S_OK)
  135. //
  136. // Returned when rename fails because the target name is taken
  137. //
  138. #define WIN_ALREADY_EXISTS(_Status) ((_Status) == ERROR_ALREADY_EXISTS)
  139. //
  140. // Returned when getting the object id
  141. //
  142. #define WIN_OID_NOT_PRESENT(_Status) ((_Status) == ERROR_FILE_NOT_FOUND)
  143. //
  144. // Oid, Fid, or relative path not found
  145. //
  146. // Fid not found is ERROR_INVALID_PARAMETER
  147. // Oid not found is ERROR_FILE_NOT_FOUND
  148. // Path not found is ERROR_FILE_NOT_FOUND
  149. //
  150. // A new error ERROR_DELETE_PENDING was added on 11/01/2000. Now STATUS_DELETE_PENDING
  151. // maps to this new error.
  152. //
  153. #define WIN_NOT_FOUND(_Status) ((_Status) == ERROR_FILE_NOT_FOUND || \
  154. (_Status) == ERROR_DELETE_PENDING || \
  155. (_Status) == ERROR_INVALID_PARAMETER)
  156. #define NT_NOT_FOUND(_ntstatus_) \
  157. (((_ntstatus_) == STATUS_DELETE_PENDING) || \
  158. ((_ntstatus_) == STATUS_FILE_DELETED) || \
  159. ((_ntstatus_) == STATUS_OBJECT_NAME_NOT_FOUND) || \
  160. ((_ntstatus_) == STATUS_OBJECTID_NOT_FOUND) || \
  161. ((_ntstatus_) == STATUS_FILE_RENAMED) || \
  162. ((_ntstatus_) == STATUS_OBJECT_PATH_NOT_FOUND))
  163. //
  164. // Retry the install (staging file)
  165. //
  166. // Note: remove ERROR_ACCESS_DENIED when FILE_OPEN_FOR_BACKUP_INTENT bug is fixed.
  167. //
  168. #define WIN_RETRY_INSTALL(_Status) ((_Status) == ERROR_SHARING_VIOLATION || \
  169. (_Status) == ERROR_ACCESS_DENIED || \
  170. (_Status) == ERROR_DISK_FULL || \
  171. (_Status) == ERROR_HANDLE_DISK_FULL || \
  172. (_Status) == ERROR_DIR_NOT_EMPTY || \
  173. (_Status) == ERROR_OPLOCK_NOT_GRANTED || \
  174. (_Status) == ERROR_RETRY)
  175. //
  176. // Retry the delete
  177. //
  178. #define WIN_RETRY_DELETE(_Status) WIN_RETRY_INSTALL(_Status)
  179. //
  180. // Retry the generate (staging file)
  181. //
  182. #define WIN_RETRY_STAGE(_Status) WIN_RETRY_INSTALL(_Status)
  183. //
  184. // Retry the fetch (staging file)
  185. //
  186. #define WIN_RETRY_FETCH(_Status) WIN_RETRY_INSTALL(_Status)
  187. //
  188. // Retry the creation of the preinstall file
  189. //
  190. #define WIN_RETRY_PREINSTALL(_Status) WIN_RETRY_INSTALL(_Status)
  191. //
  192. // Generic !ERROR_SUCCESS status
  193. //
  194. #define WIN_SET_FAIL(_Status) (_Status = ERROR_GEN_FAILURE)
  195. //
  196. // Generic "retry operation" error
  197. //
  198. #define WIN_SET_RETRY(_Status) (_Status = ERROR_RETRY)
  199. //
  200. // THis macro checks the error returns from WaitForSingleObject.
  201. //
  202. #define CHECK_WAIT_ERRORS(_Severity_, _WStatus_, _WaitObjectCount_, _Action_) \
  203. \
  204. if ((_WStatus_ == WAIT_TIMEOUT) || (_WStatus_ == ERROR_TIMEOUT)) { \
  205. DPRINT(_Severity_, "++ >>>>>>>>>>>> Wait timeout <<<<<<<<<<<<\n"); \
  206. if (_Action_) return _WStatus_; \
  207. } else \
  208. if (_WStatus_ == WAIT_ABANDONED) { \
  209. DPRINT(_Severity_, "++ >>>>>>>>>>>> Wait abandoned <<<<<<<<<<<<\n"); \
  210. if (_Action_) return _WStatus_; \
  211. } else \
  212. if (_WStatus_ == WAIT_FAILED) { \
  213. _WStatus_ = GetLastError(); \
  214. DPRINT_WS(_Severity_, "++ ERROR: wait failed :", _WStatus_); \
  215. if (_Action_) return _WStatus_; \
  216. } else \
  217. if (_WStatus_ >= _WaitObjectCount_) { \
  218. DPRINT_WS(_Severity_, "++ >>>>>>>>>> Wait failed <<<<<<<<<", _WStatus_);\
  219. if (_Action_) return _WStatus_; \
  220. }
  221. #define ACTION_RETURN TRUE
  222. #define ACTION_CONTINUE FALSE
  223. //
  224. // Like above but with no Action arg so it can be used in a finally {} clause.
  225. //
  226. #define CHECK_WAIT_ERRORS2(_Severity_, _WStatus_, _WaitObjectCount_) \
  227. \
  228. if (_WStatus_ == WAIT_TIMEOUT) { \
  229. DPRINT(_Severity_, "++ >>>>>>>>>>>> Wait timeout <<<<<<<<<<<<\n"); \
  230. } else \
  231. if (_WStatus_ == WAIT_ABANDONED) { \
  232. DPRINT(_Severity_, "++ >>>>>>>>>>>> Wait abandoned <<<<<<<<<<<<\n"); \
  233. } else \
  234. if (_WStatus_ == WAIT_FAILED) { \
  235. _WStatus_ = GetLastError(); \
  236. DPRINT_WS(_Severity_, "++ ERROR: wait failed :", _WStatus_); \
  237. } else \
  238. if (_WStatus_ >= _WaitObjectCount_) { \
  239. DPRINT_WS(_Severity_, "++ >>>>>>>>>>>>>>> Wait failed : %s <<<<<<<<<", _WStatus_);\
  240. }
  241. #define GET_EXCEPTION_CODE(_x_) \
  242. { \
  243. (_x_) = GetExceptionCode(); \
  244. DPRINT1_WS(0, "++ ERROR - EXCEPTION (%08x) :", (_x_),(_x_)); \
  245. }
  246. #define LDP_SUCCESS(_Status) ((_Status) == LDAP_SUCCESS)
  247. //
  248. // Translate Jet error codes to an FRS Error code.
  249. //
  250. FRS_ERROR_CODE
  251. DbsTranslateJetError0(
  252. IN JET_ERR jerr,
  253. IN BOOL BPrint
  254. );
  255. #define DbsTranslateJetError(_jerr_, _print_) \
  256. (((_jerr_) == JET_errSuccess) ? FrsErrorSuccess : \
  257. DbsTranslateJetError0(_jerr_, _print_))
  258. FRS_ERROR_CODE
  259. FrsTranslateWin32Error(
  260. IN DWORD WStatus
  261. );
  262. FRS_ERROR_CODE
  263. FrsTranslateNtError(
  264. IN NTSTATUS Status,
  265. IN BOOL BPrint
  266. );
  267. ULONG
  268. DisplayNTStatusSev(
  269. IN ULONG Sev,
  270. IN NTSTATUS Status
  271. );
  272. ULONG
  273. DisplayNTStatus(
  274. IN NTSTATUS Status
  275. );
  276. ULONG
  277. FrsSetLastNTError(
  278. NTSTATUS Status
  279. );
  280. VOID
  281. DisplayErrorMsg(
  282. IN ULONG Severity,
  283. IN ULONG WindowsErrorCode
  284. );
  285. PCHAR
  286. ErrLabelW32(
  287. ULONG WStatus
  288. );
  289. PCHAR
  290. ErrLabelNT(
  291. NTSTATUS Status
  292. );
  293. PCHAR
  294. ErrLabelFrs(
  295. ULONG FStatus
  296. );
  297. PCHAR
  298. ErrLabelJet(
  299. LONG jerr
  300. );
  301. //
  302. // FRS Error Handling
  303. //
  304. #define FRS_SUCCESS(_Status) ((_Status) == FrsErrorSuccess)
  305. VOID
  306. FrsError(
  307. FRS_ERROR_CODE
  308. );
  309. VOID FrsErrorCode(
  310. FRS_ERROR_CODE,
  311. DWORD
  312. );
  313. VOID FrsErrorCodeMsg1(
  314. FRS_ERROR_CODE,
  315. DWORD,
  316. PWCHAR
  317. );
  318. VOID FrsErrorCodeMsg2(
  319. FRS_ERROR_CODE,
  320. DWORD,
  321. PWCHAR,
  322. PWCHAR
  323. );
  324. VOID FrsErrorCodeMsg3(
  325. FRS_ERROR_CODE,
  326. DWORD,
  327. PWCHAR,
  328. PWCHAR,
  329. PWCHAR
  330. );
  331. VOID FrsErrorMsg1(
  332. FRS_ERROR_CODE,
  333. PWCHAR
  334. );
  335. VOID FrsErrorMsg2(
  336. FRS_ERROR_CODE,
  337. PWCHAR,
  338. PWCHAR
  339. );
  340. VOID FrsErrorMsg3(
  341. FRS_ERROR_CODE,
  342. PWCHAR,
  343. PWCHAR,
  344. PWCHAR
  345. );
  346. #endif // _FRSERROR_