ReactOS 0.4.15-dev-7842-g558ab78
dir.c File Reference
#include "vfat.h"
#include <debug.h>
Include dependency graph for dir.c:

Go to the source code of this file.

Macros

#define NDEBUG
 
#define ULONG_ROUND_UP(x)   ROUND_UP((x), (sizeof(ULONG)))
 

Functions

BOOLEAN FsdDosDateTimeToSystemTime (PDEVICE_EXTENSION DeviceExt, USHORT DosDate, USHORT DosTime, PLARGE_INTEGER SystemTime)
 
BOOLEAN FsdSystemTimeToDosDateTime (PDEVICE_EXTENSION DeviceExt, PLARGE_INTEGER SystemTime, PUSHORT pDosDate, PUSHORT pDosTime)
 
static NTSTATUS VfatGetFileNamesInformation (PVFAT_DIRENTRY_CONTEXT DirContext, PFILE_NAMES_INFORMATION pInfo, ULONG BufferLength, PULONG Written, BOOLEAN First)
 
static NTSTATUS VfatGetFileDirectoryInformation (PVFAT_DIRENTRY_CONTEXT DirContext, PDEVICE_EXTENSION DeviceExt, PFILE_DIRECTORY_INFORMATION pInfo, ULONG BufferLength, PULONG Written, BOOLEAN First)
 
static NTSTATUS VfatGetFileFullDirectoryInformation (PVFAT_DIRENTRY_CONTEXT DirContext, PDEVICE_EXTENSION DeviceExt, PFILE_FULL_DIR_INFORMATION pInfo, ULONG BufferLength, PULONG Written, BOOLEAN First)
 
static NTSTATUS VfatGetFileBothInformation (PVFAT_DIRENTRY_CONTEXT DirContext, PDEVICE_EXTENSION DeviceExt, PFILE_BOTH_DIR_INFORMATION pInfo, ULONG BufferLength, PULONG Written, BOOLEAN First)
 
static NTSTATUS DoQuery (PVFAT_IRP_CONTEXT IrpContext)
 
NTSTATUS VfatNotifyChangeDirectory (PVFAT_IRP_CONTEXT IrpContext)
 
NTSTATUS VfatDirectoryControl (PVFAT_IRP_CONTEXT IrpContext)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 14 of file dir.c.

◆ ULONG_ROUND_UP

#define ULONG_ROUND_UP (   x)    ROUND_UP((x), (sizeof(ULONG)))

Definition at line 86 of file dir.c.

Function Documentation

◆ DoQuery()

static NTSTATUS DoQuery ( PVFAT_IRP_CONTEXT  IrpContext)
static

Definition at line 474 of file dir.c.

476{
478 LONG BufferLength = 0;
479 PUNICODE_STRING pSearchPattern = NULL;
483 PVFATFCB pFcb;
484 PVFATCCB pCcb;
485 BOOLEAN FirstQuery = FALSE;
486 BOOLEAN FirstCall = TRUE;
488 WCHAR LongNameBuffer[LONGNAME_MAX_LENGTH + 1];
489 WCHAR ShortNameBuffer[13];
490 ULONG Written;
491
492 PIO_STACK_LOCATION Stack = IrpContext->Stack;
493
494 pCcb = (PVFATCCB)IrpContext->FileObject->FsContext2;
495 pFcb = (PVFATFCB)IrpContext->FileObject->FsContext;
496
497 /* Determine Buffer for result : */
498 BufferLength = Stack->Parameters.QueryDirectory.Length;
499#if 0
500 /* Do not probe the user buffer until SEH is available */
501 if (IrpContext->Irp->RequestorMode != KernelMode &&
502 IrpContext->Irp->MdlAddress == NULL &&
503 IrpContext->Irp->UserBuffer != NULL)
504 {
505 ProbeForWrite(IrpContext->Irp->UserBuffer, BufferLength, 1);
506 }
507#endif
508 Buffer = VfatGetUserBuffer(IrpContext->Irp, FALSE);
509
512 {
514 if (NT_SUCCESS(Status))
516
517 return Status;
518 }
519
522 {
525 if (NT_SUCCESS(Status))
527
528 return Status;
529 }
530
531 /* Obtain the callers parameters */
532 pSearchPattern = (PUNICODE_STRING)Stack->Parameters.QueryDirectory.FileName;
533 FileInformationClass = Stack->Parameters.QueryDirectory.FileInformationClass;
534
535 /* Allocate search pattern in case:
536 * -> We don't have one already in context
537 * -> We have been given an input pattern
538 * -> The pattern length is not null
539 * -> The pattern buffer is not null
540 * Otherwise, we'll fall later and allocate a match all (*) pattern
541 */
542 if (pSearchPattern &&
543 pSearchPattern->Length != 0 && pSearchPattern->Buffer != NULL)
544 {
545 if (!pCcb->SearchPattern.Buffer)
546 {
547 FirstQuery = TRUE;
548 pCcb->SearchPattern.MaximumLength = pSearchPattern->Length + sizeof(WCHAR);
551 TAG_SEARCH);
552 if (!pCcb->SearchPattern.Buffer)
553 {
557 }
558 RtlCopyUnicodeString(&pCcb->SearchPattern, pSearchPattern);
559 pCcb->SearchPattern.Buffer[pCcb->SearchPattern.Length / sizeof(WCHAR)] = 0;
560 }
561 }
562 else if (!pCcb->SearchPattern.Buffer)
563 {
564 FirstQuery = TRUE;
565 pCcb->SearchPattern.MaximumLength = 2 * sizeof(WCHAR);
567 2 * sizeof(WCHAR),
568 TAG_SEARCH);
569 if (!pCcb->SearchPattern.Buffer)
570 {
574 }
575 pCcb->SearchPattern.Buffer[0] = L'*';
576 pCcb->SearchPattern.Buffer[1] = 0;
577 pCcb->SearchPattern.Length = sizeof(WCHAR);
578 }
579
580 if (BooleanFlagOn(IrpContext->Stack->Flags, SL_INDEX_SPECIFIED))
581 {
582 DirContext.DirIndex = pCcb->Entry = Stack->Parameters.QueryDirectory.FileIndex;
583 }
584 else if (FirstQuery || BooleanFlagOn(IrpContext->Stack->Flags, SL_RESTART_SCAN))
585 {
586 DirContext.DirIndex = pCcb->Entry = 0;
587 }
588 else
589 {
590 DirContext.DirIndex = pCcb->Entry;
591 }
592
593 DPRINT("Buffer=%p tofind=%wZ\n", Buffer, &pCcb->SearchPattern);
594
595 DirContext.DeviceExt = IrpContext->DeviceExt;
596 DirContext.LongNameU.Buffer = LongNameBuffer;
597 DirContext.LongNameU.MaximumLength = sizeof(LongNameBuffer);
598 DirContext.ShortNameU.Buffer = ShortNameBuffer;
599 DirContext.ShortNameU.MaximumLength = sizeof(ShortNameBuffer);
600
601 Written = 0;
602 while ((Status == STATUS_SUCCESS) && (BufferLength > 0))
603 {
604 Status = FindFile(IrpContext->DeviceExt,
605 pFcb,
606 &pCcb->SearchPattern,
607 &DirContext,
608 FirstCall);
609 pCcb->Entry = DirContext.DirIndex;
610
611 DPRINT("Found %wZ, Status=%x, entry %x\n", &DirContext.LongNameU, Status, pCcb->Entry);
612
613 FirstCall = FALSE;
614 if (NT_SUCCESS(Status))
615 {
616 switch (FileInformationClass)
617 {
620 IrpContext->DeviceExt,
623 &Written,
624 Buffer0 == NULL);
625 break;
626
629 IrpContext->DeviceExt,
632 &Written,
633 Buffer0 == NULL);
634 break;
635
638 IrpContext->DeviceExt,
641 &Written,
642 Buffer0 == NULL);
643 break;
644
649 &Written,
650 Buffer0 == NULL);
651 break;
652
653 default:
655 break;
656 }
657
659 break;
660 }
661 else
662 {
664 break;
665 }
666
668 Buffer0->FileIndex = DirContext.DirIndex;
669 pCcb->Entry = ++DirContext.DirIndex;
670 BufferLength -= Buffer0->NextEntryOffset;
671
673 break;
674
675 Buffer += Buffer0->NextEntryOffset;
676 }
677
678 if (Buffer0)
679 {
680 Buffer0->NextEntryOffset = 0;
682 IrpContext->Irp->IoStatus.Information = Stack->Parameters.QueryDirectory.Length - BufferLength;
683 }
684 else
685 {
687 ASSERT(Written <= Stack->Parameters.QueryDirectory.Length);
688 IrpContext->Irp->IoStatus.Information = Written;
689 }
690
693
694 return Status;
695}
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
_In_ PFCB _In_ PDIRENT_ENUM_CONTEXT DirContext
Definition: cdprocs.h:425
Definition: bufpool.h:45
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
@ FindFile
Definition: find.c:28
#define IRPCONTEXT_CANWAIT
Definition: ntfs.h:474
static NTSTATUS VfatGetFileBothInformation(PVFAT_DIRENTRY_CONTEXT DirContext, PDEVICE_EXTENSION DeviceExt, PFILE_BOTH_DIR_INFORMATION pInfo, ULONG BufferLength, PULONG Written, BOOLEAN First)
Definition: dir.c:347
static NTSTATUS VfatGetFileFullDirectoryInformation(PVFAT_DIRENTRY_CONTEXT DirContext, PDEVICE_EXTENSION DeviceExt, PFILE_FULL_DIR_INFORMATION pInfo, ULONG BufferLength, PULONG Written, BOOLEAN First)
Definition: dir.c:251
static NTSTATUS VfatGetFileNamesInformation(PVFAT_DIRENTRY_CONTEXT DirContext, PFILE_NAMES_INFORMATION pInfo, ULONG BufferLength, PULONG Written, BOOLEAN First)
Definition: dir.c:90
static NTSTATUS VfatGetFileDirectoryInformation(PVFAT_DIRENTRY_CONTEXT DirContext, PDEVICE_EXTENSION DeviceExt, PFILE_DIRECTORY_INFORMATION pInfo, ULONG BufferLength, PULONG Written, BOOLEAN First)
Definition: dir.c:134
NTSTATUS VfatLockUserBuffer(IN PIRP Irp, IN ULONG Length, IN LOCK_OPERATION Operation)
Definition: misc.c:460
PVOID VfatGetUserBuffer(IN PIRP Irp, IN BOOLEAN Paging)
Definition: misc.c:443
UNICODE_STRING * PUNICODE_STRING
Definition: env_spec_w32.h:373
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define ExAcquireResourceExclusiveLite(res, wait)
Definition: env_spec_w32.h:615
#define NonPagedPool
Definition: env_spec_w32.h:307
#define ExAcquireResourceSharedLite(res, wait)
Definition: env_spec_w32.h:621
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
#define BooleanFlagOn(F, SF)
Definition: ext2fs.h:183
@ FileDirectoryInformation
Definition: from_kernel.h:62
@ FileNamesInformation
Definition: from_kernel.h:73
@ FileFullDirectoryInformation
Definition: from_kernel.h:63
@ FileBothDirectoryInformation
Definition: from_kernel.h:64
enum _FILE_INFORMATION_CLASS FILE_INFORMATION_CLASS
Definition: directory.c:44
struct _FILE_NAMES_INFORMATION * PFILE_NAMES_INFORMATION
Status
Definition: gdiplustypes.h:25
if(dx< 0)
Definition: linetemp.h:194
#define ASSERT(a)
Definition: mode.c:44
static OUT PIO_STATUS_BLOCK OUT PVOID IN ULONG IN FILE_INFORMATION_CLASS FileInformationClass
Definition: pipe.c:75
#define KernelMode
Definition: asm.h:34
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1822
#define STATUS_PENDING
Definition: ntstatus.h:82
#define STATUS_INVALID_INFO_CLASS
Definition: ntstatus.h:240
#define L(x)
Definition: ntvdm.h:50
long LONG
Definition: pedump.c:60
#define STATUS_SUCCESS
Definition: shellext.h:65
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
#define DPRINT
Definition: sndvol32.h:71
ERESOURCE DirResource
Definition: ntfs.h:103
ULONG Flags
Definition: vfat.h:586
PDEVICE_EXTENSION DeviceExt
Definition: vfat.h:585
PIO_STACK_LOCATION Stack
Definition: vfat.h:588
PFILE_OBJECT FileObject
Definition: vfat.h:591
ULONG DirIndex
Definition: ntfs.h:533
IO_STATUS_BLOCK IoStatus
USHORT MaximumLength
Definition: env_spec_w32.h:370
Definition: vfat.h:537
ULONG Entry
Definition: vfat.h:541
UNICODE_STRING SearchPattern
Definition: vfat.h:543
Definition: vfat.h:448
ERESOURCE MainResource
Definition: vfat.h:452
unsigned char * PUCHAR
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_NO_SUCH_FILE
Definition: udferr_usr.h:137
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define STATUS_NO_MORE_FILES
Definition: udferr_usr.h:128
#define LONGNAME_MAX_LENGTH
Definition: vfat.h:203
struct _VFATCCB * PVFATCCB
#define TAG_SEARCH
Definition: vfat.h:554
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
Definition: wdfdevice.h:3771
_Must_inspect_result_ _In_ WDFQUEUE _In_opt_ WDFREQUEST _In_opt_ WDFFILEOBJECT _Inout_opt_ PWDF_REQUEST_PARAMETERS Parameters
Definition: wdfio.h:869
_In_ WDFREQUEST _In_ PIO_STACK_LOCATION Stack
Definition: wdfrequest.h:639
#define SL_INDEX_SPECIFIED
Definition: iotypes.h:1837
#define SL_RETURN_SINGLE_ENTRY
Definition: iotypes.h:1836
#define SL_RESTART_SCAN
Definition: iotypes.h:1835
@ IoWriteAccess
Definition: ketypes.h:864
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by VfatDirectoryControl().

◆ FsdDosDateTimeToSystemTime()

BOOLEAN FsdDosDateTimeToSystemTime ( PDEVICE_EXTENSION  DeviceExt,
USHORT  DosDate,
USHORT  DosTime,
PLARGE_INTEGER  SystemTime 
)

Definition at line 21 of file dir.c.

26{
27 PDOSTIME pdtime = (PDOSTIME)&DosTime;
28 PDOSDATE pddate = (PDOSDATE)&DosDate;
30 LARGE_INTEGER LocalTime;
31
32 if (SystemTime == NULL)
33 return FALSE;
34
36 TimeFields.Second = pdtime->Second * 2;
37 TimeFields.Minute = pdtime->Minute;
38 TimeFields.Hour = pdtime->Hour;
39
40 TimeFields.Day = pddate->Day;
41 TimeFields.Month = pddate->Month;
42 TimeFields.Year = (CSHORT)(DeviceExt->BaseDateYear + pddate->Year);
43
44 RtlTimeFieldsToTime(&TimeFields, &LocalTime);
45 ExLocalTimeToSystemTime(&LocalTime, SystemTime);
46
47 return TRUE;
48}
struct _DOSTIME * PDOSTIME
struct _DOSDATE * PDOSDATE
BOOLEAN RtlTimeFieldsToTime(IN PTIME_FIELDS TimeFields, IN PLARGE_INTEGER Time)
#define ExLocalTimeToSystemTime(LocTime, SysTime)
Definition: env_spec_w32.h:738
static PTIME_FIELDS TimeFields
Definition: time.c:104
WORD Month
Definition: cabinet.c:42
WORD Year
Definition: cabinet.c:43
WORD Day
Definition: cabinet.c:41
WORD Second
Definition: cabinet.c:34
WORD Minute
Definition: cabinet.c:35
WORD Hour
Definition: cabinet.c:36
USHORT Milliseconds
Definition: env_spec_w32.h:717
short CSHORT
Definition: umtypes.h:127

Referenced by FsdGetFsVolumeInformation(), VfatGetBasicInformation(), VfatGetFileBothInformation(), VfatGetFileDirectoryInformation(), VfatGetFileFullDirectoryInformation(), and VfatGetNetworkOpenInformation().

◆ FsdSystemTimeToDosDateTime()

BOOLEAN FsdSystemTimeToDosDateTime ( PDEVICE_EXTENSION  DeviceExt,
PLARGE_INTEGER  SystemTime,
PUSHORT  pDosDate,
PUSHORT  pDosTime 
)

Definition at line 52 of file dir.c.

57{
58 PDOSTIME pdtime = (PDOSTIME)pDosTime;
59 PDOSDATE pddate = (PDOSDATE)pDosDate;
61 LARGE_INTEGER LocalTime;
62
63 if (SystemTime == NULL)
64 return FALSE;
65
66 ExSystemTimeToLocalTime(SystemTime, &LocalTime);
67 RtlTimeToTimeFields(&LocalTime, &TimeFields);
68
69 if (pdtime)
70 {
71 pdtime->Second = TimeFields.Second / 2;
72 pdtime->Minute = TimeFields.Minute;
73 pdtime->Hour = TimeFields.Hour;
74 }
75
76 if (pddate)
77 {
78 pddate->Day = TimeFields.Day;
79 pddate->Month = TimeFields.Month;
80 pddate->Year = (USHORT) (TimeFields.Year - DeviceExt->BaseDateYear);
81 }
82
83 return TRUE;
84}
BOOLEAN RtlTimeToTimeFields(IN PLARGE_INTEGER Time, IN PTIME_FIELDS TimeFields)
#define ExSystemTimeToLocalTime(SysTime, LocTime)
Definition: env_spec_w32.h:729
unsigned short USHORT
Definition: pedump.c:61

Referenced by FATAddEntry(), FATXAddEntry(), VfatCreateFile(), VfatSetBasicInformation(), and VfatWrite().

◆ VfatDirectoryControl()

NTSTATUS VfatDirectoryControl ( PVFAT_IRP_CONTEXT  IrpContext)

Definition at line 727 of file dir.c.

729{
731
732 IrpContext->Irp->IoStatus.Information = 0;
733
734 switch (IrpContext->MinorFunction)
735 {
737 Status = DoQuery (IrpContext);
738 break;
739
741 Status = VfatNotifyChangeDirectory(IrpContext);
742 break;
743
744 default:
745 /* Error */
746 DPRINT("Unexpected minor function %x in VFAT driver\n",
747 IrpContext->MinorFunction);
749 break;
750 }
751
753 {
754 return VfatMarkIrpContextForQueue(IrpContext);
755 }
756
757 return Status;
758}
#define IRPCONTEXT_COMPLETE
Definition: ntfs.h:475
NTSTATUS VfatNotifyChangeDirectory(PVFAT_IRP_CONTEXT IrpContext)
Definition: dir.c:697
static NTSTATUS DoQuery(PVFAT_IRP_CONTEXT IrpContext)
Definition: dir.c:474
#define IRP_MN_QUERY_DIRECTORY
Definition: rdpdr.c:55
#define IRP_MN_NOTIFY_CHANGE_DIRECTORY
Definition: rdpdr.c:56
UCHAR MinorFunction
Definition: vfat.h:590
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
FORCEINLINE NTSTATUS VfatMarkIrpContextForQueue(PVFAT_IRP_CONTEXT IrpContext)
Definition: vfat.h:625

Referenced by VfatDispatchRequest().

◆ VfatGetFileBothInformation()

static NTSTATUS VfatGetFileBothInformation ( PVFAT_DIRENTRY_CONTEXT  DirContext,
PDEVICE_EXTENSION  DeviceExt,
PFILE_BOTH_DIR_INFORMATION  pInfo,
ULONG  BufferLength,
PULONG  Written,
BOOLEAN  First 
)
static

Definition at line 347 of file dir.c.

354{
356 ULONG BytesToCopy = 0;
357
358 *Written = 0;
360
362 return Status;
363
365 {
366 pInfo->FileNameLength = DirContext->LongNameU.Length;
367 pInfo->EaSize = 0;
368
370 pInfo->NextEntryOffset = 0;
372 {
374 RtlCopyMemory(pInfo->FileName,
375 DirContext->LongNameU.Buffer,
377 *Written += BytesToCopy;
378
379 if (BytesToCopy == DirContext->LongNameU.Length)
380 {
384 }
385 }
386
387 if (vfatVolumeIsFatX(DeviceExt))
388 {
389 pInfo->ShortName[0] = 0;
390 pInfo->ShortNameLength = 0;
391 /* pInfo->FileIndex = ; */
392
394 DirContext->DirEntry.FatX.CreationDate,
395 DirContext->DirEntry.FatX.CreationTime,
396 &pInfo->CreationTime);
398 DirContext->DirEntry.FatX.AccessDate,
399 DirContext->DirEntry.FatX.AccessTime,
400 &pInfo->LastAccessTime);
402 DirContext->DirEntry.FatX.UpdateDate,
403 DirContext->DirEntry.FatX.UpdateTime,
404 &pInfo->LastWriteTime);
405
406 pInfo->ChangeTime = pInfo->LastWriteTime;
407
408 if (BooleanFlagOn(DirContext->DirEntry.FatX.Attrib, FILE_ATTRIBUTE_DIRECTORY))
409 {
410 pInfo->EndOfFile.QuadPart = 0;
411 pInfo->AllocationSize.QuadPart = 0;
412 }
413 else
414 {
415 pInfo->EndOfFile.u.HighPart = 0;
416 pInfo->EndOfFile.u.LowPart = DirContext->DirEntry.FatX.FileSize;
417 /* Make allocsize a rounded up multiple of BytesPerCluster */
418 pInfo->AllocationSize.u.HighPart = 0;
419 pInfo->AllocationSize.u.LowPart = ROUND_UP(DirContext->DirEntry.FatX.FileSize,
420 DeviceExt->FatInfo.BytesPerCluster);
421 }
422
423 pInfo->FileAttributes = DirContext->DirEntry.FatX.Attrib & 0x3f;
424 }
425 else
426 {
427 pInfo->ShortNameLength = (CCHAR)DirContext->ShortNameU.Length;
428
429 ASSERT(pInfo->ShortNameLength / sizeof(WCHAR) <= 12);
431 DirContext->ShortNameU.Buffer,
432 DirContext->ShortNameU.Length);
433
434 /* pInfo->FileIndex = ; */
435
437 DirContext->DirEntry.Fat.CreationDate,
438 DirContext->DirEntry.Fat.CreationTime,
439 &pInfo->CreationTime);
441 DirContext->DirEntry.Fat.AccessDate,
442 0,
443 &pInfo->LastAccessTime);
445 DirContext->DirEntry.Fat.UpdateDate,
446 DirContext->DirEntry.Fat.UpdateTime,
447 &pInfo->LastWriteTime);
448
449 pInfo->ChangeTime = pInfo->LastWriteTime;
450
451 if (BooleanFlagOn(DirContext->DirEntry.Fat.Attrib, FILE_ATTRIBUTE_DIRECTORY))
452 {
453 pInfo->EndOfFile.QuadPart = 0;
454 pInfo->AllocationSize.QuadPart = 0;
455 }
456 else
457 {
458 pInfo->EndOfFile.u.HighPart = 0;
459 pInfo->EndOfFile.u.LowPart = DirContext->DirEntry.Fat.FileSize;
460 /* Make allocsize a rounded up multiple of BytesPerCluster */
461 pInfo->AllocationSize.u.HighPart = 0;
462 pInfo->AllocationSize.u.LowPart = ROUND_UP(DirContext->DirEntry.Fat.FileSize, DeviceExt->FatInfo.BytesPerCluster);
463 }
464
465 pInfo->FileAttributes = DirContext->DirEntry.Fat.Attrib & 0x3f;
466 }
467 }
468
469 return Status;
470}
WCHAR First[]
Definition: FormatMessage.c:11
#define ULONG_ROUND_UP(x)
Definition: dir.c:86
BOOLEAN FsdDosDateTimeToSystemTime(PDEVICE_EXTENSION DeviceExt, USHORT DosDate, USHORT DosTime, PLARGE_INTEGER SystemTime)
Definition: dir.c:21
#define ROUND_UP(n, align)
Definition: eventvwr.h:34
#define min(a, b)
Definition: monoChain.cc:55
_In_ UINT _In_ UINT BytesToCopy
Definition: ndis.h:3168
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
LONGLONG CreationTime
Definition: cdstruc.h:1030
LARGE_INTEGER CreationTime
Definition: from_kernel.h:141
LARGE_INTEGER AllocationSize
Definition: from_kernel.h:146
LARGE_INTEGER LastAccessTime
Definition: from_kernel.h:142
LARGE_INTEGER LastWriteTime
Definition: from_kernel.h:143
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
char CCHAR
Definition: typedefs.h:51
LONGLONG QuadPart
Definition: typedefs.h:114
struct _LARGE_INTEGER::@2290 u
FORCEINLINE BOOLEAN vfatVolumeIsFatX(PDEVICE_EXTENSION DeviceExt)
Definition: vfat.h:651

Referenced by DoQuery().

◆ VfatGetFileDirectoryInformation()

static NTSTATUS VfatGetFileDirectoryInformation ( PVFAT_DIRENTRY_CONTEXT  DirContext,
PDEVICE_EXTENSION  DeviceExt,
PFILE_DIRECTORY_INFORMATION  pInfo,
ULONG  BufferLength,
PULONG  Written,
BOOLEAN  First 
)
static

Definition at line 134 of file dir.c.

141{
143 ULONG BytesToCopy = 0;
144
145 *Written = 0;
147
149 return Status;
150
152 {
153 pInfo->FileNameLength = DirContext->LongNameU.Length;
154 /* pInfo->FileIndex = ; */
155
157 pInfo->NextEntryOffset = 0;
159 {
161 RtlCopyMemory(pInfo->FileName,
162 DirContext->LongNameU.Buffer,
164 *Written += BytesToCopy;
165
166 if (BytesToCopy == DirContext->LongNameU.Length)
167 {
171 }
172 }
173
174
175
176 if (vfatVolumeIsFatX(DeviceExt))
177 {
179 DirContext->DirEntry.FatX.CreationDate,
180 DirContext->DirEntry.FatX.CreationTime,
181 &pInfo->CreationTime);
183 DirContext->DirEntry.FatX.AccessDate,
184 DirContext->DirEntry.FatX.AccessTime,
185 &pInfo->LastAccessTime);
187 DirContext->DirEntry.FatX.UpdateDate,
188 DirContext->DirEntry.FatX.UpdateTime,
189 &pInfo->LastWriteTime);
190
191 pInfo->ChangeTime = pInfo->LastWriteTime;
192
193 if (BooleanFlagOn(DirContext->DirEntry.FatX.Attrib, FILE_ATTRIBUTE_DIRECTORY))
194 {
195 pInfo->EndOfFile.QuadPart = 0;
196 pInfo->AllocationSize.QuadPart = 0;
197 }
198 else
199 {
200 pInfo->EndOfFile.u.HighPart = 0;
201 pInfo->EndOfFile.u.LowPart = DirContext->DirEntry.FatX.FileSize;
202 /* Make allocsize a rounded up multiple of BytesPerCluster */
203 pInfo->AllocationSize.u.HighPart = 0;
204 pInfo->AllocationSize.u.LowPart = ROUND_UP(DirContext->DirEntry.FatX.FileSize,
205 DeviceExt->FatInfo.BytesPerCluster);
206 }
207
208 pInfo->FileAttributes = DirContext->DirEntry.FatX.Attrib & 0x3f;
209 }
210 else
211 {
213 DirContext->DirEntry.Fat.CreationDate,
214 DirContext->DirEntry.Fat.CreationTime,
215 &pInfo->CreationTime);
217 DirContext->DirEntry.Fat.AccessDate,
218 0,
219 &pInfo->LastAccessTime);
221 DirContext->DirEntry.Fat.UpdateDate,
222 DirContext->DirEntry.Fat.UpdateTime,
223 &pInfo->LastWriteTime);
224
225 pInfo->ChangeTime = pInfo->LastWriteTime;
226
227 if (BooleanFlagOn(DirContext->DirEntry.Fat.Attrib, FILE_ATTRIBUTE_DIRECTORY))
228 {
229 pInfo->EndOfFile.QuadPart = 0;
230 pInfo->AllocationSize.QuadPart = 0;
231 }
232 else
233 {
234 pInfo->EndOfFile.u.HighPart = 0;
235 pInfo->EndOfFile.u.LowPart = DirContext->DirEntry.Fat.FileSize;
236 /* Make allocsize a rounded up multiple of BytesPerCluster */
237 pInfo->AllocationSize.u.HighPart = 0;
238 pInfo->AllocationSize.u.LowPart = ROUND_UP(DirContext->DirEntry.Fat.FileSize,
239 DeviceExt->FatInfo.BytesPerCluster);
240 }
241
242 pInfo->FileAttributes = DirContext->DirEntry.Fat.Attrib & 0x3f;
243 }
244 }
245
246 return Status;
247}
WCHAR FileName[ANYSIZE_ARRAY]
Definition: winternl.h:524
LARGE_INTEGER ChangeTime
Definition: winternl.h:519
LARGE_INTEGER EndOfFile
Definition: winternl.h:520
LARGE_INTEGER CreationTime
Definition: winternl.h:516
LARGE_INTEGER LastWriteTime
Definition: winternl.h:518
LARGE_INTEGER LastAccessTime
Definition: winternl.h:517
LARGE_INTEGER AllocationSize
Definition: winternl.h:521

Referenced by DoQuery().

◆ VfatGetFileFullDirectoryInformation()

static NTSTATUS VfatGetFileFullDirectoryInformation ( PVFAT_DIRENTRY_CONTEXT  DirContext,
PDEVICE_EXTENSION  DeviceExt,
PFILE_FULL_DIR_INFORMATION  pInfo,
ULONG  BufferLength,
PULONG  Written,
BOOLEAN  First 
)
static

Definition at line 251 of file dir.c.

258{
260 ULONG BytesToCopy = 0;
261
262 *Written = 0;
264
266 return Status;
267
269 {
270 pInfo->FileNameLength = DirContext->LongNameU.Length;
271 /* pInfo->FileIndex = ; */
272 pInfo->EaSize = 0;
273
275 pInfo->NextEntryOffset = 0;
277 {
279 RtlCopyMemory(pInfo->FileName,
280 DirContext->LongNameU.Buffer,
282 *Written += BytesToCopy;
283
284 if (BytesToCopy == DirContext->LongNameU.Length)
285 {
289 }
290 }
291
292 if (vfatVolumeIsFatX(DeviceExt))
293 {
295 DirContext->DirEntry.FatX.CreationDate,
296 DirContext->DirEntry.FatX.CreationTime,
297 &pInfo->CreationTime);
299 DirContext->DirEntry.FatX.AccessDate,
300 DirContext->DirEntry.FatX.AccessTime,
301 &pInfo->LastAccessTime);
303 DirContext->DirEntry.FatX.UpdateDate,
304 DirContext->DirEntry.FatX.UpdateTime,
305 &pInfo->LastWriteTime);
306
307 pInfo->ChangeTime = pInfo->LastWriteTime;
308 pInfo->EndOfFile.u.HighPart = 0;
309 pInfo->EndOfFile.u.LowPart = DirContext->DirEntry.FatX.FileSize;
310 /* Make allocsize a rounded up multiple of BytesPerCluster */
311 pInfo->AllocationSize.u.HighPart = 0;
312 pInfo->AllocationSize.u.LowPart = ROUND_UP(DirContext->DirEntry.FatX.FileSize,
313 DeviceExt->FatInfo.BytesPerCluster);
314 pInfo->FileAttributes = DirContext->DirEntry.FatX.Attrib & 0x3f;
315 }
316 else
317 {
319 DirContext->DirEntry.Fat.CreationDate,
320 DirContext->DirEntry.Fat.CreationTime,
321 &pInfo->CreationTime);
323 DirContext->DirEntry.Fat.AccessDate,
324 0,
325 &pInfo->LastAccessTime);
327 DirContext->DirEntry.Fat.UpdateDate,
328 DirContext->DirEntry.Fat.UpdateTime,
329 &pInfo->LastWriteTime);
330
331 pInfo->ChangeTime = pInfo->LastWriteTime;
332 pInfo->EndOfFile.u.HighPart = 0;
333 pInfo->EndOfFile.u.LowPart = DirContext->DirEntry.Fat.FileSize;
334 /* Make allocsize a rounded up multiple of BytesPerCluster */
335 pInfo->AllocationSize.u.HighPart = 0;
336 pInfo->AllocationSize.u.LowPart = ROUND_UP(DirContext->DirEntry.Fat.FileSize,
337 DeviceExt->FatInfo.BytesPerCluster);
338 pInfo->FileAttributes = DirContext->DirEntry.Fat.Attrib & 0x3f;
339 }
340 }
341
342 return Status;
343}
WCHAR FileName[ANYSIZE_ARRAY]
Definition: winternl.h:539

Referenced by DoQuery().

◆ VfatGetFileNamesInformation()

static NTSTATUS VfatGetFileNamesInformation ( PVFAT_DIRENTRY_CONTEXT  DirContext,
PFILE_NAMES_INFORMATION  pInfo,
ULONG  BufferLength,
PULONG  Written,
BOOLEAN  First 
)
static

Definition at line 90 of file dir.c.

96{
99
100 *Written = 0;
102
104 return Status;
105
107 {
108 pInfo->FileNameLength = DirContext->LongNameU.Length;
109
111 pInfo->NextEntryOffset = 0;
113 {
115 RtlCopyMemory(pInfo->FileName,
116 DirContext->LongNameU.Buffer,
118 *Written += BytesToCopy;
119
120 if (BytesToCopy == DirContext->LongNameU.Length)
121 {
125 }
126 }
127 }
128
129 return Status;
130}

Referenced by DoQuery().

◆ VfatNotifyChangeDirectory()

NTSTATUS VfatNotifyChangeDirectory ( PVFAT_IRP_CONTEXT  IrpContext)

Definition at line 697 of file dir.c.

698{
699 PVCB pVcb;
700 PVFATFCB pFcb;
702 Stack = IrpContext->Stack;
703 pVcb = IrpContext->DeviceExt;
704 pFcb = (PVFATFCB) IrpContext->FileObject->FsContext;
705
707 &(pVcb->NotifyList),
708 IrpContext->FileObject->FsContext2,
709 (PSTRING)&(pFcb->PathNameU),
711 FALSE,
712 Stack->Parameters.NotifyDirectory.CompletionFilter,
713 IrpContext->Irp,
714 NULL,
715 NULL);
716
717 /* We won't handle IRP completion */
718 IrpContext->Flags &= ~IRPCONTEXT_COMPLETE;
719
720 return STATUS_PENDING;
721}
VOID NTAPI FsRtlNotifyFullChangeDirectory(IN PNOTIFY_SYNC NotifySync, IN PLIST_ENTRY NotifyList, IN PVOID FsContext, IN PSTRING FullDirectoryName, IN BOOLEAN WatchTree, IN BOOLEAN IgnoreBuffer, IN ULONG CompletionFilter, IN PIRP NotifyIrp, IN PCHECK_FOR_TRAVERSE_ACCESS TraverseCallback OPTIONAL, IN PSECURITY_SUBJECT_CONTEXT SubjectContext OPTIONAL)
Definition: notify.c:1487
Definition: cdstruc.h:498
PNOTIFY_SYNC NotifySync
Definition: cdstruc.h:607
UNICODE_STRING PathNameU
Definition: vfat.h:472
struct _STRING * PSTRING
struct _VFATFCB * PVFATFCB
#define SL_WATCH_TREE
Definition: iotypes.h:1839

Referenced by VfatDirectoryControl().