Storing the real casing of names internally.

svn path=/trunk/; revision=1667
This commit is contained in:
Carl Nettelblad 2001-03-06 23:28:42 +00:00
parent 43038e9c15
commit 9e66717a35

View file

@ -1,4 +1,4 @@
/* $Id: create.c,v 1.18 2001/03/06 17:28:25 dwelch Exp $ /* $Id: create.c,v 1.19 2001/03/06 23:28:42 cnettel Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -14,7 +14,7 @@
#include <wchar.h> #include <wchar.h>
#include <limits.h> #include <limits.h>
#define NDEBUG #define NDEBUGN
#include <debug.h> #include <debug.h>
#include "vfat.h" #include "vfat.h"
@ -383,6 +383,7 @@ VfatOpenFile (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
PWSTR current = NULL; PWSTR current = NULL;
PWSTR next; PWSTR next;
PWSTR string; PWSTR string;
PWSTR buffer; // used to store a pointer while checking MAX_PATH conformance
PVFATFCB ParentFcb; PVFATFCB ParentFcb;
PVFATFCB Fcb, pRelFcb; PVFATFCB Fcb, pRelFcb;
PVFATFCB Temp; PVFATFCB Temp;
@ -472,11 +473,12 @@ VfatOpenFile (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
ParentFcb = NULL; ParentFcb = NULL;
Fcb = ExAllocatePool (NonPagedPool, sizeof (VFATFCB)); Fcb = ExAllocatePool (NonPagedPool, sizeof (VFATFCB));
memset (Fcb, 0, sizeof (VFATFCB)); memset (Fcb, 0, sizeof (VFATFCB));
Fcb->ObjectName = Fcb->PathName; Fcb->ObjectName = &Fcb->PathName[1];
Fcb->PathName[0]='\\';
next = &string[0]; next = &string[0];
CHECKPOINT; CHECKPOINT;
if (*next == 0) // root if (*next == 0 || *(next+1) == 0) // root
{ {
memset (Fcb->entry.Filename, ' ', 11); memset (Fcb->entry.Filename, ' ', 11);
Fcb->entry.FileSize = DeviceExt->rootDirectorySectors * BLOCKSIZE; Fcb->entry.FileSize = DeviceExt->rootDirectorySectors * BLOCKSIZE;
@ -486,7 +488,9 @@ VfatOpenFile (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
else else
Fcb->entry.FirstCluster = 1; Fcb->entry.FirstCluster = 1;
/* FIXME : is 1 the good value for mark root? */ /* FIXME : is 1 the good value for mark root? */
Fcb->ObjectName--;
ParentFcb = Fcb; ParentFcb = Fcb;
DPRINT("%S filename, PathName: %S \n",FileName, ParentFcb->PathName);
Fcb = NULL; Fcb = NULL;
} }
else else
@ -530,10 +534,32 @@ VfatOpenFile (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
CHECKPOINT; CHECKPOINT;
Fcb = ExAllocatePool (NonPagedPool, sizeof (VFATFCB)); Fcb = ExAllocatePool (NonPagedPool, sizeof (VFATFCB));
memset (Fcb, 0, sizeof (VFATFCB)); memset (Fcb, 0, sizeof (VFATFCB));
Fcb->ObjectName = Fcb->PathName; Fcb->ObjectName = &Fcb->PathName[1];
Fcb->PathName[0] = '\\';
} }
else else
Fcb = ParentFcb; Fcb = ParentFcb;
buffer=Fcb->ObjectName;
Fcb->ObjectName = Fcb->PathName + (Temp->ObjectName-Temp->PathName) + wcslen(Temp->ObjectName)+1;
// The line above should be possible to optimize. I was tired when writing it and always did something wrong
if (Fcb->ObjectName - Fcb->PathName >= MAX_PATH)
{
if (Fcb != NULL)
ExFreePool (Fcb);
if (ParentFcb != NULL)
ExFreePool (ParentFcb);
if (AbsFileName)
ExFreePool (AbsFileName);
return STATUS_OBJECT_PATH_NOT_FOUND;
// Which error code? It's no input buffer limit, it's the MAX_PATH limit.
// However, the current one is still wrong. Fix it!
}
wcscat(buffer, Temp->ObjectName-1);
Fcb->ObjectName[-1]='\\';
Fcb->ObjectName[0]=0;
CHECKPOINT; CHECKPOINT;
ParentFcb = Temp; ParentFcb = Temp;
} }
@ -542,7 +568,7 @@ VfatOpenFile (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
DPRINT ("current '%S'\n", current); DPRINT ("current '%S'\n", current);
Status = FindFile (DeviceExt, Fcb, ParentFcb, current, NULL, NULL); Status = FindFile (DeviceExt, Fcb, ParentFcb, current, NULL, NULL);
if (Status != STATUS_SUCCESS) if (Status != STATUS_SUCCESS)
{ {
/* file does not exist */ /* file does not exist */
CHECKPOINT; CHECKPOINT;
if (Fcb != NULL) if (Fcb != NULL)
@ -552,20 +578,14 @@ VfatOpenFile (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
if (AbsFileName) if (AbsFileName)
ExFreePool (AbsFileName); ExFreePool (AbsFileName);
return STATUS_OBJECT_NAME_NOT_FOUND; return STATUS_OBJECT_NAME_NOT_FOUND;
} }
Temp = Fcb; Temp = Fcb;
if (ParentFcb == NULL)
{ Fcb = ParentFcb;
CHECKPOINT;
Fcb = ExAllocatePool (NonPagedPool, sizeof (VFATFCB));
memset (Fcb, 0, sizeof (VFATFCB));
Fcb->ObjectName = Fcb->PathName;
}
else
Fcb = ParentFcb;
ParentFcb = Temp; ParentFcb = Temp;
ParentFcb->ObjectName = wcschr (ParentFcb->ObjectName, '\\');
} }
FileObject->Flags = FileObject->Flags | FileObject->Flags = FileObject->Flags |
@ -586,8 +606,8 @@ VfatOpenFile (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
InsertTailList (&DeviceExt->FcbListHead, &ParentFcb->FcbListEntry); InsertTailList (&DeviceExt->FcbListHead, &ParentFcb->FcbListEntry);
KeReleaseSpinLock (&DeviceExt->FcbListLock, oldIrql); KeReleaseSpinLock (&DeviceExt->FcbListLock, oldIrql);
vfat_wcsncpy (ParentFcb->PathName, FileName, MAX_PATH); /* vfat_wcsncpy (ParentFcb->PathName, FileName, MAX_PATH);
ParentFcb->ObjectName = ParentFcb->PathName + (current - FileName); ParentFcb->ObjectName = ParentFcb->PathName + (current - FileName); */
ParentFcb->pDevExt = DeviceExt; ParentFcb->pDevExt = DeviceExt;
BytesPerCluster = DeviceExt->Boot->SectorsPerCluster * BLOCKSIZE; BytesPerCluster = DeviceExt->Boot->SectorsPerCluster * BLOCKSIZE;
if (BytesPerCluster >= PAGESIZE) if (BytesPerCluster >= PAGESIZE)