1998-12-30 19:01:23 +00:00
|
|
|
/*
|
2022-09-24 13:24:08 +00:00
|
|
|
* PROJECT: VFAT Filesystem
|
|
|
|
* LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
|
|
|
|
* PURPOSE: Directory control
|
|
|
|
* COPYRIGHT: Copyright 1998 Jason Filby <jasonfilby@yahoo.com>
|
|
|
|
* Copyright 2004-2005 Hervé Poussineau <hpoussin@reactos.org>
|
|
|
|
* Copyright 2012-2018 Pierre Schweitzer <pierre@reactos.org>
|
|
|
|
*/
|
1999-03-19 05:55:55 +00:00
|
|
|
|
2012-09-06 18:36:48 +00:00
|
|
|
/* INCLUDES *****************************************************************/
|
|
|
|
|
1998-12-30 19:01:23 +00:00
|
|
|
#include "vfat.h"
|
|
|
|
|
2013-12-19 16:20:28 +00:00
|
|
|
#define NDEBUG
|
|
|
|
#include <debug.h>
|
|
|
|
|
2012-09-06 18:36:48 +00:00
|
|
|
/* FUNCTIONS ****************************************************************/
|
1999-05-15 17:25:02 +00:00
|
|
|
|
2012-09-06 18:36:48 +00:00
|
|
|
/* Function like DosDateTimeToFileTime */
|
2005-01-12 10:46:13 +00:00
|
|
|
BOOLEAN
|
2013-12-09 18:48:13 +00:00
|
|
|
FsdDosDateTimeToSystemTime(
|
|
|
|
PDEVICE_EXTENSION DeviceExt,
|
|
|
|
USHORT DosDate,
|
|
|
|
USHORT DosTime,
|
|
|
|
PLARGE_INTEGER SystemTime)
|
1998-12-30 19:01:23 +00:00
|
|
|
{
|
2012-09-06 18:36:48 +00:00
|
|
|
PDOSTIME pdtime = (PDOSTIME)&DosTime;
|
|
|
|
PDOSDATE pddate = (PDOSDATE)&DosDate;
|
|
|
|
TIME_FIELDS TimeFields;
|
|
|
|
LARGE_INTEGER LocalTime;
|
1998-12-30 19:01:23 +00:00
|
|
|
|
2012-09-06 18:36:48 +00:00
|
|
|
if (SystemTime == NULL)
|
|
|
|
return FALSE;
|
1998-12-30 19:01:23 +00:00
|
|
|
|
2012-09-06 18:36:48 +00:00
|
|
|
TimeFields.Milliseconds = 0;
|
|
|
|
TimeFields.Second = pdtime->Second * 2;
|
|
|
|
TimeFields.Minute = pdtime->Minute;
|
|
|
|
TimeFields.Hour = pdtime->Hour;
|
1999-05-15 17:25:02 +00:00
|
|
|
|
2012-09-06 18:36:48 +00:00
|
|
|
TimeFields.Day = pddate->Day;
|
|
|
|
TimeFields.Month = pddate->Month;
|
|
|
|
TimeFields.Year = (CSHORT)(DeviceExt->BaseDateYear + pddate->Year);
|
1999-05-15 17:25:02 +00:00
|
|
|
|
2012-09-06 18:36:48 +00:00
|
|
|
RtlTimeFieldsToTime(&TimeFields, &LocalTime);
|
|
|
|
ExLocalTimeToSystemTime(&LocalTime, SystemTime);
|
1999-05-15 17:25:02 +00:00
|
|
|
|
2012-09-06 18:36:48 +00:00
|
|
|
return TRUE;
|
1999-05-15 17:25:02 +00:00
|
|
|
}
|
1998-12-30 19:01:23 +00:00
|
|
|
|
2012-09-06 18:36:48 +00:00
|
|
|
/* Function like FileTimeToDosDateTime */
|
2005-01-12 10:46:13 +00:00
|
|
|
BOOLEAN
|
2013-12-09 18:48:13 +00:00
|
|
|
FsdSystemTimeToDosDateTime(
|
|
|
|
PDEVICE_EXTENSION DeviceExt,
|
|
|
|
PLARGE_INTEGER SystemTime,
|
|
|
|
PUSHORT pDosDate,
|
|
|
|
PUSHORT pDosTime)
|
1999-12-16 23:08:17 +00:00
|
|
|
{
|
2012-09-06 18:36:48 +00:00
|
|
|
PDOSTIME pdtime = (PDOSTIME)pDosTime;
|
|
|
|
PDOSDATE pddate = (PDOSDATE)pDosDate;
|
|
|
|
TIME_FIELDS TimeFields;
|
|
|
|
LARGE_INTEGER LocalTime;
|
1999-12-16 23:08:17 +00:00
|
|
|
|
2012-09-06 18:36:48 +00:00
|
|
|
if (SystemTime == NULL)
|
|
|
|
return FALSE;
|
1999-12-16 23:08:17 +00:00
|
|
|
|
2012-09-06 18:36:48 +00:00
|
|
|
ExSystemTimeToLocalTime(SystemTime, &LocalTime);
|
|
|
|
RtlTimeToTimeFields(&LocalTime, &TimeFields);
|
1999-12-16 23:08:17 +00:00
|
|
|
|
2012-09-06 18:36:48 +00:00
|
|
|
if (pdtime)
|
2000-12-29 23:17:12 +00:00
|
|
|
{
|
2012-09-06 18:36:48 +00:00
|
|
|
pdtime->Second = TimeFields.Second / 2;
|
|
|
|
pdtime->Minute = TimeFields.Minute;
|
|
|
|
pdtime->Hour = TimeFields.Hour;
|
2000-12-29 23:17:12 +00:00
|
|
|
}
|
1999-12-16 23:08:17 +00:00
|
|
|
|
2012-09-06 18:36:48 +00:00
|
|
|
if (pddate)
|
2000-12-29 23:17:12 +00:00
|
|
|
{
|
2012-09-06 18:36:48 +00:00
|
|
|
pddate->Day = TimeFields.Day;
|
|
|
|
pddate->Month = TimeFields.Month;
|
|
|
|
pddate->Year = (USHORT) (TimeFields.Year - DeviceExt->BaseDateYear);
|
2000-12-29 23:17:12 +00:00
|
|
|
}
|
1999-12-16 23:08:17 +00:00
|
|
|
|
2012-09-06 18:36:48 +00:00
|
|
|
return TRUE;
|
1999-12-16 23:08:17 +00:00
|
|
|
}
|
|
|
|
|
2005-01-12 10:46:13 +00:00
|
|
|
#define ULONG_ROUND_UP(x) ROUND_UP((x), (sizeof(ULONG)))
|
1998-12-30 19:01:23 +00:00
|
|
|
|
2017-12-09 11:33:29 +00:00
|
|
|
static
|
|
|
|
NTSTATUS
|
|
|
|
VfatGetFileNamesInformation(
|
2013-12-09 18:48:13 +00:00
|
|
|
PVFAT_DIRENTRY_CONTEXT DirContext,
|
|
|
|
PFILE_NAMES_INFORMATION pInfo,
|
2017-12-09 09:58:19 +00:00
|
|
|
ULONG BufferLength,
|
|
|
|
PULONG Written,
|
|
|
|
BOOLEAN First)
|
1998-12-30 19:01:23 +00:00
|
|
|
{
|
2017-12-09 09:58:19 +00:00
|
|
|
NTSTATUS Status;
|
|
|
|
ULONG BytesToCopy = 0;
|
2012-09-06 18:36:48 +00:00
|
|
|
|
2017-12-09 09:58:19 +00:00
|
|
|
*Written = 0;
|
|
|
|
Status = STATUS_BUFFER_OVERFLOW;
|
2012-09-06 18:36:48 +00:00
|
|
|
|
2017-12-09 09:58:19 +00:00
|
|
|
if (FIELD_OFFSET(FILE_NAMES_INFORMATION, FileName) > BufferLength)
|
|
|
|
return Status;
|
|
|
|
|
2018-06-07 17:33:23 +00:00
|
|
|
if (First || (BufferLength > FIELD_OFFSET(FILE_NAMES_INFORMATION, FileName) + DirContext->LongNameU.Length))
|
2017-12-09 09:58:19 +00:00
|
|
|
{
|
|
|
|
pInfo->FileNameLength = DirContext->LongNameU.Length;
|
|
|
|
|
|
|
|
*Written = FIELD_OFFSET(FILE_NAMES_INFORMATION, FileName);
|
|
|
|
pInfo->NextEntryOffset = 0;
|
|
|
|
if (BufferLength > FIELD_OFFSET(FILE_NAMES_INFORMATION, FileName))
|
|
|
|
{
|
|
|
|
BytesToCopy = min(DirContext->LongNameU.Length, BufferLength - FIELD_OFFSET(FILE_NAMES_INFORMATION, FileName));
|
|
|
|
RtlCopyMemory(pInfo->FileName,
|
|
|
|
DirContext->LongNameU.Buffer,
|
|
|
|
BytesToCopy);
|
|
|
|
*Written += BytesToCopy;
|
|
|
|
|
|
|
|
if (BytesToCopy == DirContext->LongNameU.Length)
|
|
|
|
{
|
|
|
|
pInfo->NextEntryOffset = ULONG_ROUND_UP(sizeof(FILE_NAMES_INFORMATION) +
|
|
|
|
BytesToCopy);
|
|
|
|
Status = STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-09-06 18:36:48 +00:00
|
|
|
|
2017-12-09 09:58:19 +00:00
|
|
|
return Status;
|
1998-12-30 19:01:23 +00:00
|
|
|
}
|
|
|
|
|
2013-12-09 18:48:13 +00:00
|
|
|
static
|
|
|
|
NTSTATUS
|
|
|
|
VfatGetFileDirectoryInformation(
|
|
|
|
PVFAT_DIRENTRY_CONTEXT DirContext,
|
|
|
|
PDEVICE_EXTENSION DeviceExt,
|
|
|
|
PFILE_DIRECTORY_INFORMATION pInfo,
|
2017-12-09 09:58:19 +00:00
|
|
|
ULONG BufferLength,
|
|
|
|
PULONG Written,
|
|
|
|
BOOLEAN First)
|
1998-12-30 19:01:23 +00:00
|
|
|
{
|
2017-12-09 09:58:19 +00:00
|
|
|
NTSTATUS Status;
|
|
|
|
ULONG BytesToCopy = 0;
|
2012-09-06 18:36:48 +00:00
|
|
|
|
2017-12-09 09:58:19 +00:00
|
|
|
*Written = 0;
|
|
|
|
Status = STATUS_BUFFER_OVERFLOW;
|
2012-09-06 18:36:48 +00:00
|
|
|
|
2017-12-09 09:58:19 +00:00
|
|
|
if (FIELD_OFFSET(FILE_DIRECTORY_INFORMATION, FileName) > BufferLength)
|
|
|
|
return Status;
|
2012-09-06 18:36:48 +00:00
|
|
|
|
2018-06-07 17:33:23 +00:00
|
|
|
if (First || (BufferLength > FIELD_OFFSET(FILE_DIRECTORY_INFORMATION, FileName) + DirContext->LongNameU.Length))
|
2012-09-06 18:36:48 +00:00
|
|
|
{
|
2017-12-09 09:58:19 +00:00
|
|
|
pInfo->FileNameLength = DirContext->LongNameU.Length;
|
|
|
|
/* pInfo->FileIndex = ; */
|
|
|
|
|
|
|
|
*Written = FIELD_OFFSET(FILE_DIRECTORY_INFORMATION, FileName);
|
|
|
|
pInfo->NextEntryOffset = 0;
|
|
|
|
if (BufferLength > FIELD_OFFSET(FILE_DIRECTORY_INFORMATION, FileName))
|
2012-09-06 18:36:48 +00:00
|
|
|
{
|
2017-12-09 09:58:19 +00:00
|
|
|
BytesToCopy = min(DirContext->LongNameU.Length, BufferLength - FIELD_OFFSET(FILE_DIRECTORY_INFORMATION, FileName));
|
|
|
|
RtlCopyMemory(pInfo->FileName,
|
|
|
|
DirContext->LongNameU.Buffer,
|
|
|
|
BytesToCopy);
|
|
|
|
*Written += BytesToCopy;
|
|
|
|
|
|
|
|
if (BytesToCopy == DirContext->LongNameU.Length)
|
|
|
|
{
|
|
|
|
pInfo->NextEntryOffset = ULONG_ROUND_UP(sizeof(FILE_DIRECTORY_INFORMATION) +
|
|
|
|
BytesToCopy);
|
|
|
|
Status = STATUS_SUCCESS;
|
|
|
|
}
|
2012-09-06 18:36:48 +00:00
|
|
|
}
|
2016-09-15 13:12:02 +00:00
|
|
|
|
2017-12-09 09:58:19 +00:00
|
|
|
|
|
|
|
|
|
|
|
if (vfatVolumeIsFatX(DeviceExt))
|
2012-09-06 18:36:48 +00:00
|
|
|
{
|
2017-12-09 09:58:19 +00:00
|
|
|
FsdDosDateTimeToSystemTime(DeviceExt,
|
|
|
|
DirContext->DirEntry.FatX.CreationDate,
|
|
|
|
DirContext->DirEntry.FatX.CreationTime,
|
|
|
|
&pInfo->CreationTime);
|
|
|
|
FsdDosDateTimeToSystemTime(DeviceExt,
|
|
|
|
DirContext->DirEntry.FatX.AccessDate,
|
|
|
|
DirContext->DirEntry.FatX.AccessTime,
|
|
|
|
&pInfo->LastAccessTime);
|
|
|
|
FsdDosDateTimeToSystemTime(DeviceExt,
|
|
|
|
DirContext->DirEntry.FatX.UpdateDate,
|
|
|
|
DirContext->DirEntry.FatX.UpdateTime,
|
|
|
|
&pInfo->LastWriteTime);
|
|
|
|
|
|
|
|
pInfo->ChangeTime = pInfo->LastWriteTime;
|
|
|
|
|
|
|
|
if (BooleanFlagOn(DirContext->DirEntry.FatX.Attrib, FILE_ATTRIBUTE_DIRECTORY))
|
|
|
|
{
|
|
|
|
pInfo->EndOfFile.QuadPart = 0;
|
|
|
|
pInfo->AllocationSize.QuadPart = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
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->FileAttributes = DirContext->DirEntry.FatX.Attrib & 0x3f;
|
2012-09-06 18:36:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-12-09 09:58:19 +00:00
|
|
|
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,
|
|
|
|
DirContext->DirEntry.Fat.UpdateTime,
|
|
|
|
&pInfo->LastWriteTime);
|
|
|
|
|
|
|
|
pInfo->ChangeTime = pInfo->LastWriteTime;
|
|
|
|
|
|
|
|
if (BooleanFlagOn(DirContext->DirEntry.Fat.Attrib, FILE_ATTRIBUTE_DIRECTORY))
|
|
|
|
{
|
|
|
|
pInfo->EndOfFile.QuadPart = 0;
|
|
|
|
pInfo->AllocationSize.QuadPart = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
1998-12-30 22:48:14 +00:00
|
|
|
|
2017-12-09 09:58:19 +00:00
|
|
|
pInfo->FileAttributes = DirContext->DirEntry.Fat.Attrib & 0x3f;
|
|
|
|
}
|
2012-09-06 18:36:48 +00:00
|
|
|
}
|
1998-12-30 19:01:23 +00:00
|
|
|
|
2017-12-09 09:58:19 +00:00
|
|
|
return Status;
|
1998-12-30 19:01:23 +00:00
|
|
|
}
|
|
|
|
|
2013-12-09 18:48:13 +00:00
|
|
|
static
|
|
|
|
NTSTATUS
|
|
|
|
VfatGetFileFullDirectoryInformation(
|
|
|
|
PVFAT_DIRENTRY_CONTEXT DirContext,
|
|
|
|
PDEVICE_EXTENSION DeviceExt,
|
|
|
|
PFILE_FULL_DIR_INFORMATION pInfo,
|
2017-12-09 09:58:19 +00:00
|
|
|
ULONG BufferLength,
|
|
|
|
PULONG Written,
|
|
|
|
BOOLEAN First)
|
1998-12-30 19:01:23 +00:00
|
|
|
{
|
2017-12-09 09:58:19 +00:00
|
|
|
NTSTATUS Status;
|
|
|
|
ULONG BytesToCopy = 0;
|
1998-12-30 19:01:23 +00:00
|
|
|
|
2017-12-09 09:58:19 +00:00
|
|
|
*Written = 0;
|
|
|
|
Status = STATUS_BUFFER_OVERFLOW;
|
2012-09-06 18:36:48 +00:00
|
|
|
|
2017-12-09 09:58:19 +00:00
|
|
|
if (FIELD_OFFSET(FILE_FULL_DIR_INFORMATION, FileName) > BufferLength)
|
|
|
|
return Status;
|
2012-09-06 18:36:48 +00:00
|
|
|
|
2018-06-07 17:33:23 +00:00
|
|
|
if (First || (BufferLength > FIELD_OFFSET(FILE_FULL_DIR_INFORMATION, FileName) + DirContext->LongNameU.Length))
|
2012-09-06 18:36:48 +00:00
|
|
|
{
|
|
|
|
pInfo->FileNameLength = DirContext->LongNameU.Length;
|
|
|
|
/* pInfo->FileIndex = ; */
|
2017-12-09 09:58:19 +00:00
|
|
|
pInfo->EaSize = 0;
|
2012-09-06 18:36:48 +00:00
|
|
|
|
2017-12-09 09:58:19 +00:00
|
|
|
*Written = FIELD_OFFSET(FILE_FULL_DIR_INFORMATION, FileName);
|
|
|
|
pInfo->NextEntryOffset = 0;
|
|
|
|
if (BufferLength > FIELD_OFFSET(FILE_FULL_DIR_INFORMATION, FileName))
|
2012-09-06 18:36:48 +00:00
|
|
|
{
|
2017-12-09 09:58:19 +00:00
|
|
|
BytesToCopy = min(DirContext->LongNameU.Length, BufferLength - FIELD_OFFSET(FILE_FULL_DIR_INFORMATION, FileName));
|
|
|
|
RtlCopyMemory(pInfo->FileName,
|
|
|
|
DirContext->LongNameU.Buffer,
|
|
|
|
BytesToCopy);
|
|
|
|
*Written += BytesToCopy;
|
|
|
|
|
|
|
|
if (BytesToCopy == DirContext->LongNameU.Length)
|
|
|
|
{
|
|
|
|
pInfo->NextEntryOffset = ULONG_ROUND_UP(sizeof(FILE_FULL_DIR_INFORMATION) +
|
|
|
|
BytesToCopy);
|
|
|
|
Status = STATUS_SUCCESS;
|
|
|
|
}
|
2012-09-06 18:36:48 +00:00
|
|
|
}
|
2017-12-09 09:58:19 +00:00
|
|
|
|
|
|
|
if (vfatVolumeIsFatX(DeviceExt))
|
2012-09-06 18:36:48 +00:00
|
|
|
{
|
2017-12-09 09:58:19 +00:00
|
|
|
FsdDosDateTimeToSystemTime(DeviceExt,
|
|
|
|
DirContext->DirEntry.FatX.CreationDate,
|
|
|
|
DirContext->DirEntry.FatX.CreationTime,
|
|
|
|
&pInfo->CreationTime);
|
|
|
|
FsdDosDateTimeToSystemTime(DeviceExt,
|
|
|
|
DirContext->DirEntry.FatX.AccessDate,
|
|
|
|
DirContext->DirEntry.FatX.AccessTime,
|
|
|
|
&pInfo->LastAccessTime);
|
|
|
|
FsdDosDateTimeToSystemTime(DeviceExt,
|
|
|
|
DirContext->DirEntry.FatX.UpdateDate,
|
|
|
|
DirContext->DirEntry.FatX.UpdateTime,
|
|
|
|
&pInfo->LastWriteTime);
|
|
|
|
|
|
|
|
pInfo->ChangeTime = pInfo->LastWriteTime;
|
2012-09-06 18:36:48 +00:00
|
|
|
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);
|
2017-12-09 09:58:19 +00:00
|
|
|
pInfo->FileAttributes = DirContext->DirEntry.FatX.Attrib & 0x3f;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
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,
|
|
|
|
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->FileAttributes = DirContext->DirEntry.Fat.Attrib & 0x3f;
|
2012-09-06 18:36:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-09 09:58:19 +00:00
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
static
|
|
|
|
NTSTATUS
|
|
|
|
VfatGetFileBothInformation(
|
|
|
|
PVFAT_DIRENTRY_CONTEXT DirContext,
|
|
|
|
PDEVICE_EXTENSION DeviceExt,
|
|
|
|
PFILE_BOTH_DIR_INFORMATION pInfo,
|
|
|
|
ULONG BufferLength,
|
|
|
|
PULONG Written,
|
|
|
|
BOOLEAN First)
|
|
|
|
{
|
|
|
|
NTSTATUS Status;
|
|
|
|
ULONG BytesToCopy = 0;
|
|
|
|
|
|
|
|
*Written = 0;
|
|
|
|
Status = STATUS_BUFFER_OVERFLOW;
|
2012-09-06 18:36:48 +00:00
|
|
|
|
2017-12-09 09:58:19 +00:00
|
|
|
if (FIELD_OFFSET(FILE_BOTH_DIR_INFORMATION, FileName) > BufferLength)
|
|
|
|
return Status;
|
2012-09-06 18:36:48 +00:00
|
|
|
|
2018-06-07 17:33:23 +00:00
|
|
|
if (First || (BufferLength > FIELD_OFFSET(FILE_BOTH_DIR_INFORMATION, FileName) + DirContext->LongNameU.Length))
|
2017-12-09 09:58:19 +00:00
|
|
|
{
|
|
|
|
pInfo->FileNameLength = DirContext->LongNameU.Length;
|
|
|
|
pInfo->EaSize = 0;
|
2012-09-06 18:36:48 +00:00
|
|
|
|
2017-12-09 09:58:19 +00:00
|
|
|
*Written = FIELD_OFFSET(FILE_BOTH_DIR_INFORMATION, FileName);
|
|
|
|
pInfo->NextEntryOffset = 0;
|
|
|
|
if (BufferLength > FIELD_OFFSET(FILE_BOTH_DIR_INFORMATION, FileName))
|
|
|
|
{
|
|
|
|
BytesToCopy = min(DirContext->LongNameU.Length, BufferLength - FIELD_OFFSET(FILE_BOTH_DIR_INFORMATION, FileName));
|
|
|
|
RtlCopyMemory(pInfo->FileName,
|
|
|
|
DirContext->LongNameU.Buffer,
|
|
|
|
BytesToCopy);
|
|
|
|
*Written += BytesToCopy;
|
|
|
|
|
|
|
|
if (BytesToCopy == DirContext->LongNameU.Length)
|
|
|
|
{
|
|
|
|
pInfo->NextEntryOffset = ULONG_ROUND_UP(sizeof(FILE_BOTH_DIR_INFORMATION) +
|
|
|
|
BytesToCopy);
|
|
|
|
Status = STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
2012-09-06 18:36:48 +00:00
|
|
|
|
2017-12-09 09:58:19 +00:00
|
|
|
if (vfatVolumeIsFatX(DeviceExt))
|
2012-09-06 18:36:48 +00:00
|
|
|
{
|
2017-12-09 09:58:19 +00:00
|
|
|
pInfo->ShortName[0] = 0;
|
|
|
|
pInfo->ShortNameLength = 0;
|
|
|
|
/* pInfo->FileIndex = ; */
|
|
|
|
|
|
|
|
FsdDosDateTimeToSystemTime(DeviceExt,
|
|
|
|
DirContext->DirEntry.FatX.CreationDate,
|
|
|
|
DirContext->DirEntry.FatX.CreationTime,
|
|
|
|
&pInfo->CreationTime);
|
|
|
|
FsdDosDateTimeToSystemTime(DeviceExt,
|
|
|
|
DirContext->DirEntry.FatX.AccessDate,
|
|
|
|
DirContext->DirEntry.FatX.AccessTime,
|
|
|
|
&pInfo->LastAccessTime);
|
|
|
|
FsdDosDateTimeToSystemTime(DeviceExt,
|
|
|
|
DirContext->DirEntry.FatX.UpdateDate,
|
|
|
|
DirContext->DirEntry.FatX.UpdateTime,
|
|
|
|
&pInfo->LastWriteTime);
|
|
|
|
|
|
|
|
pInfo->ChangeTime = pInfo->LastWriteTime;
|
|
|
|
|
|
|
|
if (BooleanFlagOn(DirContext->DirEntry.FatX.Attrib, FILE_ATTRIBUTE_DIRECTORY))
|
|
|
|
{
|
|
|
|
pInfo->EndOfFile.QuadPart = 0;
|
|
|
|
pInfo->AllocationSize.QuadPart = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
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->FileAttributes = DirContext->DirEntry.FatX.Attrib & 0x3f;
|
2012-09-06 18:36:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-12-09 09:58:19 +00:00
|
|
|
pInfo->ShortNameLength = (CCHAR)DirContext->ShortNameU.Length;
|
|
|
|
|
2017-12-09 20:22:55 +00:00
|
|
|
ASSERT(pInfo->ShortNameLength / sizeof(WCHAR) <= 12);
|
|
|
|
RtlCopyMemory(pInfo->ShortName,
|
|
|
|
DirContext->ShortNameU.Buffer,
|
|
|
|
DirContext->ShortNameU.Length);
|
2017-12-09 09:58:19 +00:00
|
|
|
|
|
|
|
/* pInfo->FileIndex = ; */
|
|
|
|
|
|
|
|
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,
|
|
|
|
DirContext->DirEntry.Fat.UpdateTime,
|
|
|
|
&pInfo->LastWriteTime);
|
|
|
|
|
|
|
|
pInfo->ChangeTime = pInfo->LastWriteTime;
|
|
|
|
|
|
|
|
if (BooleanFlagOn(DirContext->DirEntry.Fat.Attrib, FILE_ATTRIBUTE_DIRECTORY))
|
|
|
|
{
|
|
|
|
pInfo->EndOfFile.QuadPart = 0;
|
|
|
|
pInfo->AllocationSize.QuadPart = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
2012-09-06 18:36:48 +00:00
|
|
|
|
2017-12-09 09:58:19 +00:00
|
|
|
pInfo->FileAttributes = DirContext->DirEntry.Fat.Attrib & 0x3f;
|
|
|
|
}
|
2012-09-06 18:36:48 +00:00
|
|
|
}
|
|
|
|
|
2017-12-09 09:58:19 +00:00
|
|
|
return Status;
|
2012-09-06 18:36:48 +00:00
|
|
|
}
|
|
|
|
|
2013-12-09 18:48:13 +00:00
|
|
|
static
|
|
|
|
NTSTATUS
|
|
|
|
DoQuery(
|
|
|
|
PVFAT_IRP_CONTEXT IrpContext)
|
2012-09-06 18:36:48 +00:00
|
|
|
{
|
|
|
|
NTSTATUS Status = STATUS_SUCCESS;
|
|
|
|
LONG BufferLength = 0;
|
|
|
|
PUNICODE_STRING pSearchPattern = NULL;
|
|
|
|
FILE_INFORMATION_CLASS FileInformationClass;
|
|
|
|
PUCHAR Buffer = NULL;
|
|
|
|
PFILE_NAMES_INFORMATION Buffer0 = NULL;
|
|
|
|
PVFATFCB pFcb;
|
|
|
|
PVFATCCB pCcb;
|
|
|
|
BOOLEAN FirstQuery = FALSE;
|
|
|
|
BOOLEAN FirstCall = TRUE;
|
|
|
|
VFAT_DIRENTRY_CONTEXT DirContext;
|
|
|
|
WCHAR LongNameBuffer[LONGNAME_MAX_LENGTH + 1];
|
|
|
|
WCHAR ShortNameBuffer[13];
|
2017-12-09 09:58:19 +00:00
|
|
|
ULONG Written;
|
2012-09-06 18:36:48 +00:00
|
|
|
|
|
|
|
PIO_STACK_LOCATION Stack = IrpContext->Stack;
|
|
|
|
|
|
|
|
pCcb = (PVFATCCB)IrpContext->FileObject->FsContext2;
|
|
|
|
pFcb = (PVFATFCB)IrpContext->FileObject->FsContext;
|
|
|
|
|
|
|
|
/* Determine Buffer for result : */
|
|
|
|
BufferLength = Stack->Parameters.QueryDirectory.Length;
|
2003-12-13 14:25:04 +00:00
|
|
|
#if 0
|
2012-09-06 18:36:48 +00:00
|
|
|
/* Do not probe the user buffer until SEH is available */
|
|
|
|
if (IrpContext->Irp->RequestorMode != KernelMode &&
|
|
|
|
IrpContext->Irp->MdlAddress == NULL &&
|
|
|
|
IrpContext->Irp->UserBuffer != NULL)
|
2003-10-11 17:51:56 +00:00
|
|
|
{
|
2012-09-06 18:36:48 +00:00
|
|
|
ProbeForWrite(IrpContext->Irp->UserBuffer, BufferLength, 1);
|
2003-10-11 17:51:56 +00:00
|
|
|
}
|
2003-12-13 14:25:04 +00:00
|
|
|
#endif
|
2015-05-17 12:22:28 +00:00
|
|
|
Buffer = VfatGetUserBuffer(IrpContext->Irp, FALSE);
|
2003-10-11 17:51:56 +00:00
|
|
|
|
2016-09-15 13:12:02 +00:00
|
|
|
if (!ExAcquireResourceExclusiveLite(&IrpContext->DeviceExt->DirResource,
|
|
|
|
BooleanFlagOn(IrpContext->Flags, IRPCONTEXT_CANWAIT)))
|
|
|
|
{
|
|
|
|
Status = VfatLockUserBuffer(IrpContext->Irp, BufferLength, IoWriteAccess);
|
|
|
|
if (NT_SUCCESS(Status))
|
|
|
|
Status = STATUS_PENDING;
|
|
|
|
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
2012-09-06 18:36:48 +00:00
|
|
|
if (!ExAcquireResourceSharedLite(&pFcb->MainResource,
|
2015-05-25 17:30:01 +00:00
|
|
|
BooleanFlagOn(IrpContext->Flags, IRPCONTEXT_CANWAIT)))
|
2003-10-11 17:51:56 +00:00
|
|
|
{
|
2016-09-15 13:12:02 +00:00
|
|
|
ExReleaseResourceLite(&IrpContext->DeviceExt->DirResource);
|
2012-09-06 18:36:48 +00:00
|
|
|
Status = VfatLockUserBuffer(IrpContext->Irp, BufferLength, IoWriteAccess);
|
|
|
|
if (NT_SUCCESS(Status))
|
|
|
|
Status = STATUS_PENDING;
|
|
|
|
|
|
|
|
return Status;
|
2003-10-11 17:51:56 +00:00
|
|
|
}
|
2001-11-02 22:47:36 +00:00
|
|
|
|
2012-09-06 18:36:48 +00:00
|
|
|
/* Obtain the callers parameters */
|
|
|
|
pSearchPattern = (PUNICODE_STRING)Stack->Parameters.QueryDirectory.FileName;
|
|
|
|
FileInformationClass = Stack->Parameters.QueryDirectory.FileInformationClass;
|
|
|
|
|
2012-12-02 16:42:54 +00:00
|
|
|
/* Allocate search pattern in case:
|
|
|
|
* -> We don't have one already in context
|
|
|
|
* -> We have been given an input pattern
|
|
|
|
* -> The pattern length is not null
|
|
|
|
* -> The pattern buffer is not null
|
|
|
|
* Otherwise, we'll fall later and allocate a match all (*) pattern
|
2016-09-15 13:12:02 +00:00
|
|
|
*/
|
2012-12-02 16:42:54 +00:00
|
|
|
if (pSearchPattern &&
|
|
|
|
pSearchPattern->Length != 0 && pSearchPattern->Buffer != NULL)
|
2002-02-05 21:31:03 +00:00
|
|
|
{
|
2012-09-06 18:36:48 +00:00
|
|
|
if (!pCcb->SearchPattern.Buffer)
|
2003-10-11 17:51:56 +00:00
|
|
|
{
|
2012-09-06 18:36:48 +00:00
|
|
|
FirstQuery = TRUE;
|
|
|
|
pCcb->SearchPattern.MaximumLength = pSearchPattern->Length + sizeof(WCHAR);
|
|
|
|
pCcb->SearchPattern.Buffer = ExAllocatePoolWithTag(NonPagedPool,
|
|
|
|
pCcb->SearchPattern.MaximumLength,
|
2018-08-21 06:36:51 +00:00
|
|
|
TAG_SEARCH);
|
2012-09-06 18:36:48 +00:00
|
|
|
if (!pCcb->SearchPattern.Buffer)
|
2003-10-11 17:51:56 +00:00
|
|
|
{
|
2012-09-06 18:36:48 +00:00
|
|
|
ExReleaseResourceLite(&pFcb->MainResource);
|
2016-09-15 13:12:02 +00:00
|
|
|
ExReleaseResourceLite(&IrpContext->DeviceExt->DirResource);
|
2012-09-06 18:36:48 +00:00
|
|
|
return STATUS_INSUFFICIENT_RESOURCES;
|
2003-10-11 17:51:56 +00:00
|
|
|
}
|
2012-09-06 18:36:48 +00:00
|
|
|
RtlCopyUnicodeString(&pCcb->SearchPattern, pSearchPattern);
|
|
|
|
pCcb->SearchPattern.Buffer[pCcb->SearchPattern.Length / sizeof(WCHAR)] = 0;
|
|
|
|
}
|
2000-12-29 23:17:12 +00:00
|
|
|
}
|
2012-09-06 18:36:48 +00:00
|
|
|
else if (!pCcb->SearchPattern.Buffer)
|
2002-02-05 21:31:03 +00:00
|
|
|
{
|
2012-09-06 18:36:48 +00:00
|
|
|
FirstQuery = TRUE;
|
|
|
|
pCcb->SearchPattern.MaximumLength = 2 * sizeof(WCHAR);
|
|
|
|
pCcb->SearchPattern.Buffer = ExAllocatePoolWithTag(NonPagedPool,
|
|
|
|
2 * sizeof(WCHAR),
|
2018-08-21 06:36:51 +00:00
|
|
|
TAG_SEARCH);
|
2012-09-06 18:36:48 +00:00
|
|
|
if (!pCcb->SearchPattern.Buffer)
|
2003-10-11 17:51:56 +00:00
|
|
|
{
|
2012-09-06 18:36:48 +00:00
|
|
|
ExReleaseResourceLite(&pFcb->MainResource);
|
2016-09-15 13:12:02 +00:00
|
|
|
ExReleaseResourceLite(&IrpContext->DeviceExt->DirResource);
|
2012-09-06 18:36:48 +00:00
|
|
|
return STATUS_INSUFFICIENT_RESOURCES;
|
2003-10-11 17:51:56 +00:00
|
|
|
}
|
2012-09-06 18:36:48 +00:00
|
|
|
pCcb->SearchPattern.Buffer[0] = L'*';
|
|
|
|
pCcb->SearchPattern.Buffer[1] = 0;
|
|
|
|
pCcb->SearchPattern.Length = sizeof(WCHAR);
|
2002-02-05 21:31:03 +00:00
|
|
|
}
|
2002-03-18 22:37:13 +00:00
|
|
|
|
2017-02-17 17:58:18 +00:00
|
|
|
if (BooleanFlagOn(IrpContext->Stack->Flags, SL_INDEX_SPECIFIED))
|
2003-10-11 17:51:56 +00:00
|
|
|
{
|
2012-09-06 18:36:48 +00:00
|
|
|
DirContext.DirIndex = pCcb->Entry = Stack->Parameters.QueryDirectory.FileIndex;
|
2003-10-11 17:51:56 +00:00
|
|
|
}
|
2017-02-17 17:58:18 +00:00
|
|
|
else if (FirstQuery || BooleanFlagOn(IrpContext->Stack->Flags, SL_RESTART_SCAN))
|
2003-10-11 17:51:56 +00:00
|
|
|
{
|
2012-09-06 18:36:48 +00:00
|
|
|
DirContext.DirIndex = pCcb->Entry = 0;
|
2003-10-11 17:51:56 +00:00
|
|
|
}
|
2012-09-06 18:36:48 +00:00
|
|
|
else
|
2003-10-11 17:51:56 +00:00
|
|
|
{
|
2012-09-06 18:36:48 +00:00
|
|
|
DirContext.DirIndex = pCcb->Entry;
|
2003-10-11 17:51:56 +00:00
|
|
|
}
|
|
|
|
|
2012-09-06 18:36:48 +00:00
|
|
|
DPRINT("Buffer=%p tofind=%wZ\n", Buffer, &pCcb->SearchPattern);
|
2003-10-11 17:51:56 +00:00
|
|
|
|
2018-05-18 12:03:20 +00:00
|
|
|
DirContext.DeviceExt = IrpContext->DeviceExt;
|
2012-09-06 18:36:48 +00:00
|
|
|
DirContext.LongNameU.Buffer = LongNameBuffer;
|
|
|
|
DirContext.LongNameU.MaximumLength = sizeof(LongNameBuffer);
|
|
|
|
DirContext.ShortNameU.Buffer = ShortNameBuffer;
|
|
|
|
DirContext.ShortNameU.MaximumLength = sizeof(ShortNameBuffer);
|
2002-02-05 21:31:03 +00:00
|
|
|
|
2017-12-09 09:58:19 +00:00
|
|
|
Written = 0;
|
2012-09-06 18:36:48 +00:00
|
|
|
while ((Status == STATUS_SUCCESS) && (BufferLength > 0))
|
1999-01-04 12:02:38 +00:00
|
|
|
{
|
2012-09-06 18:36:48 +00:00
|
|
|
Status = FindFile(IrpContext->DeviceExt,
|
|
|
|
pFcb,
|
|
|
|
&pCcb->SearchPattern,
|
|
|
|
&DirContext,
|
|
|
|
FirstCall);
|
|
|
|
pCcb->Entry = DirContext.DirIndex;
|
|
|
|
|
|
|
|
DPRINT("Found %wZ, Status=%x, entry %x\n", &DirContext.LongNameU, Status, pCcb->Entry);
|
|
|
|
|
|
|
|
FirstCall = FALSE;
|
|
|
|
if (NT_SUCCESS(Status))
|
2003-10-11 17:51:56 +00:00
|
|
|
{
|
2012-09-06 18:36:48 +00:00
|
|
|
switch (FileInformationClass)
|
2003-10-11 17:51:56 +00:00
|
|
|
{
|
2012-09-06 18:36:48 +00:00
|
|
|
case FileDirectoryInformation:
|
|
|
|
Status = VfatGetFileDirectoryInformation(&DirContext,
|
|
|
|
IrpContext->DeviceExt,
|
|
|
|
(PFILE_DIRECTORY_INFORMATION)Buffer,
|
2017-12-09 09:58:19 +00:00
|
|
|
BufferLength,
|
|
|
|
&Written,
|
|
|
|
Buffer0 == NULL);
|
2012-09-06 18:36:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case FileFullDirectoryInformation:
|
|
|
|
Status = VfatGetFileFullDirectoryInformation(&DirContext,
|
|
|
|
IrpContext->DeviceExt,
|
|
|
|
(PFILE_FULL_DIR_INFORMATION)Buffer,
|
2017-12-09 09:58:19 +00:00
|
|
|
BufferLength,
|
|
|
|
&Written,
|
|
|
|
Buffer0 == NULL);
|
2012-09-06 18:36:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case FileBothDirectoryInformation:
|
|
|
|
Status = VfatGetFileBothInformation(&DirContext,
|
|
|
|
IrpContext->DeviceExt,
|
|
|
|
(PFILE_BOTH_DIR_INFORMATION)Buffer,
|
2017-12-09 09:58:19 +00:00
|
|
|
BufferLength,
|
|
|
|
&Written,
|
|
|
|
Buffer0 == NULL);
|
2012-09-06 18:36:48 +00:00
|
|
|
break;
|
|
|
|
|
2017-12-09 11:33:29 +00:00
|
|
|
case FileNamesInformation:
|
|
|
|
Status = VfatGetFileNamesInformation(&DirContext,
|
|
|
|
(PFILE_NAMES_INFORMATION)Buffer,
|
|
|
|
BufferLength,
|
|
|
|
&Written,
|
|
|
|
Buffer0 == NULL);
|
|
|
|
break;
|
|
|
|
|
2012-09-06 18:36:48 +00:00
|
|
|
default:
|
|
|
|
Status = STATUS_INVALID_INFO_CLASS;
|
|
|
|
break;
|
2003-10-11 17:51:56 +00:00
|
|
|
}
|
2012-09-06 18:36:48 +00:00
|
|
|
|
|
|
|
if (Status == STATUS_BUFFER_OVERFLOW || Status == STATUS_INVALID_INFO_CLASS)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
2002-02-05 21:31:03 +00:00
|
|
|
{
|
2012-09-06 18:36:48 +00:00
|
|
|
Status = (FirstQuery ? STATUS_NO_SUCH_FILE : STATUS_NO_MORE_FILES);
|
|
|
|
break;
|
2002-02-05 21:31:03 +00:00
|
|
|
}
|
2012-09-06 18:36:48 +00:00
|
|
|
|
|
|
|
Buffer0 = (PFILE_NAMES_INFORMATION) Buffer;
|
|
|
|
Buffer0->FileIndex = DirContext.DirIndex;
|
|
|
|
pCcb->Entry = ++DirContext.DirIndex;
|
|
|
|
BufferLength -= Buffer0->NextEntryOffset;
|
|
|
|
|
2017-02-17 17:58:18 +00:00
|
|
|
if (BooleanFlagOn(IrpContext->Stack->Flags, SL_RETURN_SINGLE_ENTRY))
|
2012-09-06 18:36:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
Buffer += Buffer0->NextEntryOffset;
|
1998-12-30 19:01:23 +00:00
|
|
|
}
|
2005-05-05 11:05:05 +00:00
|
|
|
|
2012-09-06 18:36:48 +00:00
|
|
|
if (Buffer0)
|
|
|
|
{
|
|
|
|
Buffer0->NextEntryOffset = 0;
|
|
|
|
Status = STATUS_SUCCESS;
|
|
|
|
IrpContext->Irp->IoStatus.Information = Stack->Parameters.QueryDirectory.Length - BufferLength;
|
1998-12-30 19:01:23 +00:00
|
|
|
}
|
2017-12-09 09:58:19 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
ASSERT(Status != STATUS_SUCCESS || BufferLength == 0);
|
|
|
|
ASSERT(Written <= Stack->Parameters.QueryDirectory.Length);
|
|
|
|
IrpContext->Irp->IoStatus.Information = Written;
|
|
|
|
}
|
2012-09-06 18:36:48 +00:00
|
|
|
|
|
|
|
ExReleaseResourceLite(&pFcb->MainResource);
|
2016-09-15 13:12:02 +00:00
|
|
|
ExReleaseResourceLite(&IrpContext->DeviceExt->DirResource);
|
2012-09-06 18:36:48 +00:00
|
|
|
|
|
|
|
return Status;
|
1998-12-30 19:01:23 +00:00
|
|
|
}
|
|
|
|
|
2015-05-15 16:03:29 +00:00
|
|
|
NTSTATUS VfatNotifyChangeDirectory(PVFAT_IRP_CONTEXT IrpContext)
|
2014-03-07 19:42:54 +00:00
|
|
|
{
|
|
|
|
PVCB pVcb;
|
|
|
|
PVFATFCB pFcb;
|
|
|
|
PIO_STACK_LOCATION Stack;
|
2015-05-15 16:03:29 +00:00
|
|
|
Stack = IrpContext->Stack;
|
|
|
|
pVcb = IrpContext->DeviceExt;
|
|
|
|
pFcb = (PVFATFCB) IrpContext->FileObject->FsContext;
|
2016-09-15 13:12:02 +00:00
|
|
|
|
2014-03-07 19:42:54 +00:00
|
|
|
FsRtlNotifyFullChangeDirectory(pVcb->NotifySync,
|
|
|
|
&(pVcb->NotifyList),
|
2015-05-15 16:03:29 +00:00
|
|
|
IrpContext->FileObject->FsContext2,
|
2014-03-07 19:42:54 +00:00
|
|
|
(PSTRING)&(pFcb->PathNameU),
|
|
|
|
BooleanFlagOn(Stack->Flags, SL_WATCH_TREE),
|
|
|
|
FALSE,
|
|
|
|
Stack->Parameters.NotifyDirectory.CompletionFilter,
|
2015-05-15 16:03:29 +00:00
|
|
|
IrpContext->Irp,
|
2014-03-07 19:42:54 +00:00
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
|
2015-05-15 16:03:29 +00:00
|
|
|
/* We won't handle IRP completion */
|
|
|
|
IrpContext->Flags &= ~IRPCONTEXT_COMPLETE;
|
2014-03-07 19:42:54 +00:00
|
|
|
|
|
|
|
return STATUS_PENDING;
|
|
|
|
}
|
1998-12-30 19:01:23 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* FUNCTION: directory control : read/write directory informations
|
|
|
|
*/
|
2012-09-06 18:36:48 +00:00
|
|
|
NTSTATUS
|
2013-12-09 18:48:13 +00:00
|
|
|
VfatDirectoryControl(
|
|
|
|
PVFAT_IRP_CONTEXT IrpContext)
|
1998-12-30 19:01:23 +00:00
|
|
|
{
|
2012-09-06 18:36:48 +00:00
|
|
|
NTSTATUS Status = STATUS_SUCCESS;
|
|
|
|
|
|
|
|
IrpContext->Irp->IoStatus.Information = 0;
|
|
|
|
|
|
|
|
switch (IrpContext->MinorFunction)
|
2000-12-29 23:17:12 +00:00
|
|
|
{
|
2012-09-06 18:36:48 +00:00
|
|
|
case IRP_MN_QUERY_DIRECTORY:
|
|
|
|
Status = DoQuery (IrpContext);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IRP_MN_NOTIFY_CHANGE_DIRECTORY:
|
2015-05-15 16:03:29 +00:00
|
|
|
Status = VfatNotifyChangeDirectory(IrpContext);
|
2012-09-06 18:36:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
/* Error */
|
|
|
|
DPRINT("Unexpected minor function %x in VFAT driver\n",
|
|
|
|
IrpContext->MinorFunction);
|
|
|
|
Status = STATUS_INVALID_DEVICE_REQUEST;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2017-02-17 17:58:18 +00:00
|
|
|
if (Status == STATUS_PENDING && BooleanFlagOn(IrpContext->Flags, IRPCONTEXT_COMPLETE))
|
2012-09-06 18:36:48 +00:00
|
|
|
{
|
2015-05-15 16:03:29 +00:00
|
|
|
return VfatMarkIrpContextForQueue(IrpContext);
|
2000-12-29 23:17:12 +00:00
|
|
|
}
|
2001-07-05 01:51:53 +00:00
|
|
|
|
2012-09-06 18:36:48 +00:00
|
|
|
return Status;
|
|
|
|
}
|
2001-07-05 01:51:53 +00:00
|
|
|
|
2012-12-02 16:42:54 +00:00
|
|
|
/* EOF */
|