mirror of
https://github.com/reactos/reactos.git
synced 2025-07-31 14:21:50 +00:00
- Use Unicode strings instead of WCHAR strings.
- Use FsRtl functions to handle wildcards. svn path=/trunk/; revision=10858
This commit is contained in:
parent
5a97f250e7
commit
5ad00f54e3
6 changed files with 218 additions and 192 deletions
|
@ -174,10 +174,11 @@ typedef struct _FCB
|
|||
PFILE_OBJECT FileObject;
|
||||
PDEVICE_EXTENSION DevExt;
|
||||
|
||||
UNICODE_STRING ShortNameU;
|
||||
|
||||
WCHAR *ObjectName; /* point on filename (250 chars max) in PathName */
|
||||
WCHAR PathName[MAX_PATH]; /* path+filename 260 max */
|
||||
WCHAR ShortName[13];
|
||||
USHORT ShortNameLength;
|
||||
WCHAR ShortNameBuffer[13];
|
||||
|
||||
ERESOURCE MainResource;
|
||||
|
||||
|
@ -205,7 +206,7 @@ typedef struct _CCB
|
|||
ULONG Entry;
|
||||
ULONG Offset;
|
||||
/* for DirectoryControl */
|
||||
PWCHAR DirectorySearchPattern;
|
||||
UNICODE_STRING DirectorySearchPattern;
|
||||
ULONG LastCluster;
|
||||
ULONG LastOffset;
|
||||
} CCB, *PCCB;
|
||||
|
@ -305,7 +306,7 @@ CdfsAddFCBToTable(PDEVICE_EXTENSION Vcb,
|
|||
|
||||
PFCB
|
||||
CdfsGrabFCBFromTable(PDEVICE_EXTENSION Vcb,
|
||||
PWSTR FileName);
|
||||
PUNICODE_STRING FileName);
|
||||
|
||||
NTSTATUS
|
||||
CdfsFCBInitializeCache(PVCB Vcb,
|
||||
|
@ -335,14 +336,14 @@ CdfsAttachFCBToFileObject(PDEVICE_EXTENSION Vcb,
|
|||
NTSTATUS
|
||||
CdfsDirFindFile(PDEVICE_EXTENSION DeviceExt,
|
||||
PFCB DirectoryFcb,
|
||||
PWSTR FileToFind,
|
||||
PUNICODE_STRING FileToFind,
|
||||
PFCB *FoundFCB);
|
||||
|
||||
NTSTATUS
|
||||
CdfsGetFCBForFile(PDEVICE_EXTENSION Vcb,
|
||||
PFCB *pParentFCB,
|
||||
PFCB *pFCB,
|
||||
const PWSTR pFileName);
|
||||
PUNICODE_STRING FileName);
|
||||
|
||||
|
||||
/* finfo.c */
|
||||
|
@ -365,9 +366,6 @@ CdfsFileSystemControl(PDEVICE_OBJECT DeviceObject,
|
|||
|
||||
/* misc.c */
|
||||
|
||||
BOOLEAN
|
||||
wstrcmpjoki(PWSTR s1, PWSTR s2);
|
||||
|
||||
VOID
|
||||
CdfsSwapString(PWCHAR Out,
|
||||
PUCHAR In,
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
/* $Id: close.c,v 1.7 2003/09/20 20:31:57 weiden Exp $
|
||||
/* $Id: close.c,v 1.8 2004/09/14 21:46:39 ekohl Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -69,10 +69,7 @@ CdfsCloseFile(PDEVICE_EXTENSION DeviceExt,
|
|||
CdfsReleaseFCB(DeviceExt, FileObject->FsContext);
|
||||
}
|
||||
|
||||
if (Ccb->DirectorySearchPattern)
|
||||
{
|
||||
ExFreePool(Ccb->DirectorySearchPattern);
|
||||
}
|
||||
RtlFreeUnicodeString(&Ccb->DirectorySearchPattern);
|
||||
ExFreePool(Ccb);
|
||||
|
||||
return(STATUS_SUCCESS);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* ReactOS kernel
|
||||
* Copyright (C) 2002, 2003 ReactOS Team
|
||||
* Copyright (C) 2002, 2003, 2004 ReactOS Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -16,7 +16,7 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
/* $Id: create.c,v 1.11 2003/11/13 15:25:08 ekohl Exp $
|
||||
/* $Id: create.c,v 1.12 2004/09/14 21:46:39 ekohl Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -39,58 +39,103 @@
|
|||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
static NTSTATUS
|
||||
CdfsMakeAbsoluteFilename(PFILE_OBJECT pFileObject,
|
||||
PWSTR pRelativeFileName,
|
||||
PWSTR *pAbsoluteFilename)
|
||||
CdfsMakeAbsoluteFilename(PFILE_OBJECT FileObject,
|
||||
PUNICODE_STRING RelativeFileName,
|
||||
PUNICODE_STRING AbsoluteFileName)
|
||||
{
|
||||
PWSTR rcName;
|
||||
ULONG Length;
|
||||
// PWSTR rcName;
|
||||
PFCB Fcb;
|
||||
NTSTATUS Status;
|
||||
|
||||
DPRINT("try related for %S\n", pRelativeFileName);
|
||||
Fcb = pFileObject->FsContext;
|
||||
DPRINT("try related for %wZ\n", RelativeFileName);
|
||||
Fcb = FileObject->FsContext;
|
||||
assert(Fcb);
|
||||
|
||||
/* verify related object is a directory and target name
|
||||
don't start with \. */
|
||||
if ((Fcb->Entry.FileFlags & 0x02) == 0 ||
|
||||
pRelativeFileName[0] == L'\\')
|
||||
if ((Fcb->Entry.FileFlags & FILE_FLAG_DIRECTORY) == 0 ||
|
||||
RelativeFileName->Buffer[0] == L'\\')
|
||||
{
|
||||
return(STATUS_INVALID_PARAMETER);
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
/* construct absolute path name */
|
||||
assert(wcslen (Fcb->PathName) + 1 + wcslen (pRelativeFileName) + 1
|
||||
<= MAX_PATH);
|
||||
rcName = ExAllocatePool(NonPagedPool, MAX_PATH * sizeof(WCHAR));
|
||||
if (!rcName)
|
||||
Length = (wcslen(Fcb->PathName) * sizeof(WCHAR)) +
|
||||
sizeof(WCHAR) +
|
||||
RelativeFileName->Length +
|
||||
sizeof(WCHAR);
|
||||
// assert(wcslen (Fcb->PathName) + 1 + wcslen (pRelativeFileName) + 1
|
||||
// <= MAX_PATH);
|
||||
// rcName = ExAllocatePool(NonPagedPool, MAX_PATH * sizeof(WCHAR));
|
||||
// if (!rcName)
|
||||
// {
|
||||
// return(STATUS_INSUFFICIENT_RESOURCES);
|
||||
// }
|
||||
AbsoluteFileName->Length = 0;
|
||||
AbsoluteFileName->MaximumLength = Length;
|
||||
AbsoluteFileName->Buffer = ExAllocatePool(NonPagedPool,
|
||||
Length);
|
||||
if (AbsoluteFileName->Buffer == NULL)
|
||||
{
|
||||
return(STATUS_INSUFFICIENT_RESOURCES);
|
||||
CHECKPOINT1;
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
}
|
||||
|
||||
wcscpy(rcName, Fcb->PathName);
|
||||
if (!CdfsFCBIsRoot(Fcb))
|
||||
wcscat (rcName, L"\\");
|
||||
wcscat (rcName, pRelativeFileName);
|
||||
*pAbsoluteFilename = rcName;
|
||||
|
||||
return(STATUS_SUCCESS);
|
||||
// wcscpy(rcName, Fcb->PathName);
|
||||
Status = RtlAppendUnicodeToString(AbsoluteFileName,
|
||||
Fcb->PathName);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
CHECKPOINT1;
|
||||
RtlFreeUnicodeString(AbsoluteFileName);
|
||||
return Status;
|
||||
}
|
||||
|
||||
if (!CdfsFCBIsRoot(Fcb))
|
||||
{
|
||||
// wcscat (rcName, L"\\");
|
||||
Status = RtlAppendUnicodeToString(AbsoluteFileName,
|
||||
L"\\");
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
CHECKPOINT1;
|
||||
RtlFreeUnicodeString(AbsoluteFileName);
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
|
||||
Status = RtlAppendUnicodeStringToString(AbsoluteFileName,
|
||||
RelativeFileName);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
CHECKPOINT1;
|
||||
RtlFreeUnicodeString(AbsoluteFileName);
|
||||
return Status;
|
||||
}
|
||||
|
||||
// wcscat (rcName, pRelativeFileName);
|
||||
// *pAbsoluteFilename = rcName;
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static NTSTATUS
|
||||
CdfsOpenFile(PDEVICE_EXTENSION DeviceExt,
|
||||
PFILE_OBJECT FileObject,
|
||||
PWSTR FileName)
|
||||
/*
|
||||
* FUNCTION: Opens a file
|
||||
*/
|
||||
static NTSTATUS
|
||||
CdfsOpenFile(PDEVICE_EXTENSION DeviceExt,
|
||||
PFILE_OBJECT FileObject,
|
||||
PUNICODE_STRING FileName)
|
||||
{
|
||||
PFCB ParentFcb;
|
||||
PFCB Fcb;
|
||||
NTSTATUS Status;
|
||||
PWSTR AbsFileName = NULL;
|
||||
UNICODE_STRING AbsFileName;
|
||||
|
||||
DPRINT("CdfsOpenFile(%08lx, %08lx, %S)\n", DeviceExt, FileObject, FileName);
|
||||
DPRINT("CdfsOpenFile(%08lx, %08lx, %wZ)\n", DeviceExt, FileObject, FileName);
|
||||
|
||||
if (FileObject->RelatedFileObject)
|
||||
{
|
||||
|
@ -99,12 +144,15 @@ CdfsOpenFile(PDEVICE_EXTENSION DeviceExt,
|
|||
Status = CdfsMakeAbsoluteFilename(FileObject->RelatedFileObject,
|
||||
FileName,
|
||||
&AbsFileName);
|
||||
FileName = AbsFileName;
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
return Status;
|
||||
}
|
||||
|
||||
FileName = &AbsFileName;
|
||||
|
||||
RtlFreeUnicodeString(&AbsFileName);
|
||||
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
|
||||
|
@ -141,9 +189,7 @@ CdfsOpenFile(PDEVICE_EXTENSION DeviceExt,
|
|||
return Status;
|
||||
}
|
||||
|
||||
//FIXME: Get cannonical path name (remove .'s, ..'s and extra separators)
|
||||
|
||||
DPRINT("PathName to open: %S\n", FileName);
|
||||
DPRINT("PathName to open: %wZ\n", FileName);
|
||||
|
||||
/* try first to find an existing FCB in memory */
|
||||
DPRINT("Checking for existing FCB in memory\n");
|
||||
|
@ -166,10 +212,10 @@ CdfsOpenFile(PDEVICE_EXTENSION DeviceExt,
|
|||
{
|
||||
DPRINT("Could not make a new FCB, status: %x\n", Status);
|
||||
|
||||
if (AbsFileName)
|
||||
ExFreePool(AbsFileName);
|
||||
if (FileName == &AbsFileName)
|
||||
RtlFreeUnicodeString(&AbsFileName);
|
||||
|
||||
return(Status);
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -178,19 +224,19 @@ CdfsOpenFile(PDEVICE_EXTENSION DeviceExt,
|
|||
Fcb,
|
||||
FileObject);
|
||||
|
||||
if (AbsFileName)
|
||||
ExFreePool (AbsFileName);
|
||||
if (FileName == &AbsFileName)
|
||||
RtlFreeUnicodeString(&AbsFileName);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
static NTSTATUS
|
||||
CdfsCreateFile(PDEVICE_OBJECT DeviceObject,
|
||||
PIRP Irp)
|
||||
/*
|
||||
* FUNCTION: Opens a file
|
||||
*/
|
||||
static NTSTATUS
|
||||
CdfsCreateFile(PDEVICE_OBJECT DeviceObject,
|
||||
PIRP Irp)
|
||||
{
|
||||
PDEVICE_EXTENSION DeviceExt;
|
||||
PIO_STACK_LOCATION Stack;
|
||||
|
@ -198,7 +244,6 @@ CdfsCreateFile(PDEVICE_OBJECT DeviceObject,
|
|||
ULONG RequestedDisposition;
|
||||
ULONG RequestedOptions;
|
||||
PFCB Fcb;
|
||||
// PWSTR FileName;
|
||||
NTSTATUS Status;
|
||||
|
||||
DPRINT("CdfsCreateFile() called\n");
|
||||
|
@ -219,13 +264,12 @@ CdfsCreateFile(PDEVICE_OBJECT DeviceObject,
|
|||
RequestedDisposition == FILE_OVERWRITE_IF ||
|
||||
RequestedDisposition == FILE_SUPERSEDE)
|
||||
{
|
||||
return(STATUS_ACCESS_DENIED);
|
||||
return STATUS_ACCESS_DENIED;
|
||||
}
|
||||
|
||||
Status = CdfsOpenFile(DeviceExt,
|
||||
FileObject,
|
||||
FileObject->FileName.Buffer);
|
||||
|
||||
&FileObject->FileName);
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
Fcb = FileObject->FsContext;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* ReactOS kernel
|
||||
* Copyright (C) 2002 ReactOS Team
|
||||
* Copyright (C) 2002, 2004 ReactOS Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -16,7 +16,7 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
/* $Id: dirctl.c,v 1.15 2004/05/23 13:31:25 hbirr Exp $
|
||||
/* $Id: dirctl.c,v 1.16 2004/09/14 21:46:39 ekohl Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -42,6 +42,9 @@
|
|||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
/*
|
||||
* FUNCTION: Retrieves the file name, be it in short or long file name format
|
||||
*/
|
||||
static NTSTATUS
|
||||
CdfsGetEntryName(PDEVICE_EXTENSION DeviceExt,
|
||||
PVOID *Context,
|
||||
|
@ -52,9 +55,6 @@ CdfsGetEntryName(PDEVICE_EXTENSION DeviceExt,
|
|||
PWSTR Name,
|
||||
PULONG pIndex,
|
||||
PULONG CurrentOffset)
|
||||
/*
|
||||
* FUNCTION: Retrieves the file name, be it in short or long file name format
|
||||
*/
|
||||
{
|
||||
PDIR_RECORD Record = *Ptr;
|
||||
ULONG Index;
|
||||
|
@ -112,8 +112,9 @@ CdfsGetEntryName(PDEVICE_EXTENSION DeviceExt,
|
|||
*Ptr = *Block;
|
||||
Record = (PDIR_RECORD)*Ptr;
|
||||
}
|
||||
|
||||
if (*CurrentOffset >= DirLength)
|
||||
return(STATUS_NO_MORE_ENTRIES);
|
||||
return STATUS_NO_MORE_ENTRIES;
|
||||
|
||||
DPRINT("Index %lu RecordLength %lu Offset %lu\n",
|
||||
*pIndex, Record->RecordLength, *CurrentOffset);
|
||||
|
@ -149,20 +150,21 @@ CdfsGetEntryName(PDEVICE_EXTENSION DeviceExt,
|
|||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* FUNCTION: Find a file
|
||||
*/
|
||||
static NTSTATUS
|
||||
CdfsFindFile(PDEVICE_EXTENSION DeviceExt,
|
||||
PFCB Fcb,
|
||||
PFCB Parent,
|
||||
PWSTR FileToFind,
|
||||
PUNICODE_STRING FileToFind,
|
||||
PULONG pDirIndex,
|
||||
PULONG pOffset)
|
||||
/*
|
||||
* FUNCTION: Find a file
|
||||
*/
|
||||
{
|
||||
WCHAR name[256];
|
||||
WCHAR TempStr[2];
|
||||
WCHAR ShortNameBuffer[13];
|
||||
UNICODE_STRING TempString;
|
||||
UNICODE_STRING ShortName;
|
||||
UNICODE_STRING LongName;
|
||||
PVOID Block;
|
||||
|
@ -178,19 +180,19 @@ CdfsFindFile(PDEVICE_EXTENSION DeviceExt,
|
|||
BOOLEAN HasSpaces;
|
||||
GENERATE_NAME_CONTEXT NameContext;
|
||||
|
||||
DPRINT("FindFile(Parent %x, FileToFind '%S', DirIndex: %d)\n",
|
||||
DPRINT("FindFile(Parent %x, FileToFind '%wZ', DirIndex: %d)\n",
|
||||
Parent, FileToFind, pDirIndex ? *pDirIndex : 0);
|
||||
DPRINT("FindFile: old Pathname %x, old Objectname %x)\n",
|
||||
Fcb->PathName, Fcb->ObjectName);
|
||||
|
||||
IsRoot = FALSE;
|
||||
DirIndex = 0;
|
||||
if (wcslen (FileToFind) == 0)
|
||||
|
||||
if (FileToFind == NULL || FileToFind->Length == 0)
|
||||
{
|
||||
CHECKPOINT;
|
||||
TempStr[0] = (WCHAR) '.';
|
||||
TempStr[1] = 0;
|
||||
FileToFind = (PWSTR)&TempStr;
|
||||
RtlInitUnicodeString(&TempString, L".");
|
||||
FileToFind = &TempString;
|
||||
}
|
||||
|
||||
if (Parent)
|
||||
|
@ -211,13 +213,14 @@ CdfsFindFile(PDEVICE_EXTENSION DeviceExt,
|
|||
DirSize = DeviceExt->CdInfo.RootSize;
|
||||
|
||||
|
||||
if (FileToFind[0] == 0 || (FileToFind[0] == '\\' && FileToFind[1] == 0)
|
||||
|| (FileToFind[0] == '.' && FileToFind[1] == 0))
|
||||
if (FileToFind->Buffer[0] == 0 ||
|
||||
(FileToFind->Buffer[0] == '\\' && FileToFind->Buffer[1] == 0) ||
|
||||
(FileToFind->Buffer[0] == '.' && FileToFind->Buffer[1] == 0))
|
||||
{
|
||||
/* it's root : complete essentials fields then return ok */
|
||||
RtlZeroMemory(Fcb, sizeof(FCB));
|
||||
|
||||
Fcb->PathName[0]='\\';
|
||||
Fcb->PathName[0] = '\\';
|
||||
Fcb->ObjectName = &Fcb->PathName[1];
|
||||
Fcb->Entry.ExtentLocationL = DeviceExt->CdInfo.RootStart;
|
||||
Fcb->Entry.DataLengthL = DeviceExt->CdInfo.RootSize;
|
||||
|
@ -228,7 +231,7 @@ CdfsFindFile(PDEVICE_EXTENSION DeviceExt,
|
|||
if (pOffset)
|
||||
*pOffset = 0;
|
||||
DPRINT("CdfsFindFile: new Pathname %S, new Objectname %S)\n",Fcb->PathName, Fcb->ObjectName);
|
||||
return (STATUS_SUCCESS);
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -243,24 +246,25 @@ CdfsFindFile(PDEVICE_EXTENSION DeviceExt,
|
|||
DirIndex = *pDirIndex;
|
||||
|
||||
if (pOffset && (*pOffset))
|
||||
{
|
||||
Offset = *pOffset;
|
||||
StreamOffset.QuadPart += ROUND_DOWN(Offset, BLOCKSIZE);
|
||||
}
|
||||
{
|
||||
Offset = *pOffset;
|
||||
StreamOffset.QuadPart += ROUND_DOWN(Offset, BLOCKSIZE);
|
||||
}
|
||||
|
||||
if(!CcMapData(DeviceExt->StreamFileObject, &StreamOffset,
|
||||
if (!CcMapData(DeviceExt->StreamFileObject, &StreamOffset,
|
||||
BLOCKSIZE, TRUE, &Context, &Block))
|
||||
{
|
||||
DPRINT("CcMapData() failed\n");
|
||||
return(STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
{
|
||||
DPRINT("CcMapData() failed\n");
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
|
||||
Record = (PDIR_RECORD) (Block + Offset % BLOCKSIZE);
|
||||
if (Offset)
|
||||
{
|
||||
Offset += Record->RecordLength;
|
||||
Record = (PVOID)Record + Record->RecordLength;
|
||||
}
|
||||
{
|
||||
Offset += Record->RecordLength;
|
||||
Record = (PVOID)Record + Record->RecordLength;
|
||||
}
|
||||
|
||||
while(TRUE)
|
||||
{
|
||||
DPRINT("RecordLength %u ExtAttrRecordLength %u NameLength %u\n",
|
||||
|
@ -276,7 +280,7 @@ CdfsFindFile(PDEVICE_EXTENSION DeviceExt,
|
|||
else if (Status == STATUS_UNSUCCESSFUL)
|
||||
{
|
||||
/* Note: the directory cache has already been unpinned */
|
||||
return(Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
DPRINT("Name '%S'\n", name);
|
||||
|
@ -305,8 +309,8 @@ CdfsFindFile(PDEVICE_EXTENSION DeviceExt,
|
|||
|
||||
DPRINT("ShortName '%wZ'\n", &ShortName);
|
||||
|
||||
if (wstrcmpjoki(name, FileToFind) ||
|
||||
wstrcmpjoki(ShortNameBuffer, FileToFind))
|
||||
if (FsRtlIsNameInExpression(FileToFind, &LongName, TRUE, NULL) ||
|
||||
FsRtlIsNameInExpression(FileToFind, &ShortName, TRUE, NULL))
|
||||
{
|
||||
if (Parent && Parent->PathName)
|
||||
{
|
||||
|
@ -332,8 +336,10 @@ CdfsFindFile(PDEVICE_EXTENSION DeviceExt,
|
|||
wcsncpy(Fcb->ObjectName, name, MAX_PATH);
|
||||
|
||||
/* Copy short name */
|
||||
Fcb->ShortNameLength = ShortName.Length;
|
||||
memcpy(Fcb->ShortName, ShortName.Buffer, ShortName.Length);
|
||||
Fcb->ShortNameU.Length = ShortName.Length;
|
||||
Fcb->ShortNameU.MaximumLength = ShortName.Length;
|
||||
Fcb->ShortNameU.Buffer = Fcb->ShortNameBuffer;
|
||||
memcpy(Fcb->ShortNameBuffer, ShortName.Buffer, ShortName.Length);
|
||||
|
||||
if (pDirIndex)
|
||||
*pDirIndex = DirIndex;
|
||||
|
@ -345,7 +351,7 @@ CdfsFindFile(PDEVICE_EXTENSION DeviceExt,
|
|||
|
||||
CcUnpinData(Context);
|
||||
|
||||
return(STATUS_SUCCESS);
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
Offset += Record->RecordLength;
|
||||
|
@ -361,7 +367,7 @@ CdfsFindFile(PDEVICE_EXTENSION DeviceExt,
|
|||
if (pOffset)
|
||||
*pOffset = Offset;
|
||||
|
||||
return(STATUS_UNSUCCESSFUL);
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
|
||||
|
||||
|
@ -542,8 +548,8 @@ CdfsGetBothDirectoryInformation(PFCB Fcb,
|
|||
Info->EaSize = 0;
|
||||
|
||||
/* Copy short name */
|
||||
Info->ShortNameLength = Fcb->ShortNameLength;
|
||||
memcpy(Info->ShortName, Fcb->ShortName, Fcb->ShortNameLength);
|
||||
Info->ShortNameLength = Fcb->ShortNameU.Length;
|
||||
memcpy(Info->ShortName, Fcb->ShortNameU.Buffer, Fcb->ShortNameU.Length);
|
||||
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
@ -587,34 +593,40 @@ CdfsQueryDirectory(PDEVICE_OBJECT DeviceObject,
|
|||
|
||||
if (SearchPattern != NULL)
|
||||
{
|
||||
if (!Ccb->DirectorySearchPattern)
|
||||
if (Ccb->DirectorySearchPattern.Buffer == NULL)
|
||||
{
|
||||
First = TRUE;
|
||||
Ccb->DirectorySearchPattern =
|
||||
Ccb->DirectorySearchPattern.Buffer =
|
||||
ExAllocatePool(NonPagedPool, SearchPattern->Length + sizeof(WCHAR));
|
||||
if (!Ccb->DirectorySearchPattern)
|
||||
if (Ccb->DirectorySearchPattern.Buffer == NULL)
|
||||
{
|
||||
return(STATUS_INSUFFICIENT_RESOURCES);
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
}
|
||||
|
||||
memcpy(Ccb->DirectorySearchPattern,
|
||||
Ccb->DirectorySearchPattern.Length = SearchPattern->Length;
|
||||
Ccb->DirectorySearchPattern.MaximumLength = SearchPattern->Length + sizeof(WCHAR);
|
||||
|
||||
memcpy(Ccb->DirectorySearchPattern.Buffer,
|
||||
SearchPattern->Buffer,
|
||||
SearchPattern->Length);
|
||||
Ccb->DirectorySearchPattern[SearchPattern->Length / sizeof(WCHAR)] = 0;
|
||||
Ccb->DirectorySearchPattern.Buffer[SearchPattern->Length / sizeof(WCHAR)] = 0;
|
||||
}
|
||||
}
|
||||
else if (!Ccb->DirectorySearchPattern)
|
||||
else if (Ccb->DirectorySearchPattern.Buffer == NULL)
|
||||
{
|
||||
First = TRUE;
|
||||
Ccb->DirectorySearchPattern = ExAllocatePool(NonPagedPool, 2 * sizeof(WCHAR));
|
||||
if (!Ccb->DirectorySearchPattern)
|
||||
Ccb->DirectorySearchPattern.Buffer = ExAllocatePool(NonPagedPool, 2 * sizeof(WCHAR));
|
||||
if (Ccb->DirectorySearchPattern.Buffer == NULL)
|
||||
{
|
||||
return(STATUS_INSUFFICIENT_RESOURCES);
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
}
|
||||
Ccb->DirectorySearchPattern[0] = L'*';
|
||||
Ccb->DirectorySearchPattern[1] = 0;
|
||||
|
||||
Ccb->DirectorySearchPattern.Length = sizeof(WCHAR);
|
||||
Ccb->DirectorySearchPattern.MaximumLength = 2 * sizeof(WCHAR);
|
||||
Ccb->DirectorySearchPattern.Buffer[0] = L'*';
|
||||
Ccb->DirectorySearchPattern.Buffer[1] = 0;
|
||||
}
|
||||
DPRINT("Search pattern '%S'\n", Ccb->DirectorySearchPattern);
|
||||
DPRINT("Search pattern '%wZ'\n", &Ccb->DirectorySearchPattern);
|
||||
|
||||
/* Determine directory index */
|
||||
if (Stack->Flags & SL_INDEX_SPECIFIED)
|
||||
|
@ -637,7 +649,7 @@ CdfsQueryDirectory(PDEVICE_OBJECT DeviceObject,
|
|||
{
|
||||
Buffer = Irp->UserBuffer;
|
||||
}
|
||||
DPRINT("Buffer=%x tofind=%S\n", Buffer, Ccb->DirectorySearchPattern);
|
||||
DPRINT("Buffer = %p tofind = %wZ\n", Buffer, &Ccb->DirectorySearchPattern);
|
||||
|
||||
TempFcb.ObjectName = TempFcb.PathName;
|
||||
while (Status == STATUS_SUCCESS && BufferLength > 0)
|
||||
|
@ -645,7 +657,7 @@ CdfsQueryDirectory(PDEVICE_OBJECT DeviceObject,
|
|||
Status = CdfsFindFile(DeviceExtension,
|
||||
&TempFcb,
|
||||
Fcb,
|
||||
Ccb->DirectorySearchPattern,
|
||||
&Ccb->DirectorySearchPattern,
|
||||
&Ccb->Entry,
|
||||
&Ccb->Offset);
|
||||
DPRINT("Found %S, Status=%x, entry %x\n", TempFcb.ObjectName, Status, Ccb->Entry);
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
/* $Id: fcb.c,v 1.18 2004/03/08 08:51:26 ekohl Exp $
|
||||
/* $Id: fcb.c,v 1.19 2004/09/14 21:46:39 ekohl Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -176,7 +176,7 @@ CdfsAddFCBToTable(PDEVICE_EXTENSION Vcb,
|
|||
|
||||
PFCB
|
||||
CdfsGrabFCBFromTable(PDEVICE_EXTENSION Vcb,
|
||||
PWSTR FileName)
|
||||
PUNICODE_STRING FileName)
|
||||
{
|
||||
KIRQL oldIrql;
|
||||
PFCB Fcb;
|
||||
|
@ -184,7 +184,7 @@ CdfsGrabFCBFromTable(PDEVICE_EXTENSION Vcb,
|
|||
|
||||
KeAcquireSpinLock(&Vcb->FcbListLock, &oldIrql);
|
||||
|
||||
if (FileName == NULL || *FileName == 0)
|
||||
if (FileName == NULL || FileName->Length == 0 || FileName->Buffer[0] == 0)
|
||||
{
|
||||
DPRINT("Return FCB for stream file object\n");
|
||||
Fcb = Vcb->StreamFileObject->FsContext;
|
||||
|
@ -198,8 +198,8 @@ CdfsGrabFCBFromTable(PDEVICE_EXTENSION Vcb,
|
|||
{
|
||||
Fcb = CONTAINING_RECORD(current_entry, FCB, FcbListEntry);
|
||||
|
||||
DPRINT("Comparing '%S' and '%S'\n", FileName, Fcb->PathName);
|
||||
if (_wcsicmp(FileName, Fcb->PathName) == 0)
|
||||
DPRINT("Comparing '%wZ' and '%S'\n", FileName, Fcb->PathName);
|
||||
if (_wcsicmp(FileName->Buffer, Fcb->PathName) == 0)
|
||||
{
|
||||
Fcb->RefCount++;
|
||||
KeReleaseSpinLock(&Vcb->FcbListLock, oldIrql);
|
||||
|
@ -286,9 +286,13 @@ CdfsMakeRootFCB(PDEVICE_EXTENSION Vcb)
|
|||
PFCB
|
||||
CdfsOpenRootFCB(PDEVICE_EXTENSION Vcb)
|
||||
{
|
||||
UNICODE_STRING FileName;
|
||||
PFCB Fcb;
|
||||
|
||||
Fcb = CdfsGrabFCBFromTable(Vcb, L"\\");
|
||||
RtlInitUnicodeString(&FileName, L"\\");
|
||||
|
||||
Fcb = CdfsGrabFCBFromTable(Vcb,
|
||||
&FileName);
|
||||
if (Fcb == NULL)
|
||||
{
|
||||
Fcb = CdfsMakeRootFCB(Vcb);
|
||||
|
@ -378,8 +382,10 @@ CdfsMakeFCBFromDirEntry(PVCB Vcb,
|
|||
memcpy(&rcFCB->Entry, Record, sizeof(DIR_RECORD));
|
||||
|
||||
/* Copy short name into FCB */
|
||||
rcFCB->ShortNameLength = wcslen(ShortName) * sizeof(WCHAR);
|
||||
wcscpy(rcFCB->ShortName, ShortName);
|
||||
rcFCB->ShortNameU.Length = wcslen(ShortName) * sizeof(WCHAR);
|
||||
rcFCB->ShortNameU.MaximumLength = rcFCB->ShortNameU.Length;
|
||||
rcFCB->ShortNameU.Buffer = rcFCB->ShortNameBuffer;
|
||||
wcscpy(rcFCB->ShortNameBuffer, ShortName);
|
||||
|
||||
Size = rcFCB->Entry.DataLengthL;
|
||||
|
||||
|
@ -446,10 +452,10 @@ CdfsAttachFCBToFileObject(PDEVICE_EXTENSION Vcb,
|
|||
NTSTATUS
|
||||
CdfsDirFindFile(PDEVICE_EXTENSION DeviceExt,
|
||||
PFCB DirectoryFcb,
|
||||
PWSTR FileToFind,
|
||||
PUNICODE_STRING FileToFind,
|
||||
PFCB *FoundFCB)
|
||||
{
|
||||
WCHAR TempName[2];
|
||||
UNICODE_STRING TempName;
|
||||
WCHAR Name[256];
|
||||
PVOID Block;
|
||||
ULONG DirSize;
|
||||
|
@ -472,29 +478,32 @@ CdfsDirFindFile(PDEVICE_EXTENSION DeviceExt,
|
|||
assert(DirectoryFcb);
|
||||
assert(FileToFind);
|
||||
|
||||
DPRINT("CdfsDirFindFile(VCB:%08x, dirFCB:%08x, File:%S)\n",
|
||||
DPRINT("CdfsDirFindFile(VCB:%p, dirFCB:%p, File:%wZ)\n",
|
||||
DeviceExt,
|
||||
DirectoryFcb,
|
||||
FileToFind);
|
||||
DPRINT("Dir Path:%S\n", DirectoryFcb->PathName);
|
||||
|
||||
/* default to '.' if no filename specified */
|
||||
if (wcslen(FileToFind) == 0)
|
||||
/* default to '.' if no filename specified */
|
||||
if (FileToFind->Length == 0)
|
||||
{
|
||||
TempName[0] = L'.';
|
||||
TempName[1] = 0;
|
||||
FileToFind = TempName;
|
||||
RtlInitUnicodeString(&TempName, L".");
|
||||
FileToFind = &TempName;
|
||||
}
|
||||
|
||||
DirSize = DirectoryFcb->Entry.DataLengthL;
|
||||
StreamOffset.QuadPart = (LONGLONG)DirectoryFcb->Entry.ExtentLocationL * (LONGLONG)BLOCKSIZE;
|
||||
|
||||
if(!CcMapData(DeviceExt->StreamFileObject, &StreamOffset,
|
||||
BLOCKSIZE, TRUE, &Context, &Block))
|
||||
{
|
||||
DPRINT("CcMapData() failed\n");
|
||||
return(STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
if (!CcMapData(DeviceExt->StreamFileObject,
|
||||
&StreamOffset,
|
||||
BLOCKSIZE,
|
||||
TRUE,
|
||||
&Context,
|
||||
&Block))
|
||||
{
|
||||
DPRINT("CcMapData() failed\n");
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
|
||||
Offset = 0;
|
||||
BlockOffset = 0;
|
||||
|
@ -540,7 +549,8 @@ CdfsDirFindFile(PDEVICE_EXTENSION DeviceExt,
|
|||
|
||||
DPRINT("ShortName '%wZ'\n", &ShortName);
|
||||
|
||||
if (wstrcmpjoki(Name, FileToFind) || wstrcmpjoki(ShortNameBuffer, FileToFind))
|
||||
if (FsRtlIsNameInExpression(FileToFind, &LongName, TRUE, NULL) ||
|
||||
FsRtlIsNameInExpression(FileToFind, &ShortName, TRUE, NULL))
|
||||
{
|
||||
DPRINT("Match found, %S\n", Name);
|
||||
Status = CdfsMakeFCBFromDirEntry(DeviceExt,
|
||||
|
@ -593,8 +603,10 @@ NTSTATUS
|
|||
CdfsGetFCBForFile(PDEVICE_EXTENSION Vcb,
|
||||
PFCB *pParentFCB,
|
||||
PFCB *pFCB,
|
||||
const PWSTR pFileName)
|
||||
PUNICODE_STRING FileName)
|
||||
{
|
||||
UNICODE_STRING PathName;
|
||||
UNICODE_STRING ElementName;
|
||||
NTSTATUS Status;
|
||||
WCHAR pathName [MAX_PATH];
|
||||
WCHAR elementName [MAX_PATH];
|
||||
|
@ -602,14 +614,14 @@ CdfsGetFCBForFile(PDEVICE_EXTENSION Vcb,
|
|||
PFCB FCB;
|
||||
PFCB parentFCB;
|
||||
|
||||
DPRINT("CdfsGetFCBForFile(%x, %x, %x, '%S')\n",
|
||||
DPRINT("CdfsGetFCBForFile(%x, %x, %x, '%wZ')\n",
|
||||
Vcb,
|
||||
pParentFCB,
|
||||
pFCB,
|
||||
pFileName);
|
||||
FileName);
|
||||
|
||||
/* Trivial case, open of the root directory on volume */
|
||||
if (pFileName [0] == L'\0' || wcscmp(pFileName, L"\\") == 0)
|
||||
if (FileName->Buffer[0] == L'\0' || wcscmp(FileName->Buffer, L"\\") == 0)
|
||||
{
|
||||
DPRINT("returning root FCB\n");
|
||||
|
||||
|
@ -621,7 +633,7 @@ CdfsGetFCBForFile(PDEVICE_EXTENSION Vcb,
|
|||
}
|
||||
else
|
||||
{
|
||||
currentElement = pFileName + 1;
|
||||
currentElement = &FileName->Buffer[1];
|
||||
wcscpy (pathName, L"\\");
|
||||
FCB = CdfsOpenRootFCB (Vcb);
|
||||
}
|
||||
|
@ -663,11 +675,13 @@ CdfsGetFCBForFile(PDEVICE_EXTENSION Vcb,
|
|||
|
||||
/* Extract next directory level into dirName */
|
||||
CdfsWSubString(pathName,
|
||||
pFileName,
|
||||
CdfsGetNextPathElement(currentElement) - pFileName);
|
||||
FileName->Buffer,
|
||||
CdfsGetNextPathElement(currentElement) - FileName->Buffer);
|
||||
DPRINT(" pathName:%S\n", pathName);
|
||||
|
||||
FCB = CdfsGrabFCBFromTable(Vcb, pathName);
|
||||
RtlInitUnicodeString(&PathName, pathName);
|
||||
|
||||
FCB = CdfsGrabFCBFromTable(Vcb, &PathName);
|
||||
if (FCB == NULL)
|
||||
{
|
||||
CdfsWSubString(elementName,
|
||||
|
@ -675,7 +689,11 @@ CdfsGetFCBForFile(PDEVICE_EXTENSION Vcb,
|
|||
CdfsGetNextPathElement(currentElement) - currentElement);
|
||||
DPRINT(" elementName:%S\n", elementName);
|
||||
|
||||
Status = CdfsDirFindFile(Vcb, parentFCB, elementName, &FCB);
|
||||
RtlInitUnicodeString(&ElementName, elementName);
|
||||
Status = CdfsDirFindFile(Vcb,
|
||||
parentFCB,
|
||||
&ElementName,
|
||||
&FCB);
|
||||
if (Status == STATUS_OBJECT_NAME_NOT_FOUND)
|
||||
{
|
||||
*pParentFCB = parentFCB;
|
||||
|
@ -705,7 +723,7 @@ CdfsGetFCBForFile(PDEVICE_EXTENSION Vcb,
|
|||
*pParentFCB = parentFCB;
|
||||
*pFCB = FCB;
|
||||
|
||||
return(STATUS_SUCCESS);
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
/* $Id: misc.c,v 1.7 2004/05/23 13:27:26 hbirr Exp $
|
||||
/* $Id: misc.c,v 1.8 2004/09/14 21:46:39 ekohl Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -38,49 +38,6 @@
|
|||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
|
||||
BOOLEAN
|
||||
wstrcmpjoki(PWSTR s1,
|
||||
PWSTR s2)
|
||||
/*
|
||||
* FUNCTION: Compare two wide character strings, s2 with jokers (* or ?)
|
||||
* return TRUE if s1 like s2
|
||||
*/
|
||||
{
|
||||
while ((*s2=='*')||(*s2=='?')||(towlower(*s1)==towlower(*s2)))
|
||||
{
|
||||
if ((*s1)==0 && (*s2)==0)
|
||||
return(TRUE);
|
||||
|
||||
if(*s2=='*')
|
||||
{
|
||||
s2++;
|
||||
while (*s1)
|
||||
if (wstrcmpjoki(s1,s2))
|
||||
return(TRUE);
|
||||
else
|
||||
s1++;
|
||||
}
|
||||
else
|
||||
{
|
||||
s1++;
|
||||
s2++;
|
||||
}
|
||||
}
|
||||
|
||||
if ((*s2)=='.')
|
||||
{
|
||||
for (;((*s2)=='.')||((*s2)=='*')||((*s2)=='?');s2++)
|
||||
;
|
||||
}
|
||||
|
||||
if ((*s1)==0 && (*s2)==0)
|
||||
return(TRUE);
|
||||
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
|
||||
VOID
|
||||
CdfsSwapString(PWCHAR Out,
|
||||
PUCHAR In,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue