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.

254 lines
6.9 KiB

  1. /*++
  2. Copyright (c) 1996-2001 Microsoft Corporation
  3. Module Name:
  4. Qfs.h
  5. Abstract:
  6. Redirection layer for quorum access
  7. Author:
  8. GorN 19-Sep-2001
  9. Revision History:
  10. --*/
  11. #ifndef _QFS_H_INCLUDED
  12. #define _QFS_H_INCLUDED
  13. #ifdef __cplusplus
  14. extern "C" {
  15. #endif
  16. VOID QfsInitialize();
  17. VOID QfsCleanup();
  18. // By defining a handle this way
  19. // we allow compiler to catch the places where
  20. // QfsHANDLE is used mistakenly in Win32 api requiring
  21. // a regular handle and vice versa
  22. typedef struct _QfsHANDLE
  23. {
  24. PVOID realHandle;
  25. int IsQfs;
  26. } QfsHANDLE, *PQfsHANDLE;
  27. #define REAL_INVALID_HANDLE_VALUE ((HANDLE)(LONG_PTR)-1)
  28. #define QfspHandle(x) ((x).realHandle)
  29. #define QfsIsHandleValid(x) (QfspHandle(x) != REAL_INVALID_HANDLE_VALUE)
  30. extern QfsHANDLE QfsINVALID_HANDLE_VALUE;
  31. #if !defined(QFS_DO_NOT_UNMAP_WIN32)
  32. #undef INVALID_HANDLE_VALUE
  33. #undef CreateFile
  34. #define CreateFile UseQfsCreateFile
  35. #define CreateFileW UseQfsCreateFile
  36. #define WriteFile UseQfsWriteFile
  37. #define ReadFile UseQfsReadFile
  38. #define FlushFileBuffers UseQfsFlushFileBuffers
  39. #undef DeleteFile
  40. #define DeleteFile UseQfsDeleteFile
  41. #define DeleteFileW UseQfsDeleteFile
  42. #undef RemoveDirectory
  43. #define RemoveDirectory UseQfsRemoveDirectory
  44. #define RemoveDirectoryW UseQfsRemoveDirectory
  45. // NYI add the rest
  46. #endif
  47. QfsHANDLE QfsCreateFile(
  48. LPCWSTR lpFileName, // file name
  49. DWORD dwDesiredAccess, // access mode
  50. DWORD dwShareMode, // share mode
  51. LPSECURITY_ATTRIBUTES lpSecurityAttributes, // SD
  52. DWORD dwCreationDisposition, // how to create
  53. DWORD dwFlagsAndAttributes, // file attributes
  54. HANDLE hTemplateFile // handle to template file
  55. );
  56. BOOL QfsCloseHandle(
  57. QfsHANDLE hObject // handle to object
  58. );
  59. BOOL QfsWriteFile(
  60. QfsHANDLE hFile, // handle to file
  61. LPCVOID lpBuffer, // data buffer
  62. DWORD nNumberOfBytesToWrite, // number of bytes to write
  63. LPDWORD lpNumberOfBytesWritten, // number of bytes written
  64. LPOVERLAPPED lpOverlapped // overlapped buffer
  65. );
  66. BOOL QfsReadFile(
  67. QfsHANDLE hFile, // handle to file
  68. LPVOID lpBuffer, // data buffer
  69. DWORD nNumberOfBytesToRead, // number of bytes to read
  70. LPDWORD lpNumberOfBytesRead, // number of bytes read
  71. LPOVERLAPPED lpOverlapped // overlapped buffer
  72. );
  73. BOOL QfsFlushFileBuffers(
  74. QfsHANDLE hFile // handle to file
  75. );
  76. BOOL QfsDeleteFile(
  77. LPCTSTR lpFileName );
  78. BOOL QfsRemoveDirectory(
  79. LPCTSTR lpFileName );
  80. QfsHANDLE QfsFindFirstFile(
  81. LPCTSTR lpFileName, // file name
  82. LPWIN32_FIND_DATA lpFindFileData // data buffer
  83. );
  84. BOOL QfsFindNextFile(
  85. QfsHANDLE hFindFile, // search handle
  86. LPWIN32_FIND_DATA lpFindFileData // data buffer
  87. );
  88. BOOL QfsFindClose(
  89. QfsHANDLE hFindFile // file search handle
  90. );
  91. #define QfsFindCloseIfValid(hFile) (QfsIsHandleValid(hFile)?QfsFindClose(hFile):0)
  92. #define QfsCloseHandleIfValid(hFile) (QfsIsHandleValid(hFile)?QfsCloseHandle(hFile):0)
  93. DWORD QfsSetEndOfFile(
  94. QfsHANDLE hFile,
  95. LONGLONG Offset
  96. );
  97. DWORD QfsGetFileSize(
  98. QfsHANDLE hFile, // handle to file
  99. LPDWORD lpFileSizeHigh // high-order word of file size
  100. );
  101. DWORD QfsIsOnline(
  102. IN LPCWSTR Path,
  103. OUT BOOL *pfOnline
  104. );
  105. // Returns success if the Path is valid qfs path. Sets pfOnline to where the resource is online or not
  106. // failure otherwise
  107. HANDLE QfsCreateFileMapping(
  108. QfsHANDLE hFile, // handle to file
  109. LPSECURITY_ATTRIBUTES lpAttributes, // security
  110. DWORD flProtect, // protection
  111. DWORD dwMaximumSizeHigh, // high-order DWORD of size
  112. DWORD dwMaximumSizeLow, // low-order DWORD of size
  113. LPCTSTR lpName // object name
  114. );
  115. BOOL QfsGetOverlappedResult(
  116. QfsHANDLE hFile, // handle to file, pipe, or device
  117. LPOVERLAPPED lpOverlapped, // overlapped structure
  118. LPDWORD lpNumberOfBytesTransferred, // bytes transferred
  119. BOOL bWait // wait option
  120. );
  121. BOOL QfsSetFileAttributes(
  122. LPCWSTR lpFileName, // file name
  123. DWORD dwFileAttributes // attributes
  124. );
  125. BOOL QfsCopyFile(
  126. LPCWSTR lpExistingFileName, // name of an existing file
  127. LPCWSTR lpNewFileName, // name of new file
  128. BOOL bFailIfExists // operation if file exists
  129. );
  130. BOOL QfsCopyFileEx(
  131. LPCWSTR lpExistingFileName, // name of existing file
  132. LPCWSTR lpNewFileName, // name of new file
  133. LPPROGRESS_ROUTINE lpProgressRoutine, // callback function
  134. LPVOID lpData, // callback parameter
  135. LPBOOL pbCancel, // cancel status
  136. DWORD dwCopyFlags // copy options
  137. );
  138. BOOL QfsCreateDirectory(
  139. LPCWSTR lpPathName, // directory name
  140. LPSECURITY_ATTRIBUTES lpSecurityAttributes // SD
  141. );
  142. BOOL QfsGetDiskFreeSpaceEx(
  143. LPCTSTR lpDirectoryName, // directory name
  144. PULARGE_INTEGER lpFreeBytesAvailable, // bytes available to caller
  145. PULARGE_INTEGER lpTotalNumberOfBytes, // bytes on disk
  146. PULARGE_INTEGER lpTotalNumberOfFreeBytes // free bytes on disk
  147. );
  148. BOOL QfsMoveFileEx(
  149. LPCTSTR lpExistingFileName, // file name
  150. LPCTSTR lpNewFileName, // new file name
  151. DWORD dwFlags // move options
  152. );
  153. #define QfsMoveFile(lpSrc, lpDst) \
  154. QfsMoveFileEx(lpSrc, lpDst, MOVEFILE_COPY_ALLOWED)
  155. UINT QfsGetTempFileName(
  156. LPCTSTR lpPathName, // directory name
  157. LPCTSTR lpPrefixString, // file name prefix
  158. UINT uUnique, // integer
  159. LPTSTR lpTempFileName // file name buffer
  160. );
  161. LONG QfsRegSaveKey(
  162. HKEY hKey, // handle to key
  163. LPCWSTR lpFile, // data file
  164. LPSECURITY_ATTRIBUTES lpSecurityAttributes // SD
  165. );
  166. DWORD QfsMapFileAndCheckSum(
  167. LPCWSTR Filename,
  168. PDWORD HeaderSum,
  169. PDWORD CheckSum
  170. );
  171. ////////////// Clusrtl funcs replacement ////////////////
  172. BOOL
  173. QfsClRtlCopyFileAndFlushBuffers(
  174. IN LPCWSTR lpszSourceFile,
  175. IN LPCWSTR lpszDestinationFile
  176. );
  177. BOOL QfsClRtlCreateDirectory(
  178. LPCWSTR lpPathName // directory name
  179. );
  180. DWORD
  181. QfsSetFileSecurityInfo(
  182. IN LPCWSTR lpszFile,
  183. IN DWORD dwAdminMask,
  184. IN DWORD dwOwnerMask,
  185. IN DWORD dwEveryoneMask
  186. );
  187. // opens the specified file/directory with
  188. // GENERIC_READ|WRITE_DAC|READ_CONTROL,
  189. // 0,
  190. // NULL,
  191. // OPEN_ALWAYS,
  192. // FILE_FLAG_BACKUP_SEMANTICS,
  193. // and then calls ClRtlSetObjSecurityInfo on it
  194. ////////////////////////////////////////////
  195. #ifdef __cplusplus
  196. };
  197. #endif
  198. #endif