{
PFUNCTIONAL_DEVICE_EXTENSION fdoExtension = Fdo->DeviceExtension;
PCOMMON_DEVICE_EXTENSION commonExtension = Fdo->DeviceExtension;
PCDROM_DATA cdData = fdoExtension->CommonExtension.DriverData;
PCDROM_MMC_EXTENSION mmcData = &(cdData->Mmc);
PIO_STACK_LOCATION thisStack = IoGetCurrentIrpStackLocation(mmcData->CapabilitiesIrp);
PSCSI_REQUEST_BLOCK srb = &(mmcData->CapabilitiesSrb);
NTSTATUSstatus;
ASSERT(Context == NULL);
//// NOTE: a remove lock is unneccessary, since the delayed irp// will have said lock held for itself, preventing a remove.//CdRomPrepareUpdateCapabilitiesIrp(Fdo);
ASSERT(thisStack->Parameters.Others.Argument1 == Fdo);
ASSERT(thisStack->Parameters.Others.Argument2 == mmcData->CapabilitiesBuffer);
ASSERT(thisStack->Parameters.Others.Argument3 == &(mmcData->CapabilitiesSrb));
mmcData->WriteAllowed = FALSE; // default to read-only//// set max retries, and also allow volume verify override based on// original (delayed) irp//
thisStack->Parameters.Others.Argument4 = (PVOID)MAXIMUM_RETRIES;
//// send to self... note that SL_OVERRIDE_VERIFY_VOLUME is not required,// as this is IRP_MJ_INTERNAL_DEVICE_CONTROL //IoCallDriver(commonExtension->LowerDeviceObject, mmcData->CapabilitiesIrp);
KeWaitForSingleObject(&mmcData->CapabilitiesEvent,
Executive, KernelMode, FALSE, NULL);
status = mmcData->CapabilitiesIrp->IoStatus.Status;
if (!NT_SUCCESS(status)) {
goto FinishDriveUpdate;
}
//// we've updated the feature set, so update whether or not reads and writes// are allowed or not.//KdPrintEx((DPFLTR_CDROM_ID, CdromDebugFeatures,
"CdRomUpdateMmc => Succeeded ""--------------------""--------------------\n"));
/*++ NOTE: It is important to only use srb->DataTransferLength worth of data at this point, since the bufferSize is what is *available* to use, not what was *actually* used. --*/#if DBGCdRompPrintAllFeaturePages(mmcData->CapabilitiesBuffer,
srb->DataTransferLength);
#endif // DBG//// update whether or not writes are allowed. this is currently defined// as requiring TargetDefectManagement and RandomWritable features//
{
PFEATURE_HEADER defectHeader;
PFEATURE_HEADER writableHeader;
defectHeader = CdRomFindFeaturePage(mmcData->CapabilitiesBuffer,
srb->DataTransferLength,
FeatureDefectManagement);
writableHeader = CdRomFindFeaturePage(mmcData->CapabilitiesBuffer,
srb->DataTransferLength,
FeatureRandomWritable);
if ((defectHeader != NULL) && (writableHeader != NULL) &&
(defectHeader->Current) && (writableHeader->Current)) {
//// this should be the *ONLY* place writes are set to allowed //KdPrintEx((DPFLTR_CDROM_ID, CdromDebugFeatures,
"CdRomUpdateMmc => Writes *allowed*\n"));
mmcData->WriteAllowed = TRUE;
} else {
if (defectHeader == NULL) {
KdPrintEx((DPFLTR_CDROM_ID, CdromDebugFeatures,
"CdRomUpdateMmc => No writes - %s = %s\n",
"defect management", "DNE"));
} else {
KdPrintEx((DPFLTR_CDROM_ID, CdromDebugFeatures,
"CdRomUpdateMmc => No writes - %s = %s\n",
"defect management", "Not Current"));
}
if (writableHeader == NULL) {
KdPrintEx((DPFLTR_CDROM_ID, CdromDebugFeatures,
"CdRomUpdateMmc => No writes - %s = %s\n",
"sector writable", "DNE"));
} else {
KdPrintEx((DPFLTR_CDROM_ID, CdromDebugFeatures,
"CdRomUpdateMmc => No writes - %s = %s\n",
"sector writable", "Not Current"));
}
} // end of feature checking
} // end of check for writability//// update the cached partition table information//// NOTE: THIS WILL CURRENTLY CAUSE A DEADLOCK!//// ISSUE-2000/06/20-henrygab - partition support not implemented// IoReadPartitionTable must be done// at PASSIVE level, requiring a thread// or worker item or other such method.//#if 0
status = IoReadPartitionTable(Fdo, 1 << fdoExtension->SectorShift,
TRUE, &mmcData->PartitionList);
if (!NT_SUCCESS(status)) {
goto FinishDriveUpdate;
}
#endif
status = STATUS_SUCCESS;
FinishDriveUpdate:
CdRompFlushDelayedList(Fdo, mmcData, status, TRUE);
return;
}
Generated on Sun May 27 2012 04:41:13 for ReactOS by
1.7.6.1
ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.