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: services/fs/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 DPRINT("Name '%S'\n", name
);
295 RtlInitUnicodeString(&LongName
, name
);
296 ShortName
.Length
= 0;
297 ShortName
.MaximumLength
= 26;
298 ShortName
.Buffer
= ShortNameBuffer
;
300 OffsetOfEntry
.QuadPart
= StreamOffset
.QuadPart
+ Offset
;
301 CdfsShortNameCacheGet(Parent
, &OffsetOfEntry
, &LongName
, &ShortName
);
303 DPRINT("ShortName '%wZ'\n", &ShortName
);
305 if (FsRtlIsNameInExpression(&FileToFindUpcase
, &LongName
, TRUE
, NULL
) ||
306 FsRtlIsNameInExpression(&FileToFindUpcase
, &ShortName
, TRUE
, NULL
))
308 if (Parent
->PathName
.Buffer
[0])
310 RtlCopyUnicodeString(&Fcb
->PathName
, &Parent
->PathName
);
311 len
= Parent
->PathName
.Length
/ sizeof(WCHAR
);
312 Fcb
->ObjectName
=&Fcb
->PathName
.Buffer
[len
];
313 if (len
!= 1 || Fcb
->PathName
.Buffer
[0] != '\\')
315 Fcb
->ObjectName
[0] = '\\';
316 Fcb
->ObjectName
= &Fcb
->ObjectName
[1];
321 Fcb
->ObjectName
=Fcb
->PathName
.Buffer
;
322 Fcb
->ObjectName
[0]='\\';
323 Fcb
->ObjectName
=&Fcb
->ObjectName
[1];
326 DPRINT("PathName '%wZ' ObjectName '%S'\n", &Fcb
->PathName
, Fcb
->ObjectName
);
328 memcpy(&Fcb
->Entry
, Record
, sizeof(DIR_RECORD
));
329 wcsncpy(Fcb
->ObjectName
, name
, min(wcslen(name
) + 1,
330 MAX_PATH
- (Fcb
->PathName
.Length
/ sizeof(WCHAR
)) + wcslen(Fcb
->ObjectName
)));
332 /* Copy short name */
333 Fcb
->ShortNameU
.Length
= ShortName
.Length
;
334 Fcb
->ShortNameU
.MaximumLength
= ShortName
.Length
;
335 Fcb
->ShortNameU
.Buffer
= Fcb
->ShortNameBuffer
;
336 memcpy(Fcb
->ShortNameBuffer
, ShortName
.Buffer
, ShortName
.Length
);
339 *pDirIndex
= DirIndex
;
343 DPRINT("FindFile: new Pathname %wZ, new Objectname %S, DirIndex %u\n",
344 &Fcb
->PathName
, Fcb
->ObjectName
, DirIndex
);
346 RtlFreeUnicodeString(&FileToFindUpcase
);
347 CcUnpinData(Context
);
349 return STATUS_SUCCESS
;
352 Offset
+= Record
->RecordLength
;
353 Record
= (PDIR_RECORD
)((ULONG_PTR
)Record
+ Record
->RecordLength
);
357 RtlFreeUnicodeString(&FileToFindUpcase
);
358 CcUnpinData(Context
);
361 *pDirIndex
= DirIndex
;
366 return STATUS_UNSUCCESSFUL
;
371 CdfsGetNameInformation(PFCB Fcb
,
372 PDEVICE_EXTENSION DeviceExt
,
373 PFILE_NAMES_INFORMATION Info
,
378 DPRINT("CdfsGetNameInformation() called\n");
380 UNREFERENCED_PARAMETER(DeviceExt
);
382 Length
= wcslen(Fcb
->ObjectName
) * sizeof(WCHAR
);
383 if ((sizeof(FILE_NAMES_INFORMATION
) + Length
) > BufferLength
)
384 return(STATUS_BUFFER_OVERFLOW
);
386 Info
->FileNameLength
= Length
;
387 Info
->NextEntryOffset
=
388 ROUND_UP(sizeof(FILE_NAMES_INFORMATION
) + Length
, sizeof(ULONG
));
389 RtlCopyMemory(Info
->FileName
, Fcb
->ObjectName
, Length
);
393 return(STATUS_SUCCESS
);
398 CdfsGetDirectoryInformation(PFCB Fcb
,
399 PDEVICE_EXTENSION DeviceExt
,
400 PFILE_DIRECTORY_INFORMATION Info
,
405 DPRINT("CdfsGetDirectoryInformation() called\n");
407 UNREFERENCED_PARAMETER(DeviceExt
);
409 Length
= wcslen(Fcb
->ObjectName
) * sizeof(WCHAR
);
410 if ((sizeof (FILE_DIRECTORY_INFORMATION
) + Length
) > BufferLength
)
411 return(STATUS_BUFFER_OVERFLOW
);
413 Info
->FileNameLength
= Length
;
414 Info
->NextEntryOffset
=
415 ROUND_UP(sizeof(FILE_DIRECTORY_INFORMATION
) + Length
, sizeof(ULONG
));
416 RtlCopyMemory(Info
->FileName
, Fcb
->ObjectName
, Length
);
418 /* Convert file times */
419 CdfsDateTimeToSystemTime(Fcb
,
420 &Info
->CreationTime
);
421 Info
->LastWriteTime
= Info
->CreationTime
;
422 Info
->ChangeTime
= Info
->CreationTime
;
424 /* Convert file flags */
425 CdfsFileFlagsToAttributes(Fcb
,
426 &Info
->FileAttributes
);
427 if (CdfsFCBIsDirectory(Fcb
))
429 Info
->EndOfFile
.QuadPart
= 0;
430 Info
->AllocationSize
.QuadPart
= 0;
434 Info
->EndOfFile
.QuadPart
= Fcb
->Entry
.DataLengthL
;
436 /* Make AllocSize a rounded up multiple of the sector size */
437 Info
->AllocationSize
.QuadPart
= ROUND_UP(Fcb
->Entry
.DataLengthL
, BLOCKSIZE
);
442 return(STATUS_SUCCESS
);
447 CdfsGetFullDirectoryInformation(PFCB Fcb
,
448 PDEVICE_EXTENSION DeviceExt
,
449 PFILE_FULL_DIR_INFORMATION Info
,
454 DPRINT("CdfsGetFullDirectoryInformation() called\n");
456 UNREFERENCED_PARAMETER(DeviceExt
);
458 Length
= wcslen(Fcb
->ObjectName
) * sizeof(WCHAR
);
459 if ((sizeof (FILE_FULL_DIR_INFORMATION
) + Length
) > BufferLength
)
460 return(STATUS_BUFFER_OVERFLOW
);
462 Info
->FileNameLength
= Length
;
463 Info
->NextEntryOffset
=
464 ROUND_UP(sizeof(FILE_FULL_DIR_INFORMATION
) + Length
, sizeof(ULONG
));
465 RtlCopyMemory(Info
->FileName
, Fcb
->ObjectName
, Length
);
467 /* Convert file times */
468 CdfsDateTimeToSystemTime(Fcb
,
469 &Info
->CreationTime
);
470 Info
->LastWriteTime
= Info
->CreationTime
;
471 Info
->ChangeTime
= Info
->CreationTime
;
473 /* Convert file flags */
474 CdfsFileFlagsToAttributes(Fcb
,
475 &Info
->FileAttributes
);
477 if (CdfsFCBIsDirectory(Fcb
))
479 Info
->EndOfFile
.QuadPart
= 0;
480 Info
->AllocationSize
.QuadPart
= 0;
484 Info
->EndOfFile
.QuadPart
= Fcb
->Entry
.DataLengthL
;
486 /* Make AllocSize a rounded up multiple of the sector size */
487 Info
->AllocationSize
.QuadPart
= ROUND_UP(Fcb
->Entry
.DataLengthL
, BLOCKSIZE
);
493 return(STATUS_SUCCESS
);
498 CdfsGetBothDirectoryInformation(PFCB Fcb
,
499 PDEVICE_EXTENSION DeviceExt
,
500 PFILE_BOTH_DIR_INFORMATION Info
,
505 DPRINT("CdfsGetBothDirectoryInformation() called\n");
507 UNREFERENCED_PARAMETER(DeviceExt
);
509 Length
= wcslen(Fcb
->ObjectName
) * sizeof(WCHAR
);
510 if ((sizeof (FILE_BOTH_DIR_INFORMATION
) + Length
) > BufferLength
)
511 return(STATUS_BUFFER_OVERFLOW
);
513 Info
->FileNameLength
= Length
;
514 Info
->NextEntryOffset
=
515 ROUND_UP(sizeof(FILE_BOTH_DIR_INFORMATION
) + Length
, sizeof(ULONG
));
516 RtlCopyMemory(Info
->FileName
, Fcb
->ObjectName
, Length
);
518 /* Convert file times */
519 CdfsDateTimeToSystemTime(Fcb
,
520 &Info
->CreationTime
);
521 Info
->LastWriteTime
= Info
->CreationTime
;
522 Info
->ChangeTime
= Info
->CreationTime
;
524 /* Convert file flags */
525 CdfsFileFlagsToAttributes(Fcb
,
526 &Info
->FileAttributes
);
528 if (CdfsFCBIsDirectory(Fcb
))
530 Info
->EndOfFile
.QuadPart
= 0;
531 Info
->AllocationSize
.QuadPart
= 0;
535 Info
->EndOfFile
.QuadPart
= Fcb
->Entry
.DataLengthL
;
537 /* Make AllocSize a rounded up multiple of the sector size */
538 Info
->AllocationSize
.QuadPart
= ROUND_UP(Fcb
->Entry
.DataLengthL
, BLOCKSIZE
);
544 /* Copy short name */
545 ASSERT(Fcb
->ShortNameU
.Length
/ sizeof(WCHAR
) <= 12);
546 Info
->ShortNameLength
= (CCHAR
)Fcb
->ShortNameU
.Length
;
547 RtlCopyMemory(Info
->ShortName
, Fcb
->ShortNameU
.Buffer
, Fcb
->ShortNameU
.Length
);
549 return(STATUS_SUCCESS
);
554 CdfsQueryDirectory(PDEVICE_OBJECT DeviceObject
,
557 PDEVICE_EXTENSION DeviceExtension
;
558 LONG BufferLength
= 0;
559 PUNICODE_STRING SearchPattern
= NULL
;
560 FILE_INFORMATION_CLASS FileInformationClass
;
562 PUCHAR Buffer
= NULL
;
563 PFILE_NAMES_INFORMATION Buffer0
= NULL
;
567 BOOLEAN First
= FALSE
;
568 PIO_STACK_LOCATION Stack
;
569 PFILE_OBJECT FileObject
;
570 NTSTATUS Status
= STATUS_SUCCESS
;
572 DPRINT("CdfsQueryDirectory() called\n");
574 DeviceExtension
= DeviceObject
->DeviceExtension
;
575 Stack
= IoGetCurrentIrpStackLocation(Irp
);
576 FileObject
= Stack
->FileObject
;
577 RtlInitEmptyUnicodeString(&TempFcb
.PathName
, TempFcb
.PathNameBuffer
, sizeof(TempFcb
.PathNameBuffer
));
579 Ccb
= (PCCB
)FileObject
->FsContext2
;
580 Fcb
= (PFCB
)FileObject
->FsContext
;
582 /* Obtain the callers parameters */
583 BufferLength
= Stack
->Parameters
.QueryDirectory
.Length
;
584 SearchPattern
= Stack
->Parameters
.QueryDirectory
.FileName
;
585 FileInformationClass
=
586 Stack
->Parameters
.QueryDirectory
.FileInformationClass
;
587 FileIndex
= Stack
->Parameters
.QueryDirectory
.FileIndex
;
589 /* Determine Buffer for result */
592 Buffer
= MmGetSystemAddressForMdl(Irp
->MdlAddress
);
596 Buffer
= Irp
->UserBuffer
;
599 /* Allocate search pattern in case:
600 * -> We don't have one already in context
601 * -> We have been given an input pattern
602 * -> The pattern length is not null
603 * -> The pattern buffer is not null
604 * Otherwise, we'll fall later and allocate a match all (*) pattern
606 if (SearchPattern
!= NULL
&&
607 SearchPattern
->Length
!= 0 && SearchPattern
->Buffer
!= NULL
)
609 if (Ccb
->DirectorySearchPattern
.Buffer
== NULL
)
612 Ccb
->DirectorySearchPattern
.Buffer
=
613 ExAllocatePoolWithTag(NonPagedPool
, SearchPattern
->Length
+ sizeof(WCHAR
), TAG_CCB
);
614 if (Ccb
->DirectorySearchPattern
.Buffer
== NULL
)
616 return STATUS_INSUFFICIENT_RESOURCES
;
618 Ccb
->DirectorySearchPattern
.MaximumLength
= SearchPattern
->Length
+ sizeof(WCHAR
);
619 RtlCopyUnicodeString(&Ccb
->DirectorySearchPattern
, SearchPattern
);
620 Ccb
->DirectorySearchPattern
.Buffer
[SearchPattern
->Length
/ sizeof(WCHAR
)] = 0;
623 else if (Ccb
->DirectorySearchPattern
.Buffer
== NULL
)
626 Ccb
->DirectorySearchPattern
.Buffer
= ExAllocatePoolWithTag(NonPagedPool
, 2 * sizeof(WCHAR
), TAG_CCB
);
627 if (Ccb
->DirectorySearchPattern
.Buffer
== NULL
)
629 return STATUS_INSUFFICIENT_RESOURCES
;
632 Ccb
->DirectorySearchPattern
.Length
= sizeof(WCHAR
);
633 Ccb
->DirectorySearchPattern
.MaximumLength
= 2 * sizeof(WCHAR
);
634 Ccb
->DirectorySearchPattern
.Buffer
[0] = L
'*';
635 Ccb
->DirectorySearchPattern
.Buffer
[1] = 0;
637 DPRINT("Search pattern '%wZ'\n", &Ccb
->DirectorySearchPattern
);
639 /* Determine directory index */
640 if (Stack
->Flags
& SL_INDEX_SPECIFIED
)
642 Ccb
->Entry
= Stack
->Parameters
.QueryDirectory
.FileIndex
;
643 Ccb
->Offset
= Ccb
->CurrentByteOffset
.u
.LowPart
;
645 else if (First
|| (Stack
->Flags
& SL_RESTART_SCAN
))
650 DPRINT("Buffer = %p tofind = %wZ\n", Buffer
, &Ccb
->DirectorySearchPattern
);
652 TempFcb
.ObjectName
= TempFcb
.PathName
.Buffer
;
653 while (Status
== STATUS_SUCCESS
&& BufferLength
> 0)
655 Status
= CdfsFindFile(DeviceExtension
,
658 &Ccb
->DirectorySearchPattern
,
661 DPRINT("Found %S, Status=%x, entry %x\n", TempFcb
.ObjectName
, Status
, Ccb
->Entry
);
663 if (NT_SUCCESS(Status
))
665 switch (FileInformationClass
)
667 case FileNameInformation
:
668 Status
= CdfsGetNameInformation(&TempFcb
,
670 (PFILE_NAMES_INFORMATION
)Buffer
,
674 case FileDirectoryInformation
:
675 Status
= CdfsGetDirectoryInformation(&TempFcb
,
677 (PFILE_DIRECTORY_INFORMATION
)Buffer
,
681 case FileFullDirectoryInformation
:
682 Status
= CdfsGetFullDirectoryInformation(&TempFcb
,
684 (PFILE_FULL_DIR_INFORMATION
)Buffer
,
688 case FileBothDirectoryInformation
:
689 Status
= CdfsGetBothDirectoryInformation(&TempFcb
,
691 (PFILE_BOTH_DIR_INFORMATION
)Buffer
,
696 Status
= STATUS_INVALID_INFO_CLASS
;
699 if (Status
== STATUS_BUFFER_OVERFLOW
)
703 Buffer0
->NextEntryOffset
= 0;
712 Buffer0
->NextEntryOffset
= 0;
717 Status
= STATUS_NO_SUCH_FILE
;
721 Status
= STATUS_NO_MORE_FILES
;
726 Buffer0
= (PFILE_NAMES_INFORMATION
)Buffer
;
727 Buffer0
->FileIndex
= FileIndex
++;
730 if (Stack
->Flags
& SL_RETURN_SINGLE_ENTRY
)
734 BufferLength
-= Buffer0
->NextEntryOffset
;
735 Buffer
+= Buffer0
->NextEntryOffset
;
740 Buffer0
->NextEntryOffset
= 0;
745 Status
= STATUS_SUCCESS
;
753 CdfsNotifyChangeDirectory(PDEVICE_OBJECT DeviceObject
,
756 PDEVICE_EXTENSION DeviceExtension
;
759 PIO_STACK_LOCATION Stack
;
760 PFILE_OBJECT FileObject
;
762 DPRINT("CdfsNotifyChangeDirectory() called\n");
764 DeviceExtension
= DeviceObject
->DeviceExtension
;
765 Stack
= IoGetCurrentIrpStackLocation(Irp
);
766 FileObject
= Stack
->FileObject
;
768 Ccb
= (PCCB
)FileObject
->FsContext2
;
769 Fcb
= (PFCB
)FileObject
->FsContext
;
771 FsRtlNotifyFullChangeDirectory(DeviceExtension
->NotifySync
,
772 &(DeviceExtension
->NotifyList
),
774 (PSTRING
)&(Fcb
->PathName
),
775 BooleanFlagOn(Stack
->Flags
, SL_WATCH_TREE
),
777 Stack
->Parameters
.NotifyDirectory
.CompletionFilter
,
782 return STATUS_PENDING
;
787 CdfsDirectoryControl(PDEVICE_OBJECT DeviceObject
,
790 PIO_STACK_LOCATION Stack
;
793 DPRINT("CdfsDirectoryControl() called\n");
794 FsRtlEnterFileSystem();
796 Stack
= IoGetCurrentIrpStackLocation(Irp
);
798 switch (Stack
->MinorFunction
)
800 case IRP_MN_QUERY_DIRECTORY
:
801 Status
= CdfsQueryDirectory(DeviceObject
,
805 case IRP_MN_NOTIFY_CHANGE_DIRECTORY
:
806 Status
= CdfsNotifyChangeDirectory(DeviceObject
,
811 DPRINT1("CDFS: MinorFunction %u\n", Stack
->MinorFunction
);
812 Status
= STATUS_INVALID_DEVICE_REQUEST
;
816 if (Status
!= STATUS_PENDING
)
818 Irp
->IoStatus
.Status
= Status
;
819 Irp
->IoStatus
.Information
= 0;
820 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
822 FsRtlExitFileSystem();