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.

337 lines
7.8 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. DWORD (*FsConnect)(
  207. IN PVOID fshandle,
  208. IN DWORD pid
  209. );
  210. } FsDispatchTable;
  211. #include "fsapi.h"
  212. DWORD
  213. FsMount(PVOID hdl, LPWSTR root_name, USHORT uid, USHORT *tid);
  214. void
  215. FsDisMount(PVOID hdl, USHORT uid, USHORT tid);
  216. DWORD
  217. FsLogonUser(PVOID hdl, HANDLE token, LUID LogonId, USHORT *uid);
  218. void
  219. FsLogoffUser(PVOID hdl, LUID LogonId);
  220. DWORD
  221. LsaInit(
  222. HANDLE *LsaHandle,
  223. ULONG *AuthenticationPackage
  224. );
  225. BOOL
  226. LsaValidateLogon(
  227. HANDLE LsaHandle,
  228. ULONG AuthenticationPackage,
  229. LPBYTE lpChallenge,
  230. UINT cbChallengeSize,
  231. LPBYTE lpResponse,
  232. UINT cbResponseSize,
  233. LPSTR lpszUserName,
  234. LPSTR lpszDomainName,
  235. LUID *pLogonId,
  236. PHANDLE phLogonToken
  237. );
  238. BOOL
  239. LsaGetChallenge(
  240. HANDLE LsaHandle,
  241. ULONG AuthenticationPackage,
  242. LPBYTE lpChallenge,
  243. UINT cbSize,
  244. PUINT lpcbChallengeSize
  245. );
  246. FsDispatchTable *
  247. FsGetHandle(PVOID FsCtx, USHORT tid, USHORT uid, PVOID *fshandle);
  248. UINT32* FsGetFilePointerFromHandle(
  249. PVOID *fshdl,
  250. fhandle_t handle
  251. );
  252. #define EPRINT(_x_) error_log _x_
  253. #define DPRINT(_x_) debug_log _x_
  254. #define SrvLogError(_x_) EPRINT(_x_)
  255. #define FsLogError(_x_) EPRINT(_x_)
  256. #define FsArbLog(_x_) DPRINT(_x_)
  257. #define FsLogReplay(_x_) DPRINT(_x_)
  258. #define FsLogUndo(_x_) DPRINT(_x_)
  259. // enable this for now as rodga requested
  260. #define QFS_DBG 1
  261. // enable this if you want details logging
  262. #ifdef QFS_DBG
  263. #define xFsLog(_x_) DPRINT(_x_)
  264. #define FsLog(_x_) DPRINT(_x_)
  265. #define SrvLog(_x_) DPRINT(_x_)
  266. #else
  267. #define xFsLog(_x_)
  268. #define FsLog(_x_)
  269. #define SrvLog(_x_)
  270. #endif
  271. #endif /* __FS_H */