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.

377 lines
10 KiB

  1. /*++
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. fileinfo.c
  5. Abstract:
  6. This module implements the mini redirector call down routines pertaining to retrieval/
  7. update of file/directory/volume information.
  8. Author:
  9. Balan Sethu Raman [SethuR] 7-March-1995
  10. Revision History:
  11. --*/
  12. #include "precomp.h"
  13. #pragma hdrstop
  14. #pragma warning(error:4101) // Unreferenced local variable
  15. RXDT_DefineCategory(VOLINFO);
  16. #undef Dbg
  17. #define Dbg (DEBUG_TRACE_VOLINFO)
  18. NTSTATUS
  19. MRxProxyQueryVolumeInformation(
  20. IN OUT PRX_CONTEXT RxContext
  21. )
  22. /*++
  23. Routine Description:
  24. This routine queries the volume information
  25. Arguments:
  26. pRxContext - the RDBSS context
  27. Return Value:
  28. RXSTATUS - The return status for the operation
  29. --*/
  30. {
  31. NTSTATUS Status;
  32. RxCaptureFcb;
  33. RxCaptureFobx;
  34. PMRX_PROXY_SRV_OPEN proxySrvOpen;
  35. FS_INFORMATION_CLASS FsInformationClass = RxContext->Info.FsInformationClass;
  36. PVOID pBuffer = RxContext->Info.Buffer;
  37. PLONG pLengthRemaining = &RxContext->Info.LengthRemaining;
  38. PFILE_OBJECT FileObject;
  39. ULONG PassedInLength,ReturnedLength;
  40. PAGED_CODE();
  41. if (capFobx == NULL) {
  42. return STATUS_INVALID_PARAMETER;
  43. }
  44. TURN_BACK_ASYNCHRONOUS_OPERATIONS();
  45. proxySrvOpen = MRxProxyGetSrvOpenExtension(capFobx->pSrvOpen);
  46. FileObject = proxySrvOpen->UnderlyingFileObject;
  47. ASSERT (FileObject);
  48. PassedInLength = *pLengthRemaining;
  49. Status = MRxProxySyncXxxInformation(
  50. RxContext, //IN OUT PRX_CONTEXT RxContext,
  51. IRP_MJ_QUERY_VOLUME_INFORMATION, //IN UCHAR MajorFunction,
  52. FileObject, //IN PFILE_OBJECT FileObject,
  53. FsInformationClass, //IN ULONG InformationClass,
  54. PassedInLength, //IN ULONG Length,
  55. pBuffer, //OUT PVOID Information,
  56. &ReturnedLength //OUT PULONG ReturnedLength OPTIONAL
  57. );
  58. if (!NT_ERROR(Status)) {
  59. *pLengthRemaining -= ReturnedLength;
  60. }
  61. if (!NT_SUCCESS(Status)) {
  62. RxDbgTrace( 0, Dbg, ("MRxProxyQueryVolumeInformation: Failed .. returning %lx\n",Status));
  63. }
  64. return Status;
  65. }
  66. NTSTATUS
  67. MRxProxySetVolumeInformation(
  68. IN OUT PRX_CONTEXT pRxContext
  69. )
  70. /*++
  71. Routine Description:
  72. This routine sets the volume information
  73. Arguments:
  74. pRxContext - the RDBSS context
  75. FsInformationClass - the kind of Fs information desired.
  76. pBuffer - the buffer for copying the information
  77. BufferLength - the buffer length
  78. Return Value:
  79. RXSTATUS - The return status for the operation
  80. --*/
  81. {
  82. //FS_INFORMATION_CLASS FsInformationClass = RxContext->Info.FsInformationClass;
  83. //PVOID pBuffer = RxContext->Info.Buffer;
  84. //LONG BufferLength = RxContext->Info.Length;
  85. return STATUS_NOT_IMPLEMENTED;
  86. }
  87. RXDT_DefineCategory(FILEINFO);
  88. #undef Dbg
  89. #define Dbg (DEBUG_TRACE_FILEINFO)
  90. NTSTATUS
  91. MRxProxyQueryFileInformation(
  92. IN PRX_CONTEXT RxContext
  93. )
  94. /*++
  95. Routine Description:
  96. This routine does a query file info.
  97. Arguments:
  98. RxContext - the RDBSS context
  99. Return Value:
  100. RXSTATUS - The return status for the operation
  101. --*/
  102. {
  103. NTSTATUS Status;
  104. RxCaptureFcb;
  105. RxCaptureFobx;
  106. FILE_INFORMATION_CLASS FileInformationClass;
  107. PVOID pBuffer;
  108. PULONG pLengthRemaining;
  109. PMRX_PROXY_SRV_OPEN proxySrvOpen = MRxProxyGetSrvOpenExtension(capFobx->pSrvOpen);
  110. //PMRX_PROXY_FCB proxyFcb = MRxProxyGetFcbExtension(capFcb);
  111. PFILE_OBJECT FileObject;
  112. ULONG PassedInLength,ReturnedLength;
  113. PUNICODE_STRING RemainingName = &(capFcb->AlreadyPrefixedName);
  114. PMRX_NET_ROOT NetRoot = capFcb->pNetRoot;
  115. PAGED_CODE();
  116. FileInformationClass = RxContext->Info.FileInformationClass;
  117. pBuffer = RxContext->Info.Buffer;
  118. pLengthRemaining = &RxContext->Info.LengthRemaining;
  119. RxDbgTrace(+1, Dbg, ("MRxProxyQueryFileInformation: class=%08lx\n",FileInformationClass));
  120. TURN_BACK_ASYNCHRONOUS_OPERATIONS();
  121. FileObject = proxySrvOpen->UnderlyingFileObject;
  122. ASSERT (FileObject);
  123. PassedInLength = *pLengthRemaining;
  124. Status = MRxProxySyncXxxInformation(
  125. RxContext, //IN OUT PRX_CONTEXT RxContext,
  126. IRP_MJ_QUERY_INFORMATION, //IN UCHAR MajorFunction,
  127. FileObject, //IN PFILE_OBJECT FileObject,
  128. FileInformationClass, //IN ULONG InformationClass,
  129. PassedInLength, //IN ULONG Length,
  130. pBuffer, //OUT PVOID Information,
  131. &ReturnedLength //OUT PULONG ReturnedLength OPTIONAL
  132. );
  133. if (!NT_ERROR(Status)) {
  134. *pLengthRemaining -= ReturnedLength;
  135. }
  136. if (!NT_SUCCESS(Status)) {
  137. RxDbgTrace( 0, Dbg, ("MRxProxyQueryFile: Failed .. returning %lx\n",Status));
  138. }
  139. RxDbgTraceUnIndent(-1,Dbg);
  140. return Status;
  141. }
  142. typedef enum _INTERESTING_SFI_FOLLOWONS {
  143. SFI_FOLLOWON_NOTHING,
  144. SFI_FOLLOWON_DISPOSITION_SENT
  145. } INTERESTING_SFI_FOLLOWONS;
  146. #if DBG
  147. VOID
  148. MRxProxyDumpRenameInfo (
  149. PSZ Msg,
  150. PFILE_RENAME_INFORMATION RenameInfo,
  151. ULONG BufferLength
  152. )
  153. {
  154. UNICODE_STRING sss;
  155. sss.Buffer = &RenameInfo->FileName[0];
  156. sss.Length = ((USHORT)(RenameInfo->FileNameLength));
  157. RxDbgTrace(0, Dbg, ("MRxProxyDumpRenameInfo: %s %08lx %wZ\n",Msg,BufferLength,&sss));
  158. }
  159. #else
  160. #define MRxProxyDumpRenameInfo(a,b,c);
  161. #endif
  162. NTSTATUS
  163. MRxProxySetFileInformation(
  164. IN PRX_CONTEXT RxContext
  165. )
  166. /*++
  167. Routine Description:
  168. This routine does a set file info.
  169. it works by just remoting the call basically without further ado.
  170. Arguments:
  171. RxContext - the RDBSS context
  172. Return Value:
  173. RXSTATUS - The return status for the operation
  174. --*/
  175. {
  176. NTSTATUS Status;
  177. RxCaptureFcb;
  178. RxCaptureFobx;
  179. FILE_INFORMATION_CLASS FileInformationClass;
  180. PVOID pBuffer;
  181. ULONG BufferLength;
  182. //PMRX_PROXY_FOBX proxyFobx = MRxProxyGetFileObjectExtension(capFobx);
  183. PMRX_PROXY_SRV_OPEN proxySrvOpen = MRxProxyGetSrvOpenExtension(capFobx->pSrvOpen);
  184. //PMRX_PROXY_FCB proxyFcb = MRxProxyGetFcbExtension(capFcb);
  185. PFILE_OBJECT UnderlyingFileObject = proxySrvOpen->UnderlyingFileObject;
  186. PAGED_CODE();
  187. TURN_BACK_ASYNCHRONOUS_OPERATIONS();
  188. FileInformationClass = RxContext->Info.FileInformationClass;
  189. pBuffer = RxContext->Info.Buffer;
  190. BufferLength = RxContext->Info.Length;
  191. RxDbgTrace(+1, Dbg, ("MRxProxySetFile: Class %08lx size %08lx\n",FileInformationClass,BufferLength));
  192. if (FileInformationClass==FileRenameInformation) {
  193. PFILE_RENAME_INFORMATION RenameInfo = (PFILE_RENAME_INFORMATION)pBuffer;
  194. if (RenameInfo->FileName[0] == L'\\') {
  195. //here, we have to carefully copy the the rename prefix
  196. PWCHAR w;
  197. PMRXPROXY_DEVICE_OBJECT MRxProxyDeviceObject = (PMRXPROXY_DEVICE_OBJECT)(RxContext->RxDeviceObject);
  198. PUNICODE_STRING RenamePrefix = &MRxProxyDeviceObject->PrefixForRename;
  199. ULONG prefixlength;
  200. MRxProxyDumpRenameInfo("Before:",RenameInfo,BufferLength);
  201. prefixlength = (RenamePrefix->Length)/sizeof(WCHAR);
  202. w = (&(RenameInfo->FileName[0])) + ((RenameInfo->FileNameLength)/sizeof(WCHAR));
  203. for (;;) {
  204. w--;
  205. //DbgPrint ("yaya %c\n",*w);
  206. *(w+prefixlength) = *w;
  207. if ( w == (&(RenameInfo->FileName[0])) ) {
  208. break;
  209. }
  210. }
  211. RtlCopyMemory(&(RenameInfo->FileName[0]),RenamePrefix->Buffer,RenamePrefix->Length);
  212. RenameInfo->FileNameLength += RenamePrefix->Length;
  213. BufferLength += RenamePrefix->Length;
  214. MRxProxyDumpRenameInfo(" After:",RenameInfo,BufferLength);
  215. //DbgBreakPoint();
  216. }
  217. }
  218. if(BufferLength==0){
  219. //zero length means that this is the special calldown from the cachemanager...for now just boost
  220. //joejoe this should be fixed soon
  221. BufferLength = sizeof(FILE_END_OF_FILE_INFORMATION);
  222. }
  223. RxDbgTrace( 0, Dbg, (" ---->UserBuffer = %08lx\n", pBuffer));
  224. ASSERT (UnderlyingFileObject);
  225. //this could be a setfileinfo that comes in from the lazywriter
  226. //after the underlying file has already been cleaned up
  227. //BUGBUG not too sure about this...........
  228. if (UnderlyingFileObject == NULL) {
  229. Status = STATUS_FILE_CLOSED;
  230. RxDbgTrace(-1, Dbg, (" ---->AlreadyClosed!!! Status = %08lx\n", Status));
  231. return(Status);
  232. }
  233. Status = MRxProxySyncXxxInformation(
  234. RxContext, //IN OUT PRX_CONTEXT RxContext,
  235. IRP_MJ_SET_INFORMATION, //IN UCHAR MajorFunction,
  236. UnderlyingFileObject, //IN PFILE_OBJECT FileObject,
  237. FileInformationClass, //IN ULONG InformationClass,
  238. BufferLength, //IN ULONG Length,
  239. pBuffer, //OUT PVOID Information,
  240. NULL //OUT PULONG ReturnedLength OPTIONAL
  241. );
  242. if (!NT_SUCCESS(Status)) {
  243. RxDbgTrace( 0, Dbg, ("MRxProxySetFile: Failed .. returning %lx\n",Status));
  244. }
  245. RxDbgTraceUnIndent(-1,Dbg);
  246. return Status;
  247. }
  248. NTSTATUS
  249. MRxProxySetFileInformationAtCleanup(
  250. IN PRX_CONTEXT RxContext
  251. )
  252. /*++
  253. Routine Description:
  254. This routine sets the file information on cleanup. rdrs just swallow this operation (i.e.
  255. it doesn't generate it). we cannot do the same because we are local..........
  256. This routine implements the set file info call called on cleanup or flush. We dont actually set the times
  257. but we do the endoffile info.
  258. Arguments:
  259. pRxContext - the RDBSS context
  260. Return Value:
  261. RXSTATUS - The return status for the operation
  262. --*/
  263. {
  264. NTSTATUS Status;
  265. FILE_INFORMATION_CLASS FileInformationClass;
  266. TURN_BACK_ASYNCHRONOUS_OPERATIONS();
  267. FileInformationClass = RxContext->Info.FileInformationClass;
  268. if (FileInformationClass == FileBasicInformation) {
  269. return(STATUS_SUCCESS);
  270. }
  271. RxDbgTrace(+1, Dbg, ("MRxLocalSetFileInfoAtCleanup...\n"));
  272. Status = MRxProxySetFileInformation(RxContext);
  273. RxDbgTrace(-1, Dbg, ("MRxLocalSetFileInfoAtCleanup...status =%08lx\n", Status));
  274. }
  275.