_cdio_linux.c: eject routines does it's own open and close.
cdio.h, Makefile.am, cdio.c: Add FreeBSD routine (not complete yet).
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
# $Id: Makefile.am,v 1.1 2003/03/24 19:01:09 rocky Exp $
|
# $Id: Makefile.am,v 1.2 2003/03/24 23:59:22 rocky Exp $
|
||||||
#
|
#
|
||||||
# Copyright (C) 2003 Rocky Bernstein <rocky@panix.com>
|
# Copyright (C) 2003 Rocky Bernstein <rocky@panix.com>
|
||||||
#
|
#
|
||||||
@@ -28,6 +28,7 @@ include_HEADERS = cdio.h logging.h sector.h cdio_types.h util.h
|
|||||||
libcdio_sources = \
|
libcdio_sources = \
|
||||||
_cdio_bincue.c \
|
_cdio_bincue.c \
|
||||||
_cdio_bsdi.c \
|
_cdio_bsdi.c \
|
||||||
|
_cdio_freebsd.c \
|
||||||
_cdio_linux.c \
|
_cdio_linux.c \
|
||||||
_cdio_nrg.c \
|
_cdio_nrg.c \
|
||||||
_cdio_stdio.c \
|
_cdio_stdio.c \
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
$Id: _cdio_bsdi.c,v 1.1 2003/03/24 19:01:09 rocky Exp $
|
$Id: _cdio_bsdi.c,v 1.2 2003/03/24 23:59:22 rocky Exp $
|
||||||
|
|
||||||
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
|
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
|
||||||
Copyright (C) 2003 Rocky Bernstein <rocky@panix.com>
|
Copyright (C) 2003 Rocky Bernstein <rocky@panix.com>
|
||||||
@@ -33,7 +33,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
static const char _rcsid[] = "$Id: _cdio_bsdi.c,v 1.1 2003/03/24 19:01:09 rocky Exp $";
|
static const char _rcsid[] = "$Id: _cdio_bsdi.c,v 1.2 2003/03/24 23:59:22 rocky Exp $";
|
||||||
|
|
||||||
#if HAVE_BSDI_CDROM
|
#if HAVE_BSDI_CDROM
|
||||||
|
|
||||||
@@ -127,7 +127,7 @@ _cdio_free (void *user_data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_set_bsize (int fd, unsigned bsize)
|
_set_bsize (int fd, unsigned int bsize)
|
||||||
{
|
{
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
$Id: _cdio_linux.c,v 1.1 2003/03/24 19:01:09 rocky Exp $
|
$Id: _cdio_linux.c,v 1.2 2003/03/24 23:59:22 rocky Exp $
|
||||||
|
|
||||||
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
|
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
|
||||||
Copyright (C) 2002,2003 Rocky Bernstein <rocky@panix.com>
|
Copyright (C) 2002,2003 Rocky Bernstein <rocky@panix.com>
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const char _rcsid[] = "$Id: _cdio_linux.c,v 1.1 2003/03/24 19:01:09 rocky Exp $";
|
static const char _rcsid[] = "$Id: _cdio_linux.c,v 1.2 2003/03/24 23:59:22 rocky Exp $";
|
||||||
|
|
||||||
#include "cdio_assert.h"
|
#include "cdio_assert.h"
|
||||||
#include "cdio_private.h"
|
#include "cdio_private.h"
|
||||||
@@ -129,7 +129,7 @@ _cdio_free (void *user_data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_set_bsize (int fd, unsigned bsize)
|
_set_bsize (int fd, unsigned int bsize)
|
||||||
{
|
{
|
||||||
struct cdrom_generic_command cgc;
|
struct cdrom_generic_command cgc;
|
||||||
|
|
||||||
@@ -485,29 +485,31 @@ static int
|
|||||||
_cdio_eject_media (void *user_data) {
|
_cdio_eject_media (void *user_data) {
|
||||||
|
|
||||||
_img_private_t *_obj = user_data;
|
_img_private_t *_obj = user_data;
|
||||||
int ret, status;
|
int ret=2;
|
||||||
|
int status;
|
||||||
|
int fd;
|
||||||
|
|
||||||
if (_obj->fd > -1) {
|
if ((fd = open (_obj->source_name, O_RDONLY|O_NONBLOCK)) > -1) {
|
||||||
if((status = ioctl(_obj->fd, CDROM_DRIVE_STATUS, CDSL_CURRENT)) > 0) {
|
if((status = ioctl(fd, CDROM_DRIVE_STATUS, CDSL_CURRENT)) > 0) {
|
||||||
switch(status) {
|
switch(status) {
|
||||||
case CDS_TRAY_OPEN:
|
case CDS_TRAY_OPEN:
|
||||||
if((ret = ioctl(_obj->fd, CDROMCLOSETRAY)) != 0) {
|
if((ret = ioctl(fd, CDROMCLOSETRAY)) != 0) {
|
||||||
cdio_error ("CDROMCLOSETRAY failed: %s\n", strerror(errno));
|
cdio_error ("ioctl CDROMCLOSETRAY failed: %s\n", strerror(errno));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CDS_DISC_OK:
|
case CDS_DISC_OK:
|
||||||
if((ret = ioctl(_obj->fd, CDROMEJECT)) != 0) {
|
if((ret = ioctl(fd, CDROMEJECT)) != 0) {
|
||||||
cdio_error("CDROMEJECT failed: %s\n", strerror(errno));
|
cdio_error("ioctl CDROMEJECT failed: %s\n", strerror(errno));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
_cdio_free((void *) _obj);
|
ret=0;
|
||||||
return 0;
|
|
||||||
} else {
|
} else {
|
||||||
cdio_error ("CDROM_DRIVE_STATUS failed: %s\n", strerror(errno));
|
cdio_error ("CDROM_DRIVE_STATUS failed: %s\n", strerror(errno));
|
||||||
_cdio_free((void *) _obj);
|
ret=1;
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
close(fd);
|
||||||
|
_cdio_free((void *) _obj);
|
||||||
}
|
}
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|||||||
31
lib/cdio.c
31
lib/cdio.c
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
$Id: cdio.c,v 1.1 2003/03/24 19:01:09 rocky Exp $
|
$Id: cdio.c,v 1.2 2003/03/24 23:59:22 rocky Exp $
|
||||||
|
|
||||||
Copyright (C) 2003 Rocky Bernstein <rocky@panix.com>
|
Copyright (C) 2003 Rocky Bernstein <rocky@panix.com>
|
||||||
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
|
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
#include "logging.h"
|
#include "logging.h"
|
||||||
#include "cdio_private.h"
|
#include "cdio_private.h"
|
||||||
|
|
||||||
static const char _rcsid[] = "$Id: cdio.c,v 1.1 2003/03/24 19:01:09 rocky Exp $";
|
static const char _rcsid[] = "$Id: cdio.c,v 1.2 2003/03/24 23:59:22 rocky Exp $";
|
||||||
|
|
||||||
|
|
||||||
const char *track_format2str[5] =
|
const char *track_format2str[5] =
|
||||||
@@ -70,6 +70,22 @@ CdIo_driver_t CdIo_all_drivers[MAX_DRIVER+1] = {
|
|||||||
NULL
|
NULL
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{DRIVER_BSDI,
|
||||||
|
CDIO_SRC_IS_DEVICE_MASK|CDIO_SRC_IS_NATIVE_MASK|CDIO_SRC_IS_SCSI_MASK,
|
||||||
|
"BSDI",
|
||||||
|
"BSDI ATAPI and SCSI driver",
|
||||||
|
&cdio_have_bsdi,
|
||||||
|
cdio_open_bsdi
|
||||||
|
},
|
||||||
|
|
||||||
|
{DRIVER_FREEBSD,
|
||||||
|
CDIO_SRC_IS_DEVICE_MASK|CDIO_SRC_IS_NATIVE_MASK|CDIO_SRC_IS_SCSI_MASK,
|
||||||
|
"FreeBSD",
|
||||||
|
"FreeBSD driver",
|
||||||
|
&cdio_have_freebsd,
|
||||||
|
cdio_open_freebsd
|
||||||
|
},
|
||||||
|
|
||||||
{DRIVER_LINUX,
|
{DRIVER_LINUX,
|
||||||
CDIO_SRC_IS_DEVICE_MASK|CDIO_SRC_IS_NATIVE_MASK,
|
CDIO_SRC_IS_DEVICE_MASK|CDIO_SRC_IS_NATIVE_MASK,
|
||||||
"Linux",
|
"Linux",
|
||||||
@@ -86,14 +102,6 @@ CdIo_driver_t CdIo_all_drivers[MAX_DRIVER+1] = {
|
|||||||
&cdio_open_solaris
|
&cdio_open_solaris
|
||||||
},
|
},
|
||||||
|
|
||||||
{DRIVER_BSDI,
|
|
||||||
CDIO_SRC_IS_DEVICE_MASK|CDIO_SRC_IS_NATIVE_MASK|CDIO_SRC_IS_SCSI_MASK,
|
|
||||||
"BSDI",
|
|
||||||
"BSDI ATAPI and SCSI driver",
|
|
||||||
&cdio_have_bsdi,
|
|
||||||
cdio_open_bsdi
|
|
||||||
},
|
|
||||||
|
|
||||||
{DRIVER_NRG,
|
{DRIVER_NRG,
|
||||||
CDIO_SRC_IS_DISK_IMAGE_MASK,
|
CDIO_SRC_IS_DISK_IMAGE_MASK,
|
||||||
"NRG",
|
"NRG",
|
||||||
@@ -404,9 +412,10 @@ cdio_open (const char *source_name, driver_id_t driver_id)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case DRIVER_BSDI:
|
||||||
|
case DRIVER_FREEBSD:
|
||||||
case DRIVER_LINUX:
|
case DRIVER_LINUX:
|
||||||
case DRIVER_SOLARIS:
|
case DRIVER_SOLARIS:
|
||||||
case DRIVER_BSDI:
|
|
||||||
case DRIVER_NRG:
|
case DRIVER_NRG:
|
||||||
case DRIVER_BINCUE:
|
case DRIVER_BINCUE:
|
||||||
if ((*CdIo_all_drivers[driver_id].have_driver)()) {
|
if ((*CdIo_all_drivers[driver_id].have_driver)()) {
|
||||||
|
|||||||
13
lib/cdio.h
13
lib/cdio.h
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
$Id: cdio.h,v 1.1 2003/03/24 19:01:09 rocky Exp $
|
$Id: cdio.h,v 1.2 2003/03/24 23:59:22 rocky Exp $
|
||||||
|
|
||||||
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
|
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
|
||||||
Copyright (C) 2003 Rocky Bernstein <rocky@panix.com>
|
Copyright (C) 2003 Rocky Bernstein <rocky@panix.com>
|
||||||
@@ -47,9 +47,10 @@ extern "C" {
|
|||||||
*/
|
*/
|
||||||
typedef enum {
|
typedef enum {
|
||||||
DRIVER_UNKNOWN,
|
DRIVER_UNKNOWN,
|
||||||
|
DRIVER_BSDI,
|
||||||
|
DRIVER_FREEBSD,
|
||||||
DRIVER_LINUX,
|
DRIVER_LINUX,
|
||||||
DRIVER_SOLARIS,
|
DRIVER_SOLARIS,
|
||||||
DRIVER_BSDI,
|
|
||||||
DRIVER_NRG,
|
DRIVER_NRG,
|
||||||
DRIVER_BINCUE,
|
DRIVER_BINCUE,
|
||||||
DRIVER_DEVICE,
|
DRIVER_DEVICE,
|
||||||
@@ -156,11 +157,12 @@ extern "C" {
|
|||||||
|
|
||||||
/* True if xxx driver is available. where xxx=linux, solaris, nrg, ...
|
/* True if xxx driver is available. where xxx=linux, solaris, nrg, ...
|
||||||
*/
|
*/
|
||||||
|
bool cdio_have_bsdi (void);
|
||||||
|
bool cdio_have_freebsd (void);
|
||||||
bool cdio_have_linux (void);
|
bool cdio_have_linux (void);
|
||||||
bool cdio_have_solaris (void);
|
bool cdio_have_solaris (void);
|
||||||
bool cdio_have_nrg (void);
|
bool cdio_have_nrg (void);
|
||||||
bool cdio_have_bincue (void);
|
bool cdio_have_bincue (void);
|
||||||
bool cdio_have_bsdi (void);
|
|
||||||
|
|
||||||
/* Like above but uses the enumeration instead. */
|
/* Like above but uses the enumeration instead. */
|
||||||
bool cdio_have_driver (driver_id_t driver_id);
|
bool cdio_have_driver (driver_id_t driver_id);
|
||||||
@@ -197,6 +199,11 @@ extern "C" {
|
|||||||
*/
|
*/
|
||||||
CdIo * cdio_open_bsdi (const char *source_name);
|
CdIo * cdio_open_bsdi (const char *source_name);
|
||||||
|
|
||||||
|
/*! BSDI CD-reading routines.
|
||||||
|
NULL is returned on error.
|
||||||
|
*/
|
||||||
|
CdIo * cdio_open_freebsd (const char *source_name);
|
||||||
|
|
||||||
/*! Linux CD-reading routines.
|
/*! Linux CD-reading routines.
|
||||||
NULL is returned on error.
|
NULL is returned on error.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user