From 60457afcdcd3d2c7db3806a537b95f23c008bcd2 Mon Sep 17 00:00:00 2001 From: Hartmut Birr Date: Tue, 17 Sep 2002 20:42:59 +0000 Subject: [PATCH] Changed the detection of the last session from IOCTL_CDROM_READ_TOC to IOCTL_CDROM_GET_LAST_SESSION. Fixed the calculation of the VolumeOffset. svn path=/trunk/; revision=3512 --- reactos/drivers/fs/cdfs/fsctl.c | 52 +++++++++++++-------------------- 1 file changed, 20 insertions(+), 32 deletions(-) diff --git a/reactos/drivers/fs/cdfs/fsctl.c b/reactos/drivers/fs/cdfs/fsctl.c index 694c6d2a6e7..7e2a1e403f0 100644 --- a/reactos/drivers/fs/cdfs/fsctl.c +++ b/reactos/drivers/fs/cdfs/fsctl.c @@ -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.10 2002/09/15 22:25:05 hbirr Exp $ +/* $Id: fsctl.c,v 1.11 2002/09/17 20:42:59 hbirr Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -185,27 +185,32 @@ CdfsGetVolumeData(PDEVICE_OBJECT DeviceObject, NTSTATUS Status; ULONG Sector; PVD_HEADER VdHeader; - PCDROM_TOC Toc; ULONG Size; ULONG Offset; ULONG i; - PTRACK_DATA TrackData; + struct + { + UCHAR Length[2]; + UCHAR FirstSession; + UCHAR LastSession; + TRACK_DATA TrackData; + } + Toc; DPRINT("CdfsGetVolumeData\n"); Buffer = ExAllocatePool(NonPagedPool, - max (CDFS_BASIC_SECTOR, CDROM_TOC_SIZE)); + CDFS_BASIC_SECTOR); if (Buffer == NULL) return(STATUS_INSUFFICIENT_RESOURCES); - Toc = (PCDROM_TOC)Buffer; - Size = sizeof(CDROM_TOC); + Size = sizeof(Toc); Status = CdfsDeviceIoControl(DeviceObject, - IOCTL_CDROM_READ_TOC, + IOCTL_CDROM_GET_LAST_SESSION, NULL, 0, - Toc, + &Toc, &Size); if (!NT_SUCCESS(Status)) { @@ -213,34 +218,17 @@ CdfsGetVolumeData(PDEVICE_OBJECT DeviceObject, return Status; } - CHECKPOINT; - if (Toc->FirstTrack == 0xaa) - { - ExFreePool(Buffer); - return STATUS_UNSUCCESSFUL; - } + DPRINT("FirstSession %d, LastSession %d, FirstTrack %d\n", + Toc.FirstSession, Toc.LastSession, Toc.TrackData.TrackNumber); - for (i = Toc->LastTrack; i >= Toc->FirstTrack; i--) + Offset = 0; + for (i = 0; i < 4; i++) { - TrackData = &Toc->TrackData[i - 1]; - if (TrackData->Control & 0x4) - { - /* we have found the last data session */ - CHECKPOINT; - break; - } + Offset = (Offset << 8) + Toc.TrackData.Address[i]; } + CdInfo->VolumeOffset = Offset; - if (i < Toc->FirstTrack) - { - /* there is no data session on the cd */ - CHECKPOINT; - ExFreePool(Buffer); - return STATUS_UNSUCCESSFUL; - } - - Offset = msf_to_lba(TrackData->Address[1], TrackData->Address[2], TrackData->Address[3]); - CdInfo->VolumeOffset = Offset * BLOCKSIZE; + DPRINT("Offset of first track in last session %d\n", Offset); CdInfo->JolietLevel = 0; VdHeader = (PVD_HEADER)Buffer;