mirror of
https://github.com/reactos/reactos.git
synced 2024-06-30 09:50:07 +00:00
Fixed typos
Added more safety checks Minor cleanup svn path=/trunk/; revision=1662
This commit is contained in:
parent
de10767975
commit
2d5f3d1c74
|
@ -37,7 +37,7 @@ VfatReadSectors (IN PDEVICE_OBJECT pDeviceObject,
|
|||
KeInitializeEvent (&event, NotificationEvent, FALSE);
|
||||
sectorSize = BLOCKSIZE * SectorCount;
|
||||
|
||||
DPRINT ("VFATReadSector(pDeviceObject %x, DiskSector %d, Buffer %x)\n",
|
||||
DPRINT ("VfatReadSectors(pDeviceObject %x, DiskSector %d, Buffer %x)\n",
|
||||
pDeviceObject, DiskSector, Buffer);
|
||||
DPRINT ("sectorNumber %08lx:%08lx sectorSize %ld\n",
|
||||
(unsigned long int) sectorNumber.u.LowPart,
|
||||
|
@ -56,7 +56,7 @@ VfatReadSectors (IN PDEVICE_OBJECT pDeviceObject,
|
|||
if (Irp == NULL)
|
||||
{
|
||||
DPRINT("IoBuildSynchronousFsdRequest failed\n");
|
||||
return(STATUS_UNSUCCESSFUL);;
|
||||
return(STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
|
||||
DPRINT ("Calling IO Driver... with irp %x\n", Irp);
|
||||
|
@ -73,7 +73,7 @@ VfatReadSectors (IN PDEVICE_OBJECT pDeviceObject,
|
|||
|
||||
if (!NT_SUCCESS (Status))
|
||||
{
|
||||
DPRINT ("IO failed!!! VFATREadSectors : Error code: %x\n", Status);
|
||||
DPRINT ("IO failed!!! VfatReadSectors : Error code: %x\n", Status);
|
||||
DPRINT ("(pDeviceObject %x, DiskSector %x, Buffer %x, offset 0x%x%x)\n",
|
||||
pDeviceObject, DiskSector, Buffer, sectorNumber.u.HighPart,
|
||||
sectorNumber.u.LowPart);
|
||||
|
@ -96,7 +96,7 @@ VfatWriteSectors (IN PDEVICE_OBJECT pDeviceObject,
|
|||
NTSTATUS Status;
|
||||
ULONG sectorSize;
|
||||
|
||||
DPRINT ("VFATWriteSector(pDeviceObject %x, DiskSector %d, Buffer %x)\n",
|
||||
DPRINT ("VfatWriteSectors(pDeviceObject %x, DiskSector %d, Buffer %x)\n",
|
||||
pDeviceObject, DiskSector, Buffer);
|
||||
|
||||
sectorNumber.u.LowPart = DiskSector << 9;
|
||||
|
@ -134,7 +134,7 @@ VfatWriteSectors (IN PDEVICE_OBJECT pDeviceObject,
|
|||
|
||||
if (!NT_SUCCESS (Status))
|
||||
{
|
||||
DPRINT1 ("IO failed!!! VFATWriteSectors : Error code: %x\n", Status);
|
||||
DPRINT1 ("IO failed!!! VfatWriteSectors : Error code: %x\n", Status);
|
||||
return (Status);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: iface.c,v 1.49 2001/01/16 09:55:02 dwelch Exp $
|
||||
/* $Id: iface.c,v 1.50 2001/03/06 08:19:58 ekohl Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -27,7 +27,6 @@
|
|||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <ddk/ntddk.h>
|
||||
#include <wchar.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
@ -40,44 +39,61 @@ static PDRIVER_OBJECT VfatDriverObject;
|
|||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
BOOLEAN
|
||||
VfatHasFileSystem (PDEVICE_OBJECT DeviceToMount)
|
||||
static NTSTATUS
|
||||
VfatHasFileSystem(PDEVICE_OBJECT DeviceToMount,
|
||||
PBOOLEAN RecognizedFS)
|
||||
/*
|
||||
* FUNCTION: Tests if the device contains a filesystem that can be mounted
|
||||
* by this fsd
|
||||
*/
|
||||
{
|
||||
BootSector *Boot;
|
||||
NTSTATUS Status;
|
||||
|
||||
Boot = ExAllocatePool(NonPagedPool, 512);
|
||||
|
||||
/* FIXME: Check status */
|
||||
VfatReadSectors (DeviceToMount, 0, 1, (UCHAR *) Boot);
|
||||
Status = VfatReadSectors(DeviceToMount, 0, 1, (UCHAR *) Boot);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
return Status;
|
||||
}
|
||||
|
||||
DPRINT("Boot->SysType %.5s\n", Boot->SysType);
|
||||
if (strncmp(Boot->SysType, "FAT12", 5) == 0 ||
|
||||
strncmp(Boot->SysType, "FAT16", 5) == 0 ||
|
||||
strncmp(((struct _BootSector32 *) (Boot))->SysType, "FAT32", 5) == 0)
|
||||
{
|
||||
ExFreePool (Boot);
|
||||
return (TRUE);
|
||||
*RecognizedFS = TRUE;
|
||||
}
|
||||
ExFreePool (Boot);
|
||||
return (FALSE);
|
||||
else
|
||||
{
|
||||
*RecognizedFS = FALSE;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
ExFreePool(Boot);
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static NTSTATUS
|
||||
VfatMountDevice (PDEVICE_EXTENSION DeviceExt, PDEVICE_OBJECT DeviceToMount)
|
||||
/*
|
||||
* FUNCTION: Mounts the device
|
||||
*/
|
||||
{
|
||||
NTSTATUS Status;
|
||||
|
||||
DPRINT("Mounting VFAT device...");
|
||||
DPRINT("DeviceExt %x\n", DeviceExt);
|
||||
|
||||
DeviceExt->Boot = ExAllocatePool(NonPagedPool, 512);
|
||||
/* FIXME: Check status */
|
||||
VfatReadSectors (DeviceToMount, 0, 1, (UCHAR *) DeviceExt->Boot);
|
||||
|
||||
Status = VfatReadSectors(DeviceToMount, 0, 1, (UCHAR *) DeviceExt->Boot);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
return Status;
|
||||
}
|
||||
|
||||
DeviceExt->FATStart = DeviceExt->Boot->ReservedSectors;
|
||||
DeviceExt->rootDirectorySectors =
|
||||
|
@ -109,8 +125,7 @@ VfatMountDevice (PDEVICE_EXTENSION DeviceExt, PDEVICE_OBJECT DeviceToMount)
|
|||
DbgPrint("FAT12\n");
|
||||
DeviceExt->FatType = FAT12;
|
||||
}
|
||||
else
|
||||
if (strncmp
|
||||
else if (strncmp
|
||||
(((struct _BootSector32 *) (DeviceExt->Boot))->SysType, "FAT32",
|
||||
5) == 0)
|
||||
{
|
||||
|
@ -131,7 +146,8 @@ VfatMountDevice (PDEVICE_EXTENSION DeviceExt, PDEVICE_OBJECT DeviceToMount)
|
|||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
|
||||
static NTSTATUS
|
||||
VfatMount (PDEVICE_OBJECT DeviceToMount)
|
||||
/*
|
||||
* FUNCTION: Mount the filesystem
|
||||
|
@ -139,24 +155,60 @@ VfatMount (PDEVICE_OBJECT DeviceToMount)
|
|||
{
|
||||
PDEVICE_OBJECT DeviceObject;
|
||||
PDEVICE_EXTENSION DeviceExt;
|
||||
BOOLEAN RecognizedFS;
|
||||
NTSTATUS Status;
|
||||
|
||||
IoCreateDevice (VfatDriverObject,
|
||||
Status = VfatHasFileSystem (DeviceToMount, &RecognizedFS);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
return Status;
|
||||
}
|
||||
|
||||
if (RecognizedFS == FALSE)
|
||||
{
|
||||
DPRINT("VFAT: Unrecognized Volume\n");
|
||||
return STATUS_UNRECOGNIZED_VOLUME;
|
||||
}
|
||||
|
||||
DPRINT("VFAT: Recognized volume\n");
|
||||
|
||||
Status = IoCreateDevice(VfatDriverObject,
|
||||
sizeof (DEVICE_EXTENSION),
|
||||
NULL, FILE_DEVICE_FILE_SYSTEM, 0, FALSE, &DeviceObject);
|
||||
NULL,
|
||||
FILE_DEVICE_FILE_SYSTEM,
|
||||
0,
|
||||
FALSE,
|
||||
&DeviceObject);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
return Status;
|
||||
}
|
||||
|
||||
DeviceObject->Flags = DeviceObject->Flags | DO_DIRECT_IO;
|
||||
DeviceExt = (PVOID) DeviceObject->DeviceExtension;
|
||||
// use same vpb as device disk
|
||||
/* use same vpb as device disk */
|
||||
DeviceObject->Vpb = DeviceToMount->Vpb;
|
||||
VfatMountDevice (DeviceExt, DeviceToMount);
|
||||
Status = VfatMountDevice (DeviceExt, DeviceToMount);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
/* FIXME: delete device object */
|
||||
return Status;
|
||||
}
|
||||
|
||||
DeviceObject->Vpb->Flags |= VPB_MOUNTED;
|
||||
DeviceExt->StorageDevice = IoAttachDeviceToDeviceStack(DeviceObject,
|
||||
DeviceToMount);
|
||||
DeviceExt->StreamStorageDevice =
|
||||
IoCreateStreamFileObject(NULL, DeviceExt->StorageDevice);
|
||||
DeviceExt->StreamStorageDevice = IoCreateStreamFileObject(NULL,
|
||||
DeviceExt->StorageDevice);
|
||||
Status = CcInitializeFileCache(DeviceExt->StreamStorageDevice,
|
||||
&DeviceExt->StorageBcb,
|
||||
PAGESIZE);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
/* FIXME: delete device object */
|
||||
return Status;
|
||||
}
|
||||
|
||||
if (DeviceExt->FatType == FAT12)
|
||||
{
|
||||
DeviceExt->Fat12StorageDevice =
|
||||
|
@ -164,6 +216,11 @@ VfatMount (PDEVICE_OBJECT DeviceToMount)
|
|||
Status = CcInitializeFileCache(DeviceExt->Fat12StorageDevice,
|
||||
&DeviceExt->Fat12StorageBcb,
|
||||
PAGESIZE * 3);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
/* FIXME: delete device object */
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
ExInitializeResourceLite (&DeviceExt->DirResource);
|
||||
ExInitializeResourceLite (&DeviceExt->FatResource);
|
||||
|
@ -182,9 +239,10 @@ VfatMount (PDEVICE_OBJECT DeviceToMount)
|
|||
/* read volume label */
|
||||
ReadVolumeLabel(DeviceExt, DeviceObject->Vpb);
|
||||
|
||||
return (STATUS_SUCCESS);
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS STDCALL
|
||||
VfatFileSystemControl (PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||
/*
|
||||
|
@ -192,24 +250,28 @@ VfatFileSystemControl (PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
|||
*/
|
||||
{
|
||||
PIO_STACK_LOCATION Stack = IoGetCurrentIrpStackLocation (Irp);
|
||||
// PVPB vpb = Stack->Parameters.Mount.Vpb;
|
||||
PDEVICE_OBJECT DeviceToMount = Stack->Parameters.Mount.DeviceObject;
|
||||
NTSTATUS Status;
|
||||
|
||||
// DPRINT("VFAT FSC\n");
|
||||
DbgPrint ("VFAT FSC\n");
|
||||
|
||||
/* FIXME: should make sure that this is actually a mount request! */
|
||||
|
||||
if (VfatHasFileSystem (DeviceToMount))
|
||||
switch (Stack->MinorFunction)
|
||||
{
|
||||
DPRINT ("VFAT: Recognized volume\n");
|
||||
Status = VfatMount (DeviceToMount);
|
||||
}
|
||||
else
|
||||
{
|
||||
DPRINT ("VFAT: Unrecognized Volume\n");
|
||||
Status = STATUS_UNRECOGNIZED_VOLUME;
|
||||
case IRP_MN_USER_FS_REQUEST:
|
||||
DPRINT1("VFAT FSC: IRP_MN_USER_FS_REQUEST\n");
|
||||
Status = STATUS_INVALID_DEVICE_REQUEST;
|
||||
break;
|
||||
|
||||
case IRP_MN_MOUNT_VOLUME:
|
||||
Status = VfatMount(Stack->Parameters.Mount.DeviceObject);
|
||||
break;
|
||||
|
||||
case IRP_MN_VERIFY_VOLUME:
|
||||
DPRINT1("VFAT FSC: IRP_MN_VERIFY_VOLUME\n");
|
||||
Status = STATUS_INVALID_DEVICE_REQUEST;
|
||||
break;
|
||||
|
||||
default:
|
||||
DPRINT1("VFAT FSC: MinorFunction %d\n", Stack->MinorFunction);
|
||||
Status = STATUS_INVALID_DEVICE_REQUEST;
|
||||
break;
|
||||
}
|
||||
|
||||
Irp->IoStatus.Status = Status;
|
||||
|
@ -219,6 +281,7 @@ VfatFileSystemControl (PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
|||
return (Status);
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS STDCALL
|
||||
DriverEntry (PDRIVER_OBJECT _DriverObject, PUNICODE_STRING RegistryPath)
|
||||
/*
|
||||
|
@ -230,19 +293,25 @@ DriverEntry (PDRIVER_OBJECT _DriverObject, PUNICODE_STRING RegistryPath)
|
|||
*/
|
||||
{
|
||||
PDEVICE_OBJECT DeviceObject;
|
||||
NTSTATUS ret;
|
||||
UNICODE_STRING DeviceName;
|
||||
NTSTATUS Status;
|
||||
|
||||
DbgPrint("VFAT 0.0.6\n");
|
||||
|
||||
VfatDriverObject = _DriverObject;
|
||||
|
||||
RtlInitUnicodeString (&DeviceName, L"\\Device\\Vfat");
|
||||
ret = IoCreateDevice (VfatDriverObject, 0, &DeviceName,
|
||||
FILE_DEVICE_FILE_SYSTEM, 0, FALSE, &DeviceObject);
|
||||
if (ret != STATUS_SUCCESS)
|
||||
RtlInitUnicodeString(&DeviceName,
|
||||
L"\\Device\\Vfat");
|
||||
Status = IoCreateDevice(VfatDriverObject,
|
||||
0,
|
||||
&DeviceName,
|
||||
FILE_DEVICE_FILE_SYSTEM,
|
||||
0,
|
||||
FALSE,
|
||||
&DeviceObject);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
return (ret);
|
||||
return (Status);
|
||||
}
|
||||
|
||||
DeviceObject->Flags = DO_DIRECT_IO;
|
||||
|
@ -266,5 +335,7 @@ DriverEntry (PDRIVER_OBJECT _DriverObject, PUNICODE_STRING RegistryPath)
|
|||
|
||||
IoRegisterFileSystem(DeviceObject);
|
||||
|
||||
return (STATUS_SUCCESS);
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
|
Loading…
Reference in a new issue