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