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.

179 lines
3.6 KiB

  1. /*
  2. Module Name:
  3. mirror.h
  4. Abstract:
  5. This module is the header file for the code that copies from one
  6. tree to another.
  7. Author:
  8. Andy Herron May 27 1998
  9. Revision History:
  10. */
  11. //
  12. // This structure contains all the global data passed around for the
  13. // different instances of copying subtrees active.
  14. //
  15. typedef struct _COPY_TREE_CONTEXT {
  16. LIST_ENTRY PendingDirectoryList;
  17. LARGE_INTEGER BytesCopied;
  18. ULONG FilesCopied;
  19. ULONG AttributesModified;
  20. ULONG SourceFilesScanned;
  21. ULONG DestFilesScanned;
  22. ULONG DirectoriesCreated;
  23. ULONG ErrorsEncountered;
  24. ULONG FilesDeleted;
  25. ULONG DirectoriesDeleted;
  26. ULONG SecurityDescriptorsWritten;
  27. ULONG SourceSecurityDescriptorsRead;
  28. ULONG SFNWritten;
  29. BOOLEAN Cancelled;
  30. BOOLEAN DeleteOtherFiles;
  31. CRITICAL_SECTION Lock;
  32. } COPY_TREE_CONTEXT, *PCOPY_TREE_CONTEXT;
  33. //
  34. // this is the structure we use to track per thread instance data, per thread
  35. // buffers, etc.
  36. //
  37. #define IMIRROR_INITIAL_SD_LENGTH 2048
  38. #define IMIRROR_INITIAL_SFN_LENGTH 32
  39. typedef struct _IMIRROR_THREAD_CONTEXT {
  40. PCOPY_TREE_CONTEXT CopyContext;
  41. LPBYTE SDBuffer;
  42. DWORD SDBufferLength;
  43. LPBYTE SFNBuffer;
  44. DWORD SFNBufferLength;
  45. LPBYTE DirectoryBuffer;
  46. DWORD DirectoryBufferLength;
  47. BOOLEAN IsNTFS;
  48. HANDLE SourceDirHandle;
  49. HANDLE DestDirHandle;
  50. PVOID FindBufferBase;
  51. PVOID FindBufferNext;
  52. ULONG FindBufferLength;
  53. LIST_ENTRY FilesToIgnore;
  54. } IMIRROR_THREAD_CONTEXT, *PIMIRROR_THREAD_CONTEXT;
  55. //
  56. // This structure is used to report back errors that occurred during copying.
  57. //
  58. typedef struct _COPY_ERROR {
  59. LIST_ENTRY ListEntry;
  60. DWORD Error;
  61. DWORD ActionCode;
  62. PWCHAR FileName;
  63. WCHAR FileNameBuffer[1];
  64. } COPY_ERROR, *PCOPY_ERROR;
  65. #define IMIRROR_ATTRIBUTES_TO_REPLICATE ( FILE_ATTRIBUTE_HIDDEN | \
  66. FILE_ATTRIBUTE_READONLY | \
  67. FILE_ATTRIBUTE_SYSTEM | \
  68. FILE_ATTRIBUTE_TEMPORARY | \
  69. FILE_ATTRIBUTE_NORMAL | \
  70. FILE_ATTRIBUTE_DIRECTORY | \
  71. FILE_ATTRIBUTE_ARCHIVE )
  72. #define IMIRROR_ATTRIBUTES_TO_STORE (~(IMIRROR_ATTRIBUTES_TO_REPLICATE))
  73. #define IMIRROR_ATTRIBUTES_TO_IGNORE ( FILE_ATTRIBUTE_OFFLINE | \
  74. FILE_ATTRIBUTE_SPARSE_FILE | \
  75. FILE_ATTRIBUTE_NOT_CONTENT_INDEXED )
  76. //
  77. // These are the functions in mirror.c
  78. //
  79. #ifdef DEBUGLOG
  80. VOID
  81. IMLogToFile (
  82. PSTR Buffer
  83. );
  84. VOID
  85. IMFlushAndCloseLog (
  86. VOID
  87. );
  88. #endif
  89. DWORD
  90. AllocateCopyTreeContext (
  91. PCOPY_TREE_CONTEXT *CopyContext,
  92. BOOLEAN DeleteOtherFiles
  93. );
  94. VOID
  95. FreeCopyTreeContext (
  96. PCOPY_TREE_CONTEXT CopyContext
  97. );
  98. DWORD
  99. CopyTree (
  100. PCOPY_TREE_CONTEXT CopyContext,
  101. BOOLEAN IsNtfs,
  102. PWCHAR SourceRoot,
  103. PWCHAR DestRoot
  104. );
  105. ULONG
  106. ReportCopyError (
  107. PCOPY_TREE_CONTEXT CopyContext OPTIONAL,
  108. PWCHAR File,
  109. DWORD ActionCode,
  110. DWORD err
  111. );
  112. ULONG
  113. IMConvertNT2Win32Error(
  114. IN NTSTATUS Status
  115. );
  116. DWORD
  117. IMFindNextFile(
  118. PIMIRROR_THREAD_CONTEXT ThreadContext,
  119. HANDLE DirHandle,
  120. PFILE_FULL_DIR_INFORMATION *lpFindFileData
  121. );
  122. DWORD
  123. IMFindFirstFile(
  124. PIMIRROR_THREAD_CONTEXT ThreadContext,
  125. HANDLE DirHandle,
  126. PFILE_FULL_DIR_INFORMATION *lpFindFileData
  127. );
  128. NTSTATUS
  129. GetTokenHandle(
  130. IN OUT PHANDLE TokenHandle
  131. );
  132. NTSTATUS
  133. SetPrivs(
  134. IN HANDLE TokenHandle,
  135. IN LPTSTR lpszPriv
  136. );