3 * Copyright (C) 2002, 2004 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 * COPYRIGHT: See COPYING in the top level directory
21 * PROJECT: ReactOS kernel
22 * FILE: drivers/filesystems/cdfs/dirctl.c
23 * PURPOSE: CDROM (ISO 9660) filesystem driver
24 * PROGRAMMER: Art Yerkes
29 /* INCLUDES *****************************************************************/
36 /* FUNCTIONS ****************************************************************/
38 #define ROUND_DOWN(N, S) (((N) / (S)) * (S))
39 #define ROUND_UP(N, S) ((((N) + (S) - 1) / (S)) * (S))
41 /* FUNCTIONS ****************************************************************/
44 * FUNCTION: Retrieves the file name, be it in short or long file name format
47 CdfsGetEntryName(PDEVICE_EXTENSION DeviceExt
,
50 PLARGE_INTEGER StreamOffset
,
57 PDIR_RECORD Record
= *Ptr
;
60 if (*CurrentOffset
>= DirLength
)
61 return(STATUS_NO_MORE_ENTRIES
);
63 if (*CurrentOffset
== 0)
66 Record
= (PDIR_RECORD
)*Block
;
67 while (Index
< *pIndex
)
69 (*Ptr
) = (PVOID
)((ULONG_PTR
)(*Ptr
) + Record
->RecordLength
);
70 (*CurrentOffset
) += Record
->RecordLength
;
72 if ((ULONG_PTR
)(*Ptr
) - (ULONG_PTR
)(*Block
) >= BLOCKSIZE
|| Record
->RecordLength
== 0)
74 DPRINT("Map next sector\n");
75 CcUnpinData(*Context
);
76 StreamOffset
->QuadPart
+= BLOCKSIZE
;
77 *CurrentOffset
= ROUND_UP(*CurrentOffset
, BLOCKSIZE
);
78 if (!CcMapData(DeviceExt
->StreamFileObject
,
83 DPRINT("CcMapData() failed\n");
84 return(STATUS_UNSUCCESSFUL
);
87 Record
= (PDIR_RECORD
)*Ptr
;
89 if (*CurrentOffset
>= DirLength
)
90 return(STATUS_NO_MORE_ENTRIES
);
96 if ((ULONG_PTR
)(*Ptr
) - (ULONG_PTR
)(*Block
) >= BLOCKSIZE
|| Record
->RecordLength
== 0)
98 DPRINT("Map next sector\n");
99 CcUnpinData(*Context
);
100 StreamOffset
->QuadPart
+= BLOCKSIZE
;
101 *CurrentOffset
= ROUND_UP(*CurrentOffset
, BLOCKSIZE
);
102 if (!CcMapData(DeviceExt
->StreamFileObject
,
107 DPRINT("CcMapData() failed\n");
108 return(STATUS_UNSUCCESSFUL
);
111 Record
= (PDIR_RECORD
)*Ptr
;
114 if (*CurrentOffset
>= DirLength
)
115 return STATUS_NO_MORE_ENTRIES
;
117 DPRINT("Index %lu RecordLength %lu Offset %lu\n",
118 *pIndex
, Record
->RecordLength
, *CurrentOffset
);
120 if (Record
->FileIdLength
== 1 && Record
->FileId
[0] == 0)
124 else if (Record
->FileIdLength
== 1 && Record
->FileId
[0] == 1)
130 if (DeviceExt
->CdInfo
.JolietLevel
== 0)
134 for (i
= 0; i
< Record
->FileIdLength
&& Record
->FileId
[i
] != ';'; i
++)
135 Name
[i
] = (WCHAR
)Record
->FileId
[i
];
140 CdfsSwapString(Name
, Record
->FileId
, Record
->FileIdLength
);
144 DPRINT("Name '%S'\n", Name
);
148 return(STATUS_SUCCESS
);
153 * FUNCTION: Find a file
156 CdfsFindFile(PDEVICE_EXTENSION DeviceExt
,
159 PUNICODE_STRING FileToFind
,
164 WCHAR ShortNameBuffer
[13];
165 UNICODE_STRING TempString
;
166 UNICODE_STRING ShortName
;
167 UNICODE_STRING LongName
;
168 UNICODE_STRING FileToFindUpcase
;
175 PVOID Context
= NULL
;
178 LARGE_INTEGER StreamOffset
, OffsetOfEntry
;
180 DPRINT("FindFile(Parent %p, FileToFind '%wZ', DirIndex: %u)\n",
181 Parent
, FileToFind
, pDirIndex
? *pDirIndex
: 0);
182 DPRINT("FindFile: old Pathname %p, old Objectname %p)\n",
183 Fcb
->PathName
, Fcb
->ObjectName
);
188 if (FileToFind
== NULL
|| FileToFind
->Length
== 0)
190 RtlInitUnicodeString(&TempString
, L
".");
191 FileToFind
= &TempString
;
196 if (Parent
->Entry
.ExtentLocationL
== DeviceExt
->CdInfo
.RootStart
)
208 StreamOffset
.QuadPart
= (LONGLONG
)DeviceExt
->CdInfo
.RootStart
* (LONGLONG
)BLOCKSIZE
;
209 DirSize
= DeviceExt
->CdInfo
.RootSize
;
212 if (FileToFind
->Buffer
[0] == 0 ||
213 (FileToFind
->Buffer
[0] == '\\' && FileToFind
->Buffer
[1] == 0) ||
214 (FileToFind
->Buffer
[0] == '.' && FileToFind
->Buffer
[1] == 0))
216 /* it's root : complete essentials fields then return ok */
217 RtlZeroMemory(Fcb
, sizeof(FCB
));
218 RtlInitEmptyUnicodeString(&Fcb
->PathName
, Fcb
->PathNameBuffer
, sizeof(Fcb
->PathNameBuffer
));
220 Fcb
->PathNameBuffer
[0] = '\\';
221 Fcb
->PathName
.Length
= sizeof(WCHAR
);
222 Fcb
->ObjectName
= &Fcb
->PathNameBuffer
[1];
223 Fcb
->Entry
.ExtentLocationL
= DeviceExt
->CdInfo
.RootStart
;
224 Fcb
->Entry
.DataLengthL
= DeviceExt
->CdInfo
.RootSize
;
225 Fcb
->Entry
.FileFlags
= 0x02; //FILE_ATTRIBUTE_DIRECTORY;
231 DPRINT("CdfsFindFile: new Pathname %wZ, new Objectname %S)\n",&Fcb
->PathName
, Fcb
->ObjectName
);
232 return STATUS_SUCCESS
;
237 StreamOffset
.QuadPart
= (LONGLONG
)Parent
->Entry
.ExtentLocationL
* (LONGLONG
)BLOCKSIZE
;
238 DirSize
= Parent
->Entry
.DataLengthL
;
241 DPRINT("StreamOffset %I64d DirSize %u\n", StreamOffset
.QuadPart
, DirSize
);
243 if (pDirIndex
&& (*pDirIndex
))
244 DirIndex
= *pDirIndex
;
246 if (pOffset
&& (*pOffset
))
249 StreamOffset
.QuadPart
+= ROUND_DOWN(Offset
, BLOCKSIZE
);
252 if (!CcMapData(DeviceExt
->StreamFileObject
, &StreamOffset
,
253 BLOCKSIZE
, TRUE
, &Context
, &Block
))
255 DPRINT("CcMapData() failed\n");
256 return STATUS_UNSUCCESSFUL
;
259 Record
= (PDIR_RECORD
) ((ULONG_PTR
)Block
+ Offset
% BLOCKSIZE
);
262 Offset
+= Record
->RecordLength
;
263 Record
= (PDIR_RECORD
)((ULONG_PTR
)Record
+ Record
->RecordLength
);
266 /* Upper case the expression for FsRtlIsNameInExpression */
267 Status
= RtlUpcaseUnicodeString(&FileToFindUpcase
, FileToFind
, TRUE
);
268 if (!NT_SUCCESS(Status
))
275 DPRINT("RecordLength %u ExtAttrRecordLength %u NameLength %u\n",
276 Record
->RecordLength
, Record
->ExtAttrRecordLength
, Record
->FileIdLength
);
278 Status
= CdfsGetEntryName
279 (DeviceExt
, &Context
, &Block
, &StreamOffset
,
280 DirSize
, (PVOID
*)&Record
, name
, &DirIndex
, &Offset
);
282 if (Status
== STATUS_NO_MORE_ENTRIES
)
286 else if (Status
== STATUS_UNSUCCESSFUL
)
288 /* Note: the directory cache has already been unpinned */
289 RtlFreeUnicodeString(&FileToFindUpcase
);
293 if (!CdfsIsRecordValid(DeviceExt
, Record
))
295 RtlFreeUnicodeString(&FileToFindUpcase
);
296 CcUnpinData(Context
);
297 return STATUS_DISK_CORRUPT_ERROR
;
300 DPRINT("Name '%S'\n", name
);
302 RtlInitUnicodeString(&LongName
, name
);
304 ShortName
.Length
= 0;
305 ShortName
.MaximumLength
= 26;
306 ShortName
.Buffer
= ShortNameBuffer
;
308 OffsetOfEntry
.QuadPart
= StreamOffset
.QuadPart
+ Offset
;
309 CdfsShortNameCacheGet(Parent
, &OffsetOfEntry
, &LongName
, &ShortName
);
311 DPRINT("ShortName '%wZ'\n", &ShortName
);
313 if (FsRtlIsNameInExpression(&FileToFindUpcase
, &LongName
, TRUE
, NULL
) ||
314 FsRtlIsNameInExpression(&FileToFindUpcase
, &ShortName
, TRUE
, NULL
))
316 if (Parent
->PathName
.Buffer
[0])
318 RtlCopyUnicodeString(&Fcb
->PathName
, &Parent
->PathName
);
319 len
= Parent
->PathName
.Length
/ sizeof(WCHAR
);
320 Fcb
->ObjectName
=&Fcb
->PathName
.Buffer
[len
];
321 if (len
!= 1 || Fcb
->PathName
.Buffer
[0] != '\\')
323 Fcb
->ObjectName
[0] = '\\';
324 Fcb
->ObjectName
= &Fcb
->ObjectName
[1];
329 Fcb
->ObjectName
=Fcb
->PathName
.Buffer
;
330 Fcb
->ObjectName
[0]='\\';
331 Fcb
->ObjectName
=&Fcb
->ObjectName
[1];
334 DPRINT("PathName '%wZ' ObjectName '%S'\n", &Fcb
->PathName
, Fcb
->ObjectName
);
336 memcpy(&Fcb
->Entry
, Record
, sizeof(DIR_RECORD
));
337 wcsncpy(Fcb
->ObjectName
, name
, min(wcslen(name
) + 1,
338 MAX_PATH
- (Fcb
->PathName
.Length
/ sizeof(WCHAR
)) + wcslen(Fcb
->ObjectName
)));
340 /* Copy short name */
341 Fcb
->ShortNameU
.Length
= ShortName
.Length
;
342 Fcb
->ShortNameU
.MaximumLength
= ShortName
.Length
;
343 Fcb
->ShortNameU
.Buffer
= Fcb
->ShortNameBuffer
;
344 memcpy(Fcb
->ShortNameBuffer
, ShortName
.Buffer
, ShortName
.Length
);
347 *pDirIndex
= DirIndex
;
351 DPRINT("FindFile: new Pathname %wZ, new Objectname %S, DirIndex %u\n",
352 &Fcb
->PathName
, Fcb
->ObjectName
, DirIndex
);
354 RtlFreeUnicodeString(&FileToFindUpcase
);
355 CcUnpinData(Context
);
357 return STATUS_SUCCESS
;
360 Offset
+= Record
->RecordLength
;
361 Record
= (PDIR_RECORD
)((ULONG_PTR
)Record
+ Record
->RecordLength
);
365 RtlFreeUnicodeString(&FileToFindUpcase
);
366 CcUnpinData(Context
);
369 *pDirIndex
= DirIndex
;
374 return STATUS_UNSUCCESSFUL
;
379 CdfsGetNameInformation(PFCB Fcb
,
380 PDEVICE_EXTENSION DeviceExt
,
381 PFILE_NAMES_INFORMATION Info
,
386 DPRINT("CdfsGetNameInformation() called\n");
388 UNREFERENCED_PARAMETER(DeviceExt
);
390 Length
= wcslen(Fcb
->ObjectName
) * sizeof(WCHAR
);
391 if ((sizeof(FILE_NAMES_INFORMATION
) + Length
) > BufferLength
)
392 return(STATUS_BUFFER_OVERFLOW
);
394 Info
->FileNameLength
= Length
;
395 Info
->NextEntryOffset
=
396 ROUND_UP(sizeof(FILE_NAMES_INFORMATION
) + Length
, sizeof(ULONG
));
397 RtlCopyMemory(Info
->FileName
, Fcb
->ObjectName
, Length
);
401 return(STATUS_SUCCESS
);
406 CdfsGetDirectoryInformation(PFCB Fcb
,
407 PDEVICE_EXTENSION DeviceExt
,
408 PFILE_DIRECTORY_INFORMATION Info
,
413 DPRINT("CdfsGetDirectoryInformation() called\n");
415 UNREFERENCED_PARAMETER(DeviceExt
);
417 Length
= wcslen(Fcb
->ObjectName
) * sizeof(WCHAR
);
418 if ((sizeof (FILE_DIRECTORY_INFORMATION
) + Length
) > BufferLength
)
419 return(STATUS_BUFFER_OVERFLOW
);
421 Info
->FileNameLength
= Length
;
422 Info
->NextEntryOffset
=
423 ROUND_UP(sizeof(FILE_DIRECTORY_INFORMATION
) + Length
, sizeof(ULONG
));
424 RtlCopyMemory(Info
->FileName
, Fcb
->ObjectName
, Length
);
426 /* Convert file times */
427 CdfsDateTimeToSystemTime(Fcb
,
428 &Info
->CreationTime
);
429 Info
->LastWriteTime
= Info
->CreationTime
;
430 Info
->ChangeTime
= Info
->CreationTime
;
432 /* Convert file flags */
433 CdfsFileFlagsToAttributes(Fcb
,
434 &Info
->FileAttributes
);
435 if (CdfsFCBIsDirectory(Fcb
))
437 Info
->EndOfFile
.QuadPart
= 0;
438 Info
->AllocationSize
.QuadPart
= 0;
442 Info
->EndOfFile
.QuadPart
= Fcb
->Entry
.DataLengthL
;
444 /* Make AllocSize a rounded up multiple of the sector size */
445 Info
->AllocationSize
.QuadPart
= ROUND_UP(Fcb
->Entry
.DataLengthL
, BLOCKSIZE
);
450 return(STATUS_SUCCESS
);
455 CdfsGetFullDirectoryInformation(PFCB Fcb
,
456 PDEVICE_EXTENSION DeviceExt
,
457 PFILE_FULL_DIR_INFORMATION Info
,
462 DPRINT("CdfsGetFullDirectoryInformation() called\n");
464 UNREFERENCED_PARAMETER(DeviceExt
);
466 Length
= wcslen(Fcb
->ObjectName
) * sizeof(WCHAR
);
467 if ((sizeof (FILE_FULL_DIR_INFORMATION
) + Length
) > BufferLength
)
468 return(STATUS_BUFFER_OVERFLOW
);
470 Info
->FileNameLength
= Length
;
471 Info
->NextEntryOffset
=
472 ROUND_UP(sizeof(FILE_FULL_DIR_INFORMATION
) + Length
, sizeof(ULONG
));
473 RtlCopyMemory(Info
->FileName
, Fcb
->ObjectName
, Length
);
475 /* Convert file times */
476 CdfsDateTimeToSystemTime(Fcb
,
477 &Info
->CreationTime
);
478 Info
->LastWriteTime
= Info
->CreationTime
;
479 Info
->ChangeTime
= Info
->CreationTime
;
481 /* Convert file flags */
482 CdfsFileFlagsToAttributes(Fcb
,
483 &Info
->FileAttributes
);
485 if (CdfsFCBIsDirectory(Fcb
))
487 Info
->EndOfFile
.QuadPart
= 0;
488 Info
->AllocationSize
.QuadPart
= 0;
492 Info
->EndOfFile
.QuadPart
= Fcb
->Entry
.DataLengthL
;
494 /* Make AllocSize a rounded up multiple of the sector size */
495 Info
->AllocationSize
.QuadPart
= ROUND_UP(Fcb
->Entry
.DataLengthL
, BLOCKSIZE
);
501 return(STATUS_SUCCESS
);
506 CdfsGetBothDirectoryInformation(PFCB Fcb
,
507 PDEVICE_EXTENSION DeviceExt
,
508 PFILE_BOTH_DIR_INFORMATION Info
,
513 DPRINT("CdfsGetBothDirectoryInformation() called\n");
515 UNREFERENCED_PARAMETER(DeviceExt
);
517 Length
= wcslen(Fcb
->ObjectName
) * sizeof(WCHAR
);
518 if ((sizeof (FILE_BOTH_DIR_INFORMATION
) + Length
) > BufferLength
)
519 return(STATUS_BUFFER_OVERFLOW
);
521 Info
->FileNameLength
= Length
;
522 Info
->NextEntryOffset
=
523 ROUND_UP(sizeof(FILE_BOTH_DIR_INFORMATION
) + Length
, sizeof(ULONG
));
524 RtlCopyMemory(Info
->FileName
, Fcb
->ObjectName
, Length
);
526 /* Convert file times */
527 CdfsDateTimeToSystemTime(Fcb
,
528 &Info
->CreationTime
);
529 Info
->LastWriteTime
= Info
->CreationTime
;
530 Info
->ChangeTime
= Info
->CreationTime
;
532 /* Convert file flags */
533 CdfsFileFlagsToAttributes(Fcb
,
534 &Info
->FileAttributes
);
536 if (CdfsFCBIsDirectory(Fcb
))
538 Info
->EndOfFile
.QuadPart
= 0;
539 Info
->AllocationSize
.QuadPart
= 0;
543 Info
->EndOfFile
.QuadPart
= Fcb
->Entry
.DataLengthL
;
545 /* Make AllocSize a rounded up multiple of the sector size */
546 Info
->AllocationSize
.QuadPart
= ROUND_UP(Fcb
->Entry
.DataLengthL
, BLOCKSIZE
);
552 /* Copy short name */
553 ASSERT(Fcb
->ShortNameU
.Length
/ sizeof(WCHAR
) <= 12);
554 Info
->ShortNameLength
= (CCHAR
)Fcb
->ShortNameU
.Length
;
555 RtlCopyMemory(Info
->ShortName
, Fcb
->ShortNameU
.Buffer
, Fcb
->ShortNameU
.Length
);
557 return(STATUS_SUCCESS
);
562 CdfsQueryDirectory(PDEVICE_OBJECT DeviceObject
,
565 PDEVICE_EXTENSION DeviceExtension
;
566 LONG BufferLength
= 0;
567 PUNICODE_STRING SearchPattern
= NULL
;
568 FILE_INFORMATION_CLASS FileInformationClass
;
570 PUCHAR Buffer
= NULL
;
571 PFILE_NAMES_INFORMATION Buffer0
= NULL
;
575 BOOLEAN First
= FALSE
;
576 PIO_STACK_LOCATION Stack
;
577 PFILE_OBJECT FileObject
;
578 NTSTATUS Status
= STATUS_SUCCESS
;
580 DPRINT("CdfsQueryDirectory() called\n");
582 DeviceExtension
= DeviceObject
->DeviceExtension
;
583 Stack
= IoGetCurrentIrpStackLocation(Irp
);
584 FileObject
= Stack
->FileObject
;
585 RtlInitEmptyUnicodeString(&TempFcb
.PathName
, TempFcb
.PathNameBuffer
, sizeof(TempFcb
.PathNameBuffer
));
587 Ccb
= (PCCB
)FileObject
->FsContext2
;
588 Fcb
= (PFCB
)FileObject
->FsContext
;
590 /* Obtain the callers parameters */
591 BufferLength
= Stack
->Parameters
.QueryDirectory
.Length
;
592 SearchPattern
= Stack
->Parameters
.QueryDirectory
.FileName
;
593 FileInformationClass
=
594 Stack
->Parameters
.QueryDirectory
.FileInformationClass
;
595 FileIndex
= Stack
->Parameters
.QueryDirectory
.FileIndex
;
597 /* Determine Buffer for result */
600 Buffer
= MmGetSystemAddressForMdl(Irp
->MdlAddress
);
604 Buffer
= Irp
->UserBuffer
;
607 /* Allocate search pattern in case:
608 * -> We don't have one already in context
609 * -> We have been given an input pattern
610 * -> The pattern length is not null
611 * -> The pattern buffer is not null
612 * Otherwise, we'll fall later and allocate a match all (*) pattern
614 if (SearchPattern
!= NULL
&&
615 SearchPattern
->Length
!= 0 && SearchPattern
->Buffer
!= NULL
)
617 if (Ccb
->DirectorySearchPattern
.Buffer
== NULL
)
620 Ccb
->DirectorySearchPattern
.Buffer
=
621 ExAllocatePoolWithTag(NonPagedPool
, SearchPattern
->Length
+ sizeof(WCHAR
), CDFS_SEARCH_PATTERN_TAG
);
622 if (Ccb
->DirectorySearchPattern
.Buffer
== NULL
)
624 return STATUS_INSUFFICIENT_RESOURCES
;
626 Ccb
->DirectorySearchPattern
.MaximumLength
= SearchPattern
->Length
+ sizeof(WCHAR
);
627 RtlCopyUnicodeString(&Ccb
->DirectorySearchPattern
, SearchPattern
);
628 Ccb
->DirectorySearchPattern
.Buffer
[SearchPattern
->Length
/ sizeof(WCHAR
)] = 0;
631 else if (Ccb
->DirectorySearchPattern
.Buffer
== NULL
)
634 Ccb
->DirectorySearchPattern
.Buffer
= ExAllocatePoolWithTag(NonPagedPool
, 2 * sizeof(WCHAR
), CDFS_SEARCH_PATTERN_TAG
);
635 if (Ccb
->DirectorySearchPattern
.Buffer
== NULL
)
637 return STATUS_INSUFFICIENT_RESOURCES
;
640 Ccb
->DirectorySearchPattern
.Length
= sizeof(WCHAR
);
641 Ccb
->DirectorySearchPattern
.MaximumLength
= 2 * sizeof(WCHAR
);
642 Ccb
->DirectorySearchPattern
.Buffer
[0] = L
'*';
643 Ccb
->DirectorySearchPattern
.Buffer
[1] = 0;
645 DPRINT("Search pattern '%wZ'\n", &Ccb
->DirectorySearchPattern
);
647 /* Determine directory index */
648 if (Stack
->Flags
& SL_INDEX_SPECIFIED
)
650 Ccb
->Entry
= Stack
->Parameters
.QueryDirectory
.FileIndex
;
651 Ccb
->Offset
= Ccb
->CurrentByteOffset
.u
.LowPart
;
653 else if (First
|| (Stack
->Flags
& SL_RESTART_SCAN
))
658 DPRINT("Buffer = %p tofind = %wZ\n", Buffer
, &Ccb
->DirectorySearchPattern
);
660 TempFcb
.ObjectName
= TempFcb
.PathName
.Buffer
;
661 while (Status
== STATUS_SUCCESS
&& BufferLength
> 0)
663 Status
= CdfsFindFile(DeviceExtension
,
666 &Ccb
->DirectorySearchPattern
,
669 DPRINT("Found %S, Status=%x, entry %x\n", TempFcb
.ObjectName
, Status
, Ccb
->Entry
);
671 if (NT_SUCCESS(Status
))
673 switch (FileInformationClass
)
675 case FileNameInformation
:
676 Status
= CdfsGetNameInformation(&TempFcb
,
678 (PFILE_NAMES_INFORMATION
)Buffer
,
682 case FileDirectoryInformation
:
683 Status
= CdfsGetDirectoryInformation(&TempFcb
,
685 (PFILE_DIRECTORY_INFORMATION
)Buffer
,
689 case FileFullDirectoryInformation
:
690 Status
= CdfsGetFullDirectoryInformation(&TempFcb
,
692 (PFILE_FULL_DIR_INFORMATION
)Buffer
,
696 case FileBothDirectoryInformation
:
697 Status
= CdfsGetBothDirectoryInformation(&TempFcb
,
699 (PFILE_BOTH_DIR_INFORMATION
)Buffer
,
704 Status
= STATUS_INVALID_INFO_CLASS
;
707 if (Status
== STATUS_BUFFER_OVERFLOW
)
711 Buffer0
->NextEntryOffset
= 0;
720 Buffer0
->NextEntryOffset
= 0;
725 Status
= STATUS_NO_SUCH_FILE
;
729 Status
= STATUS_NO_MORE_FILES
;
734 Buffer0
= (PFILE_NAMES_INFORMATION
)Buffer
;
735 Buffer0
->FileIndex
= FileIndex
++;
738 if (Stack
->Flags
& SL_RETURN_SINGLE_ENTRY
)
742 BufferLength
-= Buffer0
->NextEntryOffset
;
743 Buffer
+= Buffer0
->NextEntryOffset
;
748 Buffer0
->NextEntryOffset
= 0;
753 Status
= STATUS_SUCCESS
;
761 CdfsNotifyChangeDirectory(PDEVICE_OBJECT DeviceObject
,
763 PCDFS_IRP_CONTEXT IrpContext
)
765 PDEVICE_EXTENSION DeviceExtension
;
768 PIO_STACK_LOCATION Stack
;
769 PFILE_OBJECT FileObject
;
771 DPRINT("CdfsNotifyChangeDirectory() called\n");
773 DeviceExtension
= DeviceObject
->DeviceExtension
;
774 Stack
= IoGetCurrentIrpStackLocation(Irp
);
775 FileObject
= Stack
->FileObject
;
777 Ccb
= (PCCB
)FileObject
->FsContext2
;
778 Fcb
= (PFCB
)FileObject
->FsContext
;
780 FsRtlNotifyFullChangeDirectory(DeviceExtension
->NotifySync
,
781 &(DeviceExtension
->NotifyList
),
783 (PSTRING
)&(Fcb
->PathName
),
784 BooleanFlagOn(Stack
->Flags
, SL_WATCH_TREE
),
786 Stack
->Parameters
.NotifyDirectory
.CompletionFilter
,
791 /* We won't handle IRP completion */
792 IrpContext
->Flags
&= ~IRPCONTEXT_COMPLETE
;
794 return STATUS_PENDING
;
799 CdfsDirectoryControl(
800 PCDFS_IRP_CONTEXT IrpContext
)
803 PDEVICE_OBJECT DeviceObject
;
806 DPRINT("CdfsDirectoryControl() called\n");
810 Irp
= IrpContext
->Irp
;
811 DeviceObject
= IrpContext
->DeviceObject
;
813 switch (IrpContext
->MinorFunction
)
815 case IRP_MN_QUERY_DIRECTORY
:
816 Status
= CdfsQueryDirectory(DeviceObject
,
820 case IRP_MN_NOTIFY_CHANGE_DIRECTORY
:
821 Status
= CdfsNotifyChangeDirectory(DeviceObject
,
826 DPRINT1("CDFS: MinorFunction %u\n", IrpContext
->MinorFunction
);
827 Status
= STATUS_INVALID_DEVICE_REQUEST
;
831 if (Status
!= STATUS_PENDING
)
833 Irp
->IoStatus
.Information
= 0;