mirror of
https://github.com/reactos/reactos.git
synced 2024-09-28 05:26:58 +00:00
Added removable mediachange support.
svn path=/trunk/; revision=8930
This commit is contained in:
parent
942d7e47a7
commit
3b1c2903f6
|
@ -161,7 +161,7 @@ VfatWriteDisk (IN PDEVICE_OBJECT pDeviceObject,
|
|||
|
||||
if (!NT_SUCCESS (Status))
|
||||
{
|
||||
DPRINT1 ("IO failed!!! VfatWriteSectors : Error code: %x\n", Status);
|
||||
DPRINT ("IO failed!!! VfatWriteSectors : Error code: %x\n", Status);
|
||||
return (Status);
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
/* $Id: create.c,v 1.66 2004/01/18 22:31:23 hbirr Exp $
|
||||
/* $Id: create.c,v 1.67 2004/03/31 03:30:36 jimtabor Exp $
|
||||
*
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: drivers/fs/vfat/create.c
|
||||
|
@ -338,10 +338,14 @@ VfatOpenFile (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
|
|||
{
|
||||
PVFATFCB ParentFcb;
|
||||
PVFATFCB Fcb;
|
||||
DISK_GEOMETRY DiskGeometry;
|
||||
NTSTATUS Status;
|
||||
UNICODE_STRING NameU;
|
||||
WCHAR Name[MAX_PATH];
|
||||
ULONG Size;
|
||||
|
||||
// PDEVICE_OBJECT DeviceObject = DeviceExt->StorageDevice->Vpb->DeviceObject;
|
||||
|
||||
DPRINT ("VfatOpenFile(%08lx, %08lx, '%wZ')\n", DeviceExt, FileObject, FileNameU);
|
||||
|
||||
if (FileObject->RelatedFileObject)
|
||||
|
@ -366,6 +370,53 @@ VfatOpenFile (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
|
|||
|
||||
DPRINT ("PathName to open: '%wZ'\n", FileNameU);
|
||||
|
||||
Size = sizeof(DISK_GEOMETRY);
|
||||
Status = VfatBlockDeviceIoControl(DeviceExt->StorageDevice,
|
||||
IOCTL_DISK_GET_DRIVE_GEOMETRY,
|
||||
NULL,
|
||||
0,
|
||||
&DiskGeometry,
|
||||
&Size,
|
||||
FALSE);
|
||||
|
||||
if (DiskGeometry.MediaType != FixedMedia )
|
||||
{
|
||||
|
||||
Status = VfatBlockDeviceIoControl (DeviceExt->StorageDevice,
|
||||
IOCTL_DISK_CHECK_VERIFY,
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
0,
|
||||
TRUE);
|
||||
|
||||
if (Status == STATUS_VERIFY_REQUIRED)
|
||||
{
|
||||
PDEVICE_OBJECT DeviceToVerify;
|
||||
|
||||
DPRINT ("Media change detected!\n");
|
||||
DPRINT ("Device %p\n", DeviceObject);
|
||||
|
||||
DeviceToVerify = IoGetDeviceToVerify (PsGetCurrentThread ());
|
||||
IoSetDeviceToVerify (PsGetCurrentThread (),
|
||||
NULL);
|
||||
|
||||
Status = IoVerifyVolume (DeviceToVerify,
|
||||
FALSE);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT ("Status %lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
else if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT ("Status %lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* try first to find an existing FCB in memory */
|
||||
DPRINT ("Checking for existing FCB in memory\n");
|
||||
Fcb = vfatGrabFCBFromTable (DeviceExt, FileNameU);
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
/* $Id: fsctl.c,v 1.28 2004/03/16 08:30:28 arty Exp $
|
||||
/* $Id: fsctl.c,v 1.29 2004/03/31 03:30:36 jimtabor Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -66,12 +66,15 @@ VfatHasFileSystem(PDEVICE_OBJECT DeviceToMount,
|
|||
&DiskGeometry,
|
||||
&Size,
|
||||
FALSE);
|
||||
DPRINT("VfatHasFileSystem start\n");
|
||||
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT("VfatBlockDeviceIoControl faild (%x)\n", Status);
|
||||
return Status;
|
||||
}
|
||||
if (DiskGeometry.MediaType == FixedMedia)
|
||||
if (DiskGeometry.MediaType == FixedMedia || RemovableMedia)
|
||||
{
|
||||
// We have found a hard disk
|
||||
Size = sizeof(PARTITION_INFORMATION);
|
||||
|
@ -87,7 +90,7 @@ VfatHasFileSystem(PDEVICE_OBJECT DeviceToMount,
|
|||
DPRINT("VfatBlockDeviceIoControl faild (%x)\n", Status);
|
||||
return Status;
|
||||
}
|
||||
#ifndef NDEBUG
|
||||
/*#ifndef NDEBUG*/
|
||||
DbgPrint("Partition Information:\n");
|
||||
DbgPrint("StartingOffset %u\n", PartitionInfo.StartingOffset.QuadPart / 512);
|
||||
DbgPrint("PartitionLength %u\n", PartitionInfo.PartitionLength.QuadPart / 512);
|
||||
|
@ -97,7 +100,7 @@ VfatHasFileSystem(PDEVICE_OBJECT DeviceToMount,
|
|||
DbgPrint("BootIndicator %u\n", PartitionInfo.BootIndicator);
|
||||
DbgPrint("RecognizedPartition %u\n", PartitionInfo.RecognizedPartition);
|
||||
DbgPrint("RewritePartition %u\n", PartitionInfo.RewritePartition);
|
||||
#endif
|
||||
/*#endif*/
|
||||
if (PartitionInfo.PartitionType == PARTITION_FAT_12 ||
|
||||
PartitionInfo.PartitionType == PARTITION_FAT_16 ||
|
||||
PartitionInfo.PartitionType == PARTITION_HUGE ||
|
||||
|
@ -108,7 +111,7 @@ VfatHasFileSystem(PDEVICE_OBJECT DeviceToMount,
|
|||
*RecognizedFS = TRUE;
|
||||
}
|
||||
}
|
||||
else if (DiskGeometry.MediaType > Unknown && DiskGeometry.MediaType <= RemovableMedia)
|
||||
else if (DiskGeometry.MediaType > Unknown && DiskGeometry.MediaType <= RemovableMedia )
|
||||
{
|
||||
*RecognizedFS = TRUE;
|
||||
}
|
||||
|
@ -120,13 +123,19 @@ VfatHasFileSystem(PDEVICE_OBJECT DeviceToMount,
|
|||
Boot = ExAllocatePool(NonPagedPool, DiskGeometry.BytesPerSector);
|
||||
if (Boot == NULL)
|
||||
{
|
||||
DPRINT("VfatHasFileSystem 1\n");
|
||||
|
||||
*RecognizedFS=FALSE;
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
}
|
||||
|
||||
Offset.QuadPart = 0;
|
||||
|
||||
Status = VfatReadDisk(DeviceToMount, &Offset, DiskGeometry.BytesPerSector, (PUCHAR) Boot, FALSE);
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT("VfatHasFileSystem 2\n");
|
||||
|
||||
if (Boot->BytesPerSector != 0)
|
||||
{
|
||||
FatInfo.VolumeID = Boot->VolumeID;
|
||||
|
@ -167,9 +176,13 @@ VfatHasFileSystem(PDEVICE_OBJECT DeviceToMount,
|
|||
}
|
||||
else
|
||||
{
|
||||
DPRINT("VfatHasFileSystem 3\n");
|
||||
|
||||
Status = STATUS_INSUFFICIENT_RESOURCES;
|
||||
}
|
||||
}
|
||||
DPRINT("VfatHasFileSystem end\n");
|
||||
|
||||
ExFreePool(Boot);
|
||||
return Status;
|
||||
}
|
||||
|
@ -191,6 +204,7 @@ VfatMountDevice(PDEVICE_EXTENSION DeviceExt,
|
|||
{
|
||||
return(Status);
|
||||
}
|
||||
DPRINT("MountVfatdev %d, PAGE_SIZE = %d\n", DeviceExt->FatInfo.BytesPerCluster, PAGE_SIZE);
|
||||
|
||||
if (DeviceExt->FatInfo.BytesPerCluster >= PAGE_SIZE &&
|
||||
(DeviceExt->FatInfo.BytesPerCluster % PAGE_SIZE) != 0)
|
||||
|
@ -398,7 +412,8 @@ VfatVerify (PVFAT_IRP_CONTEXT IrpContext)
|
|||
*/
|
||||
{
|
||||
PDEVICE_OBJECT DeviceToVerify;
|
||||
NTSTATUS Status;
|
||||
NTSTATUS Status = STATUS_SUCCESS;
|
||||
|
||||
|
||||
DPRINT("VfatVerify(IrpContext %x)\n", IrpContext);
|
||||
|
||||
|
@ -412,16 +427,17 @@ VfatVerify (PVFAT_IRP_CONTEXT IrpContext)
|
|||
FALSE);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("VfatBlockDeviceIoControl() failed (Status %lx)\n", Status);
|
||||
DPRINT("VfatBlockDeviceIoControl() failed (Status %lx)\n", Status);
|
||||
|
||||
/* FIXME: Compare volume label */
|
||||
|
||||
DPRINT1(" returning STATUS_WRONG_VOLUME\n");
|
||||
DPRINT(" returning STATUS_WRONG_VOLUME\n");
|
||||
|
||||
return STATUS_WRONG_VOLUME;
|
||||
Status = STATUS_WRONG_VOLUME;
|
||||
}
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
DeviceToVerify->Flags &= ~DO_VERIFY_VOLUME;
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
|
@ -598,6 +614,7 @@ NTSTATUS VfatFileSystemControl(PVFAT_IRP_CONTEXT IrpContext)
|
|||
break;
|
||||
|
||||
case IRP_MN_VERIFY_VOLUME:
|
||||
DPRINT("VFATFS: IRP_MN_VERIFY_VOLUME\n");
|
||||
Status = VfatVerify(IrpContext);
|
||||
break;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
/* $Id: rw.c,v 1.64 2004/01/28 20:53:46 ekohl Exp $
|
||||
/* $Id: rw.c,v 1.65 2004/03/31 03:30:36 jimtabor Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -460,7 +460,7 @@ VfatRead(PVFAT_IRP_CONTEXT IrpContext)
|
|||
PERESOURCE Resource = NULL;
|
||||
LARGE_INTEGER ByteOffset;
|
||||
PVOID Buffer;
|
||||
/*PDEVICE_OBJECT DeviceToVerify;*/
|
||||
PDEVICE_OBJECT DeviceToVerify;
|
||||
ULONG BytesPerSector;
|
||||
|
||||
assert(IrpContext);
|
||||
|
@ -629,21 +629,22 @@ VfatRead(PVFAT_IRP_CONTEXT IrpContext)
|
|||
}
|
||||
|
||||
Status = VfatReadFileData(IrpContext, Buffer, Length, ByteOffset, &ReturnedLength);
|
||||
/*
|
||||
/**/
|
||||
if (Status == STATUS_VERIFY_REQUIRED)
|
||||
{
|
||||
DPRINT("VfatReadFile returned STATUS_VERIFY_REQUIRED\n");
|
||||
DeviceToVerify = IoGetDeviceToVerify(KeGetCurrentThread());
|
||||
IoSetDeviceToVerify(KeGetCurrentThread(), NULL);
|
||||
DeviceToVerify = IoGetDeviceToVerify((struct _ETHREAD*)KeGetCurrentThread());
|
||||
IoSetDeviceToVerify((struct _ETHREAD*)KeGetCurrentThread(), NULL);
|
||||
Status = IoVerifyVolume (DeviceToVerify, FALSE);
|
||||
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
Status = VfatReadFileData(IrpContext, Buffer, Length,
|
||||
ByteOffset.u.LowPart, &ReturnedLength);
|
||||
ByteOffset, &ReturnedLength);
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
/**/
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
IrpContext->Irp->IoStatus.Information = ReturnedLength;
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
/* $Id: disk.c,v 1.35 2004/02/14 12:29:33 navaraf Exp $
|
||||
/* $Id: disk.c,v 1.36 2004/03/31 03:33:48 jimtabor Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -53,8 +53,7 @@ typedef struct _DISK_DATA
|
|||
BOOLEAN BootIndicator;
|
||||
BOOLEAN DriveNotReady;
|
||||
} DISK_DATA, *PDISK_DATA;
|
||||
|
||||
|
||||
|
||||
BOOLEAN STDCALL
|
||||
DiskClassFindDevices(PDRIVER_OBJECT DriverObject,
|
||||
PUNICODE_STRING RegistryPath,
|
||||
|
@ -69,6 +68,9 @@ NTSTATUS STDCALL
|
|||
DiskClassCheckReadWrite(IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp);
|
||||
|
||||
static VOID
|
||||
DiskClassCreateMediaChangeEvent(IN PDEVICE_EXTENSION DeviceExtension,
|
||||
IN ULONG DeviceNumber);
|
||||
|
||||
static NTSTATUS
|
||||
DiskClassCreateDeviceObject(IN PDRIVER_OBJECT DriverObject,
|
||||
|
@ -105,6 +107,20 @@ ScsiDiskCalcMbrCheckSum(IN PDEVICE_EXTENSION DeviceExtension,
|
|||
OUT PULONG Checksum);
|
||||
|
||||
|
||||
static NTSTATUS
|
||||
DiskBuildPartionTable(IN PDEVICE_OBJECT DiskDeviceObject,
|
||||
IN PIRP Irp);
|
||||
|
||||
VOID STDCALL
|
||||
DiskClassStartIo (IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp);
|
||||
|
||||
NTSTATUS STDCALL
|
||||
DiskDeviceControlCompletion (IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp,
|
||||
IN PVOID Context);
|
||||
|
||||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
/**********************************************************************
|
||||
|
@ -304,6 +320,28 @@ DiskClassFindDevices(PDRIVER_OBJECT DriverObject,
|
|||
}
|
||||
|
||||
|
||||
static VOID
|
||||
DiskClassCreateMediaChangeEvent(IN PDEVICE_EXTENSION DeviceExtension,
|
||||
IN ULONG DeviceNumber)
|
||||
{
|
||||
WCHAR NameBuffer[MAX_PATH];
|
||||
UNICODE_STRING Name;
|
||||
|
||||
swprintf (NameBuffer,
|
||||
L"\\Device\\MediaChangeEvent%lu",
|
||||
DeviceNumber);
|
||||
RtlInitUnicodeString (&Name,
|
||||
NameBuffer);
|
||||
|
||||
DeviceExtension->MediaChangeEvent =
|
||||
IoCreateSynchronizationEvent (&Name,
|
||||
&DeviceExtension->MediaChangeEventHandle);
|
||||
|
||||
KeClearEvent (DeviceExtension->MediaChangeEvent);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* NAME EXPORTED
|
||||
* DiskClassCheckDevice
|
||||
|
@ -590,7 +628,7 @@ DiskClassCreateDeviceObject(IN PDRIVER_OBJECT DriverObject,
|
|||
if (!NT_SUCCESS(Status) &&
|
||||
(DiskDeviceObject->Characteristics & FILE_REMOVABLE_MEDIA) == 0)
|
||||
{
|
||||
DPRINT1("Failed to retrieve drive capacity!\n");
|
||||
DPRINT("Failed to retrieve drive capacity!\n");
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
else
|
||||
|
@ -601,6 +639,18 @@ DiskClassCreateDeviceObject(IN PDRIVER_OBJECT DriverObject,
|
|||
|
||||
DPRINT("SectorSize: %lu\n", DiskDeviceExtension->DiskGeometry->BytesPerSector);
|
||||
|
||||
if ((DiskDeviceObject->Characteristics & FILE_REMOVABLE_MEDIA) &&
|
||||
(DiskDeviceExtension->DiskGeometry->MediaType == RemovableMedia))
|
||||
{
|
||||
|
||||
DiskClassCreateMediaChangeEvent(DiskDeviceExtension,DiskNumber);
|
||||
if(DiskDeviceExtension->MediaChangeEvent != NULL)
|
||||
{
|
||||
DPRINT("Allocated media change event!\n");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* Check disk for presence of a disk manager */
|
||||
HalExamineMBR(DiskDeviceObject,
|
||||
DiskDeviceExtension->DiskGeometry->BytesPerSector,
|
||||
|
@ -619,10 +669,9 @@ DiskClassCreateDeviceObject(IN PDRIVER_OBJECT DriverObject,
|
|||
ExFreePool(MbrBuffer);
|
||||
MbrBuffer = NULL;
|
||||
}
|
||||
|
||||
if ((DiskDeviceObject->Characteristics & FILE_REMOVABLE_MEDIA) &&
|
||||
(DiskDeviceExtension->DiskGeometry->MediaType == RemovableMedia))
|
||||
{
|
||||
{
|
||||
/* Allocate a partition list for a single entry. */
|
||||
PartitionList = ExAllocatePool(NonPagedPool,
|
||||
sizeof(DRIVE_LAYOUT_INFORMATION));
|
||||
|
@ -729,7 +778,7 @@ DiskClassCreateDeviceObject(IN PDRIVER_OBJECT DriverObject,
|
|||
Status = ScsiClassCreateDeviceObject(DriverObject,
|
||||
NameBuffer2,
|
||||
DiskDeviceObject,
|
||||
&PartitionDeviceObject,
|
||||
&PartitionDeviceObject ,
|
||||
InitializationData);
|
||||
DPRINT("ScsiClassCreateDeviceObject(): Status %x\n", Status);
|
||||
if (NT_SUCCESS(Status))
|
||||
|
@ -781,7 +830,7 @@ DiskClassCreateDeviceObject(IN PDRIVER_OBJECT DriverObject,
|
|||
}
|
||||
else
|
||||
{
|
||||
DPRINT1("ScsiClassCreateDeviceObject() failed to create partition device object (Status %x)\n", Status);
|
||||
DPRINT("ScsiClassCreateDeviceObject() failed to create partition device object (Status %x)\n", Status);
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -797,6 +846,88 @@ DiskClassCreateDeviceObject(IN PDRIVER_OBJECT DriverObject,
|
|||
}
|
||||
|
||||
|
||||
static NTSTATUS
|
||||
DiskBuildPartionTable(IN PDEVICE_OBJECT DiskDeviceObject,
|
||||
IN PIRP Irp)
|
||||
{
|
||||
PDRIVE_LAYOUT_INFORMATION PartitionList = NULL;
|
||||
PDEVICE_EXTENSION DiskDeviceExtension;
|
||||
PDISK_DATA DiskData;
|
||||
PPARTITION_INFORMATION PartitionEntry;
|
||||
ULONG PartitionNumber;
|
||||
NTSTATUS Status;
|
||||
|
||||
DPRINT("DiskBuildPartitionTable() start\n");
|
||||
|
||||
DiskDeviceExtension = (PDEVICE_EXTENSION)DiskDeviceObject->DeviceExtension;
|
||||
DiskData = (PDISK_DATA)(DiskDeviceExtension + 1);
|
||||
|
||||
if (DiskDeviceExtension->StartingOffset.QuadPart)
|
||||
{
|
||||
DPRINT("Partition already installed\n");
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
/* Read partition table */
|
||||
Status = IoReadPartitionTable(DiskDeviceObject,
|
||||
DiskDeviceExtension->DiskGeometry->BytesPerSector,
|
||||
TRUE,
|
||||
&PartitionList);
|
||||
|
||||
|
||||
DPRINT("IoReadPartitionTable(): Status: %lx\n", Status);
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
/* Drive is not ready. */
|
||||
DPRINT("Drive not ready\n");
|
||||
DiskData->DriveNotReady = TRUE;
|
||||
|
||||
if (PartitionList != NULL)
|
||||
ExFreePool(PartitionList);
|
||||
return Status;
|
||||
}
|
||||
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT("Read partition table!\n");
|
||||
DPRINT(" Number of partitions: %u\n", PartitionList->PartitionCount);
|
||||
|
||||
/* Set disk signature */
|
||||
DiskData->Signature = PartitionList->Signature;
|
||||
|
||||
for (PartitionNumber = 0; PartitionNumber < PartitionList->PartitionCount; PartitionNumber++)
|
||||
{
|
||||
PartitionEntry = &PartitionList->PartitionEntry[PartitionNumber];
|
||||
|
||||
DiskData->NextPartition = NULL;
|
||||
DiskData->PartitionType = PartitionEntry->PartitionType;
|
||||
DiskData->PartitionNumber = PartitionNumber + 1;
|
||||
DiskData->PartitionOrdinal = PartitionNumber + 1;
|
||||
DiskData->HiddenSectors = PartitionEntry->HiddenSectors;
|
||||
DiskData->BootIndicator = PartitionEntry->BootIndicator;
|
||||
DiskData->DriveNotReady = FALSE;
|
||||
DiskDeviceExtension->StartingOffset = PartitionEntry->StartingOffset;
|
||||
DiskDeviceExtension->PartitionLength = PartitionEntry->PartitionLength;
|
||||
|
||||
DPRINT("Partition %02ld: nr: %d boot: %1x type: %x offset: %I64d size: %I64d\n",
|
||||
PartitionNumber,
|
||||
DiskData->PartitionNumber,
|
||||
DiskData->BootIndicator,
|
||||
DiskData->PartitionType,
|
||||
DiskDeviceExtension->StartingOffset.QuadPart / 512 /*DrvParms.BytesPerSector*/,
|
||||
DiskDeviceExtension->PartitionLength.QuadPart / 512 /* DrvParms.BytesPerSector*/);
|
||||
}
|
||||
}
|
||||
if (PartitionList != NULL)
|
||||
ExFreePool(PartitionList);
|
||||
|
||||
DPRINT("DiskBuildPartitionTable() done\n");
|
||||
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* NAME EXPORTED
|
||||
* DiskClassDeviceControl
|
||||
|
@ -817,7 +948,7 @@ DiskClassCreateDeviceObject(IN PDRIVER_OBJECT DriverObject,
|
|||
NTSTATUS STDCALL
|
||||
DiskClassDeviceControl(IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp)
|
||||
{
|
||||
{
|
||||
PDEVICE_EXTENSION DeviceExtension;
|
||||
PIO_STACK_LOCATION IrpStack;
|
||||
ULONG ControlCode, InputLength, OutputLength;
|
||||
|
@ -878,6 +1009,14 @@ DiskClassDeviceControl(IN PDEVICE_OBJECT DeviceObject,
|
|||
|
||||
case IOCTL_DISK_GET_PARTITION_INFO:
|
||||
DPRINT("IOCTL_DISK_GET_PARTITION_INFO\n");
|
||||
|
||||
if ((DeviceObject->Characteristics & FILE_REMOVABLE_MEDIA) &&
|
||||
(DeviceExtension->DiskGeometry->MediaType == RemovableMedia))
|
||||
{
|
||||
/* Allocate a partition list for a single entry. */
|
||||
Status = DiskBuildPartionTable(DeviceObject,Irp);
|
||||
}
|
||||
|
||||
if (IrpStack->Parameters.DeviceIoControl.OutputBufferLength <
|
||||
sizeof(PARTITION_INFORMATION))
|
||||
{
|
||||
|
@ -888,7 +1027,7 @@ DiskClassDeviceControl(IN PDEVICE_OBJECT DeviceObject,
|
|||
Status = STATUS_INVALID_DEVICE_REQUEST;
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
PPARTITION_INFORMATION PartitionInfo;
|
||||
|
||||
PartitionInfo = (PPARTITION_INFORMATION)Irp->AssociatedIrp.SystemBuffer;
|
||||
|
@ -1051,6 +1190,23 @@ DiskClassDeviceControl(IN PDEVICE_OBJECT DeviceObject,
|
|||
ExFreePool (ModeData);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case IOCTL_DISK_CHECK_VERIFY:
|
||||
DPRINT("IOCTL_DISK_CHECK_VERIFY\n");
|
||||
if (DeviceObject->Flags & DO_VERIFY_VOLUME)
|
||||
{
|
||||
DPRINT("Do Verify Set\n");
|
||||
Status = STATUS_VERIFY_REQUIRED;
|
||||
Information = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
DPRINT("Do Verify Clear\n");
|
||||
Status = STATUS_SUCCESS;
|
||||
Information = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case IOCTL_DISK_VERIFY:
|
||||
case IOCTL_DISK_FORMAT_TRACKS:
|
||||
|
@ -1063,7 +1219,7 @@ DiskClassDeviceControl(IN PDEVICE_OBJECT DeviceObject,
|
|||
case IOCTL_DISK_REQUEST_STRUCTURE:
|
||||
case IOCTL_DISK_REQUEST_DATA:
|
||||
/* If we get here, something went wrong. Inform the requestor */
|
||||
DPRINT1("Unhandled control code: %lx\n", ControlCode);
|
||||
DPRINT("Unhandled control code: %lx\n", ControlCode);
|
||||
Status = STATUS_INVALID_DEVICE_REQUEST;
|
||||
Information = 0;
|
||||
break;
|
||||
|
@ -1290,7 +1446,7 @@ DiskClassUpdatePartitionDeviceObjects(IN PDEVICE_OBJECT DiskDeviceObject,
|
|||
DeviceExtension->PartitionLength.QuadPart))
|
||||
continue;
|
||||
|
||||
DPRINT1("Found matching partition entry for partition %lu\n",
|
||||
DPRINT("Found matching partition entry for partition %lu\n",
|
||||
DiskData->PartitionNumber);
|
||||
|
||||
/* Found matching partition */
|
||||
|
@ -1392,7 +1548,7 @@ DiskClassUpdatePartitionDeviceObjects(IN PDEVICE_OBJECT DiskDeviceObject,
|
|||
&DeviceObject);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("IoCreateDevice() failed (Status %lx)\n", Status);
|
||||
DPRINT("IoCreateDevice() failed (Status %lx)\n", Status);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1745,7 +1901,7 @@ ScsiDiskUpdateFixedDiskGeometry(IN PDEVICE_EXTENSION DeviceExtension)
|
|||
1024);
|
||||
if (ValueBuffer == NULL)
|
||||
{
|
||||
DPRINT1("Failed to allocate value buffer\n");
|
||||
DPRINT("Failed to allocate value buffer\n");
|
||||
ZwClose(SystemKey);
|
||||
return;
|
||||
}
|
||||
|
@ -1808,7 +1964,7 @@ ScsiDiskUpdateFixedDiskGeometry(IN PDEVICE_EXTENSION DeviceExtension)
|
|||
#if 0
|
||||
for (i = 0; i< DriveParameters[0].NumberDrives; i++)
|
||||
{
|
||||
DPRINT1("Drive %lu: %lu Cylinders %hu Heads %hu Sectors\n",
|
||||
DPRINT("Drive %lu: %lu Cylinders %hu Heads %hu Sectors\n",
|
||||
i,
|
||||
DriveParameters[i].MaxCylinders,
|
||||
DriveParameters[i].MaxHeads,
|
||||
|
@ -1834,7 +1990,7 @@ ScsiDiskUpdateFixedDiskGeometry(IN PDEVICE_EXTENSION DeviceExtension)
|
|||
Length = TracksPerCylinder * SectorsPerTrack;
|
||||
if (Length == 0)
|
||||
{
|
||||
DPRINT1("Invalid track length 0\n");
|
||||
DPRINT("Invalid track length 0\n");
|
||||
ExFreePool(ValueBuffer);
|
||||
return;
|
||||
}
|
||||
|
@ -1853,7 +2009,7 @@ ScsiDiskUpdateFixedDiskGeometry(IN PDEVICE_EXTENSION DeviceExtension)
|
|||
|
||||
if (DeviceExtension->DMActive)
|
||||
{
|
||||
DPRINT1("FIXME: Update geometry with respect to the installed disk manager!\n");
|
||||
DPRINT("FIXME: Update geometry with respect to the installed disk manager!\n");
|
||||
|
||||
/* FIXME: Update geometry for disk managers */
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $Id: makefile,v 1.4 2003/11/13 14:19:23 ekohl Exp $
|
||||
# $Id: makefile,v 1.5 2004/03/31 03:33:48 jimtabor Exp $
|
||||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
|
@ -12,7 +12,7 @@ TARGET_DDKLIBS = class2.a
|
|||
|
||||
TARGET_OBJECTS = $(TARGET_NAME).o
|
||||
|
||||
TARGET_CFLAGS = -Werror -Wall
|
||||
TARGET_CFLAGS = -Wall
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
|
|
Loading…
Reference in a new issue