fix formatting

svn path=/trunk/; revision=39327
This commit is contained in:
Christoph von Wittich 2009-02-03 14:50:50 +00:00
parent a9d8af1af6
commit 8517038812
12 changed files with 2637 additions and 2632 deletions

View file

@ -1,30 +1,30 @@
/* /*
* ReactOS kernel * ReactOS kernel
* Copyright (C) 2002, 2003 ReactOS Team * Copyright (C) 2002, 2003 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
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* 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$ /* $Id$
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
* FILE: drivers/fs/cdfs/cdfs.c * FILE: drivers/fs/cdfs/cdfs.c
* PURPOSE: CDROM (ISO 9660) filesystem driver * PURPOSE: CDROM (ISO 9660) filesystem driver
* PROGRAMMER: Art Yerkes * PROGRAMMER: Art Yerkes
* Eric Kohl * Eric Kohl
*/ */
/* INCLUDES *****************************************************************/ /* INCLUDES *****************************************************************/
@ -42,72 +42,72 @@ PCDFS_GLOBAL_DATA CdfsGlobalData;
NTSTATUS NTAPI NTSTATUS NTAPI
DriverEntry(PDRIVER_OBJECT DriverObject, DriverEntry(PDRIVER_OBJECT DriverObject,
PUNICODE_STRING RegistryPath) PUNICODE_STRING RegistryPath)
/* /*
* FUNCTION: Called by the system to initalize the driver * FUNCTION: Called by the system to initalize the driver
* ARGUMENTS: * ARGUMENTS:
* DriverObject = object describing this driver * DriverObject = object describing this driver
* RegistryPath = path to our configuration entries * RegistryPath = path to our configuration entries
* RETURNS: Success or failure * RETURNS: Success or failure
*/ */
{ {
PDEVICE_OBJECT DeviceObject; PDEVICE_OBJECT DeviceObject;
NTSTATUS Status; NTSTATUS Status;
UNICODE_STRING DeviceName = RTL_CONSTANT_STRING(L"\\Cdfs"); UNICODE_STRING DeviceName = RTL_CONSTANT_STRING(L"\\Cdfs");
DPRINT("CDFS 0.0.3\n"); DPRINT("CDFS 0.0.3\n");
Status = IoCreateDevice(DriverObject, Status = IoCreateDevice(DriverObject,
sizeof(CDFS_GLOBAL_DATA), sizeof(CDFS_GLOBAL_DATA),
&DeviceName, &DeviceName,
FILE_DEVICE_CD_ROM_FILE_SYSTEM, FILE_DEVICE_CD_ROM_FILE_SYSTEM,
0, 0,
FALSE, FALSE,
&DeviceObject); &DeviceObject);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
return(Status); return(Status);
} }
/* Initialize global data */ /* Initialize global data */
CdfsGlobalData = DeviceObject->DeviceExtension; CdfsGlobalData = DeviceObject->DeviceExtension;
RtlZeroMemory(CdfsGlobalData, RtlZeroMemory(CdfsGlobalData,
sizeof(CDFS_GLOBAL_DATA)); sizeof(CDFS_GLOBAL_DATA));
CdfsGlobalData->DriverObject = DriverObject; CdfsGlobalData->DriverObject = DriverObject;
CdfsGlobalData->DeviceObject = DeviceObject; CdfsGlobalData->DeviceObject = DeviceObject;
/* Initialize driver data */ /* Initialize driver data */
DeviceObject->Flags = DO_DIRECT_IO; DeviceObject->Flags = DO_DIRECT_IO;
DriverObject->MajorFunction[IRP_MJ_CLOSE] = CdfsClose; DriverObject->MajorFunction[IRP_MJ_CLOSE] = CdfsClose;
DriverObject->MajorFunction[IRP_MJ_CLEANUP] = CdfsCleanup; DriverObject->MajorFunction[IRP_MJ_CLEANUP] = CdfsCleanup;
DriverObject->MajorFunction[IRP_MJ_CREATE] = CdfsCreate; DriverObject->MajorFunction[IRP_MJ_CREATE] = CdfsCreate;
DriverObject->MajorFunction[IRP_MJ_READ] = CdfsRead; DriverObject->MajorFunction[IRP_MJ_READ] = CdfsRead;
DriverObject->MajorFunction[IRP_MJ_WRITE] = CdfsWrite; DriverObject->MajorFunction[IRP_MJ_WRITE] = CdfsWrite;
DriverObject->MajorFunction[IRP_MJ_FILE_SYSTEM_CONTROL] = DriverObject->MajorFunction[IRP_MJ_FILE_SYSTEM_CONTROL] =
CdfsFileSystemControl; CdfsFileSystemControl;
DriverObject->MajorFunction[IRP_MJ_DIRECTORY_CONTROL] = DriverObject->MajorFunction[IRP_MJ_DIRECTORY_CONTROL] =
CdfsDirectoryControl; CdfsDirectoryControl;
DriverObject->MajorFunction[IRP_MJ_QUERY_INFORMATION] = DriverObject->MajorFunction[IRP_MJ_QUERY_INFORMATION] =
CdfsQueryInformation; CdfsQueryInformation;
DriverObject->MajorFunction[IRP_MJ_SET_INFORMATION] = DriverObject->MajorFunction[IRP_MJ_SET_INFORMATION] =
CdfsSetInformation; CdfsSetInformation;
DriverObject->MajorFunction[IRP_MJ_QUERY_VOLUME_INFORMATION] = DriverObject->MajorFunction[IRP_MJ_QUERY_VOLUME_INFORMATION] =
CdfsQueryVolumeInformation; CdfsQueryVolumeInformation;
DriverObject->MajorFunction[IRP_MJ_SET_VOLUME_INFORMATION] = DriverObject->MajorFunction[IRP_MJ_SET_VOLUME_INFORMATION] =
CdfsSetVolumeInformation; CdfsSetVolumeInformation;
DriverObject->DriverUnload = NULL; DriverObject->DriverUnload = NULL;
/* Cache manager */ /* Cache manager */
CdfsGlobalData->CacheMgrCallbacks.AcquireForLazyWrite = CdfsAcquireForLazyWrite; CdfsGlobalData->CacheMgrCallbacks.AcquireForLazyWrite = CdfsAcquireForLazyWrite;
CdfsGlobalData->CacheMgrCallbacks.ReleaseFromLazyWrite = CdfsReleaseFromLazyWrite; CdfsGlobalData->CacheMgrCallbacks.ReleaseFromLazyWrite = CdfsReleaseFromLazyWrite;
CdfsGlobalData->CacheMgrCallbacks.AcquireForReadAhead = CdfsAcquireForLazyWrite; CdfsGlobalData->CacheMgrCallbacks.AcquireForReadAhead = CdfsAcquireForLazyWrite;
CdfsGlobalData->CacheMgrCallbacks.ReleaseFromReadAhead = CdfsReleaseFromLazyWrite; CdfsGlobalData->CacheMgrCallbacks.ReleaseFromReadAhead = CdfsReleaseFromLazyWrite;
IoRegisterFileSystem(DeviceObject); IoRegisterFileSystem(DeviceObject);
DeviceObject->Flags &= ~DO_DEVICE_INITIALIZING; DeviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
return(STATUS_SUCCESS); return(STATUS_SUCCESS);
} }
@ -115,24 +115,24 @@ BOOLEAN NTAPI
CdfsAcquireForLazyWrite(IN PVOID Context, CdfsAcquireForLazyWrite(IN PVOID Context,
IN BOOLEAN Wait) IN BOOLEAN Wait)
{ {
PFCB Fcb = (PFCB)Context; PFCB Fcb = (PFCB)Context;
ASSERT(Fcb); ASSERT(Fcb);
DPRINT("CdfsAcquireForLazyWrite(): Fcb %p\n", Fcb); DPRINT("CdfsAcquireForLazyWrite(): Fcb %p\n", Fcb);
if (!ExAcquireResourceExclusiveLite(&(Fcb->MainResource), Wait)) if (!ExAcquireResourceExclusiveLite(&(Fcb->MainResource), Wait))
{ {
DPRINT("CdfsAcquireForLazyWrite(): ExReleaseResourceLite failed.\n"); DPRINT("CdfsAcquireForLazyWrite(): ExReleaseResourceLite failed.\n");
return FALSE; return FALSE;
} }
return TRUE; return TRUE;
} }
VOID NTAPI VOID NTAPI
CdfsReleaseFromLazyWrite(IN PVOID Context) CdfsReleaseFromLazyWrite(IN PVOID Context)
{ {
PFCB Fcb = (PFCB)Context; PFCB Fcb = (PFCB)Context;
ASSERT(Fcb); ASSERT(Fcb);
DPRINT("CdfsReleaseFromLazyWrite(): Fcb %p\n", Fcb); DPRINT("CdfsReleaseFromLazyWrite(): Fcb %p\n", Fcb);
ExReleaseResourceLite(&(Fcb->MainResource)); ExReleaseResourceLite(&(Fcb->MainResource));
} }

View file

@ -1,30 +1,30 @@
/* /*
* ReactOS kernel * ReactOS kernel
* Copyright (C) 2002 ReactOS Team * Copyright (C) 2002 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
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* 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$ /* $Id$
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
* FILE: services/fs/cdfs/cleanup.c * FILE: services/fs/cdfs/cleanup.c
* PURPOSE: CDROM (ISO 9660) filesystem driver * PURPOSE: CDROM (ISO 9660) filesystem driver
* PROGRAMMER: * PROGRAMMER:
* UPDATE HISTORY: * UPDATE HISTORY:
*/ */
/* INCLUDES *****************************************************************/ /* INCLUDES *****************************************************************/
@ -37,63 +37,63 @@
static NTSTATUS static NTSTATUS
CdfsCleanupFile(PDEVICE_EXTENSION DeviceExt, CdfsCleanupFile(PDEVICE_EXTENSION DeviceExt,
PFILE_OBJECT FileObject) PFILE_OBJECT FileObject)
/* /*
* FUNCTION: Cleans up after a file has been closed. * FUNCTION: Cleans up after a file has been closed.
*/ */
{ {
DPRINT("CdfsCleanupFile(DeviceExt %x, FileObject %x)\n", DPRINT("CdfsCleanupFile(DeviceExt %x, FileObject %x)\n",
DeviceExt, DeviceExt,
FileObject); FileObject);
/* Uninitialize file cache if initialized for this file object. */ /* Uninitialize file cache if initialized for this file object. */
if (FileObject->SectionObjectPointer && FileObject->SectionObjectPointer->SharedCacheMap) if (FileObject->SectionObjectPointer && FileObject->SectionObjectPointer->SharedCacheMap)
{ {
CcUninitializeCacheMap (FileObject, NULL, NULL); CcUninitializeCacheMap (FileObject, NULL, NULL);
} }
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
NTSTATUS NTAPI NTSTATUS NTAPI
CdfsCleanup(PDEVICE_OBJECT DeviceObject, CdfsCleanup(PDEVICE_OBJECT DeviceObject,
PIRP Irp) PIRP Irp)
{ {
PDEVICE_EXTENSION DeviceExtension; PDEVICE_EXTENSION DeviceExtension;
PIO_STACK_LOCATION Stack; PIO_STACK_LOCATION Stack;
PFILE_OBJECT FileObject; PFILE_OBJECT FileObject;
NTSTATUS Status; NTSTATUS Status;
DPRINT("CdfsCleanup() called\n"); DPRINT("CdfsCleanup() called\n");
if (DeviceObject == CdfsGlobalData->DeviceObject) if (DeviceObject == CdfsGlobalData->DeviceObject)
{ {
DPRINT("Closing file system\n"); DPRINT("Closing file system\n");
Status = STATUS_SUCCESS; Status = STATUS_SUCCESS;
goto ByeBye; goto ByeBye;
} }
Stack = IoGetCurrentIrpStackLocation(Irp); Stack = IoGetCurrentIrpStackLocation(Irp);
FileObject = Stack->FileObject; FileObject = Stack->FileObject;
DeviceExtension = DeviceObject->DeviceExtension; DeviceExtension = DeviceObject->DeviceExtension;
KeEnterCriticalRegion(); KeEnterCriticalRegion();
ExAcquireResourceExclusiveLite(&DeviceExtension->DirResource, TRUE); ExAcquireResourceExclusiveLite(&DeviceExtension->DirResource, TRUE);
Status = CdfsCleanupFile(DeviceExtension, FileObject); Status = CdfsCleanupFile(DeviceExtension, FileObject);
ExReleaseResourceLite(&DeviceExtension->DirResource); ExReleaseResourceLite(&DeviceExtension->DirResource);
KeLeaveCriticalRegion(); KeLeaveCriticalRegion();
ByeBye: ByeBye:
Irp->IoStatus.Status = Status; Irp->IoStatus.Status = Status;
Irp->IoStatus.Information = 0; Irp->IoStatus.Information = 0;
IoCompleteRequest(Irp, IO_NO_INCREMENT); IoCompleteRequest(Irp, IO_NO_INCREMENT);
return(Status); return(Status);
} }
/* EOF */ /* EOF */

View file

@ -1,30 +1,30 @@
/* /*
* ReactOS kernel * ReactOS kernel
* Copyright (C) 2002 ReactOS Team * Copyright (C) 2002 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
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* 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$ /* $Id$
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
* FILE: services/fs/cdfs/close.c * FILE: services/fs/cdfs/close.c
* PURPOSE: CDROM (ISO 9660) filesystem driver * PURPOSE: CDROM (ISO 9660) filesystem driver
* PROGRAMMER: Art Yerkes * PROGRAMMER: Art Yerkes
* UPDATE HISTORY: * UPDATE HISTORY:
*/ */
/* INCLUDES *****************************************************************/ /* INCLUDES *****************************************************************/
@ -37,75 +37,75 @@
NTSTATUS NTSTATUS
CdfsCloseFile(PDEVICE_EXTENSION DeviceExt, CdfsCloseFile(PDEVICE_EXTENSION DeviceExt,
PFILE_OBJECT FileObject) PFILE_OBJECT FileObject)
/* /*
* FUNCTION: Closes a file * FUNCTION: Closes a file
*/ */
{ {
PCCB Ccb; PCCB Ccb;
DPRINT("CdfsCloseFile(DeviceExt %x, FileObject %x)\n", DPRINT("CdfsCloseFile(DeviceExt %x, FileObject %x)\n",
DeviceExt, DeviceExt,
FileObject); FileObject);
Ccb = (PCCB)(FileObject->FsContext2); Ccb = (PCCB)(FileObject->FsContext2);
DPRINT("Ccb %x\n", Ccb); DPRINT("Ccb %x\n", Ccb);
if (Ccb == NULL) if (Ccb == NULL)
{ {
return(STATUS_SUCCESS); return(STATUS_SUCCESS);
} }
FileObject->FsContext2 = NULL; FileObject->FsContext2 = NULL;
if (FileObject->FileName.Buffer) if (FileObject->FileName.Buffer)
{ {
// This a FO, that was created outside from FSD. // This a FO, that was created outside from FSD.
// Some FO's are created with IoCreateStreamFileObject() insid from FSD. // Some FO's are created with IoCreateStreamFileObject() insid from FSD.
// This FO's don't have a FileName. // This FO's don't have a FileName.
CdfsReleaseFCB(DeviceExt, FileObject->FsContext); CdfsReleaseFCB(DeviceExt, FileObject->FsContext);
} }
if (Ccb->DirectorySearchPattern.Buffer) if (Ccb->DirectorySearchPattern.Buffer)
{ {
ExFreePool(Ccb->DirectorySearchPattern.Buffer); ExFreePool(Ccb->DirectorySearchPattern.Buffer);
} }
ExFreePool(Ccb); ExFreePool(Ccb);
return(STATUS_SUCCESS); return(STATUS_SUCCESS);
} }
NTSTATUS NTAPI NTSTATUS NTAPI
CdfsClose(PDEVICE_OBJECT DeviceObject, CdfsClose(PDEVICE_OBJECT DeviceObject,
PIRP Irp) PIRP Irp)
{ {
PDEVICE_EXTENSION DeviceExtension; PDEVICE_EXTENSION DeviceExtension;
PIO_STACK_LOCATION Stack; PIO_STACK_LOCATION Stack;
PFILE_OBJECT FileObject; PFILE_OBJECT FileObject;
NTSTATUS Status; NTSTATUS Status;
DPRINT("CdfsClose() called\n"); DPRINT("CdfsClose() called\n");
if (DeviceObject == CdfsGlobalData->DeviceObject) if (DeviceObject == CdfsGlobalData->DeviceObject)
{ {
DPRINT("Closing file system\n"); DPRINT("Closing file system\n");
Status = STATUS_SUCCESS; Status = STATUS_SUCCESS;
goto ByeBye; goto ByeBye;
} }
Stack = IoGetCurrentIrpStackLocation(Irp); Stack = IoGetCurrentIrpStackLocation(Irp);
FileObject = Stack->FileObject; FileObject = Stack->FileObject;
DeviceExtension = DeviceObject->DeviceExtension; DeviceExtension = DeviceObject->DeviceExtension;
Status = CdfsCloseFile(DeviceExtension,FileObject); Status = CdfsCloseFile(DeviceExtension,FileObject);
ByeBye: ByeBye:
Irp->IoStatus.Status = Status; Irp->IoStatus.Status = Status;
Irp->IoStatus.Information = 0; Irp->IoStatus.Information = 0;
IoCompleteRequest(Irp, IO_NO_INCREMENT); IoCompleteRequest(Irp, IO_NO_INCREMENT);
return(Status); return(Status);
} }
/* EOF */ /* EOF */

View file

@ -1,30 +1,30 @@
/* /*
* ReactOS kernel * ReactOS kernel
* Copyright (C) 2002, 2003 ReactOS Team * Copyright (C) 2002, 2003 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
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* 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$ /* $Id$
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
* FILE: drivers/fs/cdfs/common.c * FILE: drivers/fs/cdfs/common.c
* PURPOSE: CDROM (ISO 9660) filesystem driver * PURPOSE: CDROM (ISO 9660) filesystem driver
* PROGRAMMER: Art Yerkes * PROGRAMMER: Art Yerkes
* Eric Kohl * Eric Kohl
*/ */
/* INCLUDES *****************************************************************/ /* INCLUDES *****************************************************************/
@ -37,173 +37,173 @@
NTSTATUS NTSTATUS
CdfsReadSectors(IN PDEVICE_OBJECT DeviceObject, CdfsReadSectors(IN PDEVICE_OBJECT DeviceObject,
IN ULONG DiskSector, IN ULONG DiskSector,
IN ULONG SectorCount, IN ULONG SectorCount,
IN OUT PUCHAR Buffer, IN OUT PUCHAR Buffer,
IN BOOLEAN Override) IN BOOLEAN Override)
{ {
PIO_STACK_LOCATION Stack; PIO_STACK_LOCATION Stack;
IO_STATUS_BLOCK IoStatus; IO_STATUS_BLOCK IoStatus;
LARGE_INTEGER Offset; LARGE_INTEGER Offset;
ULONG BlockSize; ULONG BlockSize;
KEVENT Event; KEVENT Event;
PIRP Irp; PIRP Irp;
NTSTATUS Status; NTSTATUS Status;
KeInitializeEvent(&Event, KeInitializeEvent(&Event,
NotificationEvent, NotificationEvent,
FALSE); FALSE);
Offset.u.LowPart = DiskSector << 11; Offset.u.LowPart = DiskSector << 11;
Offset.u.HighPart = DiskSector >> 21; Offset.u.HighPart = DiskSector >> 21;
BlockSize = BLOCKSIZE * SectorCount; BlockSize = BLOCKSIZE * SectorCount;
DPRINT("CdfsReadSectors(DeviceObject %x, DiskSector %d, Buffer %x)\n", DPRINT("CdfsReadSectors(DeviceObject %x, DiskSector %d, Buffer %x)\n",
DeviceObject, DiskSector, Buffer); DeviceObject, DiskSector, Buffer);
DPRINT("Offset %I64x BlockSize %ld\n", DPRINT("Offset %I64x BlockSize %ld\n",
Offset.QuadPart, Offset.QuadPart,
BlockSize); BlockSize);
DPRINT("Building synchronous FSD Request...\n"); DPRINT("Building synchronous FSD Request...\n");
Irp = IoBuildSynchronousFsdRequest(IRP_MJ_READ, Irp = IoBuildSynchronousFsdRequest(IRP_MJ_READ,
DeviceObject, DeviceObject,
Buffer, Buffer,
BlockSize, BlockSize,
&Offset, &Offset,
&Event, &Event,
&IoStatus); &IoStatus);
if (Irp == NULL) if (Irp == NULL)
{ {
DPRINT("IoBuildSynchronousFsdRequest failed\n"); DPRINT("IoBuildSynchronousFsdRequest failed\n");
return(STATUS_INSUFFICIENT_RESOURCES); return(STATUS_INSUFFICIENT_RESOURCES);
} }
if (Override) if (Override)
{ {
Stack = IoGetNextIrpStackLocation(Irp); Stack = IoGetNextIrpStackLocation(Irp);
Stack->Flags |= SL_OVERRIDE_VERIFY_VOLUME; Stack->Flags |= SL_OVERRIDE_VERIFY_VOLUME;
} }
DPRINT("Calling IO Driver... with irp %x\n", Irp); DPRINT("Calling IO Driver... with irp %x\n", Irp);
Status = IoCallDriver(DeviceObject, Irp); Status = IoCallDriver(DeviceObject, Irp);
DPRINT("Waiting for IO Operation for %x\n", Irp); DPRINT("Waiting for IO Operation for %x\n", Irp);
if (Status == STATUS_PENDING) if (Status == STATUS_PENDING)
{ {
DPRINT("Operation pending\n"); DPRINT("Operation pending\n");
KeWaitForSingleObject(&Event, Suspended, KernelMode, FALSE, NULL); KeWaitForSingleObject(&Event, Suspended, KernelMode, FALSE, NULL);
DPRINT("Getting IO Status... for %x\n", Irp); DPRINT("Getting IO Status... for %x\n", Irp);
Status = IoStatus.Status; Status = IoStatus.Status;
} }
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
if (Status == STATUS_VERIFY_REQUIRED) if (Status == STATUS_VERIFY_REQUIRED)
{ {
PDEVICE_OBJECT DeviceToVerify; PDEVICE_OBJECT DeviceToVerify;
NTSTATUS NewStatus; NTSTATUS NewStatus;
DPRINT1("STATUS_VERIFY_REQUIRED\n"); DPRINT1("STATUS_VERIFY_REQUIRED\n");
DeviceToVerify = IoGetDeviceToVerify(PsGetCurrentThread()); DeviceToVerify = IoGetDeviceToVerify(PsGetCurrentThread());
IoSetDeviceToVerify(PsGetCurrentThread(), NULL); IoSetDeviceToVerify(PsGetCurrentThread(), NULL);
NewStatus = IoVerifyVolume(DeviceToVerify, FALSE); NewStatus = IoVerifyVolume(DeviceToVerify, FALSE);
DPRINT1("IoVerifyVolume() returned (Status %lx)\n", NewStatus); DPRINT1("IoVerifyVolume() returned (Status %lx)\n", NewStatus);
} }
DPRINT("CdfsReadSectors() failed (Status %x)\n", Status); DPRINT("CdfsReadSectors() failed (Status %x)\n", Status);
DPRINT("(DeviceObject %x, DiskSector %x, Buffer %x, Offset 0x%I64x)\n", DPRINT("(DeviceObject %x, DiskSector %x, Buffer %x, Offset 0x%I64x)\n",
DeviceObject, DiskSector, Buffer, DeviceObject, DiskSector, Buffer,
Offset.QuadPart); Offset.QuadPart);
return(Status); return(Status);
} }
DPRINT("Block request succeeded for %x\n", Irp); DPRINT("Block request succeeded for %x\n", Irp);
return(STATUS_SUCCESS); return(STATUS_SUCCESS);
} }
NTSTATUS NTSTATUS
CdfsDeviceIoControl (IN PDEVICE_OBJECT DeviceObject, CdfsDeviceIoControl (IN PDEVICE_OBJECT DeviceObject,
IN ULONG CtlCode, IN ULONG CtlCode,
IN PVOID InputBuffer, IN PVOID InputBuffer,
IN ULONG InputBufferSize, IN ULONG InputBufferSize,
IN OUT PVOID OutputBuffer, IN OUT PVOID OutputBuffer,
IN OUT PULONG OutputBufferSize, IN OUT PULONG OutputBufferSize,
IN BOOLEAN Override) IN BOOLEAN Override)
{ {
PIO_STACK_LOCATION Stack; PIO_STACK_LOCATION Stack;
IO_STATUS_BLOCK IoStatus; IO_STATUS_BLOCK IoStatus;
KEVENT Event; KEVENT Event;
PIRP Irp; PIRP Irp;
NTSTATUS Status; NTSTATUS Status;
DPRINT("CdfsDeviceIoControl(DeviceObject %x, CtlCode %x, " DPRINT("CdfsDeviceIoControl(DeviceObject %x, CtlCode %x, "
"InputBuffer %x, InputBufferSize %x, OutputBuffer %x, " "InputBuffer %x, InputBufferSize %x, OutputBuffer %x, "
"POutputBufferSize %x (%x)\n", DeviceObject, CtlCode, "POutputBufferSize %x (%x)\n", DeviceObject, CtlCode,
InputBuffer, InputBufferSize, OutputBuffer, OutputBufferSize, InputBuffer, InputBufferSize, OutputBuffer, OutputBufferSize,
OutputBufferSize ? *OutputBufferSize : 0); OutputBufferSize ? *OutputBufferSize : 0);
KeInitializeEvent (&Event, NotificationEvent, FALSE); KeInitializeEvent (&Event, NotificationEvent, FALSE);
DPRINT("Building device I/O control request ...\n"); DPRINT("Building device I/O control request ...\n");
Irp = IoBuildDeviceIoControlRequest(CtlCode, Irp = IoBuildDeviceIoControlRequest(CtlCode,
DeviceObject, DeviceObject,
InputBuffer, InputBuffer,
InputBufferSize, InputBufferSize,
OutputBuffer, OutputBuffer,
(OutputBufferSize != NULL) ? *OutputBufferSize : 0, (OutputBufferSize != NULL) ? *OutputBufferSize : 0,
FALSE, FALSE,
&Event, &Event,
&IoStatus); &IoStatus);
if (Irp == NULL) if (Irp == NULL)
{ {
DPRINT("IoBuildDeviceIoControlRequest failed\n"); DPRINT("IoBuildDeviceIoControlRequest failed\n");
return STATUS_INSUFFICIENT_RESOURCES; return STATUS_INSUFFICIENT_RESOURCES;
} }
if (Override) if (Override)
{ {
Stack = IoGetNextIrpStackLocation(Irp); Stack = IoGetNextIrpStackLocation(Irp);
Stack->Flags |= SL_OVERRIDE_VERIFY_VOLUME; Stack->Flags |= SL_OVERRIDE_VERIFY_VOLUME;
} }
DPRINT ("Calling IO Driver... with irp %x\n", Irp); DPRINT ("Calling IO Driver... with irp %x\n", Irp);
Status = IoCallDriver(DeviceObject, Irp); Status = IoCallDriver(DeviceObject, Irp);
DPRINT ("Waiting for IO Operation for %x\n", Irp); DPRINT ("Waiting for IO Operation for %x\n", Irp);
if (Status == STATUS_PENDING) if (Status == STATUS_PENDING)
{ {
DPRINT ("Operation pending\n"); DPRINT ("Operation pending\n");
KeWaitForSingleObject (&Event, Suspended, KernelMode, FALSE, NULL); KeWaitForSingleObject (&Event, Suspended, KernelMode, FALSE, NULL);
DPRINT ("Getting IO Status... for %x\n", Irp); DPRINT ("Getting IO Status... for %x\n", Irp);
Status = IoStatus.Status; Status = IoStatus.Status;
} }
if (OutputBufferSize != NULL) if (OutputBufferSize != NULL)
{ {
*OutputBufferSize = IoStatus.Information; *OutputBufferSize = IoStatus.Information;
} }
if (Status == STATUS_VERIFY_REQUIRED) if (Status == STATUS_VERIFY_REQUIRED)
{ {
PDEVICE_OBJECT DeviceToVerify; PDEVICE_OBJECT DeviceToVerify;
NTSTATUS NewStatus; NTSTATUS NewStatus;
DPRINT1("STATUS_VERIFY_REQUIRED\n"); DPRINT1("STATUS_VERIFY_REQUIRED\n");
DeviceToVerify = IoGetDeviceToVerify(PsGetCurrentThread()); DeviceToVerify = IoGetDeviceToVerify(PsGetCurrentThread());
IoSetDeviceToVerify(PsGetCurrentThread(), NULL); IoSetDeviceToVerify(PsGetCurrentThread(), NULL);
NewStatus = IoVerifyVolume(DeviceToVerify, FALSE); NewStatus = IoVerifyVolume(DeviceToVerify, FALSE);
DPRINT1("IoVerifyVolume() returned (Status %lx)\n", NewStatus); DPRINT1("IoVerifyVolume() returned (Status %lx)\n", NewStatus);
} }
DPRINT("Returning Status %x\n", Status); DPRINT("Returning Status %x\n", Status);
return Status; return Status;
} }
/* EOF */ /* EOF */

View file

@ -1,30 +1,30 @@
/* /*
* ReactOS kernel * ReactOS kernel
* Copyright (C) 2002, 2003, 2004 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
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* 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$ /* $Id$
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
* FILE: services/fs/cdfs/cdfs.c * FILE: services/fs/cdfs/cdfs.c
* PURPOSE: CDROM (ISO 9660) filesystem driver * PURPOSE: CDROM (ISO 9660) filesystem driver
* PROGRAMMER: Art Yerkes * PROGRAMMER: Art Yerkes
* Eric Kohl * Eric Kohl
*/ */
/* INCLUDES *****************************************************************/ /* INCLUDES *****************************************************************/
@ -37,260 +37,260 @@
static NTSTATUS static NTSTATUS
CdfsMakeAbsoluteFilename(PFILE_OBJECT FileObject, CdfsMakeAbsoluteFilename(PFILE_OBJECT FileObject,
PUNICODE_STRING RelativeFileName, PUNICODE_STRING RelativeFileName,
PUNICODE_STRING AbsoluteFileName) PUNICODE_STRING AbsoluteFileName)
{ {
ULONG Length; ULONG Length;
PFCB Fcb; PFCB Fcb;
NTSTATUS Status; NTSTATUS Status;
DPRINT("try related for %wZ\n", RelativeFileName); DPRINT("try related for %wZ\n", RelativeFileName);
Fcb = FileObject->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 & FILE_FLAG_DIRECTORY) == 0 || if ((Fcb->Entry.FileFlags & FILE_FLAG_DIRECTORY) == 0 ||
RelativeFileName->Buffer[0] == L'\\') RelativeFileName->Buffer[0] == L'\\')
{ {
return STATUS_INVALID_PARAMETER; return STATUS_INVALID_PARAMETER;
} }
/* construct absolute path name */ /* construct absolute path name */
Length = (wcslen(Fcb->PathName) * sizeof(WCHAR)) + Length = (wcslen(Fcb->PathName) * sizeof(WCHAR)) +
sizeof(WCHAR) + sizeof(WCHAR) +
RelativeFileName->Length + RelativeFileName->Length +
sizeof(WCHAR); sizeof(WCHAR);
AbsoluteFileName->Length = 0; AbsoluteFileName->Length = 0;
AbsoluteFileName->MaximumLength = Length; AbsoluteFileName->MaximumLength = Length;
AbsoluteFileName->Buffer = ExAllocatePool(NonPagedPool, AbsoluteFileName->Buffer = ExAllocatePool(NonPagedPool,
Length); Length);
if (AbsoluteFileName->Buffer == NULL) if (AbsoluteFileName->Buffer == NULL)
{ {
return STATUS_INSUFFICIENT_RESOURCES; return STATUS_INSUFFICIENT_RESOURCES;
} }
Status = RtlAppendUnicodeToString(AbsoluteFileName, Status = RtlAppendUnicodeToString(AbsoluteFileName,
Fcb->PathName); Fcb->PathName);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
RtlFreeUnicodeString(AbsoluteFileName); RtlFreeUnicodeString(AbsoluteFileName);
return Status; return Status;
} }
if (!CdfsFCBIsRoot(Fcb)) if (!CdfsFCBIsRoot(Fcb))
{ {
Status = RtlAppendUnicodeToString(AbsoluteFileName, Status = RtlAppendUnicodeToString(AbsoluteFileName,
L"\\"); L"\\");
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
RtlFreeUnicodeString(AbsoluteFileName); RtlFreeUnicodeString(AbsoluteFileName);
return Status; return Status;
} }
} }
Status = RtlAppendUnicodeStringToString(AbsoluteFileName, Status = RtlAppendUnicodeStringToString(AbsoluteFileName,
RelativeFileName); RelativeFileName);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
RtlFreeUnicodeString(AbsoluteFileName); RtlFreeUnicodeString(AbsoluteFileName);
return Status; return Status;
} }
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
/* /*
* FUNCTION: Opens a file * FUNCTION: Opens a file
*/ */
static NTSTATUS static NTSTATUS
CdfsOpenFile(PDEVICE_EXTENSION DeviceExt, CdfsOpenFile(PDEVICE_EXTENSION DeviceExt,
PFILE_OBJECT FileObject, PFILE_OBJECT FileObject,
PUNICODE_STRING FileName) PUNICODE_STRING FileName)
{ {
PFCB ParentFcb; PFCB ParentFcb;
PFCB Fcb; PFCB Fcb;
NTSTATUS Status; NTSTATUS Status;
UNICODE_STRING AbsFileName; UNICODE_STRING AbsFileName;
DPRINT("CdfsOpenFile(%08lx, %08lx, %wZ)\n", DeviceExt, FileObject, FileName); DPRINT("CdfsOpenFile(%08lx, %08lx, %wZ)\n", DeviceExt, FileObject, FileName);
if (FileObject->RelatedFileObject) if (FileObject->RelatedFileObject)
{ {
DPRINT("Converting relative filename to absolute filename\n"); DPRINT("Converting relative filename to absolute filename\n");
Status = CdfsMakeAbsoluteFilename(FileObject->RelatedFileObject, Status = CdfsMakeAbsoluteFilename(FileObject->RelatedFileObject,
FileName, FileName,
&AbsFileName); &AbsFileName);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
return Status; return Status;
} }
FileName = &AbsFileName; FileName = &AbsFileName;
} }
Status = CdfsDeviceIoControl (DeviceExt->StorageDevice, Status = CdfsDeviceIoControl (DeviceExt->StorageDevice,
IOCTL_CDROM_CHECK_VERIFY, IOCTL_CDROM_CHECK_VERIFY,
NULL, NULL,
0, 0,
NULL, NULL,
0, 0,
FALSE); FALSE);
DPRINT ("Status %lx\n", Status); DPRINT ("Status %lx\n", Status);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
if (Status == STATUS_NO_MEDIA_IN_DEVICE || Status == STATUS_VERIFY_REQUIRED) if (Status == STATUS_NO_MEDIA_IN_DEVICE || Status == STATUS_VERIFY_REQUIRED)
{ {
DeviceExt->VolumeDevice->Flags |= DO_VERIFY_VOLUME; DeviceExt->VolumeDevice->Flags |= DO_VERIFY_VOLUME;
} }
DPRINT1 ("Status %lx\n", Status); DPRINT1 ("Status %lx\n", Status);
return Status; return Status;
} }
DPRINT("PathName to open: %wZ\n", FileName); DPRINT("PathName to open: %wZ\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");
Fcb = CdfsGrabFCBFromTable(DeviceExt, Fcb = CdfsGrabFCBFromTable(DeviceExt,
FileName); FileName);
if (Fcb == NULL) if (Fcb == NULL)
{ {
DPRINT("No existing FCB found, making a new one if file exists.\n"); DPRINT("No existing FCB found, making a new one if file exists.\n");
Status = CdfsGetFCBForFile(DeviceExt, Status = CdfsGetFCBForFile(DeviceExt,
&ParentFcb, &ParentFcb,
&Fcb, &Fcb,
FileName); FileName);
if (ParentFcb != NULL) if (ParentFcb != NULL)
{ {
CdfsReleaseFCB(DeviceExt, CdfsReleaseFCB(DeviceExt,
ParentFcb); ParentFcb);
} }
if (!NT_SUCCESS (Status)) if (!NT_SUCCESS (Status))
{ {
DPRINT("Could not make a new FCB, status: %x\n", Status); DPRINT("Could not make a new FCB, status: %x\n", Status);
if (FileName == &AbsFileName) if (FileName == &AbsFileName)
RtlFreeUnicodeString(&AbsFileName); RtlFreeUnicodeString(&AbsFileName);
return Status; return Status;
} }
} }
DPRINT("Attaching FCB to fileObject\n"); DPRINT("Attaching FCB to fileObject\n");
Status = CdfsAttachFCBToFileObject(DeviceExt, Status = CdfsAttachFCBToFileObject(DeviceExt,
Fcb, Fcb,
FileObject); FileObject);
if ((FileName == &AbsFileName) && AbsFileName.Buffer) if ((FileName == &AbsFileName) && AbsFileName.Buffer)
ExFreePool(AbsFileName.Buffer); ExFreePool(AbsFileName.Buffer);
return Status; return Status;
} }
/* /*
* FUNCTION: Opens a file * FUNCTION: Opens a file
*/ */
static NTSTATUS static NTSTATUS
CdfsCreateFile(PDEVICE_OBJECT DeviceObject, CdfsCreateFile(PDEVICE_OBJECT DeviceObject,
PIRP Irp) PIRP Irp)
{ {
PDEVICE_EXTENSION DeviceExt; PDEVICE_EXTENSION DeviceExt;
PIO_STACK_LOCATION Stack; PIO_STACK_LOCATION Stack;
PFILE_OBJECT FileObject; PFILE_OBJECT FileObject;
ULONG RequestedDisposition; ULONG RequestedDisposition;
ULONG RequestedOptions; ULONG RequestedOptions;
PFCB Fcb; PFCB Fcb;
NTSTATUS Status; NTSTATUS Status;
DPRINT("CdfsCreateFile() called\n"); DPRINT("CdfsCreateFile() called\n");
DeviceExt = DeviceObject->DeviceExtension; DeviceExt = DeviceObject->DeviceExtension;
ASSERT(DeviceExt); ASSERT(DeviceExt);
Stack = IoGetCurrentIrpStackLocation (Irp); Stack = IoGetCurrentIrpStackLocation (Irp);
ASSERT(Stack); ASSERT(Stack);
RequestedDisposition = ((Stack->Parameters.Create.Options >> 24) & 0xff); RequestedDisposition = ((Stack->Parameters.Create.Options >> 24) & 0xff);
RequestedOptions = Stack->Parameters.Create.Options & FILE_VALID_OPTION_FLAGS; RequestedOptions = Stack->Parameters.Create.Options & FILE_VALID_OPTION_FLAGS;
DPRINT("RequestedDisposition %x, RequestedOptions %x\n", DPRINT("RequestedDisposition %x, RequestedOptions %x\n",
RequestedDisposition, RequestedOptions); RequestedDisposition, RequestedOptions);
FileObject = Stack->FileObject; FileObject = Stack->FileObject;
if (RequestedDisposition == FILE_CREATE || if (RequestedDisposition == FILE_CREATE ||
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); &FileObject->FileName);
if (NT_SUCCESS(Status)) if (NT_SUCCESS(Status))
{ {
Fcb = FileObject->FsContext; Fcb = FileObject->FsContext;
/* Check whether the file has the requested attributes */ /* Check whether the file has the requested attributes */
if (RequestedOptions & FILE_NON_DIRECTORY_FILE && CdfsFCBIsDirectory(Fcb)) if (RequestedOptions & FILE_NON_DIRECTORY_FILE && CdfsFCBIsDirectory(Fcb))
{ {
CdfsCloseFile (DeviceExt, FileObject); CdfsCloseFile (DeviceExt, FileObject);
return STATUS_FILE_IS_A_DIRECTORY; return STATUS_FILE_IS_A_DIRECTORY;
} }
if (RequestedOptions & FILE_DIRECTORY_FILE && !CdfsFCBIsDirectory(Fcb)) if (RequestedOptions & FILE_DIRECTORY_FILE && !CdfsFCBIsDirectory(Fcb))
{ {
CdfsCloseFile (DeviceExt, FileObject); CdfsCloseFile (DeviceExt, FileObject);
return STATUS_NOT_A_DIRECTORY; return STATUS_NOT_A_DIRECTORY;
} }
} }
/* /*
* If the directory containing the file to open doesn't exist then * If the directory containing the file to open doesn't exist then
* fail immediately * fail immediately
*/ */
Irp->IoStatus.Information = (NT_SUCCESS(Status)) ? FILE_OPENED : 0; Irp->IoStatus.Information = (NT_SUCCESS(Status)) ? FILE_OPENED : 0;
Irp->IoStatus.Status = Status; Irp->IoStatus.Status = Status;
return Status; return Status;
} }
NTSTATUS NTAPI NTSTATUS NTAPI
CdfsCreate(PDEVICE_OBJECT DeviceObject, CdfsCreate(PDEVICE_OBJECT DeviceObject,
PIRP Irp) PIRP Irp)
{ {
PDEVICE_EXTENSION DeviceExt; PDEVICE_EXTENSION DeviceExt;
NTSTATUS Status; NTSTATUS Status;
if (DeviceObject == CdfsGlobalData->DeviceObject) if (DeviceObject == CdfsGlobalData->DeviceObject)
{ {
/* DeviceObject represents FileSystem instead of logical volume */ /* DeviceObject represents FileSystem instead of logical volume */
DPRINT("Opening file system\n"); DPRINT("Opening file system\n");
Irp->IoStatus.Information = FILE_OPENED; Irp->IoStatus.Information = FILE_OPENED;
Status = STATUS_SUCCESS; Status = STATUS_SUCCESS;
goto ByeBye; goto ByeBye;
} }
DeviceExt = DeviceObject->DeviceExtension; DeviceExt = DeviceObject->DeviceExtension;
KeEnterCriticalRegion(); KeEnterCriticalRegion();
ExAcquireResourceExclusiveLite(&DeviceExt->DirResource, ExAcquireResourceExclusiveLite(&DeviceExt->DirResource,
TRUE); TRUE);
Status = CdfsCreateFile(DeviceObject, Status = CdfsCreateFile(DeviceObject,
Irp); Irp);
ExReleaseResourceLite(&DeviceExt->DirResource); ExReleaseResourceLite(&DeviceExt->DirResource);
KeLeaveCriticalRegion(); KeLeaveCriticalRegion();
ByeBye: ByeBye:
Irp->IoStatus.Status = Status; Irp->IoStatus.Status = Status;
IoCompleteRequest(Irp, IoCompleteRequest(Irp,
NT_SUCCESS(Status) ? IO_DISK_INCREMENT : IO_NO_INCREMENT); NT_SUCCESS(Status) ? IO_DISK_INCREMENT : IO_NO_INCREMENT);
return Status; return Status;
} }
/* EOF */ /* EOF */

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,31 +1,31 @@
/* /*
* ReactOS kernel * ReactOS kernel
* Copyright (C) 2002, 2004 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
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* 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$ /* $Id$
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
* FILE: services/fs/cdfs/finfo.c * FILE: services/fs/cdfs/finfo.c
* PURPOSE: CDROM (ISO 9660) filesystem driver * PURPOSE: CDROM (ISO 9660) filesystem driver
* PROGRAMMER: Art Yerkes * PROGRAMMER: Art Yerkes
* Eric Kohl * Eric Kohl
* UPDATE HISTORY: * UPDATE HISTORY:
*/ */
/* INCLUDES *****************************************************************/ /* INCLUDES *****************************************************************/
@ -37,457 +37,457 @@
/* FUNCTIONS ****************************************************************/ /* FUNCTIONS ****************************************************************/
/* /*
* FUNCTION: Retrieve the standard file information * FUNCTION: Retrieve the standard file information
*/ */
static NTSTATUS static NTSTATUS
CdfsGetStandardInformation(PFCB Fcb, CdfsGetStandardInformation(PFCB Fcb,
PDEVICE_OBJECT DeviceObject, PDEVICE_OBJECT DeviceObject,
PFILE_STANDARD_INFORMATION StandardInfo, PFILE_STANDARD_INFORMATION StandardInfo,
PULONG BufferLength) PULONG BufferLength)
{ {
DPRINT("CdfsGetStandardInformation() called\n"); DPRINT("CdfsGetStandardInformation() called\n");
if (*BufferLength < sizeof(FILE_STANDARD_INFORMATION)) if (*BufferLength < sizeof(FILE_STANDARD_INFORMATION))
return STATUS_BUFFER_OVERFLOW; return STATUS_BUFFER_OVERFLOW;
/* PRECONDITION */ /* PRECONDITION */
ASSERT(StandardInfo != NULL); ASSERT(StandardInfo != NULL);
ASSERT(Fcb != NULL); ASSERT(Fcb != NULL);
RtlZeroMemory(StandardInfo, RtlZeroMemory(StandardInfo,
sizeof(FILE_STANDARD_INFORMATION)); sizeof(FILE_STANDARD_INFORMATION));
if (CdfsFCBIsDirectory(Fcb)) if (CdfsFCBIsDirectory(Fcb))
{ {
StandardInfo->AllocationSize.QuadPart = 0LL; StandardInfo->AllocationSize.QuadPart = 0LL;
StandardInfo->EndOfFile.QuadPart = 0LL; StandardInfo->EndOfFile.QuadPart = 0LL;
StandardInfo->Directory = TRUE; StandardInfo->Directory = TRUE;
} }
else else
{ {
StandardInfo->AllocationSize = Fcb->RFCB.AllocationSize; StandardInfo->AllocationSize = Fcb->RFCB.AllocationSize;
StandardInfo->EndOfFile = Fcb->RFCB.FileSize; StandardInfo->EndOfFile = Fcb->RFCB.FileSize;
StandardInfo->Directory = FALSE; StandardInfo->Directory = FALSE;
} }
StandardInfo->NumberOfLinks = 0; StandardInfo->NumberOfLinks = 0;
StandardInfo->DeletePending = FALSE; StandardInfo->DeletePending = FALSE;
*BufferLength -= sizeof(FILE_STANDARD_INFORMATION); *BufferLength -= sizeof(FILE_STANDARD_INFORMATION);
return(STATUS_SUCCESS); return(STATUS_SUCCESS);
} }
/* /*
* FUNCTION: Retrieve the file position information * FUNCTION: Retrieve the file position information
*/ */
static NTSTATUS static NTSTATUS
CdfsGetPositionInformation(PFILE_OBJECT FileObject, CdfsGetPositionInformation(PFILE_OBJECT FileObject,
PFILE_POSITION_INFORMATION PositionInfo, PFILE_POSITION_INFORMATION PositionInfo,
PULONG BufferLength) PULONG BufferLength)
{ {
DPRINT("CdfsGetPositionInformation() called\n"); DPRINT("CdfsGetPositionInformation() called\n");
if (*BufferLength < sizeof(FILE_POSITION_INFORMATION)) if (*BufferLength < sizeof(FILE_POSITION_INFORMATION))
return STATUS_BUFFER_OVERFLOW; return STATUS_BUFFER_OVERFLOW;
PositionInfo->CurrentByteOffset.QuadPart = PositionInfo->CurrentByteOffset.QuadPart =
FileObject->CurrentByteOffset.QuadPart; FileObject->CurrentByteOffset.QuadPart;
DPRINT("Getting position %I64x\n", DPRINT("Getting position %I64x\n",
PositionInfo->CurrentByteOffset.QuadPart); PositionInfo->CurrentByteOffset.QuadPart);
*BufferLength -= sizeof(FILE_POSITION_INFORMATION); *BufferLength -= sizeof(FILE_POSITION_INFORMATION);
return(STATUS_SUCCESS); return(STATUS_SUCCESS);
} }
/* /*
* FUNCTION: Retrieve the basic file information * FUNCTION: Retrieve the basic file information
*/ */
static NTSTATUS static NTSTATUS
CdfsGetBasicInformation(PFILE_OBJECT FileObject, CdfsGetBasicInformation(PFILE_OBJECT FileObject,
PFCB Fcb, PFCB Fcb,
PDEVICE_OBJECT DeviceObject, PDEVICE_OBJECT DeviceObject,
PFILE_BASIC_INFORMATION BasicInfo, PFILE_BASIC_INFORMATION BasicInfo,
PULONG BufferLength) PULONG BufferLength)
{ {
DPRINT("CdfsGetBasicInformation() called\n"); DPRINT("CdfsGetBasicInformation() called\n");
if (*BufferLength < sizeof(FILE_BASIC_INFORMATION)) if (*BufferLength < sizeof(FILE_BASIC_INFORMATION))
return STATUS_BUFFER_OVERFLOW; return STATUS_BUFFER_OVERFLOW;
CdfsDateTimeToSystemTime(Fcb, CdfsDateTimeToSystemTime(Fcb,
&BasicInfo->CreationTime); &BasicInfo->CreationTime);
CdfsDateTimeToSystemTime(Fcb, CdfsDateTimeToSystemTime(Fcb,
&BasicInfo->LastAccessTime); &BasicInfo->LastAccessTime);
CdfsDateTimeToSystemTime(Fcb, CdfsDateTimeToSystemTime(Fcb,
&BasicInfo->LastWriteTime); &BasicInfo->LastWriteTime);
CdfsDateTimeToSystemTime(Fcb, CdfsDateTimeToSystemTime(Fcb,
&BasicInfo->ChangeTime); &BasicInfo->ChangeTime);
CdfsFileFlagsToAttributes(Fcb, CdfsFileFlagsToAttributes(Fcb,
&BasicInfo->FileAttributes); &BasicInfo->FileAttributes);
*BufferLength -= sizeof(FILE_BASIC_INFORMATION); *BufferLength -= sizeof(FILE_BASIC_INFORMATION);
return(STATUS_SUCCESS); return(STATUS_SUCCESS);
} }
/* /*
* FUNCTION: Retrieve the file name information * FUNCTION: Retrieve the file name information
*/ */
static NTSTATUS static NTSTATUS
CdfsGetNameInformation(PFILE_OBJECT FileObject, CdfsGetNameInformation(PFILE_OBJECT FileObject,
PFCB Fcb, PFCB Fcb,
PDEVICE_OBJECT DeviceObject, PDEVICE_OBJECT DeviceObject,
PFILE_NAME_INFORMATION NameInfo, PFILE_NAME_INFORMATION NameInfo,
PULONG BufferLength) PULONG BufferLength)
{ {
ULONG NameLength; ULONG NameLength;
ULONG BytesToCopy; ULONG BytesToCopy;
DPRINT("CdfsGetNameInformation() called\n"); DPRINT("CdfsGetNameInformation() called\n");
ASSERT(NameInfo != NULL); ASSERT(NameInfo != NULL);
ASSERT(Fcb != NULL); ASSERT(Fcb != NULL);
/* If buffer can't hold at least the file name length, bail out */ /* If buffer can't hold at least the file name length, bail out */
if (*BufferLength < FIELD_OFFSET(FILE_NAME_INFORMATION, FileName[0])) if (*BufferLength < FIELD_OFFSET(FILE_NAME_INFORMATION, FileName[0]))
return STATUS_BUFFER_OVERFLOW; return STATUS_BUFFER_OVERFLOW;
/* Calculate file name length in bytes */ /* Calculate file name length in bytes */
NameLength = wcslen(Fcb->PathName) * sizeof(WCHAR); NameLength = wcslen(Fcb->PathName) * sizeof(WCHAR);
NameInfo->FileNameLength = NameLength; NameInfo->FileNameLength = NameLength;
/* Calculate amount of bytes to copy not to overflow the buffer */ /* Calculate amount of bytes to copy not to overflow the buffer */
BytesToCopy = min(NameLength, BytesToCopy = min(NameLength,
*BufferLength - FIELD_OFFSET(FILE_NAME_INFORMATION, FileName[0])); *BufferLength - FIELD_OFFSET(FILE_NAME_INFORMATION, FileName[0]));
/* Fill in the bytes */ /* Fill in the bytes */
RtlCopyMemory(NameInfo->FileName, Fcb->PathName, BytesToCopy); RtlCopyMemory(NameInfo->FileName, Fcb->PathName, BytesToCopy);
/* Check if we could write more but are not able to */ /* Check if we could write more but are not able to */
if (*BufferLength < NameLength + FIELD_OFFSET(FILE_NAME_INFORMATION, FileName[0])) if (*BufferLength < NameLength + FIELD_OFFSET(FILE_NAME_INFORMATION, FileName[0]))
{ {
/* Return number of bytes written */ /* Return number of bytes written */
*BufferLength -= FIELD_OFFSET(FILE_NAME_INFORMATION, FileName[0]) + BytesToCopy; *BufferLength -= FIELD_OFFSET(FILE_NAME_INFORMATION, FileName[0]) + BytesToCopy;
return STATUS_BUFFER_OVERFLOW; return STATUS_BUFFER_OVERFLOW;
} }
/* We filled up as many bytes, as needed */ /* We filled up as many bytes, as needed */
*BufferLength -= (FIELD_OFFSET(FILE_NAME_INFORMATION, FileName[0]) + NameLength); *BufferLength -= (FIELD_OFFSET(FILE_NAME_INFORMATION, FileName[0]) + NameLength);
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
/* /*
* FUNCTION: Retrieve the internal file information * FUNCTION: Retrieve the internal file information
*/ */
static NTSTATUS static NTSTATUS
CdfsGetInternalInformation(PFCB Fcb, CdfsGetInternalInformation(PFCB Fcb,
PFILE_INTERNAL_INFORMATION InternalInfo, PFILE_INTERNAL_INFORMATION InternalInfo,
PULONG BufferLength) PULONG BufferLength)
{ {
DPRINT("CdfsGetInternalInformation() called\n"); DPRINT("CdfsGetInternalInformation() called\n");
ASSERT(InternalInfo); ASSERT(InternalInfo);
ASSERT(Fcb); ASSERT(Fcb);
if (*BufferLength < sizeof(FILE_INTERNAL_INFORMATION)) if (*BufferLength < sizeof(FILE_INTERNAL_INFORMATION))
return(STATUS_BUFFER_OVERFLOW); return(STATUS_BUFFER_OVERFLOW);
InternalInfo->IndexNumber.QuadPart = Fcb->IndexNumber.QuadPart; InternalInfo->IndexNumber.QuadPart = Fcb->IndexNumber.QuadPart;
*BufferLength -= sizeof(FILE_INTERNAL_INFORMATION); *BufferLength -= sizeof(FILE_INTERNAL_INFORMATION);
return(STATUS_SUCCESS); return(STATUS_SUCCESS);
} }
/* /*
* FUNCTION: Retrieve the file network open information * FUNCTION: Retrieve the file network open information
*/ */
static NTSTATUS static NTSTATUS
CdfsGetNetworkOpenInformation(PFCB Fcb, CdfsGetNetworkOpenInformation(PFCB Fcb,
PFILE_NETWORK_OPEN_INFORMATION NetworkInfo, PFILE_NETWORK_OPEN_INFORMATION NetworkInfo,
PULONG BufferLength) PULONG BufferLength)
{ {
ASSERT(NetworkInfo); ASSERT(NetworkInfo);
ASSERT(Fcb); ASSERT(Fcb);
if (*BufferLength < sizeof(FILE_NETWORK_OPEN_INFORMATION)) if (*BufferLength < sizeof(FILE_NETWORK_OPEN_INFORMATION))
return(STATUS_BUFFER_OVERFLOW); return(STATUS_BUFFER_OVERFLOW);
CdfsDateTimeToSystemTime(Fcb, CdfsDateTimeToSystemTime(Fcb,
&NetworkInfo->CreationTime); &NetworkInfo->CreationTime);
CdfsDateTimeToSystemTime(Fcb, CdfsDateTimeToSystemTime(Fcb,
&NetworkInfo->LastAccessTime); &NetworkInfo->LastAccessTime);
CdfsDateTimeToSystemTime(Fcb, CdfsDateTimeToSystemTime(Fcb,
&NetworkInfo->LastWriteTime); &NetworkInfo->LastWriteTime);
CdfsDateTimeToSystemTime(Fcb, CdfsDateTimeToSystemTime(Fcb,
&NetworkInfo->ChangeTime); &NetworkInfo->ChangeTime);
if (CdfsFCBIsDirectory(Fcb)) if (CdfsFCBIsDirectory(Fcb))
{ {
NetworkInfo->AllocationSize.QuadPart = 0LL; NetworkInfo->AllocationSize.QuadPart = 0LL;
NetworkInfo->EndOfFile.QuadPart = 0LL; NetworkInfo->EndOfFile.QuadPart = 0LL;
} }
else else
{ {
NetworkInfo->AllocationSize = Fcb->RFCB.AllocationSize; NetworkInfo->AllocationSize = Fcb->RFCB.AllocationSize;
NetworkInfo->EndOfFile = Fcb->RFCB.FileSize; NetworkInfo->EndOfFile = Fcb->RFCB.FileSize;
} }
CdfsFileFlagsToAttributes(Fcb, CdfsFileFlagsToAttributes(Fcb,
&NetworkInfo->FileAttributes); &NetworkInfo->FileAttributes);
*BufferLength -= sizeof(FILE_NETWORK_OPEN_INFORMATION); *BufferLength -= sizeof(FILE_NETWORK_OPEN_INFORMATION);
return(STATUS_SUCCESS); return(STATUS_SUCCESS);
} }
/* /*
* FUNCTION: Retrieve all file information * FUNCTION: Retrieve all file information
*/ */
static NTSTATUS static NTSTATUS
CdfsGetAllInformation(PFILE_OBJECT FileObject, CdfsGetAllInformation(PFILE_OBJECT FileObject,
PFCB Fcb, PFCB Fcb,
PFILE_ALL_INFORMATION Info, PFILE_ALL_INFORMATION Info,
PULONG BufferLength) PULONG BufferLength)
{ {
ULONG NameLength; ULONG NameLength;
ASSERT(Info); ASSERT(Info);
ASSERT(Fcb); ASSERT(Fcb);
NameLength = wcslen(Fcb->PathName) * sizeof(WCHAR); NameLength = wcslen(Fcb->PathName) * sizeof(WCHAR);
if (*BufferLength < sizeof(FILE_ALL_INFORMATION) + NameLength) if (*BufferLength < sizeof(FILE_ALL_INFORMATION) + NameLength)
return(STATUS_BUFFER_OVERFLOW); return(STATUS_BUFFER_OVERFLOW);
/* Basic Information */ /* Basic Information */
CdfsDateTimeToSystemTime(Fcb, CdfsDateTimeToSystemTime(Fcb,
&Info->BasicInformation.CreationTime); &Info->BasicInformation.CreationTime);
CdfsDateTimeToSystemTime(Fcb, CdfsDateTimeToSystemTime(Fcb,
&Info->BasicInformation.LastAccessTime); &Info->BasicInformation.LastAccessTime);
CdfsDateTimeToSystemTime(Fcb, CdfsDateTimeToSystemTime(Fcb,
&Info->BasicInformation.LastWriteTime); &Info->BasicInformation.LastWriteTime);
CdfsDateTimeToSystemTime(Fcb, CdfsDateTimeToSystemTime(Fcb,
&Info->BasicInformation.ChangeTime); &Info->BasicInformation.ChangeTime);
CdfsFileFlagsToAttributes(Fcb, CdfsFileFlagsToAttributes(Fcb,
&Info->BasicInformation.FileAttributes); &Info->BasicInformation.FileAttributes);
/* Standard Information */ /* Standard Information */
if (CdfsFCBIsDirectory(Fcb)) if (CdfsFCBIsDirectory(Fcb))
{ {
Info->StandardInformation.AllocationSize.QuadPart = 0LL; Info->StandardInformation.AllocationSize.QuadPart = 0LL;
Info->StandardInformation.EndOfFile.QuadPart = 0LL; Info->StandardInformation.EndOfFile.QuadPart = 0LL;
Info->StandardInformation.Directory = TRUE; Info->StandardInformation.Directory = TRUE;
} }
else else
{ {
Info->StandardInformation.AllocationSize = Fcb->RFCB.AllocationSize; Info->StandardInformation.AllocationSize = Fcb->RFCB.AllocationSize;
Info->StandardInformation.EndOfFile = Fcb->RFCB.FileSize; Info->StandardInformation.EndOfFile = Fcb->RFCB.FileSize;
Info->StandardInformation.Directory = FALSE; Info->StandardInformation.Directory = FALSE;
} }
Info->StandardInformation.NumberOfLinks = 0; Info->StandardInformation.NumberOfLinks = 0;
Info->StandardInformation.DeletePending = FALSE; Info->StandardInformation.DeletePending = FALSE;
/* Internal Information */ /* Internal Information */
Info->InternalInformation.IndexNumber.QuadPart = Fcb->IndexNumber.QuadPart; Info->InternalInformation.IndexNumber.QuadPart = Fcb->IndexNumber.QuadPart;
/* EA Information */ /* EA Information */
Info->EaInformation.EaSize = 0; Info->EaInformation.EaSize = 0;
/* Access Information */ /* Access Information */
/* The IO-Manager adds this information */ /* The IO-Manager adds this information */
/* Position Information */ /* Position Information */
Info->PositionInformation.CurrentByteOffset.QuadPart = FileObject->CurrentByteOffset.QuadPart; Info->PositionInformation.CurrentByteOffset.QuadPart = FileObject->CurrentByteOffset.QuadPart;
/* Mode Information */ /* Mode Information */
/* The IO-Manager adds this information */ /* The IO-Manager adds this information */
/* Alignment Information */ /* Alignment Information */
/* The IO-Manager adds this information */ /* The IO-Manager adds this information */
/* Name Information */ /* Name Information */
Info->NameInformation.FileNameLength = NameLength; Info->NameInformation.FileNameLength = NameLength;
RtlCopyMemory(Info->NameInformation.FileName, RtlCopyMemory(Info->NameInformation.FileName,
Fcb->PathName, Fcb->PathName,
NameLength + sizeof(WCHAR)); NameLength + sizeof(WCHAR));
*BufferLength -= (sizeof(FILE_ALL_INFORMATION) + NameLength + sizeof(WCHAR)); *BufferLength -= (sizeof(FILE_ALL_INFORMATION) + NameLength + sizeof(WCHAR));
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
/* /*
* FUNCTION: Retrieve the specified file information * FUNCTION: Retrieve the specified file information
*/ */
NTSTATUS NTAPI NTSTATUS NTAPI
CdfsQueryInformation(PDEVICE_OBJECT DeviceObject, CdfsQueryInformation(PDEVICE_OBJECT DeviceObject,
PIRP Irp) PIRP Irp)
{ {
FILE_INFORMATION_CLASS FileInformationClass; FILE_INFORMATION_CLASS FileInformationClass;
PIO_STACK_LOCATION Stack; PIO_STACK_LOCATION Stack;
PFILE_OBJECT FileObject; PFILE_OBJECT FileObject;
PFCB Fcb; PFCB Fcb;
PVOID SystemBuffer; PVOID SystemBuffer;
ULONG BufferLength; ULONG BufferLength;
NTSTATUS Status = STATUS_SUCCESS; NTSTATUS Status = STATUS_SUCCESS;
DPRINT("CdfsQueryInformation() called\n"); DPRINT("CdfsQueryInformation() called\n");
Stack = IoGetCurrentIrpStackLocation(Irp); Stack = IoGetCurrentIrpStackLocation(Irp);
FileInformationClass = Stack->Parameters.QueryFile.FileInformationClass; FileInformationClass = Stack->Parameters.QueryFile.FileInformationClass;
FileObject = Stack->FileObject; FileObject = Stack->FileObject;
Fcb = FileObject->FsContext; Fcb = FileObject->FsContext;
SystemBuffer = Irp->AssociatedIrp.SystemBuffer; SystemBuffer = Irp->AssociatedIrp.SystemBuffer;
BufferLength = Stack->Parameters.QueryFile.Length; BufferLength = Stack->Parameters.QueryFile.Length;
switch (FileInformationClass) switch (FileInformationClass)
{ {
case FileStandardInformation: case FileStandardInformation:
Status = CdfsGetStandardInformation(Fcb, Status = CdfsGetStandardInformation(Fcb,
DeviceObject, DeviceObject,
SystemBuffer, SystemBuffer,
&BufferLength); &BufferLength);
break; break;
case FilePositionInformation: case FilePositionInformation:
Status = CdfsGetPositionInformation(FileObject, Status = CdfsGetPositionInformation(FileObject,
SystemBuffer, SystemBuffer,
&BufferLength); &BufferLength);
break; break;
case FileBasicInformation: case FileBasicInformation:
Status = CdfsGetBasicInformation(FileObject, Status = CdfsGetBasicInformation(FileObject,
Fcb, Fcb,
DeviceObject, DeviceObject,
SystemBuffer, SystemBuffer,
&BufferLength); &BufferLength);
break; break;
case FileNameInformation: case FileNameInformation:
Status = CdfsGetNameInformation(FileObject, Status = CdfsGetNameInformation(FileObject,
Fcb, Fcb,
DeviceObject, DeviceObject,
SystemBuffer, SystemBuffer,
&BufferLength); &BufferLength);
break; break;
case FileInternalInformation: case FileInternalInformation:
Status = CdfsGetInternalInformation(Fcb, Status = CdfsGetInternalInformation(Fcb,
SystemBuffer, SystemBuffer,
&BufferLength); &BufferLength);
break; break;
case FileNetworkOpenInformation: case FileNetworkOpenInformation:
Status = CdfsGetNetworkOpenInformation(Fcb, Status = CdfsGetNetworkOpenInformation(Fcb,
SystemBuffer, SystemBuffer,
&BufferLength); &BufferLength);
break; break;
case FileAllInformation: case FileAllInformation:
Status = CdfsGetAllInformation(FileObject, Status = CdfsGetAllInformation(FileObject,
Fcb, Fcb,
SystemBuffer, SystemBuffer,
&BufferLength); &BufferLength);
break; break;
case FileAlternateNameInformation: case FileAlternateNameInformation:
Status = STATUS_NOT_IMPLEMENTED; Status = STATUS_NOT_IMPLEMENTED;
break; break;
default: default:
DPRINT("Unimplemented information class %u\n", FileInformationClass); DPRINT("Unimplemented information class %u\n", FileInformationClass);
Status = STATUS_INVALID_PARAMETER; Status = STATUS_INVALID_PARAMETER;
break; break;
} }
Irp->IoStatus.Status = Status; Irp->IoStatus.Status = Status;
if (NT_SUCCESS(Status) || Status == STATUS_BUFFER_OVERFLOW) if (NT_SUCCESS(Status) || Status == STATUS_BUFFER_OVERFLOW)
Irp->IoStatus.Information = Irp->IoStatus.Information =
Stack->Parameters.QueryFile.Length - BufferLength; Stack->Parameters.QueryFile.Length - BufferLength;
else else
Irp->IoStatus.Information = 0; Irp->IoStatus.Information = 0;
IoCompleteRequest(Irp, IO_NO_INCREMENT); IoCompleteRequest(Irp, IO_NO_INCREMENT);
return(Status); return(Status);
} }
/* /*
* FUNCTION: Set the file position information * FUNCTION: Set the file position information
*/ */
static NTSTATUS static NTSTATUS
CdfsSetPositionInformation(PFILE_OBJECT FileObject, CdfsSetPositionInformation(PFILE_OBJECT FileObject,
PFILE_POSITION_INFORMATION PositionInfo) PFILE_POSITION_INFORMATION PositionInfo)
{ {
DPRINT ("CdfsSetPositionInformation()\n"); DPRINT ("CdfsSetPositionInformation()\n");
DPRINT ("PositionInfo %x\n", PositionInfo); DPRINT ("PositionInfo %x\n", PositionInfo);
DPRINT ("Setting position %I64u\n", PositionInfo->CurrentByteOffset.QuadPart); DPRINT ("Setting position %I64u\n", PositionInfo->CurrentByteOffset.QuadPart);
FileObject->CurrentByteOffset.QuadPart = FileObject->CurrentByteOffset.QuadPart =
PositionInfo->CurrentByteOffset.QuadPart; PositionInfo->CurrentByteOffset.QuadPart;
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
/* /*
* FUNCTION: Set the specified file information * FUNCTION: Set the specified file information
*/ */
NTSTATUS NTAPI NTSTATUS NTAPI
CdfsSetInformation(PDEVICE_OBJECT DeviceObject, CdfsSetInformation(PDEVICE_OBJECT DeviceObject,
PIRP Irp) PIRP Irp)
{ {
FILE_INFORMATION_CLASS FileInformationClass; FILE_INFORMATION_CLASS FileInformationClass;
PIO_STACK_LOCATION Stack; PIO_STACK_LOCATION Stack;
PFILE_OBJECT FileObject; PFILE_OBJECT FileObject;
PFCB Fcb; PFCB Fcb;
PVOID SystemBuffer; PVOID SystemBuffer;
NTSTATUS Status = STATUS_SUCCESS; NTSTATUS Status = STATUS_SUCCESS;
DPRINT("CdfsSetInformation() called\n"); DPRINT("CdfsSetInformation() called\n");
Stack = IoGetCurrentIrpStackLocation(Irp); Stack = IoGetCurrentIrpStackLocation(Irp);
FileInformationClass = Stack->Parameters.SetFile.FileInformationClass; FileInformationClass = Stack->Parameters.SetFile.FileInformationClass;
FileObject = Stack->FileObject; FileObject = Stack->FileObject;
Fcb = FileObject->FsContext; Fcb = FileObject->FsContext;
SystemBuffer = Irp->AssociatedIrp.SystemBuffer; SystemBuffer = Irp->AssociatedIrp.SystemBuffer;
switch (FileInformationClass) switch (FileInformationClass)
{ {
case FilePositionInformation: case FilePositionInformation:
Status = CdfsSetPositionInformation(FileObject, Status = CdfsSetPositionInformation(FileObject,
SystemBuffer); SystemBuffer);
break; break;
case FileBasicInformation: case FileBasicInformation:
case FileRenameInformation: case FileRenameInformation:
Status = STATUS_NOT_IMPLEMENTED; Status = STATUS_NOT_IMPLEMENTED;
break; break;
default: default:
Status = STATUS_NOT_SUPPORTED; Status = STATUS_NOT_SUPPORTED;
break; break;
} }
Irp->IoStatus.Status = Status; Irp->IoStatus.Status = Status;
Irp->IoStatus.Information = 0; Irp->IoStatus.Information = 0;
IoCompleteRequest(Irp, IO_NO_INCREMENT); IoCompleteRequest(Irp, IO_NO_INCREMENT);
return Status; return Status;
} }
/* EOF */ /* EOF */

View file

@ -1,29 +1,29 @@
/* /*
* ReactOS kernel * ReactOS kernel
* Copyright (C) 2002, 2003 ReactOS Team * Copyright (C) 2002, 2003 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
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* 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.
*/ */
/* /*
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
* FILE: drivers/fs/cdfs/fsctl.c * FILE: drivers/fs/cdfs/fsctl.c
* PURPOSE: CDROM (ISO 9660) filesystem driver * PURPOSE: CDROM (ISO 9660) filesystem driver
* PROGRAMMER: Art Yerkes * PROGRAMMER: Art Yerkes
* Eric Kohl * Eric Kohl
*/ */
/* INCLUDES *****************************************************************/ /* INCLUDES *****************************************************************/
@ -37,486 +37,486 @@
static __inline static __inline
int msf_to_lba (UCHAR m, UCHAR s, UCHAR f) int msf_to_lba (UCHAR m, UCHAR s, UCHAR f)
{ {
return (((m * 60) + s) * 75 + f) - 150; return (((m * 60) + s) * 75 + f) - 150;
} }
static VOID static VOID
CdfsGetPVDData(PUCHAR Buffer, CdfsGetPVDData(PUCHAR Buffer,
PCDINFO CdInfo) PCDINFO CdInfo)
{ {
PPVD Pvd; PPVD Pvd;
ULONG i; ULONG i;
PUCHAR pc; PUCHAR pc;
PWCHAR pw; PWCHAR pw;
union union
{ {
ULONG Value; ULONG Value;
UCHAR Part[4]; UCHAR Part[4];
} Serial; } Serial;
Pvd = (PPVD)Buffer; Pvd = (PPVD)Buffer;
/* Calculate the volume serial number */ /* Calculate the volume serial number */
Serial.Value = 0; Serial.Value = 0;
for (i = 0; i < 2048; i += 4) for (i = 0; i < 2048; i += 4)
{ {
/* DON'T optimize this to ULONG!!! (breaks overflow) */ /* DON'T optimize this to ULONG!!! (breaks overflow) */
Serial.Part[0] += Buffer[i+3]; Serial.Part[0] += Buffer[i+3];
Serial.Part[1] += Buffer[i+2]; Serial.Part[1] += Buffer[i+2];
Serial.Part[2] += Buffer[i+1]; Serial.Part[2] += Buffer[i+1];
Serial.Part[3] += Buffer[i+0]; Serial.Part[3] += Buffer[i+0];
} }
CdInfo->SerialNumber = Serial.Value; CdInfo->SerialNumber = Serial.Value;
/* Extract the volume label */ /* Extract the volume label */
pc = Pvd->VolumeId; pc = Pvd->VolumeId;
pw = CdInfo->VolumeLabel; pw = CdInfo->VolumeLabel;
for (i = 0; i < MAXIMUM_VOLUME_LABEL_LENGTH && *pc != ' '; i++) for (i = 0; i < MAXIMUM_VOLUME_LABEL_LENGTH && *pc != ' '; i++)
{ {
*pw++ = (WCHAR)*pc++; *pw++ = (WCHAR)*pc++;
} }
*pw = 0; *pw = 0;
CdInfo->VolumeLabelLength = i * sizeof(WCHAR); CdInfo->VolumeLabelLength = i * sizeof(WCHAR);
CdInfo->VolumeSpaceSize = Pvd->VolumeSpaceSizeL; CdInfo->VolumeSpaceSize = Pvd->VolumeSpaceSizeL;
CdInfo->RootStart = Pvd->RootDirRecord.ExtentLocationL; CdInfo->RootStart = Pvd->RootDirRecord.ExtentLocationL;
CdInfo->RootSize = Pvd->RootDirRecord.DataLengthL; CdInfo->RootSize = Pvd->RootDirRecord.DataLengthL;
DPRINT("VolumeSerial: %08lx\n", CdInfo->SerialNumber); DPRINT("VolumeSerial: %08lx\n", CdInfo->SerialNumber);
DPRINT("VolumeLabel: '%S'\n", CdInfo->VolumeLabel); DPRINT("VolumeLabel: '%S'\n", CdInfo->VolumeLabel);
DPRINT("VolumeLabelLength: %lu\n", CdInfo->VolumeLabelLength); DPRINT("VolumeLabelLength: %lu\n", CdInfo->VolumeLabelLength);
DPRINT("VolumeSize: %lu\n", Pvd->VolumeSpaceSizeL); DPRINT("VolumeSize: %lu\n", Pvd->VolumeSpaceSizeL);
DPRINT("RootStart: %lu\n", Pvd->RootDirRecord.ExtentLocationL); DPRINT("RootStart: %lu\n", Pvd->RootDirRecord.ExtentLocationL);
DPRINT("RootSize: %lu\n", Pvd->RootDirRecord.DataLengthL); DPRINT("RootSize: %lu\n", Pvd->RootDirRecord.DataLengthL);
DPRINT("PathTableSize: %lu\n", Pvd->PathTableSizeL); DPRINT("PathTableSize: %lu\n", Pvd->PathTableSizeL);
DPRINT("PathTablePos: %lu\n", Pvd->LPathTablePos); DPRINT("PathTablePos: %lu\n", Pvd->LPathTablePos);
DPRINT("OptPathTablePos: %lu\n", Pvd->LOptPathTablePos); DPRINT("OptPathTablePos: %lu\n", Pvd->LOptPathTablePos);
#if 0 #if 0
DbgPrint("******** PVD **********\n"); DbgPrint("******** PVD **********\n");
DbgPrint("VdType: %d\n", Pvd->VdType); DbgPrint("VdType: %d\n", Pvd->VdType);
DbgPrint("StandardId: '%.*s'\n", 5, Pvd->StandardId); DbgPrint("StandardId: '%.*s'\n", 5, Pvd->StandardId);
DbgPrint("VdVersion: %d\n", Pvd->VdVersion); DbgPrint("VdVersion: %d\n", Pvd->VdVersion);
DbgPrint("SystemId: '%.*s'\n", 32, Pvd->SystemId); DbgPrint("SystemId: '%.*s'\n", 32, Pvd->SystemId);
DbgPrint("VolumeId: '%.*s'\n", 32, Pvd->VolumeId); DbgPrint("VolumeId: '%.*s'\n", 32, Pvd->VolumeId);
DbgPrint("VolumeSpaceSizeL: %d (%x)\n", Pvd->VolumeSpaceSizeL, Pvd->VolumeSpaceSizeL); DbgPrint("VolumeSpaceSizeL: %d (%x)\n", Pvd->VolumeSpaceSizeL, Pvd->VolumeSpaceSizeL);
DbgPrint("VolumeSpaceSizeM: %d (%x)\n", Pvd->VolumeSpaceSizeM, Pvd->VolumeSpaceSizeM); DbgPrint("VolumeSpaceSizeM: %d (%x)\n", Pvd->VolumeSpaceSizeM, Pvd->VolumeSpaceSizeM);
DbgPrint("VolumeSetSize: %d (%x)\n", Pvd->VolumeSequenceNumber, Pvd->VolumeSequenceNumber); DbgPrint("VolumeSetSize: %d (%x)\n", Pvd->VolumeSequenceNumber, Pvd->VolumeSequenceNumber);
DbgPrint("VolumeSequenceNumber: %d (%x)\n", Pvd->VolumeSequenceNumber, Pvd->VolumeSequenceNumber); DbgPrint("VolumeSequenceNumber: %d (%x)\n", Pvd->VolumeSequenceNumber, Pvd->VolumeSequenceNumber);
DbgPrint("LogicalBlockSize: %d (%x)\n", Pvd->LogicalBlockSize, Pvd->LogicalBlockSize); DbgPrint("LogicalBlockSize: %d (%x)\n", Pvd->LogicalBlockSize, Pvd->LogicalBlockSize);
DbgPrint("PathTableSizeL: %d (%x)\n", Pvd->PathTableSizeL, Pvd->PathTableSizeL); DbgPrint("PathTableSizeL: %d (%x)\n", Pvd->PathTableSizeL, Pvd->PathTableSizeL);
DbgPrint("PathTableSizeM: %d (%x)\n", Pvd->PathTableSizeM, Pvd->PathTableSizeM); DbgPrint("PathTableSizeM: %d (%x)\n", Pvd->PathTableSizeM, Pvd->PathTableSizeM);
DbgPrint("LPathTablePos: %d (%x)\n", Pvd->LPathTablePos, Pvd->LPathTablePos); DbgPrint("LPathTablePos: %d (%x)\n", Pvd->LPathTablePos, Pvd->LPathTablePos);
DbgPrint("LOptPathTablePos: %d (%x)\n", Pvd->LOptPathTablePos, Pvd->LOptPathTablePos); DbgPrint("LOptPathTablePos: %d (%x)\n", Pvd->LOptPathTablePos, Pvd->LOptPathTablePos);
DbgPrint("MPathTablePos: %d (%x)\n", Pvd->MPathTablePos, Pvd->MPathTablePos); DbgPrint("MPathTablePos: %d (%x)\n", Pvd->MPathTablePos, Pvd->MPathTablePos);
DbgPrint("MOptPathTablePos: %d (%x)\n", Pvd->MOptPathTablePos, Pvd->MOptPathTablePos); DbgPrint("MOptPathTablePos: %d (%x)\n", Pvd->MOptPathTablePos, Pvd->MOptPathTablePos);
DbgPrint("VolumeSetIdentifier: '%.*s'\n", 128, Pvd->VolumeSetIdentifier); DbgPrint("VolumeSetIdentifier: '%.*s'\n", 128, Pvd->VolumeSetIdentifier);
DbgPrint("PublisherIdentifier: '%.*s'\n", 128, Pvd->PublisherIdentifier); DbgPrint("PublisherIdentifier: '%.*s'\n", 128, Pvd->PublisherIdentifier);
DbgPrint("******** Root *********\n"); DbgPrint("******** Root *********\n");
DbgPrint("RecordLength: %d\n", Pvd->RootDirRecord.RecordLength); DbgPrint("RecordLength: %d\n", Pvd->RootDirRecord.RecordLength);
DbgPrint("ExtAttrRecordLength: %d\n", Pvd->RootDirRecord.ExtAttrRecordLength); DbgPrint("ExtAttrRecordLength: %d\n", Pvd->RootDirRecord.ExtAttrRecordLength);
DbgPrint("ExtentLocationL: %d\n", Pvd->RootDirRecord.ExtentLocationL); DbgPrint("ExtentLocationL: %d\n", Pvd->RootDirRecord.ExtentLocationL);
DbgPrint("DataLengthL: %d\n", Pvd->RootDirRecord.DataLengthL); DbgPrint("DataLengthL: %d\n", Pvd->RootDirRecord.DataLengthL);
DbgPrint("Year: %d\n", Pvd->RootDirRecord.Year); DbgPrint("Year: %d\n", Pvd->RootDirRecord.Year);
DbgPrint("Month: %d\n", Pvd->RootDirRecord.Month); DbgPrint("Month: %d\n", Pvd->RootDirRecord.Month);
DbgPrint("Day: %d\n", Pvd->RootDirRecord.Day); DbgPrint("Day: %d\n", Pvd->RootDirRecord.Day);
DbgPrint("Hour: %d\n", Pvd->RootDirRecord.Hour); DbgPrint("Hour: %d\n", Pvd->RootDirRecord.Hour);
DbgPrint("Minute: %d\n", Pvd->RootDirRecord.Minute); DbgPrint("Minute: %d\n", Pvd->RootDirRecord.Minute);
DbgPrint("Second: %d\n", Pvd->RootDirRecord.Second); DbgPrint("Second: %d\n", Pvd->RootDirRecord.Second);
DbgPrint("TimeZone: %d\n", Pvd->RootDirRecord.TimeZone); DbgPrint("TimeZone: %d\n", Pvd->RootDirRecord.TimeZone);
DbgPrint("FileFlags: %d\n", Pvd->RootDirRecord.FileFlags); DbgPrint("FileFlags: %d\n", Pvd->RootDirRecord.FileFlags);
DbgPrint("FileUnitSize: %d\n", Pvd->RootDirRecord.FileUnitSize); DbgPrint("FileUnitSize: %d\n", Pvd->RootDirRecord.FileUnitSize);
DbgPrint("InterleaveGapSize: %d\n", Pvd->RootDirRecord.InterleaveGapSize); DbgPrint("InterleaveGapSize: %d\n", Pvd->RootDirRecord.InterleaveGapSize);
DbgPrint("VolumeSequenceNumber: %d\n", Pvd->RootDirRecord.VolumeSequenceNumber); DbgPrint("VolumeSequenceNumber: %d\n", Pvd->RootDirRecord.VolumeSequenceNumber);
DbgPrint("FileIdLength: %d\n", Pvd->RootDirRecord.FileIdLength); DbgPrint("FileIdLength: %d\n", Pvd->RootDirRecord.FileIdLength);
DbgPrint("FileId: '%.*s'\n", Pvd->RootDirRecord.FileId); DbgPrint("FileId: '%.*s'\n", Pvd->RootDirRecord.FileId);
DbgPrint("***********************\n"); DbgPrint("***********************\n");
#endif #endif
} }
static VOID static VOID
CdfsGetSVDData(PUCHAR Buffer, CdfsGetSVDData(PUCHAR Buffer,
PCDINFO CdInfo) PCDINFO CdInfo)
{ {
PSVD Svd; PSVD Svd;
ULONG JolietLevel = 0; ULONG JolietLevel = 0;
Svd = (PSVD)Buffer; Svd = (PSVD)Buffer;
DPRINT("EscapeSequences: '%.32s'\n", Svd->EscapeSequences); DPRINT("EscapeSequences: '%.32s'\n", Svd->EscapeSequences);
if (strncmp((PCHAR)Svd->EscapeSequences, "%/@", 3) == 0) if (strncmp((PCHAR)Svd->EscapeSequences, "%/@", 3) == 0)
{ {
DPRINT("Joliet extension found (UCS-2 Level 1)\n"); DPRINT("Joliet extension found (UCS-2 Level 1)\n");
JolietLevel = 1; JolietLevel = 1;
} }
else if (strncmp((PCHAR)Svd->EscapeSequences, "%/C", 3) == 0) else if (strncmp((PCHAR)Svd->EscapeSequences, "%/C", 3) == 0)
{ {
DPRINT("Joliet extension found (UCS-2 Level 2)\n"); DPRINT("Joliet extension found (UCS-2 Level 2)\n");
JolietLevel = 2; JolietLevel = 2;
} }
else if (strncmp((PCHAR)Svd->EscapeSequences, "%/E", 3) == 0) else if (strncmp((PCHAR)Svd->EscapeSequences, "%/E", 3) == 0)
{ {
DPRINT("Joliet extension found (UCS-2 Level 3)\n"); DPRINT("Joliet extension found (UCS-2 Level 3)\n");
JolietLevel = 3; JolietLevel = 3;
} }
CdInfo->JolietLevel = JolietLevel; CdInfo->JolietLevel = JolietLevel;
if (JolietLevel != 0) if (JolietLevel != 0)
{ {
CdInfo->RootStart = Svd->RootDirRecord.ExtentLocationL; CdInfo->RootStart = Svd->RootDirRecord.ExtentLocationL;
CdInfo->RootSize = Svd->RootDirRecord.DataLengthL; CdInfo->RootSize = Svd->RootDirRecord.DataLengthL;
DPRINT("RootStart: %lu\n", Svd->RootDirRecord.ExtentLocationL); DPRINT("RootStart: %lu\n", Svd->RootDirRecord.ExtentLocationL);
DPRINT("RootSize: %lu\n", Svd->RootDirRecord.DataLengthL); DPRINT("RootSize: %lu\n", Svd->RootDirRecord.DataLengthL);
} }
} }
static NTSTATUS static NTSTATUS
CdfsGetVolumeData(PDEVICE_OBJECT DeviceObject, CdfsGetVolumeData(PDEVICE_OBJECT DeviceObject,
PCDINFO CdInfo) PCDINFO CdInfo)
{ {
PUCHAR Buffer; PUCHAR Buffer;
NTSTATUS Status; NTSTATUS Status;
ULONG Sector; ULONG Sector;
PVD_HEADER VdHeader; PVD_HEADER VdHeader;
ULONG Size; ULONG Size;
ULONG Offset; ULONG Offset;
ULONG i; ULONG i;
struct struct
{
UCHAR Length[2];
UCHAR FirstSession;
UCHAR LastSession;
TRACK_DATA TrackData;
}
Toc;
DPRINT("CdfsGetVolumeData\n");
Buffer = ExAllocatePool(NonPagedPool,
CDFS_BASIC_SECTOR);
if (Buffer == NULL)
return STATUS_INSUFFICIENT_RESOURCES;
Size = sizeof(Toc);
Status = CdfsDeviceIoControl(DeviceObject,
IOCTL_CDROM_GET_LAST_SESSION,
NULL,
0,
&Toc,
&Size,
TRUE);
if (!NT_SUCCESS(Status))
{ {
ExFreePool(Buffer); UCHAR Length[2];
return Status; UCHAR FirstSession;
UCHAR LastSession;
TRACK_DATA TrackData;
}
Toc;
DPRINT("CdfsGetVolumeData\n");
Buffer = ExAllocatePool(NonPagedPool,
CDFS_BASIC_SECTOR);
if (Buffer == NULL)
return STATUS_INSUFFICIENT_RESOURCES;
Size = sizeof(Toc);
Status = CdfsDeviceIoControl(DeviceObject,
IOCTL_CDROM_GET_LAST_SESSION,
NULL,
0,
&Toc,
&Size,
TRUE);
if (!NT_SUCCESS(Status))
{
ExFreePool(Buffer);
return Status;
} }
DPRINT("FirstSession %d, LastSession %d, FirstTrack %d\n", DPRINT("FirstSession %d, LastSession %d, FirstTrack %d\n",
Toc.FirstSession, Toc.LastSession, Toc.TrackData.TrackNumber); Toc.FirstSession, Toc.LastSession, Toc.TrackData.TrackNumber);
Offset = 0; Offset = 0;
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
Offset = (Offset << 8) + Toc.TrackData.Address[i]; Offset = (Offset << 8) + Toc.TrackData.Address[i];
} }
CdInfo->VolumeOffset = Offset; CdInfo->VolumeOffset = Offset;
DPRINT("Offset of first track in last session %d\n", Offset); DPRINT("Offset of first track in last session %d\n", Offset);
CdInfo->JolietLevel = 0; CdInfo->JolietLevel = 0;
VdHeader = (PVD_HEADER)Buffer; VdHeader = (PVD_HEADER)Buffer;
Buffer[0] = 0; Buffer[0] = 0;
for (Sector = CDFS_PRIMARY_DESCRIPTOR_LOCATION; Sector < 100 && Buffer[0] != 255; Sector++) for (Sector = CDFS_PRIMARY_DESCRIPTOR_LOCATION; Sector < 100 && Buffer[0] != 255; Sector++)
{ {
/* Read the Primary Volume Descriptor (PVD) */ /* Read the Primary Volume Descriptor (PVD) */
Status = CdfsReadSectors (DeviceObject, Status = CdfsReadSectors (DeviceObject,
Sector + Offset, Sector + Offset,
1, 1,
Buffer, Buffer,
TRUE); TRUE);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
ExFreePool(Buffer); ExFreePool(Buffer);
return Status; return Status;
} }
if (Sector == CDFS_PRIMARY_DESCRIPTOR_LOCATION) if (Sector == CDFS_PRIMARY_DESCRIPTOR_LOCATION)
{ {
DPRINT("CD-identifier: [%.5s]\n", Buffer + 1); DPRINT("CD-identifier: [%.5s]\n", Buffer + 1);
if (Buffer[0] != 1 || Buffer[1] != 'C' || Buffer[2] != 'D' || if (Buffer[0] != 1 || Buffer[1] != 'C' || Buffer[2] != 'D' ||
Buffer[3] != '0' || Buffer[4] != '0' || Buffer[5] != '1') Buffer[3] != '0' || Buffer[4] != '0' || Buffer[5] != '1')
{ {
ExFreePool(Buffer); ExFreePool(Buffer);
return STATUS_UNRECOGNIZED_VOLUME; return STATUS_UNRECOGNIZED_VOLUME;
} }
} }
switch (VdHeader->VdType) switch (VdHeader->VdType)
{ {
case 0: case 0:
DPRINT("BootVolumeDescriptor found!\n"); DPRINT("BootVolumeDescriptor found!\n");
break; break;
case 1: case 1:
DPRINT("PrimaryVolumeDescriptor found!\n"); DPRINT("PrimaryVolumeDescriptor found!\n");
CdfsGetPVDData(Buffer, CdInfo); CdfsGetPVDData(Buffer, CdInfo);
break; break;
case 2: case 2:
DPRINT("SupplementaryVolumeDescriptor found!\n"); DPRINT("SupplementaryVolumeDescriptor found!\n");
CdfsGetSVDData(Buffer, CdInfo); CdfsGetSVDData(Buffer, CdInfo);
break; break;
case 3: case 3:
DPRINT("VolumePartitionDescriptor found!\n"); DPRINT("VolumePartitionDescriptor found!\n");
break; break;
case 255: case 255:
DPRINT("VolumeDescriptorSetTerminator found!\n"); DPRINT("VolumeDescriptorSetTerminator found!\n");
break; break;
default: default:
DPRINT1("Unknown volume descriptor type %u found!\n", VdHeader->VdType); DPRINT1("Unknown volume descriptor type %u found!\n", VdHeader->VdType);
break; break;
} }
} }
ExFreePool(Buffer); ExFreePool(Buffer);
return(STATUS_SUCCESS); return(STATUS_SUCCESS);
} }
static NTSTATUS static NTSTATUS
CdfsMountVolume(PDEVICE_OBJECT DeviceObject, CdfsMountVolume(PDEVICE_OBJECT DeviceObject,
PIRP Irp) PIRP Irp)
{ {
PDEVICE_EXTENSION DeviceExt = NULL; PDEVICE_EXTENSION DeviceExt = NULL;
PDEVICE_OBJECT NewDeviceObject = NULL; PDEVICE_OBJECT NewDeviceObject = NULL;
PDEVICE_OBJECT DeviceToMount; PDEVICE_OBJECT DeviceToMount;
PIO_STACK_LOCATION Stack; PIO_STACK_LOCATION Stack;
PFCB Fcb = NULL; PFCB Fcb = NULL;
PCCB Ccb = NULL; PCCB Ccb = NULL;
PVPB Vpb; PVPB Vpb;
NTSTATUS Status; NTSTATUS Status;
CDINFO CdInfo; CDINFO CdInfo;
DPRINT("CdfsMountVolume() called\n"); DPRINT("CdfsMountVolume() called\n");
if (DeviceObject != CdfsGlobalData->DeviceObject) if (DeviceObject != CdfsGlobalData->DeviceObject)
{ {
Status = STATUS_INVALID_DEVICE_REQUEST; Status = STATUS_INVALID_DEVICE_REQUEST;
goto ByeBye; goto ByeBye;
} }
Stack = IoGetCurrentIrpStackLocation(Irp); Stack = IoGetCurrentIrpStackLocation(Irp);
DeviceToMount = Stack->Parameters.MountVolume.DeviceObject; DeviceToMount = Stack->Parameters.MountVolume.DeviceObject;
Vpb = Stack->Parameters.MountVolume.Vpb; Vpb = Stack->Parameters.MountVolume.Vpb;
Status = CdfsGetVolumeData(DeviceToMount, &CdInfo); Status = CdfsGetVolumeData(DeviceToMount, &CdInfo);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
goto ByeBye; goto ByeBye;
} }
Status = IoCreateDevice(CdfsGlobalData->DriverObject, Status = IoCreateDevice(CdfsGlobalData->DriverObject,
sizeof(DEVICE_EXTENSION), sizeof(DEVICE_EXTENSION),
NULL, NULL,
FILE_DEVICE_CD_ROM_FILE_SYSTEM, FILE_DEVICE_CD_ROM_FILE_SYSTEM,
0, 0,
FALSE, FALSE,
&NewDeviceObject); &NewDeviceObject);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
goto ByeBye; goto ByeBye;
NewDeviceObject->Flags = NewDeviceObject->Flags | DO_DIRECT_IO; NewDeviceObject->Flags = NewDeviceObject->Flags | DO_DIRECT_IO;
NewDeviceObject->Flags &= ~DO_VERIFY_VOLUME; NewDeviceObject->Flags &= ~DO_VERIFY_VOLUME;
DeviceExt = (PVOID)NewDeviceObject->DeviceExtension; DeviceExt = (PVOID)NewDeviceObject->DeviceExtension;
RtlZeroMemory(DeviceExt, RtlZeroMemory(DeviceExt,
sizeof(DEVICE_EXTENSION)); sizeof(DEVICE_EXTENSION));
Vpb->SerialNumber = CdInfo.SerialNumber; Vpb->SerialNumber = CdInfo.SerialNumber;
Vpb->VolumeLabelLength = CdInfo.VolumeLabelLength; Vpb->VolumeLabelLength = CdInfo.VolumeLabelLength;
RtlCopyMemory(Vpb->VolumeLabel, CdInfo.VolumeLabel, CdInfo.VolumeLabelLength * sizeof(WCHAR)); RtlCopyMemory(Vpb->VolumeLabel, CdInfo.VolumeLabel, CdInfo.VolumeLabelLength * sizeof(WCHAR));
RtlCopyMemory(&DeviceExt->CdInfo, &CdInfo, sizeof(CDINFO)); RtlCopyMemory(&DeviceExt->CdInfo, &CdInfo, sizeof(CDINFO));
NewDeviceObject->Vpb = DeviceToMount->Vpb; NewDeviceObject->Vpb = DeviceToMount->Vpb;
DeviceExt->VolumeDevice = NewDeviceObject; DeviceExt->VolumeDevice = NewDeviceObject;
DeviceExt->StorageDevice = DeviceToMount; DeviceExt->StorageDevice = DeviceToMount;
DeviceExt->StorageDevice->Vpb->DeviceObject = NewDeviceObject; DeviceExt->StorageDevice->Vpb->DeviceObject = NewDeviceObject;
DeviceExt->StorageDevice->Vpb->RealDevice = DeviceExt->StorageDevice; DeviceExt->StorageDevice->Vpb->RealDevice = DeviceExt->StorageDevice;
DeviceExt->StorageDevice->Vpb->Flags |= VPB_MOUNTED; DeviceExt->StorageDevice->Vpb->Flags |= VPB_MOUNTED;
NewDeviceObject->StackSize = DeviceExt->StorageDevice->StackSize + 1; NewDeviceObject->StackSize = DeviceExt->StorageDevice->StackSize + 1;
NewDeviceObject->Flags &= ~DO_DEVICE_INITIALIZING; NewDeviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
/* Close (and cleanup) might be called from IoCreateStreamFileObject /* Close (and cleanup) might be called from IoCreateStreamFileObject
* but we use this resource from CdfsCleanup, therefore it should be * but we use this resource from CdfsCleanup, therefore it should be
* initialized no later than this. */ * initialized no later than this. */
ExInitializeResourceLite(&DeviceExt->DirResource); ExInitializeResourceLite(&DeviceExt->DirResource);
DeviceExt->StreamFileObject = IoCreateStreamFileObject(NULL, DeviceExt->StreamFileObject = IoCreateStreamFileObject(NULL,
DeviceExt->StorageDevice); DeviceExt->StorageDevice);
Fcb = CdfsCreateFCB(NULL); Fcb = CdfsCreateFCB(NULL);
if (Fcb == NULL) if (Fcb == NULL)
{ {
Status = STATUS_INSUFFICIENT_RESOURCES; Status = STATUS_INSUFFICIENT_RESOURCES;
goto ByeBye; goto ByeBye;
} }
Ccb = ExAllocatePoolWithTag(NonPagedPool, Ccb = ExAllocatePoolWithTag(NonPagedPool,
sizeof(CCB), sizeof(CCB),
TAG_CCB); TAG_CCB);
if (Ccb == NULL) if (Ccb == NULL)
{ {
Status = STATUS_INSUFFICIENT_RESOURCES; Status = STATUS_INSUFFICIENT_RESOURCES;
goto ByeBye; goto ByeBye;
} }
RtlZeroMemory(Ccb, RtlZeroMemory(Ccb,
sizeof(CCB)); sizeof(CCB));
DeviceExt->StreamFileObject->FsContext = Fcb; DeviceExt->StreamFileObject->FsContext = Fcb;
DeviceExt->StreamFileObject->FsContext2 = Ccb; DeviceExt->StreamFileObject->FsContext2 = Ccb;
DeviceExt->StreamFileObject->SectionObjectPointer = &Fcb->SectionObjectPointers; DeviceExt->StreamFileObject->SectionObjectPointer = &Fcb->SectionObjectPointers;
DeviceExt->StreamFileObject->PrivateCacheMap = NULL; DeviceExt->StreamFileObject->PrivateCacheMap = NULL;
DeviceExt->StreamFileObject->Vpb = DeviceExt->Vpb; DeviceExt->StreamFileObject->Vpb = DeviceExt->Vpb;
Ccb->PtrFileObject = DeviceExt->StreamFileObject; Ccb->PtrFileObject = DeviceExt->StreamFileObject;
Fcb->FileObject = DeviceExt->StreamFileObject; Fcb->FileObject = DeviceExt->StreamFileObject;
Fcb->DevExt = (PDEVICE_EXTENSION)DeviceExt->StorageDevice; Fcb->DevExt = (PDEVICE_EXTENSION)DeviceExt->StorageDevice;
Fcb->Flags = FCB_IS_VOLUME_STREAM; Fcb->Flags = FCB_IS_VOLUME_STREAM;
Fcb->RFCB.FileSize.QuadPart = (DeviceExt->CdInfo.VolumeSpaceSize + DeviceExt->CdInfo.VolumeOffset) * BLOCKSIZE; Fcb->RFCB.FileSize.QuadPart = (DeviceExt->CdInfo.VolumeSpaceSize + DeviceExt->CdInfo.VolumeOffset) * BLOCKSIZE;
Fcb->RFCB.ValidDataLength = Fcb->RFCB.AllocationSize = Fcb->RFCB.FileSize; Fcb->RFCB.ValidDataLength = Fcb->RFCB.AllocationSize = Fcb->RFCB.FileSize;
Fcb->Entry.ExtentLocationL = 0; Fcb->Entry.ExtentLocationL = 0;
Fcb->Entry.DataLengthL = (DeviceExt->CdInfo.VolumeSpaceSize + DeviceExt->CdInfo.VolumeOffset) * BLOCKSIZE; Fcb->Entry.DataLengthL = (DeviceExt->CdInfo.VolumeSpaceSize + DeviceExt->CdInfo.VolumeOffset) * BLOCKSIZE;
CcInitializeCacheMap(DeviceExt->StreamFileObject, CcInitializeCacheMap(DeviceExt->StreamFileObject,
(PCC_FILE_SIZES)(&Fcb->RFCB.AllocationSize), (PCC_FILE_SIZES)(&Fcb->RFCB.AllocationSize),
TRUE, TRUE,
&(CdfsGlobalData->CacheMgrCallbacks), &(CdfsGlobalData->CacheMgrCallbacks),
Fcb); Fcb);
ExInitializeResourceLite(&DeviceExt->VcbResource); ExInitializeResourceLite(&DeviceExt->VcbResource);
KeInitializeSpinLock(&DeviceExt->FcbListLock); KeInitializeSpinLock(&DeviceExt->FcbListLock);
InitializeListHead(&DeviceExt->FcbListHead); InitializeListHead(&DeviceExt->FcbListHead);
Status = STATUS_SUCCESS; Status = STATUS_SUCCESS;
ByeBye: ByeBye:
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
/* Cleanup */ /* Cleanup */
if (DeviceExt && DeviceExt->StreamFileObject) if (DeviceExt && DeviceExt->StreamFileObject)
ObDereferenceObject(DeviceExt->StreamFileObject); ObDereferenceObject(DeviceExt->StreamFileObject);
if (Fcb) if (Fcb)
ExFreePool(Fcb); ExFreePool(Fcb);
if (Ccb) if (Ccb)
ExFreePool(Ccb); ExFreePool(Ccb);
if (NewDeviceObject) if (NewDeviceObject)
IoDeleteDevice(NewDeviceObject); IoDeleteDevice(NewDeviceObject);
} }
DPRINT("CdfsMountVolume() done (Status: %lx)\n", Status); DPRINT("CdfsMountVolume() done (Status: %lx)\n", Status);
return(Status); return(Status);
} }
static NTSTATUS static NTSTATUS
CdfsVerifyVolume(PDEVICE_OBJECT DeviceObject, CdfsVerifyVolume(PDEVICE_OBJECT DeviceObject,
PIRP Irp) PIRP Irp)
{ {
PDEVICE_EXTENSION DeviceExt; PDEVICE_EXTENSION DeviceExt;
PDEVICE_OBJECT DeviceToVerify; PDEVICE_OBJECT DeviceToVerify;
PIO_STACK_LOCATION Stack; PIO_STACK_LOCATION Stack;
NTSTATUS Status; NTSTATUS Status;
CDINFO CdInfo; CDINFO CdInfo;
PLIST_ENTRY Entry; PLIST_ENTRY Entry;
PFCB Fcb; PFCB Fcb;
DPRINT1 ("CdfsVerifyVolume() called\n"); DPRINT1 ("CdfsVerifyVolume() called\n");
#if 0 #if 0
if (DeviceObject != CdfsGlobalData->DeviceObject) if (DeviceObject != CdfsGlobalData->DeviceObject)
{ {
DPRINT1("DeviceObject != CdfsGlobalData->DeviceObject\n"); DPRINT1("DeviceObject != CdfsGlobalData->DeviceObject\n");
return(STATUS_INVALID_DEVICE_REQUEST); return(STATUS_INVALID_DEVICE_REQUEST);
} }
#endif #endif
DeviceExt = DeviceObject->DeviceExtension; DeviceExt = DeviceObject->DeviceExtension;
Stack = IoGetCurrentIrpStackLocation (Irp); Stack = IoGetCurrentIrpStackLocation (Irp);
DeviceToVerify = Stack->Parameters.VerifyVolume.DeviceObject; DeviceToVerify = Stack->Parameters.VerifyVolume.DeviceObject;
ExAcquireResourceExclusiveLite (&DeviceExt->VcbResource, ExAcquireResourceExclusiveLite (&DeviceExt->VcbResource,
TRUE); TRUE);
if (!(DeviceToVerify->Flags & DO_VERIFY_VOLUME)) if (!(DeviceToVerify->Flags & DO_VERIFY_VOLUME))
{ {
DPRINT1 ("Volume has been verified!\n"); DPRINT1 ("Volume has been verified!\n");
ExReleaseResourceLite (&DeviceExt->VcbResource); ExReleaseResourceLite (&DeviceExt->VcbResource);
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
DPRINT1 ("Device object %p Device to verify %p\n", DeviceObject, DeviceToVerify); DPRINT1 ("Device object %p Device to verify %p\n", DeviceObject, DeviceToVerify);
Status = CdfsGetVolumeData (DeviceToVerify, Status = CdfsGetVolumeData (DeviceToVerify,
&CdInfo); &CdInfo);
if (NT_SUCCESS(Status) && if (NT_SUCCESS(Status) &&
CdInfo.SerialNumber == DeviceToVerify->Vpb->SerialNumber && CdInfo.SerialNumber == DeviceToVerify->Vpb->SerialNumber &&
CdInfo.VolumeLabelLength == DeviceToVerify->Vpb->VolumeLabelLength && CdInfo.VolumeLabelLength == DeviceToVerify->Vpb->VolumeLabelLength &&
!wcsncmp (CdInfo.VolumeLabel, DeviceToVerify->Vpb->VolumeLabel, CdInfo.VolumeLabelLength)) !wcsncmp (CdInfo.VolumeLabel, DeviceToVerify->Vpb->VolumeLabel, CdInfo.VolumeLabelLength))
{ {
DPRINT1 ("Same volume!\n"); DPRINT1 ("Same volume!\n");
/* FIXME: Flush and purge metadata */ /* FIXME: Flush and purge metadata */
Status = STATUS_SUCCESS; Status = STATUS_SUCCESS;
} }
else else
{ {
DPRINT1 ("Different volume!\n"); DPRINT1 ("Different volume!\n");
/* FIXME: force volume dismount */ /* FIXME: force volume dismount */
Entry = DeviceExt->FcbListHead.Flink; Entry = DeviceExt->FcbListHead.Flink;
while (Entry != &DeviceExt->FcbListHead) while (Entry != &DeviceExt->FcbListHead)
{ {
Fcb = (PFCB)CONTAINING_RECORD(Entry, FCB, FcbListEntry); Fcb = (PFCB)CONTAINING_RECORD(Entry, FCB, FcbListEntry);
DPRINT1("OpenFile %S RefCount %ld\n", Fcb->PathName, Fcb->RefCount); DPRINT1("OpenFile %S RefCount %ld\n", Fcb->PathName, Fcb->RefCount);
Entry = Entry->Flink; Entry = Entry->Flink;
} }
Status = STATUS_WRONG_VOLUME; Status = STATUS_WRONG_VOLUME;
} }
DeviceToVerify->Flags &= ~DO_VERIFY_VOLUME; DeviceToVerify->Flags &= ~DO_VERIFY_VOLUME;
ExReleaseResourceLite (&DeviceExt->VcbResource); ExReleaseResourceLite (&DeviceExt->VcbResource);
return Status; return Status;
} }
NTSTATUS NTAPI NTSTATUS NTAPI
CdfsSetCompression( CdfsSetCompression(
IN PDEVICE_OBJECT DeviceObject, IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp) IN PIRP Irp)
{ {
PIO_STACK_LOCATION Stack; PIO_STACK_LOCATION Stack;
USHORT CompressionState; USHORT CompressionState;
@ -536,54 +536,54 @@ CdfsSetCompression(
NTSTATUS NTAPI NTSTATUS NTAPI
CdfsFileSystemControl(PDEVICE_OBJECT DeviceObject, CdfsFileSystemControl(PDEVICE_OBJECT DeviceObject,
PIRP Irp) PIRP Irp)
{ {
PIO_STACK_LOCATION Stack; PIO_STACK_LOCATION Stack;
NTSTATUS Status; NTSTATUS Status;
DPRINT("CdfsFileSystemControl() called\n"); DPRINT("CdfsFileSystemControl() called\n");
Stack = IoGetCurrentIrpStackLocation(Irp); Stack = IoGetCurrentIrpStackLocation(Irp);
switch (Stack->MinorFunction) switch (Stack->MinorFunction)
{ {
case IRP_MN_USER_FS_REQUEST: case IRP_MN_USER_FS_REQUEST:
switch (Stack->Parameters.DeviceIoControl.IoControlCode) switch (Stack->Parameters.DeviceIoControl.IoControlCode)
{ {
case FSCTL_SET_COMPRESSION: case FSCTL_SET_COMPRESSION:
DPRINT("CDFS: IRP_MN_USER_FS_REQUEST / FSCTL_SET_COMPRESSION\n"); DPRINT("CDFS: IRP_MN_USER_FS_REQUEST / FSCTL_SET_COMPRESSION\n");
Status = CdfsSetCompression(DeviceObject, Irp); Status = CdfsSetCompression(DeviceObject, Irp);
break;
default:
DPRINT1("CDFS: IRP_MN_USER_FS_REQUEST / Unknown IoControlCode 0x%x\n",
Stack->Parameters.DeviceIoControl.IoControlCode);
Status = STATUS_INVALID_DEVICE_REQUEST;
}
break; break;
case IRP_MN_MOUNT_VOLUME: default:
DPRINT("CDFS: IRP_MN_MOUNT_VOLUME\n"); DPRINT1("CDFS: IRP_MN_USER_FS_REQUEST / Unknown IoControlCode 0x%x\n",
Status = CdfsMountVolume(DeviceObject, Irp); Stack->Parameters.DeviceIoControl.IoControlCode);
break; Status = STATUS_INVALID_DEVICE_REQUEST;
}
break;
case IRP_MN_VERIFY_VOLUME: case IRP_MN_MOUNT_VOLUME:
DPRINT1("CDFS: IRP_MN_VERIFY_VOLUME\n"); DPRINT("CDFS: IRP_MN_MOUNT_VOLUME\n");
Status = CdfsVerifyVolume(DeviceObject, Irp); Status = CdfsMountVolume(DeviceObject, Irp);
break; break;
default: case IRP_MN_VERIFY_VOLUME:
DPRINT1("CDFS FSC: MinorFunction %d\n", Stack->MinorFunction); DPRINT1("CDFS: IRP_MN_VERIFY_VOLUME\n");
Status = STATUS_INVALID_DEVICE_REQUEST; Status = CdfsVerifyVolume(DeviceObject, Irp);
break; break;
default:
DPRINT1("CDFS FSC: MinorFunction %d\n", Stack->MinorFunction);
Status = STATUS_INVALID_DEVICE_REQUEST;
break;
} }
Irp->IoStatus.Status = Status; Irp->IoStatus.Status = Status;
Irp->IoStatus.Information = 0; Irp->IoStatus.Information = 0;
IoCompleteRequest(Irp, IO_NO_INCREMENT); IoCompleteRequest(Irp, IO_NO_INCREMENT);
return(Status); return(Status);
} }
/* EOF */ /* EOF */

View file

@ -1,30 +1,30 @@
/* /*
* ReactOS kernel * ReactOS kernel
* Copyright (C) 2002, 2004 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
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* 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$ /* $Id$
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
* FILE: services/fs/cdfs/misc.c * FILE: services/fs/cdfs/misc.c
* PURPOSE: CDROM (ISO 9660) filesystem driver * PURPOSE: CDROM (ISO 9660) filesystem driver
* PROGRAMMER: Eric Kohl * PROGRAMMER: Eric Kohl
* UPDATE HISTORY: * UPDATE HISTORY:
*/ */
/* INCLUDES *****************************************************************/ /* INCLUDES *****************************************************************/
@ -37,62 +37,62 @@
VOID VOID
CdfsSwapString(PWCHAR Out, CdfsSwapString(PWCHAR Out,
PUCHAR In, PUCHAR In,
ULONG Count) ULONG Count)
{ {
PUCHAR t = (PUCHAR)Out; PUCHAR t = (PUCHAR)Out;
ULONG i; ULONG i;
for (i = 0; i < Count; i += 2) for (i = 0; i < Count; i += 2)
{ {
t[i] = In[i+1]; t[i] = In[i+1];
t[i+1] = In[i]; t[i+1] = In[i];
if (t[i+1] == 0 && t[i] == ';') if (t[i+1] == 0 && t[i] == ';')
break; break;
} }
if ((i>2)&&(t[i-2] == '.')) if ((i>2)&&(t[i-2] == '.'))
{ {
t[i-2] = 0; t[i-2] = 0;
t[i-1] = 0; t[i-1] = 0;
} }
t[i] = 0; t[i] = 0;
t[i+1] = 0; t[i+1] = 0;
} }
VOID VOID
CdfsDateTimeToSystemTime(PFCB Fcb, CdfsDateTimeToSystemTime(PFCB Fcb,
PLARGE_INTEGER SystemTime) PLARGE_INTEGER SystemTime)
{ {
TIME_FIELDS TimeFields; TIME_FIELDS TimeFields;
LARGE_INTEGER LocalTime; LARGE_INTEGER LocalTime;
TimeFields.Milliseconds = 0; TimeFields.Milliseconds = 0;
TimeFields.Second = Fcb->Entry.Second; TimeFields.Second = Fcb->Entry.Second;
TimeFields.Minute = Fcb->Entry.Minute; TimeFields.Minute = Fcb->Entry.Minute;
TimeFields.Hour = Fcb->Entry.Hour; TimeFields.Hour = Fcb->Entry.Hour;
TimeFields.Day = Fcb->Entry.Day; TimeFields.Day = Fcb->Entry.Day;
TimeFields.Month = Fcb->Entry.Month; TimeFields.Month = Fcb->Entry.Month;
TimeFields.Year = Fcb->Entry.Year + 1900; TimeFields.Year = Fcb->Entry.Year + 1900;
RtlTimeFieldsToTime(&TimeFields, RtlTimeFieldsToTime(&TimeFields,
&LocalTime); &LocalTime);
ExLocalTimeToSystemTime(&LocalTime, SystemTime); ExLocalTimeToSystemTime(&LocalTime, SystemTime);
} }
VOID VOID
CdfsFileFlagsToAttributes(PFCB Fcb, CdfsFileFlagsToAttributes(PFCB Fcb,
PULONG FileAttributes) PULONG FileAttributes)
{ {
/* FIXME: Fix attributes */ /* FIXME: Fix attributes */
*FileAttributes = // FILE_ATTRIBUTE_READONLY | *FileAttributes = // FILE_ATTRIBUTE_READONLY |
((Fcb->Entry.FileFlags & FILE_FLAG_HIDDEN) ? FILE_ATTRIBUTE_HIDDEN : 0) | ((Fcb->Entry.FileFlags & FILE_FLAG_HIDDEN) ? FILE_ATTRIBUTE_HIDDEN : 0) |
((Fcb->Entry.FileFlags & FILE_FLAG_DIRECTORY) ? FILE_ATTRIBUTE_DIRECTORY : 0) | ((Fcb->Entry.FileFlags & FILE_FLAG_DIRECTORY) ? FILE_ATTRIBUTE_DIRECTORY : 0) |
((Fcb->Entry.FileFlags & FILE_FLAG_SYSTEM) ? FILE_ATTRIBUTE_SYSTEM : 0) | ((Fcb->Entry.FileFlags & FILE_FLAG_SYSTEM) ? FILE_ATTRIBUTE_SYSTEM : 0) |
((Fcb->Entry.FileFlags & FILE_FLAG_READONLY) ? FILE_ATTRIBUTE_READONLY : 0); ((Fcb->Entry.FileFlags & FILE_FLAG_READONLY) ? FILE_ATTRIBUTE_READONLY : 0);
} }
/* EOF */ /* EOF */

View file

@ -1,30 +1,30 @@
/* /*
* ReactOS kernel * ReactOS kernel
* Copyright (C) 2002, 2003 ReactOS Team * Copyright (C) 2002, 2003 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
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* 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$ /* $Id$
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
* FILE: drivers/fs/cdfs/rw.c * FILE: drivers/fs/cdfs/rw.c
* PURPOSE: CDROM (ISO 9660) filesystem driver * PURPOSE: CDROM (ISO 9660) filesystem driver
* PROGRAMMER: Art Yerkes * PROGRAMMER: Art Yerkes
* Eric Kohl * Eric Kohl
*/ */
/* INCLUDES *****************************************************************/ /* INCLUDES *****************************************************************/
@ -43,201 +43,201 @@
static NTSTATUS static NTSTATUS
CdfsReadFile(PDEVICE_EXTENSION DeviceExt, CdfsReadFile(PDEVICE_EXTENSION DeviceExt,
PFILE_OBJECT FileObject, PFILE_OBJECT FileObject,
PUCHAR Buffer, PUCHAR Buffer,
ULONG Length, ULONG Length,
ULONG ReadOffset, ULONG ReadOffset,
ULONG IrpFlags, ULONG IrpFlags,
PULONG LengthRead) PULONG LengthRead)
/* /*
* FUNCTION: Reads data from a file * FUNCTION: Reads data from a file
*/ */
{ {
NTSTATUS Status = STATUS_SUCCESS; NTSTATUS Status = STATUS_SUCCESS;
PCCB Ccb; PCCB Ccb;
PFCB Fcb; PFCB Fcb;
DPRINT("CdfsReadFile(ReadOffset %lu Length %lu)\n", ReadOffset, Length); DPRINT("CdfsReadFile(ReadOffset %lu Length %lu)\n", ReadOffset, Length);
*LengthRead = 0; *LengthRead = 0;
if (Length == 0) if (Length == 0)
return(STATUS_SUCCESS); return(STATUS_SUCCESS);
Ccb = (PCCB)FileObject->FsContext2; Ccb = (PCCB)FileObject->FsContext2;
Fcb = (PFCB)FileObject->FsContext; Fcb = (PFCB)FileObject->FsContext;
if (ReadOffset >= Fcb->Entry.DataLengthL) if (ReadOffset >= Fcb->Entry.DataLengthL)
return(STATUS_END_OF_FILE); return(STATUS_END_OF_FILE);
DPRINT("Reading %d bytes at %d\n", Length, ReadOffset); DPRINT("Reading %d bytes at %d\n", Length, ReadOffset);
if (!(IrpFlags & (IRP_NOCACHE|IRP_PAGING_IO))) if (!(IrpFlags & (IRP_NOCACHE|IRP_PAGING_IO)))
{ {
LARGE_INTEGER FileOffset; LARGE_INTEGER FileOffset;
IO_STATUS_BLOCK IoStatus; IO_STATUS_BLOCK IoStatus;
CC_FILE_SIZES FileSizes; CC_FILE_SIZES FileSizes;
if (ReadOffset + Length > Fcb->Entry.DataLengthL) if (ReadOffset + Length > Fcb->Entry.DataLengthL)
Length = Fcb->Entry.DataLengthL - ReadOffset; Length = Fcb->Entry.DataLengthL - ReadOffset;
if (FileObject->PrivateCacheMap == NULL) if (FileObject->PrivateCacheMap == NULL)
{ {
FileSizes.AllocationSize = Fcb->RFCB.AllocationSize; FileSizes.AllocationSize = Fcb->RFCB.AllocationSize;
FileSizes.FileSize = Fcb->RFCB.FileSize; FileSizes.FileSize = Fcb->RFCB.FileSize;
FileSizes.ValidDataLength = Fcb->RFCB.ValidDataLength; FileSizes.ValidDataLength = Fcb->RFCB.ValidDataLength;
DPRINT("Attach FCB to File: Size %08x%08x\n", DPRINT("Attach FCB to File: Size %08x%08x\n",
Fcb->RFCB.ValidDataLength.HighPart, Fcb->RFCB.ValidDataLength.HighPart,
Fcb->RFCB.ValidDataLength.LowPart); Fcb->RFCB.ValidDataLength.LowPart);
CcInitializeCacheMap(FileObject, CcInitializeCacheMap(FileObject,
&FileSizes, &FileSizes,
FALSE, FALSE,
&(CdfsGlobalData->CacheMgrCallbacks), &(CdfsGlobalData->CacheMgrCallbacks),
Fcb); Fcb);
} }
FileOffset.QuadPart = (LONGLONG)ReadOffset; FileOffset.QuadPart = (LONGLONG)ReadOffset;
CcCopyRead(FileObject, CcCopyRead(FileObject,
&FileOffset, &FileOffset,
Length, Length,
TRUE, TRUE,
Buffer, Buffer,
&IoStatus); &IoStatus);
*LengthRead = IoStatus.Information; *LengthRead = IoStatus.Information;
return(IoStatus.Status); return(IoStatus.Status);
} }
if ((ReadOffset % BLOCKSIZE) != 0 || (Length % BLOCKSIZE) != 0) if ((ReadOffset % BLOCKSIZE) != 0 || (Length % BLOCKSIZE) != 0)
{ {
/* Then we need to do a partial or misaligned read ... */ /* Then we need to do a partial or misaligned read ... */
PVOID PageBuf = ExAllocatePool(NonPagedPool, BLOCKSIZE); PVOID PageBuf = ExAllocatePool(NonPagedPool, BLOCKSIZE);
PCHAR ReadInPage = (PCHAR)PageBuf + (ReadOffset & (BLOCKSIZE - 1)); PCHAR ReadInPage = (PCHAR)PageBuf + (ReadOffset & (BLOCKSIZE - 1));
PCHAR TargetRead = (PCHAR)Buffer; PCHAR TargetRead = (PCHAR)Buffer;
ULONG ActualReadOffset, EndOfExtent, ReadLen; ULONG ActualReadOffset, EndOfExtent, ReadLen;
if (!PageBuf) if (!PageBuf)
{ {
return STATUS_NO_MEMORY; return STATUS_NO_MEMORY;
} }
ActualReadOffset = ReadOffset & ~(BLOCKSIZE - 1); ActualReadOffset = ReadOffset & ~(BLOCKSIZE - 1);
EndOfExtent = ReadOffset + Length; EndOfExtent = ReadOffset + Length;
while (ActualReadOffset < EndOfExtent) while (ActualReadOffset < EndOfExtent)
{ {
Status = CdfsReadSectors Status = CdfsReadSectors
(DeviceExt->StorageDevice, (DeviceExt->StorageDevice,
Fcb->Entry.ExtentLocationL + (ActualReadOffset / BLOCKSIZE), Fcb->Entry.ExtentLocationL + (ActualReadOffset / BLOCKSIZE),
1, 1,
PageBuf, PageBuf,
FALSE); FALSE);
if (!NT_SUCCESS(Status))
break;
ReadLen = BLOCKSIZE - (ActualReadOffset & (BLOCKSIZE - 1));
if (ReadLen > EndOfExtent - ActualReadOffset)
{
ReadLen = EndOfExtent - ActualReadOffset;
}
RtlCopyMemory(TargetRead, ReadInPage, ReadLen); if (!NT_SUCCESS(Status))
break;
ActualReadOffset += ReadLen; ReadLen = BLOCKSIZE - (ActualReadOffset & (BLOCKSIZE - 1));
TargetRead += ReadLen; if (ReadLen > EndOfExtent - ActualReadOffset)
} {
ReadLen = EndOfExtent - ActualReadOffset;
}
ExFreePool(PageBuf); RtlCopyMemory(TargetRead, ReadInPage, ReadLen);
ActualReadOffset += ReadLen;
TargetRead += ReadLen;
}
ExFreePool(PageBuf);
} }
else else
{ {
if (ReadOffset + Length > ROUND_UP(Fcb->Entry.DataLengthL, BLOCKSIZE)) if (ReadOffset + Length > ROUND_UP(Fcb->Entry.DataLengthL, BLOCKSIZE))
Length = ROUND_UP(Fcb->Entry.DataLengthL, BLOCKSIZE) - ReadOffset; Length = ROUND_UP(Fcb->Entry.DataLengthL, BLOCKSIZE) - ReadOffset;
Status = CdfsReadSectors(DeviceExt->StorageDevice, Status = CdfsReadSectors(DeviceExt->StorageDevice,
Fcb->Entry.ExtentLocationL + (ReadOffset / BLOCKSIZE), Fcb->Entry.ExtentLocationL + (ReadOffset / BLOCKSIZE),
Length / BLOCKSIZE, Length / BLOCKSIZE,
Buffer, Buffer,
FALSE); FALSE);
if (NT_SUCCESS(Status)) if (NT_SUCCESS(Status))
{ {
*LengthRead = Length; *LengthRead = Length;
if (Length + ReadOffset > Fcb->Entry.DataLengthL) if (Length + ReadOffset > Fcb->Entry.DataLengthL)
{ {
memset(Buffer + Fcb->Entry.DataLengthL - ReadOffset, memset(Buffer + Fcb->Entry.DataLengthL - ReadOffset,
0, 0,
Length + ReadOffset - Fcb->Entry.DataLengthL); Length + ReadOffset - Fcb->Entry.DataLengthL);
} }
} }
} }
return Status; return Status;
} }
NTSTATUS NTAPI NTSTATUS NTAPI
CdfsRead(PDEVICE_OBJECT DeviceObject, CdfsRead(PDEVICE_OBJECT DeviceObject,
PIRP Irp) PIRP Irp)
{ {
PDEVICE_EXTENSION DeviceExt; PDEVICE_EXTENSION DeviceExt;
PIO_STACK_LOCATION Stack; PIO_STACK_LOCATION Stack;
PFILE_OBJECT FileObject; PFILE_OBJECT FileObject;
PVOID Buffer = NULL; PVOID Buffer = NULL;
ULONG ReadLength; ULONG ReadLength;
LARGE_INTEGER ReadOffset; LARGE_INTEGER ReadOffset;
ULONG ReturnedReadLength = 0; ULONG ReturnedReadLength = 0;
NTSTATUS Status = STATUS_SUCCESS; NTSTATUS Status = STATUS_SUCCESS;
DPRINT("CdfsRead(DeviceObject %x, Irp %x)\n",DeviceObject,Irp); DPRINT("CdfsRead(DeviceObject %x, Irp %x)\n",DeviceObject,Irp);
DeviceExt = DeviceObject->DeviceExtension; DeviceExt = DeviceObject->DeviceExtension;
Stack = IoGetCurrentIrpStackLocation(Irp); Stack = IoGetCurrentIrpStackLocation(Irp);
FileObject = Stack->FileObject; FileObject = Stack->FileObject;
ReadLength = Stack->Parameters.Read.Length; ReadLength = Stack->Parameters.Read.Length;
ReadOffset = Stack->Parameters.Read.ByteOffset; ReadOffset = Stack->Parameters.Read.ByteOffset;
if (ReadLength) Buffer = MmGetSystemAddressForMdl(Irp->MdlAddress); if (ReadLength) Buffer = MmGetSystemAddressForMdl(Irp->MdlAddress);
Status = CdfsReadFile(DeviceExt, Status = CdfsReadFile(DeviceExt,
FileObject, FileObject,
Buffer, Buffer,
ReadLength, ReadLength,
ReadOffset.u.LowPart, ReadOffset.u.LowPart,
Irp->Flags, Irp->Flags,
&ReturnedReadLength); &ReturnedReadLength);
if (NT_SUCCESS(Status)) if (NT_SUCCESS(Status))
{ {
if (FileObject->Flags & FO_SYNCHRONOUS_IO) if (FileObject->Flags & FO_SYNCHRONOUS_IO)
{ {
FileObject->CurrentByteOffset.QuadPart = FileObject->CurrentByteOffset.QuadPart =
ReadOffset.QuadPart + ReturnedReadLength; ReadOffset.QuadPart + ReturnedReadLength;
} }
Irp->IoStatus.Information = ReturnedReadLength; Irp->IoStatus.Information = ReturnedReadLength;
} }
else else
{ {
Irp->IoStatus.Information = 0; Irp->IoStatus.Information = 0;
} }
Irp->IoStatus.Status = Status; Irp->IoStatus.Status = Status;
IoCompleteRequest(Irp,IO_NO_INCREMENT); IoCompleteRequest(Irp,IO_NO_INCREMENT);
return(Status); return(Status);
} }
NTSTATUS NTAPI NTSTATUS NTAPI
CdfsWrite(PDEVICE_OBJECT DeviceObject, CdfsWrite(PDEVICE_OBJECT DeviceObject,
PIRP Irp) PIRP Irp)
{ {
DPRINT("CdfsWrite(DeviceObject %x Irp %x)\n",DeviceObject,Irp); DPRINT("CdfsWrite(DeviceObject %x Irp %x)\n",DeviceObject,Irp);
Irp->IoStatus.Status = STATUS_NOT_SUPPORTED; Irp->IoStatus.Status = STATUS_NOT_SUPPORTED;
Irp->IoStatus.Information = 0; Irp->IoStatus.Information = 0;
return(STATUS_NOT_SUPPORTED); return(STATUS_NOT_SUPPORTED);
} }
/* EOF */ /* EOF */

View file

@ -1,30 +1,30 @@
/* /*
* ReactOS kernel * ReactOS kernel
* Copyright (C) 2002, 2003 ReactOS Team * Copyright (C) 2002, 2003 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
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* 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$ /* $Id$
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
* FILE: services/fs/vfat/volume.c * FILE: services/fs/vfat/volume.c
* PURPOSE: CDROM (ISO 9660) filesystem driver * PURPOSE: CDROM (ISO 9660) filesystem driver
* PROGRAMMER: Art Yerkes * PROGRAMMER: Art Yerkes
* Eric Kohl * Eric Kohl
*/ */
/* INCLUDES *****************************************************************/ /* INCLUDES *****************************************************************/
@ -37,203 +37,203 @@
static NTSTATUS static NTSTATUS
CdfsGetFsVolumeInformation(PDEVICE_OBJECT DeviceObject, CdfsGetFsVolumeInformation(PDEVICE_OBJECT DeviceObject,
PFILE_FS_VOLUME_INFORMATION FsVolumeInfo, PFILE_FS_VOLUME_INFORMATION FsVolumeInfo,
PULONG BufferLength) PULONG BufferLength)
{ {
DPRINT("CdfsGetFsVolumeInformation() called\n"); DPRINT("CdfsGetFsVolumeInformation() called\n");
DPRINT("FsVolumeInfo = %p\n", FsVolumeInfo); DPRINT("FsVolumeInfo = %p\n", FsVolumeInfo);
DPRINT("BufferLength %lu\n", *BufferLength); DPRINT("BufferLength %lu\n", *BufferLength);
DPRINT("Vpb %p\n", DeviceObject->Vpb); DPRINT("Vpb %p\n", DeviceObject->Vpb);
DPRINT("Required length %lu\n", (sizeof(FILE_FS_VOLUME_INFORMATION) + DeviceObject->Vpb->VolumeLabelLength)); DPRINT("Required length %lu\n", (sizeof(FILE_FS_VOLUME_INFORMATION) + DeviceObject->Vpb->VolumeLabelLength));
DPRINT("LabelLength %hu\n", DeviceObject->Vpb->VolumeLabelLength); DPRINT("LabelLength %hu\n", DeviceObject->Vpb->VolumeLabelLength);
DPRINT("Label %*.S\n", DeviceObject->Vpb->VolumeLabelLength / sizeof(WCHAR), DeviceObject->Vpb->VolumeLabel); DPRINT("Label %*.S\n", DeviceObject->Vpb->VolumeLabelLength / sizeof(WCHAR), DeviceObject->Vpb->VolumeLabel);
if (*BufferLength < sizeof(FILE_FS_VOLUME_INFORMATION)) if (*BufferLength < sizeof(FILE_FS_VOLUME_INFORMATION))
return STATUS_INFO_LENGTH_MISMATCH; return STATUS_INFO_LENGTH_MISMATCH;
if (*BufferLength < (sizeof(FILE_FS_VOLUME_INFORMATION) + DeviceObject->Vpb->VolumeLabelLength)) if (*BufferLength < (sizeof(FILE_FS_VOLUME_INFORMATION) + DeviceObject->Vpb->VolumeLabelLength))
return STATUS_BUFFER_OVERFLOW; return STATUS_BUFFER_OVERFLOW;
/* valid entries */ /* valid entries */
FsVolumeInfo->VolumeSerialNumber = DeviceObject->Vpb->SerialNumber; FsVolumeInfo->VolumeSerialNumber = DeviceObject->Vpb->SerialNumber;
FsVolumeInfo->VolumeLabelLength = DeviceObject->Vpb->VolumeLabelLength; FsVolumeInfo->VolumeLabelLength = DeviceObject->Vpb->VolumeLabelLength;
memcpy(FsVolumeInfo->VolumeLabel, memcpy(FsVolumeInfo->VolumeLabel,
DeviceObject->Vpb->VolumeLabel, DeviceObject->Vpb->VolumeLabel,
DeviceObject->Vpb->VolumeLabelLength); DeviceObject->Vpb->VolumeLabelLength);
/* dummy entries */ /* dummy entries */
FsVolumeInfo->VolumeCreationTime.QuadPart = 0; FsVolumeInfo->VolumeCreationTime.QuadPart = 0;
FsVolumeInfo->SupportsObjects = FALSE; FsVolumeInfo->SupportsObjects = FALSE;
DPRINT("Finished FsdGetFsVolumeInformation()\n"); DPRINT("Finished FsdGetFsVolumeInformation()\n");
*BufferLength -= (sizeof(FILE_FS_VOLUME_INFORMATION) + DeviceObject->Vpb->VolumeLabelLength); *BufferLength -= (sizeof(FILE_FS_VOLUME_INFORMATION) + DeviceObject->Vpb->VolumeLabelLength);
DPRINT("BufferLength %lu\n", *BufferLength); DPRINT("BufferLength %lu\n", *BufferLength);
return(STATUS_SUCCESS); return(STATUS_SUCCESS);
} }
static NTSTATUS static NTSTATUS
CdfsGetFsAttributeInformation(PDEVICE_EXTENSION DeviceExt, CdfsGetFsAttributeInformation(PDEVICE_EXTENSION DeviceExt,
PFILE_FS_ATTRIBUTE_INFORMATION FsAttributeInfo, PFILE_FS_ATTRIBUTE_INFORMATION FsAttributeInfo,
PULONG BufferLength) PULONG BufferLength)
{ {
DPRINT("CdfsGetFsAttributeInformation()\n"); DPRINT("CdfsGetFsAttributeInformation()\n");
DPRINT("FsAttributeInfo = %p\n", FsAttributeInfo); DPRINT("FsAttributeInfo = %p\n", FsAttributeInfo);
DPRINT("BufferLength %lu\n", *BufferLength); DPRINT("BufferLength %lu\n", *BufferLength);
DPRINT("Required length %lu\n", (sizeof(FILE_FS_ATTRIBUTE_INFORMATION) + 8)); DPRINT("Required length %lu\n", (sizeof(FILE_FS_ATTRIBUTE_INFORMATION) + 8));
if (*BufferLength < sizeof (FILE_FS_ATTRIBUTE_INFORMATION)) if (*BufferLength < sizeof (FILE_FS_ATTRIBUTE_INFORMATION))
return STATUS_INFO_LENGTH_MISMATCH; return STATUS_INFO_LENGTH_MISMATCH;
if (*BufferLength < (sizeof(FILE_FS_ATTRIBUTE_INFORMATION) + 8)) if (*BufferLength < (sizeof(FILE_FS_ATTRIBUTE_INFORMATION) + 8))
return STATUS_BUFFER_OVERFLOW; return STATUS_BUFFER_OVERFLOW;
FsAttributeInfo->FileSystemAttributes = FsAttributeInfo->FileSystemAttributes =
FILE_CASE_PRESERVED_NAMES | FILE_UNICODE_ON_DISK; FILE_CASE_PRESERVED_NAMES | FILE_UNICODE_ON_DISK;
FsAttributeInfo->MaximumComponentNameLength = 255; FsAttributeInfo->MaximumComponentNameLength = 255;
FsAttributeInfo->FileSystemNameLength = 8; FsAttributeInfo->FileSystemNameLength = 8;
memcpy(FsAttributeInfo->FileSystemName, L"CDFS", 8); memcpy(FsAttributeInfo->FileSystemName, L"CDFS", 8);
DPRINT("Finished FsdGetFsAttributeInformation()\n"); DPRINT("Finished FsdGetFsAttributeInformation()\n");
*BufferLength -= (sizeof(FILE_FS_ATTRIBUTE_INFORMATION) + 8); *BufferLength -= (sizeof(FILE_FS_ATTRIBUTE_INFORMATION) + 8);
DPRINT("BufferLength %lu\n", *BufferLength); DPRINT("BufferLength %lu\n", *BufferLength);
return(STATUS_SUCCESS); return(STATUS_SUCCESS);
} }
static NTSTATUS static NTSTATUS
CdfsGetFsSizeInformation(PDEVICE_OBJECT DeviceObject, CdfsGetFsSizeInformation(PDEVICE_OBJECT DeviceObject,
PFILE_FS_SIZE_INFORMATION FsSizeInfo, PFILE_FS_SIZE_INFORMATION FsSizeInfo,
PULONG BufferLength) PULONG BufferLength)
{ {
PDEVICE_EXTENSION DeviceExt; PDEVICE_EXTENSION DeviceExt;
NTSTATUS Status = STATUS_SUCCESS; NTSTATUS Status = STATUS_SUCCESS;
DPRINT("CdfsGetFsSizeInformation()\n"); DPRINT("CdfsGetFsSizeInformation()\n");
DPRINT("FsSizeInfo = %p\n", FsSizeInfo); DPRINT("FsSizeInfo = %p\n", FsSizeInfo);
if (*BufferLength < sizeof(FILE_FS_SIZE_INFORMATION)) if (*BufferLength < sizeof(FILE_FS_SIZE_INFORMATION))
return(STATUS_BUFFER_OVERFLOW); return(STATUS_BUFFER_OVERFLOW);
DeviceExt = DeviceObject->DeviceExtension; DeviceExt = DeviceObject->DeviceExtension;
FsSizeInfo->AvailableAllocationUnits.QuadPart = 0; FsSizeInfo->AvailableAllocationUnits.QuadPart = 0;
FsSizeInfo->TotalAllocationUnits.QuadPart = DeviceExt->CdInfo.VolumeSpaceSize; FsSizeInfo->TotalAllocationUnits.QuadPart = DeviceExt->CdInfo.VolumeSpaceSize;
FsSizeInfo->SectorsPerAllocationUnit = 1; FsSizeInfo->SectorsPerAllocationUnit = 1;
FsSizeInfo->BytesPerSector = BLOCKSIZE; FsSizeInfo->BytesPerSector = BLOCKSIZE;
DPRINT("Finished FsdGetFsSizeInformation()\n"); DPRINT("Finished FsdGetFsSizeInformation()\n");
if (NT_SUCCESS(Status)) if (NT_SUCCESS(Status))
*BufferLength -= sizeof(FILE_FS_SIZE_INFORMATION); *BufferLength -= sizeof(FILE_FS_SIZE_INFORMATION);
return(Status); return(Status);
} }
static NTSTATUS static NTSTATUS
CdfsGetFsDeviceInformation(PFILE_FS_DEVICE_INFORMATION FsDeviceInfo, CdfsGetFsDeviceInformation(PFILE_FS_DEVICE_INFORMATION FsDeviceInfo,
PULONG BufferLength) PULONG BufferLength)
{ {
DPRINT("CdfsGetFsDeviceInformation()\n"); DPRINT("CdfsGetFsDeviceInformation()\n");
DPRINT("FsDeviceInfo = %p\n", FsDeviceInfo); DPRINT("FsDeviceInfo = %p\n", FsDeviceInfo);
DPRINT("BufferLength %lu\n", *BufferLength); DPRINT("BufferLength %lu\n", *BufferLength);
DPRINT("Required length %lu\n", sizeof(FILE_FS_DEVICE_INFORMATION)); DPRINT("Required length %lu\n", sizeof(FILE_FS_DEVICE_INFORMATION));
if (*BufferLength < sizeof(FILE_FS_DEVICE_INFORMATION)) if (*BufferLength < sizeof(FILE_FS_DEVICE_INFORMATION))
return(STATUS_BUFFER_OVERFLOW); return(STATUS_BUFFER_OVERFLOW);
FsDeviceInfo->DeviceType = FILE_DEVICE_CD_ROM; FsDeviceInfo->DeviceType = FILE_DEVICE_CD_ROM;
FsDeviceInfo->Characteristics = 0; /* FIXME: fix this !! */ FsDeviceInfo->Characteristics = 0; /* FIXME: fix this !! */
DPRINT("FsdGetFsDeviceInformation() finished.\n"); DPRINT("FsdGetFsDeviceInformation() finished.\n");
*BufferLength -= sizeof(FILE_FS_DEVICE_INFORMATION); *BufferLength -= sizeof(FILE_FS_DEVICE_INFORMATION);
DPRINT("BufferLength %lu\n", *BufferLength); DPRINT("BufferLength %lu\n", *BufferLength);
return(STATUS_SUCCESS); return(STATUS_SUCCESS);
} }
NTSTATUS NTAPI NTSTATUS NTAPI
CdfsQueryVolumeInformation(PDEVICE_OBJECT DeviceObject, CdfsQueryVolumeInformation(PDEVICE_OBJECT DeviceObject,
PIRP Irp) PIRP Irp)
{ {
FS_INFORMATION_CLASS FsInformationClass; FS_INFORMATION_CLASS FsInformationClass;
PIO_STACK_LOCATION Stack; PIO_STACK_LOCATION Stack;
NTSTATUS Status = STATUS_SUCCESS; NTSTATUS Status = STATUS_SUCCESS;
PVOID SystemBuffer; PVOID SystemBuffer;
ULONG BufferLength; ULONG BufferLength;
DPRINT("CdfsQueryVolumeInformation() called\n"); DPRINT("CdfsQueryVolumeInformation() called\n");
Stack = IoGetCurrentIrpStackLocation(Irp); Stack = IoGetCurrentIrpStackLocation(Irp);
FsInformationClass = Stack->Parameters.QueryVolume.FsInformationClass; FsInformationClass = Stack->Parameters.QueryVolume.FsInformationClass;
BufferLength = Stack->Parameters.QueryVolume.Length; BufferLength = Stack->Parameters.QueryVolume.Length;
SystemBuffer = Irp->AssociatedIrp.SystemBuffer; SystemBuffer = Irp->AssociatedIrp.SystemBuffer;
DPRINT("FsInformationClass %d\n", FsInformationClass); DPRINT("FsInformationClass %d\n", FsInformationClass);
DPRINT("SystemBuffer %x\n", SystemBuffer); DPRINT("SystemBuffer %x\n", SystemBuffer);
switch (FsInformationClass) switch (FsInformationClass)
{ {
case FileFsVolumeInformation: case FileFsVolumeInformation:
Status = CdfsGetFsVolumeInformation(DeviceObject, Status = CdfsGetFsVolumeInformation(DeviceObject,
SystemBuffer, SystemBuffer,
&BufferLength); &BufferLength);
break; break;
case FileFsAttributeInformation: case FileFsAttributeInformation:
Status = CdfsGetFsAttributeInformation(DeviceObject->DeviceExtension, Status = CdfsGetFsAttributeInformation(DeviceObject->DeviceExtension,
SystemBuffer, SystemBuffer,
&BufferLength); &BufferLength);
break; break;
case FileFsSizeInformation: case FileFsSizeInformation:
Status = CdfsGetFsSizeInformation(DeviceObject, Status = CdfsGetFsSizeInformation(DeviceObject,
SystemBuffer, SystemBuffer,
&BufferLength); &BufferLength);
break; break;
case FileFsDeviceInformation: case FileFsDeviceInformation:
Status = CdfsGetFsDeviceInformation(SystemBuffer, Status = CdfsGetFsDeviceInformation(SystemBuffer,
&BufferLength); &BufferLength);
break; break;
default: default:
Status = STATUS_NOT_SUPPORTED; Status = STATUS_NOT_SUPPORTED;
} }
Irp->IoStatus.Status = Status; Irp->IoStatus.Status = Status;
if (NT_SUCCESS(Status)) if (NT_SUCCESS(Status))
Irp->IoStatus.Information = Irp->IoStatus.Information =
Stack->Parameters.QueryVolume.Length - BufferLength; Stack->Parameters.QueryVolume.Length - BufferLength;
else else
Irp->IoStatus.Information = 0; Irp->IoStatus.Information = 0;
IoCompleteRequest(Irp, IO_NO_INCREMENT); IoCompleteRequest(Irp, IO_NO_INCREMENT);
return(Status); return(Status);
} }
NTSTATUS NTAPI NTSTATUS NTAPI
CdfsSetVolumeInformation(PDEVICE_OBJECT DeviceObject, CdfsSetVolumeInformation(PDEVICE_OBJECT DeviceObject,
PIRP Irp) PIRP Irp)
{ {
DPRINT("CdfsSetVolumeInformation() called\n"); DPRINT("CdfsSetVolumeInformation() called\n");
Irp->IoStatus.Status = STATUS_NOT_SUPPORTED; Irp->IoStatus.Status = STATUS_NOT_SUPPORTED;
Irp->IoStatus.Information = 0; Irp->IoStatus.Information = 0;
IoCompleteRequest(Irp, IO_NO_INCREMENT); IoCompleteRequest(Irp, IO_NO_INCREMENT);
return(STATUS_NOT_SUPPORTED); return(STATUS_NOT_SUPPORTED);
} }
/* EOF */ /* EOF */