mirror of
https://github.com/reactos/reactos.git
synced 2025-01-04 05:20:54 +00:00
[FORMATTING]
* No code changes. svn path=/trunk/; revision=57246
This commit is contained in:
parent
93c87d7be9
commit
5423c59abe
1 changed files with 509 additions and 411 deletions
|
@ -8,16 +8,22 @@
|
|||
|
||||
*/
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#define NDEBUG
|
||||
#include "vfat.h"
|
||||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
// function like DosDateTimeToFileTime
|
||||
/* Function like DosDateTimeToFileTime */
|
||||
BOOLEAN
|
||||
FsdDosDateTimeToSystemTime (PDEVICE_EXTENSION DeviceExt, USHORT DosDate, USHORT DosTime, PLARGE_INTEGER SystemTime)
|
||||
FsdDosDateTimeToSystemTime(PDEVICE_EXTENSION DeviceExt,
|
||||
USHORT DosDate,
|
||||
USHORT DosTime,
|
||||
PLARGE_INTEGER SystemTime)
|
||||
{
|
||||
PDOSTIME pdtime = (PDOSTIME) &DosTime;
|
||||
PDOSDATE pddate = (PDOSDATE) &DosDate;
|
||||
PDOSTIME pdtime = (PDOSTIME)&DosTime;
|
||||
PDOSDATE pddate = (PDOSDATE)&DosDate;
|
||||
TIME_FIELDS TimeFields;
|
||||
LARGE_INTEGER LocalTime;
|
||||
|
||||
|
@ -33,26 +39,29 @@ FsdDosDateTimeToSystemTime (PDEVICE_EXTENSION DeviceExt, USHORT DosDate, USHORT
|
|||
TimeFields.Month = pddate->Month;
|
||||
TimeFields.Year = (CSHORT)(DeviceExt->BaseDateYear + pddate->Year);
|
||||
|
||||
RtlTimeFieldsToTime (&TimeFields, &LocalTime);
|
||||
RtlTimeFieldsToTime(&TimeFields, &LocalTime);
|
||||
ExLocalTimeToSystemTime(&LocalTime, SystemTime);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// function like FileTimeToDosDateTime
|
||||
/* Function like FileTimeToDosDateTime */
|
||||
BOOLEAN
|
||||
FsdSystemTimeToDosDateTime (PDEVICE_EXTENSION DeviceExt, PLARGE_INTEGER SystemTime, USHORT *pDosDate, USHORT *pDosTime)
|
||||
FsdSystemTimeToDosDateTime(PDEVICE_EXTENSION DeviceExt,
|
||||
PLARGE_INTEGER SystemTime,
|
||||
PUSHORT pDosDate,
|
||||
PUSHORT pDosTime)
|
||||
{
|
||||
PDOSTIME pdtime = (PDOSTIME) pDosTime;
|
||||
PDOSDATE pddate = (PDOSDATE) pDosDate;
|
||||
PDOSTIME pdtime = (PDOSTIME)pDosTime;
|
||||
PDOSDATE pddate = (PDOSDATE)pDosDate;
|
||||
TIME_FIELDS TimeFields;
|
||||
LARGE_INTEGER LocalTime;
|
||||
|
||||
if (SystemTime == NULL)
|
||||
return FALSE;
|
||||
|
||||
ExSystemTimeToLocalTime (SystemTime, &LocalTime);
|
||||
RtlTimeToTimeFields (&LocalTime, &TimeFields);
|
||||
ExSystemTimeToLocalTime(SystemTime, &LocalTime);
|
||||
RtlTimeToTimeFields(&LocalTime, &TimeFields);
|
||||
|
||||
if (pdtime)
|
||||
{
|
||||
|
@ -74,43 +83,59 @@ FsdSystemTimeToDosDateTime (PDEVICE_EXTENSION DeviceExt, PLARGE_INTEGER SystemTi
|
|||
#define ULONG_ROUND_UP(x) ROUND_UP((x), (sizeof(ULONG)))
|
||||
|
||||
static NTSTATUS
|
||||
VfatGetFileNameInformation (PVFAT_DIRENTRY_CONTEXT DirContext,
|
||||
PFILE_NAMES_INFORMATION pInfo, ULONG BufferLength)
|
||||
VfatGetFileNameInformation(PVFAT_DIRENTRY_CONTEXT DirContext,
|
||||
PFILE_NAMES_INFORMATION pInfo,
|
||||
ULONG BufferLength)
|
||||
{
|
||||
if ((sizeof (FILE_DIRECTORY_INFORMATION) + DirContext->LongNameU.Length) > BufferLength)
|
||||
if ((sizeof(FILE_DIRECTORY_INFORMATION) + DirContext->LongNameU.Length) > BufferLength)
|
||||
return STATUS_BUFFER_OVERFLOW;
|
||||
|
||||
pInfo->FileNameLength = DirContext->LongNameU.Length;
|
||||
pInfo->NextEntryOffset =
|
||||
ULONG_ROUND_UP (sizeof (FILE_DIRECTORY_INFORMATION) + DirContext->LongNameU.Length);
|
||||
RtlCopyMemory (pInfo->FileName, DirContext->LongNameU.Buffer, DirContext->LongNameU.Length);
|
||||
pInfo->NextEntryOffset = ULONG_ROUND_UP(sizeof(FILE_DIRECTORY_INFORMATION) +
|
||||
DirContext->LongNameU.Length);
|
||||
|
||||
RtlCopyMemory(pInfo->FileName,
|
||||
DirContext->LongNameU.Buffer,
|
||||
DirContext->LongNameU.Length);
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static NTSTATUS
|
||||
VfatGetFileDirectoryInformation (PVFAT_DIRENTRY_CONTEXT DirContext,
|
||||
VfatGetFileDirectoryInformation(PVFAT_DIRENTRY_CONTEXT DirContext,
|
||||
PDEVICE_EXTENSION DeviceExt,
|
||||
PFILE_DIRECTORY_INFORMATION pInfo,
|
||||
ULONG BufferLength)
|
||||
{
|
||||
if ((sizeof (FILE_DIRECTORY_INFORMATION) + DirContext->LongNameU.Length) > BufferLength)
|
||||
if ((sizeof(FILE_DIRECTORY_INFORMATION) + DirContext->LongNameU.Length) > BufferLength)
|
||||
return STATUS_BUFFER_OVERFLOW;
|
||||
|
||||
pInfo->FileNameLength = DirContext->LongNameU.Length;
|
||||
pInfo->NextEntryOffset =
|
||||
ULONG_ROUND_UP (sizeof (FILE_DIRECTORY_INFORMATION) + DirContext->LongNameU.Length);
|
||||
RtlCopyMemory (pInfo->FileName, DirContext->LongNameU.Buffer, DirContext->LongNameU.Length);
|
||||
// pInfo->FileIndex=;
|
||||
pInfo->NextEntryOffset = ULONG_ROUND_UP(sizeof(FILE_DIRECTORY_INFORMATION) +
|
||||
DirContext->LongNameU.Length);
|
||||
/* pInfo->FileIndex = ; */
|
||||
|
||||
RtlCopyMemory(pInfo->FileName,
|
||||
DirContext->LongNameU.Buffer,
|
||||
DirContext->LongNameU.Length);
|
||||
|
||||
if (DeviceExt->Flags & VCB_IS_FATX)
|
||||
{
|
||||
FsdDosDateTimeToSystemTime (DeviceExt, DirContext->DirEntry.FatX.CreationDate,
|
||||
FsdDosDateTimeToSystemTime(DeviceExt,
|
||||
DirContext->DirEntry.FatX.CreationDate,
|
||||
DirContext->DirEntry.FatX.CreationTime,
|
||||
&pInfo->CreationTime);
|
||||
FsdDosDateTimeToSystemTime (DeviceExt, DirContext->DirEntry.FatX.AccessDate,
|
||||
FsdDosDateTimeToSystemTime(DeviceExt,
|
||||
DirContext->DirEntry.FatX.AccessDate,
|
||||
DirContext->DirEntry.FatX.AccessTime,
|
||||
&pInfo->LastAccessTime);
|
||||
FsdDosDateTimeToSystemTime (DeviceExt, DirContext->DirEntry.FatX.UpdateDate,
|
||||
FsdDosDateTimeToSystemTime(DeviceExt,
|
||||
DirContext->DirEntry.FatX.UpdateDate,
|
||||
DirContext->DirEntry.FatX.UpdateTime,
|
||||
&pInfo->LastWriteTime);
|
||||
|
||||
pInfo->ChangeTime = pInfo->LastWriteTime;
|
||||
|
||||
if (DirContext->DirEntry.FatX.Attrib & FILE_ATTRIBUTE_DIRECTORY)
|
||||
{
|
||||
pInfo->EndOfFile.QuadPart = 0;
|
||||
|
@ -122,21 +147,29 @@ VfatGetFileDirectoryInformation (PVFAT_DIRENTRY_CONTEXT DirContext,
|
|||
pInfo->EndOfFile.u.LowPart = DirContext->DirEntry.FatX.FileSize;
|
||||
/* Make allocsize a rounded up multiple of BytesPerCluster */
|
||||
pInfo->AllocationSize.u.HighPart = 0;
|
||||
pInfo->AllocationSize.u.LowPart = ROUND_UP(DirContext->DirEntry.FatX.FileSize, DeviceExt->FatInfo.BytesPerCluster);
|
||||
pInfo->AllocationSize.u.LowPart = ROUND_UP(DirContext->DirEntry.FatX.FileSize,
|
||||
DeviceExt->FatInfo.BytesPerCluster);
|
||||
}
|
||||
|
||||
pInfo->FileAttributes = DirContext->DirEntry.FatX.Attrib & 0x3f;
|
||||
}
|
||||
else
|
||||
{
|
||||
FsdDosDateTimeToSystemTime (DeviceExt, DirContext->DirEntry.Fat.CreationDate,
|
||||
FsdDosDateTimeToSystemTime(DeviceExt,
|
||||
DirContext->DirEntry.Fat.CreationDate,
|
||||
DirContext->DirEntry.Fat.CreationTime,
|
||||
&pInfo->CreationTime);
|
||||
FsdDosDateTimeToSystemTime (DeviceExt, DirContext->DirEntry.Fat.AccessDate, 0,
|
||||
FsdDosDateTimeToSystemTime(DeviceExt,
|
||||
DirContext->DirEntry.Fat.AccessDate,
|
||||
0,
|
||||
&pInfo->LastAccessTime);
|
||||
FsdDosDateTimeToSystemTime (DeviceExt, DirContext->DirEntry.Fat.UpdateDate,
|
||||
FsdDosDateTimeToSystemTime(DeviceExt,
|
||||
DirContext->DirEntry.Fat.UpdateDate,
|
||||
DirContext->DirEntry.Fat.UpdateTime,
|
||||
&pInfo->LastWriteTime);
|
||||
|
||||
pInfo->ChangeTime = pInfo->LastWriteTime;
|
||||
|
||||
if (DirContext->DirEntry.Fat.Attrib & FILE_ATTRIBUTE_DIRECTORY)
|
||||
{
|
||||
pInfo->EndOfFile.QuadPart = 0;
|
||||
|
@ -148,8 +181,10 @@ VfatGetFileDirectoryInformation (PVFAT_DIRENTRY_CONTEXT DirContext,
|
|||
pInfo->EndOfFile.u.LowPart = DirContext->DirEntry.Fat.FileSize;
|
||||
/* Make allocsize a rounded up multiple of BytesPerCluster */
|
||||
pInfo->AllocationSize.u.HighPart = 0;
|
||||
pInfo->AllocationSize.u.LowPart = ROUND_UP(DirContext->DirEntry.Fat.FileSize, DeviceExt->FatInfo.BytesPerCluster);
|
||||
pInfo->AllocationSize.u.LowPart = ROUND_UP(DirContext->DirEntry.Fat.FileSize,
|
||||
DeviceExt->FatInfo.BytesPerCluster);
|
||||
}
|
||||
|
||||
pInfo->FileAttributes = DirContext->DirEntry.Fat.Attrib & 0x3f;
|
||||
}
|
||||
|
||||
|
@ -157,87 +192,116 @@ VfatGetFileDirectoryInformation (PVFAT_DIRENTRY_CONTEXT DirContext,
|
|||
}
|
||||
|
||||
static NTSTATUS
|
||||
VfatGetFileFullDirectoryInformation (PVFAT_DIRENTRY_CONTEXT DirContext,
|
||||
VfatGetFileFullDirectoryInformation(PVFAT_DIRENTRY_CONTEXT DirContext,
|
||||
PDEVICE_EXTENSION DeviceExt,
|
||||
PFILE_FULL_DIR_INFORMATION pInfo,
|
||||
ULONG BufferLength)
|
||||
{
|
||||
if ((sizeof (FILE_FULL_DIR_INFORMATION) + DirContext->LongNameU.Length) > BufferLength)
|
||||
if ((sizeof(FILE_FULL_DIR_INFORMATION) + DirContext->LongNameU.Length) > BufferLength)
|
||||
return STATUS_BUFFER_OVERFLOW;
|
||||
|
||||
pInfo->FileNameLength = DirContext->LongNameU.Length;
|
||||
pInfo->NextEntryOffset =
|
||||
ULONG_ROUND_UP (sizeof (FILE_FULL_DIR_INFORMATION) + DirContext->LongNameU.Length);
|
||||
RtlCopyMemory (pInfo->FileName, DirContext->LongNameU.Buffer, DirContext->LongNameU.Length);
|
||||
// pInfo->FileIndex=;
|
||||
pInfo->NextEntryOffset = ULONG_ROUND_UP(sizeof(FILE_FULL_DIR_INFORMATION) +
|
||||
DirContext->LongNameU.Length);
|
||||
/* pInfo->FileIndex = ; */
|
||||
/* pInfo->EaSize = ; */
|
||||
|
||||
RtlCopyMemory(pInfo->FileName,
|
||||
DirContext->LongNameU.Buffer,
|
||||
DirContext->LongNameU.Length);
|
||||
|
||||
if (DeviceExt->Flags & VCB_IS_FATX)
|
||||
{
|
||||
FsdDosDateTimeToSystemTime (DeviceExt, DirContext->DirEntry.FatX.CreationDate,
|
||||
FsdDosDateTimeToSystemTime(DeviceExt,
|
||||
DirContext->DirEntry.FatX.CreationDate,
|
||||
DirContext->DirEntry.FatX.CreationTime,
|
||||
&pInfo->CreationTime);
|
||||
FsdDosDateTimeToSystemTime (DeviceExt, DirContext->DirEntry.FatX.AccessDate,
|
||||
FsdDosDateTimeToSystemTime(DeviceExt,
|
||||
DirContext->DirEntry.FatX.AccessDate,
|
||||
DirContext->DirEntry.FatX.AccessTime,
|
||||
&pInfo->LastAccessTime);
|
||||
FsdDosDateTimeToSystemTime (DeviceExt, DirContext->DirEntry.FatX.UpdateDate,
|
||||
FsdDosDateTimeToSystemTime(DeviceExt,
|
||||
DirContext->DirEntry.FatX.UpdateDate,
|
||||
DirContext->DirEntry.FatX.UpdateTime,
|
||||
&pInfo->LastWriteTime);
|
||||
|
||||
pInfo->ChangeTime = pInfo->LastWriteTime;
|
||||
pInfo->EndOfFile.u.HighPart = 0;
|
||||
pInfo->EndOfFile.u.LowPart = DirContext->DirEntry.FatX.FileSize;
|
||||
/* Make allocsize a rounded up multiple of BytesPerCluster */
|
||||
pInfo->AllocationSize.u.HighPart = 0;
|
||||
pInfo->AllocationSize.u.LowPart = ROUND_UP(DirContext->DirEntry.FatX.FileSize, DeviceExt->FatInfo.BytesPerCluster);
|
||||
pInfo->AllocationSize.u.LowPart = ROUND_UP(DirContext->DirEntry.FatX.FileSize,
|
||||
DeviceExt->FatInfo.BytesPerCluster);
|
||||
pInfo->FileAttributes = DirContext->DirEntry.FatX.Attrib & 0x3f;
|
||||
}
|
||||
else
|
||||
{
|
||||
FsdDosDateTimeToSystemTime (DeviceExt, DirContext->DirEntry.Fat.CreationDate,
|
||||
FsdDosDateTimeToSystemTime(DeviceExt,
|
||||
DirContext->DirEntry.Fat.CreationDate,
|
||||
DirContext->DirEntry.Fat.CreationTime,
|
||||
&pInfo->CreationTime);
|
||||
FsdDosDateTimeToSystemTime (DeviceExt, DirContext->DirEntry.Fat.AccessDate,
|
||||
0, &pInfo->LastAccessTime);
|
||||
FsdDosDateTimeToSystemTime (DeviceExt, DirContext->DirEntry.Fat.UpdateDate,
|
||||
FsdDosDateTimeToSystemTime(DeviceExt,
|
||||
DirContext->DirEntry.Fat.AccessDate,
|
||||
0,
|
||||
&pInfo->LastAccessTime);
|
||||
FsdDosDateTimeToSystemTime(DeviceExt,
|
||||
DirContext->DirEntry.Fat.UpdateDate,
|
||||
DirContext->DirEntry.Fat.UpdateTime,
|
||||
&pInfo->LastWriteTime);
|
||||
|
||||
pInfo->ChangeTime = pInfo->LastWriteTime;
|
||||
pInfo->EndOfFile.u.HighPart = 0;
|
||||
pInfo->EndOfFile.u.LowPart = DirContext->DirEntry.Fat.FileSize;
|
||||
/* Make allocsize a rounded up multiple of BytesPerCluster */
|
||||
pInfo->AllocationSize.u.HighPart = 0;
|
||||
pInfo->AllocationSize.u.LowPart = ROUND_UP(DirContext->DirEntry.Fat.FileSize, DeviceExt->FatInfo.BytesPerCluster);
|
||||
pInfo->AllocationSize.u.LowPart = ROUND_UP(DirContext->DirEntry.Fat.FileSize,
|
||||
DeviceExt->FatInfo.BytesPerCluster);
|
||||
pInfo->FileAttributes = DirContext->DirEntry.Fat.Attrib & 0x3f;
|
||||
}
|
||||
// pInfo->EaSize=;
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static NTSTATUS
|
||||
VfatGetFileBothInformation (PVFAT_DIRENTRY_CONTEXT DirContext,
|
||||
VfatGetFileBothInformation(PVFAT_DIRENTRY_CONTEXT DirContext,
|
||||
PDEVICE_EXTENSION DeviceExt,
|
||||
PFILE_BOTH_DIR_INFORMATION pInfo,
|
||||
ULONG BufferLength)
|
||||
{
|
||||
if ((sizeof (FILE_BOTH_DIR_INFORMATION) + DirContext->LongNameU.Length) > BufferLength)
|
||||
if ((sizeof(FILE_BOTH_DIR_INFORMATION) + DirContext->LongNameU.Length) > BufferLength)
|
||||
return STATUS_BUFFER_OVERFLOW;
|
||||
|
||||
pInfo->EaSize = 0;
|
||||
|
||||
if (DeviceExt->Flags & VCB_IS_FATX)
|
||||
{
|
||||
pInfo->FileNameLength = DirContext->LongNameU.Length;
|
||||
RtlCopyMemory(pInfo->FileName, DirContext->LongNameU.Buffer, DirContext->LongNameU.Length);
|
||||
pInfo->NextEntryOffset =
|
||||
ULONG_ROUND_UP (sizeof (FILE_BOTH_DIR_INFORMATION) + DirContext->LongNameU.Length);
|
||||
|
||||
RtlCopyMemory(pInfo->FileName,
|
||||
DirContext->LongNameU.Buffer,
|
||||
DirContext->LongNameU.Length);
|
||||
|
||||
pInfo->NextEntryOffset = ULONG_ROUND_UP(sizeof(FILE_BOTH_DIR_INFORMATION) +
|
||||
DirContext->LongNameU.Length);
|
||||
pInfo->ShortName[0] = 0;
|
||||
pInfo->ShortNameLength = 0;
|
||||
// pInfo->FileIndex=;
|
||||
FsdDosDateTimeToSystemTime (DeviceExt, DirContext->DirEntry.FatX.CreationDate,
|
||||
/* pInfo->FileIndex = ; */
|
||||
|
||||
FsdDosDateTimeToSystemTime(DeviceExt,
|
||||
DirContext->DirEntry.FatX.CreationDate,
|
||||
DirContext->DirEntry.FatX.CreationTime,
|
||||
&pInfo->CreationTime);
|
||||
FsdDosDateTimeToSystemTime (DeviceExt, DirContext->DirEntry.FatX.AccessDate,
|
||||
FsdDosDateTimeToSystemTime(DeviceExt,
|
||||
DirContext->DirEntry.FatX.AccessDate,
|
||||
DirContext->DirEntry.FatX.AccessTime,
|
||||
&pInfo->LastAccessTime);
|
||||
FsdDosDateTimeToSystemTime (DeviceExt, DirContext->DirEntry.FatX.UpdateDate,
|
||||
FsdDosDateTimeToSystemTime(DeviceExt,
|
||||
DirContext->DirEntry.FatX.UpdateDate,
|
||||
DirContext->DirEntry.FatX.UpdateTime,
|
||||
&pInfo->LastWriteTime);
|
||||
|
||||
pInfo->ChangeTime = pInfo->LastWriteTime;
|
||||
|
||||
if (DirContext->DirEntry.FatX.Attrib & FILE_ATTRIBUTE_DIRECTORY)
|
||||
{
|
||||
pInfo->EndOfFile.QuadPart = 0;
|
||||
|
@ -249,28 +313,45 @@ VfatGetFileBothInformation (PVFAT_DIRENTRY_CONTEXT DirContext,
|
|||
pInfo->EndOfFile.u.LowPart = DirContext->DirEntry.FatX.FileSize;
|
||||
/* Make allocsize a rounded up multiple of BytesPerCluster */
|
||||
pInfo->AllocationSize.u.HighPart = 0;
|
||||
pInfo->AllocationSize.u.LowPart = ROUND_UP(DirContext->DirEntry.FatX.FileSize, DeviceExt->FatInfo.BytesPerCluster);
|
||||
pInfo->AllocationSize.u.LowPart = ROUND_UP(DirContext->DirEntry.FatX.FileSize,
|
||||
DeviceExt->FatInfo.BytesPerCluster);
|
||||
}
|
||||
|
||||
pInfo->FileAttributes = DirContext->DirEntry.FatX.Attrib & 0x3f;
|
||||
}
|
||||
else
|
||||
{
|
||||
pInfo->FileNameLength = DirContext->LongNameU.Length;
|
||||
pInfo->NextEntryOffset =
|
||||
ULONG_ROUND_UP (sizeof (FILE_BOTH_DIR_INFORMATION) + DirContext->LongNameU.Length);
|
||||
RtlCopyMemory(pInfo->ShortName, DirContext->ShortNameU.Buffer, DirContext->ShortNameU.Length);
|
||||
pInfo->NextEntryOffset = ULONG_ROUND_UP(sizeof(FILE_BOTH_DIR_INFORMATION) +
|
||||
DirContext->LongNameU.Length);
|
||||
|
||||
RtlCopyMemory(pInfo->ShortName,
|
||||
DirContext->ShortNameU.Buffer,
|
||||
DirContext->ShortNameU.Length);
|
||||
|
||||
pInfo->ShortNameLength = (CCHAR)DirContext->ShortNameU.Length;
|
||||
RtlCopyMemory (pInfo->FileName, DirContext->LongNameU.Buffer, DirContext->LongNameU.Length);
|
||||
// pInfo->FileIndex=;
|
||||
FsdDosDateTimeToSystemTime (DeviceExt, DirContext->DirEntry.Fat.CreationDate,
|
||||
|
||||
RtlCopyMemory(pInfo->FileName,
|
||||
DirContext->LongNameU.Buffer,
|
||||
DirContext->LongNameU.Length);
|
||||
|
||||
/* pInfo->FileIndex = ; */
|
||||
|
||||
FsdDosDateTimeToSystemTime(DeviceExt,
|
||||
DirContext->DirEntry.Fat.CreationDate,
|
||||
DirContext->DirEntry.Fat.CreationTime,
|
||||
&pInfo->CreationTime);
|
||||
FsdDosDateTimeToSystemTime (DeviceExt, DirContext->DirEntry.Fat.AccessDate, 0,
|
||||
FsdDosDateTimeToSystemTime(DeviceExt,
|
||||
DirContext->DirEntry.Fat.AccessDate,
|
||||
0,
|
||||
&pInfo->LastAccessTime);
|
||||
FsdDosDateTimeToSystemTime (DeviceExt, DirContext->DirEntry.Fat.UpdateDate,
|
||||
FsdDosDateTimeToSystemTime(DeviceExt,
|
||||
DirContext->DirEntry.Fat.UpdateDate,
|
||||
DirContext->DirEntry.Fat.UpdateTime,
|
||||
&pInfo->LastWriteTime);
|
||||
|
||||
pInfo->ChangeTime = pInfo->LastWriteTime;
|
||||
|
||||
if (DirContext->DirEntry.Fat.Attrib & FILE_ATTRIBUTE_DIRECTORY)
|
||||
{
|
||||
pInfo->EndOfFile.QuadPart = 0;
|
||||
|
@ -284,19 +365,21 @@ VfatGetFileBothInformation (PVFAT_DIRENTRY_CONTEXT DirContext,
|
|||
pInfo->AllocationSize.u.HighPart = 0;
|
||||
pInfo->AllocationSize.u.LowPart = ROUND_UP(DirContext->DirEntry.Fat.FileSize, DeviceExt->FatInfo.BytesPerCluster);
|
||||
}
|
||||
|
||||
pInfo->FileAttributes = DirContext->DirEntry.Fat.Attrib & 0x3f;
|
||||
}
|
||||
pInfo->EaSize=0;
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static NTSTATUS DoQuery (PVFAT_IRP_CONTEXT IrpContext)
|
||||
static NTSTATUS
|
||||
DoQuery(PVFAT_IRP_CONTEXT IrpContext)
|
||||
{
|
||||
NTSTATUS RC = STATUS_SUCCESS;
|
||||
long BufferLength = 0;
|
||||
NTSTATUS Status = STATUS_SUCCESS;
|
||||
LONG BufferLength = 0;
|
||||
PUNICODE_STRING pSearchPattern = NULL;
|
||||
FILE_INFORMATION_CLASS FileInformationClass;
|
||||
unsigned char *Buffer = NULL;
|
||||
PUCHAR Buffer = NULL;
|
||||
PFILE_NAMES_INFORMATION Buffer0 = NULL;
|
||||
PVFATFCB pFcb;
|
||||
PVFATCCB pCcb;
|
||||
|
@ -308,10 +391,10 @@ static NTSTATUS DoQuery (PVFAT_IRP_CONTEXT IrpContext)
|
|||
|
||||
PIO_STACK_LOCATION Stack = IrpContext->Stack;
|
||||
|
||||
pCcb = (PVFATCCB) IrpContext->FileObject->FsContext2;
|
||||
pFcb = (PVFATFCB) IrpContext->FileObject->FsContext;
|
||||
pCcb = (PVFATCCB)IrpContext->FileObject->FsContext2;
|
||||
pFcb = (PVFATFCB)IrpContext->FileObject->FsContext;
|
||||
|
||||
// determine Buffer for result :
|
||||
/* Determine Buffer for result : */
|
||||
BufferLength = Stack->Parameters.QueryDirectory.Length;
|
||||
#if 0
|
||||
/* Do not probe the user buffer until SEH is available */
|
||||
|
@ -327,12 +410,11 @@ static NTSTATUS DoQuery (PVFAT_IRP_CONTEXT IrpContext)
|
|||
if (!ExAcquireResourceSharedLite(&pFcb->MainResource,
|
||||
(BOOLEAN)(IrpContext->Flags & IRPCONTEXT_CANWAIT)))
|
||||
{
|
||||
RC = VfatLockUserBuffer(IrpContext->Irp, BufferLength, IoWriteAccess);
|
||||
if (NT_SUCCESS(RC))
|
||||
{
|
||||
RC = STATUS_PENDING;
|
||||
}
|
||||
return RC;
|
||||
Status = VfatLockUserBuffer(IrpContext->Irp, BufferLength, IoWriteAccess);
|
||||
if (NT_SUCCESS(Status))
|
||||
Status = STATUS_PENDING;
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
/* Obtain the callers parameters */
|
||||
|
@ -343,15 +425,17 @@ static NTSTATUS DoQuery (PVFAT_IRP_CONTEXT IrpContext)
|
|||
#else
|
||||
pSearchPattern = Stack->Parameters.QueryDirectory.FileName;
|
||||
#endif
|
||||
FileInformationClass =
|
||||
Stack->Parameters.QueryDirectory.FileInformationClass;
|
||||
FileInformationClass = Stack->Parameters.QueryDirectory.FileInformationClass;
|
||||
|
||||
if (pSearchPattern)
|
||||
{
|
||||
if (!pCcb->SearchPattern.Buffer)
|
||||
{
|
||||
FirstQuery = TRUE;
|
||||
pCcb->SearchPattern.MaximumLength = pSearchPattern->Length + sizeof(WCHAR);
|
||||
pCcb->SearchPattern.Buffer = ExAllocatePoolWithTag(NonPagedPool, pCcb->SearchPattern.MaximumLength, TAG_VFAT);
|
||||
pCcb->SearchPattern.Buffer = ExAllocatePoolWithTag(NonPagedPool,
|
||||
pCcb->SearchPattern.MaximumLength,
|
||||
TAG_VFAT);
|
||||
if (!pCcb->SearchPattern.Buffer)
|
||||
{
|
||||
ExReleaseResourceLite(&pFcb->MainResource);
|
||||
|
@ -365,7 +449,9 @@ static NTSTATUS DoQuery (PVFAT_IRP_CONTEXT IrpContext)
|
|||
{
|
||||
FirstQuery = TRUE;
|
||||
pCcb->SearchPattern.MaximumLength = 2 * sizeof(WCHAR);
|
||||
pCcb->SearchPattern.Buffer = ExAllocatePoolWithTag(NonPagedPool, 2 * sizeof(WCHAR), TAG_VFAT);
|
||||
pCcb->SearchPattern.Buffer = ExAllocatePoolWithTag(NonPagedPool,
|
||||
2 * sizeof(WCHAR),
|
||||
TAG_VFAT);
|
||||
if (!pCcb->SearchPattern.Buffer)
|
||||
{
|
||||
ExReleaseResourceLite(&pFcb->MainResource);
|
||||
|
@ -389,123 +475,135 @@ static NTSTATUS DoQuery (PVFAT_IRP_CONTEXT IrpContext)
|
|||
DirContext.DirIndex = pCcb->Entry;
|
||||
}
|
||||
|
||||
DPRINT ("Buffer=%p tofind=%wZ\n", Buffer, &pCcb->SearchPattern);
|
||||
DPRINT("Buffer=%p tofind=%wZ\n", Buffer, &pCcb->SearchPattern);
|
||||
|
||||
DirContext.LongNameU.Buffer = LongNameBuffer;
|
||||
DirContext.LongNameU.MaximumLength = sizeof(LongNameBuffer);
|
||||
DirContext.ShortNameU.Buffer = ShortNameBuffer;
|
||||
DirContext.ShortNameU.MaximumLength = sizeof(ShortNameBuffer);
|
||||
|
||||
while (RC == STATUS_SUCCESS && BufferLength > 0)
|
||||
while ((Status == STATUS_SUCCESS) && (BufferLength > 0))
|
||||
{
|
||||
RC = FindFile (IrpContext->DeviceExt, pFcb,
|
||||
&pCcb->SearchPattern, &DirContext, FirstCall);
|
||||
Status = FindFile(IrpContext->DeviceExt,
|
||||
pFcb,
|
||||
&pCcb->SearchPattern,
|
||||
&DirContext,
|
||||
FirstCall);
|
||||
pCcb->Entry = DirContext.DirIndex;
|
||||
DPRINT ("Found %wZ, RC=%x, entry %x\n", &DirContext.LongNameU, RC, pCcb->Entry);
|
||||
|
||||
DPRINT("Found %wZ, Status=%x, entry %x\n", &DirContext.LongNameU, Status, pCcb->Entry);
|
||||
|
||||
FirstCall = FALSE;
|
||||
if (NT_SUCCESS (RC))
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
switch (FileInformationClass)
|
||||
{
|
||||
case FileNameInformation:
|
||||
RC = VfatGetFileNameInformation (&DirContext,
|
||||
(PFILE_NAMES_INFORMATION) Buffer,
|
||||
Status = VfatGetFileNameInformation(&DirContext,
|
||||
(PFILE_NAMES_INFORMATION)Buffer,
|
||||
BufferLength);
|
||||
break;
|
||||
|
||||
case FileDirectoryInformation:
|
||||
RC = VfatGetFileDirectoryInformation (&DirContext,
|
||||
Status = VfatGetFileDirectoryInformation(&DirContext,
|
||||
IrpContext->DeviceExt,
|
||||
(PFILE_DIRECTORY_INFORMATION) Buffer,
|
||||
(PFILE_DIRECTORY_INFORMATION)Buffer,
|
||||
BufferLength);
|
||||
break;
|
||||
|
||||
case FileFullDirectoryInformation:
|
||||
RC = VfatGetFileFullDirectoryInformation (&DirContext,
|
||||
Status = VfatGetFileFullDirectoryInformation(&DirContext,
|
||||
IrpContext->DeviceExt,
|
||||
(PFILE_FULL_DIR_INFORMATION) Buffer,
|
||||
(PFILE_FULL_DIR_INFORMATION)Buffer,
|
||||
BufferLength);
|
||||
break;
|
||||
|
||||
case FileBothDirectoryInformation:
|
||||
RC = VfatGetFileBothInformation (&DirContext,
|
||||
Status = VfatGetFileBothInformation(&DirContext,
|
||||
IrpContext->DeviceExt,
|
||||
(PFILE_BOTH_DIR_INFORMATION) Buffer,
|
||||
(PFILE_BOTH_DIR_INFORMATION)Buffer,
|
||||
BufferLength);
|
||||
break;
|
||||
|
||||
default:
|
||||
RC = STATUS_INVALID_INFO_CLASS;
|
||||
}
|
||||
if (RC == STATUS_BUFFER_OVERFLOW || RC == STATUS_INVALID_INFO_CLASS)
|
||||
{
|
||||
Status = STATUS_INVALID_INFO_CLASS;
|
||||
break;
|
||||
}
|
||||
|
||||
if (Status == STATUS_BUFFER_OVERFLOW || Status == STATUS_INVALID_INFO_CLASS)
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (FirstQuery)
|
||||
{
|
||||
RC = STATUS_NO_SUCH_FILE;
|
||||
}
|
||||
else
|
||||
{
|
||||
RC = STATUS_NO_MORE_FILES;
|
||||
}
|
||||
Status = (FirstQuery ? STATUS_NO_SUCH_FILE : STATUS_NO_MORE_FILES);
|
||||
break;
|
||||
}
|
||||
|
||||
Buffer0 = (PFILE_NAMES_INFORMATION) Buffer;
|
||||
Buffer0->FileIndex = DirContext.DirIndex;
|
||||
pCcb->Entry = ++DirContext.DirIndex;
|
||||
BufferLength -= Buffer0->NextEntryOffset;
|
||||
|
||||
if (IrpContext->Stack->Flags & SL_RETURN_SINGLE_ENTRY)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
Buffer += Buffer0->NextEntryOffset;
|
||||
}
|
||||
|
||||
if (Buffer0)
|
||||
{
|
||||
Buffer0->NextEntryOffset = 0;
|
||||
RC = STATUS_SUCCESS;
|
||||
Status = STATUS_SUCCESS;
|
||||
IrpContext->Irp->IoStatus.Information = Stack->Parameters.QueryDirectory.Length - BufferLength;
|
||||
|
||||
}
|
||||
|
||||
ExReleaseResourceLite(&pFcb->MainResource);
|
||||
return RC;
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS VfatDirectoryControl (PVFAT_IRP_CONTEXT IrpContext)
|
||||
/*
|
||||
* FUNCTION: directory control : read/write directory informations
|
||||
*/
|
||||
NTSTATUS
|
||||
VfatDirectoryControl(PVFAT_IRP_CONTEXT IrpContext)
|
||||
{
|
||||
NTSTATUS RC = STATUS_SUCCESS;
|
||||
NTSTATUS Status = STATUS_SUCCESS;
|
||||
|
||||
IrpContext->Irp->IoStatus.Information = 0;
|
||||
|
||||
switch (IrpContext->MinorFunction)
|
||||
{
|
||||
case IRP_MN_QUERY_DIRECTORY:
|
||||
RC = DoQuery (IrpContext);
|
||||
Status = DoQuery (IrpContext);
|
||||
break;
|
||||
|
||||
case IRP_MN_NOTIFY_CHANGE_DIRECTORY:
|
||||
DPRINT (" vfat, dir : change\n");
|
||||
RC = STATUS_NOT_IMPLEMENTED;
|
||||
DPRINT("VFAT, dir : change\n");
|
||||
Status = STATUS_NOT_IMPLEMENTED;
|
||||
break;
|
||||
|
||||
default:
|
||||
// error
|
||||
DbgPrint ("unexpected minor function %x in VFAT driver\n",
|
||||
/* Error */
|
||||
DPRINT("Unexpected minor function %x in VFAT driver\n",
|
||||
IrpContext->MinorFunction);
|
||||
RC = STATUS_INVALID_DEVICE_REQUEST;
|
||||
Status = STATUS_INVALID_DEVICE_REQUEST;
|
||||
break;
|
||||
}
|
||||
if (RC == STATUS_PENDING)
|
||||
|
||||
if (Status == STATUS_PENDING)
|
||||
{
|
||||
RC = VfatQueueRequest(IrpContext);
|
||||
Status = VfatQueueRequest(IrpContext);
|
||||
}
|
||||
else
|
||||
{
|
||||
IrpContext->Irp->IoStatus.Status = RC;
|
||||
IrpContext->Irp->IoStatus.Status = Status;
|
||||
IoCompleteRequest (IrpContext->Irp, IO_NO_INCREMENT);
|
||||
VfatFreeIrpContext(IrpContext);
|
||||
}
|
||||
return RC;
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/* EOF */
|
Loading…
Reference in a new issue