2004-08-01 21:57:18 +00:00
|
|
|
/* $Id: direntry.c,v 1.17 2004/08/01 21:57:17 navaraf Exp $
|
2001-07-05 01:51:53 +00:00
|
|
|
*
|
|
|
|
*
|
|
|
|
* FILE: DirEntry.c
|
|
|
|
* PURPOSE: Routines to manipulate directory entries.
|
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS kernel
|
|
|
|
* PROGRAMMER: Jason Filby (jasonfilby@yahoo.com)
|
|
|
|
* Rex Jolliff (rex@lvcablemodem.com)
|
2003-10-11 17:51:56 +00:00
|
|
|
* Hartmut Birr
|
2001-07-05 01:51:53 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* ------------------------------------------------------- INCLUDES */
|
|
|
|
|
|
|
|
#include <ddk/ntddk.h>
|
|
|
|
#include <wchar.h>
|
|
|
|
#include <limits.h>
|
|
|
|
|
|
|
|
#define NDEBUG
|
|
|
|
#include <debug.h>
|
|
|
|
|
|
|
|
#include "vfat.h"
|
|
|
|
|
* Used look aside lists to allocate memory for VFATFCB, VFATCCB and VFAT_IRP_CONTEXT.
* Removed IsLastEntry, IsVolEntry, IsDeletedEntry, vfat_wstrlen, vfatGrabFCB,
vfat_initstr, vfat_wcsncat, vfat_wcsncpy, vfat_movestr, wstrcmpi and replaced
this functions with existing equivalents or functions from ntoskrnl.
* Merged GetEntryName into vfatGetNextDirEntry for reducing some overhead.
* Implemented a file name cache to speed up the searching for existing fcb.
* Removed some calls to FsdDosDateTimeToFileTime.
* Moved the call to CcZeroData behind the initializing of the cache (in VfatWrite).
* Using existing fcbs in FindFile if there is no '*?' within the search name.
svn path=/trunk/; revision=3740
2002-11-11 21:49:18 +00:00
|
|
|
#define ENTRIES_PER_PAGE (PAGE_SIZE / sizeof (FATDirEntry))
|
2001-07-05 01:51:53 +00:00
|
|
|
|
|
|
|
ULONG
|
|
|
|
vfatDirEntryGetFirstCluster (PDEVICE_EXTENSION pDeviceExt,
|
|
|
|
PFAT_DIR_ENTRY pFatDirEntry)
|
|
|
|
{
|
|
|
|
ULONG cluster;
|
|
|
|
|
2002-03-18 22:37:13 +00:00
|
|
|
if (pDeviceExt->FatInfo.FatType == FAT32)
|
2001-07-05 01:51:53 +00:00
|
|
|
{
|
|
|
|
cluster = pFatDirEntry->FirstCluster +
|
|
|
|
pFatDirEntry->FirstClusterHigh * 65536;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cluster = pFatDirEntry->FirstCluster;
|
|
|
|
}
|
|
|
|
|
|
|
|
return cluster;
|
|
|
|
}
|
|
|
|
|
2003-10-11 17:51:56 +00:00
|
|
|
BOOL VfatIsDirectoryEmpty(PVFATFCB Fcb)
|
2001-07-05 01:51:53 +00:00
|
|
|
{
|
2003-10-11 17:51:56 +00:00
|
|
|
LARGE_INTEGER FileOffset;
|
|
|
|
PVOID Context = NULL;
|
|
|
|
PFAT_DIR_ENTRY FatDirEntry;
|
|
|
|
ULONG Index, MaxIndex;
|
|
|
|
|
|
|
|
if (vfatFCBIsRoot(Fcb))
|
|
|
|
{
|
|
|
|
Index = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Index = 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
FileOffset.QuadPart = 0LL;
|
|
|
|
MaxIndex = Fcb->RFCB.FileSize.u.LowPart / sizeof(FAT_DIR_ENTRY);
|
|
|
|
|
|
|
|
while (Index < MaxIndex)
|
|
|
|
{
|
|
|
|
if (Context == NULL || (Index % ENTRIES_PER_PAGE) == 0)
|
|
|
|
{
|
|
|
|
if (Context != NULL)
|
|
|
|
{
|
|
|
|
CcUnpinData(Context);
|
|
|
|
}
|
|
|
|
if (!CcMapData(Fcb->FileObject, &FileOffset, PAGE_SIZE, TRUE, &Context, (PVOID*)&FatDirEntry))
|
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
FatDirEntry += Index % ENTRIES_PER_PAGE;
|
|
|
|
}
|
|
|
|
if (ENTRY_END(FatDirEntry))
|
|
|
|
{
|
|
|
|
CcUnpinData(Context);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
if (!ENTRY_DELETED(FatDirEntry))
|
|
|
|
{
|
|
|
|
CcUnpinData(Context);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
Index++;
|
|
|
|
FatDirEntry++;
|
|
|
|
}
|
|
|
|
if (Context)
|
|
|
|
{
|
|
|
|
CcUnpinData(Context);
|
|
|
|
}
|
|
|
|
return TRUE;
|
2001-07-05 01:51:53 +00:00
|
|
|
}
|
|
|
|
|
* Used look aside lists to allocate memory for VFATFCB, VFATCCB and VFAT_IRP_CONTEXT.
* Removed IsLastEntry, IsVolEntry, IsDeletedEntry, vfat_wstrlen, vfatGrabFCB,
vfat_initstr, vfat_wcsncat, vfat_wcsncpy, vfat_movestr, wstrcmpi and replaced
this functions with existing equivalents or functions from ntoskrnl.
* Merged GetEntryName into vfatGetNextDirEntry for reducing some overhead.
* Implemented a file name cache to speed up the searching for existing fcb.
* Removed some calls to FsdDosDateTimeToFileTime.
* Moved the call to CcZeroData behind the initializing of the cache (in VfatWrite).
* Using existing fcbs in FindFile if there is no '*?' within the search name.
svn path=/trunk/; revision=3740
2002-11-11 21:49:18 +00:00
|
|
|
NTSTATUS vfatGetNextDirEntry(PVOID * pContext,
|
|
|
|
PVOID * pPage,
|
2003-10-11 17:51:56 +00:00
|
|
|
IN PVFATFCB pDirFcb,
|
|
|
|
PVFAT_DIRENTRY_CONTEXT DirContext,
|
|
|
|
BOOLEAN First)
|
* Used look aside lists to allocate memory for VFATFCB, VFATCCB and VFAT_IRP_CONTEXT.
* Removed IsLastEntry, IsVolEntry, IsDeletedEntry, vfat_wstrlen, vfatGrabFCB,
vfat_initstr, vfat_wcsncat, vfat_wcsncpy, vfat_movestr, wstrcmpi and replaced
this functions with existing equivalents or functions from ntoskrnl.
* Merged GetEntryName into vfatGetNextDirEntry for reducing some overhead.
* Implemented a file name cache to speed up the searching for existing fcb.
* Removed some calls to FsdDosDateTimeToFileTime.
* Moved the call to CcZeroData behind the initializing of the cache (in VfatWrite).
* Using existing fcbs in FindFile if there is no '*?' within the search name.
svn path=/trunk/; revision=3740
2002-11-11 21:49:18 +00:00
|
|
|
{
|
|
|
|
ULONG dirMap;
|
|
|
|
PWCHAR pName;
|
|
|
|
LARGE_INTEGER FileOffset;
|
|
|
|
FATDirEntry * fatDirEntry;
|
|
|
|
slot * longNameEntry;
|
|
|
|
ULONG index;
|
2003-10-11 17:51:56 +00:00
|
|
|
|
|
|
|
UCHAR CheckSum, shortCheckSum;
|
|
|
|
USHORT i;
|
|
|
|
BOOLEAN Valid = TRUE;
|
|
|
|
BOOLEAN Back = FALSE;
|
* Used look aside lists to allocate memory for VFATFCB, VFATCCB and VFAT_IRP_CONTEXT.
* Removed IsLastEntry, IsVolEntry, IsDeletedEntry, vfat_wstrlen, vfatGrabFCB,
vfat_initstr, vfat_wcsncat, vfat_wcsncpy, vfat_movestr, wstrcmpi and replaced
this functions with existing equivalents or functions from ntoskrnl.
* Merged GetEntryName into vfatGetNextDirEntry for reducing some overhead.
* Implemented a file name cache to speed up the searching for existing fcb.
* Removed some calls to FsdDosDateTimeToFileTime.
* Moved the call to CcZeroData behind the initializing of the cache (in VfatWrite).
* Using existing fcbs in FindFile if there is no '*?' within the search name.
svn path=/trunk/; revision=3740
2002-11-11 21:49:18 +00:00
|
|
|
|
2003-10-11 17:51:56 +00:00
|
|
|
DirContext->LongNameU.Buffer[0] = 0;
|
* Used look aside lists to allocate memory for VFATFCB, VFATCCB and VFAT_IRP_CONTEXT.
* Removed IsLastEntry, IsVolEntry, IsDeletedEntry, vfat_wstrlen, vfatGrabFCB,
vfat_initstr, vfat_wcsncat, vfat_wcsncpy, vfat_movestr, wstrcmpi and replaced
this functions with existing equivalents or functions from ntoskrnl.
* Merged GetEntryName into vfatGetNextDirEntry for reducing some overhead.
* Implemented a file name cache to speed up the searching for existing fcb.
* Removed some calls to FsdDosDateTimeToFileTime.
* Moved the call to CcZeroData behind the initializing of the cache (in VfatWrite).
* Using existing fcbs in FindFile if there is no '*?' within the search name.
svn path=/trunk/; revision=3740
2002-11-11 21:49:18 +00:00
|
|
|
|
|
|
|
FileOffset.u.HighPart = 0;
|
2003-10-11 17:51:56 +00:00
|
|
|
FileOffset.u.LowPart = ROUND_DOWN(DirContext->DirIndex * sizeof(FATDirEntry), PAGE_SIZE);
|
* Used look aside lists to allocate memory for VFATFCB, VFATCCB and VFAT_IRP_CONTEXT.
* Removed IsLastEntry, IsVolEntry, IsDeletedEntry, vfat_wstrlen, vfatGrabFCB,
vfat_initstr, vfat_wcsncat, vfat_wcsncpy, vfat_movestr, wstrcmpi and replaced
this functions with existing equivalents or functions from ntoskrnl.
* Merged GetEntryName into vfatGetNextDirEntry for reducing some overhead.
* Implemented a file name cache to speed up the searching for existing fcb.
* Removed some calls to FsdDosDateTimeToFileTime.
* Moved the call to CcZeroData behind the initializing of the cache (in VfatWrite).
* Using existing fcbs in FindFile if there is no '*?' within the search name.
svn path=/trunk/; revision=3740
2002-11-11 21:49:18 +00:00
|
|
|
|
2003-10-11 17:51:56 +00:00
|
|
|
if (*pContext == NULL || (DirContext->DirIndex % ENTRIES_PER_PAGE) == 0)
|
2001-07-05 01:51:53 +00:00
|
|
|
{
|
* Used look aside lists to allocate memory for VFATFCB, VFATCCB and VFAT_IRP_CONTEXT.
* Removed IsLastEntry, IsVolEntry, IsDeletedEntry, vfat_wstrlen, vfatGrabFCB,
vfat_initstr, vfat_wcsncat, vfat_wcsncpy, vfat_movestr, wstrcmpi and replaced
this functions with existing equivalents or functions from ntoskrnl.
* Merged GetEntryName into vfatGetNextDirEntry for reducing some overhead.
* Implemented a file name cache to speed up the searching for existing fcb.
* Removed some calls to FsdDosDateTimeToFileTime.
* Moved the call to CcZeroData behind the initializing of the cache (in VfatWrite).
* Using existing fcbs in FindFile if there is no '*?' within the search name.
svn path=/trunk/; revision=3740
2002-11-11 21:49:18 +00:00
|
|
|
if (*pContext != NULL)
|
|
|
|
{
|
|
|
|
CcUnpinData(*pContext);
|
|
|
|
}
|
|
|
|
if (!CcMapData(pDirFcb->FileObject, &FileOffset, PAGE_SIZE, TRUE, pContext, pPage))
|
|
|
|
{
|
|
|
|
*pContext = NULL;
|
|
|
|
return STATUS_NO_MORE_ENTRIES;
|
|
|
|
}
|
2001-07-05 01:51:53 +00:00
|
|
|
}
|
* Used look aside lists to allocate memory for VFATFCB, VFATCCB and VFAT_IRP_CONTEXT.
* Removed IsLastEntry, IsVolEntry, IsDeletedEntry, vfat_wstrlen, vfatGrabFCB,
vfat_initstr, vfat_wcsncat, vfat_wcsncpy, vfat_movestr, wstrcmpi and replaced
this functions with existing equivalents or functions from ntoskrnl.
* Merged GetEntryName into vfatGetNextDirEntry for reducing some overhead.
* Implemented a file name cache to speed up the searching for existing fcb.
* Removed some calls to FsdDosDateTimeToFileTime.
* Moved the call to CcZeroData behind the initializing of the cache (in VfatWrite).
* Using existing fcbs in FindFile if there is no '*?' within the search name.
svn path=/trunk/; revision=3740
2002-11-11 21:49:18 +00:00
|
|
|
|
|
|
|
|
2003-10-11 17:51:56 +00:00
|
|
|
fatDirEntry = (FATDirEntry*)(*pPage) + DirContext->DirIndex % ENTRIES_PER_PAGE;
|
* Used look aside lists to allocate memory for VFATFCB, VFATCCB and VFAT_IRP_CONTEXT.
* Removed IsLastEntry, IsVolEntry, IsDeletedEntry, vfat_wstrlen, vfatGrabFCB,
vfat_initstr, vfat_wcsncat, vfat_wcsncpy, vfat_movestr, wstrcmpi and replaced
this functions with existing equivalents or functions from ntoskrnl.
* Merged GetEntryName into vfatGetNextDirEntry for reducing some overhead.
* Implemented a file name cache to speed up the searching for existing fcb.
* Removed some calls to FsdDosDateTimeToFileTime.
* Moved the call to CcZeroData behind the initializing of the cache (in VfatWrite).
* Using existing fcbs in FindFile if there is no '*?' within the search name.
svn path=/trunk/; revision=3740
2002-11-11 21:49:18 +00:00
|
|
|
longNameEntry = (slot*) fatDirEntry;
|
|
|
|
dirMap = 0;
|
|
|
|
|
2003-10-11 17:51:56 +00:00
|
|
|
if (First)
|
|
|
|
{
|
|
|
|
/* This is the first call to vfatGetNextDirEntry. Possible the start index points
|
|
|
|
* into a long name or points to a short name with an assigned long name.
|
|
|
|
* We must go back to the real start of the entry */
|
|
|
|
while (DirContext->DirIndex > 0 &&
|
|
|
|
!ENTRY_END(fatDirEntry) &&
|
|
|
|
!ENTRY_DELETED(fatDirEntry) &&
|
|
|
|
((!ENTRY_LONG(fatDirEntry) && !Back) ||
|
|
|
|
(ENTRY_LONG(fatDirEntry) && !(longNameEntry->id & 0x40))))
|
|
|
|
{
|
|
|
|
DirContext->DirIndex--;
|
|
|
|
Back = TRUE;
|
|
|
|
if ((DirContext->DirIndex % ENTRIES_PER_PAGE) == ENTRIES_PER_PAGE - 1)
|
|
|
|
{
|
|
|
|
CcUnpinData(*pContext);
|
|
|
|
FileOffset.u.LowPart -= PAGE_SIZE;
|
|
|
|
if (!CcMapData(pDirFcb->FileObject, &FileOffset, PAGE_SIZE, TRUE, pContext, pPage))
|
|
|
|
{
|
|
|
|
CHECKPOINT;
|
|
|
|
*pContext = NULL;
|
|
|
|
return STATUS_NO_MORE_ENTRIES;
|
|
|
|
}
|
|
|
|
fatDirEntry = (FATDirEntry*)(*pPage) + DirContext->DirIndex % ENTRIES_PER_PAGE;
|
|
|
|
longNameEntry = (slot*) fatDirEntry;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
fatDirEntry--;
|
|
|
|
longNameEntry--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-10-19 17:07:58 +00:00
|
|
|
if (Back && !ENTRY_END(fatDirEntry) &&
|
2003-10-11 17:51:56 +00:00
|
|
|
(ENTRY_DELETED(fatDirEntry) || !ENTRY_LONG(fatDirEntry)))
|
|
|
|
{
|
|
|
|
DirContext->DirIndex++;
|
|
|
|
if ((DirContext->DirIndex % ENTRIES_PER_PAGE) == 0)
|
|
|
|
{
|
|
|
|
CcUnpinData(*pContext);
|
|
|
|
FileOffset.u.LowPart += PAGE_SIZE;
|
|
|
|
if (!CcMapData(pDirFcb->FileObject, &FileOffset, PAGE_SIZE, TRUE, pContext, pPage))
|
|
|
|
{
|
|
|
|
CHECKPOINT;
|
|
|
|
*pContext = NULL;
|
|
|
|
return STATUS_NO_MORE_ENTRIES;
|
|
|
|
}
|
|
|
|
fatDirEntry = (FATDirEntry*)*pPage;
|
|
|
|
longNameEntry = (slot*) *pPage;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
fatDirEntry++;
|
|
|
|
longNameEntry++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DirContext->StartIndex = DirContext->DirIndex;
|
|
|
|
CheckSum = 0;
|
* Used look aside lists to allocate memory for VFATFCB, VFATCCB and VFAT_IRP_CONTEXT.
* Removed IsLastEntry, IsVolEntry, IsDeletedEntry, vfat_wstrlen, vfatGrabFCB,
vfat_initstr, vfat_wcsncat, vfat_wcsncpy, vfat_movestr, wstrcmpi and replaced
this functions with existing equivalents or functions from ntoskrnl.
* Merged GetEntryName into vfatGetNextDirEntry for reducing some overhead.
* Implemented a file name cache to speed up the searching for existing fcb.
* Removed some calls to FsdDosDateTimeToFileTime.
* Moved the call to CcZeroData behind the initializing of the cache (in VfatWrite).
* Using existing fcbs in FindFile if there is no '*?' within the search name.
svn path=/trunk/; revision=3740
2002-11-11 21:49:18 +00:00
|
|
|
|
|
|
|
while (TRUE)
|
2003-10-11 17:51:56 +00:00
|
|
|
{
|
|
|
|
if (ENTRY_END(fatDirEntry))
|
|
|
|
{
|
* Used look aside lists to allocate memory for VFATFCB, VFATCCB and VFAT_IRP_CONTEXT.
* Removed IsLastEntry, IsVolEntry, IsDeletedEntry, vfat_wstrlen, vfatGrabFCB,
vfat_initstr, vfat_wcsncat, vfat_wcsncpy, vfat_movestr, wstrcmpi and replaced
this functions with existing equivalents or functions from ntoskrnl.
* Merged GetEntryName into vfatGetNextDirEntry for reducing some overhead.
* Implemented a file name cache to speed up the searching for existing fcb.
* Removed some calls to FsdDosDateTimeToFileTime.
* Moved the call to CcZeroData behind the initializing of the cache (in VfatWrite).
* Using existing fcbs in FindFile if there is no '*?' within the search name.
svn path=/trunk/; revision=3740
2002-11-11 21:49:18 +00:00
|
|
|
CcUnpinData(*pContext);
|
|
|
|
*pContext = NULL;
|
|
|
|
return STATUS_NO_MORE_ENTRIES;
|
2003-10-11 17:51:56 +00:00
|
|
|
}
|
* Used look aside lists to allocate memory for VFATFCB, VFATCCB and VFAT_IRP_CONTEXT.
* Removed IsLastEntry, IsVolEntry, IsDeletedEntry, vfat_wstrlen, vfatGrabFCB,
vfat_initstr, vfat_wcsncat, vfat_wcsncpy, vfat_movestr, wstrcmpi and replaced
this functions with existing equivalents or functions from ntoskrnl.
* Merged GetEntryName into vfatGetNextDirEntry for reducing some overhead.
* Implemented a file name cache to speed up the searching for existing fcb.
* Removed some calls to FsdDosDateTimeToFileTime.
* Moved the call to CcZeroData behind the initializing of the cache (in VfatWrite).
* Using existing fcbs in FindFile if there is no '*?' within the search name.
svn path=/trunk/; revision=3740
2002-11-11 21:49:18 +00:00
|
|
|
|
2003-10-11 17:51:56 +00:00
|
|
|
if (ENTRY_DELETED(fatDirEntry))
|
|
|
|
{
|
* Used look aside lists to allocate memory for VFATFCB, VFATCCB and VFAT_IRP_CONTEXT.
* Removed IsLastEntry, IsVolEntry, IsDeletedEntry, vfat_wstrlen, vfatGrabFCB,
vfat_initstr, vfat_wcsncat, vfat_wcsncpy, vfat_movestr, wstrcmpi and replaced
this functions with existing equivalents or functions from ntoskrnl.
* Merged GetEntryName into vfatGetNextDirEntry for reducing some overhead.
* Implemented a file name cache to speed up the searching for existing fcb.
* Removed some calls to FsdDosDateTimeToFileTime.
* Moved the call to CcZeroData behind the initializing of the cache (in VfatWrite).
* Using existing fcbs in FindFile if there is no '*?' within the search name.
svn path=/trunk/; revision=3740
2002-11-11 21:49:18 +00:00
|
|
|
dirMap = 0;
|
2003-10-11 17:51:56 +00:00
|
|
|
DirContext->LongNameU.Buffer[0] = 0;
|
|
|
|
DirContext->StartIndex = DirContext->DirIndex + 1;
|
|
|
|
}
|
* Used look aside lists to allocate memory for VFATFCB, VFATCCB and VFAT_IRP_CONTEXT.
* Removed IsLastEntry, IsVolEntry, IsDeletedEntry, vfat_wstrlen, vfatGrabFCB,
vfat_initstr, vfat_wcsncat, vfat_wcsncpy, vfat_movestr, wstrcmpi and replaced
this functions with existing equivalents or functions from ntoskrnl.
* Merged GetEntryName into vfatGetNextDirEntry for reducing some overhead.
* Implemented a file name cache to speed up the searching for existing fcb.
* Removed some calls to FsdDosDateTimeToFileTime.
* Moved the call to CcZeroData behind the initializing of the cache (in VfatWrite).
* Using existing fcbs in FindFile if there is no '*?' within the search name.
svn path=/trunk/; revision=3740
2002-11-11 21:49:18 +00:00
|
|
|
else
|
2003-10-11 17:51:56 +00:00
|
|
|
{
|
|
|
|
if (ENTRY_LONG(fatDirEntry))
|
|
|
|
{
|
* Used look aside lists to allocate memory for VFATFCB, VFATCCB and VFAT_IRP_CONTEXT.
* Removed IsLastEntry, IsVolEntry, IsDeletedEntry, vfat_wstrlen, vfatGrabFCB,
vfat_initstr, vfat_wcsncat, vfat_wcsncpy, vfat_movestr, wstrcmpi and replaced
this functions with existing equivalents or functions from ntoskrnl.
* Merged GetEntryName into vfatGetNextDirEntry for reducing some overhead.
* Implemented a file name cache to speed up the searching for existing fcb.
* Removed some calls to FsdDosDateTimeToFileTime.
* Moved the call to CcZeroData behind the initializing of the cache (in VfatWrite).
* Using existing fcbs in FindFile if there is no '*?' within the search name.
svn path=/trunk/; revision=3740
2002-11-11 21:49:18 +00:00
|
|
|
if (dirMap == 0)
|
2003-10-11 17:51:56 +00:00
|
|
|
{
|
|
|
|
DPRINT (" long name entry found at %d\n", DirContext->DirIndex);
|
|
|
|
memset(DirContext->LongNameU.Buffer, 0, DirContext->LongNameU.MaximumLength);
|
|
|
|
CheckSum = longNameEntry->alias_checksum;
|
|
|
|
Valid = TRUE;
|
|
|
|
}
|
* Used look aside lists to allocate memory for VFATFCB, VFATCCB and VFAT_IRP_CONTEXT.
* Removed IsLastEntry, IsVolEntry, IsDeletedEntry, vfat_wstrlen, vfatGrabFCB,
vfat_initstr, vfat_wcsncat, vfat_wcsncpy, vfat_movestr, wstrcmpi and replaced
this functions with existing equivalents or functions from ntoskrnl.
* Merged GetEntryName into vfatGetNextDirEntry for reducing some overhead.
* Implemented a file name cache to speed up the searching for existing fcb.
* Removed some calls to FsdDosDateTimeToFileTime.
* Moved the call to CcZeroData behind the initializing of the cache (in VfatWrite).
* Using existing fcbs in FindFile if there is no '*?' within the search name.
svn path=/trunk/; revision=3740
2002-11-11 21:49:18 +00:00
|
|
|
|
|
|
|
DPRINT (" name chunk1:[%.*S] chunk2:[%.*S] chunk3:[%.*S]\n",
|
|
|
|
5, longNameEntry->name0_4,
|
|
|
|
6, longNameEntry->name5_10,
|
|
|
|
2, longNameEntry->name11_12);
|
|
|
|
|
|
|
|
index = (longNameEntry->id & 0x1f) - 1;
|
|
|
|
dirMap |= 1 << index;
|
2003-10-11 17:51:56 +00:00
|
|
|
pName = DirContext->LongNameU.Buffer + 13 * index;
|
* Used look aside lists to allocate memory for VFATFCB, VFATCCB and VFAT_IRP_CONTEXT.
* Removed IsLastEntry, IsVolEntry, IsDeletedEntry, vfat_wstrlen, vfatGrabFCB,
vfat_initstr, vfat_wcsncat, vfat_wcsncpy, vfat_movestr, wstrcmpi and replaced
this functions with existing equivalents or functions from ntoskrnl.
* Merged GetEntryName into vfatGetNextDirEntry for reducing some overhead.
* Implemented a file name cache to speed up the searching for existing fcb.
* Removed some calls to FsdDosDateTimeToFileTime.
* Moved the call to CcZeroData behind the initializing of the cache (in VfatWrite).
* Using existing fcbs in FindFile if there is no '*?' within the search name.
svn path=/trunk/; revision=3740
2002-11-11 21:49:18 +00:00
|
|
|
|
|
|
|
memcpy(pName, longNameEntry->name0_4, 5 * sizeof(WCHAR));
|
|
|
|
memcpy(pName + 5, longNameEntry->name5_10, 6 * sizeof(WCHAR));
|
|
|
|
memcpy(pName + 11, longNameEntry->name11_12, 2 * sizeof(WCHAR));
|
|
|
|
|
2003-10-11 17:51:56 +00:00
|
|
|
DPRINT (" longName: [%S]\n", DirContext->LongNameU.Buffer);
|
|
|
|
if (CheckSum != longNameEntry->alias_checksum)
|
|
|
|
{
|
|
|
|
DPRINT1("Found wrong alias checksum in long name entry (first %x, current %x, %S)\n",
|
|
|
|
CheckSum, longNameEntry->alias_checksum, DirContext->LongNameU.Buffer);
|
|
|
|
Valid = FALSE;
|
|
|
|
}
|
|
|
|
}
|
* Used look aside lists to allocate memory for VFATFCB, VFATCCB and VFAT_IRP_CONTEXT.
* Removed IsLastEntry, IsVolEntry, IsDeletedEntry, vfat_wstrlen, vfatGrabFCB,
vfat_initstr, vfat_wcsncat, vfat_wcsncpy, vfat_movestr, wstrcmpi and replaced
this functions with existing equivalents or functions from ntoskrnl.
* Merged GetEntryName into vfatGetNextDirEntry for reducing some overhead.
* Implemented a file name cache to speed up the searching for existing fcb.
* Removed some calls to FsdDosDateTimeToFileTime.
* Moved the call to CcZeroData behind the initializing of the cache (in VfatWrite).
* Using existing fcbs in FindFile if there is no '*?' within the search name.
svn path=/trunk/; revision=3740
2002-11-11 21:49:18 +00:00
|
|
|
else
|
2003-10-11 17:51:56 +00:00
|
|
|
{
|
|
|
|
shortCheckSum = 0;
|
|
|
|
for (i = 0; i < 11; i++)
|
|
|
|
{
|
|
|
|
shortCheckSum = (((shortCheckSum & 1) << 7)
|
|
|
|
| ((shortCheckSum & 0xfe) >> 1))
|
|
|
|
+ fatDirEntry->Filename[i];
|
|
|
|
}
|
|
|
|
if (shortCheckSum != CheckSum && DirContext->LongNameU.Buffer[0])
|
|
|
|
{
|
|
|
|
DPRINT1("Checksum from long and short name is not equal (short: %x, long: %x, %S)\n",
|
|
|
|
shortCheckSum, CheckSum, DirContext->LongNameU.Buffer);
|
|
|
|
DirContext->LongNameU.Buffer[0] = 0;
|
|
|
|
}
|
|
|
|
if (Valid == FALSE)
|
|
|
|
{
|
|
|
|
DirContext->LongNameU.Buffer[0] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
memcpy (&DirContext->FatDirEntry, fatDirEntry, sizeof (FAT_DIR_ENTRY));
|
* Used look aside lists to allocate memory for VFATFCB, VFATCCB and VFAT_IRP_CONTEXT.
* Removed IsLastEntry, IsVolEntry, IsDeletedEntry, vfat_wstrlen, vfatGrabFCB,
vfat_initstr, vfat_wcsncat, vfat_wcsncpy, vfat_movestr, wstrcmpi and replaced
this functions with existing equivalents or functions from ntoskrnl.
* Merged GetEntryName into vfatGetNextDirEntry for reducing some overhead.
* Implemented a file name cache to speed up the searching for existing fcb.
* Removed some calls to FsdDosDateTimeToFileTime.
* Moved the call to CcZeroData behind the initializing of the cache (in VfatWrite).
* Using existing fcbs in FindFile if there is no '*?' within the search name.
svn path=/trunk/; revision=3740
2002-11-11 21:49:18 +00:00
|
|
|
break;
|
2003-10-11 17:51:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
DirContext->DirIndex++;
|
|
|
|
if ((DirContext->DirIndex % ENTRIES_PER_PAGE) == 0)
|
|
|
|
{
|
* Used look aside lists to allocate memory for VFATFCB, VFATCCB and VFAT_IRP_CONTEXT.
* Removed IsLastEntry, IsVolEntry, IsDeletedEntry, vfat_wstrlen, vfatGrabFCB,
vfat_initstr, vfat_wcsncat, vfat_wcsncpy, vfat_movestr, wstrcmpi and replaced
this functions with existing equivalents or functions from ntoskrnl.
* Merged GetEntryName into vfatGetNextDirEntry for reducing some overhead.
* Implemented a file name cache to speed up the searching for existing fcb.
* Removed some calls to FsdDosDateTimeToFileTime.
* Moved the call to CcZeroData behind the initializing of the cache (in VfatWrite).
* Using existing fcbs in FindFile if there is no '*?' within the search name.
svn path=/trunk/; revision=3740
2002-11-11 21:49:18 +00:00
|
|
|
CcUnpinData(*pContext);
|
|
|
|
FileOffset.u.LowPart += PAGE_SIZE;
|
|
|
|
if (!CcMapData(pDirFcb->FileObject, &FileOffset, PAGE_SIZE, TRUE, pContext, pPage))
|
2003-10-11 17:51:56 +00:00
|
|
|
{
|
* Used look aside lists to allocate memory for VFATFCB, VFATCCB and VFAT_IRP_CONTEXT.
* Removed IsLastEntry, IsVolEntry, IsDeletedEntry, vfat_wstrlen, vfatGrabFCB,
vfat_initstr, vfat_wcsncat, vfat_wcsncpy, vfat_movestr, wstrcmpi and replaced
this functions with existing equivalents or functions from ntoskrnl.
* Merged GetEntryName into vfatGetNextDirEntry for reducing some overhead.
* Implemented a file name cache to speed up the searching for existing fcb.
* Removed some calls to FsdDosDateTimeToFileTime.
* Moved the call to CcZeroData behind the initializing of the cache (in VfatWrite).
* Using existing fcbs in FindFile if there is no '*?' within the search name.
svn path=/trunk/; revision=3740
2002-11-11 21:49:18 +00:00
|
|
|
CHECKPOINT;
|
|
|
|
*pContext = NULL;
|
|
|
|
return STATUS_NO_MORE_ENTRIES;
|
2003-10-11 17:51:56 +00:00
|
|
|
}
|
* Used look aside lists to allocate memory for VFATFCB, VFATCCB and VFAT_IRP_CONTEXT.
* Removed IsLastEntry, IsVolEntry, IsDeletedEntry, vfat_wstrlen, vfatGrabFCB,
vfat_initstr, vfat_wcsncat, vfat_wcsncpy, vfat_movestr, wstrcmpi and replaced
this functions with existing equivalents or functions from ntoskrnl.
* Merged GetEntryName into vfatGetNextDirEntry for reducing some overhead.
* Implemented a file name cache to speed up the searching for existing fcb.
* Removed some calls to FsdDosDateTimeToFileTime.
* Moved the call to CcZeroData behind the initializing of the cache (in VfatWrite).
* Using existing fcbs in FindFile if there is no '*?' within the search name.
svn path=/trunk/; revision=3740
2002-11-11 21:49:18 +00:00
|
|
|
fatDirEntry = (FATDirEntry*)*pPage;
|
|
|
|
longNameEntry = (slot*) *pPage;
|
2003-10-11 17:51:56 +00:00
|
|
|
}
|
* Used look aside lists to allocate memory for VFATFCB, VFATCCB and VFAT_IRP_CONTEXT.
* Removed IsLastEntry, IsVolEntry, IsDeletedEntry, vfat_wstrlen, vfatGrabFCB,
vfat_initstr, vfat_wcsncat, vfat_wcsncpy, vfat_movestr, wstrcmpi and replaced
this functions with existing equivalents or functions from ntoskrnl.
* Merged GetEntryName into vfatGetNextDirEntry for reducing some overhead.
* Implemented a file name cache to speed up the searching for existing fcb.
* Removed some calls to FsdDosDateTimeToFileTime.
* Moved the call to CcZeroData behind the initializing of the cache (in VfatWrite).
* Using existing fcbs in FindFile if there is no '*?' within the search name.
svn path=/trunk/; revision=3740
2002-11-11 21:49:18 +00:00
|
|
|
else
|
2003-10-11 17:51:56 +00:00
|
|
|
{
|
* Used look aside lists to allocate memory for VFATFCB, VFATCCB and VFAT_IRP_CONTEXT.
* Removed IsLastEntry, IsVolEntry, IsDeletedEntry, vfat_wstrlen, vfatGrabFCB,
vfat_initstr, vfat_wcsncat, vfat_wcsncpy, vfat_movestr, wstrcmpi and replaced
this functions with existing equivalents or functions from ntoskrnl.
* Merged GetEntryName into vfatGetNextDirEntry for reducing some overhead.
* Implemented a file name cache to speed up the searching for existing fcb.
* Removed some calls to FsdDosDateTimeToFileTime.
* Moved the call to CcZeroData behind the initializing of the cache (in VfatWrite).
* Using existing fcbs in FindFile if there is no '*?' within the search name.
svn path=/trunk/; revision=3740
2002-11-11 21:49:18 +00:00
|
|
|
fatDirEntry++;
|
|
|
|
longNameEntry++;
|
2003-10-11 17:51:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
DirContext->LongNameU.Length = wcslen(DirContext->LongNameU.Buffer) * sizeof(WCHAR);
|
|
|
|
vfat8Dot3ToString(&DirContext->FatDirEntry, &DirContext->ShortNameU);
|
|
|
|
if (DirContext->LongNameU.Length == 0)
|
|
|
|
{
|
|
|
|
RtlCopyUnicodeString(&DirContext->LongNameU, &DirContext->ShortNameU);
|
|
|
|
}
|
* Used look aside lists to allocate memory for VFATFCB, VFATCCB and VFAT_IRP_CONTEXT.
* Removed IsLastEntry, IsVolEntry, IsDeletedEntry, vfat_wstrlen, vfatGrabFCB,
vfat_initstr, vfat_wcsncat, vfat_wcsncpy, vfat_movestr, wstrcmpi and replaced
this functions with existing equivalents or functions from ntoskrnl.
* Merged GetEntryName into vfatGetNextDirEntry for reducing some overhead.
* Implemented a file name cache to speed up the searching for existing fcb.
* Removed some calls to FsdDosDateTimeToFileTime.
* Moved the call to CcZeroData behind the initializing of the cache (in VfatWrite).
* Using existing fcbs in FindFile if there is no '*?' within the search name.
svn path=/trunk/; revision=3740
2002-11-11 21:49:18 +00:00
|
|
|
return STATUS_SUCCESS;
|
2001-07-05 01:51:53 +00:00
|
|
|
}
|