From bba1a2b132481aab328f97e3cba93899639d1a7a Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Sat, 27 Sep 2008 21:22:22 +0000 Subject: [PATCH] * Check for 0 capacity in the read(), write(), and io() hooks. In this case the cd_driver_info::io_scheduler field is not initialized and we shouldn't try to access it. No idea why, but this only crashed with the gcc4 build. * Fixed warning with tracing enabled. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27762 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../kernel/drivers/disk/scsi/scsi_cd/scsi_cd.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/add-ons/kernel/drivers/disk/scsi/scsi_cd/scsi_cd.cpp b/src/add-ons/kernel/drivers/disk/scsi/scsi_cd/scsi_cd.cpp index 6e2ec9ff27..89ecf73553 100644 --- a/src/add-ons/kernel/drivers/disk/scsi/scsi_cd/scsi_cd.cpp +++ b/src/add-ons/kernel/drivers/disk/scsi/scsi_cd/scsi_cd.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2004-2008, Haiku, Inc. All RightsReserved. + * Copyright 2004-2008, Haiku, Inc. All rights reserved. * Copyright 2002-2003, Thomas Kurschel. All rights reserved. * * Distributed under the terms of the MIT License. @@ -654,6 +654,9 @@ cd_read(void* cookie, off_t pos, void* buffer, size_t* _length) cd_handle* handle = (cd_handle*)cookie; size_t length = *_length; + if (handle->info->capacity == 0) + return B_DEV_NO_MEDIA; + IORequest request; status_t status = request.Init(pos, buffer, length, false, 0); if (status != B_OK) @@ -679,6 +682,9 @@ cd_write(void* cookie, off_t pos, const void* buffer, size_t* _length) cd_handle* handle = (cd_handle*)cookie; size_t length = *_length; + if (handle->info->capacity == 0) + return B_DEV_NO_MEDIA; + IORequest request; status_t status = request.Init(pos, (void*)buffer, length, true, 0); if (status != B_OK) @@ -703,6 +709,9 @@ cd_io(void* cookie, io_request* request) { cd_handle* handle = (cd_handle*)cookie; + if (handle->info->capacity == 0) + return B_DEV_NO_MEDIA; + return handle->info->io_scheduler->ScheduleRequest(request); } @@ -713,7 +722,7 @@ cd_ioctl(void* cookie, uint32 op, void* buffer, size_t length) cd_handle* handle = (cd_handle*)cookie; cd_driver_info *info = handle->info; - TRACE("ioctl(op = %d)\n", op); + TRACE("ioctl(op = %lu)\n", op); switch (op) { case B_GET_DEVICE_SIZE: