ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

BOOLEAN NTAPI FsRecGetDeviceSectorSize ( IN PDEVICE_OBJECT  DeviceObject,
OUT PULONG  SectorSize 
)

Definition at line 76 of file blockdev.c.

Referenced by FsRecExt2FsControl(), FsRecNtfsFsControl(), FsRecUdfsFsControl(), and FsRecVfatFsControl().

{
    DISK_GEOMETRY DiskGeometry;
    IO_STATUS_BLOCK IoStatusBlock;
    KEVENT Event;
    PIRP Irp;
    NTSTATUS Status;
    ULONG ControlCode;
    PAGED_CODE();

    /* Check what device we have */
    switch (DeviceObject->DeviceType)
    {
        case FILE_DEVICE_CD_ROM:

            /* Use the CD IOCTL */
            ControlCode = IOCTL_CDROM_GET_DRIVE_GEOMETRY;
            break;

        case FILE_DEVICE_DISK:

            /* Use the Disk IOCTL */
            ControlCode = IOCTL_DISK_GET_DRIVE_GEOMETRY;
            break;

        default:

            /* Invalid device type */
            return FALSE;
    }

    /* Build the information IRP */
    KeInitializeEvent(&Event, SynchronizationEvent, FALSE);
    Irp = IoBuildDeviceIoControlRequest(ControlCode,
                                        DeviceObject,
                                        NULL,
                                        0,
                                        &DiskGeometry,
                                        sizeof(DISK_GEOMETRY),
                                        FALSE,
                                        &Event,
                                        &IoStatusBlock);
    if (!Irp) return FALSE;

    /* Override verification */
    IoGetNextIrpStackLocation(Irp)->Flags |= SL_OVERRIDE_VERIFY_VOLUME;

    /* Do the request */
    Status = IoCallDriver(DeviceObject, Irp);
    if (Status == STATUS_PENDING)
    {
        /* Wait for completion */
        KeWaitForSingleObject(&Event,
                              Executive,
                              KernelMode,
                              FALSE,
                              NULL);
        Status = IoStatusBlock.Status;
    }

    /* Fail if we couldn't get the data */
    if (!NT_SUCCESS(Status)) return FALSE;

    /* Return the sector size if it's valid */
    if (!DiskGeometry.BytesPerSector) return FALSE;
    *SectorSize = DiskGeometry.BytesPerSector;
    return TRUE;
}

Generated on Sun May 27 2012 05:23:47 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.