/*
-* 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/dirctl.c
-* PURPOSE: CDROM (ISO 9660) filesystem driver
-* PROGRAMMER: Art Yerkes
-* Eric Kohl
-* 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/dirctl.c
+ * PURPOSE: CDROM (ISO 9660) filesystem driver
+ * PROGRAMMER: Art Yerkes
+ * Eric Kohl
+ * UPDATE HISTORY:
+ */
/* INCLUDES *****************************************************************/
PDIR_RECORD Record;
LARGE_INTEGER StreamOffset, OffsetOfEntry;
- DPRINT("FindFile(Parent %x, FileToFind '%wZ', DirIndex: %d)\n",
+ DPRINT("FindFile(Parent %p, FileToFind '%wZ', DirIndex: %u)\n",
Parent, FileToFind, pDirIndex ? *pDirIndex : 0);
- DPRINT("FindFile: old Pathname %x, old Objectname %x)\n",
+ DPRINT("FindFile: old Pathname %p, old Objectname %p)\n",
Fcb->PathName, Fcb->ObjectName);
IsRoot = FALSE;
/* it's root : complete essentials fields then return ok */
RtlZeroMemory(Fcb, sizeof(FCB));
- Fcb->PathName[0] = '\\';
- Fcb->ObjectName = &Fcb->PathName[1];
+ Fcb->PathNameBuffer[0] = '\\';
+ Fcb->ObjectName = &Fcb->PathNameBuffer[1];
Fcb->Entry.ExtentLocationL = DeviceExt->CdInfo.RootStart;
Fcb->Entry.DataLengthL = DeviceExt->CdInfo.RootSize;
Fcb->Entry.FileFlags = 0x02; //FILE_ATTRIBUTE_DIRECTORY;
+ Fcb->PathName.Length = sizeof(WCHAR);
+ Fcb->PathName.MaximumLength = sizeof(Fcb->PathNameBuffer);
+ Fcb->PathName.Buffer = Fcb->PathNameBuffer;
if (pDirIndex)
*pDirIndex = 0;
if (pOffset)
*pOffset = 0;
- DPRINT("CdfsFindFile: new Pathname %S, new Objectname %S)\n",Fcb->PathName, Fcb->ObjectName);
+ DPRINT("CdfsFindFile: new Pathname %wZ, new Objectname %S)\n",&Fcb->PathName, Fcb->ObjectName);
return STATUS_SUCCESS;
}
}
DirSize = Parent->Entry.DataLengthL;
}
- DPRINT("StreamOffset %I64u DirSize %lu\n", StreamOffset.QuadPart, DirSize);
+ DPRINT("StreamOffset %I64d DirSize %u\n", StreamOffset.QuadPart, DirSize);
if (pDirIndex && (*pDirIndex))
DirIndex = *pDirIndex;
if (FsRtlIsNameInExpression(&FileToFindUpcase, &LongName, TRUE, NULL) ||
FsRtlIsNameInExpression(&FileToFindUpcase, &ShortName, TRUE, NULL))
{
- if (Parent && Parent->PathName)
+ if (Parent->PathName.Buffer[0])
{
- len = wcslen(Parent->PathName);
- memcpy(Fcb->PathName, Parent->PathName, len*sizeof(WCHAR));
- Fcb->ObjectName=&Fcb->PathName[len];
- if (len != 1 || Fcb->PathName[0] != '\\')
+ len = Parent->PathName.Length / sizeof(WCHAR);
+ memcpy(Fcb->PathName.Buffer, Parent->PathName.Buffer, Parent->PathName.Length);
+ Fcb->PathName.Length = Parent->PathName.Length;
+ Fcb->ObjectName=&Fcb->PathName.Buffer[len];
+ if (len != 1 || Fcb->PathName.Buffer[0] != '\\')
{
Fcb->ObjectName[0] = '\\';
Fcb->ObjectName = &Fcb->ObjectName[1];
}
else
{
- Fcb->ObjectName=Fcb->PathName;
+ Fcb->ObjectName=Fcb->PathName.Buffer;
Fcb->ObjectName[0]='\\';
Fcb->ObjectName=&Fcb->ObjectName[1];
}
- DPRINT("PathName '%S' ObjectName '%S'\n", Fcb->PathName, Fcb->ObjectName);
+ DPRINT("PathName '%wZ' ObjectName '%S'\n", &Fcb->PathName, Fcb->ObjectName);
memcpy(&Fcb->Entry, Record, sizeof(DIR_RECORD));
- wcsncpy(Fcb->ObjectName, name, MAX_PATH);
+ wcsncpy(Fcb->ObjectName, name, min(wcslen(name) + 1,
+ MAX_PATH - (Fcb->PathName.Length / sizeof(WCHAR)) + wcslen(Fcb->ObjectName)));
/* Copy short name */
Fcb->ShortNameU.Length = ShortName.Length;
if (pOffset)
*pOffset = Offset;
- DPRINT("FindFile: new Pathname %S, new Objectname %S, DirIndex %d\n",
- Fcb->PathName, Fcb->ObjectName, DirIndex);
+ DPRINT("FindFile: new Pathname %wZ, new Objectname %S, DirIndex %u\n",
+ &Fcb->PathName, Fcb->ObjectName, DirIndex);
RtlFreeUnicodeString(&FileToFindUpcase);
CcUnpinData(Context);
DPRINT("CdfsGetNameInformation() called\n");
+ UNREFERENCED_PARAMETER(DeviceExt);
+
Length = wcslen(Fcb->ObjectName) * sizeof(WCHAR);
if ((sizeof(FILE_NAMES_INFORMATION) + Length) > BufferLength)
return(STATUS_BUFFER_OVERFLOW);
DPRINT("CdfsGetDirectoryInformation() called\n");
+ UNREFERENCED_PARAMETER(DeviceExt);
+
Length = wcslen(Fcb->ObjectName) * sizeof(WCHAR);
if ((sizeof (FILE_DIRECTORY_INFORMATION) + Length) > BufferLength)
return(STATUS_BUFFER_OVERFLOW);
DPRINT("CdfsGetFullDirectoryInformation() called\n");
+ UNREFERENCED_PARAMETER(DeviceExt);
+
Length = wcslen(Fcb->ObjectName) * sizeof(WCHAR);
if ((sizeof (FILE_FULL_DIR_INFORMATION) + Length) > BufferLength)
return(STATUS_BUFFER_OVERFLOW);
DPRINT("CdfsGetBothDirectoryInformation() called\n");
+ UNREFERENCED_PARAMETER(DeviceExt);
+
Length = wcslen(Fcb->ObjectName) * sizeof(WCHAR);
if ((sizeof (FILE_BOTH_DIR_INFORMATION) + Length) > BufferLength)
return(STATUS_BUFFER_OVERFLOW);
/* Copy short name */
ASSERT(Fcb->ShortNameU.Length / sizeof(WCHAR) <= 12);
- Info->ShortNameLength = Fcb->ShortNameU.Length;
+ Info->ShortNameLength = (CCHAR)Fcb->ShortNameU.Length;
RtlCopyMemory(Info->ShortName, Fcb->ShortNameU.Buffer, Fcb->ShortNameU.Length);
return(STATUS_SUCCESS);
DeviceExtension = DeviceObject->DeviceExtension;
Stack = IoGetCurrentIrpStackLocation(Irp);
FileObject = Stack->FileObject;
+ TempFcb.PathName.Buffer = TempFcb.PathNameBuffer;
+ TempFcb.PathName.MaximumLength = sizeof(TempFcb.PathNameBuffer);
Ccb = (PCCB)FileObject->FsContext2;
Fcb = (PFCB)FileObject->FsContext;
Buffer = Irp->UserBuffer;
}
- if (SearchPattern != NULL)
+ /* Allocate search pattern in case:
+ * -> We don't have one already in context
+ * -> We have been given an input pattern
+ * -> The pattern length is not null
+ * -> The pattern buffer is not null
+ * Otherwise, we'll fall later and allocate a match all (*) pattern
+ */
+ if (SearchPattern != NULL &&
+ SearchPattern->Length != 0 && SearchPattern->Buffer != NULL)
{
if (Ccb->DirectorySearchPattern.Buffer == NULL)
{
}
DPRINT("Buffer = %p tofind = %wZ\n", Buffer, &Ccb->DirectorySearchPattern);
- TempFcb.ObjectName = TempFcb.PathName;
+ TempFcb.ObjectName = TempFcb.PathName.Buffer;
while (Status == STATUS_SUCCESS && BufferLength > 0)
{
Status = CdfsFindFile(DeviceExtension,
}
-
NTSTATUS NTAPI
CdfsDirectoryControl(PDEVICE_OBJECT DeviceObject,
PIRP Irp)
break;
default:
- DPRINT1("CDFS: MinorFunction %d\n", Stack->MinorFunction);
+ DPRINT1("CDFS: MinorFunction %u\n", Stack->MinorFunction);
Status = STATUS_INVALID_DEVICE_REQUEST;
break;
}