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.

1646 lines
43 KiB

  1. #ifndef __LIB3_H__
  2. #define __LIB3_H__
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. #undef VxD
  7. #include "shdcom.h"
  8. #ifndef __COPYCHUNKCONTEXT__
  9. #define __COPYCHUNKCONTEXT__
  10. typedef struct tagCOPYCHUNKCONTEXT
  11. {
  12. DWORD dwFlags;
  13. ULONG LastAmountRead;
  14. ULONG TotalSizeBeforeThisRead;
  15. HANDLE handle;
  16. ULONG ChunkSize;
  17. ULONG Context[1];
  18. }
  19. COPYCHUNKCONTEXT;
  20. #endif
  21. /* lib3.c */
  22. #ifdef UNICODE
  23. #define GetShadow GetShadowW
  24. #define GetShadowEx GetShadowExW
  25. #define CreateShadow CreateShadowW
  26. #define GetShadowInfo GetShadowInfoW
  27. #define GetShadowInfoEx GetShadowInfoExW
  28. #define SetShadowInfo SetShadowInfoW
  29. #define GetUNCPath GetUNCPathW
  30. #define FindOpenShadow FindOpenShadowW
  31. #define FindNextShadow FindNextShadowW
  32. #define AddHint AddHintW
  33. #define DeleteHint DeleteHintW
  34. #define GetShareInfo GetShareInfoW
  35. #define ChkUpdtStatus ChkUpdtStatusW
  36. #define FindOpenHint FindOpenHintW
  37. #define FindNextHint FindNextHintW
  38. #define LpAllocCopyParams LpAllocCopyParamsW
  39. #define FreeCopyParams FreeCopyParamsW
  40. #define CopyShadow CopyShadowW
  41. #define GetShadowDatabaseLocation GetShadowDatabaseLocationW
  42. #define GetNameOfServerGoingOffline GetNameOfServerGoingOfflineW
  43. #else
  44. #define GetShadow GetShadowA
  45. #define GetShadowEx GetShadowExA
  46. #define CreateShadow CreateShadowA
  47. #define GetShadowInfo GetShadowInfoA
  48. #define GetShadowInfoEx GetShadowInfoExA
  49. #define SetShadowInfo SetShadowInfoA
  50. #define GetUNCPath GetUNCPathA
  51. #define FindOpenShadow FindOpenShadowA
  52. #define FindNextShadow FindNextShadowA
  53. #define AddHint AddHintA
  54. #define DeleteHint DeleteHintA
  55. #define GetShareInfo GetShareInfoA
  56. #define ChkUpdtStatus ChkUpdtStatusA
  57. #define FindOpenHint FindOpenHintA
  58. #define FindNextHint FindNextHintA
  59. #define LpAllocCopyParams LpAllocCopyParamsA
  60. #define FreeCopyParams FreeCopyParamsA
  61. #define CopyShadow CopyShadowA
  62. #define GetShadowDatabaseLocation GetShadowDatabaseLocationA
  63. #endif
  64. HANDLE __OpenShadowDatabaseIO(ULONG WaitForDriver);
  65. #define OpenShadowDatabaseIO() (__OpenShadowDatabaseIO(0))
  66. /*++
  67. Routine Description:
  68. This routine is called by the callers in usermode using "APIs" in this file
  69. in order to establish a means of communicating with redir in the kernel mode. All
  70. the APIs are wrappers to various device IO controls to the redir in order to accomplish
  71. the appropriate task
  72. Arguments:
  73. None. The waitfordriver argument is a temporary hack which will be removed soon.
  74. All callers should call OpenShadowDatabaseIO().
  75. Returns:
  76. If suuccessful, it returns a handle to the redir (actually a symbolic link called shadow)
  77. Returns IMVALID_HANDLE_VALUE if it fails. GetLastError() gives the error value.
  78. Notes:
  79. This is a wrapper function that does CreateFile on the "Shadow" deviceobject.
  80. --*/
  81. void CloseShadowDatabaseIO(HANDLE hShadowDB);
  82. /*++
  83. Routine Description:
  84. Closes the handle opened for communicating with the redir.
  85. Arguments:
  86. Handle returned from a successful OpenShadowDatabaseIO call.
  87. Returns:
  88. Nothing.
  89. Notes:
  90. It is important to have a matching CloseShadowDatabaseIO call for every successful open
  91. call, otherwise the redir may not be able to stop in the net stop redir command.
  92. --*/
  93. int GetShadow(HANDLE hShadowDB, HSHADOW hDir, LPHSHADOW lphShadow, LPWIN32_FIND_DATA lpFind32, unsigned long *lpuStatus);
  94. /*++
  95. Routine Description:
  96. Given the directory Inode and a name of an entry within that directory, returns the
  97. WIN32 strucutre for the entry and it's current status. For definition of status bits
  98. refer to shdcom.h.
  99. Arguments:
  100. hShadowDB Handle to the shadow database as obtained from OpenShadowDatabaseIO.
  101. if INVALID_HANDLE_VALUE is passed in, the API, opens the shadow database,
  102. issues the corresponding ioctl, and closes it before returning.
  103. hDir The directory Inode value obtained from either a FindOpen/FindNext call or
  104. from an earlier call to a GetShadow(Ex)/CreateShadow routine.
  105. If hDir is 0, then the name in the lpFind32 strucutre must be a UNC name
  106. of a share in \\server\share form.
  107. lphShadow returns the Inode number for the entry in the shadow database. If hDir is 0,
  108. the indoe is that of the root of this share.
  109. lpFind32 InOut parameter. Contains the name of the entry in cFileName member. On return
  110. all the elements of the find strucutre are filled up. These represent the
  111. find32 info as obtained from the server, with any subsequent local modifications if any.
  112. The only significant timestamp is ftLastWriteTime. ftLastCreateTime is set to 0.
  113. ftLastAccessTime contains the timestamp of the original file/directory as
  114. returned by the server.
  115. If this is a root inode of a share, the info in the Find32 strucutre is cooked up.
  116. lpuStatus returns the status of the entry, such as partially filled (sparse), locally modified
  117. etc. See SHADOW_xxx in shdcom.h
  118. If value returned in lphShadow is the root inode of a share, (ie if hDir is 0)
  119. then the status bits are SHARE_xxx as defined in shdcom.h. eg. the bits
  120. indicate whether the share is connected right now, whether it has any outstanding
  121. opens, whether it is operating in disconnected state etc.
  122. Returns:
  123. 1 if successful, 0 otherwise. GetlastError() gives the error of unsuccessful.
  124. Notes:
  125. --*/
  126. int GetShadowEx(HANDLE hShadowDB, HSHADOW hDir, LPWIN32_FIND_DATA lpFind32, LPSHADOWINFO lpSI);
  127. /*++
  128. Routine Description:
  129. Given the directory Inode and a name of an entry within that directory, returns the
  130. WIN32 strucutre for the entry and all it's metadata maintained by the shadowing database.
  131. For a defintion of SHADOWINFO structure refer to shdcom.h
  132. Arguments:
  133. hShadowDB Handle to the shadow database as obtained from OpenShadowDatabaseIO.
  134. if INVALID_HANDLE_VALUE is passed in, the API, opens the shadow database,
  135. issues the corresponding ioctl, and closes it before returning.
  136. hDir The directory Inode value obtained from either a FindOpen/FindNext call or
  137. from an earlier call to a GetShadow(Ex)/CreateShadow routine
  138. If hDir is 0, then the name in the lpFind32 strucutre must be a UNC name
  139. of a share in \\server\share form.
  140. lphShadow returns the Inode number for the entry in the shadow database
  141. lpFind32 InOut parameter. Contains the name of the entry in cFileName member. On return
  142. all the elements of the find strucutre are filled up. These represent the
  143. find32 info as obtained from the server, with any subsequent local modifications if any.
  144. The only significant timestamp is ftLastWriteTime. ftLastCreateTime is set to 0.
  145. ftLastAccessTime contains the timestamp of the original file/directory as
  146. returned by the server.
  147. When the object is in ssync, both the local and remote timestamps are identical.
  148. If this is a root inode of a share, the info in the Find32 strucutre is cooked up.
  149. lpSI returns all the information about the entry maintained by the CSC database.
  150. If value returned in lphShadow is the root inode of a share, (ie if hDir is 0)
  151. then the status bits in lpSI->uStatus are SHARE_xxx as defined in shdcom.h.
  152. eg. the bits indicate whether the share is connected right now, whether it has
  153. any outstanding opens, whether it is operating in disconnected state etc.
  154. Returns:
  155. 1 if successful, 0 otherwise. GetlastError() gives the error of unsuccessful.
  156. Notes:
  157. GetShadowEx is a superset of GetShadow and should be preferred.
  158. --*/
  159. int CreateShadow(HANDLE hShadowDB, HSHADOW hDir, LPWIN32_FIND_DATA lpFind32, unsigned long uStatus, LPHSHADOW lphShadow);
  160. /*++
  161. Routine Description:
  162. Given the directory Inode and WIN32 strucutre for a file/directory, creates an
  163. Inode for the same.
  164. Arguments:
  165. hShadowDB Handle to the shadow database as obtained from OpenShadowDatabaseIO.
  166. if INVALID_HANDLE_VALUE is passed in, the API, opens the shadow database,
  167. issues the corresponding ioctl, and closes it before returning.
  168. hDir The directory Inode value obtained from either a FindOpen/FindNext call or
  169. from an earlier call to a GetShadow(Ex)/CreateShadow routine, or 0 which
  170. indicates the root inode of a share.
  171. lpFind32 Should contain all the elements of the find32 info as obtained from the server.
  172. Only the ftLastWriteTime timestamp is used, other timestamps are ignored.
  173. If hDir is 0, then the name in the lpFind32 strucutre must be a UNC name
  174. of a share in \\server\share form. All other elements of the strucutre are ignored
  175. uStatus the initial status of the entry to be created, such as partially filled (sparse)
  176. etc. See SHADOW_xxx in shdcom.h
  177. lphShadow returns the Inode number for the entry in the shadow database
  178. Returns:
  179. 1 if successful, 0 otherwise. GetlastError() gives the error of unsuccessful.
  180. Notes:
  181. For non-root entries, if the shadow already exists, the routine works just like SetShadowInfo.
  182. --*/
  183. int DeleteShadow(HANDLE hShadowDB, HSHADOW hDir, HSHADOW hShadow);
  184. /*++
  185. Routine Description:
  186. Deletes an entry from the shadow database.
  187. Arguments:
  188. hShadowDB Handle to the shadow database as obtained from OpenShadowDatabaseIO.
  189. if INVALID_HANDLE_VALUE is passed in, the API, opens the shadow database,
  190. issues the corresponding ioctl, and closes it before returning.
  191. hDir The directory Inode value obtained from either a FindOpen/FindNext call or
  192. from an earlier call to a GetShadow(Ex)/CreateShadow routine, or 0 which
  193. indicates the root inode of a share.
  194. hShadow Inode value obtained from either a FindOpen/FindNext call or
  195. from an earlier call to a GetShadow(Ex)/CreateShadow routine. This
  196. inode represents a child of the directory represented by hDir.
  197. Returns:
  198. 1 if successful, 0 if failed. (Error reporting is not very good here)
  199. Notes:
  200. The routine failes if hShadow is a directory and has descendents of it's own.
  201. If hDir is 0, then the root of the share is deleted. This would cause the share to
  202. be inaccessible in disconnected state, because it would have gone from the
  203. CSC database.
  204. --*/
  205. int GetShadowInfo(HANDLE hShadowDB, HSHADOW hDir, HSHADOW hShadow, LPWIN32_FIND_DATA lpFind32, unsigned long *lpuStatus);
  206. /*++
  207. Routine Description:
  208. Given the directory Inode and an inode within that directory, returns the
  209. WIN32 strucutre for the entry and it's current status. For definition of status bits
  210. refer to shdcom.h.
  211. Arguments:
  212. hShadowDB Handle to the shadow database as obtained from OpenShadowDatabaseIO.
  213. if INVALID_HANDLE_VALUE is passed in, the API, opens the shadow database,
  214. issues the corresponding ioctl, and closes it before returning.
  215. hDir The directory Inode value obtained from either a FindOpen/FindNext call or
  216. from an earlier call to a GetShadow(Ex)/CreateShadow routine, or 0 which
  217. indicates the root inode of a share.
  218. hShadow Inode value obtained from either a FindOpen/FindNext call or
  219. from an earlier call to a GetShadow(Ex)/CreateShadow routine. This
  220. inode represents a child of the directory represented by hDir.
  221. lpFind32 Can be NULL. If non-NULL on return all the elements of the find strucutre
  222. are filled up. These represent the find32 info as obtained from the server,
  223. with any subsequent local modifications if any.
  224. The only significant timestamp is ftLastWriteTime. ftLastCreateTime is set to 0.
  225. ftLastAccessTime contains the timestamp of the original file/directory as
  226. returned by the server.
  227. If this is a root inode of a share, the info in the Find32 strucutre is cooked up.
  228. lpuStatus returns the status of the entry, such as partially filled (sparse), locally modified
  229. etc. See SHADOW_xxx in shdcom.h
  230. If hShadow is the root inode of a share, (ie if hDir is 0) then the status bits
  231. are SHARE_xxx as defined in shdcom.h. eg. the bits indicate whether the
  232. share is connected right now, whether it has any outstanding opens, whether
  233. it is operating in disconnected state etc.
  234. Returns:
  235. 1 if successful, 0 otherwise. GetlastError() gives the error of unsuccessful.
  236. Notes:
  237. --*/
  238. int GetShadowInfoEx(HANDLE hShadowDB, HSHADOW hDir, HSHADOW hShadow, LPWIN32_FIND_DATA lpFind32, LPSHADOWINFO lpSI);
  239. /*++
  240. Routine Description:
  241. Given the directory Inode and an inode within that directory, returns the
  242. WIN32 strucutre for the entry and it's current status. For definition of status bits
  243. refer to shdcom.h.
  244. Arguments:
  245. hShadowDB Handle to the shadow database as obtained from OpenShadowDatabaseIO.
  246. if INVALID_HANDLE_VALUE is passed in, the API, opens the shadow database,
  247. issues the corresponding ioctl, and closes it before returning.
  248. hDir The directory Inode value obtained from either a FindOpen/FindNext call or
  249. from an earlier call to a GetShadow(Ex)/CreateShadow routine, or 0 which
  250. indicates the root inode of a share.
  251. hShadow Inode value obtained from either a FindOpen/FindNext call or
  252. from an earlier call to a GetShadow(Ex)/CreateShadow routine. This
  253. inode represents a child of the directory represented by hDir.
  254. lpFind32 Can be NULL. If non NULL, on return all the elements of the find strucutre are
  255. filled up. These represent the find32 info as obtained from the server.
  256. The only significant timestamp is ftLastWriteTime. ftLastCreateTime is set to 0.
  257. ftLastAccessTime contains the timestamp of the original file/directory as
  258. returned by the server.
  259. If this is a root inode of a share, the info in the Find32 strucutre is cooked up.
  260. lpSI returns all the information about the entry maintained by the CSC database.
  261. If hShadow a root inode of a share, (ie if hDir is 0) then the status bits in lpSI->uStatus
  262. are SHARE_xxx as defined in shdcom.h. eg. the bits indicate whether the
  263. share is connected right now, whether it has ant outstanding opens, whether
  264. it is operating in disconnected state etc.
  265. Returns:
  266. 1 if successful, 0 otherwise. GetlastError() gives the error of unsuccessful.
  267. Notes:
  268. GetShadowInfoEx is a superset of GetShadowInfo and should be preferred.
  269. --*/
  270. int SetShadowInfo(HANDLE hShadowDB, HSHADOW hDir, HSHADOW hShadow, LPWIN32_FIND_DATA lpFind32, unsigned long uStatus, unsigned long uOp);
  271. /*++
  272. Routine Description:
  273. Given the directory Inode and an inode within that directory, sets the WIN32 strucutre
  274. for the entry and it's current status. For definition of status bits refer to shdcom.h.
  275. Arguments:
  276. hShadowDB Handle to the shadow database as obtained from OpenShadowDatabaseIO.
  277. if INVALID_HANDLE_VALUE is passed in, the API, opens the shadow database,
  278. issues the corresponding ioctl, and closes it before returning.
  279. hDir The directory Inode value obtained from either a FindOpen/FindNext call or
  280. from an earlier call to a GetShadow(Ex)/CreateShadow routine, or 0 which
  281. indicates the root inode.
  282. hShadow Inode value obtained from either a FindOpen/FindNext call or
  283. from an earlier call to a GetShadow(Ex)/CreateShadow routine. This
  284. inode represents a child of the directory represented by hDir.
  285. lpFind32 If Non-NULL, should contain all the elements of the find32 info as obtained from the server.
  286. Only the ftLastWriteTime timestamp is used.
  287. If NULL, no modification is done to the find data strucutre.
  288. uStatus the initial status of the entry to be created, such as partially filled (sparse)
  289. etc. See SHADOW_xxx in shdcom.h
  290. uOp specifies operation SHADOW_FLAGS_ASSIGN, SHADOW_FLAGS_AND or SHADOW_FLAGS_OR
  291. to do the corresponding operation between the existing status bits and the
  292. one passed in the uStatus parameter.
  293. Returns:
  294. 1 if successful 0 if failed. The routine failes if hDir is 0, ie. there is no way to set
  295. info on the root of a share.
  296. Notes:
  297. --*/
  298. int GetUNCPath(HANDLE hShadowDB, HSHARE hShare, HSHADOW hDir, HSHADOW hShadow, LPCOPYPARAMS lpCP);
  299. /*++
  300. Routine Description:
  301. This routine returns the path of the remote file with respect to it's root, the UNC string
  302. of ths share and the fully qualified path of the local replica.
  303. Arguments:
  304. hShadowDB Handle to the shadow database as obtained from OpenShadowDatabaseIO.
  305. if INVALID_HANDLE_VALUE is passed in, the API, opens the shadow database,
  306. issues the corresponding ioctl, and closes it before returning.
  307. hShare The share ID on which this shadow lives. (not really necessary)
  308. hDir The directory Inode value obtained from either a FindOpen/FindNext call or
  309. from an earlier call to a GetShadow(Ex)/CreateShadow routine, or 0 which
  310. indicates the root inode.
  311. hShadow Inode value obtained from either a FindOpen/FindNext call or
  312. from an earlier call to a GetShadow(Ex)/CreateShadow routine. This
  313. inode represents a child of the directory represented by hDir.
  314. lpCP COPYPARAMS structure as defined in shdcom.h. The buffer should be big enough to
  315. hold two MAX_PATH size elements and one MAX_SHARE_PATH element. On return the
  316. appropriate entires are filled up.
  317. Returns:
  318. 1 if successful 0 if failed
  319. Notes:
  320. --*/
  321. int GetGlobalStatus(HANDLE hShadowDB, LPGLOBALSTATUS lpGS);
  322. /*++
  323. Routine Description:
  324. Returns the status of the entire CSC database, such as the maximum size, the current size
  325. etc.
  326. Arguments:
  327. hShadowDB Handle to the shadow database as obtained from OpenShadowDatabaseIO.
  328. if INVALID_HANDLE_VALUE is passed in, the API, opens the shadow database,
  329. issues the corresponding ioctl, and closes it before returning.
  330. lpGS GLOBALSTATUS structure returned by the API. Refer to shdcom.h for
  331. the strucutre definition.
  332. Returns:
  333. 1 if successful 0 if failed
  334. Notes:
  335. --*/
  336. int FindOpenShadow(HANDLE hShadowDB, HSHADOW hDir, unsigned uOp, LPWIN32_FIND_DATA lpFind32, LPSHADOWINFO lpSI);
  337. /*++
  338. Routine Description:
  339. This API allows callers to begin enumeration of all entries in a directory in the CSC database.
  340. Does wildcard pattern matching.
  341. Arguments:
  342. hShadowDB Handle to the shadow database as obtained from OpenShadowDatabaseIO.
  343. This API does not allow passing in INVALID_HANDLE_VALUE.
  344. hDir The directory Inode value obtained from either a FindOpen/FindNext call or
  345. from an earlier call to a GetShadow(Ex)/CreateShadow routine, or 0 which
  346. indicates the root inode of a share.
  347. uOp Bitfield indicating which type of entries to enumerate. The alternatives are
  348. a) All normal entries when FINDINFO_SHADOWINFO_NORMAL is set
  349. b) All sparse entries when FINDINFO_SHADOWINFO_SPARSE is set
  350. c) All entries marked deleted when FINDINFO_SHADOWINFO_DELETED is set
  351. Setting FINDOPEN_SHADOWINFO_ALL enumerates all the three kind.
  352. lpFind32 InOut parameter. Contains the name of the entry in cFileName member, the name can
  353. cotain wildcard characters. On return all the elements of the find strucutre are
  354. filled up. These represent the find32 info as obtained from the server, with any
  355. subsequent local modifications if any.
  356. The only significant timestamp is ftLastWriteTime. ftLastCreateTime is set to 0.
  357. ftLastAccessTime contains the timestamp of the original file/directory as
  358. returned by the server.
  359. If this is the root inode of a share, the info in the Find32 strucutre is cooked up.
  360. lpSI returns all the information about the entry maintained by the CSC database.
  361. If hShadow a root inode of a share, (ie if hDir is 0) then the status bits in lpSI->uStatus
  362. are SHARE_xxx as defined in shdcom.h. eg. the bits indicate whether the
  363. share is connected right now, whether it has ant outstanding opens, whether
  364. it is operating in disconnected state etc.
  365. lpSI->uEmumCookie contains the enumeration handle that should be used in
  366. subsequent FindNext calls.
  367. Returns:
  368. 1 if successful 0 if failed
  369. Notes:
  370. The wildcard matching is done on both Long File Name and Short File name of an entry
  371. and if either one matches, the entry is returned.
  372. --*/
  373. int FindNextShadow(HANDLE hShadowDB, CSC_ENUMCOOKIE uEnumCookie, LPWIN32_FIND_DATA lpFind32, LPSHADOWINFO lpSI);
  374. /*++
  375. Routine Description:
  376. This API allows callers to continue enumeration of entries in a directory in the CSC database
  377. begun by a FindOpenHSHADOW API call. The restrictions specified by the FindOpenHSHADOW call
  378. such as the wildcard pattern etc. apply to this API.
  379. Arguments:
  380. hShadowDB Handle to the shadow database as obtained from OpenShadowDatabaseIO.
  381. This API does not allow passing in INVALID_HANDLE_VALUE.
  382. ulEnumCookie The enumeration handle returned in lpSI->uEnumCOokie after a successful
  383. FindOpenHSHADOW call.
  384. lpFind32 Output parameter. On return all the elements of the find strucutre are
  385. filled up. These represent the find32 info as obtained from the server, with any
  386. subsequent local modifications if any.
  387. The only significant timestamp is ftLastWriteTime. ftLastCreateTime is set to 0.
  388. ftLastAccessTime contains the timestamp of the original file/directory as
  389. returned by the server.
  390. If this is the root inode of a share, the info in the Find32 strucutre is cooked up.
  391. lpSI returns all the information about the entry maintained by the CSC database.
  392. If hShadow a root inode of a share, (ie if hDir is 0) then the status bits in lpSI->uStatus
  393. are SHARE_xxx as defined in shdcom.h. eg. the bits indicate whether the
  394. share is connected right now, whether it has ant outstanding opens, whether
  395. it is operating in disconnected state etc.
  396. Returns:
  397. 1 if successful 0 if either the enumeration completed or some error happened.
  398. Notes:
  399. --*/
  400. int FindCloseShadow(HANDLE hShadowDB, CSC_ENUMCOOKIE uEnumCookie);
  401. /*++
  402. Routine Description:
  403. This API frees up the resources associated with an enumeration initiated by FindOpenHSHADOW.
  404. Arguments:
  405. hShadowDB Handle to the shadow database as obtained from OpenShadowDatabaseIO.
  406. This API does not allow appssing in INVALID_HANDLE_VALUE.
  407. ulEnumCookie The enumeration handle returned in lpSI->uEnumCookie after a successful
  408. FindOpenHSHADOW call.
  409. Returns:
  410. Notes:
  411. --*/
  412. int AddHint(HANDLE hShadowDB, HSHADOW hDir, TCHAR *cFileName, LPHSHADOW lphShadow, unsigned long ulHintFlags, unsigned long ulHintPri);
  413. /*++
  414. Routine Description:
  415. This API allows callers to set pincount and other flags on a database entry
  416. Arguments:
  417. hShadowDB Handle to the shadow database as obtained from OpenShadowDatabaseIO.
  418. if INVALID_HANDLE_VALUE is passed in, the API, opens the shadow database,
  419. issues the corresponding ioctl, and closes it before returning.
  420. hDir The directory Inode value obtained from either a FindOpen/FindNext call or
  421. from an earlier call to a GetShadow(Ex)/CreateShadow routine, or 0 which
  422. indicates the root inode.
  423. cFileName The name of the element on which to set the pincount.
  424. lphShadow returns the Inode.
  425. ulHintFlags Misc flags to be set on the entry
  426. ulHintPri Pincount increment. Called hintpri for historical reasons.
  427. Returns:
  428. 1 if successful 0 if failed
  429. Notes:
  430. In the current implementation, the max pin count per entry is 255.
  431. --*/
  432. int DeleteHint(HANDLE hShadowDB, HSHADOW hDir, TCHAR *cFileName, BOOL fClearAll);
  433. /*++
  434. Routine Description:
  435. This API allows callers to decrement/remove pincount on a CSC database entry.
  436. Arguments:
  437. hShadowDB Handle to the shadow database as obtained from OpenShadowDatabaseIO.
  438. if INVALID_HANDLE_VALUE is passed in, the API, opens the shadow database,
  439. issues the corresponding ioctl, and closes it before returning.
  440. hDir The directory Inode value obtained from either a FindOpen/FindNext call or
  441. from an earlier call to a GetShadow(Ex)/CreateShadow routine, or 0 which
  442. indicates the root inode.
  443. cFileName The name of the element on which to set the pincount.
  444. fClearAll if TRUE, clears all pincounts and flags on the entry.
  445. Returns:
  446. 1 if successful 0 if failed
  447. Notes:
  448. --*/
  449. int SetMaxShadowSpace(HANDLE hShadowDB, long nFileSizeHigh, long nFileSizeLow);
  450. /*++
  451. Routine Description:
  452. Sets the maximum size of the shadow database
  453. Arguments:
  454. hShadowDB Handle to the shadow database as obtained from OpenShadowDatabaseIO.
  455. if INVALID_HANDLE_VALUE is passed in, the API, opens the shadow database,
  456. issues the corresponding ioctl, and closes it before returning.
  457. nFileSizeHigh The high order value of the space size
  458. nFileSizeLow The Low order value of the space size
  459. Returns:
  460. 1 if successful 0 otherwise
  461. Notes:
  462. Used by control panel shell extension to set the max space
  463. --*/
  464. int FreeShadowSpace(HANDLE hShadowDB, long nFileSizeHigh, long nFileSizeLow, BOOL fClearAll);
  465. /*++
  466. Routine Description:
  467. Allows the caller to free the requisite amount of space from the CSC database
  468. Arguments:
  469. hShadowDB Handle to the shadow database as obtained from OpenShadowDatabaseIO.
  470. if INVALID_HANDLE_VALUE is passed in, the API, opens the shadow database,
  471. issues the corresponding ioctl, and closes it before returning.
  472. nFileSizeHigh The high order value of the space size to be cleared
  473. nFileSizeLow The Low order value of the space size to be cleared
  474. fClearAll Clear the entire database, to the extent possible.
  475. Returns:
  476. 1 on success 0 on failure
  477. Notes:
  478. --*/
  479. int SetShareStatus(HANDLE hShadowDB, HSHARE hShare, unsigned long uStatus, unsigned long uOp);
  480. /*++
  481. Routine Description:
  482. This API allwos the caller to set the status bits on a share.
  483. Arguments:
  484. hShadowDB Handle to the shadow database as obtained from OpenShadowDatabaseIO.
  485. if INVALID_HANDLE_VALUE is passed in, the API, opens the shadow database,
  486. issues the corresponding ioctl, and closes it before returning.
  487. hShare Represents a share in the flat name space. hShare should have been
  488. obtained from lpSI->hShare of a successful call to GetShadowInfoEx
  489. or FindOpenHShadow/FindnextHShadow
  490. uStatus should have SHARE_xxx.
  491. uOp specifies operation SHADOW_FLAGS_ASSIGN, SHADOW_FLAGS_AND or SHADOW_FLAGS_OR
  492. to do the corresponding operation between the existing status bits and the
  493. one passed in the uStatus parameter.
  494. Returns:
  495. 1 if successful 0 if failed
  496. Notes:
  497. This should be used only for setting or clearing dirty bit on a share
  498. --*/
  499. int GetShareStatus(HANDLE hShadowDB, HSHARE hShare, unsigned long *lpulStatus);
  500. /*++
  501. Routine Description:
  502. This API allwos the caller to get the status bits set on a share.
  503. Arguments:
  504. hShadowDB Handle to the shadow database as obtained from OpenShadowDatabaseIO.
  505. if INVALID_HANDLE_VALUE is passed in, the API, opens the shadow database,
  506. issues the corresponding ioctl, and closes it before returning.
  507. hShare Represents a share in the flat name space. hShare should have been
  508. obtained from lpSI->hShare of a successful call to GetShadowInfoEx
  509. or FindOpenHShadow/FindnextHShadow
  510. lpuStatus Contains SHARE_xxx on return
  511. Returns:
  512. 1 if successful 0 if failed
  513. Notes:
  514. --*/
  515. int GetShareInfo(HANDLE hShadowDB, HSHARE hShare, LPSHAREINFO lpSVRI, unsigned long *lpulStatus);
  516. /*++
  517. Routine Description:
  518. This API allwos the caller to get the status bits set on a share as well at info about
  519. the filesystem it runs etc.
  520. Arguments:
  521. hShadowDB Handle to the shadow database as obtained from OpenShadowDatabaseIO.
  522. if INVALID_HANDLE_VALUE is passed in, the API, opens the shadow database,
  523. issues the corresponding ioctl, and closes it before returning.
  524. hShare Represents a share in the flat name space. hShare should have been
  525. obtained from lpSI->hShare of a successful call to GetShadowInfoEx
  526. or FindOpenHShadow/FindnextHShadow
  527. lpSVRI Info about the filesystem the share is running. Refer to shdcom.h
  528. lpuStatus Contains SHARE_xxx on return
  529. Returns:
  530. 1 if successful 0 if failed
  531. Notes:
  532. --*/
  533. /**************** Routines below this line for the agent and the NP ************************/
  534. int BeginInodeTransactionHSHADOW(
  535. VOID
  536. );
  537. /*++
  538. Routine Description:
  539. Arguments:
  540. Returns:
  541. Notes:
  542. --*/
  543. int EndInodeTransactionHSHADOW(
  544. VOID
  545. );
  546. /*++
  547. Routine Description:
  548. Arguments:
  549. Returns:
  550. Notes:
  551. --*/
  552. int ShadowSwitches(HANDLE hShadowDB, unsigned long * lpuSwitches, unsigned long uOp);
  553. /*++
  554. Routine Description:
  555. Arguments:
  556. Returns:
  557. Notes:
  558. --*/
  559. int BeginPQEnum(HANDLE hShadowDB, LPPQPARAMS lpPQP);
  560. /*++
  561. Routine Description:
  562. Begin priority Q enumeration
  563. Arguments:
  564. hShadowDB Handle to the shadow database as obtained from OpenShadowDatabaseIO.
  565. This API does not allow appssing in INVALID_HANDLE_VALUE.
  566. lpPQ if successful, lpPQ->uEnumCookie containes the handle for enumeration
  567. Returns:
  568. 1 if successful 0 otherwise
  569. Notes:
  570. --*/
  571. int NextPriShadow(HANDLE hShadowDB, LPPQPARAMS lpPQP);
  572. /*++
  573. Routine Description:
  574. Gets the next entry from the priority queue in the order of priority
  575. Arguments:
  576. hShadowDB Handle to the shadow database as obtained from OpenShadowDatabaseIO.
  577. This API does not allow appssing in INVALID_HANDLE_VALUE.
  578. lpPQ Input: Must be the same lpPQ that was used in an earlier BeginPQEnum/NextPriShadow
  579. Output: If successful and lpPQ->hShadow is nono-zero then the lpPQ contains
  580. the next priority queue entry. If lpPQ->hShadow is 0, then we are at
  581. the end of the enumeration.
  582. Returns:
  583. 1 if successful 0 otherwise
  584. Notes:
  585. --*/
  586. int PrevPriShadow(HANDLE hShadowDB, LPPQPARAMS lpPQP);
  587. /*++
  588. Routine Description:
  589. Arguments:
  590. Returns:
  591. Notes:
  592. --*/
  593. int EndPQEnum(HANDLE hShadowDB, LPPQPARAMS lpPQP);
  594. /*++
  595. Routine Description:
  596. Arguments:
  597. Returns:
  598. Notes:
  599. --*/
  600. int ChkUpdtStatus(HANDLE hShadowDB, unsigned long hDir, unsigned long hShadow, LPWIN32_FIND_DATA lpFind32, unsigned long *lpulShadowStatus);
  601. /*++
  602. Routine Description:
  603. Arguments:
  604. Returns:
  605. Notes:
  606. --*/
  607. int CopyChunk(HANDLE hShadowDB, LPSHADOWINFO lpSI, struct tagCOPYCHUNKCONTEXT FAR *CopyChunkContext);
  608. /*++
  609. Routine Description:
  610. Arguments:
  611. Returns:
  612. Notes:
  613. --*/
  614. // APIs for copying inward on NT, used only by the agent
  615. int OpenFileWithCopyChunkIntent(HANDLE hShadowDB, LPCWSTR lpFileName,
  616. struct tagCOPYCHUNKCONTEXT FAR *CopyChunkContext,
  617. int ChunkSize);
  618. int CloseFileWithCopyChunkIntent(HANDLE hShadowDB, struct tagCOPYCHUNKCONTEXT FAR *CopyChunkContext);
  619. int BeginReint(HSHARE hShare, BOOL fBlockingReint, LPVOID *lplpReintContext);
  620. /*++
  621. Routine Description:
  622. Arguments:
  623. Returns:
  624. Notes:
  625. --*/
  626. int EndReint(HSHARE hShare, LPVOID lpReintContext);
  627. /*++
  628. Routine Description:
  629. Arguments:
  630. Returns:
  631. Notes:
  632. --*/
  633. int RegisterAgent(HANDLE hShadowDB, HWND hwndAgent, HANDLE hEvent);
  634. /*++
  635. Routine Description:
  636. Arguments:
  637. Returns:
  638. Notes:
  639. --*/
  640. int UnregisterAgent(HANDLE hShadowDB, HWND hwndAgent);
  641. /*++
  642. Routine Description:
  643. Arguments:
  644. Returns:
  645. Notes:
  646. --*/
  647. int DisableShadowingForThisThread(HANDLE hShadowDB);
  648. /*++
  649. Routine Description:
  650. Arguments:
  651. Returns:
  652. Notes:
  653. --*/
  654. int EnableShadowingForThisThread(HANDLE hShadowDB);
  655. /*++
  656. Routine Description:
  657. Arguments:
  658. Returns:
  659. Notes:
  660. --*/
  661. int ReinitShadowDatabase(
  662. HANDLE hShadowDB,
  663. LPCSTR lpszDatabaseLocation, // location of the shadowing directory
  664. LPCSTR lpszUserName, // name of the user
  665. DWORD dwDefDataSizeHigh, // cache size if being created for the first time
  666. DWORD dwDefDataSizeLow,
  667. DWORD dwClusterSize
  668. );
  669. /*++
  670. Routine Description:
  671. Arguments:
  672. Returns:
  673. Notes:
  674. --*/
  675. int EnableShadowing(
  676. HANDLE hShadowDB,
  677. LPCSTR lpszDatabaseLocation, // location of the shadowing directory
  678. LPCSTR lpszUserName, // user name
  679. DWORD dwDefDataSizeHigh, // cache size if being created for the first time
  680. DWORD dwDefDataSizeLow,
  681. DWORD dwClusterSize, // clustersize for rounding database space
  682. BOOL fReformat
  683. );
  684. /*++
  685. Routine Description:
  686. Arguments:
  687. Returns:
  688. Notes:
  689. --*/
  690. int FindOpenHint(HANDLE hShadowDB, HSHADOW hDir, LPWIN32_FIND_DATA lpFind32, CSC_ENUMCOOKIE *lpuEnumCookie, HSHADOW *hShadow, unsigned long *lpulHintFlags, unsigned long *lpulHintPri);
  691. /*++
  692. Routine Description:
  693. Arguments:
  694. Returns:
  695. Notes:
  696. --*/
  697. int FindNextHint(HANDLE hShadowDB, CSC_ENUMCOOKIE uEnumCookie, LPWIN32_FIND_DATA lpFind32, HSHADOW *hShadow, unsigned long *lpulHintFlags, unsigned long *lpulHintPri);
  698. /*++
  699. Routine Description:
  700. Arguments:
  701. Returns:
  702. Notes:
  703. --*/
  704. int FindCloseHint(HANDLE hShadowDB, CSC_ENUMCOOKIE uEnumCookie);
  705. /*++
  706. Routine Description:
  707. Arguments:
  708. Returns:
  709. Notes:
  710. --*/
  711. AddHintFromInode(
  712. HANDLE hShadowDB,
  713. HSHADOW hDir,
  714. HSHADOW hShadow,
  715. unsigned long *lpulPinCount,
  716. unsigned long *lpulHintFlags
  717. );
  718. /*++
  719. Routine Description:
  720. The routine allows the caller to OR hintflags and increment one pincount, either for
  721. the system or for the user.
  722. Arguments:
  723. hShadowDB Handle to the shadow database as obtained from OpenShadowDatabaseIO.
  724. if INVALID_HANDLE_VALUE is passed in, the API, opens the shadow database,
  725. issues the corresponding ioctl, and closes it before returning.
  726. hDir Directory Inode
  727. hShadow Shadow on which the hintflags are to be applied
  728. lpulPinCount pincount on exit
  729. lpulHintFlags inout filed, contains flags to be ORed, returns the flags on the entry
  730. on a successful operation
  731. Returns:
  732. 1 if successful 0 if failed. It fails, if a) the pin count is about to go over MAX_PRI or
  733. b) it is attempting to pin it for the user but is already pinned for the user
  734. Notes:
  735. Mainly for CSCPinFile's use
  736. --*/
  737. DeleteHintFromInode(
  738. HANDLE hShadowDB,
  739. HSHADOW hDir,
  740. HSHADOW hShadow,
  741. unsigned long *lpulPinCount,
  742. unsigned long *lpulHintFlags
  743. );
  744. /*++
  745. Routine Description:
  746. The routine allows the caller to AND ~ of hintflags and decrement one pincount, either for
  747. the system or for the user.
  748. Arguments:
  749. hShadowDB Handle to the shadow database as obtained from OpenShadowDatabaseIO.
  750. if INVALID_HANDLE_VALUE is passed in, the API, opens the shadow database,
  751. issues the corresponding ioctl, and closes it before returning.
  752. hDir Directory Inode
  753. hShadow Shadow on which the hintflags are to be applied
  754. lpulPinCount pincount on exit
  755. lpulHintFlags inout filed, contains flags whose ~ is to be ANDed, returns the flags on the entry
  756. on a successful operation
  757. Returns:
  758. 1 if successful 0 if failed. It fails, if a) the pin count is about to go below MIN_PRI or
  759. b) it is attempting to unpin it for the user but isn't pinned for the user
  760. Notes:
  761. Mainly for CSCPinFile's use
  762. --*/
  763. int DoShadowMaintenance(HANDLE hShadowDB, unsigned long uOp);
  764. /*++
  765. Routine Description:
  766. The routine allows the caller to perform various maitenance tasks.
  767. Arguments:
  768. hShadowDB Handle to the shadow database as obtained from OpenShadowDatabaseIO.
  769. if INVALID_HANDLE_VALUE is passed in, the API, opens the shadow database,
  770. issues the corresponding ioctl, and closes it before returning.
  771. uOp Various operations to perform.
  772. Returns:
  773. 1 if successful 0 if failed
  774. Notes:
  775. Mainly for agents purposes, shouldn't be used by UI
  776. --*/
  777. BOOL
  778. IsNetDisconnected(
  779. DWORD dwErrorCode
  780. );
  781. /*++
  782. Routine Description:
  783. The routine checks from the errocode whether the net is disconnected
  784. Arguments:
  785. dwErrorCode one of the codes defined in winerror.h
  786. Returns:
  787. TRUE if net is disconnected, FALSE otherwise
  788. Notes:
  789. A central place for all CSC users of lib3, to know whether net is disconnected
  790. --*/
  791. BOOL
  792. PurgeUnpinnedFiles(
  793. HANDLE hShadowDB,
  794. LONG Timeout,
  795. PULONG pnFiles,
  796. PULONG pnYoungFiles);
  797. BOOL
  798. ShareIdToShareName(
  799. HANDLE hShadowDB,
  800. ULONG ShareId,
  801. PBYTE pBuffer,
  802. PDWORD pBufSize);
  803. BOOL
  804. CopyShadow(
  805. HANDLE hShadowDB,
  806. HSHADOW hDir,
  807. HSHADOW hShadow,
  808. TCHAR *lpFileName
  809. );
  810. /*++
  811. Routine Description:
  812. The routine makes a copy of an inode file in the CSC database
  813. Arguments:
  814. hDir Directory Inode
  815. hShadow Inode whose copy is wanted
  816. lpFileName Fully qualified local path of the filename to be given to the copy
  817. Returns:
  818. TRUE if the copy succeeded.
  819. Notes:
  820. Useful for backup/dragdrop etc.
  821. --*/
  822. LPCOPYPARAMSW
  823. LpAllocCopyParamsW(
  824. VOID
  825. );
  826. VOID
  827. FreeCopyParamsW(
  828. LPCOPYPARAMSW lpCP
  829. );
  830. LPCOPYPARAMSA
  831. LpAllocCopyParamsA(
  832. VOID
  833. );
  834. VOID
  835. FreeCopyParamsA(
  836. LPCOPYPARAMSA lpCP
  837. );
  838. int
  839. GetSecurityInfoForCSC(
  840. HANDLE hShadowDB,
  841. HSHADOW hDir,
  842. HSHADOW hShadow,
  843. LPSECURITYINFO lpSecurityInfo,
  844. DWORD *lpdwBufferSize
  845. );
  846. int
  847. FindCreatePrincipalIDFromSID(
  848. HANDLE hShadowDB,
  849. LPVOID lpSidBuffer,
  850. ULONG cbSidLength,
  851. ULONG *lpuPrincipalID,
  852. BOOL fCreate
  853. );
  854. BOOL
  855. SetExclusionList(
  856. HANDLE hShadowDB,
  857. LPWSTR lpwList,
  858. DWORD cbSize
  859. );
  860. BOOL
  861. SetBandwidthConservationList(
  862. HANDLE hShadowDB,
  863. LPWSTR lpwList,
  864. DWORD cbSize
  865. );
  866. BOOL
  867. TransitionShareToOffline(
  868. HANDLE hShadowDB,
  869. HSHARE hShare,
  870. BOOL fTransition
  871. );
  872. BOOL
  873. TransitionShareToOnline(
  874. HANDLE hShadowDB,
  875. HSHARE hShare
  876. );
  877. BOOL
  878. IsServerOfflineW(
  879. HANDLE hShadowDB,
  880. LPCWSTR lptzServer,
  881. BOOL *lpfOffline
  882. );
  883. BOOL
  884. IsServerOfflineA(
  885. HANDLE hShadowDB,
  886. LPCSTR lptzServer,
  887. BOOL *lpfOffline
  888. );
  889. int GetShadowDatabaseLocation(
  890. HANDLE hShadowDB,
  891. WIN32_FIND_DATA *lpFind32
  892. );
  893. int
  894. GetSpaceStats(
  895. HANDLE hShadowDB,
  896. SHADOWSTORE *lpsST
  897. );
  898. BOOL
  899. GetNameOfServerGoingOfflineW(
  900. HANDLE hShadowDB,
  901. LPBYTE lpBuffer,
  902. LPDWORD lpdwSize
  903. );
  904. BOOL
  905. RenameShadow(
  906. HANDLE hShadowDB,
  907. HSHADOW hDirFrom,
  908. HSHADOW hShadowFrom,
  909. HSHADOW hDirTo,
  910. LPWIN32_FIND_DATAW lpFind32,
  911. BOOL fReplaceFileIfExists,
  912. HSHADOW *lphShadowTo
  913. );
  914. BOOL
  915. GetSparseStaleDetectionCounter(
  916. HANDLE hShadowDB,
  917. LPDWORD lpdwCounter
  918. );
  919. BOOL
  920. GetManualFileDetectionCounter(
  921. HANDLE hShadowDB,
  922. LPDWORD lpdwCounter
  923. );
  924. int EnableShadowingForUser(
  925. HANDLE hShadowDB,
  926. LPCSTR lpszDatabaseLocation, // location of the shadowing directory
  927. LPCSTR lpszUserName, // name of the user
  928. DWORD dwDefDataSizeHigh, // cache size if being created for the first time
  929. DWORD dwDefDataSizeLow,
  930. DWORD dwClusterSize,
  931. BOOL fReformat
  932. );
  933. int DisableShadowingForUser(
  934. HANDLE hShadowDB
  935. );
  936. HANDLE
  937. OpenShadowDatabaseIOex(
  938. ULONG WaitForDriver,
  939. DWORD dwFlags);
  940. BOOL
  941. RecreateShadow(
  942. HANDLE hShadowDB,
  943. HSHADOW hDir,
  944. HSHADOW hShadow,
  945. ULONG ulAttrib
  946. );
  947. BOOL
  948. SetDatabaseStatus(
  949. HANDLE hShadowDB,
  950. ULONG ulStatus,
  951. ULONG uMask
  952. );
  953. #ifdef __cplusplus
  954. }
  955. #endif
  956. #endif