2002-04-15 20:39:49 +00:00
|
|
|
/*
|
2009-02-03 14:50:50 +00:00
|
|
|
* ReactOS kernel
|
|
|
|
* 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
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
2009-10-27 10:34:16 +00:00
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2009-02-03 14:50:50 +00:00
|
|
|
*/
|
2005-01-05 01:42:23 +00:00
|
|
|
/* $Id$
|
2009-02-03 14:50:50 +00:00
|
|
|
*
|
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS kernel
|
|
|
|
* FILE: services/fs/cdfs/fcb.c
|
|
|
|
* PURPOSE: CDROM (ISO 9660) filesystem driver
|
|
|
|
* PROGRAMMER: Art Yerkes
|
|
|
|
* UPDATE HISTORY:
|
|
|
|
*/
|
2002-04-15 20:39:49 +00:00
|
|
|
|
|
|
|
/* INCLUDES *****************************************************************/
|
|
|
|
|
2005-07-20 02:52:52 +00:00
|
|
|
#include "cdfs.h"
|
2002-04-15 20:39:49 +00:00
|
|
|
|
2009-02-04 06:10:19 +00:00
|
|
|
#define NDEBUG
|
2002-04-15 20:39:49 +00:00
|
|
|
#include <debug.h>
|
|
|
|
|
2005-07-20 02:52:52 +00:00
|
|
|
/* FUNCTIONS ****************************************************************/
|
2002-04-15 20:39:49 +00:00
|
|
|
|
|
|
|
#define ROUND_UP(N, S) ((((N) + (S) - 1) / (S)) * (S))
|
2002-04-12 15:43:38 +00:00
|
|
|
|
|
|
|
|
2002-04-15 20:39:49 +00:00
|
|
|
/* FUNCTIONS ****************************************************************/
|
2002-04-12 15:43:38 +00:00
|
|
|
|
2002-05-01 13:15:42 +00:00
|
|
|
static PWCHAR
|
|
|
|
CdfsGetNextPathElement(PWCHAR FileName)
|
|
|
|
{
|
2009-02-03 14:50:50 +00:00
|
|
|
if (*FileName == L'\0')
|
2002-05-01 13:15:42 +00:00
|
|
|
{
|
2009-02-03 14:50:50 +00:00
|
|
|
return(NULL);
|
2002-05-01 13:15:42 +00:00
|
|
|
}
|
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
while (*FileName != L'\0' && *FileName != L'\\')
|
2002-05-01 13:15:42 +00:00
|
|
|
{
|
2009-02-03 14:50:50 +00:00
|
|
|
FileName++;
|
2002-05-01 13:15:42 +00:00
|
|
|
}
|
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
return(FileName);
|
2002-05-01 13:15:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static VOID
|
|
|
|
CdfsWSubString(PWCHAR pTarget, const PWCHAR pSource, size_t pLength)
|
|
|
|
{
|
2009-02-03 14:50:50 +00:00
|
|
|
wcsncpy (pTarget, pSource, pLength);
|
|
|
|
pTarget [pLength] = L'\0';
|
2002-05-01 13:15:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-04-15 20:39:49 +00:00
|
|
|
PFCB
|
2005-11-11 19:59:38 +00:00
|
|
|
CdfsCreateFCB(PCWSTR FileName)
|
2002-04-15 20:39:49 +00:00
|
|
|
{
|
2009-02-03 14:50:50 +00:00
|
|
|
PFCB Fcb;
|
2002-04-15 20:39:49 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
Fcb = ExAllocatePoolWithTag(NonPagedPool, sizeof(FCB), TAG_FCB);
|
|
|
|
if(!Fcb) return NULL;
|
2008-09-08 18:06:24 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
RtlZeroMemory(Fcb, sizeof(FCB));
|
2002-04-15 20:39:49 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
if (FileName)
|
2002-04-15 20:39:49 +00:00
|
|
|
{
|
2009-02-03 14:50:50 +00:00
|
|
|
wcscpy(Fcb->PathName, FileName);
|
|
|
|
if (wcsrchr(Fcb->PathName, '\\') != 0)
|
2006-07-06 15:14:06 +00:00
|
|
|
{
|
2009-02-03 14:50:50 +00:00
|
|
|
Fcb->ObjectName = wcsrchr(Fcb->PathName, '\\');
|
2006-07-06 15:14:06 +00:00
|
|
|
}
|
2009-02-03 14:50:50 +00:00
|
|
|
else
|
2006-07-06 15:14:06 +00:00
|
|
|
{
|
2009-02-03 14:50:50 +00:00
|
|
|
Fcb->ObjectName = Fcb->PathName;
|
2006-07-06 15:14:06 +00:00
|
|
|
}
|
2002-04-15 20:39:49 +00:00
|
|
|
}
|
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
ExInitializeResourceLite(&Fcb->PagingIoResource);
|
|
|
|
ExInitializeResourceLite(&Fcb->MainResource);
|
2009-02-04 03:39:23 +00:00
|
|
|
ExInitializeResourceLite(&Fcb->NameListResource);
|
2009-02-03 14:50:50 +00:00
|
|
|
Fcb->RFCB.PagingIoResource = &Fcb->PagingIoResource;
|
|
|
|
Fcb->RFCB.Resource = &Fcb->MainResource;
|
|
|
|
Fcb->RFCB.IsFastIoPossible = FastIoIsNotPossible;
|
2009-02-04 03:39:23 +00:00
|
|
|
InitializeListHead(&Fcb->ShortNameList);
|
2002-04-15 20:39:49 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
return(Fcb);
|
2002-04-12 15:43:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-04-15 20:39:49 +00:00
|
|
|
VOID
|
|
|
|
CdfsDestroyFCB(PFCB Fcb)
|
|
|
|
{
|
2009-02-04 03:39:23 +00:00
|
|
|
PLIST_ENTRY Entry;
|
2009-02-04 06:04:24 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
ExDeleteResourceLite(&Fcb->PagingIoResource);
|
|
|
|
ExDeleteResourceLite(&Fcb->MainResource);
|
2002-04-12 15:43:38 +00:00
|
|
|
|
2009-02-04 03:39:23 +00:00
|
|
|
while (!IsListEmpty(&Fcb->ShortNameList))
|
|
|
|
{
|
2009-02-04 06:04:24 +00:00
|
|
|
Entry = Fcb->ShortNameList.Flink;
|
|
|
|
RemoveEntryList(Entry);
|
2009-02-12 18:52:12 +00:00
|
|
|
ExFreePoolWithTag(Entry, TAG_FCB);
|
2009-02-04 03:39:23 +00:00
|
|
|
}
|
|
|
|
|
2009-02-12 18:52:12 +00:00
|
|
|
ExDeleteResourceLite(&Fcb->NameListResource);
|
|
|
|
ExFreePoolWithTag(Fcb, TAG_FCB);
|
2002-04-15 20:39:49 +00:00
|
|
|
}
|
2002-04-12 15:43:38 +00:00
|
|
|
|
|
|
|
|
2002-04-15 20:39:49 +00:00
|
|
|
BOOLEAN
|
|
|
|
CdfsFCBIsDirectory(PFCB Fcb)
|
|
|
|
{
|
2009-02-03 14:50:50 +00:00
|
|
|
return(Fcb->Entry.FileFlags & FILE_FLAG_DIRECTORY);
|
2002-04-15 20:39:49 +00:00
|
|
|
}
|
2002-04-12 15:43:38 +00:00
|
|
|
|
|
|
|
|
2002-04-15 20:39:49 +00:00
|
|
|
BOOLEAN
|
|
|
|
CdfsFCBIsRoot(PFCB Fcb)
|
|
|
|
{
|
2009-02-03 14:50:50 +00:00
|
|
|
return(wcscmp(Fcb->PathName, L"\\") == 0);
|
2002-04-12 15:43:38 +00:00
|
|
|
}
|
|
|
|
|
2002-04-15 20:39:49 +00:00
|
|
|
|
|
|
|
VOID
|
|
|
|
CdfsGrabFCB(PDEVICE_EXTENSION Vcb,
|
2006-07-06 15:14:06 +00:00
|
|
|
PFCB Fcb)
|
2002-04-15 20:39:49 +00:00
|
|
|
{
|
2009-02-03 14:50:50 +00:00
|
|
|
KIRQL oldIrql;
|
2002-04-15 20:39:49 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
DPRINT("grabbing FCB at %x: %S, refCount:%d\n",
|
|
|
|
Fcb,
|
|
|
|
Fcb->PathName,
|
|
|
|
Fcb->RefCount);
|
2002-04-15 20:39:49 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
KeAcquireSpinLock(&Vcb->FcbListLock, &oldIrql);
|
|
|
|
Fcb->RefCount++;
|
|
|
|
KeReleaseSpinLock(&Vcb->FcbListLock, oldIrql);
|
2002-04-12 15:43:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-04-15 20:39:49 +00:00
|
|
|
VOID
|
|
|
|
CdfsReleaseFCB(PDEVICE_EXTENSION Vcb,
|
2006-07-06 15:14:06 +00:00
|
|
|
PFCB Fcb)
|
2002-04-15 20:39:49 +00:00
|
|
|
{
|
2009-02-03 14:50:50 +00:00
|
|
|
KIRQL oldIrql;
|
2002-04-12 15:43:38 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
DPRINT("releasing FCB at %x: %S, refCount:%d\n",
|
|
|
|
Fcb,
|
|
|
|
Fcb->PathName,
|
|
|
|
Fcb->RefCount);
|
2002-04-12 15:43:38 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
KeAcquireSpinLock(&Vcb->FcbListLock, &oldIrql);
|
|
|
|
Fcb->RefCount--;
|
|
|
|
if (Fcb->RefCount <= 0 && !CdfsFCBIsDirectory(Fcb))
|
2002-04-15 20:39:49 +00:00
|
|
|
{
|
2009-02-03 14:50:50 +00:00
|
|
|
RemoveEntryList(&Fcb->FcbListEntry);
|
|
|
|
CdfsDestroyFCB(Fcb);
|
2002-04-15 20:39:49 +00:00
|
|
|
}
|
2009-02-03 14:50:50 +00:00
|
|
|
KeReleaseSpinLock(&Vcb->FcbListLock, oldIrql);
|
2002-04-12 15:43:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-04-15 20:39:49 +00:00
|
|
|
VOID
|
|
|
|
CdfsAddFCBToTable(PDEVICE_EXTENSION Vcb,
|
2006-07-06 15:14:06 +00:00
|
|
|
PFCB Fcb)
|
2002-04-15 20:39:49 +00:00
|
|
|
{
|
2009-02-03 14:50:50 +00:00
|
|
|
KIRQL oldIrql;
|
2002-04-15 20:39:49 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
KeAcquireSpinLock(&Vcb->FcbListLock, &oldIrql);
|
|
|
|
Fcb->DevExt = Vcb;
|
|
|
|
InsertTailList(&Vcb->FcbListHead, &Fcb->FcbListEntry);
|
|
|
|
KeReleaseSpinLock(&Vcb->FcbListLock, oldIrql);
|
2002-04-15 20:39:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PFCB
|
|
|
|
CdfsGrabFCBFromTable(PDEVICE_EXTENSION Vcb,
|
2006-07-06 15:14:06 +00:00
|
|
|
PUNICODE_STRING FileName)
|
2002-04-15 20:39:49 +00:00
|
|
|
{
|
2009-02-03 14:50:50 +00:00
|
|
|
KIRQL oldIrql;
|
|
|
|
PFCB Fcb;
|
|
|
|
PLIST_ENTRY current_entry;
|
2002-04-15 20:39:49 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
KeAcquireSpinLock(&Vcb->FcbListLock, &oldIrql);
|
2002-04-15 20:39:49 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
if (FileName == NULL || FileName->Length == 0 || FileName->Buffer[0] == 0)
|
2002-04-15 20:39:49 +00:00
|
|
|
{
|
2009-02-03 14:50:50 +00:00
|
|
|
DPRINT("Return FCB for stream file object\n");
|
|
|
|
Fcb = Vcb->StreamFileObject->FsContext;
|
|
|
|
Fcb->RefCount++;
|
|
|
|
KeReleaseSpinLock(&Vcb->FcbListLock, oldIrql);
|
|
|
|
return(Fcb);
|
2002-04-15 20:39:49 +00:00
|
|
|
}
|
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
current_entry = Vcb->FcbListHead.Flink;
|
|
|
|
while (current_entry != &Vcb->FcbListHead)
|
2002-04-15 20:39:49 +00:00
|
|
|
{
|
2009-02-03 14:50:50 +00:00
|
|
|
Fcb = CONTAINING_RECORD(current_entry, FCB, FcbListEntry);
|
2002-04-15 20:39:49 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
DPRINT("Comparing '%wZ' and '%S'\n", FileName, Fcb->PathName);
|
|
|
|
if (_wcsicmp(FileName->Buffer, Fcb->PathName) == 0)
|
2006-07-06 15:14:06 +00:00
|
|
|
{
|
2009-02-03 14:50:50 +00:00
|
|
|
Fcb->RefCount++;
|
|
|
|
KeReleaseSpinLock(&Vcb->FcbListLock, oldIrql);
|
|
|
|
return(Fcb);
|
2006-07-06 15:14:06 +00:00
|
|
|
}
|
2002-04-15 20:39:49 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
//FIXME: need to compare against short name in FCB here
|
2002-04-15 20:39:49 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
current_entry = current_entry->Flink;
|
2002-04-15 20:39:49 +00:00
|
|
|
}
|
2009-02-03 14:50:50 +00:00
|
|
|
KeReleaseSpinLock(&Vcb->FcbListLock, oldIrql);
|
2002-04-15 20:39:49 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
return(NULL);
|
2002-04-15 20:39:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
CdfsFCBInitializeCache(PVCB Vcb,
|
2006-07-06 15:14:06 +00:00
|
|
|
PFCB Fcb)
|
2002-04-15 20:39:49 +00:00
|
|
|
{
|
2009-02-03 14:50:50 +00:00
|
|
|
PFILE_OBJECT FileObject;
|
|
|
|
PCCB newCCB;
|
2002-04-15 20:39:49 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
FileObject = IoCreateStreamFileObject(NULL, Vcb->StorageDevice);
|
2002-04-15 20:39:49 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
newCCB = ExAllocatePoolWithTag(NonPagedPool, sizeof(CCB), TAG_CCB);
|
|
|
|
if (newCCB == NULL)
|
2002-04-15 20:39:49 +00:00
|
|
|
{
|
2010-08-30 11:51:17 +00:00
|
|
|
return STATUS_INSUFFICIENT_RESOURCES;
|
2002-04-15 20:39:49 +00:00
|
|
|
}
|
2009-02-03 14:50:50 +00:00
|
|
|
RtlZeroMemory(newCCB,
|
|
|
|
sizeof(CCB));
|
|
|
|
|
2009-02-13 11:48:06 +00:00
|
|
|
FileObject->ReadAccess = TRUE;
|
|
|
|
FileObject->WriteAccess = FALSE;
|
|
|
|
FileObject->DeleteAccess = FALSE;
|
2009-02-03 14:50:50 +00:00
|
|
|
FileObject->SectionObjectPointer = &Fcb->SectionObjectPointers;
|
|
|
|
FileObject->FsContext = Fcb;
|
|
|
|
FileObject->FsContext2 = newCCB;
|
|
|
|
newCCB->PtrFileObject = FileObject;
|
|
|
|
Fcb->FileObject = FileObject;
|
|
|
|
Fcb->DevExt = Vcb;
|
|
|
|
|
|
|
|
CcInitializeCacheMap(FileObject,
|
|
|
|
(PCC_FILE_SIZES)(&Fcb->RFCB.AllocationSize),
|
|
|
|
FALSE,
|
|
|
|
&(CdfsGlobalData->CacheMgrCallbacks),
|
|
|
|
Fcb);
|
|
|
|
|
|
|
|
ObDereferenceObject(FileObject);
|
|
|
|
Fcb->Flags |= FCB_CACHE_INITIALIZED;
|
|
|
|
|
2010-08-30 11:51:17 +00:00
|
|
|
return STATUS_SUCCESS;
|
2002-04-15 20:39:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PFCB
|
|
|
|
CdfsMakeRootFCB(PDEVICE_EXTENSION Vcb)
|
|
|
|
{
|
2009-02-03 14:50:50 +00:00
|
|
|
PFCB Fcb;
|
2002-04-15 20:39:49 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
Fcb = CdfsCreateFCB(L"\\");
|
2002-04-15 20:39:49 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
Fcb->Entry.DataLengthL = Vcb->CdInfo.RootSize;
|
|
|
|
Fcb->Entry.ExtentLocationL = Vcb->CdInfo.RootStart;
|
|
|
|
Fcb->Entry.FileFlags = FILE_FLAG_DIRECTORY;
|
|
|
|
Fcb->IndexNumber.QuadPart = 0LL;
|
|
|
|
Fcb->RefCount = 1;
|
|
|
|
Fcb->DirIndex = 0;
|
|
|
|
Fcb->RFCB.FileSize.QuadPart = Vcb->CdInfo.RootSize;
|
|
|
|
Fcb->RFCB.ValidDataLength.QuadPart = Vcb->CdInfo.RootSize;
|
|
|
|
Fcb->RFCB.AllocationSize.QuadPart = Vcb->CdInfo.RootSize;
|
2002-04-15 20:39:49 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
CdfsFCBInitializeCache(Vcb, Fcb);
|
|
|
|
CdfsAddFCBToTable(Vcb, Fcb);
|
|
|
|
CdfsGrabFCB(Vcb, Fcb);
|
2002-04-15 20:39:49 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
return(Fcb);
|
2002-04-15 20:39:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PFCB
|
|
|
|
CdfsOpenRootFCB(PDEVICE_EXTENSION Vcb)
|
|
|
|
{
|
2009-02-03 14:50:50 +00:00
|
|
|
UNICODE_STRING FileName;
|
|
|
|
PFCB Fcb;
|
2002-04-15 20:39:49 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
RtlInitUnicodeString(&FileName, L"\\");
|
2004-09-14 21:46:39 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
Fcb = CdfsGrabFCBFromTable(Vcb,
|
|
|
|
&FileName);
|
|
|
|
if (Fcb == NULL)
|
2002-04-15 20:39:49 +00:00
|
|
|
{
|
2009-02-03 14:50:50 +00:00
|
|
|
Fcb = CdfsMakeRootFCB(Vcb);
|
2002-04-15 20:39:49 +00:00
|
|
|
}
|
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
return(Fcb);
|
2002-04-15 20:39:49 +00:00
|
|
|
}
|
|
|
|
|
2002-04-12 15:43:38 +00:00
|
|
|
|
2002-05-01 13:15:42 +00:00
|
|
|
static VOID
|
|
|
|
CdfsGetDirEntryName(PDEVICE_EXTENSION DeviceExt,
|
2006-07-06 15:14:06 +00:00
|
|
|
PDIR_RECORD Record,
|
|
|
|
PWSTR Name)
|
2009-02-03 14:50:50 +00:00
|
|
|
/*
|
|
|
|
* FUNCTION: Retrieves the file name from a directory record.
|
|
|
|
*/
|
2002-05-01 13:15:42 +00:00
|
|
|
{
|
2009-02-03 14:50:50 +00:00
|
|
|
if (Record->FileIdLength == 1 && Record->FileId[0] == 0)
|
2002-05-01 13:15:42 +00:00
|
|
|
{
|
2009-02-03 14:50:50 +00:00
|
|
|
wcscpy(Name, L".");
|
2002-05-01 13:15:42 +00:00
|
|
|
}
|
2009-02-03 14:50:50 +00:00
|
|
|
else if (Record->FileIdLength == 1 && Record->FileId[0] == 1)
|
2002-05-01 13:15:42 +00:00
|
|
|
{
|
2009-02-03 14:50:50 +00:00
|
|
|
wcscpy(Name, L"..");
|
2002-05-01 13:15:42 +00:00
|
|
|
}
|
2009-02-03 14:50:50 +00:00
|
|
|
else
|
2002-05-01 13:15:42 +00:00
|
|
|
{
|
2009-02-03 14:50:50 +00:00
|
|
|
if (DeviceExt->CdInfo.JolietLevel == 0)
|
2006-07-06 15:14:06 +00:00
|
|
|
{
|
2009-02-03 14:50:50 +00:00
|
|
|
ULONG i;
|
2002-05-01 13:15:42 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
for (i = 0; i < Record->FileIdLength && Record->FileId[i] != ';'; i++)
|
|
|
|
Name[i] = (WCHAR)Record->FileId[i];
|
|
|
|
Name[i] = 0;
|
2006-07-06 15:14:06 +00:00
|
|
|
}
|
2009-02-03 14:50:50 +00:00
|
|
|
else
|
2006-07-06 15:14:06 +00:00
|
|
|
{
|
2009-02-03 14:50:50 +00:00
|
|
|
CdfsSwapString(Name,
|
|
|
|
Record->FileId,
|
|
|
|
Record->FileIdLength);
|
2006-07-06 15:14:06 +00:00
|
|
|
}
|
2002-05-01 13:15:42 +00:00
|
|
|
}
|
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
DPRINT("Name '%S'\n", Name);
|
2002-05-01 13:15:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-04-15 20:39:49 +00:00
|
|
|
NTSTATUS
|
2002-05-01 13:15:42 +00:00
|
|
|
CdfsMakeFCBFromDirEntry(PVCB Vcb,
|
2006-07-06 15:14:06 +00:00
|
|
|
PFCB DirectoryFCB,
|
|
|
|
PWSTR LongName,
|
|
|
|
PWSTR ShortName,
|
|
|
|
PDIR_RECORD Record,
|
|
|
|
ULONG DirectorySector,
|
|
|
|
ULONG DirectoryOffset,
|
|
|
|
PFCB * fileFCB)
|
2002-04-15 20:39:49 +00:00
|
|
|
{
|
2009-02-03 14:50:50 +00:00
|
|
|
WCHAR pathName[MAX_PATH];
|
|
|
|
PFCB rcFCB;
|
|
|
|
ULONG Size;
|
2002-05-01 13:15:42 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
if (LongName [0] != 0 && wcslen (DirectoryFCB->PathName) +
|
2002-06-06 19:01:04 +00:00
|
|
|
sizeof(WCHAR) + wcslen (LongName) > MAX_PATH)
|
2002-05-01 13:15:42 +00:00
|
|
|
{
|
2009-02-03 14:50:50 +00:00
|
|
|
return(STATUS_OBJECT_NAME_INVALID);
|
2002-05-01 13:15:42 +00:00
|
|
|
}
|
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
wcscpy(pathName, DirectoryFCB->PathName);
|
|
|
|
if (!CdfsFCBIsRoot(DirectoryFCB))
|
2002-04-15 20:39:49 +00:00
|
|
|
{
|
2009-02-03 14:50:50 +00:00
|
|
|
wcscat(pathName, L"\\");
|
2002-04-15 20:39:49 +00:00
|
|
|
}
|
2002-05-01 13:15:42 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
if (LongName[0] != 0)
|
2002-04-15 20:39:49 +00:00
|
|
|
{
|
2009-02-03 14:50:50 +00:00
|
|
|
wcscat(pathName, LongName);
|
2002-04-15 20:39:49 +00:00
|
|
|
}
|
2009-02-03 14:50:50 +00:00
|
|
|
else
|
2002-05-01 13:15:42 +00:00
|
|
|
{
|
2009-02-03 14:50:50 +00:00
|
|
|
WCHAR entryName[MAX_PATH];
|
|
|
|
|
|
|
|
CdfsGetDirEntryName(Vcb, Record, entryName);
|
|
|
|
wcscat(pathName, entryName);
|
|
|
|
}
|
|
|
|
|
|
|
|
rcFCB = CdfsCreateFCB(pathName);
|
|
|
|
memcpy(&rcFCB->Entry, Record, sizeof(DIR_RECORD));
|
|
|
|
|
|
|
|
/* Copy short name into FCB */
|
|
|
|
rcFCB->ShortNameU.Length = wcslen(ShortName) * sizeof(WCHAR);
|
|
|
|
rcFCB->ShortNameU.MaximumLength = rcFCB->ShortNameU.Length;
|
|
|
|
rcFCB->ShortNameU.Buffer = rcFCB->ShortNameBuffer;
|
|
|
|
wcscpy(rcFCB->ShortNameBuffer, ShortName);
|
2002-05-01 13:15:42 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
Size = rcFCB->Entry.DataLengthL;
|
|
|
|
|
|
|
|
rcFCB->RFCB.FileSize.QuadPart = Size;
|
|
|
|
rcFCB->RFCB.ValidDataLength.QuadPart = Size;
|
|
|
|
rcFCB->RFCB.AllocationSize.QuadPart = ROUND_UP(Size, BLOCKSIZE);
|
|
|
|
if (CdfsFCBIsDirectory(rcFCB))
|
|
|
|
{
|
|
|
|
CdfsFCBInitializeCache(Vcb, rcFCB);
|
2002-05-01 13:15:42 +00:00
|
|
|
}
|
2009-02-03 14:50:50 +00:00
|
|
|
rcFCB->IndexNumber.u.HighPart = DirectorySector;
|
|
|
|
rcFCB->IndexNumber.u.LowPart = DirectoryOffset;
|
|
|
|
rcFCB->RefCount++;
|
|
|
|
CdfsAddFCBToTable(Vcb, rcFCB);
|
|
|
|
*fileFCB = rcFCB;
|
|
|
|
|
|
|
|
DPRINT("%S %d %I64d\n", LongName, Size, rcFCB->RFCB.AllocationSize.QuadPart);
|
2002-05-01 13:15:42 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
return(STATUS_SUCCESS);
|
2002-04-15 20:39:49 +00:00
|
|
|
}
|
2002-05-01 13:15:42 +00:00
|
|
|
|
2002-04-15 20:39:49 +00:00
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
CdfsAttachFCBToFileObject(PDEVICE_EXTENSION Vcb,
|
2006-07-06 15:14:06 +00:00
|
|
|
PFCB Fcb,
|
|
|
|
PFILE_OBJECT FileObject)
|
2002-04-15 20:39:49 +00:00
|
|
|
{
|
2009-02-03 14:50:50 +00:00
|
|
|
PCCB newCCB;
|
2002-04-15 20:39:49 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
newCCB = ExAllocatePoolWithTag(NonPagedPool, sizeof(CCB), TAG_CCB);
|
|
|
|
if (newCCB == NULL)
|
2002-04-15 20:39:49 +00:00
|
|
|
{
|
2009-02-03 14:50:50 +00:00
|
|
|
return(STATUS_INSUFFICIENT_RESOURCES);
|
2002-04-15 20:39:49 +00:00
|
|
|
}
|
2009-02-03 14:50:50 +00:00
|
|
|
memset(newCCB, 0, sizeof(CCB));
|
2002-04-12 15:43:38 +00:00
|
|
|
|
2010-08-30 11:51:17 +00:00
|
|
|
FileObject->ReadAccess = TRUE;
|
|
|
|
FileObject->WriteAccess = FALSE;
|
|
|
|
FileObject->DeleteAccess = FALSE;
|
2009-02-03 14:50:50 +00:00
|
|
|
FileObject->SectionObjectPointer = &Fcb->SectionObjectPointers;
|
|
|
|
FileObject->FsContext = Fcb;
|
|
|
|
FileObject->FsContext2 = newCCB;
|
|
|
|
newCCB->PtrFileObject = FileObject;
|
|
|
|
Fcb->DevExt = Vcb;
|
2005-05-08 02:16:32 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
if (CdfsFCBIsDirectory(Fcb))
|
2002-04-15 20:39:49 +00:00
|
|
|
{
|
2009-02-03 14:50:50 +00:00
|
|
|
CcInitializeCacheMap(FileObject,
|
|
|
|
(PCC_FILE_SIZES)(&Fcb->RFCB.AllocationSize),
|
|
|
|
FALSE,
|
|
|
|
&(CdfsGlobalData->CacheMgrCallbacks),
|
|
|
|
Fcb);
|
|
|
|
Fcb->Flags |= FCB_CACHE_INITIALIZED;
|
2002-04-15 20:39:49 +00:00
|
|
|
}
|
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
DPRINT("file open: fcb:%x file size: %d\n", Fcb, Fcb->Entry.DataLengthL);
|
2002-04-15 20:39:49 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
return(STATUS_SUCCESS);
|
2002-04-12 15:43:38 +00:00
|
|
|
}
|
|
|
|
|
2002-05-01 13:15:42 +00:00
|
|
|
|
2002-04-15 20:39:49 +00:00
|
|
|
NTSTATUS
|
2002-05-01 13:15:42 +00:00
|
|
|
CdfsDirFindFile(PDEVICE_EXTENSION DeviceExt,
|
2006-07-06 15:14:06 +00:00
|
|
|
PFCB DirectoryFcb,
|
|
|
|
PUNICODE_STRING FileToFind,
|
|
|
|
PFCB *FoundFCB)
|
2002-04-15 20:39:49 +00:00
|
|
|
{
|
2009-02-03 14:50:50 +00:00
|
|
|
UNICODE_STRING TempName;
|
|
|
|
WCHAR Name[256];
|
|
|
|
PVOID Block;
|
|
|
|
ULONG DirSize;
|
|
|
|
PDIR_RECORD Record;
|
|
|
|
ULONG Offset;
|
|
|
|
ULONG BlockOffset;
|
|
|
|
NTSTATUS Status;
|
|
|
|
|
2009-02-04 03:39:23 +00:00
|
|
|
LARGE_INTEGER StreamOffset, OffsetOfEntry;
|
2009-02-03 14:50:50 +00:00
|
|
|
PVOID Context;
|
|
|
|
|
|
|
|
WCHAR ShortNameBuffer[13];
|
|
|
|
UNICODE_STRING ShortName;
|
|
|
|
UNICODE_STRING LongName;
|
|
|
|
UNICODE_STRING FileToFindUpcase;
|
|
|
|
|
|
|
|
ASSERT(DeviceExt);
|
|
|
|
ASSERT(DirectoryFcb);
|
|
|
|
ASSERT(FileToFind);
|
|
|
|
|
|
|
|
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 (FileToFind->Length == 0)
|
2002-04-15 20:39:49 +00:00
|
|
|
{
|
2009-02-03 14:50:50 +00:00
|
|
|
RtlInitUnicodeString(&TempName, L".");
|
|
|
|
FileToFind = &TempName;
|
2002-04-15 20:39:49 +00:00
|
|
|
}
|
2002-05-01 13:15:42 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
DirSize = DirectoryFcb->Entry.DataLengthL;
|
|
|
|
StreamOffset.QuadPart = (LONGLONG)DirectoryFcb->Entry.ExtentLocationL * (LONGLONG)BLOCKSIZE;
|
2002-05-01 13:15:42 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
if (!CcMapData(DeviceExt->StreamFileObject,
|
|
|
|
&StreamOffset,
|
|
|
|
BLOCKSIZE,
|
|
|
|
TRUE,
|
|
|
|
&Context,
|
|
|
|
&Block))
|
2004-09-14 21:46:39 +00:00
|
|
|
{
|
2009-02-03 14:50:50 +00:00
|
|
|
DPRINT("CcMapData() failed\n");
|
|
|
|
return STATUS_UNSUCCESSFUL;
|
2004-09-14 21:46:39 +00:00
|
|
|
}
|
2002-04-15 20:39:49 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
Offset = 0;
|
|
|
|
BlockOffset = 0;
|
|
|
|
Record = (PDIR_RECORD)Block;
|
2008-11-20 20:24:10 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
/* Upper case the expression for FsRtlIsNameInExpression */
|
|
|
|
Status = RtlUpcaseUnicodeString(&FileToFindUpcase, FileToFind, TRUE);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
return Status;
|
|
|
|
}
|
2008-11-20 20:24:10 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
while(TRUE)
|
2002-04-15 20:39:49 +00:00
|
|
|
{
|
2009-02-03 14:50:50 +00:00
|
|
|
if (Record->RecordLength == 0)
|
2006-07-06 15:14:06 +00:00
|
|
|
{
|
2009-02-03 14:50:50 +00:00
|
|
|
DPRINT("RecordLength == 0 Stopped!\n");
|
|
|
|
break;
|
2006-07-06 15:14:06 +00:00
|
|
|
}
|
2005-05-08 02:16:32 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
DPRINT("RecordLength %u ExtAttrRecordLength %u NameLength %u\n",
|
|
|
|
Record->RecordLength, Record->ExtAttrRecordLength, Record->FileIdLength);
|
2002-05-01 13:15:42 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
CdfsGetDirEntryName(DeviceExt, Record, Name);
|
|
|
|
DPRINT ("Name '%S'\n", Name);
|
|
|
|
DPRINT ("Sector %lu\n", DirectoryFcb->Entry.ExtentLocationL);
|
|
|
|
DPRINT ("Offset %lu\n", Offset);
|
2002-05-01 13:15:42 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
RtlInitUnicodeString(&LongName, Name);
|
|
|
|
ShortName.Length = 0;
|
|
|
|
ShortName.MaximumLength = 26;
|
|
|
|
ShortName.Buffer = ShortNameBuffer;
|
|
|
|
memset(ShortNameBuffer, 0, 26);
|
2002-06-06 19:01:04 +00:00
|
|
|
|
2009-02-04 06:04:24 +00:00
|
|
|
OffsetOfEntry.QuadPart = StreamOffset.QuadPart + Offset;
|
|
|
|
CdfsShortNameCacheGet(DirectoryFcb, &OffsetOfEntry, &LongName, &ShortName);
|
2002-06-06 19:01:04 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
DPRINT("ShortName '%wZ'\n", &ShortName);
|
2002-06-06 19:01:04 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
if (FsRtlIsNameInExpression(&FileToFindUpcase, &LongName, TRUE, NULL) ||
|
|
|
|
FsRtlIsNameInExpression(&FileToFindUpcase, &ShortName, TRUE, NULL))
|
2006-07-06 15:14:06 +00:00
|
|
|
{
|
2009-02-03 14:50:50 +00:00
|
|
|
DPRINT("Match found, %S\n", Name);
|
|
|
|
Status = CdfsMakeFCBFromDirEntry(DeviceExt,
|
|
|
|
DirectoryFcb,
|
|
|
|
Name,
|
|
|
|
ShortNameBuffer,
|
|
|
|
Record,
|
|
|
|
DirectoryFcb->Entry.ExtentLocationL,
|
|
|
|
Offset,
|
|
|
|
FoundFCB);
|
|
|
|
|
|
|
|
RtlFreeUnicodeString(&FileToFindUpcase);
|
|
|
|
CcUnpinData(Context);
|
|
|
|
|
|
|
|
return(Status);
|
2006-07-06 15:14:06 +00:00
|
|
|
}
|
2002-05-01 13:15:42 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
Offset += Record->RecordLength;
|
|
|
|
BlockOffset += Record->RecordLength;
|
|
|
|
Record = (PDIR_RECORD)((ULONG_PTR)Block + BlockOffset);
|
|
|
|
if (BlockOffset >= BLOCKSIZE || Record->RecordLength == 0)
|
2006-07-06 15:14:06 +00:00
|
|
|
{
|
2009-02-03 14:50:50 +00:00
|
|
|
DPRINT("Map next sector\n");
|
|
|
|
CcUnpinData(Context);
|
|
|
|
StreamOffset.QuadPart += BLOCKSIZE;
|
|
|
|
Offset = ROUND_UP(Offset, BLOCKSIZE);
|
|
|
|
BlockOffset = 0;
|
|
|
|
|
|
|
|
if (!CcMapData(DeviceExt->StreamFileObject,
|
|
|
|
&StreamOffset,
|
|
|
|
BLOCKSIZE, TRUE,
|
|
|
|
&Context, &Block))
|
2006-07-06 15:14:06 +00:00
|
|
|
{
|
2009-02-03 14:50:50 +00:00
|
|
|
DPRINT("CcMapData() failed\n");
|
|
|
|
RtlFreeUnicodeString(&FileToFindUpcase);
|
|
|
|
return(STATUS_UNSUCCESSFUL);
|
2006-07-06 15:14:06 +00:00
|
|
|
}
|
2009-02-03 14:50:50 +00:00
|
|
|
Record = (PDIR_RECORD)((ULONG_PTR)Block + BlockOffset);
|
2006-07-06 15:14:06 +00:00
|
|
|
}
|
2002-05-01 13:15:42 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
if (Offset >= DirSize)
|
|
|
|
break;
|
2002-04-12 15:43:38 +00:00
|
|
|
}
|
2002-04-15 20:39:49 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
RtlFreeUnicodeString(&FileToFindUpcase);
|
|
|
|
CcUnpinData(Context);
|
2002-05-01 13:15:42 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
return(STATUS_OBJECT_NAME_NOT_FOUND);
|
2002-04-12 15:43:38 +00:00
|
|
|
}
|
2002-04-15 20:39:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
CdfsGetFCBForFile(PDEVICE_EXTENSION Vcb,
|
2006-07-06 15:14:06 +00:00
|
|
|
PFCB *pParentFCB,
|
|
|
|
PFCB *pFCB,
|
|
|
|
PUNICODE_STRING FileName)
|
2002-04-15 20:39:49 +00:00
|
|
|
{
|
2009-02-03 14:50:50 +00:00
|
|
|
UNICODE_STRING PathName;
|
|
|
|
UNICODE_STRING ElementName;
|
|
|
|
NTSTATUS Status;
|
|
|
|
WCHAR pathName [MAX_PATH];
|
|
|
|
WCHAR elementName [MAX_PATH];
|
|
|
|
PWCHAR currentElement;
|
|
|
|
PFCB FCB;
|
|
|
|
PFCB parentFCB;
|
|
|
|
|
|
|
|
DPRINT("CdfsGetFCBForFile(%x, %x, %x, '%wZ')\n",
|
|
|
|
Vcb,
|
|
|
|
pParentFCB,
|
|
|
|
pFCB,
|
|
|
|
FileName);
|
|
|
|
|
|
|
|
/* Trivial case, open of the root directory on volume */
|
|
|
|
if (FileName->Buffer[0] == L'\0' || wcscmp(FileName->Buffer, L"\\") == 0)
|
2002-04-15 20:39:49 +00:00
|
|
|
{
|
2009-02-03 14:50:50 +00:00
|
|
|
DPRINT("returning root FCB\n");
|
2002-04-15 20:39:49 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
FCB = CdfsOpenRootFCB(Vcb);
|
|
|
|
*pFCB = FCB;
|
|
|
|
*pParentFCB = NULL;
|
2002-04-15 20:39:49 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
return((FCB != NULL) ? STATUS_SUCCESS : STATUS_OBJECT_PATH_NOT_FOUND);
|
2002-04-15 20:39:49 +00:00
|
|
|
}
|
2009-02-03 14:50:50 +00:00
|
|
|
else
|
2002-04-15 20:39:49 +00:00
|
|
|
{
|
2009-02-03 14:50:50 +00:00
|
|
|
currentElement = &FileName->Buffer[1];
|
|
|
|
wcscpy (pathName, L"\\");
|
|
|
|
FCB = CdfsOpenRootFCB (Vcb);
|
2002-04-15 20:39:49 +00:00
|
|
|
}
|
2009-02-03 14:50:50 +00:00
|
|
|
parentFCB = NULL;
|
2002-04-15 20:39:49 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
/* Parse filename and check each path element for existance and access */
|
|
|
|
while (CdfsGetNextPathElement(currentElement) != 0)
|
2002-04-15 20:39:49 +00:00
|
|
|
{
|
2009-02-03 14:50:50 +00:00
|
|
|
/* Skip blank directory levels */
|
|
|
|
if ((CdfsGetNextPathElement(currentElement) - currentElement) == 0)
|
2006-07-06 15:14:06 +00:00
|
|
|
{
|
2009-02-03 14:50:50 +00:00
|
|
|
currentElement++;
|
|
|
|
continue;
|
2006-07-06 15:14:06 +00:00
|
|
|
}
|
2002-04-15 20:39:49 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
DPRINT("Parsing, currentElement:%S\n", currentElement);
|
|
|
|
DPRINT(" parentFCB:%x FCB:%x\n", parentFCB, FCB);
|
2002-04-15 20:39:49 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
/* Descend to next directory level */
|
|
|
|
if (parentFCB)
|
2006-07-06 15:14:06 +00:00
|
|
|
{
|
2009-02-03 14:50:50 +00:00
|
|
|
CdfsReleaseFCB(Vcb, parentFCB);
|
|
|
|
parentFCB = NULL;
|
2006-07-06 15:14:06 +00:00
|
|
|
}
|
2002-04-15 20:39:49 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
/* fail if element in FCB is not a directory */
|
|
|
|
if (!CdfsFCBIsDirectory(FCB))
|
2006-07-06 15:14:06 +00:00
|
|
|
{
|
2009-02-03 14:50:50 +00:00
|
|
|
DPRINT("Element in requested path is not a directory\n");
|
2002-04-15 20:39:49 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
CdfsReleaseFCB(Vcb, FCB);
|
|
|
|
FCB = 0;
|
|
|
|
*pParentFCB = NULL;
|
|
|
|
*pFCB = NULL;
|
2002-04-15 20:39:49 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
return(STATUS_OBJECT_PATH_NOT_FOUND);
|
2006-07-06 15:14:06 +00:00
|
|
|
}
|
2009-02-03 14:50:50 +00:00
|
|
|
parentFCB = FCB;
|
2002-04-15 20:39:49 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
/* Extract next directory level into dirName */
|
|
|
|
CdfsWSubString(pathName,
|
|
|
|
FileName->Buffer,
|
|
|
|
CdfsGetNextPathElement(currentElement) - FileName->Buffer);
|
|
|
|
DPRINT(" pathName:%S\n", pathName);
|
2002-05-01 13:15:42 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
RtlInitUnicodeString(&PathName, pathName);
|
2004-09-14 21:46:39 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
FCB = CdfsGrabFCBFromTable(Vcb, &PathName);
|
|
|
|
if (FCB == NULL)
|
2006-07-06 15:14:06 +00:00
|
|
|
{
|
2009-02-03 14:50:50 +00:00
|
|
|
CdfsWSubString(elementName,
|
|
|
|
currentElement,
|
|
|
|
CdfsGetNextPathElement(currentElement) - currentElement);
|
|
|
|
DPRINT(" elementName:%S\n", elementName);
|
|
|
|
|
|
|
|
RtlInitUnicodeString(&ElementName, elementName);
|
|
|
|
Status = CdfsDirFindFile(Vcb,
|
|
|
|
parentFCB,
|
|
|
|
&ElementName,
|
|
|
|
&FCB);
|
|
|
|
if (Status == STATUS_OBJECT_NAME_NOT_FOUND)
|
2006-07-06 15:14:06 +00:00
|
|
|
{
|
2009-02-03 14:50:50 +00:00
|
|
|
*pParentFCB = parentFCB;
|
|
|
|
*pFCB = NULL;
|
|
|
|
currentElement = CdfsGetNextPathElement(currentElement);
|
|
|
|
if (*currentElement == L'\0' || CdfsGetNextPathElement(currentElement + 1) == 0)
|
2006-07-06 15:14:06 +00:00
|
|
|
{
|
2009-02-03 14:50:50 +00:00
|
|
|
return(STATUS_OBJECT_NAME_NOT_FOUND);
|
2006-07-06 15:14:06 +00:00
|
|
|
}
|
2009-02-03 14:50:50 +00:00
|
|
|
else
|
2006-07-06 15:14:06 +00:00
|
|
|
{
|
2009-02-03 14:50:50 +00:00
|
|
|
return(STATUS_OBJECT_PATH_NOT_FOUND);
|
2006-07-06 15:14:06 +00:00
|
|
|
}
|
|
|
|
}
|
2009-02-03 14:50:50 +00:00
|
|
|
else if (!NT_SUCCESS(Status))
|
2006-07-06 15:14:06 +00:00
|
|
|
{
|
2009-02-03 14:50:50 +00:00
|
|
|
CdfsReleaseFCB(Vcb, parentFCB);
|
|
|
|
*pParentFCB = NULL;
|
|
|
|
*pFCB = NULL;
|
2006-07-06 15:14:06 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
return(Status);
|
2006-07-06 15:14:06 +00:00
|
|
|
}
|
|
|
|
}
|
2009-02-03 14:50:50 +00:00
|
|
|
currentElement = CdfsGetNextPathElement(currentElement);
|
2002-04-15 20:39:49 +00:00
|
|
|
}
|
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
*pParentFCB = parentFCB;
|
|
|
|
*pFCB = FCB;
|
2002-04-15 20:39:49 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
return STATUS_SUCCESS;
|
2002-04-15 20:39:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* EOF */
|