/*
-* 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.
-*
-* 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.
-*/
-/* $Id$
-*
-* 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:
-*/
+ * 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.
+ *
+ * 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.
+ */
+/*
+ * 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:
+ */
/* INCLUDES *****************************************************************/
static VOID
-CdfsWSubString(PWCHAR pTarget, const PWCHAR pSource, size_t pLength)
+CdfsWSubString(LPWSTR pTarget, LPCWSTR pSource, size_t pLength)
{
wcsncpy (pTarget, pSource, pLength);
pTarget [pLength] = L'\0';
if(!Fcb) return NULL;
RtlZeroMemory(Fcb, sizeof(FCB));
+ Fcb->PathName.Buffer = Fcb->PathNameBuffer;
+ Fcb->PathName.MaximumLength = sizeof(Fcb->PathNameBuffer);
if (FileName)
{
- wcscpy(Fcb->PathName, FileName);
- if (wcsrchr(Fcb->PathName, '\\') != 0)
+ RtlAppendUnicodeToString(&Fcb->PathName, FileName);
+ if (wcsrchr(Fcb->PathName.Buffer, '\\') != 0)
{
- Fcb->ObjectName = wcsrchr(Fcb->PathName, '\\');
+ Fcb->ObjectName = wcsrchr(Fcb->PathName.Buffer, '\\');
}
else
{
- Fcb->ObjectName = Fcb->PathName;
+ Fcb->ObjectName = Fcb->PathName.Buffer;
}
}
BOOLEAN
CdfsFCBIsRoot(PFCB Fcb)
{
- return(wcscmp(Fcb->PathName, L"\\") == 0);
+ return (Fcb->PathName.Length = sizeof(WCHAR) && Fcb->PathName.Buffer[0] == L'\\');
}
{
KIRQL oldIrql;
- DPRINT("grabbing FCB at %x: %S, refCount:%d\n",
+ DPRINT("grabbing FCB at %p: %S, refCount:%d\n",
Fcb,
Fcb->PathName,
Fcb->RefCount);
{
KIRQL oldIrql;
- DPRINT("releasing FCB at %x: %S, refCount:%d\n",
+ DPRINT("releasing FCB at %p: %wZ, refCount:%d\n",
Fcb,
- Fcb->PathName,
+ &Fcb->PathName,
Fcb->RefCount);
KeAcquireSpinLock(&Vcb->FcbListLock, &oldIrql);
{
Fcb = CONTAINING_RECORD(current_entry, FCB, FcbListEntry);
- DPRINT("Comparing '%wZ' and '%S'\n", FileName, Fcb->PathName);
- if (_wcsicmp(FileName->Buffer, Fcb->PathName) == 0)
+ DPRINT("Comparing '%wZ' and '%wZ'\n", FileName, &Fcb->PathName);
+ if (RtlCompareUnicodeString(FileName, &Fcb->PathName, TRUE) == 0)
{
Fcb->RefCount++;
KeReleaseSpinLock(&Vcb->FcbListLock, oldIrql);
PFCB Fcb)
{
PFILE_OBJECT FileObject;
- NTSTATUS Status;
PCCB newCCB;
FileObject = IoCreateStreamFileObject(NULL, Vcb->StorageDevice);
newCCB = ExAllocatePoolWithTag(NonPagedPool, sizeof(CCB), TAG_CCB);
if (newCCB == NULL)
{
- return(STATUS_INSUFFICIENT_RESOURCES);
+ return STATUS_INSUFFICIENT_RESOURCES;
}
RtlZeroMemory(newCCB,
sizeof(CCB));
Fcb->FileObject = FileObject;
Fcb->DevExt = Vcb;
- Status = STATUS_SUCCESS;
CcInitializeCacheMap(FileObject,
(PCC_FILE_SIZES)(&Fcb->RFCB.AllocationSize),
FALSE,
ObDereferenceObject(FileObject);
Fcb->Flags |= FCB_CACHE_INITIALIZED;
- return(Status);
+ return STATUS_SUCCESS;
}
PFCB rcFCB;
ULONG Size;
- if (LongName [0] != 0 && wcslen (DirectoryFCB->PathName) +
- sizeof(WCHAR) + wcslen (LongName) > MAX_PATH)
+ /* Check if the full string would overflow the pathName buffer (the additional characters are for '\\' and '\0') */
+ if ((LongName[0] != 0) &&
+ ((DirectoryFCB->PathName.Length / sizeof(WCHAR)) + 1 + wcslen(LongName) + 1 > MAX_PATH))
{
return(STATUS_OBJECT_NAME_INVALID);
}
- wcscpy(pathName, DirectoryFCB->PathName);
+ wcscpy(pathName, DirectoryFCB->PathName.Buffer);
if (!CdfsFCBIsRoot(DirectoryFCB))
{
wcscat(pathName, L"\\");
CdfsAddFCBToTable(Vcb, rcFCB);
*fileFCB = rcFCB;
- DPRINT("%S %d %I64d\n", LongName, Size, rcFCB->RFCB.AllocationSize.QuadPart);
+ DPRINT("%S %u %I64d\n", LongName, Size, rcFCB->RFCB.AllocationSize.QuadPart);
return(STATUS_SUCCESS);
}
}
memset(newCCB, 0, sizeof(CCB));
+ FileObject->ReadAccess = TRUE;
+ FileObject->WriteAccess = FALSE;
+ FileObject->DeleteAccess = FALSE;
FileObject->SectionObjectPointer = &Fcb->SectionObjectPointers;
FileObject->FsContext = Fcb;
FileObject->FsContext2 = newCCB;
Fcb->Flags |= FCB_CACHE_INITIALIZED;
}
- DPRINT("file open: fcb:%x file size: %d\n", Fcb, Fcb->Entry.DataLengthL);
+ DPRINT("file open: fcb:%p file size: %u\n", Fcb, Fcb->Entry.DataLengthL);
return(STATUS_SUCCESS);
}
DeviceExt,
DirectoryFcb,
FileToFind);
- DPRINT("Dir Path:%S\n", DirectoryFcb->PathName);
+ DPRINT("Dir Path:%wZ\n", &DirectoryFcb->PathName);
/* default to '.' if no filename specified */
if (FileToFind->Length == 0)
PFCB FCB;
PFCB parentFCB;
- DPRINT("CdfsGetFCBForFile(%x, %x, %x, '%wZ')\n",
+ DPRINT("CdfsGetFCBForFile(%p, %p, %p, '%wZ')\n",
Vcb,
pParentFCB,
pFCB,
}
DPRINT("Parsing, currentElement:%S\n", currentElement);
- DPRINT(" parentFCB:%x FCB:%x\n", parentFCB, FCB);
+ DPRINT(" parentFCB:%p FCB:%p\n", parentFCB, FCB);
/* Descend to next directory level */
if (parentFCB)