ReactOS 0.4.16-dev-297-gc569aee
fileinfo.c
Go to the documentation of this file.
1/*++
2
3Copyright (c) 1989-2000 Microsoft Corporation
4
5Module Name:
6
7 FileInfo.c
8
9Abstract:
10
11 This module implements the File Information routines for Cdfs called by
12 the Fsd/Fsp dispatch drivers.
13
14
15--*/
16
17#include "cdprocs.h"
18
19//
20// The Bug check file id for this module
21//
22
23#define BugCheckFileId (CDFS_BUG_CHECK_FILEINFO)
24
25//
26// Local support routines
27//
28
29VOID
31 _In_ PIRP_CONTEXT IrpContext,
35 );
36
37VOID
39 _In_ PIRP_CONTEXT IrpContext,
43 );
44
45VOID
47 _In_ PIRP_CONTEXT IrpContext,
51 );
52
53VOID
55 _In_ PIRP_CONTEXT IrpContext,
59 );
60
61VOID
63 _In_ PIRP_CONTEXT IrpContext,
67 );
68
71 _In_ PIRP_CONTEXT IrpContext,
75 );
76
77_Requires_lock_held_(_Global_critical_region_)
79CdQueryAlternateNameInfo (
80 _In_ PIRP_CONTEXT IrpContext,
85 );
86
87VOID
89 _In_ PIRP_CONTEXT IrpContext,
93 );
94
95#ifdef ALLOC_PRAGMA
96#pragma alloc_text(PAGE, CdCommonQueryInfo)
97#pragma alloc_text(PAGE, CdCommonSetInfo)
98#pragma alloc_text(PAGE, CdFastQueryBasicInfo)
99#pragma alloc_text(PAGE, CdFastQueryStdInfo)
100#pragma alloc_text(PAGE, CdFastQueryNetworkInfo)
101#pragma alloc_text(PAGE, CdQueryAlternateNameInfo)
102#pragma alloc_text(PAGE, CdQueryBasicInfo)
103#pragma alloc_text(PAGE, CdQueryEaInfo)
104#pragma alloc_text(PAGE, CdQueryInternalInfo)
105#pragma alloc_text(PAGE, CdQueryNameInfo)
106#pragma alloc_text(PAGE, CdQueryNetworkInfo)
107#pragma alloc_text(PAGE, CdQueryPositionInfo)
108#pragma alloc_text(PAGE, CdQueryStandardInfo)
109#endif
110
111
112_Requires_lock_held_(_Global_critical_region_)
114CdCommonQueryInfo (
115 _Inout_ PIRP_CONTEXT IrpContext,
117 )
118
119/*++
120
121Routine Description:
122
123 This is the common routine for query file information called by both the
124 fsd and fsp threads.
125
126Arguments:
127
128 Irp - Supplies the Irp to process.
129
130Return Value:
131
132 NTSTATUS - The return status for this operation.
133
134--*/
135
136{
139
143
145 PFCB Fcb;
146 PCCB Ccb;
147
148 BOOLEAN ReleaseFcb = FALSE;
149
150 PAGED_CODE();
151
152 //
153 // Reference our input parameters to make things easier
154 //
155
157 FileInformationClass = IrpSp->Parameters.QueryFile.FileInformationClass;
158 Buffer = Irp->AssociatedIrp.SystemBuffer;
159
160 //
161 // Decode the file object
162 //
163
164 TypeOfOpen = CdDecodeFileObject( IrpContext, IrpSp->FileObject, &Fcb, &Ccb );
165
166 //
167 // Use a try-finally to facilitate cleanup.
168 //
169
170 _SEH2_TRY {
171
172 //
173 // We only support query on file and directory handles.
174 //
175
176 switch (TypeOfOpen) {
177
178 case UserDirectoryOpen :
179 case UserFileOpen :
180
181 //
182 // Acquire shared access to this file. NOTE that this could be
183 // a recursive acquire, if we already preacquired in
184 // CdAcquireForCreateSection().
185 //
186
187 CdAcquireFileShared( IrpContext, Fcb );
188 ReleaseFcb = TRUE;
189
190 //
191 // Make sure we have the correct sizes for a directory.
192 //
193
195
198 }
199
200 //
201 // Make sure the Fcb is in a usable condition. This will raise
202 // an error condition if the volume is unusable
203 //
204
205 CdVerifyFcbOperation( IrpContext, Fcb );
206
207 //
208 // Based on the information class we'll do different
209 // actions. Each of hte procedures that we're calling fills
210 // up the output buffer, if possible. They will raise the
211 // status STATUS_BUFFER_OVERFLOW for an insufficient buffer.
212 // This is considered a somewhat unusual case and is handled
213 // more cleanly with the exception mechanism rather than
214 // testing a return status value for each call.
215 //
216
217 switch (FileInformationClass) {
218
220
221 //
222 // We don't allow this operation on a file opened by file Id.
223 //
224
226
228 break;
229 }
230
231 //
232 // In this case go ahead and call the individual routines to
233 // fill in the buffer. Only the name routine will
234 // pointer to the output buffer and then call the
235 // individual routines to fill in the buffer.
236 //
237
238 Length -= (sizeof( FILE_ACCESS_INFORMATION ) +
239 sizeof( FILE_MODE_INFORMATION ) +
241
242 CdQueryBasicInfo( IrpContext, Fcb, &Buffer->BasicInformation, &Length );
243 CdQueryStandardInfo( IrpContext, Fcb, &Buffer->StandardInformation, &Length );
244 CdQueryInternalInfo( IrpContext, Fcb, &Buffer->InternalInformation, &Length );
245 CdQueryEaInfo( IrpContext, Fcb, &Buffer->EaInformation, &Length );
246 CdQueryPositionInfo( IrpContext, IrpSp->FileObject, &Buffer->PositionInformation, &Length );
247 Status = CdQueryNameInfo( IrpContext, IrpSp->FileObject, &Buffer->NameInformation, &Length );
248
249 break;
250
252
254 break;
255
257
259 break;
260
262
264 break;
265
267
269 break;
270
272
274 break;
275
277
278 //
279 // We don't allow this operation on a file opened by file Id.
280 //
281
283
285
286 } else {
287
289 }
290
291 break;
292
294
296
297 Status = CdQueryAlternateNameInfo( IrpContext, Fcb, Ccb, (PFILE_NAME_INFORMATION) Buffer, &Length );
298
299 } else {
300
302 }
303
304 break;
305
307
309 break;
310
311 default :
312
314 }
315
316 break;
317
318 default :
319
321 }
322
323 //
324 // Set the information field to the number of bytes actually filled in
325 // and then complete the request
326 //
327
328 Irp->IoStatus.Information = IrpSp->Parameters.QueryFile.Length - Length;
329
330 } _SEH2_FINALLY {
331
332 //
333 // Release the file.
334 //
335
336 if (ReleaseFcb) {
337
338 CdReleaseFile( IrpContext, Fcb );
339 }
340 } _SEH2_END;
341
342 //
343 // Complete the request if we didn't raise.
344 //
345
346 CdCompleteRequest( IrpContext, Irp, Status );
347
348 return Status;
349}
350
351
352_Requires_lock_held_(_Global_critical_region_)
354CdCommonSetInfo (
355 _Inout_ PIRP_CONTEXT IrpContext,
357 )
358
359/*++
360
361Routine Description:
362
363 This is the common routine for set file information called by both the
364 fsd and fsp threads. We only support operations which set the file position.
365
366Arguments:
367
368 Irp - Supplies the Irp to process.
369
370Return Value:
371
372 NTSTATUS - The return status for this operation.
373
374--*/
375
376{
378
380 PFCB Fcb;
381 PCCB Ccb;
382
384
386
387 PAGED_CODE();
388
389 //
390 // Decode the file object
391 //
392
393 TypeOfOpen = CdDecodeFileObject( IrpContext, IrpSp->FileObject, &Fcb, &Ccb );
394
395 //
396 // We only support a SetPositionInformation on a user file.
397 //
398
399 if ((TypeOfOpen != UserFileOpen) ||
400 (IrpSp->Parameters.QueryFile.FileInformationClass != FilePositionInformation)) {
401
402 CdCompleteRequest( IrpContext, Irp, Status );
403 return Status;
404 }
405
406 //
407 // Acquire shared access to this file.
408 //
409
410 CdAcquireFileShared( IrpContext, Fcb );
411
412 _SEH2_TRY {
413
414 //
415 // Make sure the Fcb is in a usable condition. This
416 // will raise an error condition if the fcb is unusable
417 //
418
419 CdVerifyFcbOperation( IrpContext, Fcb );
420
421 Buffer = Irp->AssociatedIrp.SystemBuffer;
422
423 //
424 // Check if the file does not use intermediate buffering. If it
425 // does not use intermediate buffering then the new position we're
426 // supplied must be aligned properly for the device
427 //
428
430 ((Buffer->CurrentByteOffset.LowPart & Fcb->Vcb->BlockMask) != 0)) {
431
433 }
434
435 //
436 // The input parameter is fine so set the current byte offset and
437 // complete the request
438 //
439
440 //
441 // Lock the Fcb to provide synchronization.
442 //
443
444 CdLockFcb( IrpContext, Fcb );
445 IrpSp->FileObject->CurrentByteOffset = Buffer->CurrentByteOffset;
446 CdUnlockFcb( IrpContext, Fcb );
447
449
450 try_exit: NOTHING;
451 } _SEH2_FINALLY {
452
453 CdReleaseFile( IrpContext, Fcb );
454 } _SEH2_END;
455
456 //
457 // Complete the request if there was no raise.
458 //
459
460 CdCompleteRequest( IrpContext, Irp, Status );
461 return Status;
462}
463
464
465_Function_class_(FAST_IO_QUERY_BASIC_INFO)
467_Success_(return != FALSE)
469NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */
476 )
477
478/*++
479
480Routine Description:
481
482 This routine is for the fast query call for basic file information.
483
484Arguments:
485
486 FileObject - Supplies the file object used in this operation
487
488 Wait - Indicates if we are allowed to wait for the information
489
490 Buffer - Supplies the output buffer to receive the basic information
491
492 IoStatus - Receives the final status of the operation
493
494Return Value:
495
496 BOOLEAN - TRUE if the operation succeeded and FALSE if the caller
497 needs to take the long route.
498
499--*/
500
501{
504
505 PFCB Fcb;
506
507 PAGED_CODE();
508
510
512
514
515 //
516 // Decode the file object to find the type of open and the data
517 // structures.
518 //
519
521
522 //
523 // We only support this request on user file or directory objects.
524 //
525
526 if ((TypeOfOpen != UserFileOpen) &&
528
530 return FALSE;
531 }
532
533 //
534 // Acquire the file shared to access the Fcb.
535 //
536
537 if (!ExAcquireResourceSharedLite( Fcb->Resource, Wait )) {
538
540 return FALSE;
541 }
542
543 //
544 // Use a try-finally to facilitate cleanup.
545 //
546
547 _SEH2_TRY {
548
549 //
550 // Only deal with 'good' Fcb's.
551 //
552
553 if (CdVerifyFcbOperation( NULL, Fcb )) {
554
555 //
556 // Fill in the input buffer from the Fcb fields.
557 //
558
559 Buffer->CreationTime.QuadPart =
560 Buffer->LastWriteTime.QuadPart =
561 Buffer->ChangeTime.QuadPart = Fcb->CreationTime;
562
563 Buffer->LastAccessTime.QuadPart = 0;
564
565 Buffer->FileAttributes = Fcb->FileAttributes;
566
567 //
568 // Update the IoStatus block with the size of this data.
569 //
570
571 IoStatus->Status = STATUS_SUCCESS;
572 IoStatus->Information = sizeof( FILE_BASIC_INFORMATION );
573
574 Result = TRUE;
575 }
576
577 } _SEH2_FINALLY {
578
579 ExReleaseResourceLite( Fcb->Resource );
580
582 } _SEH2_END;
583
584 return Result;
585}
586
587
588_Function_class_(FAST_IO_QUERY_STANDARD_INFO)
590_Success_(return != FALSE)
592NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */
599 )
600
601/*++
602
603Routine Description:
604
605 This routine is for the fast query call for standard file information.
606
607Arguments:
608
609 FileObject - Supplies the file object used in this operation
610
611 Wait - Indicates if we are allowed to wait for the information
612
613 Buffer - Supplies the output buffer to receive the basic information
614
615 IoStatus - Receives the final status of the operation
616
617Return Value:
618
619 BOOLEAN - TRUE if the operation succeeded and FALSE if the caller
620 needs to take the long route.
621
622--*/
623
624{
627
628 PFCB Fcb;
629
630 PAGED_CODE();
631
633
635
637
638 //
639 // Decode the file object to find the type of open and the data
640 // structures.
641 //
642
644
645 //
646 // We only support this request on initialized user file or directory objects.
647 //
648
649 if ((TypeOfOpen != UserFileOpen) &&
651
653 return FALSE;
654 }
655
656 //
657 // Acquire the file shared to access the Fcb.
658 //
659
660 if (!ExAcquireResourceSharedLite( Fcb->Resource, Wait )) {
661
663 return FALSE;
664 }
665
666 //
667 // Use a try-finally to facilitate cleanup.
668 //
669
670 _SEH2_TRY {
671
672 //
673 // Only deal with 'good' Fcb's.
674 //
675
676 if (CdVerifyFcbOperation( NULL, Fcb )) {
677
678 //
679 // Check whether this is a directory.
680 //
681
683
684 Buffer->AllocationSize.QuadPart =
685 Buffer->EndOfFile.QuadPart = 0;
686
687 Buffer->Directory = TRUE;
688
689 } else {
690
691 Buffer->AllocationSize.QuadPart = Fcb->AllocationSize.QuadPart;
692 Buffer->EndOfFile.QuadPart = Fcb->FileSize.QuadPart;
693
694 Buffer->Directory = FALSE;
695 }
696
697 Buffer->NumberOfLinks = 1;
698 Buffer->DeletePending = FALSE;
699
700 //
701 // Update the IoStatus block with the size of this data.
702 //
703
704 IoStatus->Status = STATUS_SUCCESS;
705 IoStatus->Information = sizeof( FILE_STANDARD_INFORMATION );
706
707 Result = TRUE;
708 }
709
710 } _SEH2_FINALLY {
711
712 ExReleaseResourceLite( Fcb->Resource );
713
715 } _SEH2_END;
716
717 return Result;
718}
719
720
721_Function_class_(FAST_IO_QUERY_NETWORK_OPEN_INFO)
723_Success_(return != FALSE)
725NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */
732 )
733
734/*++
735
736Routine Description:
737
738 This routine is for the fast query call for network file information.
739
740Arguments:
741
742 FileObject - Supplies the file object used in this operation
743
744 Wait - Indicates if we are allowed to wait for the information
745
746 Buffer - Supplies the output buffer to receive the basic information
747
748 IoStatus - Receives the final status of the operation
749
750Return Value:
751
752 BOOLEAN - TRUE if the operation succeeded and FALSE if the caller
753 needs to take the long route.
754
755--*/
756
757{
760
761 PFCB Fcb;
762
763 PAGED_CODE();
764
766
768
770
771 //
772 // Decode the file object to find the type of open and the data
773 // structures.
774 //
775
777
778 //
779 // We only support this request on user file or directory objects.
780 //
781
782 if ((TypeOfOpen != UserFileOpen) &&
784
786 return FALSE;
787 }
788
789 //
790 // Acquire the file shared to access the Fcb.
791 //
792
793 if (!ExAcquireResourceSharedLite( Fcb->Resource, Wait )) {
794
796 return FALSE;
797 }
798
799 //
800 // Use a try-finally to facilitate cleanup.
801 //
802
803 _SEH2_TRY {
804
805 //
806 // Only deal with 'good' Fcb's.
807 //
808
809 if (CdVerifyFcbOperation( NULL, Fcb )) {
810
811 //
812 // Fill in the input buffer from the Fcb fields.
813 //
814
815 Buffer->CreationTime.QuadPart =
816 Buffer->LastWriteTime.QuadPart =
817 Buffer->ChangeTime.QuadPart = Fcb->CreationTime;
818
819 Buffer->LastAccessTime.QuadPart = 0;
820
821 Buffer->FileAttributes = Fcb->FileAttributes;
822
823 //
824 // Check whether this is a directory.
825 //
826
828
829 Buffer->AllocationSize.QuadPart =
830 Buffer->EndOfFile.QuadPart = 0;
831
832 } else {
833
834 Buffer->AllocationSize.QuadPart = Fcb->AllocationSize.QuadPart;
835 Buffer->EndOfFile.QuadPart = Fcb->FileSize.QuadPart;
836 }
837
838 //
839 // Update the IoStatus block with the size of this data.
840 //
841
842 IoStatus->Status = STATUS_SUCCESS;
843 IoStatus->Information = sizeof( FILE_NETWORK_OPEN_INFORMATION );
844
845 Result = TRUE;
846 }
847
848 } _SEH2_FINALLY {
849
850 ExReleaseResourceLite( Fcb->Resource );
851
853 } _SEH2_END;
854
855 return Result;
856}
857
858
859//
860// Local support routine
861//
862
863VOID
865 _In_ PIRP_CONTEXT IrpContext,
866 _In_ PFCB Fcb,
869 )
870
871/*++
872
873 Description:
874
875 This routine performs the query basic information function for Cdfs
876
877Arguments:
878
879 Fcb - Supplies the Fcb being queried, it has been verified
880
881 Buffer - Supplies a pointer to the buffer where the information is to
882 be returned
883
884 Length - Supplies the length of the buffer in bytes, and receives the
885 remaining bytes free in the buffer upon return.
886
887Return Value:
888
889 None
890
891--*/
892
893{
894 PAGED_CODE();
895
896 UNREFERENCED_PARAMETER( IrpContext );
897
898 //
899 // We only support creation, last modify and last write times on Cdfs.
900 //
901
903
904 Buffer->LastWriteTime.QuadPart =
905 Buffer->CreationTime.QuadPart =
906 Buffer->ChangeTime.QuadPart = Fcb->CreationTime;
907
908 Buffer->LastAccessTime.QuadPart = 0;
909
910 Buffer->FileAttributes = Fcb->FileAttributes;
911
912 //
913 // Update the length and status output variables
914 //
915
916 *Length -= sizeof( FILE_BASIC_INFORMATION );
917
918 return;
919}
920
921
922//
923// Local support routine
924//
925
926VOID
928 _In_ PIRP_CONTEXT IrpContext,
929 _In_ PFCB Fcb,
932 )
933/*++
934
935Routine Description:
936
937 This routine performs the query standard information function for cdfs.
938
939Arguments:
940
941 Fcb - Supplies the Fcb being queried, it has been verified
942
943 Buffer - Supplies a pointer to the buffer where the information is to
944 be returned
945
946 Length - Supplies the length of the buffer in bytes, and receives the
947 remaining bytes free in the buffer upon return.
948
949Return Value:
950
951 None
952
953--*/
954
955{
956 PAGED_CODE();
957
958 UNREFERENCED_PARAMETER( IrpContext );
959
960 //
961 // There is only one link and delete is never pending on a Cdrom file.
962 //
963
964 Buffer->NumberOfLinks = 1;
965 Buffer->DeletePending = FALSE;
966
967 //
968 // We get the sizes from the header. Return a size of zero
969 // for all directories.
970 //
971
973
974 Buffer->AllocationSize.QuadPart =
975 Buffer->EndOfFile.QuadPart = 0;
976
977 Buffer->Directory = TRUE;
978
979 } else {
980
981 Buffer->AllocationSize.QuadPart = Fcb->AllocationSize.QuadPart;
982 Buffer->EndOfFile.QuadPart = Fcb->FileSize.QuadPart;
983
984 Buffer->Directory = FALSE;
985 }
986
987 //
988 // Update the length and status output variables
989 //
990
991 *Length -= sizeof( FILE_STANDARD_INFORMATION );
992
993 return;
994}
995
996
997//
998// Local support routine
999//
1000
1001VOID
1003 _In_ PIRP_CONTEXT IrpContext,
1004 _In_ PFCB Fcb,
1007 )
1008
1009/*++
1010
1011Routine Description:
1012
1013 This routine performs the query internal information function for cdfs.
1014
1015Arguments:
1016
1017 Fcb - Supplies the Fcb being queried, it has been verified
1018
1019 Buffer - Supplies a pointer to the buffer where the information is to
1020 be returned
1021
1022 Length - Supplies the length of the buffer in bytes, and receives the
1023 remaining bytes free in the buffer upon return.
1024
1025Return Value:
1026
1027 None
1028
1029--*/
1030
1031{
1032 PAGED_CODE();
1033
1034 UNREFERENCED_PARAMETER( IrpContext );
1035
1036 //
1037 // Index number is the file Id number in the Fcb.
1038 //
1039
1040 Buffer->IndexNumber = Fcb->FileId;
1041 *Length -= sizeof( FILE_INTERNAL_INFORMATION );
1042
1043 return;
1044}
1045
1046
1047//
1048// Local support routine
1049//
1050
1051VOID
1053 _In_ PIRP_CONTEXT IrpContext,
1054 _In_ PFCB Fcb,
1057 )
1058
1059/*++
1060
1061Routine Description:
1062
1063 This routine performs the query Ea information function for cdfs.
1064
1065Arguments:
1066
1067 Fcb - Supplies the Fcb being queried, it has been verified
1068
1069 Buffer - Supplies a pointer to the buffer where the information is to
1070 be returned
1071
1072 Length - Supplies the length of the buffer in bytes, and receives the
1073 remaining bytes free in the buffer upon return.
1074
1075Return Value:
1076
1077 None
1078
1079--*/
1080
1081{
1082 PAGED_CODE();
1083
1084 UNREFERENCED_PARAMETER( IrpContext );
1086
1087 //
1088 // No Ea's on Cdfs volumes.
1089 //
1090
1091 Buffer->EaSize = 0;
1092 *Length -= sizeof( FILE_EA_INFORMATION );
1093
1094 return;
1095}
1096
1097
1098//
1099// Local support routine
1100//
1101
1102VOID
1104 _In_ PIRP_CONTEXT IrpContext,
1108 )
1109
1110/*++
1111
1112Routine Description:
1113
1114 This routine performs the query position information function for cdfs.
1115
1116Arguments:
1117
1118 FileObject - Supplies the File object being queried
1119
1120 Buffer - Supplies a pointer to the buffer where the information is to
1121 be returned
1122
1123 Length - Supplies the length of the buffer in bytes, and receives the
1124 remaining bytes free in the buffer upon return.
1125
1126Return Value:
1127
1128 None
1129
1130--*/
1131
1132{
1133 PAGED_CODE();
1134
1135 UNREFERENCED_PARAMETER( IrpContext );
1136
1137 //
1138 // Get the current position found in the file object.
1139 //
1140
1141 Buffer->CurrentByteOffset = FileObject->CurrentByteOffset;
1142
1143 //
1144 // Update the length and status output variables
1145 //
1146
1147 *Length -= sizeof( FILE_POSITION_INFORMATION );
1148
1149 return;
1150}
1151
1152
1153//
1154// Local support routine
1155//
1156
1159 _In_ PIRP_CONTEXT IrpContext,
1163 )
1164
1165/*++
1166
1167Routine Description:
1168
1169 This routine performs the query name information function for cdfs.
1170
1171Arguments:
1172
1173 FileObject - Supplies the file object containing the name.
1174
1175 Buffer - Supplies a pointer to the buffer where the information is to
1176 be returned
1177
1178 Length - Supplies the length of the buffer in bytes, and receives the
1179 remaining bytes free in the buffer upon return.
1180
1181Return Value:
1182
1183 NTSTATUS - STATUS_BUFFER_OVERFLOW if the entire name can't be copied.
1184
1185--*/
1186
1187{
1189 ULONG LengthToCopy;
1190
1191 PAGED_CODE();
1192
1193 UNREFERENCED_PARAMETER( IrpContext );
1194
1195 NT_ASSERT(*Length >= sizeof(ULONG));
1196
1197 //
1198 // Simply copy the name in the file object to the user's buffer.
1199 //
1200
1201 //
1202 // Place the size of the filename in the user's buffer and reduce the remaining
1203 // size to match.
1204 //
1205
1206 Buffer->FileNameLength = LengthToCopy = FileObject->FileName.Length;
1207 *Length -= sizeof(ULONG);
1208
1209 if (LengthToCopy > *Length) {
1210
1211 LengthToCopy = *Length;
1213 }
1214
1215 RtlCopyMemory( Buffer->FileName, FileObject->FileName.Buffer, LengthToCopy );
1216
1217 //
1218 // Reduce the available bytes by the amount stored into this buffer. In the overflow
1219 // case, this simply drops to zero. The returned filenamelength will indicate to the
1220 // caller how much space is required.
1221 //
1222
1223 *Length -= LengthToCopy;
1224
1225 return Status;
1226}
1227
1228
1229//
1230// Local support routine
1231//
1232
1233_Requires_lock_held_(_Global_critical_region_)
1235CdQueryAlternateNameInfo (
1236 _In_ PIRP_CONTEXT IrpContext,
1237 _In_ PFCB Fcb,
1238 _In_ PCCB Ccb,
1241 )
1242
1243/*++
1244
1245Routine Description:
1246
1247 This routine performs the query alternate name information function.
1248 We lookup the dirent for this file and then check if there is a
1249 short name.
1250
1251Arguments:
1252
1253 Fcb - Supplies the Fcb being queried, it has been verified.
1254
1255 Ccb - Ccb for this open handle.
1256
1257 Buffer - Supplies a pointer to the buffer where the information is to
1258 be returned.
1259
1260 Length - Supplies the length of the buffer in bytes, and receives the
1261 remaining bytes free in the buffer upon return.
1262
1263Return Value:
1264
1265 NTSTATUS - STATUS_SUCCESS if the whole name would fit into the user buffer,
1266 STATUS_OBJECT_NAME_NOT_FOUND if we can't return the name,
1267 STATUS_BUFFER_OVERFLOW otherwise.
1268
1269--*/
1270
1271{
1273
1275 DIRENT Dirent = {0};
1276
1277 PUNICODE_STRING NameToUse;
1279
1280 COMPOUND_PATH_ENTRY CompoundPathEntry = {{0}};/* ReactOS Change: GCC "missing braces around initializer" */
1282
1284 BOOLEAN ReleaseParentFcb = FALSE;
1285
1286 BOOLEAN CleanupFileLookup = FALSE;
1287 BOOLEAN CleanupDirectoryLookup = FALSE;
1288
1289 WCHAR ShortNameBuffer[ BYTE_COUNT_8_DOT_3 / 2 ];
1290 USHORT ShortNameLength;
1291
1292 PAGED_CODE();
1293
1294 //
1295 // Initialize the buffer length to zero.
1296 //
1297
1298 Buffer->FileNameLength = 0;
1299
1300 //
1301 // If this is the root or this file was opened using a version number then
1302 // there is no short name.
1303 //
1304
1305 if ((Fcb == Fcb->Vcb->RootIndexFcb) ||
1307
1309 }
1310
1311 //
1312 // Use a try-finally to cleanup the structures.
1313 //
1314
1315 _SEH2_TRY {
1316
1318 CdAcquireFileShared( IrpContext, ParentFcb );
1319 ReleaseParentFcb = TRUE;
1320
1322
1323 if (CdFidIsDirectory( Fcb->FileId)) {
1324
1325 //
1326 // Fcb is for a directory, so we need to dig the dirent from the parent. In
1327 // order to do this we need to get the name of the directory from its pathtable
1328 // entry and then search in the parent for a matching dirent.
1329 //
1330 // This could be optimized somewhat.
1331 //
1332
1334 CdInitializeFileContext( IrpContext, &FileContext );
1335
1336 CleanupDirectoryLookup = TRUE;
1337
1338 CdLookupPathEntry( IrpContext,
1340 Fcb->Ordinal,
1341 FALSE,
1343
1344 CdUpdatePathEntryName( IrpContext, &CompoundPathEntry.PathEntry, TRUE );
1345
1346 if (!CdFindDirectory( IrpContext,
1347 ParentFcb,
1348 &CompoundPathEntry.PathEntry.CdCaseDirName,
1349 TRUE,
1350 &FileContext )) {
1351
1352 //
1353 // If we failed to find the child directory by name in the parent
1354 // something is quite wrong with this disc.
1355 //
1356
1358 }
1359
1360 NameToUse = &FileContext.InitialDirent->Dirent.CdCaseFileName.FileName;
1361 DirentOffset = FileContext.InitialDirent->Dirent.DirentOffset;
1362
1363 } else {
1364
1365 //
1366 // Initialize the search dirent structures.
1367 //
1368
1369 CdInitializeDirContext( IrpContext, &DirContext );
1370 CdInitializeDirent( IrpContext, &Dirent );
1371
1372 CleanupFileLookup = TRUE;
1373
1374 CdLookupDirent( IrpContext,
1375 ParentFcb,
1377 &DirContext );
1378
1379 CdUpdateDirentFromRawDirent( IrpContext,
1380 ParentFcb,
1381 &DirContext,
1382 &Dirent );
1383
1384 //
1385 // Now update the dirent name.
1386 //
1387
1388 CdUpdateDirentName( IrpContext, &Dirent, TRUE );
1389
1390 NameToUse = &Dirent.CdCaseFileName.FileName;
1391 DirentOffset = Dirent.DirentOffset;
1392 }
1393
1394 //
1395 // If the name is 8.3 then fail this request.
1396 //
1397
1398 if (CdIs8dot3Name( IrpContext,
1399 *NameToUse )) {
1400
1401
1403 }
1404
1405 CdGenerate8dot3Name( IrpContext,
1406 NameToUse,
1408 ShortNameBuffer,
1409 &ShortNameLength );
1410
1411 //
1412 // We now have the short name. We have left it in Unicode form so copy it directly.
1413 //
1414
1415 Buffer->FileNameLength = ShortNameLength;
1416
1417 if (Buffer->FileNameLength + sizeof( ULONG ) > *Length) {
1418
1419 Buffer->FileNameLength = *Length - sizeof( ULONG );
1421 }
1422
1423 RtlCopyMemory( Buffer->FileName, ShortNameBuffer, Buffer->FileNameLength );
1424
1425 try_exit: NOTHING;
1426 } _SEH2_FINALLY {
1427
1428 if (CleanupFileLookup) {
1429
1430 CdCleanupDirContext( IrpContext, &DirContext );
1431 CdCleanupDirent( IrpContext, &Dirent );/* ReactOS Change: GCC "passing argument 1 from incompatible pointer type" */
1432
1433 } else if (CleanupDirectoryLookup) {
1434
1436 CdCleanupFileContext( IrpContext, &FileContext );
1437 }
1438
1439 if (ReleaseParentFcb) {
1440
1441 CdReleaseFile( IrpContext, ParentFcb );
1442 }
1443 } _SEH2_END;
1444
1445 //
1446 // Reduce the available bytes by the amount stored into this buffer.
1447 //
1448
1450
1451 *Length -= sizeof( ULONG ) + Buffer->FileNameLength;
1452 }
1453
1454 return Status;
1455}
1456
1457
1458//
1459// Local support routine
1460//
1461
1462VOID
1464 _In_ PIRP_CONTEXT IrpContext,
1465 _In_ PFCB Fcb,
1468 )
1469
1470/*++
1471
1472 Description:
1473
1474 This routine performs the query network open information function for Cdfs
1475
1476Arguments:
1477
1478 Fcb - Supplies the Fcb being queried, it has been verified
1479
1480 Buffer - Supplies a pointer to the buffer where the information is to
1481 be returned
1482
1483 Length - Supplies the length of the buffer in bytes, and receives the
1484 remaining bytes free in the buffer upon return.
1485
1486Return Value:
1487
1488 None
1489
1490--*/
1491
1492{
1493 PAGED_CODE();
1494
1495 UNREFERENCED_PARAMETER( IrpContext );
1496
1497 //
1498 // We only support creation, last modify and last write times on Cdfs.
1499 //
1500
1501 Buffer->LastWriteTime.QuadPart =
1502 Buffer->CreationTime.QuadPart =
1503 Buffer->ChangeTime.QuadPart = Fcb->CreationTime;
1504
1505 Buffer->LastAccessTime.QuadPart = 0;
1506
1507 Buffer->FileAttributes = Fcb->FileAttributes;
1508
1509 //
1510 // We get the sizes from the header. Return a size of zero
1511 // for all directories.
1512 //
1513
1515
1516 Buffer->AllocationSize.QuadPart =
1517 Buffer->EndOfFile.QuadPart = 0;
1518
1519 } else {
1520
1521 Buffer->AllocationSize.QuadPart = Fcb->AllocationSize.QuadPart;
1522 Buffer->EndOfFile.QuadPart = Fcb->FileSize.QuadPart;
1523 }
1524
1525 //
1526 // Update the length and status output variables
1527 //
1528
1530
1531 return;
1532}
1533
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
#define PAGED_CODE()
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
#define BYTE_COUNT_8_DOT_3
Definition: cd.h:362
VOID CdCompleteRequest(_Inout_opt_ PIRP_CONTEXT IrpContext, _Inout_opt_ PIRP Irp, _In_ NTSTATUS Status)
Definition: cddata.c:914
#define ASSERT_FILE_OBJECT(FO)
Definition: cddata.h:252
Dirent DirentOffset
Definition: dirsup.c:444
FAST_IO_QUERY_NETWORK_OPEN_INFO CdFastQueryNetworkInfo
Definition: cdprocs.h:1963
#define CdInitializeDirent(IC, D)
Definition: cdprocs.h:536
VOID CdUpdatePathEntryName(_In_ PIRP_CONTEXT IrpContext, _Inout_ PPATH_ENTRY PathEntry, _In_ BOOLEAN IgnoreCase)
Definition: pathsup.c:781
static INLINE VOID CdVerifyOrCreateDirStreamFile(_In_ PIRP_CONTEXT IrpContext, _In_ PFCB Fcb)
Definition: cdprocs.h:242
#define CdLockFcb(IC, F)
Definition: cdprocs.h:1044
_In_ PFCB ParentFcb
Definition: cdprocs.h:736
_In_ PFCB _In_ PDIRENT_ENUM_CONTEXT _Inout_ PDIRENT Dirent
Definition: cdprocs.h:427
#define CdInitializeCompoundPathEntry(IC, CP)
Definition: cdprocs.h:763
_Inout_ PFILE_OBJECT _In_ TYPE_OF_OPEN TypeOfOpen
Definition: cdprocs.h:589
FAST_IO_QUERY_STANDARD_INFO CdFastQueryStdInfo
Definition: cdprocs.h:1888
_In_ PFCB _In_ PCD_NAME _In_ BOOLEAN _Inout_ PCOMPOUND_PATH_ENTRY CompoundPathEntry
Definition: cdprocs.h:740
#define CdReleaseFile(IC, F)
Definition: cdprocs.h:1003
@ UserDirectoryOpen
Definition: cdprocs.h:576
@ UserFileOpen
Definition: cdprocs.h:577
TYPE_OF_OPEN CdFastDecodeFileObject(_In_ PFILE_OBJECT FileObject, _Out_ PFCB *Fcb)
Definition: filobsup.c:206
VOID CdUpdateDirentName(_In_ PIRP_CONTEXT IrpContext, _Inout_ PDIRENT Dirent, _In_ ULONG IgnoreCase)
Definition: dirsup.c:534
#define CdInitializeFileContext(IC, FC)
Definition: cdprocs.h:527
_In_ PFCB _In_ PCD_NAME _In_ BOOLEAN _Inout_ PFILE_ENUM_CONTEXT FileContext
Definition: cdprocs.h:442
BOOLEAN CdFindDirectory(_In_ PIRP_CONTEXT IrpContext, _In_ PFCB Fcb, _In_ PCD_NAME Name, _In_ BOOLEAN IgnoreCase, _Inout_ PFILE_ENUM_CONTEXT FileContext)
Definition: dirsup.c:997
#define CdCleanupDirContext(IC, DC)
Definition: cdprocs.h:548
FAST_IO_QUERY_BASIC_INFO CdFastQueryBasicInfo
Definition: cdprocs.h:1876
_In_ PFCB Fcb
Definition: cdprocs.h:159
VOID CdGenerate8dot3Name(_In_ PIRP_CONTEXT IrpContext, _In_ PUNICODE_STRING FileName, _In_ ULONG DirentOffset, _Out_writes_bytes_to_(BYTE_COUNT_8_DOT_3, *ShortByteCount) PWCHAR ShortFileName, _Out_ PUSHORT ShortByteCount)
Definition: namesup.c:550
#define CdCleanupCompoundPathEntry(IC, CP)
Definition: cdprocs.h:766
_Inout_ PFILE_OBJECT _In_ TYPE_OF_OPEN PFCB _In_opt_ PCCB Ccb
Definition: cdprocs.h:592
BOOLEAN CdVerifyFcbOperation(_In_opt_ PIRP_CONTEXT IrpContext, _In_ PFCB Fcb)
Definition: verfysup.c:615
VOID CdLookupDirent(_In_ PIRP_CONTEXT IrpContext, _In_ PFCB Fcb, _In_ ULONG DirentOffset, _Out_ PDIRENT_ENUM_CONTEXT DirContext)
Definition: dirsup.c:125
#define CdCleanupDirent(IC, D)
Definition: cdprocs.h:542
#define CdInitializeDirContext(IC, DC)
Definition: cdprocs.h:539
#define CdAcquireFileShared(IC, F)
Definition: cdprocs.h:997
enum _TYPE_OF_OPEN TYPE_OF_OPEN
#define try_return(S)
Definition: cdprocs.h:2179
_In_ PFCB _In_ PDIRENT_ENUM_CONTEXT DirContext
Definition: cdprocs.h:425
VOID CdLookupPathEntry(_In_ PIRP_CONTEXT IrpContext, _In_ ULONG PathEntryOffset, _In_ ULONG Ordinal, _In_ BOOLEAN VerifyBounds, _Inout_ PCOMPOUND_PATH_ENTRY CompoundPathEntry)
VOID CdCleanupFileContext(_In_ PIRP_CONTEXT IrpContext, _In_ PFILE_ENUM_CONTEXT FileContext)
Definition: dirsup.c:1636
BOOLEAN CdIs8dot3Name(_In_ PIRP_CONTEXT IrpContext, _In_ UNICODE_STRING FileName)
Definition: namesup.c:429
#define CdUnlockFcb(IC, F)
Definition: cdprocs.h:1060
#define CdRaiseStatus(IC, S)
Definition: cdprocs.h:1859
#define FCB_STATE_INITIALIZED
Definition: cdstruc.h:1042
#define CdFidIsDirectory(I)
Definition: cdstruc.h:1835
#define CCB_FLAG_OPEN_WITH_VERSION
Definition: cdstruc.h:1106
#define CdQueryFidDirentOffset(I)
Definition: cdstruc.h:1831
#define CCB_FLAG_OPEN_BY_ID
Definition: cdstruc.h:1103
#define CdQueryFidPathTableOffset(I)
Definition: cdstruc.h:1832
Definition: bufpool.h:45
#define _Requires_lock_held_(lock)
_In_ PIRP Irp
Definition: csq.h:116
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
VOID CdQueryInternalInfo(_In_ PIRP_CONTEXT IrpContext, _In_ PFCB Fcb, _Out_ PFILE_INTERNAL_INFORMATION Buffer, _Inout_ PULONG Length)
Definition: fileinfo.c:1002
VOID CdQueryPositionInfo(_In_ PIRP_CONTEXT IrpContext, _In_ PFILE_OBJECT FileObject, _Out_ PFILE_POSITION_INFORMATION Buffer, _Inout_ PULONG Length)
Definition: fileinfo.c:1103
VOID CdQueryBasicInfo(_In_ PIRP_CONTEXT IrpContext, _In_ PFCB Fcb, _Out_ PFILE_BASIC_INFORMATION Buffer, _Inout_ PULONG Length)
Definition: fileinfo.c:864
VOID CdQueryStandardInfo(_In_ PIRP_CONTEXT IrpContext, _In_ PFCB Fcb, _Out_ PFILE_STANDARD_INFORMATION Buffer, _Inout_ PULONG Length)
Definition: fileinfo.c:927
VOID CdQueryNetworkInfo(_In_ PIRP_CONTEXT IrpContext, _In_ PFCB Fcb, _Out_ PFILE_NETWORK_OPEN_INFORMATION Buffer, _Inout_ PULONG Length)
Definition: fileinfo.c:1463
VOID CdQueryEaInfo(_In_ PIRP_CONTEXT IrpContext, _In_ PFCB Fcb, _Out_ PFILE_EA_INFORMATION Buffer, _Inout_ PULONG Length)
Definition: fileinfo.c:1052
NTSTATUS CdQueryNameInfo(_In_ PIRP_CONTEXT IrpContext, _In_ PFILE_OBJECT FileObject, _Out_ PFILE_NAME_INFORMATION Buffer, _Inout_ PULONG Length)
Definition: fileinfo.c:1158
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
#define _IRQL_requires_same_
Definition: driverspecs.h:232
#define ExAcquireResourceSharedLite(res, wait)
Definition: env_spec_w32.h:621
#define FlagOn(_F, _SF)
Definition: ext2fs.h:179
@ FilePositionInformation
Definition: from_kernel.h:75
@ FileAllInformation
Definition: from_kernel.h:79
@ FileInternalInformation
Definition: from_kernel.h:67
@ FileEaInformation
Definition: from_kernel.h:68
@ FileAlternateNameInformation
Definition: from_kernel.h:82
@ FileNameInformation
Definition: from_kernel.h:70
@ FileNetworkOpenInformation
Definition: from_kernel.h:95
@ FileBasicInformation
Definition: from_kernel.h:65
struct _FILE_NETWORK_OPEN_INFORMATION FILE_NETWORK_OPEN_INFORMATION
enum _FILE_INFORMATION_CLASS FILE_INFORMATION_CLASS
Definition: directory.c:44
struct _FILE_INTERNAL_INFORMATION FILE_INTERNAL_INFORMATION
#define FsRtlEnterFileSystem
#define FsRtlExitFileSystem
Status
Definition: gdiplustypes.h:25
struct _FILE_EA_INFORMATION FILE_EA_INFORMATION
#define NOTHING
Definition: input_list.c:10
#define FILE_STANDARD_INFORMATION
Definition: disk.h:54
#define FILE_BASIC_INFORMATION
Definition: disk.h:53
static OUT PIO_STATUS_BLOCK OUT PVOID IN ULONG IN FILE_INFORMATION_CLASS FileInformationClass
Definition: pipe.c:75
__in UCHAR __in POWER_STATE __in_opt PVOID __in PIO_STATUS_BLOCK IoStatus
Definition: mxum.h:159
#define _Inout_
Definition: no_sal2.h:162
#define _Success_(c)
Definition: no_sal2.h:84
#define _Out_
Definition: no_sal2.h:160
#define _In_
Definition: no_sal2.h:158
#define _Function_class_(n)
Definition: no_sal2.h:398
struct _FILE_POSITION_INFORMATION FILE_POSITION_INFORMATION
struct _FILE_ALIGNMENT_INFORMATION FILE_ALIGNMENT_INFORMATION
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:325
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1822
unsigned short USHORT
Definition: pedump.c:61
struct _FILE_ACCESS_INFORMATION FILE_ACCESS_INFORMATION
#define FileStandardInformation
Definition: propsheet.cpp:61
#define _SEH2_FINALLY
Definition: pseh2_64.h:114
#define _SEH2_END
Definition: pseh2_64.h:155
#define _SEH2_TRY
Definition: pseh2_64.h:55
#define STATUS_SUCCESS
Definition: shellext.h:65
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
Definition: cdstruc.h:1067
Definition: cdstruc.h:1525
Definition: cdstruc.h:902
struct _FCB * ParentFcb
Definition: cdstruc.h:940
LONGLONG CreationTime
Definition: cdstruc.h:1030
ULONG Flags
Definition: ntfs.h:536
PVCB Vcb
Definition: cdstruc.h:933
ULONG FcbState
Definition: cdstruc.h:971
FILE_ID FileId
Definition: cdstruc.h:952
ULONG FileAttributes
Definition: cdstruc.h:977
PFILE_OBJECT FileObject
Definition: iotypes.h:3169
union _IO_STACK_LOCATION::@1579 Parameters
struct _IO_STACK_LOCATION::@3978::@3987 QueryFile
struct _FCB * RootIndexFcb
Definition: cdstruc.h:560
ULONG BlockMask
Definition: cdstruc.h:624
uint32_t * PULONG
Definition: typedefs.h:59
#define NTAPI
Definition: typedefs.h:36
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_DISK_CORRUPT_ERROR
Definition: udferr_usr.h:147
#define STATUS_OBJECT_NAME_NOT_FOUND
Definition: udferr_usr.h:149
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:550
_In_ WDFDPC _In_ BOOLEAN Wait
Definition: wdfdpc.h:170
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409
* PFILE_OBJECT
Definition: iotypes.h:1998
#define FO_NO_INTERMEDIATE_BUFFERING
Definition: iotypes.h:1778
#define NT_ASSERT
Definition: rtlfuncs.h:3327
__wchar_t WCHAR
Definition: xmlstorage.h:180