2008-01-10 15:20:57 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
cc -g -c \
|
|
|
|
-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE=1 -D_LARGEFILE64_SOURCE \
|
|
|
|
burn_wrap.c
|
|
|
|
*/
|
|
|
|
/* libburn wrappers for libisoburn
|
|
|
|
|
2011-03-01 14:51:17 +00:00
|
|
|
Copyright 2007 - 2011 Thomas Schmitt, <scdbackup@gmx.net>
|
2010-02-14 15:09:05 +00:00
|
|
|
Provided under GPL version 2 or later.
|
2008-01-10 15:20:57 +00:00
|
|
|
*/
|
|
|
|
|
2010-05-16 09:26:41 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "../config.h"
|
|
|
|
#endif
|
|
|
|
|
2008-01-10 15:20:57 +00:00
|
|
|
/* <<< A70929 : hardcoded CD-RW with fabricated -msinfo
|
|
|
|
#define Hardcoded_cd_rW 1
|
|
|
|
#define Hardcoded_cd_rw_c1 12999
|
|
|
|
#define Hardcoded_cd_rw_nwA 152660
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <fcntl.h>
|
2008-06-18 13:20:29 +00:00
|
|
|
#include <time.h>
|
2008-12-05 17:10:27 +00:00
|
|
|
#include <regex.h>
|
2008-01-10 15:20:57 +00:00
|
|
|
|
2008-01-20 10:30:43 +00:00
|
|
|
#ifndef Xorriso_standalonE
|
|
|
|
|
2008-01-10 15:20:57 +00:00
|
|
|
#include <libburn/libburn.h>
|
2008-01-26 00:26:57 +00:00
|
|
|
#include <libisofs/libisofs.h>
|
2010-10-15 12:55:03 +00:00
|
|
|
#ifdef Xorriso_with_libjtE
|
|
|
|
#include <libjte/libjte.h>
|
|
|
|
#endif
|
2008-01-10 15:20:57 +00:00
|
|
|
|
2008-01-20 10:30:43 +00:00
|
|
|
#else /* ! Xorriso_standalonE */
|
|
|
|
|
|
|
|
#include "../libisofs/libisofs.h"
|
|
|
|
#include "../libburn/libburn.h"
|
2010-10-07 11:49:41 +00:00
|
|
|
#ifdef Xorriso_with_libjtE
|
|
|
|
#include "../libjte/libjte.h"
|
|
|
|
#endif
|
|
|
|
|
2010-10-15 12:55:03 +00:00
|
|
|
#endif /* Xorriso_standalonE */
|
2010-10-07 11:49:41 +00:00
|
|
|
|
2008-01-20 10:30:43 +00:00
|
|
|
|
2008-01-10 15:20:57 +00:00
|
|
|
#include "libisoburn.h"
|
|
|
|
#include "isoburn.h"
|
|
|
|
|
|
|
|
|
|
|
|
/* The global list of isoburn objects. Usually there is only one. */
|
|
|
|
extern struct isoburn *isoburn_list_start; /* in isoburn.c */
|
|
|
|
|
2008-06-18 16:14:44 +00:00
|
|
|
/* Default values for application provided msgs_submit methods.
|
|
|
|
To be attached to newly aquired drives.
|
|
|
|
Storage location is isoburn.c
|
|
|
|
*/
|
|
|
|
extern int (*libisoburn_default_msgs_submit)
|
|
|
|
(void *handle, int error_code, char msg_text[],
|
|
|
|
int os_errno, char severity[], int flag);
|
|
|
|
extern void *libisoburn_default_msgs_submit_handle;
|
|
|
|
extern int libisoburn_default_msgs_submit_flag;
|
|
|
|
|
2008-01-10 15:20:57 +00:00
|
|
|
|
2008-10-05 07:55:20 +00:00
|
|
|
static int isoburn_emulate_toc(struct burn_drive *d, int flag);
|
2008-05-07 17:54:55 +00:00
|
|
|
|
|
|
|
|
2008-01-26 11:36:58 +00:00
|
|
|
int isoburn_initialize(char msg[1024], int flag)
|
2008-01-10 15:20:57 +00:00
|
|
|
{
|
2010-10-04 15:51:37 +00:00
|
|
|
int major, minor, micro, bad_match= 0, no_iso_init= 0;
|
2008-01-31 21:47:39 +00:00
|
|
|
|
|
|
|
|
2010-10-04 15:51:37 +00:00
|
|
|
/* First the ugly compile time checks for header version compatibility.
|
2008-01-31 21:47:39 +00:00
|
|
|
If everthing matches, then they produce no C code. In case of mismatch,
|
|
|
|
intentionally faulty C code will be inserted.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef iso_lib_header_version_major
|
|
|
|
/* The minimum requirement of libisoburn towards the libisofs header
|
|
|
|
at compile time is defined in libisoburn/libisoburn.h :
|
|
|
|
isoburn_libisofs_req_major
|
|
|
|
isoburn_libisofs_req_minor
|
|
|
|
isoburn_libisofs_req_micro
|
|
|
|
It gets compared against the version macros in libisofs/libisofs.h :
|
|
|
|
iso_lib_header_version_major
|
|
|
|
iso_lib_header_version_minor
|
|
|
|
iso_lib_header_version_micro
|
|
|
|
If the header is too old then the following code shall cause failure of
|
2009-01-23 10:28:47 +00:00
|
|
|
libisoburn compilation rather than to allow production of a program with
|
2008-01-31 21:47:39 +00:00
|
|
|
unpredictable bugs or memory corruption.
|
|
|
|
The compiler messages supposed to appear in this case are:
|
|
|
|
error: 'LIBISOFS_MISCONFIGURATION' undeclared (first use in this function)
|
2009-01-23 10:28:47 +00:00
|
|
|
error: 'INTENTIONAL_ABORT_OF_COMPILATION__HEADERFILE_libisofs_dot_h_TOO_OLD__SEE_libisoburn_dot_h_AND_burn_wrap_dot_h' undeclared (first use in this function)
|
2008-01-31 21:47:39 +00:00
|
|
|
error: 'LIBISOFS_MISCONFIGURATION_' undeclared (first use in this function)
|
|
|
|
*/
|
|
|
|
/* The indendation is an advise of man gcc to help old compilers ignoring */
|
|
|
|
#if isoburn_libisofs_req_major > iso_lib_header_version_major
|
|
|
|
#define Isoburn_libisofs_dot_h_too_olD 1
|
|
|
|
#endif
|
|
|
|
#if isoburn_libisofs_req_major == iso_lib_header_version_major && isoburn_libisofs_req_minor > iso_lib_header_version_minor
|
|
|
|
#define Isoburn_libisofs_dot_h_too_olD 1
|
|
|
|
#endif
|
|
|
|
#if isoburn_libisofs_req_minor == iso_lib_header_version_minor && isoburn_libisofs_req_micro > iso_lib_header_version_micro
|
|
|
|
#define Isoburn_libisofs_dot_h_too_olD 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef Isoburn_libisofs_dot_h_too_olD
|
|
|
|
LIBISOFS_MISCONFIGURATION = 0;
|
2010-10-04 15:51:37 +00:00
|
|
|
INTENTIONAL_ABORT_OF_COMPILATION__HEADERFILE_libisofs_dot_h_TOO_OLD__SEE_libisoburn_dot_h_AND_burn_wrap_dot_c = 0;
|
2008-01-31 21:47:39 +00:00
|
|
|
LIBISOFS_MISCONFIGURATION_ = 0;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* iso_lib_header_version_major */
|
|
|
|
|
|
|
|
/* The minimum requirement of libisoburn towards the libburn header
|
|
|
|
at compile time is defined in libisoburn/libisoburn.h :
|
|
|
|
isoburn_libburn_req_major
|
|
|
|
isoburn_libburn_req_minor
|
|
|
|
isoburn_libburn_req_micro
|
|
|
|
It gets compared against the version macros in libburn/libburn.h :
|
|
|
|
burn_header_version_major
|
|
|
|
burn_header_version_minor
|
|
|
|
burn_header_version_micro
|
|
|
|
If the header is too old then the following code shall cause failure of
|
|
|
|
cdrskin compilation rather than to allow production of a program with
|
|
|
|
unpredictable bugs or memory corruption.
|
|
|
|
The compiler messages supposed to appear in this case are:
|
|
|
|
error: 'LIBBURN_MISCONFIGURATION' undeclared (first use in this function)
|
|
|
|
error: 'INTENTIONAL_ABORT_OF_COMPILATION__HEADERFILE_libburn_dot_h_TOO_OLD__SEE_libisoburn_dot_h_and_burn_wrap_dot_h' undeclared (first use in this function)
|
|
|
|
error: 'LIBBURN_MISCONFIGURATION_' undeclared (first use in this function)
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* The indendation is an advise of man gcc to help old compilers ignoring */
|
|
|
|
#if isoburn_libburn_req_major > burn_header_version_major
|
|
|
|
#define Isoburn_libburn_dot_h_too_olD 1
|
|
|
|
#endif
|
|
|
|
#if isoburn_libburn_req_major == burn_header_version_major && isoburn_libburn_req_minor > burn_header_version_minor
|
|
|
|
#define Isoburn_libburn_dot_h_too_olD 1
|
|
|
|
#endif
|
|
|
|
#if isoburn_libburn_req_minor == burn_header_version_minor && isoburn_libburn_req_micro > burn_header_version_micro
|
|
|
|
#define Isoburn_libburn_dot_h_too_olD 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef Isoburn_libburn_dot_h_too_olD
|
|
|
|
LIBBURN_MISCONFIGURATION = 0;
|
|
|
|
INTENTIONAL_ABORT_OF_COMPILATION__HEADERFILE_libburn_dot_h_TOO_OLD__SEE_libisoburn_dot_h_and_burn_wrap_dot_h = 0;
|
|
|
|
LIBBURN_MISCONFIGURATION_ = 0;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2010-10-04 15:51:37 +00:00
|
|
|
#ifdef Xorriso_with_libjtE
|
|
|
|
|
|
|
|
/* The minimum requirement of libisoburn towards the libjte header
|
|
|
|
at compile time is the same as the one of a usable libisfs itowards libjte.
|
|
|
|
So the requirement is defined in libisofs/libisofs.h :
|
|
|
|
iso_libjte_req_major , iso_libjte_req_minor , iso_libjte_req_micro
|
|
|
|
*/
|
|
|
|
/* The indendation is an advise of man gcc to help old compilers ignoring */
|
|
|
|
#if iso_libjte_req_major > LIBJTE_VERSION_MAJOR
|
|
|
|
#define Libisofs_libjte_dot_h_too_olD 1
|
|
|
|
#endif
|
|
|
|
#if iso_libjte_req_major == LIBJTE_VERSION_MAJOR && iso_libjte_req_minor > LIBJTE_VERSION_MINOR
|
|
|
|
#define Libisofs_libjte_dot_h_too_olD 1
|
|
|
|
#endif
|
|
|
|
#if iso_libjte_req_minor == LIBJTE_VERSION_MINOR && iso_libjte_req_micro > LIBJTE_VERSION_MICRO
|
|
|
|
#define Libisofs_libjte_dot_h_too_olD 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef Libisofs_libjte_dot_h_too_olD
|
|
|
|
LIBJTE_MISCONFIGURATION = 0;
|
|
|
|
INTENTIONAL_ABORT_OF_COMPILATION__HEADERFILE_libjte_dot_h_TOO_OLD__SEE_libisofs_dot_h_AND_burn_wrap.c_c = 0;
|
|
|
|
LIBJTE_MISCONFIGURATION_ = 0;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* Xorriso_with_libjtE */
|
|
|
|
|
|
|
|
|
|
|
|
/* End of ugly compile time tests (scroll up for explanation) */
|
2008-01-31 21:47:39 +00:00
|
|
|
|
2008-01-26 11:36:58 +00:00
|
|
|
|
|
|
|
msg[0]= 0;
|
2010-10-04 15:51:37 +00:00
|
|
|
|
|
|
|
#ifdef Xorriso_with_libjtE
|
|
|
|
|
|
|
|
libjte__version(&major, &minor, µ);
|
|
|
|
sprintf(msg + strlen(msg), "libjte-%d.%d.%d ", major, minor, micro);
|
|
|
|
if (libjte__is_compatible(LIBJTE_VERSION_MAJOR, LIBJTE_VERSION_MINOR,
|
|
|
|
LIBJTE_VERSION_MICRO, 0)) {
|
|
|
|
sprintf(msg+strlen(msg), "ok, ");
|
|
|
|
} else {
|
|
|
|
sprintf(msg + strlen(msg),
|
|
|
|
"- TOO OLD -, need at least libjte-%d.%d.%d ,\n",
|
|
|
|
LIBJTE_VERSION_MAJOR, LIBJTE_VERSION_MINOR,
|
|
|
|
LIBJTE_VERSION_MICRO);
|
|
|
|
bad_match= 1;
|
|
|
|
no_iso_init= 1; /* iso_init() will fail anyway */
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* Xorriso_with_libjtE */
|
|
|
|
|
|
|
|
if(!no_iso_init) {
|
|
|
|
if(iso_init()<0) {
|
|
|
|
sprintf(msg+strlen(msg), "Cannot initialize libisofs\n");
|
|
|
|
return(0);
|
|
|
|
}
|
2008-01-26 11:36:58 +00:00
|
|
|
}
|
|
|
|
iso_lib_version(&major, &minor, µ);
|
2008-01-31 21:47:39 +00:00
|
|
|
sprintf(msg+strlen(msg), "libisofs-%d.%d.%d ", major, minor, micro);
|
|
|
|
#ifdef iso_lib_header_version_major
|
|
|
|
if(iso_lib_is_compatible(iso_lib_header_version_major,
|
|
|
|
iso_lib_header_version_minor,
|
|
|
|
iso_lib_header_version_micro)) {
|
|
|
|
sprintf(msg+strlen(msg), "ok, ");
|
|
|
|
} else {
|
|
|
|
sprintf(msg+strlen(msg),"- TOO OLD -, need at least libisofs-%d.%d.%d ,\n",
|
|
|
|
iso_lib_header_version_major, iso_lib_header_version_minor,
|
|
|
|
iso_lib_header_version_micro);
|
|
|
|
bad_match= 1;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
if(iso_lib_is_compatible(isoburn_libisofs_req_major,
|
|
|
|
isoburn_libisofs_req_minor,
|
|
|
|
isoburn_libisofs_req_micro)) {
|
|
|
|
sprintf(msg+strlen(msg), "suspicious, ");
|
|
|
|
} else {
|
|
|
|
sprintf(msg+strlen(msg),"- TOO OLD -, need at least libisofs-%d.%d.%d ,\n",
|
|
|
|
isoburn_libisofs_req_major, isoburn_libisofs_req_minor,
|
|
|
|
isoburn_libisofs_req_micro);
|
|
|
|
bad_match= 1;
|
|
|
|
}
|
|
|
|
#endif /* ! iso_lib_header_version_major */
|
2008-01-29 18:44:54 +00:00
|
|
|
|
2008-01-26 11:36:58 +00:00
|
|
|
if(!burn_initialize()) {
|
|
|
|
sprintf(msg+strlen(msg), "Cannot initialize libburn\n");
|
2008-01-10 15:20:57 +00:00
|
|
|
return(0);
|
2008-01-26 11:36:58 +00:00
|
|
|
}
|
2011-03-13 13:15:41 +00:00
|
|
|
|
2008-01-26 11:36:58 +00:00
|
|
|
burn_version(&major, &minor, µ);
|
2008-01-31 21:47:39 +00:00
|
|
|
sprintf(msg+strlen(msg), "libburn-%d.%d.%d ", major, minor, micro);
|
2008-01-29 21:17:29 +00:00
|
|
|
if(major > burn_header_version_major
|
|
|
|
|| (major == burn_header_version_major
|
|
|
|
&& (minor > burn_header_version_minor
|
|
|
|
|| (minor == burn_header_version_minor
|
|
|
|
&& micro >= burn_header_version_micro)))) {
|
2008-01-31 21:47:39 +00:00
|
|
|
sprintf(msg+strlen(msg), "ok, ");
|
2008-01-29 21:17:29 +00:00
|
|
|
} else {
|
2008-01-31 21:47:39 +00:00
|
|
|
sprintf(msg+strlen(msg), "- TOO OLD -, need at least libburn-%d.%d.%d ,\n",
|
2008-01-29 21:17:29 +00:00
|
|
|
burn_header_version_major, burn_header_version_minor,
|
|
|
|
burn_header_version_micro);
|
2008-01-31 21:47:39 +00:00
|
|
|
bad_match= 1;
|
2008-01-29 21:17:29 +00:00
|
|
|
}
|
2008-01-29 18:44:54 +00:00
|
|
|
|
2008-01-26 12:06:26 +00:00
|
|
|
isoburn_version(&major, &minor, µ);
|
2008-01-31 21:47:39 +00:00
|
|
|
sprintf(msg+strlen(msg), "for libisoburn-%d.%d.%d", major, minor, micro);
|
|
|
|
if(bad_match)
|
|
|
|
return(0);
|
|
|
|
|
|
|
|
isoburn_destroy_all(&isoburn_list_start, 0); /* isoburn_list_start= NULL */
|
2008-01-10 15:20:57 +00:00
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-06 13:11:20 +00:00
|
|
|
/* API @since 0.1.0 */
|
|
|
|
int isoburn_libisofs_req(int *major, int *minor, int *micro)
|
|
|
|
{
|
|
|
|
*major= iso_lib_header_version_major;
|
|
|
|
*minor= iso_lib_header_version_minor;
|
|
|
|
*micro= iso_lib_header_version_micro;
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* API @since 0.1.0 */
|
|
|
|
int isoburn_libburn_req(int *major, int *minor, int *micro)
|
|
|
|
{
|
|
|
|
*major= burn_header_version_major;
|
|
|
|
*minor= burn_header_version_minor;
|
|
|
|
*micro= burn_header_version_micro;
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-10-04 15:51:37 +00:00
|
|
|
/* API @since 0.6.4 */
|
|
|
|
int isoburn_libjte_req(int *major, int *minor, int *micro)
|
|
|
|
{
|
2010-10-08 09:34:07 +00:00
|
|
|
#ifdef Xorriso_with_libjtE
|
2010-10-04 15:51:37 +00:00
|
|
|
*major= LIBJTE_VERSION_MAJOR;
|
|
|
|
*minor= LIBJTE_VERSION_MINOR;
|
|
|
|
*micro= LIBJTE_VERSION_MICRO;
|
2010-10-08 09:34:07 +00:00
|
|
|
#else
|
|
|
|
*major= *minor= *micro= 0;
|
|
|
|
#endif /* ! Xorriso_with_libjtE */
|
2010-10-04 15:51:37 +00:00
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-06-19 09:04:04 +00:00
|
|
|
int isoburn_set_msgs_submit(int (*msgs_submit)(void *handle, int error_code,
|
|
|
|
char msg_text[], int os_errno,
|
|
|
|
char severity[], int flag),
|
2008-06-18 16:14:44 +00:00
|
|
|
void *submit_handle, int submit_flag, int flag)
|
|
|
|
{
|
|
|
|
libisoburn_default_msgs_submit= msgs_submit;
|
|
|
|
libisoburn_default_msgs_submit_handle= submit_handle;
|
|
|
|
libisoburn_default_msgs_submit_flag= submit_flag;
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-05-06 14:45:49 +00:00
|
|
|
int isoburn_is_intermediate_dvd_rw(struct burn_drive *d, int flag)
|
|
|
|
{
|
|
|
|
int profile, ret= 0, format_status, num_formats;
|
|
|
|
char profile_name[80];
|
|
|
|
enum burn_disc_status s;
|
|
|
|
off_t format_size= -1;
|
|
|
|
unsigned bl_sas;
|
|
|
|
|
|
|
|
s= isoburn_disc_get_status(d);
|
|
|
|
ret= burn_disc_get_profile(d, &profile, profile_name);
|
|
|
|
if(ret>0 && profile==0x13)
|
|
|
|
ret= burn_disc_get_formats(d, &format_status, &format_size,
|
|
|
|
&bl_sas, &num_formats);
|
|
|
|
if(ret>0 && profile==0x13 && s==BURN_DISC_BLANK &&
|
|
|
|
format_status==BURN_FORMAT_IS_UNKNOWN)
|
|
|
|
return(1);
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** Examines the media and sets appropriate emulation if needed.
|
2008-02-20 23:48:08 +00:00
|
|
|
@param flag bit0= pretent blank on overwriteable media
|
2008-05-08 14:10:43 +00:00
|
|
|
bit3= if the drive reports a -ROM profile then try to read
|
|
|
|
table of content by scanning for ISO image headers.
|
2008-10-05 07:55:20 +00:00
|
|
|
bit4= do not emulate TOC on overwriteable media
|
2009-01-21 20:39:00 +00:00
|
|
|
bit5= ignore ACL from external filesystems
|
|
|
|
bit6= ignore POSIX Extended Attributes from external filesystems
|
2009-10-07 07:55:23 +00:00
|
|
|
bit7= pretend -ROM and scan for table of content
|
2008-01-10 15:20:57 +00:00
|
|
|
*/
|
|
|
|
static int isoburn_welcome_media(struct isoburn **o, struct burn_drive *d,
|
|
|
|
int flag)
|
|
|
|
{
|
2011-07-15 08:31:22 +00:00
|
|
|
int ret, profile, readonly= 0, role, random_access;
|
2011-03-21 09:31:51 +00:00
|
|
|
int emulation_started= 0;
|
2008-01-10 15:20:57 +00:00
|
|
|
struct burn_multi_caps *caps= NULL;
|
2008-05-08 18:53:31 +00:00
|
|
|
struct isoburn_toc_entry *t;
|
2008-05-08 14:10:43 +00:00
|
|
|
char profile_name[80];
|
2009-06-25 12:50:57 +00:00
|
|
|
struct isoburn_toc_disc *disc= NULL;
|
|
|
|
struct isoburn_toc_session **sessions;
|
|
|
|
struct isoburn_toc_track **tracks;
|
|
|
|
int num_sessions= 0, num_tracks= 0, track_count= 0, session_no= 0;
|
|
|
|
char msg[80];
|
2010-03-29 10:35:22 +00:00
|
|
|
enum burn_disc_status s;
|
2008-01-10 15:20:57 +00:00
|
|
|
|
2011-07-15 08:31:22 +00:00
|
|
|
#ifndef Hardcoded_cd_rW
|
|
|
|
int lba, nwa;
|
|
|
|
#endif
|
|
|
|
|
2010-03-29 10:35:22 +00:00
|
|
|
s= burn_disc_get_status(d);
|
2008-05-08 14:10:43 +00:00
|
|
|
profile_name[0]= 0;
|
|
|
|
ret= burn_disc_get_profile(d, &profile, profile_name);
|
|
|
|
if(ret<=0)
|
|
|
|
profile= 0x00;
|
2008-01-10 15:20:57 +00:00
|
|
|
ret= burn_disc_get_multi_caps(d, BURN_WRITE_NONE, &caps, 0);
|
|
|
|
if(ret<0) /* == 0 is read-only media, but it is too early to reject it here */
|
|
|
|
goto ex;
|
2009-10-07 07:55:23 +00:00
|
|
|
if(ret==0 || (flag & 128))
|
2008-05-08 14:10:43 +00:00
|
|
|
readonly= 1;
|
2009-10-07 07:55:23 +00:00
|
|
|
if(flag & 128)
|
|
|
|
flag = (flag & ~ 16) | 8;
|
|
|
|
|
2008-01-10 15:20:57 +00:00
|
|
|
ret= isoburn_new(o, 0);
|
|
|
|
if(ret<=0)
|
|
|
|
goto ex;
|
|
|
|
(*o)->drive= d;
|
2008-06-18 16:14:44 +00:00
|
|
|
(*o)->msgs_submit= libisoburn_default_msgs_submit;
|
|
|
|
(*o)->msgs_submit_handle= libisoburn_default_msgs_submit_handle;
|
|
|
|
(*o)->msgs_submit_flag= libisoburn_default_msgs_submit_flag;
|
2009-01-21 20:39:00 +00:00
|
|
|
iso_image_set_ignore_aclea((*o)->image, (flag >> 5 ) & 3);
|
2008-01-10 15:20:57 +00:00
|
|
|
|
|
|
|
#ifdef Hardcoded_cd_rW
|
|
|
|
/* <<< A70929 : hardcoded CD-RW with fabricated -msinfo */
|
|
|
|
caps->start_adr= 0;
|
|
|
|
(*o)->fabricated_disc_status= BURN_DISC_APPENDABLE;
|
|
|
|
#endif
|
|
|
|
|
2011-03-13 13:15:41 +00:00
|
|
|
role= burn_drive_get_drive_role(d);
|
|
|
|
random_access= caps->start_adr || role == 4;
|
|
|
|
if(random_access)
|
2008-01-10 15:20:57 +00:00
|
|
|
(*o)->emulation_mode= 1;
|
2011-03-13 13:15:41 +00:00
|
|
|
if(random_access && !readonly) { /* set emulation to overwriteable */
|
2008-05-06 14:45:49 +00:00
|
|
|
ret= isoburn_is_intermediate_dvd_rw(d, 0);
|
|
|
|
if(ret>0) {
|
|
|
|
(*o)->min_start_byte= 0;
|
2008-02-20 23:48:08 +00:00
|
|
|
(*o)->nwa= 0;
|
2008-05-06 14:45:49 +00:00
|
|
|
(*o)->zero_nwa= 0;
|
|
|
|
}
|
2011-03-21 09:31:51 +00:00
|
|
|
if((flag & 1) && role != 4 && role != 5) {
|
2008-05-06 14:45:49 +00:00
|
|
|
(*o)->nwa= (*o)->zero_nwa;
|
2008-02-20 23:48:08 +00:00
|
|
|
(*o)->fabricated_disc_status= BURN_DISC_BLANK;
|
|
|
|
} else {
|
|
|
|
ret= isoburn_start_emulation(*o, 0);
|
|
|
|
if(ret<=0) {
|
|
|
|
(*o)->emulation_mode= -1;
|
|
|
|
goto ex;
|
|
|
|
}
|
2011-03-21 09:31:51 +00:00
|
|
|
emulation_started= 1;
|
2009-08-17 16:23:58 +00:00
|
|
|
/* try to read emulated toc */
|
|
|
|
ret= isoburn_emulate_toc(d, flag & 16);
|
|
|
|
if(ret<0) {
|
|
|
|
(*o)->emulation_mode= -1;
|
|
|
|
goto ex;
|
2008-05-07 17:54:55 +00:00
|
|
|
}
|
2008-01-10 15:20:57 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
|
2008-05-08 14:10:43 +00:00
|
|
|
/* >>> recognize unsuitable media (but allow read-only media) */;
|
2008-01-10 15:20:57 +00:00
|
|
|
|
2010-03-29 10:35:22 +00:00
|
|
|
if(readonly && s != BURN_DISC_EMPTY) {
|
2011-07-15 08:31:22 +00:00
|
|
|
|
|
|
|
/* >>> ts B10712: This maps BURN_DISC_UNSUITABLE to BURN_DISC_FULL
|
|
|
|
which can hardly be correct in general.
|
|
|
|
??? What reason does this have ?
|
|
|
|
*/
|
2009-10-07 07:55:23 +00:00
|
|
|
(*o)->fabricated_disc_status= BURN_DISC_FULL;
|
2011-07-15 08:31:22 +00:00
|
|
|
|
2009-06-25 12:50:57 +00:00
|
|
|
/* This might be overwriteable media in a -ROM drive.
|
|
|
|
Pitfall:
|
|
|
|
Multi-session media which bear a xorriso image for overwriteables
|
|
|
|
in their first session would get a TOC of that first image rather
|
|
|
|
than of the media.
|
|
|
|
It is not possible to distinguish a BD-RE from a single session
|
|
|
|
BD-R with an image for overwriteables. But as soon as the media
|
|
|
|
bears 2 logical tracks it cannot be overwriteable.
|
|
|
|
So count the number of tracks first.
|
|
|
|
*/
|
|
|
|
disc= isoburn_toc_drive_get_disc(d);
|
|
|
|
if(disc != NULL) {
|
|
|
|
sessions= isoburn_toc_disc_get_sessions(disc, &num_sessions);
|
|
|
|
for(session_no= 0; session_no < num_sessions; session_no++) {
|
|
|
|
tracks= isoburn_toc_session_get_tracks(sessions[session_no],
|
|
|
|
&num_tracks);
|
2011-07-02 15:33:46 +00:00
|
|
|
if(tracks != NULL)
|
|
|
|
track_count+= num_tracks;
|
2009-06-25 12:50:57 +00:00
|
|
|
}
|
|
|
|
isoburn_toc_disc_free(disc);
|
|
|
|
}
|
|
|
|
|
|
|
|
sprintf(msg, "ROM media has libburn track count = %d", track_count);
|
|
|
|
isoburn_msgs_submit(*o, 0x00060000, msg, 0, "DEBUG", 0);
|
|
|
|
|
|
|
|
if((flag & 16) || track_count >= 2) {
|
|
|
|
ret= 0; /* toc emulation off, or not overwriteable */
|
2008-10-05 07:55:20 +00:00
|
|
|
} else {
|
2011-03-21 09:31:51 +00:00
|
|
|
ret= isoburn_start_emulation(*o, 1);
|
|
|
|
if(ret<=0) {
|
|
|
|
(*o)->emulation_mode= -1;
|
|
|
|
goto ex;
|
|
|
|
}
|
|
|
|
emulation_started= 1;
|
2008-10-05 07:55:20 +00:00
|
|
|
ret= isoburn_emulate_toc(d, 1);
|
|
|
|
if(ret<0)
|
|
|
|
goto ex;
|
2009-10-07 07:55:23 +00:00
|
|
|
else if(ret > 0)
|
|
|
|
(*o)->emulation_mode= 1;
|
2008-10-05 07:55:20 +00:00
|
|
|
}
|
2009-10-07 07:55:23 +00:00
|
|
|
if(ret == 0 && (profile != 0x08 || (flag & 128)) && (flag & 8)) {
|
2008-05-08 14:10:43 +00:00
|
|
|
/* This might also be multi-session media which do not
|
|
|
|
get shown with a decent TOC.
|
|
|
|
CD-R TOC (profile 0x08) can be trusted. Others not.
|
2008-05-08 18:53:31 +00:00
|
|
|
Do a scan search of ISO headers.
|
2008-05-08 14:10:43 +00:00
|
|
|
*/
|
2011-03-21 09:31:51 +00:00
|
|
|
if(!emulation_started) {
|
|
|
|
ret= isoburn_start_emulation(*o, 1);
|
|
|
|
if(ret<=0) {
|
|
|
|
(*o)->emulation_mode= -1;
|
|
|
|
goto ex;
|
|
|
|
}
|
|
|
|
}
|
2008-05-08 14:10:43 +00:00
|
|
|
ret= isoburn_emulate_toc(d, 1|2);
|
|
|
|
if(ret<0)
|
|
|
|
goto ex;
|
2008-05-08 18:53:31 +00:00
|
|
|
if(ret>0) { /* point msc1 to last session */
|
|
|
|
if((*o)->toc!=NULL) {
|
|
|
|
for(t= (*o)->toc; t->next!=NULL; t= t->next);
|
|
|
|
(*o)->fabricated_msc1= t->start_lba;
|
|
|
|
}
|
|
|
|
}
|
2008-05-08 14:10:43 +00:00
|
|
|
}
|
|
|
|
}
|
2008-01-10 15:20:57 +00:00
|
|
|
#ifdef Hardcoded_cd_rW
|
|
|
|
(*o)->nwa= Hardcoded_cd_rw_nwA;
|
|
|
|
#else
|
|
|
|
ret= burn_disc_track_lba_nwa(d, NULL, 0, &lba, &nwa);
|
|
|
|
if(ret>0)
|
|
|
|
(*o)->nwa= nwa;
|
2011-07-07 11:44:45 +00:00
|
|
|
if((*o)->nwa < (*o)->zero_nwa)
|
|
|
|
(*o)->zero_nwa= 0;
|
2008-01-10 15:20:57 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
}
|
2008-05-12 08:13:16 +00:00
|
|
|
|
2008-01-10 15:20:57 +00:00
|
|
|
ret= 1;
|
|
|
|
ex:
|
|
|
|
if(caps!=NULL)
|
|
|
|
burn_disc_free_multi_caps(&caps);
|
|
|
|
return(ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-20 23:48:08 +00:00
|
|
|
/**
|
|
|
|
@param flag bit0= load
|
|
|
|
bit1= regard overwriteable media as blank
|
2008-02-21 18:52:52 +00:00
|
|
|
bit2= if the drive is a regular disk file: truncate it to
|
|
|
|
the write start address
|
2008-05-08 14:10:43 +00:00
|
|
|
bit3= if the drive reports a -ROM profile then try to read
|
|
|
|
table of content by scanning for ISO image headers.
|
|
|
|
(depending on media type and drive state this might
|
|
|
|
help or it might make the resulting toc even worse)
|
2008-10-05 07:55:20 +00:00
|
|
|
bit4= do not emulate TOC on overwriteable media
|
2009-01-21 20:39:00 +00:00
|
|
|
bit5= ignore ACL from external filesystems
|
|
|
|
bit6= ignore POSIX Extended Attributes from external filesystems
|
2009-10-07 07:55:23 +00:00
|
|
|
bit7= pretend -ROM profile and scan for table of content
|
2008-02-20 23:48:08 +00:00
|
|
|
*/
|
|
|
|
int isoburn_drive_aquire(struct burn_drive_info *drive_infos[],
|
|
|
|
char *adr, int flag)
|
2008-01-10 15:20:57 +00:00
|
|
|
{
|
2008-10-05 07:55:20 +00:00
|
|
|
int ret, drive_grabbed= 0;
|
2008-01-10 15:20:57 +00:00
|
|
|
struct isoburn *o= NULL;
|
2008-10-05 07:55:20 +00:00
|
|
|
int conv_ret;
|
2011-05-09 15:49:47 +00:00
|
|
|
char *libburn_drive_adr= NULL;
|
2008-10-05 07:55:20 +00:00
|
|
|
|
2011-05-09 15:49:47 +00:00
|
|
|
/* Should be obsolete by new drive addressing of libburn-0.5.2 */
|
|
|
|
/* but helps with kernel 2.4 to use /dev/sr */
|
|
|
|
libburn_drive_adr= calloc(1, BURN_DRIVE_ADR_LEN);
|
|
|
|
if(libburn_drive_adr == NULL)
|
|
|
|
{ret= -1; goto ex;}
|
2008-01-10 15:20:57 +00:00
|
|
|
conv_ret= burn_drive_convert_fs_adr(adr, libburn_drive_adr);
|
2008-08-09 16:10:50 +00:00
|
|
|
if(conv_ret<=0)
|
|
|
|
strcpy(libburn_drive_adr, adr);
|
2008-10-05 07:55:20 +00:00
|
|
|
|
2011-05-09 15:49:47 +00:00
|
|
|
ret= burn_drive_scan_and_grab(drive_infos, libburn_drive_adr, flag&1);
|
2008-01-10 15:20:57 +00:00
|
|
|
if(ret<=0)
|
|
|
|
goto ex;
|
|
|
|
drive_grabbed= 1;
|
2008-05-08 14:10:43 +00:00
|
|
|
ret= isoburn_welcome_media(&o, (*drive_infos)[0].drive,
|
2009-10-07 07:55:23 +00:00
|
|
|
(flag & (8 | 16 | 32 | 64 | 128)) | !!(flag&2));
|
2008-01-10 15:20:57 +00:00
|
|
|
if(ret<=0)
|
|
|
|
goto ex;
|
|
|
|
|
2008-02-21 18:52:52 +00:00
|
|
|
if(flag&4) {
|
|
|
|
ret= isoburn_find_emulator(&o, (*drive_infos)[0].drive, 0);
|
|
|
|
if(ret>0 && o!=NULL)
|
|
|
|
o->truncate= 1;
|
|
|
|
}
|
|
|
|
|
2008-01-10 15:20:57 +00:00
|
|
|
ret= 1;
|
|
|
|
ex:
|
|
|
|
if(ret<=0) {
|
|
|
|
if(drive_grabbed)
|
|
|
|
burn_drive_release((*drive_infos)[0].drive, 0);
|
|
|
|
isoburn_destroy(&o, 0);
|
|
|
|
}
|
2011-05-09 15:49:47 +00:00
|
|
|
if(libburn_drive_adr != NULL)
|
|
|
|
free(libburn_drive_adr);
|
2008-01-10 15:20:57 +00:00
|
|
|
return(ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-20 23:48:08 +00:00
|
|
|
int isoburn_drive_scan_and_grab(struct burn_drive_info *drive_infos[],
|
|
|
|
char *adr, int load)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret= isoburn_drive_aquire(drive_infos, adr, !!load);
|
|
|
|
return(ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-01-10 15:20:57 +00:00
|
|
|
int isoburn_drive_grab(struct burn_drive *drive, int load)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
struct isoburn *o= NULL;
|
|
|
|
|
|
|
|
ret= burn_drive_grab(drive, load);
|
|
|
|
if(ret<=0)
|
|
|
|
goto ex;
|
|
|
|
ret= isoburn_welcome_media(&o, drive, 0);
|
|
|
|
if(ret<=0)
|
|
|
|
goto ex;
|
|
|
|
|
|
|
|
ret= 1;
|
|
|
|
ex:
|
|
|
|
if(ret<=0)
|
|
|
|
isoburn_destroy(&o,0);
|
|
|
|
return(ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** Retrieve media emulation and eventual isoburn emulator of drive.
|
|
|
|
@return -1 unsuitable media, 0 generic media, 1 emulated media.
|
|
|
|
*/
|
|
|
|
int isoburn_find_emulator(struct isoburn **pt,
|
|
|
|
struct burn_drive *drive, int flag)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret= isoburn_find_by_drive(pt, drive, 0);
|
|
|
|
if(ret<=0)
|
|
|
|
return(0);
|
2008-02-04 18:47:17 +00:00
|
|
|
if((*pt)->emulation_mode==-1) {
|
2008-06-18 16:14:44 +00:00
|
|
|
isoburn_msgs_submit(*pt, 0x00060000,
|
|
|
|
"Unsuitable drive and media state", 0, "FAILURE", 0);
|
2008-01-10 15:20:57 +00:00
|
|
|
return(-1);
|
2008-02-04 18:47:17 +00:00
|
|
|
}
|
2008-01-10 15:20:57 +00:00
|
|
|
if((*pt)->emulation_mode==0)
|
|
|
|
return(0);
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
enum burn_disc_status isoburn_disc_get_status(struct burn_drive *drive)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
struct isoburn *o;
|
|
|
|
|
|
|
|
ret= isoburn_find_emulator(&o, drive, 0);
|
|
|
|
if(ret<0)
|
|
|
|
return(BURN_DISC_UNSUITABLE);
|
|
|
|
if(o!=NULL)
|
|
|
|
if(o->fabricated_disc_status!=BURN_DISC_UNREADY)
|
|
|
|
return(o->fabricated_disc_status);
|
|
|
|
if(ret==0)
|
|
|
|
return(burn_disc_get_status(drive));
|
|
|
|
|
|
|
|
/* emulated status */
|
|
|
|
if(o->emulation_mode==-1)
|
|
|
|
return(BURN_DISC_UNSUITABLE);
|
2008-05-06 14:45:49 +00:00
|
|
|
if(o->nwa>o->zero_nwa)
|
2008-01-10 15:20:57 +00:00
|
|
|
return(BURN_DISC_APPENDABLE);
|
|
|
|
return(BURN_DISC_BLANK);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int isoburn_disc_erasable(struct burn_drive *d)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
struct isoburn *o;
|
|
|
|
|
|
|
|
ret= isoburn_find_emulator(&o, d, 0);
|
|
|
|
if(ret>0)
|
|
|
|
if(o->emulation_mode==1)
|
|
|
|
return(1);
|
|
|
|
return burn_disc_erasable(d);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void isoburn_disc_erase(struct burn_drive *drive, int fast)
|
|
|
|
{
|
2011-03-21 09:31:51 +00:00
|
|
|
int ret, do_pseudo_blank= 0, role;
|
2008-01-10 15:20:57 +00:00
|
|
|
struct isoburn *o;
|
2008-05-13 13:52:33 +00:00
|
|
|
enum burn_disc_status s;
|
2011-05-09 15:49:47 +00:00
|
|
|
char *zero_buffer= NULL;
|
2010-01-17 14:49:12 +00:00
|
|
|
struct burn_multi_caps *caps= NULL;
|
2008-01-10 15:20:57 +00:00
|
|
|
|
2011-05-09 15:49:47 +00:00
|
|
|
zero_buffer= calloc(1, Libisoburn_target_head_sizE);
|
|
|
|
if(zero_buffer == NULL) {
|
|
|
|
/* To cause a negative reply with burn_drive_wrote_well() */
|
|
|
|
burn_drive_cancel(drive);
|
|
|
|
goto ex;
|
|
|
|
}
|
|
|
|
|
2008-01-10 15:20:57 +00:00
|
|
|
ret= isoburn_find_emulator(&o, drive, 0);
|
|
|
|
if(ret>0) {
|
|
|
|
if(o->emulation_mode==-1) {
|
|
|
|
/* To cause a negative reply with burn_drive_wrote_well() */
|
|
|
|
burn_drive_cancel(drive);
|
2010-01-17 14:49:12 +00:00
|
|
|
goto ex;
|
|
|
|
}
|
2011-03-22 08:13:59 +00:00
|
|
|
role = burn_drive_get_drive_role(drive);
|
|
|
|
if (role == 5) {
|
|
|
|
/* libburn will truncate the random-access write-only file
|
|
|
|
to zero size and change its state */
|
|
|
|
burn_disc_erase(drive, fast);
|
|
|
|
o->fabricated_disc_status= burn_disc_get_status(drive);
|
2011-07-07 11:44:45 +00:00
|
|
|
o->nwa= o->zero_nwa= 0;
|
2011-03-22 08:13:59 +00:00
|
|
|
goto ex;
|
|
|
|
}
|
2010-01-17 14:49:12 +00:00
|
|
|
if(o->emulation_mode > 0) { /* might be readonly with emulated sessions */
|
|
|
|
ret= burn_disc_get_multi_caps(drive, BURN_WRITE_NONE, &caps, 0);
|
|
|
|
if(ret > 0 && caps->start_adr)
|
|
|
|
do_pseudo_blank= 1;
|
2008-01-10 15:20:57 +00:00
|
|
|
}
|
2010-01-17 14:49:12 +00:00
|
|
|
if(do_pseudo_blank) {
|
2008-05-13 13:52:33 +00:00
|
|
|
s= isoburn_disc_get_status(drive);
|
|
|
|
if(s==BURN_DISC_FULL) { /* unknown data format in first 64 kB */
|
|
|
|
memset(zero_buffer, 0, Libisoburn_target_head_sizE);
|
|
|
|
ret= burn_random_access_write(drive, (off_t) 0, zero_buffer,
|
|
|
|
(off_t) Libisoburn_target_head_sizE, 1);
|
|
|
|
} else {
|
|
|
|
ret= isoburn_invalidate_iso(o, 0);
|
|
|
|
}
|
2008-01-10 15:20:57 +00:00
|
|
|
if(ret<=0)
|
2008-05-13 13:52:33 +00:00
|
|
|
burn_drive_cancel(drive); /* mark run as failure */
|
2010-01-17 14:49:12 +00:00
|
|
|
goto ex;
|
2008-01-10 15:20:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
burn_disc_erase(drive, fast);
|
2010-01-17 14:49:12 +00:00
|
|
|
ex:;
|
|
|
|
if(caps!=NULL)
|
|
|
|
burn_disc_free_multi_caps(&caps);
|
2011-05-09 15:49:47 +00:00
|
|
|
if(zero_buffer != NULL)
|
|
|
|
free(zero_buffer);
|
2008-01-10 15:20:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-09 10:08:40 +00:00
|
|
|
off_t isoburn_disc_available_space(struct burn_drive *d,
|
|
|
|
struct burn_write_opts *opts)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
struct isoburn *o;
|
2008-04-20 11:15:07 +00:00
|
|
|
struct burn_write_opts *eff_opts= NULL, *local_opts= NULL;
|
2008-05-13 13:52:33 +00:00
|
|
|
enum burn_disc_status s;
|
2008-02-09 10:08:40 +00:00
|
|
|
off_t avail;
|
|
|
|
|
2008-04-20 11:15:07 +00:00
|
|
|
eff_opts= opts;
|
2008-02-09 10:08:40 +00:00
|
|
|
ret= isoburn_find_emulator(&o, d, 0);
|
|
|
|
if(ret>0 && o!=NULL)
|
2008-04-20 11:15:07 +00:00
|
|
|
if(o->emulation_mode!=0) {
|
2008-05-13 13:52:33 +00:00
|
|
|
s= isoburn_disc_get_status(d);
|
|
|
|
if(s==BURN_DISC_FULL) /* unknown data format in first 64 kB */
|
|
|
|
return((off_t) 0);
|
2008-04-20 11:15:07 +00:00
|
|
|
local_opts= burn_write_opts_new(d);
|
|
|
|
eff_opts= local_opts;
|
|
|
|
burn_write_opts_set_start_byte(eff_opts, ((off_t) o->nwa) * (off_t) 2048);
|
|
|
|
}
|
|
|
|
avail= burn_disc_available_space(d, eff_opts);
|
|
|
|
if(local_opts!=NULL)
|
|
|
|
burn_write_opts_free(local_opts);
|
|
|
|
local_opts= NULL;
|
2008-02-09 10:08:40 +00:00
|
|
|
return(avail);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-01-10 15:20:57 +00:00
|
|
|
int isoburn_disc_get_msc1(struct burn_drive *d, int *start_lba)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
struct isoburn *o;
|
|
|
|
|
|
|
|
#ifdef Hardcoded_cd_rW
|
|
|
|
/* <<< A70929 : hardcoded CD-RW with fabricated -msinfo */
|
|
|
|
*start_lba= Hardcoded_cd_rw_c1;
|
|
|
|
return(1);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if(isoburn_disc_get_status(d)!=BURN_DISC_APPENDABLE &&
|
2008-02-04 18:47:17 +00:00
|
|
|
isoburn_disc_get_status(d)!=BURN_DISC_FULL) {
|
2008-06-18 16:14:44 +00:00
|
|
|
isoburn_msgs_submit(NULL, 0x00060000,
|
|
|
|
"Media contains no recognizable data", 0, "SORRY", 0);
|
2008-01-10 15:20:57 +00:00
|
|
|
return(0);
|
2008-02-04 18:47:17 +00:00
|
|
|
}
|
2008-01-10 15:20:57 +00:00
|
|
|
ret= isoburn_find_emulator(&o, d, 0);
|
|
|
|
if(ret<0)
|
|
|
|
return(0);
|
2008-05-08 18:53:31 +00:00
|
|
|
if(o->fabricated_msc1>=0) {
|
|
|
|
*start_lba= o->fabricated_msc1;
|
|
|
|
return(1);
|
|
|
|
}
|
2008-01-10 15:20:57 +00:00
|
|
|
if(ret>0) if(o->emulation_mode>0) {
|
|
|
|
*start_lba= 0;
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
return(burn_disc_get_msc1(d, start_lba));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int isoburn_disc_track_lba_nwa(struct burn_drive *d,
|
|
|
|
struct burn_write_opts *opts,
|
|
|
|
int trackno, int *lba, int *nwa)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
struct isoburn *o;
|
2011-07-31 09:18:56 +00:00
|
|
|
enum burn_disc_status s;
|
2008-01-10 15:20:57 +00:00
|
|
|
|
|
|
|
#ifdef Hardcoded_cd_rW
|
|
|
|
/* <<< A70929 : hardcoded CD-RW with fabricated -msinfo */
|
|
|
|
*lba= Hardcoded_cd_rw_c1;
|
|
|
|
*nwa= Hardcoded_cd_rw_nwA;
|
|
|
|
return(1);
|
|
|
|
#endif
|
|
|
|
|
2008-01-20 10:30:43 +00:00
|
|
|
*nwa= *lba= 0;
|
2008-01-10 15:20:57 +00:00
|
|
|
ret= isoburn_find_emulator(&o, d, 0);
|
|
|
|
if(ret<0)
|
|
|
|
return(0);
|
|
|
|
if(ret>0) if(o->emulation_mode>0) {
|
|
|
|
*lba= 0;
|
|
|
|
*nwa= o->nwa;
|
|
|
|
return(1);
|
|
|
|
}
|
2008-01-20 10:30:43 +00:00
|
|
|
if(burn_drive_get_drive_role(d) != 1)
|
|
|
|
return(1);
|
2011-07-31 09:18:56 +00:00
|
|
|
|
|
|
|
s= isoburn_disc_get_status(d);
|
|
|
|
if(s == BURN_DISC_BLANK) /* We do not believe in anything but nwa = lba = 0 */
|
|
|
|
return(1);
|
2008-01-10 15:20:57 +00:00
|
|
|
return(burn_disc_track_lba_nwa(d, opts, trackno, lba, nwa));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-07-05 13:25:06 +00:00
|
|
|
int isoburn_get_msc2(struct isoburn *o,
|
|
|
|
struct burn_write_opts *opts, int *msc2, int flag)
|
|
|
|
{
|
|
|
|
int ret, lba, nwa;
|
|
|
|
|
|
|
|
if(o->fabricated_msc2>=0)
|
|
|
|
*msc2= o->fabricated_msc2;
|
|
|
|
else {
|
|
|
|
ret= isoburn_disc_track_lba_nwa(o->drive, opts, 0, &lba, &nwa);
|
|
|
|
if(ret<=0)
|
|
|
|
return(ret);
|
|
|
|
*msc2= nwa;
|
|
|
|
}
|
|
|
|
return(1);
|
|
|
|
}
|
|