Patch from Burkhard Plaum:

1. In the function is_cdrom_linux(...) in the file lib/driver/gnu_linux.c,
   the CDROMREADTOCHDR ioctl gets called, which fails when the drive is
   empty. The CDROM_GET_CAPABILITY ioctl always succeeds for CDrom drives
   and fails for hard disks etc.

2. For some reason, at least my (GNU/Linux 2.6.10) Kernel fails to
   open empty drives, when only O_RDONLY is used. Changing the open flag to
   O_RDONLY|O_NONBLOCK, the call succeeds also for emtpy drives.
   By the way, the cdrom header file in the kernel says explicitely,
   that O_RDONLY|O_NONBLOCK should used whenever a cdrom is touched.

rocky: also made a change to eject to continue even if we can't get
the drive status -- which we can't with an empty CD-ROM drive.
This commit is contained in:
rocky
2005-04-23 01:16:19 +00:00
parent 15ddfdbc2c
commit 320c9bd55f
5 changed files with 19 additions and 20 deletions

View File

@@ -1,5 +1,5 @@
/*
$Id: _cdio_generic.c,v 1.18 2005/03/01 00:40:39 rocky Exp $
$Id: _cdio_generic.c,v 1.19 2005/04/23 01:16:19 rocky Exp $
Copyright (C) 2004, 2005 Rocky Bernstein <rocky@panix.com>
@@ -25,7 +25,7 @@
# include "config.h"
#endif
static const char _rcsid[] = "$Id: _cdio_generic.c,v 1.18 2005/03/01 00:40:39 rocky Exp $";
static const char _rcsid[] = "$Id: _cdio_generic.c,v 1.19 2005/04/23 01:16:19 rocky Exp $";
#include <stdio.h>
#include <stdlib.h>
@@ -105,7 +105,7 @@ cdio_generic_free (void *p_user_data)
Initialize CD device.
*/
bool
cdio_generic_init (void *user_data)
cdio_generic_init (void *user_data, int open_flags)
{
generic_img_private_t *p_env = user_data;
if (p_env->init) {
@@ -113,7 +113,7 @@ cdio_generic_init (void *user_data)
return false;
}
p_env->fd = open (p_env->source_name, O_RDONLY, 0);
p_env->fd = open (p_env->source_name, open_flags, 0);
if (p_env->fd < 0)
{