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
7.6 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. fs.h
  5. Abstract:
  6. Interface between srv and fs
  7. Author:
  8. Ahmed Mohamed (ahmedm) 1-Feb-2000
  9. Revision History:
  10. --*/
  11. #ifndef __FS_INTERFACE_H__
  12. #define __FS_INTERFACE_H__
  13. // note: we assume DWORD and DWORDDLONG are defined (from windows.h)
  14. #define UINT16 USHORT
  15. #ifndef IN
  16. #define IN
  17. #endif
  18. #ifndef OUT
  19. #define OUT
  20. #endif
  21. #ifndef _BASETSD_H_
  22. typedef DWORDLONG UINT64; // a 64-bit unsigned value
  23. typedef DWORD UINT32; // a 32-bit unsigned value
  24. #endif
  25. #ifndef MAXPATH
  26. #define MAXPATH 1024
  27. #endif
  28. typedef UINT64 TIME64; // in units of 100ns since Jan 1, 1601 (AD)
  29. #define fhandle_t USHORT
  30. #define INVALID_UINT64 ((UINT64)(0))
  31. #define INVALID_UINT32 ((UINT32)(0))
  32. #define INVALID_TIME64 INVALID_UINT64
  33. #define INVALID_FHANDLE_T ((fhandle_t)(-1))
  34. // disposition:
  35. #define DISP_CREATE_NEW 0x10000000
  36. #define DISP_CREATE_ALWAYS 0x20000000
  37. #define DISP_OPEN_EXISTING 0x30000000
  38. #define DISP_OPEN_ALWAYS 0x40000000
  39. #define DISP_TRUNCATE_EXISTING 0x50000000
  40. #define DISP_DIRECTORY 0x60000000
  41. #define FS_DISP_MASK 0x70000000
  42. // access:
  43. #define ACCESS_READ 0x00010000
  44. #define ACCESS_WRITE 0x00020000
  45. #define FS_ACCESS_MASK 0x00030000
  46. // cache:
  47. #define CACHE_WRITE_THROUGH 0x01000000
  48. #define CACHE_NO_BUFFERING 0x02000000
  49. #define FS_CACHE_MASK 0x03000000
  50. // sharing:
  51. #define SHARE_READ 0x00100000
  52. #define SHARE_WRITE 0x00200000
  53. #define FS_SHARE_MASK 0x00300000
  54. // flags = dispositions | access | sharing
  55. #define FLAGS_MASK (FS_DISP_MASK | FS_ACCESS_MASK | FS_SHARE_MASK | FS_CACHE_MASK)
  56. // attributes:
  57. #define ATTR_SYMLINK 0x00002000
  58. #define ATTR_DIRECTORY 0x00000010
  59. #define ATTR_READONLY 0x00000001
  60. #define ATTR_HIDDEN 0x00000002
  61. #define ATTR_SYSTEM 0x00000004
  62. #define ATTR_ARCHIVE 0x00000020
  63. #define ATTR_COMPRESSED 0x00000800
  64. #define ATTR_OFFLINE 0x00001000
  65. #define ATTR_MASK (ATTR_SYMLINK | ATTR_DIRECTORY | \
  66. ATTR_READONLY | ATTR_HIDDEN | \
  67. ATTR_SYSTEM | ATTR_ARCHIVE | \
  68. ATTR_COMPRESSED | ATTR_OFFLINE)
  69. #define MAX_FS_NAME_LEN 64
  70. // file system attributes
  71. typedef struct {
  72. CHAR fs_name[MAX_FS_NAME_LEN];
  73. UINT64 total_units;
  74. UINT64 free_units;
  75. ULONG sectors_per_unit;
  76. ULONG bytes_per_sector;
  77. }fs_attr_t;
  78. typedef struct {
  79. // sizes
  80. UINT64 file_size;
  81. UINT64 alloc_size;
  82. // times
  83. TIME64 create_time;
  84. TIME64 access_time;
  85. TIME64 mod_time;
  86. // mode/attr
  87. UINT32 attributes;
  88. }fattr_t;
  89. typedef struct {
  90. UINT32 cookie;
  91. fattr_t attribs;
  92. WCHAR name[MAX_PATH];
  93. } dirinfo_t;
  94. typedef struct {
  95. DWORD FsVer;
  96. DWORD (*FsCreate)(
  97. IN PVOID fshandle,
  98. IN LPWSTR name,
  99. IN USHORT name_len,
  100. IN UINT32 flags,
  101. IN fattr_t* attr,
  102. OUT fhandle_t* handle,
  103. OUT UINT32* action
  104. );
  105. DWORD (*FsLookup)(
  106. IN PVOID fshandle,
  107. IN LPWSTR name,
  108. IN USHORT len,
  109. OUT fattr_t* attr
  110. );
  111. DWORD (*FsSetAttr)(
  112. IN PVOID fshandle,
  113. IN fhandle_t handle,
  114. IN fattr_t* attr
  115. );
  116. DWORD (*FsSetAttr2)(
  117. IN PVOID fshandle,
  118. IN LPWSTR path,
  119. IN USHORT len,
  120. IN fattr_t* attr
  121. );
  122. DWORD (*FsGetAttr)(
  123. IN PVOID fshandle,
  124. IN fhandle_t handle,
  125. OUT fattr_t* attr
  126. );
  127. DWORD (*FsClose)(
  128. IN PVOID fshandle,
  129. IN fhandle_t handle
  130. );
  131. DWORD (*FsWrite)(
  132. IN PVOID fshandle,
  133. IN fhandle_t handle,
  134. IN UINT32 offset,
  135. IN OUT UINT16* count,
  136. IN void* buffer,
  137. IN PVOID context
  138. );
  139. DWORD (*FsRead)(
  140. IN PVOID fshandle,
  141. IN fhandle_t handle,
  142. IN UINT32 offset,
  143. IN OUT UINT16* count,
  144. OUT void* buffer,
  145. IN PVOID context
  146. );
  147. // to use readir(), we do a create() with DISP_DIRECTORY
  148. // returns ERROR_NO_MORE_FILES when done...
  149. DWORD (*FsReadDir)(
  150. IN PVOID fshandle,
  151. IN fhandle_t dir,
  152. IN UINT32 cookie,
  153. OUT dirinfo_t* buffer,
  154. IN UINT32 size,
  155. OUT UINT32* entries_found
  156. );
  157. DWORD (*FsStatfs)(
  158. IN PVOID fshandle,
  159. OUT fs_attr_t* attr
  160. );
  161. DWORD (*FsRemove)(
  162. IN PVOID fshandle,
  163. IN LPWSTR name,
  164. IN USHORT len
  165. );
  166. DWORD (*FsRename)(
  167. IN PVOID fshandle,
  168. IN LPWSTR fromname,
  169. IN USHORT from_len,
  170. IN LPWSTR toname,
  171. IN USHORT to_len
  172. );
  173. DWORD (*FsMkdir)(
  174. IN PVOID fshandle,
  175. IN LPWSTR name,
  176. IN USHORT len,
  177. IN fattr_t* attr
  178. );
  179. DWORD (*FsRmdir)(
  180. IN PVOID fshandle,
  181. IN LPWSTR name,
  182. IN USHORT len
  183. );
  184. DWORD (*FsFlush)(
  185. IN PVOID fshandle,
  186. IN fhandle_t handle
  187. );
  188. DWORD (*FsLock)(
  189. IN PVOID fshandle,
  190. IN fhandle_t handle,
  191. IN ULONG offset,
  192. IN ULONG length,
  193. IN ULONG flags,
  194. IN PVOID context
  195. );
  196. DWORD (*FsUnlock)(
  197. IN PVOID fshandle,
  198. IN fhandle_t handle,
  199. IN ULONG offset,
  200. IN ULONG length
  201. );
  202. DWORD (*FsGetRoot)(
  203. IN PVOID fshandle,
  204. IN OUT LPWSTR fullpath
  205. );
  206. } FsDispatchTable;
  207. #include "fsapi.h"
  208. DWORD
  209. FsMount(PVOID hdl, LPWSTR root_name, USHORT uid, USHORT *tid);
  210. void
  211. FsDisMount(PVOID hdl, USHORT uid, USHORT tid);
  212. DWORD
  213. FsLogonUser(PVOID hdl, HANDLE token, LUID LogonId, USHORT *uid);
  214. void
  215. FsLogoffUser(PVOID hdl, LUID LogonId);
  216. DWORD
  217. LsaInit(
  218. HANDLE *LsaHandle,
  219. ULONG *AuthenticationPackage
  220. );
  221. BOOL
  222. LsaValidateLogon(
  223. HANDLE LsaHandle,
  224. ULONG AuthenticationPackage,
  225. LPBYTE lpChallenge,
  226. UINT cbChallengeSize,
  227. LPBYTE lpResponse,
  228. UINT cbResponseSize,
  229. LPSTR lpszUserName,
  230. LPSTR lpszDomainName,
  231. LUID *pLogonId,
  232. PHANDLE phLogonToken
  233. );
  234. BOOL
  235. LsaGetChallenge(
  236. HANDLE LsaHandle,
  237. ULONG AuthenticationPackage,
  238. LPBYTE lpChallenge,
  239. UINT cbSize,
  240. PUINT lpcbChallengeSize
  241. );
  242. FsDispatchTable *
  243. FsGetHandle(PVOID FsCtx, USHORT tid, USHORT uid, PVOID *fshandle);
  244. #define EPRINT(_x_) error_log _x_
  245. #define DPRINT(_x_) debug_log _x_
  246. #define SrvLogError(_x_) EPRINT(_x_)
  247. #define FsLogError(_x_) EPRINT(_x_)
  248. #define FsArbLog(_x_) DPRINT(_x_)
  249. #define FsLogReplay(_x_) DPRINT(_x_)
  250. #define FsLogUndo(_x_) DPRINT(_x_)
  251. // enable this if you want details logging
  252. #ifdef QFS_DBG
  253. #define xFsLog(_x_) DPRINT(_x_)
  254. #define FsLog(_x_) DPRINT(_x_)
  255. #define SrvLog(_x_) DPRINT(_x_)
  256. #else
  257. #define xFsLog(_x_)
  258. #define FsLog(_x_)
  259. #define SrvLog(_x_)
  260. #endif
  261. #endif /* __FS_H */