|
|
|
|
|
|
|
|
|
|
|
/* Adapter to libisoburn, libisofs and libburn for xorriso,
|
|
|
|
a command line oriented batch and dialog tool which creates, loads,
|
|
|
|
manipulates and burns ISO 9660 filesystem images.
|
|
|
|
|
|
|
|
Copyright 2007-2008 Thomas Schmitt, <scdbackup@gmx.net>
|
|
|
|
|
|
|
|
Provided under GPL version 2.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <time.h>
|
|
|
|
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------ */
|
|
|
|
|
|
|
|
#ifndef Xorriso_standalonE
|
|
|
|
|
|
|
|
/* The library which does the ISO 9660 / RockRidge manipulations */
|
|
|
|
#include <libisofs/libisofs.h>
|
|
|
|
|
|
|
|
/* The library which does MMC optical drive operations */
|
|
|
|
#include <libburn/libburn.h>
|
|
|
|
|
|
|
|
/* The library which enhances overwriteable media with ISO 9660 multi-session
|
|
|
|
capabilities via the method invented by Andy Polyakov for growisofs */
|
|
|
|
#include <libisoburn/libisoburn.h>
|
|
|
|
|
|
|
|
/* The official xorriso options API. "No shortcuts" */
|
|
|
|
#include "xorriso.h"
|
|
|
|
|
|
|
|
/* The inner description of XorrisO */
|
|
|
|
#include "xorriso_private.h"
|
|
|
|
|
|
|
|
/* The inner isofs- and burn-library interface */
|
|
|
|
#include "xorrisoburn.h"
|
|
|
|
|
|
|
|
#else /* ! Xorriso_standalonE */
|
|
|
|
|
|
|
|
#include "../libisofs/libisofs.h"
|
|
|
|
#include "../libburn/libburn.h"
|
|
|
|
#include "../libisoburn/libisoburn.h"
|
|
|
|
#include "xorriso.h"
|
|
|
|
#include "xorriso_private.h"
|
|
|
|
#include "xorrisoburn.h"
|
|
|
|
|
|
|
|
#endif /* Xorriso_standalonE */
|
|
|
|
|
|
|
|
|
|
|
|
int Xorriso_pacifier_loop(struct XorrisO *xorriso, struct burn_drive *drive,
|
|
|
|
int flag);
|
|
|
|
|
|
|
|
int Xorriso__read_pacifier(IsoImage *image, IsoFileSource *filesource);
|
|
|
|
|
|
|
|
|
|
|
|
#define LIBISO_ISDIR(node) (iso_node_get_type(node) == LIBISO_DIR)
|
|
|
|
#define LIBISO_ISREG(node) (iso_node_get_type(node) == LIBISO_FILE)
|
|
|
|
#define LIBISO_ISLNK(node) (iso_node_get_type(node) == LIBISO_SYMLINK)
|
|
|
|
#define LIBISO_ISCHR(node) (iso_node_get_type(node) == LIBISO_SPECIAL && \
|
|
|
|
S_ISCHR(iso_node_get_mode(node)))
|
|
|
|
#define LIBISO_ISBLK(node) (iso_node_get_type(node) == LIBISO_SPECIAL && \
|
|
|
|
S_ISBLK(iso_node_get_mode(node)))
|
|
|
|
#define LIBISO_ISFIFO(node) (iso_node_get_type(node) == LIBISO_SPECIAL && \
|
|
|
|
S_ISFIFO(iso_node_get_mode(node)))
|
|
|
|
#define LIBISO_ISSOCK(node) (iso_node_get_type(node) == LIBISO_SPECIAL && \
|
|
|
|
S_ISSOCK(iso_node_get_mode(node)))
|
|
|
|
|
|
|
|
/* CD specs say one shall not write tracks < 600 kiB */
|
|
|
|
#define Xorriso_cd_min_track_sizE 300
|
|
|
|
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------ */
|
|
|
|
|
|
|
|
|
|
|
|
int Xorriso_startup_libraries(struct XorrisO *xorriso, int flag)
|
|
|
|
{
|
|
|
|
int ret, major, minor, micro;
|
|
|
|
char *handler_prefix= NULL;
|
|
|
|
char *queue_sev, *print_sev, reason[1024];
|
|
|
|
|
|
|
|
|
|
|
|
/* First an ugly compile time check for header version compatibility.
|
|
|
|
If everthing matches, then no C code is produced. In case of mismatch,
|
|
|
|
intentionally faulty C code will be inserted.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* The minimum requirement of xorriso towards the libisoburn header
|
|
|
|
at compile time is defined in xorriso/xorrisoburn.h
|
|
|
|
xorriso_libisoburn_req_major
|
|
|
|
xorriso_libisoburn_req_minor
|
|
|
|
xorriso_libisoburn_req_micro
|
|
|
|
It gets compared against the version macros in libburn/libburn.h :
|
|
|
|
isoburn_header_version_major
|
|
|
|
isoburn_header_version_minor
|
|
|
|
isoburn_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: 'LIBISOBURN_MISCONFIGURATION' undeclared (first use in this function)
|
|
|
|
error: 'INTENTIONAL_ABORT_OF_COMPILATION__HEADERFILE_libisoburn_dot_h_TOO_OLD__SEE_xorrisoburn_dot_c' undeclared (first use in this function)
|
|
|
|
error: 'LIBISOBURN_MISCONFIGURATION_' undeclared (first use in this function)
|
|
|
|
*/
|
|
|
|
/* The indendation is an advise of man gcc to help old compilers ignoring */
|
|
|
|
#if xorriso_libisoburn_req_major > isoburn_header_version_major
|
|
|
|
#define Isoburn_libisoburn_dot_h_too_olD 1
|
|
|
|
#endif
|
|
|
|
#if xorriso_libisoburn_req_major == isoburn_header_version_major && xorriso_libisoburn_req_minor > isoburn_header_version_minor
|
|
|
|
#define Isoburn_libisoburn_dot_h_too_olD 1
|
|
|
|
#endif
|
|
|
|
#if xorriso_libisoburn_req_minor == isoburn_header_version_minor && xorriso_libisoburn_req_micro > isoburn_header_version_micro
|
|
|
|
#define Isoburn_libisoburn_dot_h_too_olD 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef Isoburn_libisoburn_dot_h_too_olD
|
|
|
|
LIBISOBURN_MISCONFIGURATION = 0;
|
|
|
|
INTENTIONAL_ABORT_OF_COMPILATION__HEADERFILE_libisoburn_dot_h_TOO_OLD__SEE_xorrisoburn_dot_c = 0;
|
|
|
|
LIBISOBURN_MISCONFIGURATION_ = 0;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* End of ugly compile time test (scroll up for explanation) */
|
|
|
|
|
|
|
|
|
|
|
|
sprintf(xorriso->info_text, "Starting up libraries ...\n");
|
|
|
|
Xorriso_info(xorriso, 0);
|
|
|
|
|
|
|
|
handler_prefix= calloc(strlen(xorriso->progname)+3+1, 1);
|
|
|
|
if(handler_prefix==NULL) {
|
|
|
|
sprintf(xorriso->info_text,
|
|
|
|
"Cannot allocate memory for initializing libraries");
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
|
|
|
|
return(-1);
|
|
|
|
}
|
|
|
|
reason[0]= 0;
|
|
|
|
ret= isoburn_initialize(reason, 0);
|
|
|
|
if(ret==0) {
|
|
|
|
sprintf(xorriso->info_text, "Cannot initialize libraries");
|
|
|
|
if(reason[0])
|
|
|
|
sprintf(xorriso->info_text+strlen(xorriso->info_text),
|
|
|
|
". Reason given:\n%s", reason);
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
|
|
|
|
free(handler_prefix);
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
ret= isoburn_is_compatible(isoburn_header_version_major,
|
|
|
|
isoburn_header_version_minor,
|
|
|
|
isoburn_header_version_micro, 0);
|
|
|
|
if(ret<=0) {
|
|
|
|
isoburn_version(&major, &minor, µ);
|
|
|
|
sprintf(xorriso->info_text,
|
|
|
|
"libisoburn version too old: %d.%d.%d . Need at least: %d.%d.%d .\n",
|
|
|
|
major, minor, micro,
|
|
|
|
isoburn_header_version_major, isoburn_header_version_minor,
|
|
|
|
isoburn_header_version_micro);
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
|
|
|
|
return(-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
xorriso->libs_are_started= 1;
|
|
|
|
|
|
|
|
queue_sev= "DEBUG";
|
|
|
|
if(xorriso->library_msg_direct_print) {
|
|
|
|
|
|
|
|
/* >>> need option for controlling this in XorrisO.
|
|
|
|
See also Xorriso_msgs_submit */;
|
|
|
|
|
|
|
|
print_sev= xorriso->report_about_text;
|
|
|
|
} else
|
|
|
|
print_sev= "NEVER";
|
|
|
|
|
|
|
|
iso_set_msgs_severities(queue_sev, print_sev, "libsofs : ");
|
|
|
|
burn_msgs_set_severities(queue_sev, print_sev, "libburn : ");
|
|
|
|
|
|
|
|
/* ??? >>> do we want united queues ? */
|
|
|
|
/* burn_set_messenger(iso_get_messenger()); */
|
|
|
|
|
|
|
|
sprintf(handler_prefix, "%s : ", xorriso->progname);
|
|
|
|
burn_set_signal_handling(handler_prefix, NULL, 0);
|
|
|
|
|
|
|
|
Xorriso_process_msg_queues(xorriso,0);
|
|
|
|
if(reason[0]) {
|
|
|
|
sprintf(xorriso->info_text, "%s", reason);
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
sprintf(xorriso->info_text, "Library startup done.\n");
|
|
|
|
Xorriso_info(xorriso, 0);
|
|
|
|
free(handler_prefix);
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* @param flag bit0= global shutdown of libraries */
|
|
|
|
int Xorriso_detach_libraries(struct XorrisO *xorriso, int flag)
|
|
|
|
{
|
|
|
|
Xorriso_give_up_drive(xorriso, 3);
|
|
|
|
if(xorriso->in_volset_handle!=NULL) { /* standalone image */
|
|
|
|
iso_image_unref((IsoImage *) xorriso->in_volset_handle);
|
|
|
|
xorriso->in_volset_handle= NULL;
|
|
|
|
}
|
|
|
|
if(flag&1) {
|
|
|
|
if(xorriso->libs_are_started==0)
|
|
|
|
return(0);
|
|
|
|
isoburn_finish();
|
|
|
|
}
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* @param flag bit1= obtain outdrive, else indrive */
|
|
|
|
int Xorriso_get_drive_handles(struct XorrisO *xorriso,
|
|
|
|
struct burn_drive_info **dinfo,
|
|
|
|
struct burn_drive **drive,
|
|
|
|
char *attempt, int flag)
|
|
|
|
{
|
|
|
|
if(flag&2)
|
|
|
|
*dinfo= (struct burn_drive_info *) xorriso->out_drive_handle;
|
|
|
|
else
|
|
|
|
*dinfo= (struct burn_drive_info *) xorriso->in_drive_handle;
|
|
|
|
if(*dinfo==NULL) {
|
|
|
|
Xorriso_process_msg_queues(xorriso,0);
|
|
|
|
sprintf(xorriso->info_text, "No %s drive aquired %s",
|
|
|
|
(flag&2 ? "output" : "input"), attempt);
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
*drive= (*dinfo)[0].drive;
|
|
|
|
return((*drive)!=NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* <<< to be replaced by libburn-0.4.3 API call burn_sev_to_text().
|
|
|
|
This is a copy of libdax_msgs__sev_to_text() which is not exposed
|
|
|
|
by the API of of libburn-0.4.2 . As soon as xorriso gets based on
|
|
|
|
libburn-0.4.4 this redundancy is to be removed.
|
|
|
|
It is safe, nevertheless, because the severity codes are eternal.
|
|
|
|
*/
|
|
|
|
#define LIBDAX_MSGS_SEV_ALL 0x00000000
|
|
|
|
#define LIBDAX_MSGS_SEV_DEBUG 0x10000000
|
|
|
|
#define LIBDAX_MSGS_SEV_UPDATE 0x20000000
|
|
|
|
#define LIBDAX_MSGS_SEV_NOTE 0x30000000
|
|
|
|
#define LIBDAX_MSGS_SEV_HINT 0x40000000
|
|
|
|
#define LIBDAX_MSGS_SEV_WARNING 0x50000000
|
|
|
|
#define LIBDAX_MSGS_SEV_SORRY 0x60000000
|
|
|
|
#define LIBDAX_MSGS_SEV_FAILURE 0x68000000
|
|
|
|
#define LIBDAX_MSGS_SEV_FATAL 0x70000000
|
|
|
|
#define LIBDAX_MSGS_SEV_ABORT 0x71000000
|
|
|
|
#define LIBDAX_MSGS_SEV_NEVER 0x7fffffff
|
|
|
|
|
|
|
|
int Xorriso__sev_to_text(int severity, char **severity_name,
|
|
|
|
int flag)
|
|
|
|
{
|
|
|
|
if(flag&1) {
|
|
|
|
*severity_name= "NEVER\nABORT\nFATAL\nFAILURE\nSORRY\nWARNING\nHINT\nNOTE\nUPDATE\nDEBUG\nALL";
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
*severity_name= "";
|
|
|
|
if(severity>=LIBDAX_MSGS_SEV_NEVER)
|
|
|
|
*severity_name= "NEVER";
|
|
|
|
else if(severity>=LIBDAX_MSGS_SEV_ABORT)
|
|
|
|
*severity_name= "ABORT";
|
|
|
|
else if(severity>=LIBDAX_MSGS_SEV_FATAL)
|
|
|
|
*severity_name= "FATAL";
|
|
|
|
else if(severity>=LIBDAX_MSGS_SEV_FAILURE)
|
|
|
|
*severity_name= "FAILURE";
|
|
|
|
else if(severity>=LIBDAX_MSGS_SEV_SORRY)
|
|
|
|
*severity_name= "SORRY";
|
|
|
|
else if(severity>=LIBDAX_MSGS_SEV_WARNING)
|
|
|
|
*severity_name= "WARNING";
|
|
|
|
else if(severity>=LIBDAX_MSGS_SEV_HINT)
|
|
|
|
*severity_name= "HINT";
|
|
|
|
else if(severity>=LIBDAX_MSGS_SEV_NOTE)
|
|
|
|
*severity_name= "NOTE";
|
|
|
|
else if(severity>=LIBDAX_MSGS_SEV_UPDATE)
|
|
|
|
*severity_name= "UPDATE";
|
|
|
|
else if(severity>=LIBDAX_MSGS_SEV_DEBUG)
|
|
|
|
*severity_name= "DEBUG";
|
|
|
|
else if(severity>=LIBDAX_MSGS_SEV_ALL)
|
|
|
|
*severity_name= "ALL";
|
|
|
|
else {
|
|
|
|
*severity_name= "";
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* @param flag bit0=report libisofs error text */
|
|
|
|
int Xorriso_report_iso_error(struct XorrisO *xorriso, char *victim,
|
|
|
|
int iso_error_code, char msg_text[], int os_errno,
|
|
|
|
char min_severity[], int flag)
|
|
|
|
{
|
|
|
|
int error_code, iso_sev, min_sev, ret;
|
|
|
|
char *sev_text_pt, *msg_text_pt= NULL;
|
|
|
|
char sfe[6*SfileadrL];
|
|
|
|
|
|
|
|
error_code= iso_error_get_code(iso_error_code);
|
|
|
|
if(error_code < 0x00030000 || error_code >= 0x00040000)
|
|
|
|
error_code= (error_code & 0xffff) | 0x00050000;
|
|
|
|
|
|
|
|
if(flag&1)
|
|
|
|
msg_text_pt= (char *) iso_error_to_msg(iso_error_code);
|
|
|
|
if(msg_text_pt==NULL)
|
|
|
|
msg_text_pt= msg_text;
|
|
|
|
iso_sev= iso_error_get_severity(iso_error_code);
|
|
|
|
sev_text_pt= min_severity;
|
|
|
|
burn_text_to_sev(min_severity, &min_sev, 0);
|
|
|
|
if(min_sev < iso_sev)
|
|
|
|
/* >>> with libburn-0.4.4 do: burn_sev_to_text(iso_sev, &sev_text_pt, 0); */
|
|
|
|
Xorriso__sev_to_text(iso_sev, &sev_text_pt, 0);
|
|
|
|
strcpy(sfe, msg_text_pt);
|
|
|
|
if(victim[0]) {
|
|
|
|
strcat(sfe, ": ");
|
|
|
|
Text_shellsafe(victim, sfe+strlen(sfe), 0);
|
|
|
|
}
|
|
|
|
ret= Xorriso_msgs_submit(xorriso, error_code, sfe, os_errno, sev_text_pt, 4);
|
|
|
|
return(ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* @param flag bit0= suppress DEBUG messages */
|
|
|
|
int Xorriso_set_image_severities(struct XorrisO *xorriso, int flag)
|
|
|
|
{
|
|
|
|
char *queue_sev, *print_sev;
|
|
|
|
|
|
|
|
if(flag&1)
|
|
|
|
queue_sev= "UPDATE";
|
|
|
|
else
|
|
|
|
queue_sev= "DEBUG";
|
|
|
|
if(xorriso->library_msg_direct_print)
|
|
|
|
print_sev= xorriso->report_about_text;
|
|
|
|
else
|
|
|
|
print_sev= "NEVER";
|
|
|
|
iso_set_msgs_severities(queue_sev, print_sev, "libisofs : ");
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int Xorriso_update_volid(struct XorrisO *xorriso, int flag)
|
|
|
|
{
|
|
|
|
int gret, sret= 1;
|
|
|
|
|
|
|
|
gret= Xorriso_get_volid(xorriso, xorriso->loaded_volid, 0);
|
|
|
|
if(gret>0 && strcmp(xorriso->volid, "ISOIMAGE")==0)
|
|
|
|
strcpy(xorriso->volid, xorriso->loaded_volid);
|
|
|
|
else
|
|
|
|
sret= Xorriso_set_volid(xorriso, xorriso->volid, 1);
|
|
|
|
return(gret>0 && sret>0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int Xorriso_create_empty_iso(struct XorrisO *xorriso, int flag)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
IsoImage *volset;
|
|
|
|
struct isoburn_read_opts *ropts;
|
|
|
|
struct burn_drive_info *dinfo= NULL;
|
|
|
|
struct burn_drive *drive= NULL;
|
|
|
|
|
|
|
|
if(xorriso->out_drive_handle != NULL) {
|
|
|
|
ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive,
|
|
|
|
"on attempt to attach volset to drive", 2);
|
|
|
|
if(ret<=0)
|
|
|
|
return(ret);
|
|
|
|
}
|
|
|
|
if(xorriso->in_volset_handle!=NULL) {
|
|
|
|
iso_image_unref((IsoImage *) xorriso->in_volset_handle);
|
|
|
|
xorriso->in_volset_handle= NULL;
|
|
|
|
xorriso->loaded_volid[0]= 0;
|
|
|
|
xorriso->volset_change_pending= 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret= isoburn_ropt_new(&ropts, 0);
|
|
|
|
if(ret<=0)
|
|
|
|
return(ret);
|
|
|
|
/* Note: no return before isoburn_ropt_destroy() */
|
|
|
|
isoburn_ropt_set_extensions(ropts, isoburn_ropt_pretend_blank);
|
|
|
|
isoburn_ropt_set_input_charset(ropts, NULL);
|
|
|
|
isoburn_set_read_pacifier(drive, NULL, NULL);
|
|
|
|
ret= isoburn_read_image(drive, ropts, &volset);
|
|
|
|
Xorriso_process_msg_queues(xorriso,0);
|
|
|
|
isoburn_ropt_destroy(&ropts, 0);
|
|
|
|
if(ret<=0) {
|
|
|
|
sprintf(xorriso->info_text, "Failed to create new empty ISO image object");
|
|
|
|
Xorriso_report_iso_error(xorriso, "", ret, xorriso->info_text, 0, "FATAL",
|
|
|
|
0);
|
|
|
|
return(-1);
|
|
|
|
}
|
|
|
|
xorriso->in_volset_handle= (void *) volset;
|
|
|
|
Xorriso_update_volid(xorriso, 0);
|
|
|
|
xorriso->volset_change_pending= 0;
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* @param flag bit0=aquire as isoburn input drive
|
|
|
|
bit1=aquire as libburn output drive (as isoburn drive if bit0)
|
|
|
|
@return <=0 failure , 1= ok
|
|
|
|
2=success, but not writeable with bit1
|
|
|
|
3=success, but not blank and not ISO with bit0
|
|
|
|
*/
|
|
|
|
int Xorriso_aquire_drive(struct XorrisO *xorriso, char *adr, int flag)
|
|
|
|
{
|
|
|
|
int ret, hret, not_writeable= 0;
|
|
|
|
struct burn_drive_info *dinfo= NULL, *out_dinfo, *in_dinfo;
|
|
|
|
struct burn_drive *drive, *out_drive, *in_drive;
|
|
|
|
enum burn_disc_status state;
|
|
|
|
IsoImage *volset = NULL;
|
|
|
|
struct isoburn_read_opts *ropts= NULL;
|
|
|
|
char adr_data[SfileadrL], *libburn_adr;
|
|
|
|
|
|
|
|
if((flag&3)==0) {
|
|
|
|
sprintf(xorriso->info_text,
|
|
|
|
"XORRISOBURN program error : Xorriso_aquire_drive bit0+bit1 not set");
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
ret= Xorriso_give_up_drive(xorriso, (flag&3)|8);
|
|
|
|
if(ret<=0)
|
|
|
|
return(ret);
|
|
|
|
|
|
|
|
libburn_adr= adr;
|
|
|
|
if(strcmp(adr,"stdio:/dev/fd/1")==0) {
|
|
|
|
if(xorriso->dev_fd_1<0) {
|
|
|
|
sprintf(xorriso->info_text,
|
|
|
|
"\"stdio:/dev/fd/1\" was not a start argument. stdout possibly already tainted.");
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
|
|
|
|
{ret= 0; goto ex;}
|
|
|
|
} else {
|
|
|
|
sprintf(adr_data, "stdio:/dev/fd/%d", xorriso->dev_fd_1);
|
|
|
|
libburn_adr= adr_data;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if((flag&3)==1 && xorriso->out_drive_handle!=NULL) {
|
|
|
|
ret= Xorriso_get_drive_handles(xorriso, &out_dinfo, &out_drive,
|
|
|
|
"on attempt to compare new indev with outdev", 2);
|
|
|
|
if(ret<=0)
|
|
|
|
goto ex;
|
|
|
|
ret= burn_drive_equals_adr(out_drive, libburn_adr, 1);
|
|
|
|
if(ret==1)
|
|
|
|
dinfo= out_dinfo;
|
|
|
|
} else if((flag&3)==2 && xorriso->in_drive_handle!=NULL) {
|
|
|
|
ret= Xorriso_get_drive_handles(xorriso, &in_dinfo, &in_drive,
|
|
|
|
"on attempt to compare new indev with outdev", 0);
|
|
|
|
if(ret<=0)
|
|
|
|
goto ex;
|
|
|
|
ret= burn_drive_equals_adr(in_drive, libburn_adr, 1);
|
|
|
|
if(ret==1)
|
|
|
|
dinfo= in_dinfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(dinfo==NULL) {
|
|
|
|
ret= isoburn_drive_scan_and_grab(&dinfo, libburn_adr, 1);
|
|
|
|
Xorriso_process_msg_queues(xorriso,0);
|
|
|
|
if(ret<=0) {
|
|
|
|
sprintf(xorriso->info_text,"Cannot aquire drive '%s'", adr);
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
drive= dinfo[0].drive;
|
|
|
|
state= isoburn_disc_get_status(drive);
|
|
|
|
Xorriso_process_msg_queues(xorriso,0);
|
|
|
|
if(flag&1) {
|
|
|
|
volset= isoburn_get_attached_image(drive);
|
|
|
|
if(volset != NULL) { /* The image object is already created */
|
|
|
|
iso_image_unref(volset);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(flag&2) {
|
|
|
|
xorriso->out_drive_handle= dinfo;
|
|
|
|
if(Sfile_str(xorriso->outdev, adr, 0)<=0)
|
|
|
|
return(-1);
|
|
|
|
if(state != BURN_DISC_BLANK && state != BURN_DISC_APPENDABLE) {
|
|
|
|
sprintf(xorriso->info_text, "Disc status unsuitable for writing");
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0);
|
|
|
|
not_writeable= 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(flag&1) {
|
|
|
|
xorriso->in_drive_handle= dinfo;
|
|
|
|
if(Sfile_str(xorriso->indev, adr, 0)<=0)
|
|
|
|
return(-1);
|
|
|
|
} else if(flag&2) {
|
|
|
|
if(xorriso->in_volset_handle==NULL) {
|
|
|
|
/* No volume loaded: create empty one */
|
|
|
|
ret= Xorriso_create_empty_iso(xorriso, 0);
|
|
|
|
if(ret<=0)
|
|
|
|
return(ret);
|
|
|
|
} else {
|
|
|
|
iso_image_ref((IsoImage *) xorriso->in_volset_handle);
|
|
|
|
ret= isoburn_attach_image(drive, (IsoImage *) xorriso->in_volset_handle);
|
|
|
|
if(ret<=0) {
|
|
|
|
sprintf(xorriso->info_text,
|
|
|
|
"Failed to attach ISO image object to outdev");
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
|
|
|
|
return(-1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Xorriso_toc(xorriso, 1|2);
|
|
|
|
return(1+not_writeable);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(xorriso->in_volset_handle!=NULL)
|
|
|
|
iso_image_unref((IsoImage *) xorriso->in_volset_handle);
|
|
|
|
xorriso->in_volset_handle= NULL;
|
|
|
|
|
|
|
|
/* check for invalid state */
|
|
|
|
if(state != BURN_DISC_BLANK && state != BURN_DISC_APPENDABLE &&
|
|
|
|
state != BURN_DISC_FULL) {
|
|
|
|
sprintf(xorriso->info_text,
|
|
|
|
"Disc status not blank and unsuitable for reading");
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
/* fill read opts */
|
|
|
|
ret= isoburn_ropt_new(&ropts, 0);
|
|
|
|
if(ret<=0)
|
|
|
|
return(ret);
|
|
|
|
isoburn_ropt_set_extensions(ropts, isoburn_ropt_noiso1999);
|
|
|
|
isoburn_ropt_set_default_perms(ropts, (uid_t) 0, (gid_t) 0, (mode_t) 0555);
|
|
|
|
isoburn_ropt_set_input_charset(ropts, NULL);
|
|
|
|
|
|
|
|
#ifdef NIX
|
|
|
|
memset(&ropts, sizeof(ropts), 0);
|
|
|
|
ropts.norock= 0;
|
|
|
|
ropts.nojoliet= 0;
|
|
|
|
ropts.noiso1999= 1;
|
|
|
|
ropts.preferjoliet= 0;
|
|
|
|
ropts.uid= 0;
|
|
|
|
ropts.gid= 0;
|
|
|
|
ropts.mode= 0555;
|
|
|
|
ropts.input_charset= NULL;
|
|
|
|
ropts.pretend_blank= 0;
|
|
|
|
#endif /* NIX */
|
|
|
|
|
|
|
|
Xorriso_set_image_severities(xorriso, 1); /* No DEBUG messages */
|
|
|
|
Xorriso_pacifier_reset(xorriso, 0);
|
|
|
|
isoburn_set_read_pacifier(drive, Xorriso__read_pacifier, (void *) xorriso);
|
|
|
|
if(isoburn_read_image(drive, ropts, &volset) <= 0) {
|
|
|
|
Xorriso_process_msg_queues(xorriso,0);
|
|
|
|
Xorriso_set_image_severities(xorriso, 0);
|
|
|
|
sprintf(xorriso->info_text,"Cannot read ISO image volset");
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
|
|
|
|
ret= 3; goto ex;
|
|
|
|
}
|
|
|
|
xorriso->in_volset_handle= (void *) volset;
|
|
|
|
Xorriso_set_image_severities(xorriso, 0);
|
|
|
|
Xorriso_update_volid(xorriso, 0);
|
|
|
|
|
|
|
|
if(xorriso->out_drive_handle != NULL &&
|
|
|
|
xorriso->out_drive_handle != xorriso->in_drive_handle) {
|
|
|
|
ret= Xorriso_get_drive_handles(xorriso, &out_dinfo, &out_drive,
|
|
|
|
"on attempt to attach ISO image volset to outdev", 2);
|
|
|
|
if(ret<=0)
|
|
|
|
goto ex;
|
|
|
|
iso_image_ref((IsoImage *) xorriso->in_volset_handle);
|
|
|
|
isoburn_attach_image(out_drive, xorriso->in_volset_handle);
|
|
|
|
}
|
|
|
|
Xorriso_process_msg_queues(xorriso,0);
|
|
|
|
Xorriso_toc(xorriso, 1);
|
|
|
|
if(xorriso->loaded_volid[0]!=0) {
|
|
|
|
sprintf(xorriso->result_line,"Volume id : '%s'\n",xorriso->loaded_volid);
|
|
|
|
Xorriso_result(xorriso,0);
|
|
|
|
if(strcmp(xorriso->loaded_volid, xorriso->volid)!=0) {
|
|
|
|
sprintf(xorriso->result_line, "New volume id: '%s'\n", xorriso->volid);
|
|
|
|
Xorriso_result(xorriso,0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ret= 1+not_writeable;
|
|
|
|
ex:
|
|
|
|
Xorriso_process_msg_queues(xorriso,0);
|
|
|
|
if(ret<=0) {
|
|
|
|
hret= Xorriso_give_up_drive(xorriso, flag&3);
|
|
|
|
if(hret<ret)
|
|
|
|
ret= hret;
|
|
|
|
}
|
|
|
|
isoburn_ropt_destroy(&ropts, 0);
|
|
|
|
return(ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* @param flag bit0=input drive
|
|
|
|
bit1=output drive
|
|
|
|
bit2=eject
|
|
|
|
bit3=no info message or toc
|
|
|
|
*/
|
|
|
|
int Xorriso_give_up_drive(struct XorrisO *xorriso, int flag)
|
|
|
|
{
|
|
|
|
int in_is_out_too, ret;
|
|
|
|
struct burn_drive_info *dinfo;
|
|
|
|
struct burn_drive *drive;
|
|
|
|
char sfe[5*SfileadrL];
|
|
|
|
|
|
|
|
in_is_out_too= (xorriso->in_drive_handle == xorriso->out_drive_handle);
|
|
|
|
if((flag&4) && in_is_out_too && (flag&(1|2))) {
|
|
|
|
if((flag&3)!=3) {
|
|
|
|
sprintf(xorriso->info_text,"Giving up for -eject whole -dev %s",
|
|
|
|
Text_shellsafe(xorriso->indev, sfe, 0));
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
|
|
|
|
}
|
|
|
|
flag|= 3; /* give up in/out drive to eject it */
|
|
|
|
}
|
|
|
|
|
|
|
|
if((flag&1) && xorriso->in_drive_handle != NULL) {
|
|
|
|
Xorriso_get_drive_handles(xorriso, &dinfo, &drive,
|
|
|
|
"on attempt to give up drive", 0);
|
|
|
|
|
|
|
|
if(!in_is_out_too) {
|
|
|
|
if(drive!=NULL && !in_is_out_too)
|
|
|
|
isoburn_drive_release(drive,!!(flag&4));
|
|
|
|
if(dinfo!=NULL && !in_is_out_too)
|
|
|
|
burn_drive_info_free(dinfo);
|
|
|
|
}
|
|
|
|
xorriso->in_drive_handle= NULL;
|
|
|
|
xorriso->indev[0]= 0;
|
|
|
|
|
|
|
|
if(xorriso->in_volset_handle!=NULL)
|
|
|
|
iso_image_unref((IsoImage *) xorriso->in_volset_handle);
|
|
|
|
xorriso->in_volset_handle= NULL;
|
|
|
|
xorriso->loaded_volid[0]= 0;
|
|
|
|
xorriso->volset_change_pending= 0;
|
|
|
|
|
|
|
|
in_is_out_too= 0;
|
|
|
|
}
|
|
|
|
if((flag&2) && xorriso->out_drive_handle!=NULL) {
|
|
|
|
Xorriso_get_drive_handles(xorriso, &dinfo, &drive,
|
|
|
|
"on attempt to give up drive", 2);
|
|
|
|
if(!in_is_out_too) {
|
|
|
|
if(drive!=NULL)
|
|
|
|
isoburn_drive_release(drive,!!(flag&4));
|
|
|
|
if(dinfo!=NULL)
|
|
|
|
burn_drive_info_free(dinfo);
|
|
|
|
}
|
|
|
|
xorriso->out_drive_handle= NULL;
|
|
|
|
xorriso->outdev[0]= 0;
|
|
|
|
} else if((flag&1) && xorriso->out_drive_handle!=NULL) {
|
|
|
|
ret= Xorriso_create_empty_iso(xorriso, 0);
|
|
|
|
if(ret<=0)
|
|
|
|
return(ret);
|
|
|
|
if(!(flag&8)) {
|
|
|
|
sprintf(xorriso->info_text,
|
|
|
|
"Only the output drive remains. Created empty ISO image.\n");
|
|
|
|
Xorriso_info(xorriso, 0);
|
|
|
|
Xorriso_toc(xorriso, 1|2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Xorriso_process_msg_queues(xorriso,0);
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int Xorriso_make_write_options(
|
|
|
|
struct XorrisO *xorriso, struct burn_drive *drive,
|
|
|
|
struct burn_write_opts **burn_options, int flag)
|
|
|
|
{
|
|
|
|
int drive_role;
|
|
|
|
|
|
|
|
*burn_options= burn_write_opts_new(drive);
|
|
|
|
if(*burn_options==NULL) {
|
|
|
|
Xorriso_process_msg_queues(xorriso,0);
|
|
|
|
sprintf(xorriso->info_text,"Cannot allocate option set");
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
burn_write_opts_set_simulate(*burn_options, !!xorriso->do_dummy);
|
|
|
|
drive_role= burn_drive_get_drive_role(drive);
|
|
|
|
burn_write_opts_set_multi(*burn_options,
|
|
|
|
!(xorriso->do_close || drive_role==0 || drive_role==3));
|
|
|
|
burn_drive_set_speed(drive, xorriso->speed, xorriso->speed);
|
|
|
|
burn_write_opts_set_underrun_proof(*burn_options, 1);
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* @param flag bit0= do not write but only prepare and return size in sectors
|
|
|
|
*/
|
|
|
|
int Xorriso_write_session(struct XorrisO *xorriso, int flag)
|
|
|
|
{
|
|
|
|
int ret, media_space, img_sectors, padding= 0, profile= 0;
|
|
|
|
char profile_name[80];
|
|
|
|
struct isoburn_imgen_opts *sopts= NULL;
|
|
|
|
struct burn_drive_info *dinfo, *source_dinfo;
|
|
|
|
struct burn_drive *drive, *source_drive;
|
|
|
|
struct burn_disc *disc= NULL;
|
|
|
|
struct burn_write_opts *burn_options;
|
|
|
|
off_t readcounter= 0,writecounter= 0;
|
|
|
|
int num_sessions= 0, num_tracks= 0;
|
|
|
|
struct burn_session **sessions;
|
|
|
|
struct burn_track **tracks;
|
|
|
|
enum burn_disc_status s;
|
|
|
|
|
|
|
|
ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive,
|
|
|
|
"on attempt to write", 2);
|
|
|
|
if(ret<=0)
|
|
|
|
return(0);
|
|
|
|
|
|
|
|
ret= isoburn_igopt_new(&sopts, 0);
|
|
|
|
if(ret<=0)
|
|
|
|
return(ret);
|
|
|
|
isoburn_igopt_set_level(sopts, 2);
|
|
|
|
isoburn_igopt_set_extensions(sopts, 1|((!!xorriso->do_joliet)<<1));
|
|
|
|
isoburn_igopt_set_relaxed(sopts, isoburn_igopt_allow_deep_paths);
|
|
|
|
isoburn_igopt_set_sort_files(sopts, 1);
|
|
|
|
isoburn_igopt_set_over_mode(sopts, 0, 0, (mode_t) 0, (mode_t) 0);
|
|
|
|
isoburn_igopt_set_over_ugid(sopts, 0, 0, (uid_t) 0, (gid_t) 0);
|
|
|
|
isoburn_igopt_set_out_charset(sopts, NULL);
|
|
|
|
isoburn_igopt_set_fifo_size(sopts, xorriso->fs * 2048);
|
|
|
|
|
|
|
|
#ifdef NIX
|
|
|
|
memset(&sopts, 0, sizeof(sopts));
|
|
|
|
sopts.level= 2;
|
|
|
|
sopts.rockridge= 1;
|
|
|
|
sopts.joliet= !!xorriso->do_joliet;
|
|
|
|
sopts.iso1999= 0;
|
|
|
|
sopts.omit_version_numbers= 0;
|
|
|
|
sopts.allow_deep_paths= 1;
|
|
|
|
sopts.allow_longer_paths= 0;
|
|
|
|
sopts.max_37_char_filenames= 0;
|
|
|
|
sopts.no_force_dots= 0;
|
|
|
|
sopts.allow_lowercase= 0;
|
|
|
|
sopts.allow_full_ascii= 0;
|
|
|
|
sopts.joliet_longer_paths= 0;
|
|
|
|
sopts.sort_files= 1;
|
|
|
|
sopts.replace_dir_mode= 2*!!xorriso->do_global_mode;
|
|
|
|
sopts.dir_mode= xorriso->global_dir_mode;
|
|
|
|
sopts.replace_file_mode= 2*!!xorriso->do_global_mode;
|
|
|
|
sopts.file_mode= xorriso->global_file_mode;
|
|
|
|
sopts.replace_uid= 2*!!xorriso->do_global_uid;
|
|
|
|
sopts.uid= xorriso->global_uid;
|
|
|
|
sopts.replace_gid= 2*!!xorriso->do_global_gid;
|
|
|
|
sopts.gid= xorriso->global_gid;
|
|
|
|
sopts.output_charset= NULL;
|
|
|
|
sopts.fifo_size= xorriso->fs * 2048;
|
|
|
|
#endif /* NIX */
|
|
|
|
|
|
|
|
if(xorriso->out_drive_handle == xorriso->in_drive_handle ||
|
|
|
|
xorriso->in_drive_handle == NULL) {
|
|
|
|
source_drive= drive;
|
|
|
|
ret= isoburn_prepare_disc(source_drive, &disc, sopts);
|
|
|
|
} else {
|
|
|
|
s= isoburn_disc_get_status(drive);
|
|
|
|
if(s!=BURN_DISC_BLANK) {
|
|
|
|
s= burn_disc_get_status(drive);
|
|
|
|
if(s!=BURN_DISC_BLANK)
|
|
|
|
sprintf(xorriso->info_text,
|
|
|
|
"-indev differs from -outdev and -outdev media is not blank");
|
|
|
|
else
|
|
|
|
sprintf(xorriso->info_text,
|
|
|
|
"-indev differs from -outdev and -outdev media holds valid ISO image");
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
|
|
|
|
{ret= 0; goto ex;}
|
|
|
|
}
|
|
|
|
ret= Xorriso_get_drive_handles(xorriso, &source_dinfo, &source_drive,
|
|
|
|
"on attempt to get source for write", 0);
|
|
|
|
if(ret<=0)
|
|
|
|
goto ex;
|
|
|
|
ret= isoburn_prepare_new_image(source_drive, &disc, sopts, drive);
|
|
|
|
}
|
|
|
|
if (ret <= 0) {
|
|
|
|
Xorriso_process_msg_queues(xorriso,0);
|
|
|
|
sprintf(xorriso->info_text,"Failed to prepare session write run");
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
|
|
|
|
{ret= 0; goto ex;}
|
|
|
|
}
|
|
|
|
|
|
|
|
ret= Xorriso_make_write_options(xorriso, drive, &burn_options, 0);
|
|
|
|
if(ret<=0)
|
|
|
|
goto ex;
|
|
|
|
|
|
|
|
ret= img_sectors= burn_disc_get_sectors(disc);
|
|
|
|
if(flag&1)
|
|
|
|
goto ex;
|
|
|
|
|
|
|
|
sessions= burn_disc_get_sessions(disc, &num_sessions);
|
|
|
|
if(sessions==NULL || num_sessions < 1) {
|
|
|
|
no_track:;
|
|
|
|
Xorriso_process_msg_queues(xorriso,0);
|
|
|
|
sprintf(xorriso->info_text,"Program error : no track in prepared disc");
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
|
|
|
|
isoburn_cancel_prepared_write(source_drive, drive, 0);
|
|
|
|
{ret= -1; goto ex;}
|
|
|
|
}
|
|
|
|
tracks= burn_session_get_tracks(sessions[0], &num_tracks);
|
|
|
|
if(tracks==NULL || num_tracks < 1)
|
|
|
|
goto no_track;
|
|
|
|
|
|
|
|
padding= 0;
|
|
|
|
ret= burn_disc_get_profile(drive, &profile, profile_name);
|
|
|
|
padding= xorriso->padding / 2048;
|
|
|
|
if(xorriso->padding > padding * 2048)
|
|
|
|
padding++;
|
|
|
|
if(profile==0x09 || profile==0x0a) { /* CD-R , CD-RW */
|
|
|
|
if(img_sectors + padding < Xorriso_cd_min_track_sizE) {
|
|
|
|
padding= Xorriso_cd_min_track_sizE - img_sectors;
|
|
|
|
sprintf(xorriso->info_text,
|
|
|
|
"Expanded track to minimum size of %d sectors",
|
|
|
|
Xorriso_cd_min_track_sizE);
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
burn_track_define_data(tracks[0], 0, padding * 2048, 0, BURN_MODE1);
|
|
|
|
Xorriso_process_msg_queues(xorriso,0);
|
|
|
|
|
|
|
|
media_space= burn_disc_available_space(drive, burn_options) / (off_t) 2048;
|
|
|
|
if(media_space < img_sectors + padding) {
|
|
|
|
Xorriso_process_msg_queues(xorriso,0);
|
|
|
|
sprintf(xorriso->info_text,"Image size %ds exceeds free space on media %ds",
|
|
|
|
img_sectors + padding, media_space);
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
|
|
|
|
isoburn_cancel_prepared_write(source_drive, drive, 0);
|
|
|
|
{ret= 0; goto ex;}
|
|
|
|
}
|
|
|
|
|
|
|
|
isoburn_disc_write(burn_options, disc);
|
|
|
|
burn_write_opts_free(burn_options);
|
|
|
|
|
|
|
|
ret= Xorriso_pacifier_loop(xorriso, drive, 0);
|
|
|
|
if(ret<=0)
|
|
|
|
goto ex;
|
|
|
|
if(!isoburn_drive_wrote_well(drive)) {
|
|
|
|
Xorriso_process_msg_queues(xorriso,0);
|
|
|
|
sprintf(xorriso->info_text,
|
|
|
|
"libburn indicates failure with writing.");
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
|
|
|
|
ret= 0; goto ex;
|
|
|
|
}
|
|
|
|
|
|
|
|
sessions= burn_disc_get_sessions(disc, &num_sessions);
|
|
|
|
if(num_sessions>0) {
|
|
|
|
tracks= burn_session_get_tracks(sessions[0], &num_tracks);
|
|
|
|
if(tracks!=NULL && num_tracks>0) {
|
|
|
|
burn_track_get_counters(tracks[0],&readcounter,&writecounter);
|
|
|
|
sprintf(xorriso->info_text,
|
|
|
|
"ISO image produced: %d sectors. Written to media: %d sectors\n",
|
|
|
|
(int) (readcounter/ (off_t) 2048),
|
|
|
|
(int) (writecounter/ (off_t) 2048));
|
|
|
|
Xorriso_info(xorriso, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ret= isoburn_activate_session(drive);
|
|
|
|
Xorriso_process_msg_queues(xorriso,0);
|
|
|
|
if(ret<=0) {
|
|
|
|
sprintf(xorriso->info_text,
|
|
|
|
"Could not write new set of volume descriptors");
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
|
|
|
|
goto ex;
|
|
|
|
}
|
|
|
|
/* Done early to free any reference to the libisofs resources via disc */
|
|
|
|
if(disc!=NULL)
|
|
|
|
burn_disc_free(disc);
|
|
|
|
disc= NULL;
|
|
|
|
/* To wait for the end of the libisofs threads and their messages. */
|
|
|
|
isoburn_sync_after_write(source_drive, drive, 0);
|
|
|
|
Xorriso_process_msg_queues(xorriso,0);
|
|
|
|
|
|
|
|
sprintf(xorriso->info_text, "Writing completed sucessfully.\n\n");
|
|
|
|
Xorriso_info(xorriso, 0);
|
|
|
|
ret= 1;
|
|
|
|
ex:;
|
|
|
|
if(disc!=NULL)
|
|
|
|
burn_disc_free(disc);
|
|
|
|
isoburn_igopt_destroy(&sopts, 0);
|
|
|
|
Xorriso_process_msg_queues(xorriso,0);
|
|
|
|
return(ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* This loop watches burn runs until they end.
|
|
|
|
It issues pacifying update messages to the user.
|
|
|
|
*/
|
|
|
|
int Xorriso_pacifier_loop(struct XorrisO *xorriso, struct burn_drive *drive,
|
|
|
|
int flag)
|
|
|
|
{
|
|
|
|
int ret, size, free_bytes, i;
|
|
|
|
struct burn_progress progress;
|
|
|
|
char *status_text;
|
|
|
|
enum burn_drive_status drive_status;
|
|
|
|
double start_time, current_time;
|
|
|
|
|
|
|
|
start_time= Sfile_microtime(0);
|
|
|
|
while(burn_drive_get_status(drive, NULL) == BURN_DRIVE_SPAWNING)
|
|
|
|
usleep(100002);
|
|
|
|
|
|
|
|
while(1) {
|
|
|
|
drive_status= burn_drive_get_status(drive, &progress);
|
|
|
|
if(drive_status == BURN_DRIVE_IDLE)
|
|
|
|
break;
|
|
|
|
current_time= Sfile_microtime(0);
|
|
|
|
if(drive_status == BURN_DRIVE_WRITING && progress.sectors > 0) {
|
|
|
|
sprintf(xorriso->info_text, "Writing: sector %d of %d",
|
|
|
|
progress.sector, progress.sectors);
|
|
|
|
ret= isoburn_get_fifo_status(drive, &size, &free_bytes, &status_text);
|
|
|
|
if(ret>0 )
|
|
|
|