Browse Source

Gave up adapter to old libisofs. Renaming libisoburn and xorriso dirs.

master
Thomas Schmitt 15 years ago
parent
commit
3fbaf84660
  1. 26
      Makefile.am
  2. 3
      libisoburn/burn_wrap.c
  3. 3
      libisoburn/data_source.c
  4. 4
      libisoburn/isoburn.c
  5. 0
      libisoburn/isoburn.h
  6. 3
      libisoburn/isofs_wrap.c
  7. 0
      libisoburn/libisoburn.h
  8. 457
      og_src/burn_wrap.c
  9. 87
      og_src/data_source.c
  10. 335
      og_src/isoburn.c
  11. 139
      og_src/isoburn.h
  12. 319
      og_src/isofs_wrap.c
  13. 378
      og_src/libisoburn.h
  14. 49
      test/xorriso.txt
  15. 1
      test/xorriso_timestamp.h
  16. 3037
      test/xorrisoburn.c
  17. 138
      test/xorrisoburn.h
  18. 0
      xorriso/README
  19. 0
      xorriso/changelog.txt
  20. 0
      xorriso/compare_file.c
  21. 97
      xorriso/compile_xorriso.sh
  22. 0
      xorriso/configure_ac.txt
  23. 9
      xorriso/convert_man_to_html.sh
  24. 4
      xorriso/make_timestamp.sh
  25. 28
      xorriso/make_xorriso_standalone.sh
  26. 0
      xorriso/xorriso.1
  27. 8
      xorriso/xorriso.c
  28. 0
      xorriso/xorriso.h
  29. 0
      xorriso/xorriso_eng.html
  30. 0
      xorriso/xorriso_makefile_am.txt
  31. 0
      xorriso/xorriso_pc_in.txt
  32. 0
      xorriso/xorriso_private.h
  33. 1
      xorriso/xorriso_timestamp.h
  34. 9
      xorriso/xorrisoburn.c
  35. 0
      xorriso/xorrisoburn.h

26
Makefile.am

@ -1,26 +1,24 @@
pkgconfigdir=$(libdir)/pkgconfig
libincludedir=$(includedir)/libisoburn
lib_LTLIBRARIES = src/libisoburn.la
lib_LTLIBRARIES = libisoburn/libisoburn.la
## ========================================================================= ##
# Build libraries
src_libisoburn_la_LDFLAGS = \
libisoburn_libisoburn_la_LDFLAGS = \
-version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE)
src_libisoburn_la_SOURCES = \
src/burn_wrap.c \
src/data_source.c \
src/isoburn.c \
src/isoburn.h \
src/isofs_wrap.c \
src/libisoburn.h \
libisoburn_libisoburn_la_SOURCES = \
libisoburn/burn_wrap.c \
libisoburn/data_source.c \
libisoburn/isoburn.c \
libisoburn/isoburn.h \
libisoburn/isofs_wrap.c \
libisoburn/libisoburn.h \
version.h
## libburn/sg-@ARCH@.c \
libinclude_HEADERS = \
src/libisoburn.h
libisoburn/libisoburn.h
## ========================================================================= ##
@ -32,7 +30,7 @@ noinst_PROGRAMS =
# test/test
# test_test_CPPFLAGS = -Ilibisofs -Ilibburn -Ilibisoburn
# test_test_LDADD = $(src_libisoburn_la_OBJECTS) $(THREAD_LIBS) -lburn -lisofs
# test_test_LDADD = $(libisoburn_libisoburn_la_OBJECTS) $(THREAD_LIBS) -lburn -lisofs
# test_test_SOURCES = test/test.c
bin_PROGRAMS =
@ -71,7 +69,7 @@ uninstall-local:
# Indent source files
indent_files = \
$(src_libisoburn_la_SOURCES)
$(libisoburn_libisoburn_la_SOURCES)
indent: $(indent_files)

3
ng_src/burn_wrap.c → libisoburn/burn_wrap.c

@ -29,8 +29,7 @@
#include <libburn/libburn.h>
/* >>> NG */
#include <libisofs/nglibisofs.h>
#include <libisofs/libisofs.h>
#else /* ! Xorriso_standalonE */

3
ng_src/data_source.c → libisoburn/data_source.c

@ -12,8 +12,7 @@
#include <libburn/libburn.h>
/* >>> NG */
#include <libisofs/nglibisofs.h>
#include <libisofs/libisofs.h>
#else /* ! Xorriso_standalonE */

4
ng_src/isoburn.c → libisoburn/isoburn.c

@ -23,8 +23,7 @@
#include <libburn/libburn.h>
/* >>> NG */
#include <libisofs/nglibisofs.h>
#include <libisofs/libisofs.h>
#else /* ! Xorriso_standalonE */
@ -304,6 +303,7 @@ int isoburn_prepare_disc_aux(struct burn_drive *d, struct burn_disc **disc,
wopts.file_mode = opts->file_mode;
wopts.gid = opts->gid;
wopts.uid = opts->uid;
wopts.timestamp = 0;
wopts.output_charset = opts->output_charset;
#ifdef Libisoburn_no_fifO
wopts.fifo_size= fifo_chunks;

0
ng_src/isoburn.h → libisoburn/isoburn.h

3
ng_src/isofs_wrap.c → libisoburn/isofs_wrap.c

@ -17,8 +17,7 @@
#include <libburn/libburn.h>
/* >>> NG */
#include <libisofs/nglibisofs.h>
#include <libisofs/libisofs.h>
#else /* ! Xorriso_standalonE */

0
ng_src/libisoburn.h → libisoburn/libisoburn.h

457
og_src/burn_wrap.c

@ -1,457 +0,0 @@
/*
cc -g -c \
-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE=1 -D_LARGEFILE64_SOURCE \
burn_wrap.c
*/
/* libburn wrappers for libisoburn
Copyright 2007 Thomas Schmitt, <scdbackup@gmx.net>
*/
/* <<< 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>
#include <libburn/libburn.h>
#include <libisofs/libisofs.h>
#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 */
int isoburn_initialize(void)
{
if(!iso_init())
return(0);
if(!burn_initialize())
return(0);
isoburn_destroy_all(&isoburn_list_start, 0); /* isoburn_list_start= NULL */
return(1);
}
/** Examine the media and sets appropriate emulation if needed.
*/
static int isoburn_welcome_media(struct isoburn **o, struct burn_drive *d,
int flag)
{
int ret, lba, nwa;
struct burn_multi_caps *caps= NULL;
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;
ret= isoburn_new(o, 0);
if(ret<=0)
goto ex;
(*o)->drive= d;
ret= isoburn_create_data_source(*o);
if(ret<=0)
goto ex;
#ifdef Hardcoded_cd_rW
/* <<< A70929 : hardcoded CD-RW with fabricated -msinfo */
caps->start_adr= 0;
(*o)->fabricated_disc_status= BURN_DISC_APPENDABLE;
#endif
if(caps->start_adr) { /* set emulation to overwriteable */
(*o)->emulation_mode= 1;
ret= isoburn_start_emulation(*o, 0);
if(ret<=0) {
(*o)->emulation_mode= -1;
goto ex;
}
} else {
/* >>> recognize unsuitable media (but allow read-only media) */;
#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;
#endif
}
ret= 1;
ex:
if(caps!=NULL)
burn_disc_free_multi_caps(&caps);
return(ret);
}
int isoburn_drive_scan_and_grab(struct burn_drive_info *drive_infos[],
char *adr, int load)
{
int ret, conv_ret, drive_grabbed= 0;
char libburn_drive_adr[BURN_DRIVE_ADR_LEN];
struct isoburn *o= NULL;
char msg[BURN_MSGS_MESSAGE_LEN+4096];
conv_ret= burn_drive_convert_fs_adr(adr, libburn_drive_adr);
if(conv_ret<=0) {
sprintf(msg, "Unsuitable drive address: '%s'\n",adr);
msg[BURN_MSGS_MESSAGE_LEN-1]= 0;
burn_msgs_submit(0, msg, 0, "SORRY", NULL);
ret= 0; goto ex;
}
ret= burn_drive_scan_and_grab(drive_infos, libburn_drive_adr, load);
if(ret<=0)
goto ex;
drive_grabbed= 1;
ret= isoburn_welcome_media(&o, (*drive_infos)[0].drive, 0);
if(ret<=0)
goto ex;
ret= 1;
ex:
if(ret<=0) {
if(drive_grabbed)
burn_drive_release((*drive_infos)[0].drive, 0);
isoburn_destroy(&o, 0);
}
return(ret);
}
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);
if((*pt)->emulation_mode==-1)
return(-1);
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);
if(o->nwa>0)
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)
{
int ret;
struct isoburn *o;
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);
return;
}
if(o->emulation_mode>0) {
ret= isoburn_invalidate_iso(o, 0);
if(ret<=0)
burn_drive_cancel(drive);
return;
}
}
burn_disc_erase(drive, fast);
}
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 &&
isoburn_disc_get_status(d)!=BURN_DISC_FULL)
return(0);
ret= isoburn_find_emulator(&o, d, 0);
if(ret<0)
return(0);
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;
#ifdef Hardcoded_cd_rW
/* <<< A70929 : hardcoded CD-RW with fabricated -msinfo */
*lba= Hardcoded_cd_rw_c1;
*nwa= Hardcoded_cd_rw_nwA;
return(1);
#endif
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);
}
return(burn_disc_track_lba_nwa(d, opts, trackno, lba, nwa));
}
void isoburn_disc_write(struct burn_write_opts *opts, struct burn_disc *disc)
{
int ret;
struct isoburn *o;
struct burn_drive *drive;
char reasons[BURN_REASONS_LEN],msg[160+BURN_REASONS_LEN];
enum burn_write_types write_type;
drive= burn_write_opts_get_drive(opts);
ret= isoburn_find_emulator(&o, drive, 0);
if(ret<0)
return;
if(o!=NULL) {
o->wrote_well= -1;
if(o->emulation_mode!=0) {
burn_write_opts_set_multi(opts, 0);
if(o->emulation_mode>0 && o->nwa >= 0)
burn_write_opts_set_start_byte(opts, ((off_t) o->nwa) * (off_t) 2048);
}
}
write_type= burn_write_opts_auto_write_type(opts, disc, reasons, 0);
if (write_type == BURN_WRITE_NONE) {
sprintf(msg, "Failed to find a suitable write mode:\n%s", reasons);
burn_msgs_submit(0, msg, 0, "SORRY", NULL);
if(o!=NULL)
o->wrote_well= 0;
/* To cause a negative reply with burn_drive_wrote_well() */
burn_drive_cancel(drive);
return;
}
/*
sprintf(reasons, "%d", (int) write_type);
fprintf(stderr, "isoburn_EXPERIMENTAL: write_type = %s\n",
(write_type == BURN_WRITE_SAO ? "SAO" :
(write_type == BURN_WRITE_TAO ? "TAO" : reasons)));
*/
#ifdef Hardcoded_cd_rW
/* <<< A70929 : hardcoded CD-RW with fabricated -msinfo */
fprintf(stderr, "Setting write address to LBA %d\n", Hardcoded_cd_rw_nwA);
burn_write_opts_set_start_byte(opts,
((off_t) Hardcoded_cd_rw_nwA) * (off_t) 2048);
#endif
burn_disc_write(opts, disc);
}
void isoburn_drive_release(struct burn_drive *drive, int eject)
{
int ret;
struct isoburn *o;
ret= isoburn_find_emulator(&o, drive, 0);
if(ret<0)
return;
if(o!=NULL) {
isoburn_free_data_source(o);
isoburn_destroy(&o, 0);
}
burn_drive_release(drive, eject);
}
void isoburn_finish(void)
{
isoburn_destroy_all(&isoburn_list_start, 0);
burn_finish();
iso_finish();
}
int isoburn_needs_emulation(struct burn_drive *drive)
{
int ret;
struct isoburn *o;
enum burn_disc_status s;
s= isoburn_disc_get_status(drive);
if(s!=BURN_DISC_BLANK && s!=BURN_DISC_APPENDABLE)
return(-1);
ret= isoburn_find_emulator(&o, drive, 0);
if(ret<0)
return(-1);
if(ret>0)
if(o->emulation_mode>0)
return(1);
return(0);
}
int isoburn_set_start_byte(struct isoburn *o, off_t value, int flag)
{
int ret;
struct burn_drive *drive = o->drive;
struct burn_multi_caps *caps= NULL;
ret= burn_disc_get_multi_caps(drive, BURN_WRITE_NONE, &caps, 0);
if(ret<=0)
goto ex;
if(!caps->start_adr)
{ret= 0; goto ex;}
o->min_start_byte= value;
if(value % caps->start_alignment)
value+= caps->start_alignment - (value % caps->start_alignment);
o->nwa= value/2048;
/* If suitable for alignment, round up to full 16 sector addresses */
if((o->nwa%16) && ((16*2048) % caps->start_alignment)==0 )
o->nwa+= 16 - (o->nwa%16);
ret= 1;
ex:
if(caps!=NULL)
burn_disc_free_multi_caps(&caps);
return(ret);
}
int isoburn_get_min_start_byte(struct burn_drive *d, off_t *start_byte,
int flag)
{
int ret;
struct isoburn *o;
ret= isoburn_find_emulator(&o, d, 0);
if(ret<0)
return(-1);
if(ret==0)
return(0);
*start_byte= o->min_start_byte;
if(o->min_start_byte<=0)
return(0);
return(1);
}
int isoburn_drive_wrote_well(struct burn_drive *d)
{
int ret;
struct isoburn *o;
ret= isoburn_find_emulator(&o, d, 0);
if(ret<0)
return(-1);
if(o!=NULL)
if(o->wrote_well>=0)
return(o->wrote_well);
ret= burn_drive_wrote_well(d);
return ret;
}
int isoburn_get_fifo_status(struct burn_drive *d, int *size, int *free_bytes,
char **status_text)
{
int ret;
struct isoburn *o;
ret= isoburn_find_emulator(&o, d, 0);
if(ret<0)
return(-1);
if(o==NULL)
return(0);
if(o->fifo==NULL)
return(0);
ret= burn_fifo_inquire_status(o->fifo, size, free_bytes, status_text);
return(ret);
}

87
og_src/data_source.c

@ -1,87 +0,0 @@
/*
data source for libisoburn.
Copyright 2007 Vreixo Formoso Lopes <metalpain2002@yahoo.es>
*/
#include <assert.h>
#include <stdlib.h>
#include <libburn/libburn.h>
#include <libisofs/libisofs.h>
#include "isoburn.h"
struct disc_data_src {
struct burn_drive *d;
int nblocks;
};
static int
ds_read_block(struct data_source *src, int lba, unsigned char *buffer)
{
int ret;
struct disc_data_src *data;
off_t count;
assert(src && buffer);
data = (struct disc_data_src*)src->data;
/* if (lba >= data->nblocks)
* return BLOCK_OUT_OF_FILE;
*/
ret = burn_read_data(data->d, (off_t) lba * (off_t) 2048, (char *) buffer,
2048, &count, 0);
if (ret <= 0 )
return -1;
return 0;
}
static int
ds_get_size(struct data_source *src)
{
struct disc_data_src *data;
assert(src);
data = (struct disc_data_src*)src->data;
return data->nblocks;
}
static void
ds_free_data(struct data_source *src)
{
free(src->data);
}
struct data_source *
isoburn_data_source_new(struct burn_drive *d)
{
struct disc_data_src *data;
struct data_source *ret;
assert(d);
data = malloc(sizeof(struct disc_data_src));
if (!data)
return NULL;
data->d = d;
/* TODO should be filled with the size of disc (or track?) */
data->nblocks = 0;
ret = malloc(sizeof(struct data_source));
if (!ret) {
free(data);
return NULL;
}
ret->refcount = 1;
ret->read_block = ds_read_block;
ret->get_size = ds_get_size;
ret->free_data = ds_free_data;
ret->data = data;
return ret;
}

335
og_src/isoburn.c

@ -1,335 +0,0 @@
/*
cc -g -c isoburn.c
*/
/*
Class core of libisoburn.
Copyright 2007 Vreixo Formoso Lopes <metalpain2002@yahoo.es>
and Thomas Schmitt <scdbackup@gmx.net>
*/
/* ( derived from stub generated by CgeN on Sat, 01 Sep 2007 12:04:36 GMT ) */
#include <sys/types.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <libburn/libburn.h>
#include <libisofs/libisofs.h>
#include "libisoburn.h"
#include "isoburn.h"
/* -------------------------- isoburn ----------------------- */
/* The global list of isoburn objects. Usually there is only one.
>>> we are not ready for multiple control threads yet. See >>> mutex .
Multiple burns under one control thread should work.
*/
struct isoburn *isoburn_list_start= NULL;
int isoburn_new(struct isoburn **objpt, int flag)
{
struct isoburn *o;
int i;
*objpt= o= (struct isoburn *) malloc(sizeof(struct isoburn));
if(o==NULL)
return(-1);
o->drive= NULL;
o->emulation_mode= 0;
o->min_start_byte= 0;
o->nwa= 0;
o->fifo= NULL;
o->wrote_well= -1;
o->src= NULL;
o->fabricated_disc_status= BURN_DISC_UNREADY;
for(i=0;i<65536;i++)
o->target_iso_head[i]= 0;
o->target_volset= NULL;
o->prev= NULL;
o->next= NULL;
isoburn_link(o, isoburn_list_start, 1);
return(1);
}
int isoburn_destroy(struct isoburn **objpt, int flag)
{
struct isoburn *o;
o= *objpt;
if(o==NULL)
return(0);
/* >>> mutex */
if(o==isoburn_list_start)
isoburn_list_start= o->next;
if(o->prev!=NULL)
o->prev->next= o->next;
if(o->next!=NULL)
o->next->prev= o->prev;
/* >>> end mutex */
if(o->target_volset!=NULL)
iso_volset_free(o->target_volset);
if(o->fifo!=NULL)
burn_source_free(o->fifo);
free((char *) o);
*objpt= NULL;
return(1);
}
int isoburn_destroy_all(struct isoburn **objpt, int flag)
{
struct isoburn *o,*n;
o= *objpt;
if(o==NULL)
return(0);
for(;o->prev!=NULL;o= o->prev);
for(;o!=NULL;o= n) {
n= o->next;
isoburn_destroy(&o,0);
}
*objpt= NULL;
return(1);
}
int isoburn_get_emulation_mode(struct isoburn *o, int *pt, int flag)
{
*pt= o->emulation_mode;
return(1);
}
int isoburn_get_target_volset(struct isoburn *o, struct iso_volset **pt,
int flag)
{
*pt= o->target_volset;
return(1);
}
int isoburn_get_prev(struct isoburn *o, struct isoburn **pt, int flag)
{
*pt= o->prev;
return(1);
}
int isoburn_get_next(struct isoburn *o, struct isoburn **pt, int flag)
{
*pt= o->next;
return(1);
}
int isoburn_link(struct isoburn *o, struct isoburn *link, int flag)
/*
bit0= insert as link->prev rather than as link->next
*/
{
/* >>> mutex */
if(isoburn_list_start==NULL ||
(isoburn_list_start==link && (flag&1)))
isoburn_list_start= o;
if(o->prev!=NULL)
o->prev->next= o->next;
if(o->next!=NULL)
o->next->prev= o->prev;
o->prev= o->next= NULL;
if(link==NULL)
return(1);
if(flag&1) {
o->next= link;
o->prev= link->prev;
if(o->prev!=NULL)
o->prev->next= o;
link->prev= o;
} else {
o->prev= link;
o->next= link->next;
if(o->next!=NULL)
o->next->prev= o;
link->next= o;
}
/* >>> end mutex */
return(1);
}
int isoburn_count(struct isoburn *o, int flag)
/* flag: bit1= count from start of list */
{
int counter= 0;
if(flag&2)
for(;o->prev!=NULL;o= o->prev);
for(;o!=NULL;o= o->next)
counter++;
return(counter);
}
int isoburn_by_idx(struct isoburn *o, int idx, struct isoburn **pt, int flag)
/* flag: bit0= fetch first (idx<0) or last (idx>0) item in list
bit1= address from start of list */
{
int i,abs_idx;
struct isoburn *npt;
if(flag&2)
for(;o->prev!=NULL;o= o->prev);
abs_idx= (idx>0?idx:-idx);
*pt= o;
for(i= 0;(i<abs_idx || (flag&1)) && *pt!=NULL;i++) {
if(idx>0)
npt= o->next;
else
npt= o->prev;
if(npt==NULL && (flag&1))
break;
*pt= npt;
}
return(*pt!=NULL);
}
int isoburn_find_by_drive(struct isoburn **pt, struct burn_drive *d, int flag)
{
struct isoburn *o;
*pt= NULL;
for(o= isoburn_list_start;o!=NULL;o= o->next)
if(o->drive==d) {
*pt= o;
return(1);
}
return(0);
}
static
int isoburn_prepare_disc_aux(struct burn_drive *d, struct burn_disc **disc,
struct isoburn_source_opts *opts, int new_img)
{
struct burn_source *wsrc;
struct burn_session *session;
struct burn_track *track;
struct isoburn *o;
struct ecma119_source_opts wopts;
enum burn_disc_status state;
int ret, chunks;
ret= isoburn_find_emulator(&o, d, 0);
if(ret<0 || o==NULL)
return -1;
o->wrote_well= 0; /* early end will be registered as failure */
state = isoburn_disc_get_status(d);
if (state != BURN_DISC_BLANK && state != BURN_DISC_APPENDABLE
&& (state != BURN_DISC_FULL || ! new_img)) {
/* unsuitable status */
return -2;
}
wopts.volnum = 0;
wopts.level = opts->level;
wopts.flags = opts->flags;
wopts.relaxed_constraints = opts->relaxed_constraints;
wopts.copy_eltorito = opts->copy_eltorito;
wopts.no_cache_inodes = opts->no_cache_inodes;
wopts.sort_files = opts->sort_files;
wopts.default_mode = opts->default_mode;
wopts.replace_dir_mode = opts->replace_dir_mode;
wopts.replace_file_mode = opts->replace_file_mode;
wopts.replace_uid = opts->replace_uid;
wopts.replace_gid = opts->replace_gid;
wopts.dir_mode = opts->dir_mode;
wopts.file_mode = opts->file_mode;
wopts.gid = opts->gid;
wopts.uid = opts->uid;
wopts.input_charset = opts->input_charset;
wopts.ouput_charset = opts->ouput_charset;
if (new_img) {
wopts.ms_block = 0;
} else {
int lba, nwa;
ret = isoburn_disc_track_lba_nwa(d, NULL, 0, &lba, &nwa);
if (ret != 1)
return -3;
if (nwa == 0 && state == BURN_DISC_APPENDABLE) {
/* invalid nwa */
return -4;
}
wopts.ms_block = nwa;
}
wopts.src = o->src;
wopts.overwrite = (new_img ? NULL : o->target_iso_head);
wsrc = iso_source_new_ecma119(o->target_volset, &wopts);
if (wsrc == NULL)
return -1;
/* TODO check return values for failure. propertly clean-up on error */
chunks= 32;
if(opts->fifo_size >= 64*1024 && opts->fifo_size <= 1024.0 * 1024.0 * 1024.0){
chunks= opts->fifo_size/2048;
if(chunks*2048 < opts->fifo_size)
chunks++;
}
o->fifo = burn_fifo_source_new(wsrc, 2048, chunks, 0);
burn_source_free(wsrc);
if (o->fifo == NULL) {
fprintf(stderr, "Cannot attach fifo\n");
return -1;
}
*disc = burn_disc_create();
session = burn_session_create();
burn_disc_add_session(*disc, session, BURN_POS_END);
track = burn_track_create();
burn_track_set_source(track, o->fifo);
burn_session_add_track(session, track, BURN_POS_END);
/* give up local references */
burn_track_free(track);
burn_session_free(session);
o->wrote_well= -1; /* neutral */
return 1;
}
int isoburn_prepare_disc(struct burn_drive *d, struct burn_disc **disc,
struct isoburn_source_opts *opts)
{
return isoburn_prepare_disc_aux(d, disc, opts, 0);
}
int isoburn_prepare_new_image(struct burn_drive *d, struct burn_disc **disc,
struct isoburn_source_opts *opts)
{
return isoburn_prepare_disc_aux(d, disc, opts, 1);
}

139
og_src/isoburn.h

@ -1,139 +0,0 @@
/*
Class struct of libisoburn.
Copyright 2007 Vreixo Formoso Lopes <metalpain2002@yahoo.es>
and Thomas Schmitt <scdbackup@gmx.net>
*/
#ifndef Isoburn_includeD
#define Isoburn_includeD
/* for uint8_t */
#include <stdint.h>
struct isoburn {
/* The libburn drive to which this isoburn object is related
Most isoburn calls will use a burn_drive as object handle */
struct burn_drive *drive;
/* -1= inappropriate media state detected
0= libburn multi-session media, resp. undecided yet
1= random access media */
int emulation_mode;
/* Although rarely used, libburn can operate on several
drives simultaneously. */
struct isoburn *prev;
struct isoburn *next;
/* --- My part --- */
/* Start address as given by image examination (bytes, not blocks) */
off_t min_start_byte;
/* Aligned start address to be used for processing (counted in blocks) */
int nwa;
/* Eventual freely fabricated isoburn_disc_get_status().
BURN_DISC_UNREADY means that normally emulated status is in effect.
*/
enum burn_disc_status fabricated_disc_status;
/* The fifo which is installed between track and libisofs burn_source
*/
struct burn_source *fifo;
/* Indicator wether the most recent burn run worked :
-1 = undetermined, ask libburn , 0 = failure , 1 = success
To be inquired by isoburn_drive_wrote_well()
*/
int wrote_well;
/* --- Vreixo's part --- */
/* The data source for reading the old image */
struct data_source *src;
/* Buffered ISO head from media (should that become part of
ecma119_read_opts ?) */
uint8_t target_iso_head[65536];
/* The filesystem structure of the old image from media. */
struct iso_volset *target_volset;
};
/* Creation and disposal function */
int isoburn_new(struct isoburn **objpt, int flag);
int isoburn_destroy(struct isoburn **objpt, int flag);
/* Eventual readers for public attributes */
/* ( put into separate .h file then ) */
int isoburn_get_emulation_mode(struct isoburn *o, int *pt, int flag);
int isoburn_get_target_volset(struct isoburn *o, struct iso_volset **pt,
int flag);
/* List management */
int isoburn_get_prev(struct isoburn *o, struct isoburn **pt, int flag);
int isoburn_get_next(struct isoburn *o, struct isoburn **pt, int flag);
int isoburn_destroy_all(struct isoburn **objpt, int flag);
int isoburn_link(struct isoburn *o, struct isoburn *link, int flag);
int isoburn_count(struct isoburn *o, int flag);
int isoburn_by_idx(struct isoburn *o, int idx, struct isoburn **pt, int flag);
int isoburn_find_by_drive(struct isoburn **pt, struct burn_drive *d, int flag);
/* Non API inner interfaces */
/* Calls from burn_wrap.c into isofs_wrap.c */
int isoburn_start_emulation(struct isoburn *o, int flag);
int isoburn_create_data_source(struct isoburn *o);
int isoburn_free_data_source(struct isoburn *o);
int isoburn_invalidate_iso(struct isoburn *o, int flag);
/* Calls from isofs_wrap.c into burn_wrap.c */
/** Get an eventual isoburn object which is wrapped around the drive.
@param pt Eventually returns a pointer to the found object.
It is allowed to become NULL if return value is -1 or 0.
In this case, the drive is a genuine libburn drive
with no emulation activated by isoburn.
@param drive The drive to be searched for
@param flag unused yet
@return -1 unsuitable media, 0 generic media, 1 emulated media.
*/
int isoburn_find_emulator(struct isoburn **pt,
struct burn_drive *drive, int flag);
/** Set the start address for an emulated add-on session. The value will
be rounded up to the alignment necessary for the media. The aligned
value will be divided by 2048 and then put into o->nwa .
@param o The isoburn object to be programmed.
@param value The start address in bytes
@param flag unused yet
@return <=0 is failure , >0 success
*/
int isoburn_set_start_byte(struct isoburn *o, off_t value, int flag);
/** Get a data source suitable for read from a drive using burn_read_data()
function.
@param d drive to read from. Must be grabbed.
@return the data source, NULL on error. Must be freed with libisofs
data_source_free() function. Note that that doesn't release the
drive.
*/
struct data_source *
isoburn_data_source_new(struct burn_drive *d);
#endif /* Isoburn_includeD */

319
og_src/isofs_wrap.c

@ -1,319 +0,0 @@
/*
cc -g -c isofs_wrap.c
*/
/*
libisofs related functions of libisoburn.
Copyright 2007 Vreixo Formoso Lopes <metalpain2002@yahoo.es>
Thomas Schmitt <scdbackup@gmx.net>
*/
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <libburn/libburn.h>
#include <libisofs/libisofs.h>
#include "isoburn.h"
#include "libisoburn.h"
#define BP(a,b) [(b) - (a) + 1]
struct ecma119_pri_vol_desc
{
uint8_t vol_desc_type BP(1, 1);
uint8_t std_identifier BP(2, 6);
uint8_t vol_desc_version BP(7, 7);
uint8_t unused1 BP(8, 8);
uint8_t system_id BP(9, 40);
uint8_t volume_id BP(41, 72);
uint8_t unused2 BP(73, 80);
uint8_t vol_space_size BP(81, 88);
uint8_t unused3 BP(89, 120);
uint8_t vol_set_size BP(121, 124);
uint8_t vol_seq_number BP(125, 128);
uint8_t block_size BP(129, 132);
uint8_t path_table_size BP(133, 140);
uint8_t l_path_table_pos BP(141, 144);
uint8_t opt_l_path_table_pos BP(145, 148);
uint8_t m_path_table_pos BP(149, 152);
uint8_t opt_m_path_table_pos BP(153, 156);
uint8_t root_dir_record BP(157, 190);
uint8_t vol_set_id BP(191, 318);
uint8_t publisher_id BP(319, 446);
uint8_t data_prep_id BP(447, 574);
uint8_t application_id BP(575, 702);
uint8_t copyright_file_id BP(703, 739);
uint8_t abstract_file_id BP(740, 776);
uint8_t bibliographic_file_id BP(777, 813);
uint8_t vol_creation_time BP(814, 830);
uint8_t vol_modification_time BP(831, 847);
uint8_t vol_expiration_time BP(848, 864);
uint8_t vol_effective_time BP(865, 881);
uint8_t file_structure_version BP(882, 882);
uint8_t reserved1 BP(883, 883);
uint8_t app_use BP(884, 1395);
uint8_t reserved2 BP(1396, 2048);
};
static
uint32_t iso_read_lsb(const uint8_t *buf, int bytes)
{
int i;
uint32_t ret = 0;
for (i=0; i<bytes; i++) {
ret += ((uint32_t) buf[i]) << (i*8);
}
return ret;
}
/* API function. See libisoburn.h
*/
int isoburn_read_volset(struct burn_drive *d,
struct isoburn_read_opts *read_opts,
struct iso_volset **volset)
{
int ret;
struct ecma119_read_opts ropts;
enum burn_disc_status status= BURN_DISC_BLANK;
struct isoburn *o= NULL;
if(read_opts==NULL || volset==NULL) {
/* >>> program error */;
return(-1);
}
if(d != NULL) {
ret = isoburn_find_emulator(&o, d, 0);
if (ret < 0)
return 0;
if (o == NULL) {
return -1;
}
status = isoburn_disc_get_status(d);
if(o->target_volset != NULL)
iso_volset_free(o->target_volset);
o->target_volset= NULL;
}
if (d == NULL || status == BURN_DISC_BLANK || read_opts->pretend_blank) {
struct iso_volume *volume;
struct iso_tree_node_dir *root;
/*
* Blank disc, we create a new volset without files.
*/
root = iso_tree_new_root();
if (!root)
return -1;
volume = iso_volume_new_with_root("NEW DISC", "", "LIBISOBURN", root);
if (!volume)
return -1;
*volset = iso_volset_new(volume, "NEW VOLSET");
if (!*volset)
return -1;
if(o!=NULL) {
o->target_volset = *volset;
iso_volset_ref(o->target_volset); /*protects object from premature free*/
}
return 1;
}
if (status != BURN_DISC_APPENDABLE && status != BURN_DISC_FULL) {
/* incorrect disc status */
return -4;
}
ret = isoburn_disc_get_msc1(d, (int*) &ropts.block);
if (ret < 0)
return -2;
ropts.norock = read_opts->norock;
ropts.nojoliet = read_opts->nojoliet;
ropts.preferjoliet = read_opts->preferjoliet;
ropts.mode = read_opts->mode;
ropts.uid = read_opts->uid;
ropts.gid = read_opts->gid;
assert(o->src);
*volset = iso_volset_read(o->src, &ropts);
if (!(*volset))
return -3;
o->target_volset = *volset;
iso_volset_ref(o->target_volset); /* protects object from premature free */
read_opts->hasRR = ropts.hasRR;
read_opts->hasJoliet = ropts.hasJoliet;
return 1;
}
/* API function. See libisoburn.h
*/
int isoburn_attach_volset(struct burn_drive *d, struct iso_volset *volset)
{
int ret;
struct isoburn *o;
if (volset == NULL)
return -1;
ret = isoburn_find_emulator(&o, d, 0);
if (ret < 0)
return 0;
if (o == NULL)
return -1;
if(o->target_volset != NULL)
iso_volset_free(o->target_volset);
o->target_volset = volset;
return(1);
}
/* API function. See libisoburn.h
*/
int isoburn_activate_session(struct burn_drive *drive)
{
int ret;
struct isoburn *o;
ret = isoburn_find_emulator(&o, drive, 0);
if (ret < 0)
return -1;
if (o->emulation_mode != 1)
return 1; /* don't need to activate session */
if (o->fabricated_disc_status != BURN_DISC_APPENDABLE)
return 1;
ret = burn_random_access_write(drive, 0, (char*)o->target_iso_head,
32*2048, 1);
return ret;
}
/** Create a new data source suitable for reading from the given drive.
@param o A freshly created isoburn object, without any data_source
(src field == NULL), but with the drive field set.
@return <=0 error , 1 = success
*/
int isoburn_create_data_source(struct isoburn *o)
{
/* create and initialize the data source */
o->src = isoburn_data_source_new(o->drive);
return (o->src ? 1 : -1);
}
/** Dispose the data source created by isoburn_create_data_source().
@return <=0 error , 1 = success
*/
int isoburn_free_data_source(struct isoburn *o)
{
if (o->src)
data_source_free(o->src);
return 1;
}
/** Initialize the emulation of multi-session on random access media.
The need for emulation is confirmed already.
@param o A freshly created isoburn object. isoburn_create_data_source() was
already called, nevertheless.
@return <=0 error , 1 = success
*/
int isoburn_start_emulation(struct isoburn *o, int flag)
{
int ret, i;
off_t data_count;
struct burn_drive *drive;
struct ecma119_pri_vol_desc *pvm;
assert(o);
drive= o->drive;
/* we can assume 0 as start block for image */
/* TODO what about ms? where we validate valid iso image in ms disc? */
ret = burn_read_data(drive, (off_t) 0, (char*)o->target_iso_head,
sizeof(o->target_iso_head), &data_count, 1);
/* an error means an empty disc */
if (ret <= 0) {
o->fabricated_disc_status= BURN_DISC_BLANK;
return 1;
}
/* check first 64K. If 0's, the disc is treated as a blank disc, and thus
overwritten without extra check. */
i = sizeof(o->target_iso_head);
while (i && !o->target_iso_head[i-1])
--i;
if (!i) {
o->fabricated_disc_status= BURN_DISC_BLANK;