Windows: smb_ReceiveTran2QFileInfo Pioctl support
[openafs.git] / src / WINNT / afsrdr / kernel / lib / AFSFileInfo.cpp
1 /*
2  * Copyright (c) 2008, 2009, 2010, 2011 Kernel Drivers, LLC.
3  * Copyright (c) 2009, 2010, 2011 Your File System, Inc.
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  *
10  * - Redistributions of source code must retain the above copyright notice,
11  *   this list of conditions and the following disclaimer.
12  * - Redistributions in binary form must reproduce the above copyright
13  *   notice,
14  *   this list of conditions and the following disclaimer in the
15  *   documentation
16  *   and/or other materials provided with the distribution.
17  * - Neither the names of Kernel Drivers, LLC and Your File System, Inc.
18  *   nor the names of their contributors may be used to endorse or promote
19  *   products derived from this software without specific prior written
20  *   permission from Kernel Drivers, LLC and Your File System, Inc.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
24  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
25  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
26  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
27  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
28  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
29  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
30  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
31  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  */
34
35 //
36 // File: AFSFileInfo.cpp
37 //
38
39 #include "AFSCommon.h"
40
41 //
42 // Function: AFSQueryFileInfo
43 //
44 // Description:
45 //
46 //      This function is the dispatch handler for the IRP_MJ_QUERY_FILE_INFORMATION request
47 //
48 // Return:
49 //
50 //      A status is returned for the function
51 //
52
53 NTSTATUS
54 AFSQueryFileInfo( IN PDEVICE_OBJECT LibDeviceObject,
55                   IN PIRP Irp)
56 {
57
58     NTSTATUS ntStatus = STATUS_SUCCESS;
59     AFSDeviceExt *pDeviceExt = (AFSDeviceExt *)AFSRDRDeviceObject->DeviceExtension;
60     ULONG ulRequestType = 0;
61     IO_STACK_LOCATION *pIrpSp = IoGetCurrentIrpStackLocation( Irp);
62     AFSFcb *pFcb = NULL;
63     AFSCcb *pCcb = NULL;
64     PFILE_OBJECT pFileObject;
65     BOOLEAN bReleaseMain = FALSE;
66     LONG lLength;
67     FILE_INFORMATION_CLASS stFileInformationClass;
68     PVOID pBuffer;
69
70     __try
71     {
72
73         //
74         // Determine the type of request this request is
75         //
76
77         pFcb = (AFSFcb *)pIrpSp->FileObject->FsContext;
78
79         pCcb = (AFSCcb *)pIrpSp->FileObject->FsContext2;
80
81         if( pFcb == NULL)
82         {
83
84             AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
85                           AFS_TRACE_LEVEL_ERROR,
86                           "AFSQueryFileInfo Attempted access (%08lX) when pFcb == NULL\n",
87                           Irp);
88
89             try_return( ntStatus = STATUS_INVALID_DEVICE_REQUEST);
90         }
91
92         lLength = (LONG)pIrpSp->Parameters.QueryFile.Length;
93         stFileInformationClass = pIrpSp->Parameters.QueryFile.FileInformationClass;
94         pBuffer = Irp->AssociatedIrp.SystemBuffer;
95
96         //
97         // Grab the main shared right off the bat
98         //
99
100         AFSDbgLogMsg( AFS_SUBSYSTEM_LOCK_PROCESSING,
101                       AFS_TRACE_LEVEL_VERBOSE,
102                       "AFSQueryFileInfo Acquiring Fcb lock %08lX SHARED %08lX\n",
103                       &pFcb->NPFcb->Resource,
104                       PsGetCurrentThread());
105
106         AFSAcquireShared( &pFcb->NPFcb->Resource,
107                           TRUE);
108
109         bReleaseMain = TRUE;
110
111         //
112         // Don't allow requests against IOCtl nodes
113         //
114
115         if( pFcb->Header.NodeTypeCode == AFS_SPECIAL_SHARE_FCB)
116         {
117
118             AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
119                           AFS_TRACE_LEVEL_VERBOSE,
120                           "AFSQueryFileInfo Processing request against SpecialShare Fcb\n");
121
122             ntStatus = AFSProcessShareQueryInfo( Irp,
123                                                  pFcb,
124                                                  pCcb);
125
126             try_return( ntStatus);
127         }
128         else if( pFcb->Header.NodeTypeCode == AFS_IOCTL_FCB)
129         {
130             AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
131                           AFS_TRACE_LEVEL_VERBOSE,
132                           "AFSQueryFileInfo request against PIOCtl Fcb\n");
133
134             ntStatus = AFSProcessPIOCtlQueryInfo( Irp,
135                                                   pFcb,
136                                                   pCcb,
137                                                   &lLength);
138
139             try_return( ntStatus);
140         }
141
142         else if( pFcb->Header.NodeTypeCode == AFS_INVALID_FCB)
143         {
144             AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
145                           AFS_TRACE_LEVEL_VERBOSE,
146                           "AFSQueryFileInfo request against Invalid Fcb\n");
147
148             try_return( ntStatus = STATUS_ACCESS_DENIED);
149         }
150
151         //
152         // Process the request
153         //
154
155         switch( stFileInformationClass)
156         {
157
158             case FileAllInformation:
159             {
160
161                 PFILE_ALL_INFORMATION pAllInfo;
162
163                 //
164                 //  For the all information class we'll typecast a local
165                 //  pointer to the output buffer and then call the
166                 //  individual routines to fill in the buffer.
167                 //
168
169                 pAllInfo = (PFILE_ALL_INFORMATION)pBuffer;
170
171                 ntStatus = AFSQueryBasicInfo( Irp,
172                                               pCcb->DirectoryCB,
173                                               &pAllInfo->BasicInformation,
174                                               &lLength);
175
176                 if( !NT_SUCCESS( ntStatus))
177                 {
178
179                     try_return( ntStatus);
180                 }
181
182                 ntStatus = AFSQueryStandardInfo( Irp,
183                                                  pCcb->DirectoryCB,
184                                                  &pAllInfo->StandardInformation,
185                                                  &lLength);
186
187                 if( !NT_SUCCESS( ntStatus))
188                 {
189
190                     try_return( ntStatus);
191                 }
192
193                 ntStatus = AFSQueryInternalInfo( Irp,
194                                                  pFcb,
195                                                  &pAllInfo->InternalInformation,
196                                                  &lLength);
197
198                 if( !NT_SUCCESS( ntStatus))
199                 {
200
201                     try_return( ntStatus);
202                 }
203
204                 ntStatus = AFSQueryEaInfo( Irp,
205                                            pCcb->DirectoryCB,
206                                            &pAllInfo->EaInformation,
207                                            &lLength);
208
209                 if( !NT_SUCCESS( ntStatus))
210                 {
211
212                     try_return( ntStatus);
213                 }
214
215                 ntStatus = AFSQueryAccess( Irp,
216                                            pFcb,
217                                            &pAllInfo->AccessInformation,
218                                            &lLength);
219
220                 if( !NT_SUCCESS( ntStatus))
221                 {
222
223                     try_return( ntStatus);
224                 }
225
226                 ntStatus = AFSQueryPositionInfo( Irp,
227                                                  pFcb,
228                                                  &pAllInfo->PositionInformation,
229                                                  &lLength);
230
231                 if( !NT_SUCCESS( ntStatus))
232                 {
233
234                     try_return( ntStatus);
235                 }
236
237                 ntStatus = AFSQueryMode( Irp,
238                                          pFcb,
239                                          &pAllInfo->ModeInformation,
240                                          &lLength);
241
242                 if( !NT_SUCCESS( ntStatus))
243                 {
244
245                     try_return( ntStatus);
246                 }
247
248                 ntStatus = AFSQueryAlignment( Irp,
249                                               pFcb,
250                                               &pAllInfo->AlignmentInformation,
251                                               &lLength);
252
253                 if( !NT_SUCCESS( ntStatus))
254                 {
255
256                     try_return( ntStatus);
257                 }
258
259                 ntStatus = AFSQueryNameInfo( Irp,
260                                              pCcb->DirectoryCB,
261                                              &pAllInfo->NameInformation,
262                                              &lLength);
263
264                 if( !NT_SUCCESS( ntStatus))
265                 {
266
267                     try_return( ntStatus);
268                 }
269
270                 break;
271             }
272
273             case FileBasicInformation:
274             {
275
276                 ntStatus = AFSQueryBasicInfo( Irp,
277                                               pCcb->DirectoryCB,
278                                               (PFILE_BASIC_INFORMATION)pBuffer,
279                                               &lLength);
280
281                 break;
282             }
283
284             case FileStandardInformation:
285             {
286
287                 ntStatus = AFSQueryStandardInfo( Irp,
288                                                  pCcb->DirectoryCB,
289                                                  (PFILE_STANDARD_INFORMATION)pBuffer,
290                                                  &lLength);
291
292                 break;
293             }
294
295             case FileInternalInformation:
296             {
297
298                 ntStatus = AFSQueryInternalInfo( Irp,
299                                                  pFcb,
300                                                  (PFILE_INTERNAL_INFORMATION)pBuffer,
301                                                  &lLength);
302
303                 break;
304             }
305
306             case FileEaInformation:
307             {
308
309                 ntStatus = AFSQueryEaInfo( Irp,
310                                            pCcb->DirectoryCB,
311                                            (PFILE_EA_INFORMATION)pBuffer,
312                                            &lLength);
313
314                 break;
315             }
316
317             case FilePositionInformation:
318             {
319
320                 ntStatus = AFSQueryPositionInfo( Irp,
321                                       pFcb,
322                                       (PFILE_POSITION_INFORMATION)pBuffer,
323                                       &lLength);
324
325                 break;
326             }
327
328             case FileNormalizedNameInformation:
329             case FileNameInformation:
330             {
331
332                 ntStatus = AFSQueryNameInfo( Irp,
333                                   pCcb->DirectoryCB,
334                                   (PFILE_NAME_INFORMATION)pBuffer,
335                                   &lLength);
336
337                 break;
338             }
339
340             case FileAlternateNameInformation:
341             {
342
343                 ntStatus = AFSQueryShortNameInfo( Irp,
344                                        pCcb->DirectoryCB,
345                                        (PFILE_NAME_INFORMATION)pBuffer,
346                                        &lLength);
347
348                 break;
349             }
350
351             case FileNetworkOpenInformation:
352             {
353
354                 ntStatus = AFSQueryNetworkInfo( Irp,
355                                      pCcb->DirectoryCB,
356                                      (PFILE_NETWORK_OPEN_INFORMATION)pBuffer,
357                                      &lLength);
358
359                 break;
360             }
361
362             case FileStreamInformation:
363             {
364
365                 ntStatus = AFSQueryStreamInfo( Irp,
366                                                pCcb->DirectoryCB,
367                                                (FILE_STREAM_INFORMATION *)pBuffer,
368                                                &lLength);
369
370                 break;
371             }
372
373
374             case FileAttributeTagInformation:
375             {
376
377                 ntStatus = AFSQueryAttribTagInfo( Irp,
378                                                   pCcb->DirectoryCB,
379                                                   (FILE_ATTRIBUTE_TAG_INFORMATION *)pBuffer,
380                                                   &lLength);
381
382                 break;
383             }
384
385             case FileRemoteProtocolInformation:
386             {
387
388                     ntStatus = AFSQueryRemoteProtocolInfo( Irp,
389                                                            pCcb->DirectoryCB,
390                                                            (FILE_REMOTE_PROTOCOL_INFORMATION *)pBuffer,
391                                                            &lLength);
392
393                 break;
394             }
395
396             case FileNetworkPhysicalNameInformation:
397             {
398
399                 ntStatus = AFSQueryPhysicalNameInfo( Irp,
400                                                      pCcb->DirectoryCB,
401                                                      (FILE_NETWORK_PHYSICAL_NAME_INFORMATION *)pBuffer,
402                                                      &lLength);
403
404                 break;
405             }
406
407             default:
408             {
409                 ntStatus = STATUS_INVALID_PARAMETER;
410                 break;
411             }
412         }
413
414 try_exit:
415
416         Irp->IoStatus.Information = pIrpSp->Parameters.QueryFile.Length - lLength;
417
418         if( bReleaseMain)
419         {
420
421             AFSReleaseResource( &pFcb->NPFcb->Resource);
422         }
423
424         if( !NT_SUCCESS( ntStatus) &&
425             ntStatus != STATUS_INVALID_PARAMETER &&
426             ntStatus != STATUS_BUFFER_OVERFLOW)
427         {
428
429             if( pCcb != NULL &&
430                 pCcb->DirectoryCB != NULL)
431             {
432
433                 AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
434                               AFS_TRACE_LEVEL_ERROR,
435                               "AFSQueryFileInfo Failed to process request for %wZ FID %08lX-%08lX-%08lX-%08lX Status %08lX\n",
436                               &pCcb->DirectoryCB->NameInformation.FileName,
437                               pCcb->DirectoryCB->ObjectInformation->FileId.Cell,
438                               pCcb->DirectoryCB->ObjectInformation->FileId.Volume,
439                               pCcb->DirectoryCB->ObjectInformation->FileId.Vnode,
440                               pCcb->DirectoryCB->ObjectInformation->FileId.Unique,
441                               ntStatus);
442             }
443         }
444     }
445     __except( AFSExceptionFilter( __FUNCTION__, GetExceptionCode(), GetExceptionInformation()) )
446     {
447
448         AFSDbgLogMsg( 0,
449                       0,
450                       "EXCEPTION - AFSQueryFileInfo\n");
451
452         AFSDumpTraceFilesFnc();
453
454         ntStatus = STATUS_UNSUCCESSFUL;
455
456         if( bReleaseMain)
457         {
458
459             AFSReleaseResource( &pFcb->NPFcb->Resource);
460         }
461     }
462
463     AFSCompleteRequest( Irp,
464                         ntStatus);
465
466     return ntStatus;
467 }
468
469 //
470 // Function: AFSSetFileInfo
471 //
472 // Description:
473 //
474 //      This function is the dispatch handler for the IRP_MJ_SET_FILE_INFORMATION request
475 //
476 // Return:
477 //
478 //      A status is returned for the function
479 //
480
481 NTSTATUS
482 AFSSetFileInfo( IN PDEVICE_OBJECT LibDeviceObject,
483                 IN PIRP Irp)
484 {
485
486     NTSTATUS ntStatus = STATUS_SUCCESS;
487     AFSDeviceExt *pDeviceExt = (AFSDeviceExt *)AFSRDRDeviceObject->DeviceExtension;
488     IO_STACK_LOCATION *pIrpSp = IoGetCurrentIrpStackLocation( Irp);
489     AFSFcb *pFcb = NULL;
490     AFSCcb *pCcb = NULL;
491     BOOLEAN bCompleteRequest = TRUE;
492     FILE_INFORMATION_CLASS FileInformationClass;
493     BOOLEAN bCanQueueRequest = FALSE;
494     PFILE_OBJECT pFileObject = NULL;
495     BOOLEAN bReleaseMain = FALSE;
496     BOOLEAN bUpdateFileInfo = FALSE;
497     AFSFileID stParentFileId;
498
499     __try
500     {
501
502         pFileObject = pIrpSp->FileObject;
503
504         pFcb = (AFSFcb *)pFileObject->FsContext;
505         pCcb = (AFSCcb *)pFileObject->FsContext2;
506
507         if( pFcb == NULL)
508         {
509
510             AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
511                           AFS_TRACE_LEVEL_ERROR,
512                           "AFSSetFileInfo Attempted access (%08lX) when pFcb == NULL\n",
513                           Irp);
514
515             try_return( ntStatus = STATUS_INVALID_DEVICE_REQUEST);
516         }
517
518         bCanQueueRequest = !(IoIsOperationSynchronous( Irp) | (KeGetCurrentIrql() != PASSIVE_LEVEL));
519         FileInformationClass = pIrpSp->Parameters.SetFile.FileInformationClass;
520
521         //
522         // Grab the Fcb EXCL
523         //
524
525         AFSDbgLogMsg( AFS_SUBSYSTEM_LOCK_PROCESSING,
526                       AFS_TRACE_LEVEL_VERBOSE,
527                       "AFSSetFileInfo Acquiring Fcb lock %08lX EXCL %08lX\n",
528                       &pFcb->NPFcb->Resource,
529                       PsGetCurrentThread());
530
531         AFSAcquireExcl( &pFcb->NPFcb->Resource,
532                         TRUE);
533
534         bReleaseMain = TRUE;
535
536         //
537         // Don't allow requests against IOCtl nodes
538         //
539
540         if( pFcb->Header.NodeTypeCode == AFS_IOCTL_FCB)
541         {
542
543             AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
544                           AFS_TRACE_LEVEL_ERROR,
545                           "AFSSetFileInfo Failing request against PIOCtl Fcb\n");
546
547             try_return( ntStatus = STATUS_INVALID_DEVICE_REQUEST);
548         }
549         else if( pFcb->Header.NodeTypeCode == AFS_SPECIAL_SHARE_FCB)
550         {
551
552             AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
553                           AFS_TRACE_LEVEL_VERBOSE,
554                           "AFSSetFileInfo Processing request against SpecialShare Fcb\n");
555
556             ntStatus = AFSProcessShareSetInfo( Irp,
557                                                pFcb,
558                                                pCcb);
559
560             try_return( ntStatus);
561         }
562
563         if( BooleanFlagOn( pFcb->ObjectInformation->VolumeCB->VolumeInformation.Characteristics, FILE_READ_ONLY_DEVICE))
564         {
565
566             AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
567                           AFS_TRACE_LEVEL_ERROR,
568                           "AFSSetFileInfo Request failed due to read only volume\n",
569                           Irp);
570
571             try_return( ntStatus = STATUS_MEDIA_WRITE_PROTECTED);
572         }
573
574         if( pFcb->Header.NodeTypeCode == AFS_INVALID_FCB &&
575             FileInformationClass != FileDispositionInformation)
576         {
577             AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
578                           AFS_TRACE_LEVEL_VERBOSE,
579                           "AFSSetFileInfo request against Invalid Fcb\n");
580
581             try_return( ntStatus = STATUS_ACCESS_DENIED);
582         }
583
584         //
585         // Ensure rename operations are synchronous
586         //
587
588         if( FileInformationClass == FileRenameInformation)
589         {
590
591             bCanQueueRequest = FALSE;
592         }
593
594         //
595         // Store away the parent fid
596         //
597
598         RtlZeroMemory( &stParentFileId,
599                        sizeof( AFSFileID));
600
601         if( pFcb->ObjectInformation->ParentObjectInformation != NULL)
602         {
603             stParentFileId = pFcb->ObjectInformation->ParentObjectInformation->FileId;
604         }
605
606         //
607         // Process the request
608         //
609
610         switch( FileInformationClass)
611         {
612
613             case FileBasicInformation:
614             {
615
616                 bUpdateFileInfo = TRUE;
617
618                 ntStatus = AFSSetBasicInfo( Irp,
619                                             pCcb->DirectoryCB);
620
621                 break;
622             }
623
624             case FileDispositionInformation:
625             {
626
627                 ntStatus = AFSSetDispositionInfo( Irp,
628                                                   pCcb->DirectoryCB);
629
630                 break;
631             }
632
633             case FileRenameInformation:
634             {
635
636                 ntStatus = AFSSetRenameInfo( Irp);
637
638                 break;
639             }
640
641             case FilePositionInformation:
642             {
643
644                 ntStatus = AFSSetPositionInfo( Irp,
645                                                pCcb->DirectoryCB);
646
647                 break;
648             }
649
650             case FileLinkInformation:
651             {
652
653                 ntStatus = STATUS_INVALID_DEVICE_REQUEST;
654
655                 break;
656             }
657
658             case FileAllocationInformation:
659             {
660
661                 ntStatus = AFSSetAllocationInfo( Irp,
662                                                  pCcb->DirectoryCB);
663
664                 break;
665             }
666
667             case FileEndOfFileInformation:
668             {
669
670                 ntStatus = AFSSetEndOfFileInfo( Irp,
671                                                 pCcb->DirectoryCB);
672
673                 break;
674             }
675
676             default:
677
678                 ntStatus = STATUS_INVALID_PARAMETER;
679
680                 break;
681         }
682
683 try_exit:
684
685         if( bReleaseMain)
686         {
687
688             AFSReleaseResource( &pFcb->NPFcb->Resource);
689         }
690
691         if( NT_SUCCESS( ntStatus) &&
692             bUpdateFileInfo)
693         {
694
695             ntStatus = AFSUpdateFileInformation( &stParentFileId,
696                                                  pFcb->ObjectInformation,
697                                                  &pCcb->AuthGroup);
698
699             if( !NT_SUCCESS( ntStatus))
700             {
701
702                 AFSAcquireExcl( &pFcb->NPFcb->Resource,
703                                 TRUE);
704
705                 //
706                 // Unwind the update and fail the request
707                 //
708
709                 AFSUnwindFileInfo( pFcb,
710                                    pCcb);
711
712                 AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
713                               AFS_TRACE_LEVEL_ERROR,
714                               "AFSSetFileInfo Failed to send file info update to service request for %wZ FID %08lX-%08lX-%08lX-%08lX Status %08lX\n",
715                               &pCcb->DirectoryCB->NameInformation.FileName,
716                               pCcb->DirectoryCB->ObjectInformation->FileId.Cell,
717                               pCcb->DirectoryCB->ObjectInformation->FileId.Volume,
718                               pCcb->DirectoryCB->ObjectInformation->FileId.Vnode,
719                               pCcb->DirectoryCB->ObjectInformation->FileId.Unique,
720                               ntStatus);
721
722                 AFSReleaseResource( &pFcb->NPFcb->Resource);
723             }
724         }
725
726         if( !NT_SUCCESS( ntStatus))
727         {
728
729             if( pCcb != NULL &&
730                 pCcb->DirectoryCB != NULL)
731             {
732
733                 AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
734                               AFS_TRACE_LEVEL_ERROR,
735                               "AFSSetFileInfo Failed to process request for %wZ FID %08lX-%08lX-%08lX-%08lX Status %08lX\n",
736                               &pCcb->DirectoryCB->NameInformation.FileName,
737                               pCcb->DirectoryCB->ObjectInformation->FileId.Cell,
738                               pCcb->DirectoryCB->ObjectInformation->FileId.Volume,
739                               pCcb->DirectoryCB->ObjectInformation->FileId.Vnode,
740                               pCcb->DirectoryCB->ObjectInformation->FileId.Unique,
741                               ntStatus);
742             }
743         }
744     }
745     __except( AFSExceptionFilter( __FUNCTION__, GetExceptionCode(), GetExceptionInformation()) )
746     {
747
748         AFSDbgLogMsg( 0,
749                       0,
750                       "EXCEPTION - AFSSetFileInfo\n");
751
752         AFSDumpTraceFilesFnc();
753
754         ntStatus = STATUS_UNSUCCESSFUL;
755
756         if( bReleaseMain)
757         {
758
759             AFSReleaseResource( &pFcb->NPFcb->Resource);
760         }
761     }
762
763     AFSCompleteRequest( Irp,
764                         ntStatus);
765
766     return ntStatus;
767 }
768
769 //
770 // Function: AFSQueryBasicInfo
771 //
772 // Description:
773 //
774 //      This function is the handler for the query basic information request
775 //
776 // Return:
777 //
778 //      A status is returned for the function
779 //
780
781 NTSTATUS
782 AFSQueryBasicInfo( IN PIRP Irp,
783                    IN AFSDirectoryCB *DirectoryCB,
784                    IN OUT PFILE_BASIC_INFORMATION Buffer,
785                    IN OUT PLONG Length)
786 {
787     NTSTATUS ntStatus = STATUS_SUCCESS;
788     AFSDeviceExt *pDeviceExt = (AFSDeviceExt *)AFSRDRDeviceObject->DeviceExtension;
789     ULONG ulFileAttribs = 0;
790     AFSFcb *pFcb = NULL;
791     AFSCcb *pCcb = NULL;
792     IO_STACK_LOCATION *pIrpSp = IoGetCurrentIrpStackLocation( Irp);
793     AFSFileInfoCB stFileInfo;
794     AFSDirectoryCB *pParentDirectoryCB = NULL;
795     UNICODE_STRING uniParentPath;
796
797     if( *Length >= sizeof( FILE_BASIC_INFORMATION))
798     {
799
800         RtlZeroMemory( Buffer,
801                        *Length);
802
803         ulFileAttribs = DirectoryCB->ObjectInformation->FileAttributes;
804
805         pFcb = (AFSFcb *)pIrpSp->FileObject->FsContext;
806         pCcb = (AFSCcb *)pIrpSp->FileObject->FsContext2;
807
808         if( DirectoryCB->ObjectInformation->FileType == AFS_FILE_TYPE_SYMLINK)
809         {
810
811             pParentDirectoryCB = AFSGetParentEntry( pCcb->NameArray);
812
813             AFSRetrieveParentPath( &pCcb->FullFileName,
814                                    &uniParentPath);
815
816             RtlZeroMemory( &stFileInfo,
817                            sizeof( AFSFileInfoCB));
818
819             //
820             // Can't hold the Fcb while evaluating the path, leads to lock inversion
821             //
822
823             AFSReleaseResource( &pFcb->NPFcb->Resource);
824
825             if( NT_SUCCESS( AFSRetrieveFileAttributes( pParentDirectoryCB,
826                                                        DirectoryCB,
827                                                        &uniParentPath,
828                                                        pCcb->NameArray,
829                                                        &pCcb->AuthGroup,
830                                                        &stFileInfo)))
831             {
832
833                 if ( ulFileAttribs == FILE_ATTRIBUTE_NORMAL)
834                 {
835
836                     ulFileAttribs = FILE_ATTRIBUTE_REPARSE_POINT;
837                 }
838                 else
839                 {
840
841                     ulFileAttribs |= FILE_ATTRIBUTE_REPARSE_POINT;
842                 }
843
844                 if ( stFileInfo.FileAttributes & FILE_ATTRIBUTE_DIRECTORY)
845                 {
846
847                     ulFileAttribs |= FILE_ATTRIBUTE_DIRECTORY;
848                 }
849             }
850
851             AFSAcquireShared( &pFcb->NPFcb->Resource,
852                               TRUE);
853         }
854
855
856         AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
857                       AFS_TRACE_LEVEL_VERBOSE_2,
858                       "AFSQueryBasicInfo %wZ Type 0x%x Attrib 0x%x -> 0x%x\n",
859                       &pCcb->DirectoryCB->NameInformation.FileName,
860                       pCcb->DirectoryCB->ObjectInformation->FileType,
861                       pCcb->DirectoryCB->ObjectInformation->FileAttributes,
862                       ulFileAttribs);
863
864         Buffer->CreationTime = DirectoryCB->ObjectInformation->CreationTime;
865         Buffer->LastAccessTime = DirectoryCB->ObjectInformation->LastAccessTime;
866         Buffer->LastWriteTime = DirectoryCB->ObjectInformation->LastWriteTime;
867         Buffer->ChangeTime = DirectoryCB->ObjectInformation->ChangeTime;
868         Buffer->FileAttributes = ulFileAttribs;
869
870         if( DirectoryCB->NameInformation.FileName.Buffer[ 0] == L'.' &&
871             BooleanFlagOn( pDeviceExt->DeviceFlags, AFS_DEVICE_FLAG_HIDE_DOT_NAMES))
872         {
873
874             if ( Buffer->FileAttributes != FILE_ATTRIBUTE_NORMAL)
875             {
876                 Buffer->FileAttributes |= FILE_ATTRIBUTE_HIDDEN;
877             }
878             else
879             {
880                 Buffer->FileAttributes = FILE_ATTRIBUTE_HIDDEN;
881             }
882         }
883
884         *Length -= sizeof( FILE_BASIC_INFORMATION);
885     }
886     else
887     {
888
889         ntStatus = STATUS_BUFFER_TOO_SMALL;
890     }
891
892     return ntStatus;
893 }
894
895 NTSTATUS
896 AFSQueryStandardInfo( IN PIRP Irp,
897                       IN AFSDirectoryCB *DirectoryCB,
898                       IN OUT PFILE_STANDARD_INFORMATION Buffer,
899                       IN OUT PLONG Length)
900 {
901
902     NTSTATUS ntStatus = STATUS_SUCCESS;
903     AFSFcb *pFcb = NULL;
904     AFSCcb *pCcb = NULL;
905     PIO_STACK_LOCATION pIrpSp = IoGetCurrentIrpStackLocation( Irp);
906     AFSFileInfoCB stFileInfo;
907     AFSDirectoryCB *pParentDirectoryCB = NULL;
908     UNICODE_STRING uniParentPath;
909     ULONG ulFileAttribs = 0;
910
911     if( *Length >= sizeof( FILE_STANDARD_INFORMATION))
912     {
913
914         pFcb = (AFSFcb *)pIrpSp->FileObject->FsContext;
915         pCcb = (AFSCcb *)pIrpSp->FileObject->FsContext2;
916
917         RtlZeroMemory( Buffer,
918                        *Length);
919
920         Buffer->NumberOfLinks = 1;
921         Buffer->DeletePending = BooleanFlagOn( pCcb->DirectoryCB->Flags, AFS_DIR_ENTRY_PENDING_DELETE);
922
923         Buffer->AllocationSize.QuadPart = (ULONGLONG)((DirectoryCB->ObjectInformation->AllocationSize.QuadPart/PAGE_SIZE) + 1) * PAGE_SIZE;
924
925         Buffer->EndOfFile = DirectoryCB->ObjectInformation->EndOfFile;
926
927         ulFileAttribs = DirectoryCB->ObjectInformation->FileAttributes;
928
929         if( DirectoryCB->ObjectInformation->FileType == AFS_FILE_TYPE_SYMLINK)
930         {
931
932             pParentDirectoryCB = AFSGetParentEntry( pCcb->NameArray);
933
934             AFSRetrieveParentPath( &pCcb->FullFileName,
935                                    &uniParentPath);
936
937             RtlZeroMemory( &stFileInfo,
938                            sizeof( AFSFileInfoCB));
939
940             //
941             // Can't hold the Fcb while evaluating the path, leads to lock inversion
942             //
943
944             AFSReleaseResource( &pFcb->NPFcb->Resource);
945
946             if( NT_SUCCESS( AFSRetrieveFileAttributes( pParentDirectoryCB,
947                                                        DirectoryCB,
948                                                        &uniParentPath,
949                                                        pCcb->NameArray,
950                                                        &pCcb->AuthGroup,
951                                                        &stFileInfo)))
952             {
953
954                 if ( ulFileAttribs == FILE_ATTRIBUTE_NORMAL)
955                 {
956
957                     ulFileAttribs = FILE_ATTRIBUTE_REPARSE_POINT;
958                 }
959                 else
960                 {
961
962                     ulFileAttribs |= FILE_ATTRIBUTE_REPARSE_POINT;
963                 }
964
965                 if ( stFileInfo.FileAttributes & FILE_ATTRIBUTE_DIRECTORY)
966                 {
967
968                     ulFileAttribs |= FILE_ATTRIBUTE_DIRECTORY;
969                 }
970             }
971
972             AFSAcquireShared( &pFcb->NPFcb->Resource,
973                               TRUE);
974         }
975
976         AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
977                       AFS_TRACE_LEVEL_VERBOSE_2,
978                       "AFSQueryStandardInfo %wZ Type 0x%x Attrib 0x%x -> 0x%x\n",
979                       &pCcb->DirectoryCB->NameInformation.FileName,
980                       pCcb->DirectoryCB->ObjectInformation->FileType,
981                       pCcb->DirectoryCB->ObjectInformation->FileAttributes,
982                       ulFileAttribs);
983
984         Buffer->Directory = BooleanFlagOn( ulFileAttribs, FILE_ATTRIBUTE_DIRECTORY);
985
986         *Length -= sizeof( FILE_STANDARD_INFORMATION);
987     }
988     else
989     {
990
991         ntStatus = STATUS_BUFFER_TOO_SMALL;
992     }
993
994     return ntStatus;
995 }
996
997 NTSTATUS
998 AFSQueryInternalInfo( IN PIRP Irp,
999                       IN AFSFcb *Fcb,
1000                       IN OUT PFILE_INTERNAL_INFORMATION Buffer,
1001                       IN OUT PLONG Length)
1002 {
1003
1004     NTSTATUS ntStatus = STATUS_SUCCESS;
1005
1006     if( *Length >= sizeof( FILE_INTERNAL_INFORMATION))
1007     {
1008
1009         Buffer->IndexNumber.HighPart = Fcb->ObjectInformation->FileId.Volume;
1010
1011         Buffer->IndexNumber.LowPart = Fcb->ObjectInformation->FileId.Vnode;
1012
1013         *Length -= sizeof( FILE_INTERNAL_INFORMATION);
1014     }
1015     else
1016     {
1017
1018         ntStatus = STATUS_BUFFER_TOO_SMALL;
1019     }
1020
1021     return ntStatus;
1022 }
1023
1024 NTSTATUS
1025 AFSQueryEaInfo( IN PIRP Irp,
1026                 IN AFSDirectoryCB *DirectoryCB,
1027                 IN OUT PFILE_EA_INFORMATION Buffer,
1028                 IN OUT PLONG Length)
1029 {
1030
1031     NTSTATUS ntStatus = STATUS_SUCCESS;
1032
1033     RtlZeroMemory( Buffer,
1034                    *Length);
1035
1036     if( *Length >= sizeof( FILE_EA_INFORMATION))
1037     {
1038
1039         Buffer->EaSize = 0;
1040
1041         *Length -= sizeof( FILE_EA_INFORMATION);
1042     }
1043     else
1044     {
1045
1046         ntStatus = STATUS_BUFFER_TOO_SMALL;
1047     }
1048
1049     return ntStatus;
1050 }
1051
1052 NTSTATUS
1053 AFSQueryPositionInfo( IN PIRP Irp,
1054                       IN AFSFcb *Fcb,
1055                       IN OUT PFILE_POSITION_INFORMATION Buffer,
1056                       IN OUT PLONG Length)
1057 {
1058
1059     NTSTATUS ntStatus = STATUS_SUCCESS;
1060     PIO_STACK_LOCATION pIrpSp = IoGetCurrentIrpStackLocation( Irp);
1061
1062     if( *Length >= sizeof( FILE_POSITION_INFORMATION))
1063     {
1064
1065         RtlZeroMemory( Buffer,
1066                        *Length);
1067
1068         Buffer->CurrentByteOffset.QuadPart = pIrpSp->FileObject->CurrentByteOffset.QuadPart;
1069
1070         *Length -= sizeof( FILE_POSITION_INFORMATION);
1071     }
1072     else
1073     {
1074
1075         ntStatus = STATUS_BUFFER_TOO_SMALL;
1076     }
1077
1078     return ntStatus;
1079 }
1080
1081 NTSTATUS
1082 AFSQueryAccess( IN PIRP Irp,
1083                 IN AFSFcb *Fcb,
1084                 IN OUT PFILE_ACCESS_INFORMATION Buffer,
1085                 IN OUT PLONG Length)
1086 {
1087
1088     NTSTATUS ntStatus = STATUS_SUCCESS;
1089
1090     if( *Length >= sizeof( FILE_ACCESS_INFORMATION))
1091     {
1092
1093         RtlZeroMemory( Buffer,
1094                        *Length);
1095
1096         Buffer->AccessFlags = 0;
1097
1098         *Length -= sizeof( FILE_ACCESS_INFORMATION);
1099     }
1100     else
1101     {
1102
1103         ntStatus = STATUS_BUFFER_TOO_SMALL;
1104     }
1105
1106     return ntStatus;
1107 }
1108
1109 NTSTATUS
1110 AFSQueryMode( IN PIRP Irp,
1111               IN AFSFcb *Fcb,
1112               IN OUT PFILE_MODE_INFORMATION Buffer,
1113               IN OUT PLONG Length)
1114 {
1115
1116     NTSTATUS ntStatus = STATUS_SUCCESS;
1117
1118     if( *Length >= sizeof( FILE_MODE_INFORMATION))
1119     {
1120
1121         RtlZeroMemory( Buffer,
1122                        *Length);
1123
1124         Buffer->Mode = 0;
1125
1126         *Length -= sizeof( FILE_MODE_INFORMATION);
1127     }
1128     else
1129     {
1130
1131         ntStatus = STATUS_BUFFER_TOO_SMALL;
1132     }
1133
1134     return ntStatus;
1135 }
1136
1137 NTSTATUS
1138 AFSQueryAlignment( IN PIRP Irp,
1139                    IN AFSFcb *Fcb,
1140                    IN OUT PFILE_ALIGNMENT_INFORMATION Buffer,
1141                    IN OUT PLONG Length)
1142 {
1143
1144     NTSTATUS ntStatus = STATUS_SUCCESS;
1145
1146     if( *Length >= sizeof( FILE_ALIGNMENT_INFORMATION))
1147     {
1148
1149         RtlZeroMemory( Buffer,
1150                        *Length);
1151
1152         Buffer->AlignmentRequirement = 1;
1153
1154         *Length -= sizeof( FILE_ALIGNMENT_INFORMATION);
1155     }
1156     else
1157     {
1158
1159         ntStatus = STATUS_BUFFER_TOO_SMALL;
1160     }
1161
1162     return ntStatus;
1163 }
1164
1165 NTSTATUS
1166 AFSQueryNameInfo( IN PIRP Irp,
1167                   IN AFSDirectoryCB *DirectoryCB,
1168                   IN OUT PFILE_NAME_INFORMATION Buffer,
1169                   IN OUT PLONG Length)
1170 {
1171
1172     NTSTATUS ntStatus = STATUS_SUCCESS;
1173     ULONG ulCopyLength = 0;
1174     ULONG cchCopied = 0;
1175     AFSFcb *pFcb = NULL;
1176     AFSCcb *pCcb = NULL;
1177     IO_STACK_LOCATION *pIrpSp = IoGetCurrentIrpStackLocation( Irp);
1178     BOOLEAN bAddLeadingSlash = FALSE;
1179     BOOLEAN bAddTrailingSlash = FALSE;
1180     USHORT usFullNameLength = 0;
1181
1182     pFcb = (AFSFcb *)pIrpSp->FileObject->FsContext;
1183
1184     pCcb = (AFSCcb *)pIrpSp->FileObject->FsContext2;
1185
1186     if( *Length >= FIELD_OFFSET( FILE_NAME_INFORMATION, FileName))
1187     {
1188
1189         RtlZeroMemory( Buffer,
1190                        *Length);
1191
1192         if( pCcb->FullFileName.Length == 0 ||
1193             pCcb->FullFileName.Buffer[ 0] != L'\\')
1194         {
1195             bAddLeadingSlash = TRUE;
1196         }
1197
1198         if( pFcb->ObjectInformation->FileType == AFS_FILE_TYPE_DIRECTORY &&
1199             pCcb->FullFileName.Length > 0 &&
1200             pCcb->FullFileName.Buffer[ (pCcb->FullFileName.Length/sizeof( WCHAR)) - 1] != L'\\')
1201         {
1202             bAddTrailingSlash = TRUE;
1203         }
1204
1205         usFullNameLength = sizeof( WCHAR) +
1206                                     AFSServerName.Length +
1207                                     pCcb->FullFileName.Length;
1208
1209         if( bAddLeadingSlash)
1210         {
1211             usFullNameLength += sizeof( WCHAR);
1212         }
1213
1214         if( bAddTrailingSlash)
1215         {
1216             usFullNameLength += sizeof( WCHAR);
1217         }
1218
1219         if( *Length >= (LONG)(FIELD_OFFSET( FILE_NAME_INFORMATION, FileName) + (LONG)usFullNameLength))
1220         {
1221
1222             ulCopyLength = (LONG)usFullNameLength;
1223         }
1224         else
1225         {
1226
1227             ulCopyLength = *Length - FIELD_OFFSET( FILE_NAME_INFORMATION, FileName);
1228
1229             ntStatus = STATUS_BUFFER_OVERFLOW;
1230         }
1231
1232         Buffer->FileNameLength = (ULONG)usFullNameLength;
1233
1234         *Length -= FIELD_OFFSET( FILE_NAME_INFORMATION, FileName);
1235
1236         if( ulCopyLength > 0)
1237         {
1238
1239             Buffer->FileName[ 0] = L'\\';
1240             ulCopyLength -= sizeof( WCHAR);
1241
1242             *Length -= sizeof( WCHAR);
1243             cchCopied += 1;
1244
1245             if( ulCopyLength >= AFSServerName.Length)
1246             {
1247
1248                 RtlCopyMemory( &Buffer->FileName[ 1],
1249                                AFSServerName.Buffer,
1250                                AFSServerName.Length);
1251
1252                 ulCopyLength -= AFSServerName.Length;
1253                 *Length -= AFSServerName.Length;
1254                 cchCopied += AFSServerName.Length/sizeof( WCHAR);
1255
1256                 if ( ulCopyLength > 0 &&
1257                      bAddLeadingSlash)
1258                 {
1259
1260                     Buffer->FileName[ cchCopied] = L'\\';
1261
1262                     ulCopyLength -= sizeof( WCHAR);
1263                     *Length -= sizeof( WCHAR);
1264                     cchCopied++;
1265                 }
1266
1267                 if( ulCopyLength >= pCcb->FullFileName.Length)
1268                 {
1269
1270                     RtlCopyMemory( &Buffer->FileName[ cchCopied],
1271                                    pCcb->FullFileName.Buffer,
1272                                    pCcb->FullFileName.Length);
1273
1274                     ulCopyLength -= pCcb->FullFileName.Length;
1275                     *Length -= pCcb->FullFileName.Length;
1276                     cchCopied += pCcb->FullFileName.Length/sizeof( WCHAR);
1277
1278                     if( ulCopyLength > 0 &&
1279                         bAddTrailingSlash)
1280                     {
1281                         Buffer->FileName[ cchCopied] = L'\\';
1282
1283                         *Length -= sizeof( WCHAR);
1284                     }
1285                 }
1286                 else
1287                 {
1288
1289                     RtlCopyMemory( &Buffer->FileName[ cchCopied],
1290                                    pCcb->FullFileName.Buffer,
1291                                    ulCopyLength);
1292
1293                     *Length -= ulCopyLength;
1294                 }
1295             }
1296         }
1297     }
1298     else
1299     {
1300
1301         ntStatus = STATUS_BUFFER_TOO_SMALL;
1302     }
1303
1304     return ntStatus;
1305 }
1306
1307 NTSTATUS
1308 AFSQueryShortNameInfo( IN PIRP Irp,
1309                        IN AFSDirectoryCB *DirectoryCB,
1310                        IN OUT PFILE_NAME_INFORMATION Buffer,
1311                        IN OUT PLONG Length)
1312 {
1313
1314     NTSTATUS ntStatus = STATUS_BUFFER_TOO_SMALL;
1315     ULONG ulCopyLength = 0;
1316
1317     RtlZeroMemory( Buffer,
1318                    *Length);
1319
1320     if( DirectoryCB->NameInformation.ShortNameLength == 0)
1321     {
1322
1323         //
1324         // The short name IS the long name
1325         //
1326
1327         if( *Length >= (LONG)FIELD_OFFSET( FILE_NAME_INFORMATION, FileName))
1328         {
1329
1330             if( *Length >= (LONG)(FIELD_OFFSET( FILE_NAME_INFORMATION, FileName) + (LONG)DirectoryCB->NameInformation.FileName.Length))
1331             {
1332
1333                 ulCopyLength = (LONG)DirectoryCB->NameInformation.FileName.Length;
1334
1335                 ntStatus = STATUS_SUCCESS;
1336             }
1337             else
1338             {
1339
1340                 ulCopyLength = *Length - FIELD_OFFSET( FILE_NAME_INFORMATION, FileName);
1341
1342                 ntStatus = STATUS_BUFFER_OVERFLOW;
1343             }
1344
1345             Buffer->FileNameLength = DirectoryCB->NameInformation.FileName.Length;
1346
1347             *Length -= FIELD_OFFSET( FILE_NAME_INFORMATION, FileName);
1348
1349             if( ulCopyLength > 0)
1350             {
1351
1352                 RtlCopyMemory( Buffer->FileName,
1353                                DirectoryCB->NameInformation.FileName.Buffer,
1354                                ulCopyLength);
1355
1356                 *Length -= ulCopyLength;
1357             }
1358         }
1359     }
1360     else
1361     {
1362
1363         if( *Length >= (LONG)FIELD_OFFSET( FILE_NAME_INFORMATION, FileName))
1364         {
1365
1366             if( *Length >= (LONG)(FIELD_OFFSET( FILE_NAME_INFORMATION, FileName) + (LONG)DirectoryCB->NameInformation.FileName.Length))
1367             {
1368
1369                 ulCopyLength = (LONG)DirectoryCB->NameInformation.ShortNameLength;
1370
1371                 ntStatus = STATUS_SUCCESS;
1372             }
1373             else
1374             {
1375
1376                 ulCopyLength = *Length - FIELD_OFFSET( FILE_NAME_INFORMATION, FileName);
1377
1378                 ntStatus = STATUS_BUFFER_OVERFLOW;
1379             }
1380
1381             Buffer->FileNameLength = DirectoryCB->NameInformation.ShortNameLength;
1382
1383             *Length -= FIELD_OFFSET( FILE_NAME_INFORMATION, FileName);
1384
1385             if( ulCopyLength > 0)
1386             {
1387
1388                 RtlCopyMemory( Buffer->FileName,
1389                                DirectoryCB->NameInformation.ShortName,
1390                                Buffer->FileNameLength);
1391
1392                 *Length -= ulCopyLength;
1393             }
1394         }
1395     }
1396
1397     return ntStatus;
1398 }
1399
1400 NTSTATUS
1401 AFSQueryNetworkInfo( IN PIRP Irp,
1402                      IN AFSDirectoryCB *DirectoryCB,
1403                      IN OUT PFILE_NETWORK_OPEN_INFORMATION Buffer,
1404                      IN OUT PLONG Length)
1405 {
1406
1407     NTSTATUS ntStatus = STATUS_SUCCESS;
1408     AFSDeviceExt *pDeviceExt = (AFSDeviceExt *)AFSRDRDeviceObject->DeviceExtension;
1409     AFSFcb *pFcb = NULL;
1410     AFSCcb *pCcb = NULL;
1411     PIO_STACK_LOCATION pIrpSp = IoGetCurrentIrpStackLocation( Irp);
1412     AFSFileInfoCB stFileInfo;
1413     AFSDirectoryCB *pParentDirectoryCB = NULL;
1414     UNICODE_STRING uniParentPath;
1415     ULONG ulFileAttribs = 0;
1416
1417     RtlZeroMemory( Buffer,
1418                    *Length);
1419
1420     if( *Length >= sizeof( FILE_NETWORK_OPEN_INFORMATION))
1421     {
1422
1423         ulFileAttribs = DirectoryCB->ObjectInformation->FileAttributes;
1424
1425         pFcb = (AFSFcb *)pIrpSp->FileObject->FsContext;
1426         pCcb = (AFSCcb *)pIrpSp->FileObject->FsContext2;
1427
1428         if( DirectoryCB->ObjectInformation->FileType == AFS_FILE_TYPE_SYMLINK)
1429         {
1430
1431             pParentDirectoryCB = AFSGetParentEntry( pCcb->NameArray);
1432
1433             AFSRetrieveParentPath( &pCcb->FullFileName,
1434                                    &uniParentPath);
1435
1436             RtlZeroMemory( &stFileInfo,
1437                            sizeof( AFSFileInfoCB));
1438
1439             //
1440             // Can't hold the Fcb while evaluating the path, leads to lock inversion
1441             //
1442
1443             AFSReleaseResource( &pFcb->NPFcb->Resource);
1444
1445             if( NT_SUCCESS( AFSRetrieveFileAttributes( pParentDirectoryCB,
1446                                                        DirectoryCB,
1447                                                        &uniParentPath,
1448                                                        pCcb->NameArray,
1449                                                        &pCcb->AuthGroup,
1450                                                        &stFileInfo)))
1451             {
1452
1453                 if ( ulFileAttribs == FILE_ATTRIBUTE_NORMAL)
1454                 {
1455
1456                     ulFileAttribs = FILE_ATTRIBUTE_REPARSE_POINT;
1457                 }
1458                 else
1459                 {
1460
1461                     ulFileAttribs |= FILE_ATTRIBUTE_REPARSE_POINT;
1462                 }
1463
1464                 if ( stFileInfo.FileAttributes & FILE_ATTRIBUTE_DIRECTORY)
1465                 {
1466
1467                     ulFileAttribs |= FILE_ATTRIBUTE_DIRECTORY;
1468                 }
1469             }
1470
1471             AFSAcquireShared( &pFcb->NPFcb->Resource,
1472                               TRUE);
1473         }
1474
1475         AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
1476                       AFS_TRACE_LEVEL_VERBOSE_2,
1477                       "AFSQueryNetworkInfo %wZ Type 0x%x Attrib 0x%x -> 0x%x\n",
1478                       &pCcb->DirectoryCB->NameInformation.FileName,
1479                       pCcb->DirectoryCB->ObjectInformation->FileType,
1480                       pCcb->DirectoryCB->ObjectInformation->FileAttributes,
1481                       ulFileAttribs);
1482
1483         Buffer->CreationTime.QuadPart = DirectoryCB->ObjectInformation->CreationTime.QuadPart;
1484         Buffer->LastAccessTime.QuadPart = DirectoryCB->ObjectInformation->LastAccessTime.QuadPart;
1485         Buffer->LastWriteTime.QuadPart = DirectoryCB->ObjectInformation->LastWriteTime.QuadPart;
1486         Buffer->ChangeTime.QuadPart = DirectoryCB->ObjectInformation->ChangeTime.QuadPart;
1487
1488         Buffer->AllocationSize.QuadPart = DirectoryCB->ObjectInformation->AllocationSize.QuadPart;
1489         Buffer->EndOfFile.QuadPart = DirectoryCB->ObjectInformation->EndOfFile.QuadPart;
1490
1491         Buffer->FileAttributes = ulFileAttribs;
1492
1493         if( DirectoryCB->NameInformation.FileName.Buffer[ 0] == L'.' &&
1494             BooleanFlagOn( pDeviceExt->DeviceFlags, AFS_DEVICE_FLAG_HIDE_DOT_NAMES))
1495         {
1496
1497             if ( Buffer->FileAttributes != FILE_ATTRIBUTE_NORMAL)
1498             {
1499
1500                 Buffer->FileAttributes |= FILE_ATTRIBUTE_HIDDEN;
1501             }
1502             else
1503             {
1504
1505                 Buffer->FileAttributes = FILE_ATTRIBUTE_HIDDEN;
1506             }
1507         }
1508
1509         *Length -= sizeof( FILE_NETWORK_OPEN_INFORMATION);
1510     }
1511     else
1512     {
1513
1514         ntStatus = STATUS_BUFFER_TOO_SMALL;
1515     }
1516
1517     return ntStatus;
1518 }
1519
1520 NTSTATUS
1521 AFSQueryStreamInfo( IN PIRP Irp,
1522                     IN AFSDirectoryCB *DirectoryCB,
1523                     IN OUT FILE_STREAM_INFORMATION *Buffer,
1524                     IN OUT PLONG Length)
1525 {
1526
1527     NTSTATUS ntStatus = STATUS_BUFFER_TOO_SMALL;
1528     ULONG ulCopyLength = 0;
1529     AFSDeviceExt *pDeviceExt = (AFSDeviceExt *)AFSRDRDeviceObject->DeviceExtension;
1530
1531     if( *Length >= FIELD_OFFSET( FILE_STREAM_INFORMATION, StreamName))
1532     {
1533
1534         RtlZeroMemory( Buffer,
1535                        *Length);
1536
1537         Buffer->NextEntryOffset = 0;
1538
1539
1540         if( !BooleanFlagOn( DirectoryCB->ObjectInformation->FileAttributes, FILE_ATTRIBUTE_DIRECTORY))
1541         {
1542
1543             if( *Length >= (LONG)(FIELD_OFFSET( FILE_STREAM_INFORMATION, StreamName) + 14))  // ::$DATA
1544             {
1545
1546                 ulCopyLength = 14;
1547
1548                 ntStatus = STATUS_SUCCESS;
1549             }
1550             else
1551             {
1552
1553                 ulCopyLength = *Length - FIELD_OFFSET( FILE_STREAM_INFORMATION, StreamName);
1554
1555                 ntStatus = STATUS_BUFFER_OVERFLOW;
1556             }
1557
1558             Buffer->StreamNameLength = 14; // ::$DATA
1559
1560             Buffer->StreamSize.QuadPart = DirectoryCB->ObjectInformation->EndOfFile.QuadPart;
1561
1562             Buffer->StreamAllocationSize.QuadPart = DirectoryCB->ObjectInformation->AllocationSize.QuadPart;
1563
1564             *Length -= FIELD_OFFSET( FILE_STREAM_INFORMATION, StreamName);
1565
1566             if( ulCopyLength > 0)
1567             {
1568
1569                 RtlCopyMemory( Buffer->StreamName,
1570                                L"::$DATA",
1571                                ulCopyLength);
1572
1573                 *Length -= ulCopyLength;
1574             }
1575         }
1576         else
1577         {
1578
1579             Buffer->StreamNameLength = 0;       // No stream for a directory
1580
1581             // The response size is zero
1582
1583             ntStatus = STATUS_SUCCESS;
1584         }
1585     }
1586
1587     return ntStatus;
1588 }
1589
1590 NTSTATUS
1591 AFSQueryAttribTagInfo( IN PIRP Irp,
1592                        IN AFSDirectoryCB *DirectoryCB,
1593                        IN OUT FILE_ATTRIBUTE_TAG_INFORMATION *Buffer,
1594                        IN OUT PLONG Length)
1595 {
1596
1597     NTSTATUS ntStatus = STATUS_BUFFER_TOO_SMALL;
1598     ULONG ulCopyLength = 0;
1599     AFSDeviceExt *pDeviceExt = (AFSDeviceExt *)AFSRDRDeviceObject->DeviceExtension;
1600     AFSFcb *pFcb = NULL;
1601     AFSCcb *pCcb = NULL;
1602     PIO_STACK_LOCATION pIrpSp = IoGetCurrentIrpStackLocation( Irp);
1603     AFSFileInfoCB stFileInfo;
1604     AFSDirectoryCB *pParentDirectoryCB = NULL;
1605     UNICODE_STRING uniParentPath;
1606     ULONG ulFileAttribs = 0;
1607
1608     if( *Length >= sizeof( FILE_ATTRIBUTE_TAG_INFORMATION))
1609     {
1610
1611         RtlZeroMemory( Buffer,
1612                        *Length);
1613
1614         ulFileAttribs = DirectoryCB->ObjectInformation->FileAttributes;
1615
1616         pFcb = (AFSFcb *)pIrpSp->FileObject->FsContext;
1617         pCcb = (AFSCcb *)pIrpSp->FileObject->FsContext2;
1618
1619         if( DirectoryCB->ObjectInformation->FileType == AFS_FILE_TYPE_SYMLINK)
1620         {
1621
1622             pParentDirectoryCB = AFSGetParentEntry( pCcb->NameArray);
1623
1624             AFSRetrieveParentPath( &pCcb->FullFileName,
1625                                    &uniParentPath);
1626
1627             RtlZeroMemory( &stFileInfo,
1628                            sizeof( AFSFileInfoCB));
1629
1630             //
1631             // Can't hold the Fcb while evaluating the path, leads to lock inversion
1632             //
1633
1634             AFSReleaseResource( &pFcb->NPFcb->Resource);
1635
1636             if( NT_SUCCESS( AFSRetrieveFileAttributes( pParentDirectoryCB,
1637                                                        DirectoryCB,
1638                                                        &uniParentPath,
1639                                                        pCcb->NameArray,
1640                                                        &pCcb->AuthGroup,
1641                                                        &stFileInfo)))
1642             {
1643
1644                 if ( ulFileAttribs == FILE_ATTRIBUTE_NORMAL)
1645                 {
1646
1647                     ulFileAttribs = FILE_ATTRIBUTE_REPARSE_POINT;
1648                 }
1649                 else
1650                 {
1651
1652                     ulFileAttribs |= FILE_ATTRIBUTE_REPARSE_POINT;
1653                 }
1654
1655                 if ( stFileInfo.FileAttributes & FILE_ATTRIBUTE_DIRECTORY)
1656                 {
1657
1658                     ulFileAttribs |= FILE_ATTRIBUTE_DIRECTORY;
1659                 }
1660             }
1661
1662             AFSAcquireShared( &pFcb->NPFcb->Resource,
1663                               TRUE);
1664         }
1665
1666         AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
1667                       AFS_TRACE_LEVEL_VERBOSE_2,
1668                       "AFSAttribTagInfo %wZ Type 0x%x Attrib 0x%x -> 0x%x\n",
1669                       &pCcb->DirectoryCB->NameInformation.FileName,
1670                       pCcb->DirectoryCB->ObjectInformation->FileType,
1671                       pCcb->DirectoryCB->ObjectInformation->FileAttributes,
1672                       ulFileAttribs);
1673
1674         Buffer->FileAttributes = ulFileAttribs;
1675
1676         if( DirectoryCB->NameInformation.FileName.Buffer[ 0] == L'.' &&
1677             BooleanFlagOn( pDeviceExt->DeviceFlags, AFS_DEVICE_FLAG_HIDE_DOT_NAMES))
1678         {
1679
1680             if ( Buffer->FileAttributes != FILE_ATTRIBUTE_NORMAL)
1681             {
1682
1683                 Buffer->FileAttributes |= FILE_ATTRIBUTE_HIDDEN;
1684             }
1685             else
1686             {
1687
1688                 Buffer->FileAttributes = FILE_ATTRIBUTE_HIDDEN;
1689             }
1690         }
1691
1692         if( BooleanFlagOn( DirectoryCB->ObjectInformation->FileAttributes, FILE_ATTRIBUTE_REPARSE_POINT))
1693         {
1694             Buffer->ReparseTag = IO_REPARSE_TAG_SURROGATE|IO_REPARSE_TAG_OPENAFS_DFS;
1695         }
1696
1697         *Length -= sizeof( FILE_ATTRIBUTE_TAG_INFORMATION);
1698
1699         ntStatus = STATUS_SUCCESS;
1700     }
1701
1702     return ntStatus;
1703 }
1704
1705 NTSTATUS
1706 AFSQueryRemoteProtocolInfo( IN PIRP Irp,
1707                             IN AFSDirectoryCB *DirectoryCB,
1708                             IN OUT FILE_REMOTE_PROTOCOL_INFORMATION *Buffer,
1709                             IN OUT PLONG Length)
1710 {
1711
1712     NTSTATUS ntStatus = STATUS_BUFFER_TOO_SMALL;
1713     ULONG ulCopyLength = 0;
1714     AFSDeviceExt *pDeviceExt = (AFSDeviceExt *)AFSRDRDeviceObject->DeviceExtension;
1715
1716     if( *Length >= sizeof( FILE_REMOTE_PROTOCOL_INFORMATION))
1717     {
1718
1719         RtlZeroMemory( Buffer,
1720                        *Length);
1721
1722         Buffer->StructureVersion = 1;
1723
1724         Buffer->StructureSize = sizeof(FILE_REMOTE_PROTOCOL_INFORMATION);
1725
1726         Buffer->Protocol = WNNC_NET_OPENAFS;
1727
1728         Buffer->ProtocolMajorVersion = 3;
1729
1730         Buffer->ProtocolMinorVersion = 0;
1731
1732         Buffer->ProtocolRevision = 0;
1733
1734         *Length -= sizeof( FILE_REMOTE_PROTOCOL_INFORMATION);
1735
1736         ntStatus = STATUS_SUCCESS;
1737     }
1738
1739     return ntStatus;
1740 }
1741
1742 NTSTATUS
1743 AFSQueryPhysicalNameInfo( IN PIRP Irp,
1744                           IN AFSDirectoryCB *DirectoryCB,
1745                           IN OUT PFILE_NETWORK_PHYSICAL_NAME_INFORMATION Buffer,
1746                           IN OUT PLONG Length)
1747 {
1748
1749     NTSTATUS ntStatus = STATUS_SUCCESS;
1750     ULONG ulCopyLength = 0;
1751     ULONG cchCopied = 0;
1752     AFSFcb *pFcb = NULL;
1753     AFSCcb *pCcb = NULL;
1754     IO_STACK_LOCATION *pIrpSp = IoGetCurrentIrpStackLocation( Irp);
1755     BOOLEAN bAddLeadingSlash = FALSE;
1756     USHORT usFullNameLength = 0;
1757
1758     pFcb = (AFSFcb *)pIrpSp->FileObject->FsContext;
1759
1760     pCcb = (AFSCcb *)pIrpSp->FileObject->FsContext2;
1761
1762     if( *Length >= FIELD_OFFSET( FILE_NETWORK_PHYSICAL_NAME_INFORMATION, FileName))
1763     {
1764
1765         RtlZeroMemory( Buffer,
1766                        *Length);
1767
1768         if( pCcb->FullFileName.Length == 0 ||
1769             pCcb->FullFileName.Buffer[ 0] != L'\\')
1770         {
1771             bAddLeadingSlash = TRUE;
1772         }
1773
1774         usFullNameLength = pCcb->FullFileName.Length;
1775
1776         if( bAddLeadingSlash)
1777         {
1778             usFullNameLength += sizeof( WCHAR);
1779         }
1780
1781         if( *Length >= (LONG)(FIELD_OFFSET( FILE_NETWORK_PHYSICAL_NAME_INFORMATION, FileName) + (LONG)usFullNameLength))
1782         {
1783             ulCopyLength = (LONG)usFullNameLength;
1784         }
1785         else
1786         {
1787
1788             ulCopyLength = *Length - FIELD_OFFSET( FILE_NETWORK_PHYSICAL_NAME_INFORMATION, FileName);
1789
1790             ntStatus = STATUS_BUFFER_OVERFLOW;
1791         }
1792
1793         Buffer->FileNameLength = (ULONG)usFullNameLength;
1794
1795         *Length -= FIELD_OFFSET( FILE_NETWORK_PHYSICAL_NAME_INFORMATION, FileName);
1796
1797         if( ulCopyLength > 0)
1798         {
1799
1800             if( bAddLeadingSlash)
1801             {
1802
1803                 Buffer->FileName[ cchCopied] = L'\\';
1804
1805                 ulCopyLength -= sizeof( WCHAR);
1806                 *Length -= sizeof( WCHAR);
1807                 cchCopied++;
1808             }
1809
1810             if( ulCopyLength >= pCcb->FullFileName.Length)
1811             {
1812
1813                 RtlCopyMemory( &Buffer->FileName[ cchCopied],
1814                                pCcb->FullFileName.Buffer,
1815                                pCcb->FullFileName.Length);
1816
1817                 ulCopyLength -= pCcb->FullFileName.Length;
1818                 *Length -= pCcb->FullFileName.Length;
1819                 cchCopied += pCcb->FullFileName.Length/sizeof( WCHAR);
1820             }
1821             else
1822             {
1823
1824                 RtlCopyMemory( &Buffer->FileName[ cchCopied],
1825                                pCcb->FullFileName.Buffer,
1826                                ulCopyLength);
1827
1828                 *Length -= ulCopyLength;
1829             }
1830         }
1831     }
1832     else
1833     {
1834
1835         ntStatus = STATUS_BUFFER_TOO_SMALL;
1836     }
1837
1838     return ntStatus;
1839 }
1840
1841 NTSTATUS
1842 AFSSetBasicInfo( IN PIRP Irp,
1843                  IN AFSDirectoryCB *DirectoryCB)
1844 {
1845     NTSTATUS ntStatus = STATUS_SUCCESS;
1846     PFILE_BASIC_INFORMATION pBuffer;
1847     PIO_STACK_LOCATION pIrpSp = IoGetCurrentIrpStackLocation( Irp);
1848     ULONG ulNotifyFilter = 0;
1849     AFSCcb *pCcb = NULL;
1850
1851     __Enter
1852     {
1853
1854         pCcb = (AFSCcb *)pIrpSp->FileObject->FsContext2;
1855
1856         pBuffer = (PFILE_BASIC_INFORMATION)Irp->AssociatedIrp.SystemBuffer;
1857
1858         pCcb->FileUnwindInfo.FileAttributes = (ULONG)-1;
1859
1860         if( pBuffer->FileAttributes != (ULONGLONG)0)
1861         {
1862
1863             if( DirectoryCB->ObjectInformation->Fcb->Header.NodeTypeCode == AFS_FILE_FCB &&
1864                 BooleanFlagOn( pBuffer->FileAttributes, FILE_ATTRIBUTE_DIRECTORY))
1865             {
1866
1867                 try_return( ntStatus = STATUS_INVALID_PARAMETER);
1868             }
1869
1870             if( DirectoryCB->ObjectInformation->Fcb->Header.NodeTypeCode == AFS_DIRECTORY_FCB)
1871             {
1872
1873                 pBuffer->FileAttributes |= FILE_ATTRIBUTE_DIRECTORY;
1874             }
1875
1876             pCcb->FileUnwindInfo.FileAttributes = DirectoryCB->ObjectInformation->FileAttributes;
1877
1878             DirectoryCB->ObjectInformation->FileAttributes = pBuffer->FileAttributes;
1879
1880             ulNotifyFilter |= FILE_NOTIFY_CHANGE_ATTRIBUTES;
1881
1882             SetFlag( DirectoryCB->ObjectInformation->Fcb->Flags, AFS_FCB_FLAG_FILE_MODIFIED);
1883         }
1884
1885         pCcb->FileUnwindInfo.CreationTime.QuadPart = (ULONGLONG)-1;
1886
1887         if( pBuffer->CreationTime.QuadPart != (ULONGLONG)-1 &&
1888             pBuffer->CreationTime.QuadPart != (ULONGLONG)0)
1889         {
1890
1891             pCcb->FileUnwindInfo.CreationTime.QuadPart = DirectoryCB->ObjectInformation->CreationTime.QuadPart;
1892
1893             DirectoryCB->ObjectInformation->CreationTime.QuadPart = pBuffer->CreationTime.QuadPart;
1894
1895             ulNotifyFilter |= FILE_NOTIFY_CHANGE_CREATION;
1896
1897             SetFlag( DirectoryCB->ObjectInformation->Fcb->Flags, AFS_FCB_FLAG_FILE_MODIFIED | AFS_FCB_FLAG_UPDATE_CREATE_TIME);
1898         }
1899
1900         pCcb->FileUnwindInfo.LastAccessTime.QuadPart = (ULONGLONG)-1;
1901
1902         if( pBuffer->LastAccessTime.QuadPart != (ULONGLONG)-1 &&
1903             pBuffer->LastAccessTime.QuadPart != (ULONGLONG)0)
1904         {
1905
1906             pCcb->FileUnwindInfo.LastAccessTime.QuadPart = DirectoryCB->ObjectInformation->LastAccessTime.QuadPart;
1907
1908             DirectoryCB->ObjectInformation->LastAccessTime.QuadPart = pBuffer->LastAccessTime.QuadPart;
1909
1910             ulNotifyFilter |= FILE_NOTIFY_CHANGE_LAST_ACCESS;
1911
1912             SetFlag( DirectoryCB->ObjectInformation->Fcb->Flags, AFS_FCB_FLAG_FILE_MODIFIED | AFS_FCB_FLAG_UPDATE_ACCESS_TIME);
1913         }
1914
1915         pCcb->FileUnwindInfo.LastWriteTime.QuadPart = (ULONGLONG)-1;
1916
1917         if( pBuffer->LastWriteTime.QuadPart != (ULONGLONG)-1 &&
1918             pBuffer->LastWriteTime.QuadPart != (ULONGLONG)0)
1919         {
1920
1921             pCcb->FileUnwindInfo.LastWriteTime.QuadPart = DirectoryCB->ObjectInformation->LastWriteTime.QuadPart;
1922
1923             DirectoryCB->ObjectInformation->LastWriteTime.QuadPart = pBuffer->LastWriteTime.QuadPart;
1924
1925             ulNotifyFilter |= FILE_NOTIFY_CHANGE_LAST_WRITE;
1926
1927             SetFlag( DirectoryCB->ObjectInformation->Fcb->Flags, AFS_FCB_FLAG_FILE_MODIFIED | AFS_FCB_FLAG_UPDATE_LAST_WRITE_TIME);
1928         }
1929
1930         pCcb->FileUnwindInfo.ChangeTime.QuadPart = (ULONGLONG)-1;
1931
1932         if( pBuffer->ChangeTime.QuadPart != (ULONGLONG)-1 &&
1933             pBuffer->ChangeTime.QuadPart != (ULONGLONG)0)
1934         {
1935
1936             pCcb->FileUnwindInfo.ChangeTime.QuadPart = DirectoryCB->ObjectInformation->ChangeTime.QuadPart;
1937
1938             DirectoryCB->ObjectInformation->ChangeTime.QuadPart = pBuffer->ChangeTime.QuadPart;
1939
1940             ulNotifyFilter |= FILE_NOTIFY_CHANGE_LAST_ACCESS;
1941
1942             SetFlag( DirectoryCB->ObjectInformation->Fcb->Flags, AFS_FCB_FLAG_FILE_MODIFIED | AFS_FCB_FLAG_UPDATE_CHANGE_TIME);
1943         }
1944
1945         if( ulNotifyFilter > 0)
1946         {
1947
1948             if( DirectoryCB->ObjectInformation->ParentObjectInformation != NULL)
1949             {
1950
1951                 AFSFsRtlNotifyFullReportChange( DirectoryCB->ObjectInformation->ParentObjectInformation,
1952                                                 pCcb,
1953                                                 (ULONG)ulNotifyFilter,
1954                                                 (ULONG)FILE_ACTION_MODIFIED);
1955             }
1956         }
1957
1958 try_exit:
1959
1960         NOTHING;
1961     }
1962
1963     return ntStatus;
1964 }
1965
1966 NTSTATUS
1967 AFSSetDispositionInfo( IN PIRP Irp,
1968                        IN AFSDirectoryCB *DirectoryCB)
1969 {
1970     NTSTATUS ntStatus = STATUS_SUCCESS;
1971     PFILE_DISPOSITION_INFORMATION pBuffer;
1972     PIO_STACK_LOCATION pIrpSp = IoGetCurrentIrpStackLocation( Irp);
1973     AFSFcb *pFcb = NULL;
1974     AFSCcb *pCcb = NULL;
1975
1976     __Enter
1977     {
1978
1979         pBuffer = (PFILE_DISPOSITION_INFORMATION)Irp->AssociatedIrp.SystemBuffer;
1980
1981         pFcb = (AFSFcb *)pIrpSp->FileObject->FsContext;
1982
1983         pCcb = (AFSCcb *)pIrpSp->FileObject->FsContext2;
1984
1985         //
1986         // Can't delete the root
1987         //
1988
1989         if( pFcb->Header.NodeTypeCode == AFS_ROOT_FCB)
1990         {
1991
1992             AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
1993                           AFS_TRACE_LEVEL_ERROR,
1994                           "AFSSetDispositionInfo Attempt to delete root entry\n");
1995
1996             try_return( ntStatus = STATUS_CANNOT_DELETE);
1997         }
1998
1999         //
2000         // If the file is read only then do not allow the delete
2001         //
2002
2003         if( BooleanFlagOn( DirectoryCB->ObjectInformation->FileAttributes, FILE_ATTRIBUTE_READONLY))
2004         {
2005
2006             AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
2007                           AFS_TRACE_LEVEL_ERROR,
2008                           "AFSSetDispositionInfo Attempt to delete read only entry %wZ\n",
2009                           &DirectoryCB->NameInformation.FileName);
2010
2011             try_return( ntStatus = STATUS_CANNOT_DELETE);
2012         }
2013
2014         if( pBuffer->DeleteFile)
2015         {
2016
2017             //
2018             // Check if the caller can delete the file
2019             //
2020
2021             ntStatus = AFSNotifyDelete( DirectoryCB,
2022                                         &pCcb->AuthGroup,
2023                                         TRUE);
2024
2025             if( !NT_SUCCESS( ntStatus))
2026             {
2027
2028                 AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
2029                               AFS_TRACE_LEVEL_ERROR,
2030                               "AFSSetDispositionInfo Cannot delete entry %wZ Status %08lX\n",
2031                               &DirectoryCB->NameInformation.FileName,
2032                               ntStatus);
2033
2034                 try_return( ntStatus);
2035             }
2036
2037             if( pFcb->Header.NodeTypeCode == AFS_DIRECTORY_FCB)
2038             {
2039
2040                 //
2041                 // Check if this is a directory that there are not currently other opens
2042                 //
2043
2044                 if( pFcb->ObjectInformation->Specific.Directory.ChildOpenHandleCount > 0)
2045                 {
2046
2047                     AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
2048                                   AFS_TRACE_LEVEL_ERROR,
2049                                   "AFSSetDispositionInfo Attempt to delete directory %wZ with open %u handles\n",
2050                                   &DirectoryCB->NameInformation.FileName,
2051                                   pFcb->ObjectInformation->Specific.Directory.ChildOpenHandleCount);
2052
2053                     try_return( ntStatus = STATUS_DIRECTORY_NOT_EMPTY);
2054                 }
2055
2056                 if( !AFSIsDirectoryEmptyForDelete( pFcb))
2057                 {
2058
2059                     AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
2060                                   AFS_TRACE_LEVEL_ERROR,
2061                                   "AFSSetDispositionInfo Attempt to delete non-empty directory %wZ\n",
2062                                   &DirectoryCB->NameInformation.FileName);
2063
2064                     try_return( ntStatus = STATUS_DIRECTORY_NOT_EMPTY);
2065                 }
2066
2067                 AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
2068                               AFS_TRACE_LEVEL_VERBOSE,
2069                               "AFSSetDispositionInfo Setting PENDING_DELETE on DirEntry  %p Name %wZ\n",
2070                               DirectoryCB,
2071                               &DirectoryCB->NameInformation.FileName);
2072
2073                 SetFlag( pCcb->DirectoryCB->Flags, AFS_DIR_ENTRY_PENDING_DELETE);
2074             }
2075             else if( pFcb->Header.NodeTypeCode == AFS_FILE_FCB)
2076             {
2077
2078                 //
2079                 // Attempt to flush any outstanding data
2080                 //
2081
2082                 if( !MmFlushImageSection( &pFcb->NPFcb->SectionObjectPointers,
2083                                           MmFlushForDelete))
2084                 {
2085
2086                     AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
2087                                   AFS_TRACE_LEVEL_ERROR,
2088                                   "AFSSetDispositionInfo Failed to flush image section for delete Entry %wZ\n",
2089                                   &DirectoryCB->NameInformation.FileName);
2090
2091                     try_return( ntStatus = STATUS_CANNOT_DELETE);
2092                 }
2093
2094                 //
2095                 // Set PENDING_DELETE before CcPurgeCacheSection to avoid a
2096                 // deadlock with Trend Micro's Enterprise anti-virus product
2097                 // which attempts to open the file which is being deleted.
2098                 //
2099
2100                 AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
2101                               AFS_TRACE_LEVEL_VERBOSE,
2102                               "AFSSetDispositionInfo Setting PENDING_DELETE on DirEntry %p Name %wZ\n",
2103                               DirectoryCB,
2104                               &DirectoryCB->NameInformation.FileName);
2105
2106                 SetFlag( pCcb->DirectoryCB->Flags, AFS_DIR_ENTRY_PENDING_DELETE);
2107
2108                 //
2109                 // Purge the cache as well
2110                 //
2111
2112                 if( pFcb->NPFcb->SectionObjectPointers.DataSectionObject != NULL)
2113                 {
2114
2115                     if ( !CcPurgeCacheSection( &pFcb->NPFcb->SectionObjectPointers,
2116                                                NULL,
2117                                                0,
2118                                                TRUE))
2119                     {
2120
2121                         SetFlag( pFcb->Flags, AFS_FCB_FLAG_PURGE_ON_CLOSE);
2122                     }
2123                 }
2124             }
2125         }
2126         else
2127         {
2128
2129             ClearFlag( pCcb->DirectoryCB->Flags, AFS_DIR_ENTRY_PENDING_DELETE);
2130         }
2131
2132         //
2133         // OK, should be good to go, set the flag in the file object
2134         //
2135
2136         pIrpSp->FileObject->DeletePending = pBuffer->DeleteFile;
2137
2138 try_exit:
2139
2140         NOTHING;
2141     }
2142
2143     return ntStatus;
2144 }
2145
2146 NTSTATUS
2147 AFSSetRenameInfo( IN PIRP Irp)
2148 {
2149
2150     NTSTATUS ntStatus = STATUS_SUCCESS;
2151     AFSDeviceExt *pDeviceExt = (AFSDeviceExt *)AFSRDRDeviceObject->DeviceExtension;
2152     PIO_STACK_LOCATION pIrpSp = IoGetCurrentIrpStackLocation( Irp);
2153     IO_STATUS_BLOCK stIoSb = {0,0};
2154     AFSFcb *pSrcFcb = NULL, *pTargetDcb = NULL, *pTargetFcb = NULL;
2155     AFSCcb *pSrcCcb = NULL, *pTargetDirCcb = NULL;
2156     PFILE_OBJECT pSrcFileObj = pIrpSp->FileObject;
2157     PFILE_OBJECT pTargetFileObj = pIrpSp->Parameters.SetFile.FileObject;
2158     PFILE_RENAME_INFORMATION pRenameInfo = NULL;
2159     UNICODE_STRING uniTargetName, uniSourceName;
2160     BOOLEAN bReplaceIfExists = FALSE;
2161     UNICODE_STRING uniShortName;
2162     AFSDirectoryCB *pTargetDirEntry = NULL;
2163     ULONG ulTargetCRC = 0;
2164     BOOLEAN bTargetEntryExists = FALSE;
2165     AFSObjectInfoCB *pSrcObject = NULL, *pTargetObject = NULL;
2166     AFSObjectInfoCB *pSrcParentObject = NULL, *pTargetParentObject = NULL;
2167     AFSFileID stNewFid, stTmpTargetFid;
2168     ULONG ulNotificationAction = 0, ulNotifyFilter = 0;
2169     UNICODE_STRING uniFullTargetPath;
2170     BOOLEAN bCommonParent = FALSE;
2171     BOOLEAN bReleaseTargetDirLock = FALSE;
2172     BOOLEAN bReleaseSourceDirLock = FALSE;
2173     PERESOURCE  pSourceDirLock = NULL;
2174     LONG lCount;
2175
2176     __Enter
2177     {
2178
2179         bReplaceIfExists = pIrpSp->Parameters.SetFile.ReplaceIfExists;
2180
2181         pSrcFcb = (AFSFcb *)pSrcFileObj->FsContext;
2182         pSrcCcb = (AFSCcb *)pSrcFileObj->FsContext2;
2183
2184         pSrcObject = pSrcFcb->ObjectInformation;
2185         pSrcParentObject = pSrcFcb->ObjectInformation->ParentObjectInformation;
2186
2187         //
2188         // Perform some basic checks to ensure FS integrity
2189         //
2190
2191         if( pSrcFcb->Header.NodeTypeCode == AFS_ROOT_FCB)
2192         {
2193
2194             //
2195             // Can't rename the root directory
2196             //
2197
2198             AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
2199                           AFS_TRACE_LEVEL_ERROR,
2200                           "AFSSetRenameInfo Attempt to rename root entry\n");
2201
2202             try_return( ntStatus = STATUS_INVALID_PARAMETER);
2203         }
2204
2205         if( pSrcFcb->Header.NodeTypeCode == AFS_DIRECTORY_FCB)
2206         {
2207
2208             //
2209             // If there are any open children then fail the rename
2210             //
2211
2212             if( pSrcFcb->ObjectInformation->Specific.Directory.ChildOpenHandleCount > 0)
2213             {
2214
2215                 AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
2216                               AFS_TRACE_LEVEL_ERROR,
2217                               "AFSSetRenameInfo Attempt to rename directory with open children %wZ\n",
2218                               &pSrcCcb->DirectoryCB->NameInformation.FileName);
2219
2220                 try_return( ntStatus = STATUS_ACCESS_DENIED);
2221             }
2222         }
2223
2224         //
2225         // Extract off the final component name from the Fcb
2226         //
2227
2228         uniSourceName.Length = (USHORT)pSrcCcb->DirectoryCB->NameInformation.FileName.Length;
2229         uniSourceName.MaximumLength = uniSourceName.Length;
2230
2231         uniSourceName.Buffer = pSrcCcb->DirectoryCB->NameInformation.FileName.Buffer;
2232
2233         //
2234         // Resolve the target fileobject
2235         //
2236
2237         if( pTargetFileObj == NULL)
2238         {
2239
2240             //
2241             // This is a simple rename. Here the target directory is the same as the source parent directory
2242             // and the name is retrieved from the system buffer information
2243             //
2244
2245             pRenameInfo = (PFILE_RENAME_INFORMATION)Irp->AssociatedIrp.SystemBuffer;
2246
2247             pTargetParentObject = pSrcParentObject;
2248
2249             pTargetDcb = pTargetParentObject->Fcb;
2250
2251             uniTargetName.Length = (USHORT)pRenameInfo->FileNameLength;
2252             uniTargetName.Buffer = (PWSTR)&pRenameInfo->FileName;
2253         }
2254         else
2255         {
2256
2257             //
2258             // So here we have the target directory taken from the targetfile object
2259             //
2260
2261             pTargetDcb = (AFSFcb *)pTargetFileObj->FsContext;
2262
2263             pTargetDirCcb = (AFSCcb *)pTargetFileObj->FsContext2;
2264
2265             pTargetParentObject = (AFSObjectInfoCB *)pTargetDcb->ObjectInformation;
2266
2267             //
2268             // Grab the target name which we setup in the IRP_MJ_CREATE handler. By how we set this up
2269             // it is only the target component of the rename operation
2270             //
2271
2272             uniTargetName = *((PUNICODE_STRING)&pTargetFileObj->FileName);
2273         }
2274
2275         //
2276         // The quick check to see if they are not really performing a rename
2277         // Do the names match? Only do this where the parent directories are
2278         // the same
2279         //
2280
2281         if( pTargetParentObject == pSrcParentObject)
2282         {
2283
2284             if( FsRtlAreNamesEqual( &uniTargetName,
2285                                     &uniSourceName,
2286                                     FALSE,
2287                                     NULL))
2288             {
2289                 try_return( ntStatus = STATUS_SUCCESS);
2290             }
2291
2292             bCommonParent = TRUE;
2293         }
2294         else
2295         {
2296
2297             bCommonParent = FALSE;
2298         }
2299
2300         //
2301         // We do not allow cross-volume renames to occur
2302         //
2303
2304         if( pTargetParentObject->VolumeCB != pSrcObject->VolumeCB)
2305         {
2306
2307             AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
2308                           AFS_TRACE_LEVEL_ERROR,
2309                           "AFSSetRenameInfo Attempt to rename directory to different volume %wZ\n",
2310                           &pSrcCcb->DirectoryCB->NameInformation.FileName);
2311
2312             try_return( ntStatus = STATUS_NOT_SAME_DEVICE);
2313         }
2314
2315         ulTargetCRC = AFSGenerateCRC( &uniTargetName,
2316                                       FALSE);
2317
2318         AFSAcquireExcl( pTargetParentObject->Specific.Directory.DirectoryNodeHdr.TreeLock,
2319                         TRUE);
2320
2321         bReleaseTargetDirLock = TRUE;
2322
2323         if( pTargetParentObject != pSrcParentObject)
2324         {
2325             AFSAcquireExcl( pSrcParentObject->Specific.Directory.DirectoryNodeHdr.TreeLock,
2326                             TRUE);
2327
2328             bReleaseSourceDirLock = TRUE;
2329
2330             pSourceDirLock = pSrcParentObject->Specific.Directory.DirectoryNodeHdr.TreeLock;
2331         }
2332
2333         AFSLocateCaseSensitiveDirEntry( pTargetParentObject->Specific.Directory.DirectoryNodeHdr.CaseSensitiveTreeHead,
2334                                         ulTargetCRC,
2335                                         &pTargetDirEntry);
2336
2337         if( pTargetDirEntry == NULL)
2338         {
2339
2340             //
2341             // Missed so perform a case insensitive lookup
2342             //
2343
2344             ulTargetCRC = AFSGenerateCRC( &uniTargetName,
2345                                           TRUE);
2346
2347             AFSLocateCaseInsensitiveDirEntry( pTargetParentObject->Specific.Directory.DirectoryNodeHdr.CaseInsensitiveTreeHead,
2348                                               ulTargetCRC,
2349                                               &pTargetDirEntry);
2350         }
2351
2352         if ( !BooleanFlagOn( pDeviceExt->DeviceFlags, AFS_DEVICE_FLAG_DISABLE_SHORTNAMES) &&
2353              pTargetDirEntry == NULL && RtlIsNameLegalDOS8Dot3( &uniTargetName,
2354                                                                NULL,
2355                                                                NULL))
2356         {
2357             //
2358             // Try the short name
2359             //
2360             AFSLocateShortNameDirEntry( pTargetParentObject->Specific.Directory.ShortNameTree,
2361                                         ulTargetCRC,
2362                                         &pTargetDirEntry);
2363         }
2364
2365         //
2366         // Increment our ref count on the dir entry
2367         //
2368
2369         if( pTargetDirEntry != NULL)
2370         {
2371
2372             ASSERT( pTargetParentObject == pTargetDirEntry->ObjectInformation->ParentObjectInformation);
2373
2374             lCount = InterlockedIncrement( &pTargetDirEntry->OpenReferenceCount);
2375
2376             if( !bReplaceIfExists)
2377             {
2378
2379                 AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
2380                               AFS_TRACE_LEVEL_ERROR,
2381                               "AFSSetRenameInfo Attempt to rename directory with target collision %wZ Target %wZ\n",
2382                               &pSrcCcb->DirectoryCB->NameInformation.FileName,
2383                               &pTargetDirEntry->NameInformation.FileName);
2384
2385                 try_return( ntStatus = STATUS_OBJECT_NAME_COLLISION);
2386             }
2387
2388             AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
2389                           AFS_TRACE_LEVEL_ERROR,
2390                           "AFSSetRenameInfo Target %wZ exists DE %p Count %08lX, performing delete of target\n",
2391                           &pTargetDirEntry->NameInformation.FileName,
2392                           pTargetDirEntry,
2393                           pTargetDirEntry->OpenReferenceCount);
2394
2395             //
2396             // Pull the directory entry from the parent
2397             //
2398
2399             AFSRemoveDirNodeFromParent( pTargetParentObject,
2400                                         pTargetDirEntry,
2401                                         FALSE);
2402
2403             bTargetEntryExists = TRUE;
2404         }
2405         else
2406         {
2407             AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
2408                           AFS_TRACE_LEVEL_VERBOSE,
2409                           "AFSSetRenameInfo Target does NOT exist, normal rename\n");
2410         }
2411
2412         //
2413         // We need to remove the DirEntry from the parent node, update the index
2414         // and reinsert it into the parent tree. Note that for entries with the
2415         // same parent we do not pull the node from the enumeration list
2416         //
2417
2418         AFSRemoveDirNodeFromParent( pSrcFcb->ObjectInformation->ParentObjectInformation,
2419                                     pSrcCcb->DirectoryCB,
2420                                     !bCommonParent);
2421
2422         //
2423         // OK, this is a simple rename. Issue the rename
2424         // request to the service.
2425         //
2426
2427         ntStatus = AFSNotifyRename( pSrcFcb->ObjectInformation,
2428                                     &pSrcCcb->AuthGroup,
2429                                     pSrcFcb->ObjectInformation->ParentObjectInformation,
2430                                     pTargetDcb->ObjectInformation,
2431                                     pSrcCcb->DirectoryCB,
2432                                     &uniTargetName,
2433                                     &stNewFid);
2434
2435         if( !NT_SUCCESS( ntStatus))
2436         {
2437
2438             //
2439             // Attempt to re-insert the directory entry
2440             //
2441
2442             AFSInsertDirectoryNode( pSrcFcb->ObjectInformation->ParentObjectInformation,
2443                                     pSrcCcb->DirectoryCB,
2444                                     !bCommonParent);
2445
2446             AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
2447                           AFS_TRACE_LEVEL_ERROR,
2448                           "AFSSetRenameInfo Failed rename of %wZ to target %wZ Status %08lX\n",
2449                           &pSrcCcb->DirectoryCB->NameInformation.FileName,
2450                           &uniTargetName,
2451                           ntStatus);
2452
2453             try_return( ntStatus);
2454         }
2455
2456         //
2457         // Set the notification up for the source file
2458         //
2459
2460         if( pSrcCcb->DirectoryCB->ObjectInformation->ParentObjectInformation == pTargetParentObject &&
2461             !bTargetEntryExists)
2462         {
2463
2464             ulNotificationAction = FILE_ACTION_RENAMED_OLD_NAME;
2465         }
2466         else
2467         {
2468
2469             ulNotificationAction = FILE_ACTION_REMOVED;
2470         }
2471
2472         if( pSrcCcb->DirectoryCB->ObjectInformation->FileType == AFS_FILE_TYPE_DIRECTORY)
2473         {
2474
2475             ulNotifyFilter = FILE_NOTIFY_CHANGE_DIR_NAME;
2476         }
2477         else
2478         {
2479
2480             ulNotifyFilter = FILE_NOTIFY_CHANGE_FILE_NAME;
2481         }
2482
2483         AFSFsRtlNotifyFullReportChange( pSrcCcb->DirectoryCB->ObjectInformation->ParentObjectInformation,
2484                                         pSrcCcb,
2485                                         (ULONG)ulNotifyFilter,
2486                                         (ULONG)ulNotificationAction);
2487
2488         //
2489         // Update the name in the dir entry.
2490         //
2491
2492         ntStatus = AFSUpdateDirEntryName( pSrcCcb->DirectoryCB,
2493                                           &uniTargetName);
2494
2495         if( !NT_SUCCESS( ntStatus))
2496         {
2497
2498             //
2499             // Attempt to re-insert the directory entry
2500             //
2501
2502             AFSInsertDirectoryNode( pSrcFcb->ObjectInformation->ParentObjectInformation,
2503                                     pSrcCcb->DirectoryCB,
2504                                     !bCommonParent);
2505
2506             AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
2507                           AFS_TRACE_LEVEL_ERROR,
2508                           "AFSSetRenameInfo Failed update of dir entry %wZ to target %wZ Status %08lX\n",
2509                           &pSrcCcb->DirectoryCB->NameInformation.FileName,
2510                           &uniTargetName,
2511                           ntStatus);
2512
2513             try_return( ntStatus);
2514         }
2515
2516         //
2517         // Update the object information block, if needed
2518         //
2519
2520         if( !AFSIsEqualFID( &pSrcObject->FileId,
2521                             &stNewFid))
2522         {
2523
2524             AFSAcquireExcl( pSrcObject->VolumeCB->ObjectInfoTree.TreeLock,
2525                             TRUE);
2526
2527             //
2528             // Remove the old information entry
2529             //
2530
2531             AFSRemoveHashEntry( &pSrcObject->VolumeCB->ObjectInfoTree.TreeHead,
2532                                 &pSrcObject->TreeEntry);
2533
2534             RtlCopyMemory( &pSrcObject->FileId,
2535                            &stNewFid,
2536                            sizeof( AFSFileID));
2537
2538             //
2539             // Insert the entry into the new object table.
2540             //
2541
2542             pSrcObject->TreeEntry.HashIndex = AFSCreateLowIndex( &pSrcObject->FileId);
2543
2544             if( pSrcObject->VolumeCB->ObjectInfoTree.TreeHead == NULL)
2545             {
2546
2547                 pSrcObject->VolumeCB->ObjectInfoTree.TreeHead = &pSrcObject->TreeEntry;
2548             }
2549             else
2550             {
2551
2552                 if ( !NT_SUCCESS( AFSInsertHashEntry( pSrcObject->VolumeCB->ObjectInfoTree.TreeHead,
2553                                                      &pSrcObject->TreeEntry)))
2554                 {
2555
2556                     //
2557                     // Lost a race, an ObjectInfo object already exists for this FID.
2558                     // Let this copy be garbage collected.
2559                     //
2560
2561                     ClearFlag( pSrcObject->Flags, AFS_OBJECT_INSERTED_HASH_TREE);
2562                 }
2563             }
2564
2565             AFSReleaseResource( pSrcObject->VolumeCB->ObjectInfoTree.TreeLock);
2566         }
2567
2568         //
2569         // Update the hash values for the name trees.
2570         //
2571
2572         pSrcCcb->DirectoryCB->CaseSensitiveTreeEntry.HashIndex = AFSGenerateCRC( &pSrcCcb->DirectoryCB->NameInformation.FileName,
2573                                                                                  FALSE);
2574
2575         pSrcCcb->DirectoryCB->CaseInsensitiveTreeEntry.HashIndex = AFSGenerateCRC( &pSrcCcb->DirectoryCB->NameInformation.FileName,
2576                                                                                    TRUE);
2577
2578         if( !BooleanFlagOn( pDeviceExt->DeviceFlags, AFS_DEVICE_FLAG_DISABLE_SHORTNAMES) &&
2579             pSrcCcb->DirectoryCB->NameInformation.ShortNameLength > 0 &&
2580             !RtlIsNameLegalDOS8Dot3( &pSrcCcb->DirectoryCB->NameInformation.FileName,
2581                                      NULL,
2582                                      NULL))
2583         {
2584
2585             uniShortName.Length = pSrcCcb->DirectoryCB->NameInformation.ShortNameLength;
2586             uniShortName.MaximumLength = uniShortName.Length;
2587             uniShortName.Buffer = pSrcCcb->DirectoryCB->NameInformation.ShortName;
2588
2589             pSrcCcb->DirectoryCB->Type.Data.ShortNameTreeEntry.HashIndex = AFSGenerateCRC( &uniShortName,
2590                                                                                            TRUE);
2591
2592             AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
2593                           AFS_TRACE_LEVEL_VERBOSE,
2594                           "AFSSetRenameInfo Initialized short name hash for %wZ longname %wZ\n",
2595                           &uniShortName,
2596                           &pSrcCcb->DirectoryCB->NameInformation.FileName);
2597         }
2598         else
2599         {
2600
2601             pSrcCcb->DirectoryCB->Type.Data.ShortNameTreeEntry.HashIndex = 0;
2602         }
2603
2604         if( !bCommonParent)
2605         {
2606
2607             //
2608             // Update the file index for the object in the new parent
2609             //
2610
2611             pSrcCcb->DirectoryCB->FileIndex = (ULONG)InterlockedIncrement( &pTargetParentObject->Specific.Directory.DirectoryNodeHdr.ContentIndex);
2612         }
2613
2614         //
2615         // Re-insert the directory entry
2616         //
2617
2618         AFSInsertDirectoryNode( pTargetParentObject,
2619                                 pSrcCcb->DirectoryCB,
2620                                 !bCommonParent);
2621
2622         //
2623         // Update the parent pointer in the source object if they are different
2624         //
2625
2626         if( pSrcCcb->DirectoryCB->ObjectInformation->ParentObjectInformation != pTargetParentObject)
2627         {
2628
2629             lCount = InterlockedDecrement( &pSrcCcb->DirectoryCB->ObjectInformation->ParentObjectInformation->Specific.Directory.ChildOpenHandleCount);
2630
2631             lCount = InterlockedDecrement( &pSrcCcb->DirectoryCB->ObjectInformation->ParentObjectInformation->Specific.Directory.ChildOpenReferenceCount);
2632
2633             lCount = InterlockedIncrement( &pTargetParentObject->Specific.Directory.ChildOpenHandleCount);
2634
2635             lCount = InterlockedIncrement( &pTargetParentObject->Specific.Directory.ChildOpenReferenceCount);
2636
2637             pSrcCcb->DirectoryCB->ObjectInformation->ParentObjectInformation = pTargetParentObject;
2638
2639             ulNotificationAction = FILE_ACTION_ADDED;
2640         }
2641         else
2642         {
2643
2644             ulNotificationAction = FILE_ACTION_RENAMED_NEW_NAME;
2645         }
2646
2647         //
2648         // Now update the notification for the target file
2649         //
2650
2651         AFSFsRtlNotifyFullReportChange( pTargetParentObject->ParentObjectInformation,
2652                                         pSrcCcb,
2653                                         (ULONG)ulNotifyFilter,
2654                                         (ULONG)ulNotificationAction);
2655
2656         //
2657         // If we performed the rename of the target because it existed, we now need to
2658         // delete the tmp target we created above
2659         //
2660
2661         if( bTargetEntryExists)
2662         {
2663
2664             AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
2665                           AFS_TRACE_LEVEL_VERBOSE,
2666                           "AFSSetRenameInfo Setting DELETE flag in dir entry %p name %wZ\n",
2667                           pTargetDirEntry,
2668                           &pTargetDirEntry->NameInformation.FileName);
2669
2670             SetFlag( pTargetDirEntry->Flags, AFS_DIR_ENTRY_DELETED);
2671
2672             //
2673             // Try and purge the cache map if this is a file
2674             //
2675
2676             if( pTargetDirEntry->ObjectInformation->FileType == AFS_FILE_TYPE_FILE &&
2677                 pTargetDirEntry->ObjectInformation->Fcb != NULL &&
2678                 pTargetDirEntry->OpenReferenceCount > 1)
2679             {
2680
2681                 pTargetFcb = pTargetDirEntry->ObjectInformation->Fcb;
2682
2683                 AFSAcquireExcl( &pTargetFcb->NPFcb->Resource,
2684                                 TRUE);
2685
2686                 //
2687                 // Close the section in the event it was mapped
2688                 //
2689
2690                 if( !MmForceSectionClosed( &pTargetFcb->NPFcb->SectionObjectPointers,
2691                                            TRUE))
2692                 {
2693
2694                     AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
2695                                   AFS_TRACE_LEVEL_ERROR,
2696                                   "AFSSetRenameInfo Failed to delete section for target file %wZ\n",
2697                                   &pTargetDirEntry->NameInformation.FileName);
2698                 }
2699
2700                 AFSReleaseResource( &pTargetFcb->NPFcb->Resource);
2701             }
2702
2703             ASSERT( pTargetDirEntry->OpenReferenceCount > 0);
2704
2705             lCount = InterlockedDecrement( &pTargetDirEntry->OpenReferenceCount); // The count we added above
2706
2707             if( lCount == 0)
2708             {
2709
2710                 AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
2711                               AFS_TRACE_LEVEL_VERBOSE,
2712                               "AFSSetRenameInfo Deleting dir entry %p name %wZ\n",
2713                               pTargetDirEntry,
2714                               &pTargetDirEntry->NameInformation.FileName);
2715
2716                 AFSDeleteDirEntry( pTargetParentObject,
2717                                    pTargetDirEntry);
2718             }
2719
2720             pTargetDirEntry = NULL;
2721         }
2722
2723 try_exit:
2724
2725
2726         if( !NT_SUCCESS( ntStatus))
2727         {
2728
2729             if( bTargetEntryExists)
2730             {
2731                 AFSInsertDirectoryNode( pTargetDirEntry->ObjectInformation->ParentObjectInformation,
2732                                         pTargetDirEntry,
2733                                         FALSE);
2734             }
2735         }
2736
2737         if( pTargetDirEntry != NULL)
2738         {
2739
2740             lCount = InterlockedDecrement( &pTargetDirEntry->OpenReferenceCount);
2741         }
2742
2743         if( bReleaseTargetDirLock)
2744         {
2745             AFSReleaseResource( pTargetParentObject->Specific.Directory.DirectoryNodeHdr.TreeLock);
2746         }
2747
2748         if( bReleaseSourceDirLock)
2749         {
2750             AFSReleaseResource( pSourceDirLock);
2751         }
2752     }
2753
2754     return ntStatus;
2755 }
2756
2757 NTSTATUS
2758 AFSSetPositionInfo( IN PIRP Irp,
2759                     IN AFSDirectoryCB *DirectoryCB)
2760 {
2761     NTSTATUS ntStatus = STATUS_SUCCESS;
2762     PFILE_POSITION_INFORMATION pBuffer;
2763     PIO_STACK_LOCATION pIrpSp = IoGetCurrentIrpStackLocation( Irp);
2764
2765     pBuffer = (PFILE_POSITION_INFORMATION)Irp->AssociatedIrp.SystemBuffer;
2766
2767     pIrpSp->FileObject->CurrentByteOffset.QuadPart = pBuffer->CurrentByteOffset.QuadPart;
2768
2769     return ntStatus;
2770 }
2771
2772 NTSTATUS
2773 AFSSetAllocationInfo( IN PIRP Irp,
2774                       IN AFSDirectoryCB *DirectoryCB)
2775 {
2776     NTSTATUS ntStatus = STATUS_SUCCESS;
2777     PFILE_ALLOCATION_INFORMATION pBuffer;
2778     BOOLEAN bReleasePaging = FALSE;
2779     BOOLEAN bTellCc = FALSE;
2780     BOOLEAN bTellService = FALSE;
2781     PIO_STACK_LOCATION pIrpSp = IoGetCurrentIrpStackLocation( Irp);
2782     PFILE_OBJECT pFileObject = pIrpSp->FileObject;
2783     AFSFcb *pFcb = NULL;
2784     AFSCcb *pCcb = NULL;
2785     LARGE_INTEGER liSaveAlloc;
2786     LARGE_INTEGER liSaveFileSize;
2787     LARGE_INTEGER liSaveVDL;
2788
2789     pBuffer = (PFILE_ALLOCATION_INFORMATION)Irp->AssociatedIrp.SystemBuffer;
2790
2791     pFcb = (AFSFcb *)pIrpSp->FileObject->FsContext;
2792
2793     pCcb = (AFSCcb *)pIrpSp->FileObject->FsContext2;
2794
2795     //
2796     // save values to put back
2797     //
2798     liSaveAlloc = pFcb->Header.AllocationSize;
2799     liSaveFileSize = pFcb->Header.FileSize;
2800     liSaveVDL = pFcb->Header.ValidDataLength;
2801
2802     if( pFcb->Header.AllocationSize.QuadPart == pBuffer->AllocationSize.QuadPart ||
2803         pIrpSp->Parameters.SetFile.AdvanceOnly)
2804     {
2805         return STATUS_SUCCESS ;
2806     }
2807
2808     if( pFcb->Header.AllocationSize.QuadPart > pBuffer->AllocationSize.QuadPart)
2809     {
2810         //
2811         // Truncating the file
2812         //
2813         if( !MmCanFileBeTruncated( pFileObject->SectionObjectPointer,
2814                                    &pBuffer->AllocationSize))
2815         {
2816
2817             ntStatus = STATUS_USER_MAPPED_FILE ;
2818         }
2819         else
2820         {
2821             //
2822             // If this is a truncation we need to grab the paging IO resource.
2823             //
2824
2825             AFSDbgLogMsg( AFS_SUBSYSTEM_LOCK_PROCESSING,
2826                           AFS_TRACE_LEVEL_VERBOSE,
2827                           "AFSSetAllocationInfo Acquiring Fcb PagingIo lock %08lX EXCL %08lX\n",
2828                           &pFcb->NPFcb->PagingResource,
2829                           PsGetCurrentThread());
2830
2831             AFSAcquireExcl( &pFcb->NPFcb->PagingResource,
2832                             TRUE);
2833
2834             bReleasePaging = TRUE;
2835
2836             //
2837             // Must drop the Fcb Resource.  When changing the file size
2838             // a deadlock can occur with Trend Micro's filter if the file
2839             // size is set to zero.
2840             //
2841
2842             AFSReleaseResource( &pFcb->NPFcb->Resource);
2843
2844             pFcb->Header.AllocationSize = pBuffer->AllocationSize;
2845
2846             pFcb->ObjectInformation->AllocationSize = pBuffer->AllocationSize;
2847
2848             //
2849             // Tell Cc that Allocation is moved.
2850             //
2851             bTellCc = TRUE;
2852
2853             if( pFcb->Header.FileSize.QuadPart > pBuffer->AllocationSize.QuadPart)
2854             {
2855                 //
2856                 // We are pulling the EOF back as well so we need to tell
2857                 // the service.
2858                 //
2859                 bTellService = TRUE;
2860
2861                 pFcb->Header.FileSize = pBuffer->AllocationSize;
2862
2863                 pFcb->ObjectInformation->EndOfFile = pBuffer->AllocationSize;
2864             }
2865
2866         }
2867     }
2868     else
2869     {
2870         //
2871         // Tell Cc if allocation is increased.
2872         //
2873
2874         AFSDbgLogMsg( AFS_SUBSYSTEM_LOCK_PROCESSING,
2875                       AFS_TRACE_LEVEL_VERBOSE,
2876                       "AFSSetAllocationInfo Acquiring Fcb PagingIo lock %08lX EXCL %08lX\n",
2877                       &pFcb->NPFcb->PagingResource,
2878                       PsGetCurrentThread());
2879
2880         AFSAcquireExcl( &pFcb->NPFcb->PagingResource,
2881                         TRUE);
2882
2883         bReleasePaging = TRUE;
2884
2885         //
2886         // Must drop the Fcb Resource.  When changing the file size
2887         // a deadlock can occur with Trend Micro's filter if the file
2888         // size is set to zero.
2889         //
2890
2891         AFSReleaseResource( &pFcb->NPFcb->Resource);
2892
2893         bTellCc = pBuffer->AllocationSize.QuadPart > pFcb->Header.AllocationSize.QuadPart;
2894
2895         pFcb->Header.AllocationSize = pBuffer->AllocationSize;
2896
2897         pFcb->ObjectInformation->AllocationSize = pBuffer->AllocationSize;
2898     }
2899
2900     //
2901     // Now Tell the server if we have to
2902     //
2903     if (bTellService)
2904     {
2905         ntStatus = AFSUpdateFileInformation( &pFcb->ObjectInformation->ParentObjectInformation->FileId,
2906                                              pFcb->ObjectInformation,
2907                                              &pCcb->AuthGroup);
2908     }
2909
2910     if (NT_SUCCESS(ntStatus))
2911     {
2912         //
2913         // Trim extents if we told the service - the update has done an implicit
2914         // trim at the service.
2915         //
2916         if (bTellService)
2917         {
2918             AFSTrimExtents( pFcb,
2919                             &pFcb->Header.FileSize);
2920         }
2921
2922         KeQuerySystemTime( &pFcb->ObjectInformation->ChangeTime);
2923
2924         SetFlag( pFcb->Flags, AFS_FCB_FLAG_FILE_MODIFIED | AFS_FCB_FLAG_UPDATE_CHANGE_TIME);
2925
2926         if (bTellCc &&
2927             CcIsFileCached( pFileObject))
2928         {
2929             CcSetFileSizes( pFileObject,
2930                             (PCC_FILE_SIZES)&pFcb->Header.AllocationSize);
2931         }
2932     }
2933     else
2934     {
2935         //
2936         // Put the saved values back
2937         //
2938         pFcb->Header.ValidDataLength = liSaveVDL;
2939         pFcb->Header.FileSize = liSaveFileSize;
2940         pFcb->Header.AllocationSize = liSaveAlloc;
2941         pFcb->ObjectInformation->EndOfFile = liSaveFileSize;
2942         pFcb->ObjectInformation->AllocationSize = liSaveAlloc;
2943     }
2944
2945     if( bReleasePaging)
2946     {
2947
2948         AFSReleaseResource( &pFcb->NPFcb->PagingResource);
2949
2950         AFSAcquireExcl( &pFcb->NPFcb->Resource,
2951                         TRUE);
2952     }
2953
2954     return ntStatus;
2955 }
2956
2957 NTSTATUS
2958 AFSSetEndOfFileInfo( IN PIRP Irp,
2959                      IN AFSDirectoryCB *DirectoryCB)
2960 {
2961     NTSTATUS ntStatus = STATUS_SUCCESS;
2962     PFILE_END_OF_FILE_INFORMATION pBuffer;
2963     PIO_STACK_LOCATION pIrpSp = IoGetCurrentIrpStackLocation( Irp);
2964     PFILE_OBJECT pFileObject = pIrpSp->FileObject;
2965     LARGE_INTEGER liSaveSize;
2966     LARGE_INTEGER liSaveVDL;
2967     LARGE_INTEGER liSaveAlloc;
2968     BOOLEAN bModified = FALSE;
2969     BOOLEAN bReleasePaging = FALSE;
2970     BOOLEAN bTruncated = FALSE;
2971     AFSFcb *pFcb = NULL;
2972     AFSCcb *pCcb = NULL;
2973
2974     pFcb = (AFSFcb *)pIrpSp->FileObject->FsContext;
2975
2976     pCcb = (AFSCcb *)pIrpSp->FileObject->FsContext2;
2977
2978     pBuffer = (PFILE_END_OF_FILE_INFORMATION)Irp->AssociatedIrp.SystemBuffer;
2979
2980     liSaveSize = pFcb->Header.FileSize;
2981     liSaveAlloc = pFcb->Header.AllocationSize;
2982     liSaveVDL = pFcb->Header.ValidDataLength;
2983
2984     if( pFcb->Header.FileSize.QuadPart != pBuffer->EndOfFile.QuadPart &&
2985         !pIrpSp->Parameters.SetFile.AdvanceOnly)
2986     {
2987
2988         if( pBuffer->EndOfFile.QuadPart < pFcb->Header.FileSize.QuadPart)
2989         {
2990
2991             // Truncating the file
2992             if( !MmCanFileBeTruncated( pFileObject->SectionObjectPointer,
2993                                        &pBuffer->EndOfFile))
2994             {
2995
2996                 ntStatus = STATUS_USER_MAPPED_FILE;
2997             }
2998             else
2999             {
3000
3001                 //
3002                 // If this is a truncation we need to grab the paging
3003                 // IO resource.
3004                 //
3005                 AFSDbgLogMsg( AFS_SUBSYSTEM_LOCK_PROCESSING,
3006                               AFS_TRACE_LEVEL_VERBOSE,
3007                               "AFSSetAllocationInfo Acquiring Fcb PagingIo lock %08lX EXCL %08lX\n",
3008                               &pFcb->NPFcb->PagingResource,
3009                               PsGetCurrentThread());
3010
3011                 AFSAcquireExcl( &pFcb->NPFcb->PagingResource,
3012                                 TRUE);
3013
3014                 bReleasePaging = TRUE;
3015
3016                 //
3017                 // Must drop the Fcb Resource.  When changing the file size
3018                 // a deadlock can occur with Trend Micro's filter if the file
3019                 // size is set to zero.
3020                 //
3021
3022                 AFSReleaseResource( &pFcb->NPFcb->Resource);
3023
3024                 pFcb->Header.AllocationSize = pBuffer->EndOfFile;
3025
3026                 pFcb->Header.FileSize = pBuffer->EndOfFile;
3027
3028                 pFcb->ObjectInformation->EndOfFile = pBuffer->EndOfFile;
3029
3030                 pFcb->ObjectInformation->AllocationSize = pBuffer->EndOfFile;
3031
3032                 if( pFcb->Header.ValidDataLength.QuadPart > pFcb->Header.FileSize.QuadPart)
3033                 {
3034
3035                     pFcb->Header.ValidDataLength = pFcb->Header.FileSize;
3036                 }
3037
3038                 bTruncated = TRUE;
3039
3040                 bModified = TRUE;
3041             }
3042         }
3043         else
3044         {
3045
3046             //
3047             // extending the file, move EOF
3048             //
3049
3050             //
3051             // If this is a truncation we need to grab the paging
3052             // IO resource.
3053             //
3054             AFSDbgLogMsg( AFS_SUBSYSTEM_LOCK_PROCESSING,
3055                           AFS_TRACE_LEVEL_VERBOSE,
3056                           "AFSSetAllocationInfo Acquiring Fcb PagingIo lock %08lX EXCL %08lX\n",
3057                           &pFcb->NPFcb->PagingResource,
3058                           PsGetCurrentThread());
3059
3060             AFSAcquireExcl( &pFcb->NPFcb->PagingResource,
3061                             TRUE);
3062
3063             bReleasePaging = TRUE;
3064
3065             //
3066             // Must drop the Fcb Resource.  When changing the file size
3067             // a deadlock can occur with Trend Micro's filter if the file
3068             // size is set to zero.
3069             //
3070
3071             AFSReleaseResource( &pFcb->NPFcb->Resource);
3072
3073             pFcb->Header.FileSize = pBuffer->EndOfFile;
3074
3075             pFcb->ObjectInformation->EndOfFile = pBuffer->EndOfFile;
3076
3077             if (pFcb->Header.FileSize.QuadPart > pFcb->Header.AllocationSize.QuadPart)
3078             {
3079                 //
3080                 // And Allocation as needed.
3081                 //
3082                 pFcb->Header.AllocationSize = pBuffer->EndOfFile;
3083
3084                 pFcb->ObjectInformation->AllocationSize = pBuffer->EndOfFile;
3085             }
3086
3087             bModified = TRUE;
3088         }
3089     }
3090
3091     if (bModified)
3092     {
3093
3094         KeQuerySystemTime( &pFcb->ObjectInformation->ChangeTime);
3095
3096         SetFlag( pFcb->Flags, AFS_FCB_FLAG_FILE_MODIFIED | AFS_FCB_FLAG_UPDATE_CHANGE_TIME);
3097
3098         //
3099         // Tell the server
3100         //
3101
3102         ntStatus = AFSUpdateFileInformation( &pFcb->ObjectInformation->ParentObjectInformation->FileId,
3103                                              pFcb->ObjectInformation,
3104                                              &pCcb->AuthGroup);
3105
3106         if( NT_SUCCESS(ntStatus))
3107         {
3108             //
3109             // We are now good to go so tell CC.
3110             //
3111             CcSetFileSizes( pFileObject,
3112                             (PCC_FILE_SIZES)&pFcb->Header.AllocationSize);
3113
3114             //
3115             // And give up those extents
3116             //
3117             if( bTruncated)
3118             {
3119
3120                 AFSTrimExtents( pFcb,
3121                                 &pFcb->Header.FileSize);
3122             }
3123         }
3124         else
3125         {
3126             pFcb->Header.ValidDataLength = liSaveVDL;
3127             pFcb->Header.FileSize = liSaveSize;
3128             pFcb->Header.AllocationSize = liSaveAlloc;
3129             pFcb->ObjectInformation->EndOfFile = liSaveSize;
3130             pFcb->ObjectInformation->AllocationSize = liSaveAlloc;
3131         }
3132     }
3133
3134     if( bReleasePaging)
3135     {
3136
3137         AFSReleaseResource( &pFcb->NPFcb->PagingResource);
3138
3139         AFSAcquireExcl( &pFcb->NPFcb->Resource,
3140                         TRUE);
3141     }
3142
3143     return ntStatus;
3144 }
3145
3146 NTSTATUS
3147 AFSProcessShareSetInfo( IN IRP *Irp,
3148                         IN AFSFcb *Fcb,
3149                         IN AFSCcb *Ccb)
3150 {
3151
3152     NTSTATUS ntStatus = STATUS_SUCCESS;
3153     PIO_STACK_LOCATION pIrpSp = IoGetCurrentIrpStackLocation( Irp);
3154     ULONG ulOutputBufferLen = 0, ulInputBufferLen;
3155     FILE_INFORMATION_CLASS ulFileInformationClass;
3156     void *pPipeInfo = NULL;
3157
3158     __Enter
3159     {
3160         ulFileInformationClass = pIrpSp->Parameters.SetFile.FileInformationClass;
3161
3162         AFSDbgLogMsg( AFS_SUBSYSTEM_PIPE_PROCESSING,
3163                       AFS_TRACE_LEVEL_VERBOSE,
3164                       "AFSProcessShareSetInfo On pipe %wZ Class %08lX\n",
3165                       &Ccb->DirectoryCB->NameInformation.FileName,
3166                       ulFileInformationClass);
3167
3168         pPipeInfo = AFSLockSystemBuffer( Irp,
3169                                          pIrpSp->Parameters.SetFile.Length);
3170
3171         if( pPipeInfo == NULL)
3172         {
3173
3174             AFSDbgLogMsg( AFS_SUBSYSTEM_PIPE_PROCESSING,
3175                           AFS_TRACE_LEVEL_ERROR,
3176                           "AFSProcessShareSetInfo Failed to lock buffer on pipe %wZ\n",
3177                           &Ccb->DirectoryCB->NameInformation.FileName);
3178
3179             try_return( ntStatus = STATUS_INSUFFICIENT_RESOURCES);
3180         }
3181
3182         //
3183         // Send the request to the service
3184         //
3185
3186         ntStatus = AFSNotifySetPipeInfo( Ccb,
3187                                          (ULONG)ulFileInformationClass,
3188                                          pIrpSp->Parameters.SetFile.Length,
3189                                          pPipeInfo);
3190
3191         if( !NT_SUCCESS( ntStatus))
3192         {
3193
3194             AFSDbgLogMsg( AFS_SUBSYSTEM_PIPE_PROCESSING,
3195                           AFS_TRACE_LEVEL_ERROR,
3196                           "AFSProcessShareSetInfo Failed to send request to service on pipe %wZ Status %08lX\n",
3197                           &Ccb->DirectoryCB->NameInformation.FileName,
3198                           ntStatus);
3199
3200             try_return( ntStatus);
3201         }
3202
3203         AFSDbgLogMsg( AFS_SUBSYSTEM_PIPE_PROCESSING,
3204                       AFS_TRACE_LEVEL_VERBOSE,
3205                       "AFSProcessShareSetInfo Completed request on pipe %wZ Class %08lX\n",
3206                       &Ccb->DirectoryCB->NameInformation.FileName,
3207                       ulFileInformationClass);
3208
3209 try_exit:
3210
3211         NOTHING;
3212     }
3213
3214     return ntStatus;
3215 }
3216
3217 NTSTATUS
3218 AFSProcessShareQueryInfo( IN IRP *Irp,
3219                           IN AFSFcb *Fcb,
3220                           IN AFSCcb *Ccb)
3221 {
3222
3223     NTSTATUS ntStatus = STATUS_SUCCESS;
3224     PIO_STACK_LOCATION pIrpSp = IoGetCurrentIrpStackLocation( Irp);
3225     ULONG ulOutputBufferLen = 0, ulInputBufferLen;
3226     FILE_INFORMATION_CLASS ulFileInformationClass;
3227     void *pPipeInfo = NULL;
3228
3229     __Enter
3230     {
3231
3232         ulFileInformationClass = pIrpSp->Parameters.QueryFile.FileInformationClass;
3233
3234         AFSDbgLogMsg( AFS_SUBSYSTEM_PIPE_PROCESSING,
3235                       AFS_TRACE_LEVEL_VERBOSE,
3236                       "AFSProcessShareQueryInfo On pipe %wZ Class %08lX\n",
3237                       &Ccb->DirectoryCB->NameInformation.FileName,
3238                       ulFileInformationClass);
3239
3240         pPipeInfo = AFSLockSystemBuffer( Irp,
3241                                          pIrpSp->Parameters.QueryFile.Length);
3242
3243         if( pPipeInfo == NULL)
3244         {
3245
3246             AFSDbgLogMsg( AFS_SUBSYSTEM_PIPE_PROCESSING,
3247                           AFS_TRACE_LEVEL_ERROR,
3248                           "AFSProcessShareQueryInfo Failed to lock buffer on pipe %wZ\n",
3249                           &Ccb->DirectoryCB->NameInformation.FileName);
3250
3251             try_return( ntStatus = STATUS_INSUFFICIENT_RESOURCES);
3252         }
3253
3254         //
3255         // Send the request to the service
3256         //
3257
3258         ntStatus = AFSNotifyQueryPipeInfo( Ccb,
3259                                            (ULONG)ulFileInformationClass,
3260                                            pIrpSp->Parameters.QueryFile.Length,
3261                                            pPipeInfo,
3262                                            (ULONG *)&Irp->IoStatus.Information);
3263
3264         if( !NT_SUCCESS( ntStatus))
3265         {
3266
3267             AFSDbgLogMsg( AFS_SUBSYSTEM_PIPE_PROCESSING,