diff --git a/libisoburn/trunk/Makefile.am b/libisoburn/trunk/Makefile.am index c0432869..c443100f 100644 --- a/libisoburn/trunk/Makefile.am +++ b/libisoburn/trunk/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) diff --git a/libisoburn/trunk/ng_src/burn_wrap.c b/libisoburn/trunk/libisoburn/burn_wrap.c similarity index 99% rename from libisoburn/trunk/ng_src/burn_wrap.c rename to libisoburn/trunk/libisoburn/burn_wrap.c index 6e7cf8ca..74e41251 100644 --- a/libisoburn/trunk/ng_src/burn_wrap.c +++ b/libisoburn/trunk/libisoburn/burn_wrap.c @@ -29,8 +29,7 @@ #include -/* >>> NG */ -#include +#include #else /* ! Xorriso_standalonE */ diff --git a/libisoburn/trunk/ng_src/data_source.c b/libisoburn/trunk/libisoburn/data_source.c similarity index 96% rename from libisoburn/trunk/ng_src/data_source.c rename to libisoburn/trunk/libisoburn/data_source.c index 540f1ee2..f48d8c99 100644 --- a/libisoburn/trunk/ng_src/data_source.c +++ b/libisoburn/trunk/libisoburn/data_source.c @@ -12,8 +12,7 @@ #include -/* >>> NG */ -#include +#include #else /* ! Xorriso_standalonE */ diff --git a/libisoburn/trunk/ng_src/isoburn.c b/libisoburn/trunk/libisoburn/isoburn.c similarity index 99% rename from libisoburn/trunk/ng_src/isoburn.c rename to libisoburn/trunk/libisoburn/isoburn.c index cd28d348..e81af5a4 100644 --- a/libisoburn/trunk/ng_src/isoburn.c +++ b/libisoburn/trunk/libisoburn/isoburn.c @@ -23,8 +23,7 @@ #include -/* >>> NG */ -#include +#include #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; diff --git a/libisoburn/trunk/ng_src/isoburn.h b/libisoburn/trunk/libisoburn/isoburn.h similarity index 100% rename from libisoburn/trunk/ng_src/isoburn.h rename to libisoburn/trunk/libisoburn/isoburn.h diff --git a/libisoburn/trunk/ng_src/isofs_wrap.c b/libisoburn/trunk/libisoburn/isofs_wrap.c similarity index 99% rename from libisoburn/trunk/ng_src/isofs_wrap.c rename to libisoburn/trunk/libisoburn/isofs_wrap.c index 49e42b0e..0f0cfe42 100644 --- a/libisoburn/trunk/ng_src/isofs_wrap.c +++ b/libisoburn/trunk/libisoburn/isofs_wrap.c @@ -17,8 +17,7 @@ #include -/* >>> NG */ -#include +#include #else /* ! Xorriso_standalonE */ diff --git a/libisoburn/trunk/ng_src/libisoburn.h b/libisoburn/trunk/libisoburn/libisoburn.h similarity index 100% rename from libisoburn/trunk/ng_src/libisoburn.h rename to libisoburn/trunk/libisoburn/libisoburn.h diff --git a/libisoburn/trunk/og_src/burn_wrap.c b/libisoburn/trunk/og_src/burn_wrap.c deleted file mode 100644 index 5bbb05b5..00000000 --- a/libisoburn/trunk/og_src/burn_wrap.c +++ /dev/null @@ -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, -*/ - -/* <<< 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 -#include -#include -#include -#include -#include -#include -#include - - -#include -#include -#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); -} - - diff --git a/libisoburn/trunk/og_src/data_source.c b/libisoburn/trunk/og_src/data_source.c deleted file mode 100644 index 60e861f7..00000000 --- a/libisoburn/trunk/og_src/data_source.c +++ /dev/null @@ -1,87 +0,0 @@ -/* - data source for libisoburn. - - Copyright 2007 Vreixo Formoso Lopes -*/ - -#include -#include - -#include -#include -#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; -} - diff --git a/libisoburn/trunk/og_src/isoburn.c b/libisoburn/trunk/og_src/isoburn.c deleted file mode 100644 index b3ee5bed..00000000 --- a/libisoburn/trunk/og_src/isoburn.c +++ /dev/null @@ -1,335 +0,0 @@ - -/* - cc -g -c isoburn.c -*/ - -/* - Class core of libisoburn. - - Copyright 2007 Vreixo Formoso Lopes - and Thomas Schmitt -*/ - -/* ( derived from stub generated by CgeN on Sat, 01 Sep 2007 12:04:36 GMT ) */ - -#include -#include -#include -#include -#include -#include - -#include -#include -#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;(i0) - 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); -} diff --git a/libisoburn/trunk/og_src/isoburn.h b/libisoburn/trunk/og_src/isoburn.h deleted file mode 100644 index b72ee2d6..00000000 --- a/libisoburn/trunk/og_src/isoburn.h +++ /dev/null @@ -1,139 +0,0 @@ - -/* - Class struct of libisoburn. - - Copyright 2007 Vreixo Formoso Lopes - and Thomas Schmitt -*/ - -#ifndef Isoburn_includeD -#define Isoburn_includeD - - - -/* for uint8_t */ -#include - - -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 */ - diff --git a/libisoburn/trunk/og_src/isofs_wrap.c b/libisoburn/trunk/og_src/isofs_wrap.c deleted file mode 100644 index ddf4d45d..00000000 --- a/libisoburn/trunk/og_src/isofs_wrap.c +++ /dev/null @@ -1,319 +0,0 @@ - -/* - cc -g -c isofs_wrap.c -*/ - -/* - libisofs related functions of libisoburn. - - Copyright 2007 Vreixo Formoso Lopes - Thomas Schmitt -*/ - -#include -#include -#include - -#include -#include -#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>> 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; - return 1; - } - - pvm = (struct ecma119_pri_vol_desc *)(o->target_iso_head + 16 * 2048); - - if (!strncmp((char*)pvm->std_identifier, "CD001", 5)) { - off_t size; - - /* sanity check */ - if (pvm->vol_desc_type[0] != 1 || pvm->vol_desc_version[0] != 1 - || pvm->file_structure_version[0] != 1 ) { - /* TODO for now I treat this as a full disc */ - o->fabricated_disc_status= BURN_DISC_FULL; - return 1; - } - - /* ok, PVM found, set size */ - size = (off_t) iso_read_lsb(pvm->vol_space_size, 4); - size *= (off_t) 2048; /* block size in bytes */ - isoburn_set_start_byte(o, size, 0); - o->fabricated_disc_status= BURN_DISC_APPENDABLE; - } else if (!strncmp((char*)pvm->std_identifier, "CDXX1", 5)) { - - /* empty image */ - isoburn_set_start_byte(o, (off_t) 0, 0); - o->fabricated_disc_status= BURN_DISC_BLANK; - } else { - /* treat any disc in an unknown format as full */ - o->fabricated_disc_status= BURN_DISC_FULL; - } - return 1; -} - - -/** Alters and writes the first 64 kB of a "media" to invalidate - an ISO image. (It shall stay restorable by skilled humans, though). - The result shall especially keep libisoburn from accepting the media - image as ISO filesystem. - @param o A fully activated isoburn object. isoburn_start_emulation() - was already called. - @return <=0 error , 1 = success -*/ -int isoburn_invalidate_iso(struct isoburn *o, int flag) -{ - /* - * replace CD001 with CDXX1 in PVM. - * I think this is enought for invalidating an iso image - */ - strncpy((char*)o->target_iso_head + 16 * 2048 + 1, "CDXX1", 5); - return isoburn_activate_session(o->drive); -} - diff --git a/libisoburn/trunk/og_src/libisoburn.h b/libisoburn/trunk/og_src/libisoburn.h deleted file mode 100644 index bd792802..00000000 --- a/libisoburn/trunk/og_src/libisoburn.h +++ /dev/null @@ -1,378 +0,0 @@ - -/* - API definition of libisoburn. - - Copyright 2007 Vreixo Formoso Lopes - and Thomas Schmitt -*/ - -/** - -libisoburn is a frontend for libraries libburn and libisofs which enables -creation and expansion of ISO-9660 filesystems on all CD/DVD media supported -by libburn. This includes media like DVD+RW, which do not support multi-session -management on media level and even plain disk files or block devices. - -The price for that is thorough specialization on data files in ISO-9660 -filesystem images. So libisoburn is not suitable for audio (CD-DA) or any -other CD layout which does not entirely consist of ISO-9660 sessions. - -The priciple of this frontend is that you may use any call of libisofs or -libburn unless it has a isoburn_*() wrapper listed in the following function -documentation. - -E.g. call isoburn_initialize() rather than iso_init(); burn_initialize() -and call isoburn_drive_scan_and_grab() rather than burn_drive_scan_and_grab(). -But you may call burn_disc_get_profile() directly if you want to display -the media type. - ->>> ->>> Take into respect Vreixo's (mandatory ?) shortcuts which are to come ->>> - -The usage model is like with libburn: the target is a "media" in a "drive". -The wrappers will transparently provide the necessary emulations which -are appropriate for particular target "drives". - -*/ - - - /* API functions */ - - -/** Initialize libisoburn, libisofs and libburn. - Wrapper for : iso_init() and burn_initialize() - @return 1 indicates success, 0 is failure -*/ -int isoburn_initialize(void); - - -/** Aquire a target drive by its filesystem path resp. libburn persistent - address. - Wrapper for: burn_drive_scan_and_grab() -*/ -int isoburn_drive_scan_and_grab(struct burn_drive_info *drive_infos[], - char* adr, int load); - - -/** Aquire a drive from the burn_drive_info[] array which was obtained by - a previous call of burn_drive_scan(). - Wrapper for: burn_drive_grab() -*/ -int isoburn_drive_grab(struct burn_drive *drive, int load); - - -/** Inquire the media status. Expect the whole spectrum of libburn BURN_DISC_* - with multi-session media. Emulated states with random access media are - BURN_DISC_BLANK and BURN_DISC_APPENDABLE. - Wrapper for: burn_disc_get_status() -*/ -enum burn_disc_status isoburn_disc_get_status(struct burn_drive *drive); - - -/** Tells whether the media can be treated by isoburn_disc_erase(). - Wrapper for: burn_disc_erasable() -*/ -int isoburn_disc_erasable(struct burn_drive *d); - - -/** Mark the media as blank. With multi-session media this will call - burn_disc_erase(). With random access media, an eventual ISO-9660 - filesystem will get invalidated by altering its start blocks on media. - In case of success, the media is in status BURN_DISC_BLANK afterwards. - Wrapper for: burn_disc_erase() -*/ -void isoburn_disc_erase(struct burn_drive *drive, int fast); - -/** - * Options for image reading. - */ -struct isoburn_read_opts { - unsigned int norock:1; /*< Do not read Rock Ridge extensions */ - unsigned int nojoliet:1; /*< Do not read Joliet extensions */ - unsigned int preferjoliet:1; - /*< When both Joliet and RR extensions are present, the RR - * tree is used. If you prefer using Joliet, set this to 1. */ - uid_t uid; /**< Default uid when no RR */ - gid_t gid; /**< Default uid when no RR */ - mode_t mode; /**< Default mode when no RR (only permissions) */ - - /* modified by the function isoburn_read_volset */ - unsigned int hasRR:1; /*< It will be set to 1 if RR extensions are present, - to 0 if not. */ - unsigned int hasJoliet:1; /*< It will be set to 1 if Joliet extensions are - present, to 0 if not. */ - uint32_t size; /**< Will be filled with the size (in 2048 byte block) of - * the image, as reported in the PVM. */ - unsigned int pretend_blank:1; /* always create empty image */ -}; - -/** - * Options for image generation by libisofs and image transport to libburn. - */ -struct isoburn_source_opts { - - /* Options for image generation */ - - int level; /**< ISO level to write at. */ - int flags; /**< Which extensions to support. */ - int relaxed_constraints; /**< see ecma119_relaxed_constraints_flag */ - - unsigned int copy_eltorito:1; - /**< - * In multisession discs, select whether to copy el-torito catalog - * and boot image. Copy is needed for isolinux images, that need to - * be patched. However, it can lead to problems when the image is - * not present in the iso filesystem, because we can't figure out - * its size. In those cases, we only copy 1 block of data. - */ - - unsigned int no_cache_inodes:1; - /**< If use inode caching or not. Set it to 1 to prevent - * inode caching. - * Usage of inode caching allows detection of hard-links, - * which contents are only written once to disc this way. - * Don't use inode caching in systems with non unique inodes - * per device. - */ - unsigned int sort_files:1; - /**< If files should be sorted based on their weight. */ - unsigned int default_mode:1; - /**< - * The default values for files and directory permissions, - * gid and uid. This option can be overwritten when set - * one of the following. - * 0 to use useful values, 1 to use node modes (this are - * the same as filesystem ones if not changed after added - * to tree). - */ - unsigned int replace_dir_mode:1; - /**< - * When 1, permissions for all dirs will be replaced by the - * specified in dir_mode field. - */ - unsigned int replace_file_mode:1; - /**< - * When 1, permissions for all files will be replaced by the - * specified in file_mode field. - */ - unsigned int replace_uid:1; - /**< - * When 1, uid of all nodes (both files and dirs) will be - * replaced by the specified in uid field. - */ - unsigned int replace_gid:1; - /**< - * When 1, gid of all nodes (both files and dirs) will be - * replaced by the specified in gid field. - */ - mode_t dir_mode; /**< Mode to use on dirs when replace_dir_mode is set. */ - mode_t file_mode; /**< Mode to use on files when replace_file_mode is set. */ - gid_t gid; /**< gid to use when replace_gid is set. */ - uid_t uid; /**< uid to use when replace_uid is set. */ - char *input_charset; /**< NULL to use default charset */ - char *ouput_charset; /**< NULL to use default charset */ - - - /* Options for image transport */ - - /** The number of bytes to be used for the fifo which decouples libisofs - and libburn for better throughput and for reducing the risk of - interrupting signals hitting the libburn thread which operates the - MMC drive. - The size will be rounded up to the next full 2048. - Minimum is 64kiB, maximum is 1 GiB (but that is too much anyway). - */ - int fifo_size; - -}; - -/** Load the ISO filesystem directory tree from the media in the given drive. - This will give libisoburn the base on which it can let libisofs perform - image growing or image modification. The loaded volset gets attached - to the drive object and handed out to the application. - Not a wrapper, but peculiar to libisoburn. - @param d The drive which holds an existing ISO filesystem or blank media. - d is allowed to be NULL which produces an empty ISO image. In - this case one has to call before writing isoburn_attach_volset() - with the volset from this call and with the intended output - drive. - @param read_opts The read options which can be chosen by the application - @param volset the volset that represents the image, if the disc is blank - it will have no files. - This reference needs to be released via iso_volset_free() when - it is not longer needed. The drive, if not NULL, will hold an - own reference which it will release when it gets a new volset - or when it gets released via isoburn_drive_release(). - @return <=0 error , 1 = success - >>>>> error means damaged or unsupported image - error code is stored in ecma119_read_opts in libisofs - also error msgs are enqueued. Any need to pass them to usr? <<<<<< -*/ -int isoburn_read_volset(struct burn_drive *d, - struct isoburn_read_opts *read_opts, - struct iso_volset **volset); - - -/** Attach a ISO filesystem directory tree to a drive. This eventually releases - the reference to the old volset attached to the drive. - Caution: Use with care. It hardly makes sense to replace a volset that - reflects a valid ISO image on media. - This call is rather intended for writing a newly created and populated - image to blank media. The use case in xorriso is to let a volset survive - the change or demise of the outdev target drive. - @param d The drive which shall be write target of the volset. - @param volset The volset that represents the image to be written. - This volset pointer MUST already be a valid reference suitable - for iso_volset_free(). - It may have been obtained by appropriate libisofs calls or by - isoburn_read_volset() with d==NULL. - @return <=0 error , 1 = success -*/ -int isoburn_attach_volset(struct burn_drive *d, struct iso_volset *volset); - - -/** Obtain the start block number of the most recent session on media. In - case of random access media this will always be 0. Succesfull return is - not a guarantee that there is a ISO-9660 image at all. The call will fail, - nevertheless,if isoburn_disc_get_status() returns not BURN_DISC_APPENDABLE. - Wrapper for: burn_disc_get_msc1() -*/ -int isoburn_disc_get_msc1(struct burn_drive *d, int *start_lba); - - -/** Use this with trackno==0 to obtain the predicted start block number of the - new session. The interesting number is returned in parameter nwa. - Wrapper for: burn_disc_track_lba_nwa() -*/ -int isoburn_disc_track_lba_nwa(struct burn_drive *d, struct burn_write_opts *o, - int trackno, int *lba, int *nwa); - - -/** Obtain the size which was attributed to an emulated appendable on actually - overwriteable media. This value is supposed to be <= 2048 * nwa as of - isoburn_disc_track_lba_nwa(). - @param drive The drive holding the media. - @param start_byte The reply value counted in bytes, not in sectors. - @param flag Unused yet. Submit 0. - @return 1=stat_byte is valid, 0=not an emulated appendable, -1=error -*/ -int isoburn_get_min_start_byte(struct burn_drive *d, off_t *start_byte, - int flag); - - -/** Create a disc object for writing the new session from the created or loaded - iso_volset which has been manipulated via libisofs, to the same media from - where the image was eventually loaded. This struct burn_disc is ready for - use by a subsequent call to isoburn_disc_write(). - After this asynchronous writing has ended and the drive is BURN_DRIVE_IDLE - again, the burn_disc object has to be disposed by burn_disc_free(). - @param drive The combined source and target drive, grabbed with - isoburn_drive_scan_and_grab(). . - @param disc Returns the newly created burn_disc object. - @return <=0 error , 1 = success -*/ -int isoburn_prepare_disc(struct burn_drive *d, struct burn_disc **disc, - struct isoburn_source_opts *opts); - - -/** Create a disc object for producing a new image from a previous image - plus the changes made by user. The generated burn_disc is suitable - to be written to any other libburn drive. You must not use the same drive - for writing as you are using here as source, because data will be - read from the source drive while the target drive gets written to. - The resulting burn_disc object has to be disposed when all its writing - is done and the drive is BURN_DRIVE_IDLE again after asynchronous - burn_disc_write(). - @param d The source drive, grabbed with isoburn_drive_scan_and_grab(). - @param disc Returns the newly created burn_disc object. - @return <=0 error , 1 = success -*/ -int isoburn_prepare_new_image(struct burn_drive *d, struct burn_disc **disc, - struct isoburn_source_opts *opts); - -/** Start writing of the new session. - This call is asynchrounous. I.e. it returns quite soon and the progress has - to be watched by a loop with call burn_drive_get_status() until - BURN_DRIVE_IDLE is returned. - Wrapper for: burn_disc_write() -*/ -void isoburn_disc_write(struct burn_write_opts *o, struct burn_disc *disc); - - -/** Inquire state and fill parameters of the fifo which is attached to - the emerging track. This should be done in the pacifier loop while - isoburn_disc_write() or burn_disc_write() are active. - Hint: If only burn_write_opts and not burn_drive is known, then the drive - can be obtained by burn_write_opts_get_drive(). - @parm d The drive to which the track with the fifo gets burned. - @param size The total size of the fifo - @param free_bytes The current free capacity of the fifo - @param status_text Returns a pointer to a constant text, see below - @return <0 reply invalid, >=0 fifo status code: - bit0+1=input status, bit2=consumption status, i.e: - 0="standby" : data processing not started yet - 1="active" : input and consumption are active - 2="ending" : input has ended without error - 3="failing" : input had error and ended, - 4="unused" : ( consumption has ended before processing start ) - 5="abandoned" : consumption has ended prematurely - 6="ended" : consumption has ended without input error - 7="aborted" : consumption has ended after input error -*/ -int isoburn_get_fifo_status(struct burn_drive *d, int *size, int *free_bytes, - char **status_text); - - -/** Inquire whether the most recent write run was successful. - Wrapper for: burn_drive_wrote_well() -*/ -int isoburn_drive_wrote_well(struct burn_drive *d); - - -/** Call this after isoburn_disc_write has finished and burn_drive_wrote_well() - indicates success. It will eventually complete the emulation of - multi-session functionality, if needed at all. Let libisoburn decide. - Not a wrapper, but peculiar to libisoburn. -*/ -int isoburn_activate_session(struct burn_drive *drive); - - -/** Write a new session to a disc. - This is a synchronous call equivalent to isoburn_prepare_disc + - isoburn_disc_write + isoburn_activate_session - @param pacifier_func If not NULL: a function to produce appeasing messages. - See burn_abort_pacifier() in libburn.h for an example. -*/ -/* TODO implement this */ -int isoburn_perform_write(struct burn_write_opts *o, - int (*pacifier_func)(void *handle, int patience, - int elapsed)); - -/** Release an aquired drive. - Wrapper for: burn_drive_release() -*/ -void isoburn_drive_release(struct burn_drive *drive, int eject); - - -/** Shutdown all three libraries. - Wrapper for : iso_finish() and burn_finish(). -*/ -void isoburn_finish(void); - - -/* - The following two calls are for expert applications only. - An application should have a special reason to use them. -*/ - - -/** Inquire wether the media needs emulation or would be suitable for - generic multi-session via libburn. - @return 0 is generic multi-session - 1 is emulated multi-session - -1 is not suitable for isoburn -*/ -int isoburn_needs_emulation(struct burn_drive *drive); - - diff --git a/libisoburn/trunk/test/ng_xorrisoburn.c b/libisoburn/trunk/test/ng_xorrisoburn.c deleted file mode 100644 index c5eff17f..00000000 --- a/libisoburn/trunk/test/ng_xorrisoburn.c +++ /dev/null @@ -1,3250 +0,0 @@ - - -/* 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, - - Provided under GPL version 2. -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -/* ------------------------------------------------------------------------ */ - -#ifndef Xorriso_standalonE - -/* The library which does the ISO 9660 / RockRidge manipulations */ -/* >>> NG this is a botch name until somebody shows a better solution */ -#include - -/* The library which does MMC optical drive operations */ -#include - -/* The library which enhances overwriteable media with ISO 9660 multi-session - capabilities via the method invented by Andy Polyakov for growisofs */ -/* >>> NG this is a botch name until somebody shows a better solution */ -#include - -/* 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 */ -/* >>> NG */ -#include "ng_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); - -#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))) - - -/* ------------------------------------------------------------------------ */ - - -int Xorriso_startup_libraries(struct XorrisO *xorriso, int flag) -{ - int ret; - char *handler_prefix= NULL; - char *queue_sev, *print_sev; - - 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); - } - ret= isoburn_initialize(); - if(ret==0) { - sprintf(xorriso->info_text, "Cannot initialize libraries"); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); - free(handler_prefix); - return(0); - } - 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); - 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, "SORRY", 0); - return(0); - } - *drive= (*dinfo)[0].drive; - return((*drive)!=NULL); -} - - -/* @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; - } - memset(&ropts, sizeof(ropts), 0); - ropts.pretend_blank= 1; - ropts.input_charset= NULL; - ret= isoburn_read_image(drive, &ropts, &volset); - Xorriso_process_msg_queues(xorriso,0); - if(ret<=0) { - sprintf(xorriso->info_text, "Failed to create new empty ISO image object"); - Xorriso_msgs_submit(xorriso, 0, 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; - 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, "SORRY", 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, "SORRY", 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 */ - 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; - - Xorriso_set_image_severities(xorriso, 1); /* No DEBUG messages */ - 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, "SORRY", 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: - if(ret<=0) { - hret= Xorriso_give_up_drive(xorriso, flag&3); - if(hretin_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, "SORRY", 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; - struct isoburn_source_opts sopts; - 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); - - 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; - - if(xorriso->out_drive_handle == xorriso->in_drive_handle || - xorriso->in_drive_handle == NULL) { - ret= isoburn_prepare_disc(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, "SORRY", 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); - } - 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, "SORRY", 0); - {ret= 0; goto ex;} - } - - ret= Xorriso_make_write_options(xorriso, drive, &burn_options, 0); - if(ret<=0) - goto ex; - - ret= burn_disc_get_sectors(disc); - if(flag&1) - goto ex; - - media_space= burn_disc_available_space(drive, burn_options) / (off_t) 2048; - if(media_space < ret) { - Xorriso_process_msg_queues(xorriso,0); - sprintf(xorriso->info_text,"Image size %ds exceeds free space on media %ds", - ret, media_space); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 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, "SORRY", 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; - } - - sprintf(xorriso->info_text, "Writing completed sucessfully.\n\n"); - Xorriso_info(xorriso, 0); - ret= 1; -ex:; - if(disc!=NULL) - burn_disc_free(disc); - Xorriso_process_msg_queues(xorriso,0); - return(ret); -} - - -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 ) - sprintf(xorriso->info_text+strlen(xorriso->info_text), - " [fifo %s, %2d%% fill, size=%d , free=%d]", status_text, - (int) (100.0-100.0*((double) free_bytes)/(double) size), - size, free_bytes); -/* - sprintf(xorriso->info_text+strlen(xorriso->info_text), - " [fifo %s, %2d%% fill]", status_text, - (int) (100.0-100.0*((double) free_bytes)/(double) size)); -*/ - } else if(drive_status == BURN_DRIVE_CLOSING_SESSION || - drive_status == BURN_DRIVE_CLOSING_TRACK) - sprintf(xorriso->info_text, - "Closing track/session. Working since %.f seconds", - current_time-start_time); - else if(drive_status == BURN_DRIVE_FORMATTING) - sprintf(xorriso->info_text, "Formatting. Working since %.f seconds", - current_time-start_time); - else - sprintf(xorriso->info_text, - "Thank you for being patient since %.f seconds", - current_time-start_time); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "UPDATE", 0); - - for(i= 0; i<10; i++) { - Xorriso_process_msg_queues(xorriso, 0); - usleep(100000); - } - } - return(1); -} - - -int Xorriso_get_volume(struct XorrisO *xorriso, IsoImage **volume, - int flag) -{ - if(xorriso->in_volset_handle==NULL) { - Xorriso_process_msg_queues(xorriso,0); - sprintf(xorriso->info_text,"No ISO image present."); - if(xorriso->indev[0]==0 && xorriso->outdev[0]==0) - sprintf(xorriso->info_text+strlen(xorriso->info_text), - " No -dev, -indev, or -outdev selected."); - else - sprintf(xorriso->info_text+strlen(xorriso->info_text), - " Possible program error with drive '%s'.", xorriso->indev); - - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); - return(0); - } - *volume= (IsoImage *) xorriso->in_volset_handle; - return(*volume != NULL); -} - - -/* @param flag bit0=do not complain about non existent node */ -int Xorriso_node_from_path(struct XorrisO *xorriso, IsoImage *volume, - char *path, IsoNode **node, int flag) -{ - int ret; - char sfe[5*SfileadrL], *path_pt; - - path_pt= path; - if(path[0]==0) - path_pt= "/"; - *node= NULL; - ret= iso_tree_path_to_node(volume, path_pt, node); - Xorriso_process_msg_queues(xorriso,0); - if(ret<=0) { - if(!(flag&1)) { - sprintf(xorriso->info_text, "Cannot find path %s in loaded ISO image", - Text_shellsafe(path_pt, sfe, 0)); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); - } - return(0); - } - return(1); -} - - -/* @param eff_path returns resulting effective path. - Must provide at least SfileadrL bytes of storage. - @param flag bit0= do not produce problem events (unless faulty path format) - bit1= work purely literally, do not use libisofs - bit2= (with bit1) this is an address in the disk world - @return -1 = faulty path format, 0 = not found , - 1 = found simple node , 2 = found directory -*/ -int Xorriso_normalize_img_path(struct XorrisO *xorriso, char *wd, - char *img_path, char eff_path[], int flag) -{ - int ret, is_dir= 0, done= 0; - IsoImage *volume; - IsoDir *dir= NULL; - IsoNode *node= NULL; - char path[SfileadrL], *apt, *npt, sfe[5*SfileadrL], *cpt; - - eff_path[0]= 0; - if(img_path[0]==0) - return(2); /* root directory */ - - if(!(flag&2)) { - ret= Xorriso_get_volume(xorriso, &volume, 0); - if(ret<=0) - return(ret); - } - - apt= npt= path; - if(img_path[0]!='/') { - strcpy(path, wd); - ret= Sfile_add_to_path(path, img_path, 0); - if(ret<=0) - goto much_too_long; - } else - if(Sfile_str(path, img_path, 0)<=0) - return(-1); - - if(path[0]!='/') { - sprintf(xorriso->info_text, - "Internal error: Unresolvable relative addressing in iso_rr_path '%s'", - img_path); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FATAL", 0); - return(-1); - } else if(path[1]==0) - return(2); /* root directory */ - - for(npt= apt; !done; apt= npt+1) { - npt= strchr(apt, '/'); - if(npt==NULL) { - npt= apt+strlen(apt); - done= 1; - } else - *npt= 0; - if(*apt==0) { - *apt= '/'; - apt++; - if(done) - break; - continue; - } - if(strcmp(apt,".")==0) - continue; - if(strcmp(apt,"..")==0) { - if(!(flag&2)) { - node= (IsoNode *) dir; - if(node==NULL) { -bonked_root:; - sprintf(xorriso->info_text, - "Relative addressing in path exceeds root directory: %s", - Text_shellsafe(img_path, sfe, 0)); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); - return(-1); - } - dir= iso_node_get_parent(node); - } - /* truncate eff_path */; - cpt= strrchr(eff_path, '/'); - if(cpt==NULL) /* ??? if not flag&2 then this is a bug */ - goto bonked_root; - *cpt= 0; - continue; - } - ret= Sfile_add_to_path(eff_path, apt, 0); - if(ret<=0) { -much_too_long:; - sprintf(xorriso->info_text, "Effective path gets much too long (%d)", - (int) (strlen(eff_path)+strlen(apt)+1)); - if(!(flag&1)) - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); - return(-1); - } - if(!(flag&2)) { - dir= (IsoDir *) node; - ret= Xorriso_node_from_path(xorriso, volume, eff_path, &node, flag&1); - if(ret<=0) - return(0); - if(dir==NULL) /* could be false with "/dir/.." */ - dir= iso_node_get_parent(node); - is_dir= LIBISO_ISDIR(node); - } - } - return(1+!!is_dir); -} - - -int Xorriso_get_node_by_path(struct XorrisO *xorriso, - char *in_path, char *eff_path, - IsoNode **node, int flag) -{ - int ret; - char path[SfileadrL]; - IsoImage *volume; - - ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, in_path, path, 0); - if(ret<=0) - return(ret); - if(eff_path!=NULL) - strcpy(eff_path, path); - ret= Xorriso_get_volume(xorriso, &volume, 0); - if(ret<=0) - return(ret); - ret= Xorriso_node_from_path(xorriso, volume, path, node, 0); - if(ret<=0) - return(0); - return(1); -} - - -int Xorriso_transfer_properties(struct XorrisO *xorriso, struct stat *stbuf, - IsoNode *node, int flag) -{ - iso_node_set_permissions(node, stbuf->st_mode & 07777); - iso_node_set_uid(node, stbuf->st_uid); - iso_node_set_gid(node, stbuf->st_gid); - iso_node_set_atime(node, stbuf->st_atime); - iso_node_set_mtime(node, stbuf->st_mtime); - iso_node_set_ctime(node, stbuf->st_ctime); - return(1); -} - - -/* @param flag bit0= recursion is active */ -int Xorriso_add_tree(struct XorrisO *xorriso, IsoDir *dir, - char *img_dir_path, char *disk_dir_path, - struct LinkiteM *link_stack, int flag) -{ - IsoImage *volume; - IsoNode *node; - IsoSymlink *iso_symlink; - int ret, target_is_dir, source_is_dir, source_is_link, fret, was_failure= 0; - int do_not_dive; - struct DirseQ *dirseq= NULL; - char *name, *img_name, *srcpt; - struct stat stbuf, hstbuf; - dev_t dir_dev; - struct LinkiteM *own_link_stack; - -#ifdef Xorriso_fat_local_meM - char sfe[5*SfileadrL], sfe2[5*SfileadrL]; - char disk_path[2*SfileadrL], img_path[2*SfileadrL], link_target[SfileadrL]; -#else /* Xorriso_fat_local_meM */ - - char *sfe= NULL, *sfe2= NULL; - char *disk_path= NULL, *img_path= NULL, *link_target= NULL; - - /* Avoiding large local memory objects in order to save stack space */ - sfe= malloc(5*SfileadrL); - sfe2= malloc(5*SfileadrL); - disk_path= malloc(2*SfileadrL); - img_path= malloc(2*SfileadrL); - link_target= malloc(SfileadrL); - if(sfe==NULL || sfe2==NULL || disk_path==NULL || img_path==NULL || - link_target==NULL) { - Xorriso_no_malloc_memory(xorriso, &sfe, 0); - {ret= -1; goto ex;} - } - -#endif /* ! Xorriso_fat_local_meM */ - - own_link_stack= link_stack; - - ret= Xorriso_get_volume(xorriso, &volume, 0); - if(ret<=0) - goto ex; - - if(lstat(disk_dir_path, &stbuf)==-1) - goto cannot_open_dir; - dir_dev= stbuf.st_dev; - if(S_ISLNK(stbuf.st_mode)) { - if(!(xorriso->do_follow_links || (xorriso->do_follow_param && !(flag&1)))) - {ret= 2; goto ex;} - if(stat(disk_dir_path, &stbuf)==-1) - goto cannot_open_dir; - if(dir_dev != stbuf.st_dev && - !(xorriso->do_follow_mount || (xorriso->do_follow_param && !(flag&1)))) - {ret= 2; goto ex;} - } - ret= Dirseq_new(&dirseq, disk_dir_path, 1); - if(ret<0) { - sprintf(xorriso->info_text,"Failed to create source filesystem iterator"); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); - {ret= -1; goto ex;} - } - if(ret==0) { -cannot_open_dir:; - sprintf(xorriso->info_text,"Cannot open as source directory: %s", - Text_shellsafe(disk_dir_path, sfe, 0)); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); - {ret= 0; goto ex;} - } - - if(Sfile_str(disk_path, disk_dir_path,0)<=0) - {ret= -1; goto ex;} - if(disk_path[0]==0 || disk_path[strlen(disk_path)-1]!='/') - strcat(disk_path,"/"); - name= disk_path+strlen(disk_path); - if(Sfile_str(img_path, img_dir_path, 0)<=0) - {ret= -1; goto ex;} - if(img_path[0] || img_path[strlen(img_path)-1]!='/') - strcat(img_path,"/"); - img_name= img_path+strlen(img_path); - - while(1) { /* loop over directory content */ - Linkitem_reset_stack(&own_link_stack, link_stack, 0); - srcpt= disk_path; - Xorriso_process_msg_queues(xorriso,0); - ret= Dirseq_next_adr(dirseq,name,0); - if(ret==0) - break; - if(ret<0) { - sprintf(xorriso->info_text,"Failed to obtain next directory entry"); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); - {ret= -1; goto ex;} - } - strcpy(img_name, name); - if(Xorriso_much_too_long(xorriso, strlen(img_path), 0)<=0) - {ret= 0; goto was_problem;} - if(Xorriso_much_too_long(xorriso, strlen(srcpt), 0)<=0) - {ret= 0; goto was_problem;} - if(lstat(srcpt, &stbuf)==-1) { -cannot_lstat:; - sprintf(xorriso->info_text, - "Cannot determine attributes of source file %s", - Text_shellsafe(srcpt, sfe, 0)); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "SORRY", 0); - ret= 0; goto was_problem; - } - source_is_dir= 0; - source_is_link= S_ISLNK(stbuf.st_mode); - if(xorriso->do_follow_links && source_is_link) { - /* Xorriso_hop_link checks for wide link loops */ - ret= Xorriso_hop_link(xorriso, srcpt, &own_link_stack, &hstbuf, 0); - if(ret<0) - goto was_problem; - if(ret==1) { - ret= Xorriso_resolve_link(xorriso, srcpt, link_target, 0); - if(ret<=0) - goto was_problem; - srcpt= link_target; - if(lstat(srcpt, &stbuf)==-1) - goto cannot_lstat; - } else { - if(Xorriso_eval_problem_status(xorriso, 0, 1|2)<0) - {ret= 0; goto was_problem;} - } - } else if (S_ISLNK(stbuf.st_mode)) { - ret= Xorriso_resolve_link(xorriso, srcpt, link_target, 1); - if(ret<=0) - goto was_problem; - } - do_not_dive= 0; - if(S_ISDIR(stbuf.st_mode)) { - source_is_dir= 1; - if(dir_dev != stbuf.st_dev && !xorriso->do_follow_mount) - do_not_dive= 1; - -#ifdef NIX - } else if(!(S_ISREG(stbuf.st_mode) || S_ISLNK(stbuf.st_mode))) { - sprintf(xorriso->info_text,"Source file %s %s non-supported file type", - Text_shellsafe(disk_path, sfe, 0), - source_is_link ? "leads to" : "is of"); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); - ret= 0; goto was_problem; -#endif /* NIX */ - - } - - /* does a node exist with this name ? */ - node= NULL; - ret= Xorriso_node_from_path(xorriso, volume, img_path, &node, 1); - if(ret>0) { - target_is_dir= LIBISO_ISDIR(node); - if(!(target_is_dir && source_is_dir)) { - Xorriso_process_msg_queues(xorriso,0); - - /* handle overwrite situation */; - if(xorriso->do_overwrite==1 || - (xorriso->do_overwrite==2 && !target_is_dir)) { - ret= Xorriso_rmi(xorriso, NULL, img_path, 1|8); - if(ret<=0) - goto was_problem; - if(ret==3) { - sprintf(xorriso->info_text, "User revoked adding of: %s", - Text_shellsafe(img_path, sfe, 0)); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); - ret= 0; goto was_problem; - } - node= NULL; - } else { - sprintf(xorriso->info_text, - "While grafting %s : file object exists and may not be overwritten", - Text_shellsafe(img_path,sfe,0)); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); - ret= 0; goto was_problem; - } - } - } - - if(node==NULL) { - if(S_ISLNK(stbuf.st_mode)) { - - /* ??? NG : A80107 : is this solved now ? */ - /* <<< One should rather change libisofs so that iso_tree_add_node() - adds a disk_link as RR link, if RR is enabled */ - - ret= iso_tree_add_new_symlink(dir, img_name, link_target, &iso_symlink); - node= (IsoNode *) iso_symlink; - if(ret>0) { - ret= Xorriso_transfer_properties(xorriso, &stbuf, node, 0); - if(ret<=0) - goto was_problem; - } else - {ret= 0; goto was_problem;} - } else { - ret= iso_tree_add_node(volume, dir, srcpt, &node); - if(ret<0) - goto was_problem; - } - } - if(node==NULL) { - Xorriso_process_msg_queues(xorriso,0); - sprintf(xorriso->info_text, "Grafting failed: %s = %s", - Text_shellsafe(img_path,sfe,0), Text_shellsafe(disk_path,sfe2,0)); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); - ret=0; goto was_problem; - } - xorriso->volset_change_pending= 1; - if(source_is_dir) { - if(do_not_dive) { - sprintf(xorriso->info_text, "Did not follow mount point : %s", - Text_shellsafe(disk_path, sfe, 0)); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); - } else { - ret= Xorriso_add_tree(xorriso, (IsoDir *) node, - img_path, disk_path, own_link_stack, 1); - } - if(ret<=0) - goto was_problem; - } - - continue; /* regular bottom of loop */ -was_problem:; - was_failure= 1; - fret= Xorriso_eval_problem_status(xorriso, ret, 1|2); - if(fret<0) - goto ex; - } - - ret= 1; -ex: - -#ifndef Xorriso_fat_local_meM - if(sfe!=NULL) - free(sfe); - if(sfe2!=NULL) - free(sfe2); - if(disk_path!=NULL) - free(disk_path); - if(img_path!=NULL) - free(img_path); - if(link_target!=NULL) - free(link_target); -#endif /* ! Xorriso_fat_local_meM */ - - Xorriso_process_msg_queues(xorriso,0); - Linkitem_reset_stack(&own_link_stack, link_stack, 0); - Dirseq_destroy(&dirseq, 0); - if(ret<=0) - return(ret); - return(!was_failure); -} - - -/** @param flag bit0= mkdir: graft in as empty directory, not as copy from disk - @return <=0 = error , 1 = added simple node , 2 = added directory */ -int Xorriso_graft_in(struct XorrisO *xorriso, char *disk_path, char *img_path, - int flag) -{ - IsoImage *volume; - char path[SfileadrL], *apt, *npt, *cpt, sfe[5*SfileadrL], sfe2[5*SfileadrL]; - IsoDir *dir, *hdir; - IsoNode *node; - int done= 0, is_dir= 0, l, ret, target_is_dir, source_is_dir; - struct stat stbuf; - - for(cpt= img_path; 1; cpt++) { -/* - if(cpt[0]!='/') - break; -*/ - cpt= strstr(cpt,"/."); - if(cpt==NULL) - break; - if(cpt[2]=='.') { - if(cpt[3]=='/' || cpt[3]==0) - break; - } else if(cpt[2]=='/' || cpt[2]==0) - break; - } - if(cpt!=NULL) { - sprintf(xorriso->info_text, - "Unsupported relative addressing in iso_rr_path '%s'", img_path); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "SORRY", 0); - return(0); - } - - ret= Xorriso_get_volume(xorriso, &volume, 0); - if(ret<=0) - return(ret); - - strncpy(path, img_path, sizeof(path)-1); - path[sizeof(path)-1]= 0; - apt= npt= path; - - if(!(flag&1)) { - if(xorriso->do_follow_links || xorriso->do_follow_param) - ret= stat(disk_path, &stbuf); - else - ret= lstat(disk_path, &stbuf); - if(ret == -1) { - Xorriso_process_msg_queues(xorriso,0); - sprintf(xorriso->info_text, - "Cannot determine attributes of source file '%s'",disk_path); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "SORRY", 0); - return(0); - } - if(S_ISDIR(stbuf.st_mode)) { - is_dir= 1; - -#ifdef NIX - } else if(!(S_ISREG(stbuf.st_mode) || S_ISLNK(stbuf.st_mode))) { - Xorriso_process_msg_queues(xorriso,0); - sprintf(xorriso->info_text, - "Source file '%s' is of non-supported file type", disk_path); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); - return(0); -#endif /* NIX */ - - } else { - l= strlen(img_path); - if(l>0) - if(img_path[l-1]=='/') - l= 0; - if(l==0) { - sprintf(xorriso->info_text, - "Source '%s' is not a directory. Target '%s' would be.", - disk_path, img_path); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); - return(0); - } - } - } - - dir= iso_image_get_root(volume); - if(dir==NULL) { - Xorriso_process_msg_queues(xorriso,0); - sprintf(xorriso->info_text, - "While grafting '%s' : no root node available", img_path); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); - return(0); - } - for(npt= apt; !done; apt= npt+1) { - npt= strchr(apt, '/'); - if(npt==NULL) { - npt= apt+strlen(apt); - done= 1; - } else - *npt= 0; - if(*apt==0) { - *apt= '/'; - apt++; - if(done) - goto attach_source; - continue; - } - source_is_dir= (is_dir || (flag&1) || !done); - ret= Xorriso_node_from_path(xorriso, volume, path, &node, 1); - if(ret>0) { - target_is_dir= LIBISO_ISDIR(node); - if(!(target_is_dir && source_is_dir)) { - Xorriso_process_msg_queues(xorriso,0); - - /* handle overwrite situation */; - if(xorriso->do_overwrite==1 || - (xorriso->do_overwrite==2 && !target_is_dir)) { - ret= Xorriso_rmi(xorriso, NULL, path, 1|8); - if(ret<=0) - return(ret); - if(ret==3) { - sprintf(xorriso->info_text, "User revoked adding of: %s", - Text_shellsafe(disk_path, sfe, 0)); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); - return(0); - } - node= NULL; - goto handle_path_node; - } - - sprintf(xorriso->info_text, - "While grafting '%s' : '%s' exists and may not be overwritten", - img_path, path); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); - return(0); - } - dir= (IsoDir *) node; - } - -handle_path_node:; - if(node==NULL && source_is_dir) { /* make a directory */ - ret= iso_tree_add_new_dir(dir, apt, &hdir); - if(ret<0) { - Xorriso_process_msg_queues(xorriso,0); - sprintf(xorriso->info_text, - "While grafting '%s' : could not insert '%s'", img_path, path); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); - return(0); - } - dir= hdir; - xorriso->volset_change_pending= 1; - iso_node_set_ctime((IsoNode *) dir, time(NULL)); - iso_node_set_uid((IsoNode *) dir, geteuid()); - iso_node_set_gid((IsoNode *) dir, getegid()); - - /* >>> copy properties from correspondent directory in disk_path - if there is any */; - - } - if(done) { -attach_source:; - if(flag&1) { - /* directory node was created above */; - - } else if(is_dir) { - Xorriso_transfer_properties(xorriso, &stbuf, (IsoNode *) dir, 0); - ret= Xorriso_add_tree(xorriso, dir, img_path, disk_path, NULL, 0); - if(ret<=0) - return(ret); - - } else { - ret= iso_tree_add_node(volume, dir, disk_path, &node); - if(ret<0) { - Xorriso_process_msg_queues(xorriso,0); - sprintf(xorriso->info_text, "Grafting failed: %s = %s", - Text_shellsafe(img_path,sfe,0), Text_shellsafe(disk_path,sfe2,0)); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); - return(0); - } - xorriso->volset_change_pending= 1; - iso_node_set_name(node, apt); - } - } else - *npt= '/'; - } - Xorriso_process_msg_queues(xorriso,0); - return(1+!!is_dir); -} - - -int Xorriso__text_to_sev(char *severity_name, int *severity_number, int flag) -{ - int ret= 1; - - if(severity_name[0]==0) - *severity_number= 0; - else - ret= burn_text_to_sev(severity_name, severity_number, 0); - return(ret); -} - - -int Xorriso_process_msg_queues(struct XorrisO *xorriso, int flag) -{ - int ret, error_code= 0, os_errno= 0, count= 0, pass; - char severity[80]; - - if(!xorriso->libs_are_started) - return(1); - for(pass= 0; pass< 2; pass++) { - while(1) { - if(pass==0) - ret= iso_obtain_msgs("ALL", &error_code, - xorriso->info_text, &os_errno, severity); - else - ret= burn_msgs_obtain("ALL", &error_code, xorriso->info_text, &os_errno, - severity); - if(ret<=0) - break; - Xorriso_msgs_submit(xorriso, error_code, xorriso->info_text, os_errno, - severity, (pass+1)<<2); - count++; - } - } - if(xorriso->library_msg_direct_print && count>0) { - sprintf(xorriso->info_text," (%d library messages repeated by xorriso)\n", - count); - Xorriso_info(xorriso, 0); - } - return(1); -} - - -/* @param flag bit0=short report form - bit1=report about output drive -*/ -int Xorriso_toc(struct XorrisO *xorriso, int flag) -{ - int num_sessions= 0, num_tracks= 0, lba= 0, nwa= -1, pmin, psec, pframe, ret; - int track_count= 0, session_no, track_no, profile_no= -1; - int last_track_start= 0, last_track_size= -1, num_data= 0, is_data= 0; - int is_inout_drive= 0, drive_role; - char profile_name[80],*respt,*devadr; - struct burn_disc *disc= NULL; - struct burn_session **sessions; - struct burn_track **tracks; - struct burn_toc_entry toc_entry; - struct burn_drive_info *dinfo; - struct burn_drive *drive; - enum burn_disc_status s; - char mem_text[80]; - - ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive, - "on attempt to print Table Of Content", flag&2); - if(ret<=0) - return(0); - - respt= xorriso->result_line; - - if(strcmp(xorriso->indev, xorriso->outdev)==0) - is_inout_drive= 1; - if(flag&2) - devadr= xorriso->outdev; - else - devadr= xorriso->indev; - sprintf(respt, "Drive current: %s '%s'\n", - (is_inout_drive ? "-dev" : (flag&2 ? "-outdev" : "-indev")), - devadr); - Xorriso_result(xorriso,0); - sprintf(respt, "Drive type : vendor '%s' product '%s' revision '%s'\n", - dinfo[0].vendor, dinfo[0].product, dinfo[0].revision); - if(!(flag&1)) - Xorriso_result(xorriso,0); - - sprintf(respt, "Media current: "); - ret= burn_disc_get_profile(drive, &profile_no, profile_name); - if (profile_no > 0 && ret > 0) { - if (profile_name[0]) - sprintf(respt+strlen(respt), "%s", profile_name); - else - sprintf(respt+strlen(respt), "%4.4Xh", profile_no); - drive_role= burn_drive_get_drive_role(drive); - if(drive_role==2) - sprintf(respt+strlen(respt), ", overwriteable"); - else if(drive_role==0 || drive_role==3) - sprintf(respt+strlen(respt), ", sequential"); - strcat(respt, "\n"); - } else - sprintf(respt+strlen(respt), "is not recognizable\n"); - Xorriso_result(xorriso,0); - - sprintf(respt, "Media status : "); - s= isoburn_disc_get_status(drive); - if (s == BURN_DISC_FULL) { - sprintf(respt+strlen(respt), "is written , is closed\n"); - } else if (s == BURN_DISC_APPENDABLE) { - sprintf(respt+strlen(respt), "is written , is appendable\n"); - } else if (s == BURN_DISC_BLANK) { - sprintf(respt+strlen(respt), "is blank\n"); - } else if (s == BURN_DISC_EMPTY) - sprintf(respt+strlen(respt), "is not present\n"); - else - sprintf(respt+strlen(respt), "is not recognizable\n"); - Xorriso_result(xorriso,0); - - if(s != BURN_DISC_FULL && s != BURN_DISC_APPENDABLE) - return(1); - - if(xorriso->request_to_abort) - return(1); - - disc= burn_drive_get_disc(drive); - if (disc==NULL) { - Xorriso_process_msg_queues(xorriso,0); - -#define Xorriso_with_isoburn_get_min_start_bytE 1 -#ifdef Xorriso_with_isoburn_get_min_start_bytE - { off_t start_byte= 0; - ret= isoburn_get_min_start_byte(drive, &start_byte, 0); - nwa= start_byte / 2048; - } -#else - ret= isoburn_disc_track_lba_nwa(drive, NULL, 0, &lba, &nwa); -#endif - - if(ret<=0) { - Xorriso_process_msg_queues(xorriso,0); - if(flag&1) - return(0); - sprintf(xorriso->info_text, "Cannot obtain Table Of Content"); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); - return(0); - } - /* fabricate TOC */ - sprintf(respt, "Media content: session %2d ", 1); - sprintf(respt+strlen(respt), "track %2d %s lba: %9d\n", 1, "data ", 0); - if(!(flag&1)) - Xorriso_result(xorriso,0); - last_track_start= lba; - sprintf(respt, "Media content: session %2d ", 1); - sprintf(respt+strlen(respt), "leadout lba: %9d\n", nwa); - if(!(flag&1)) - Xorriso_result(xorriso,0); - num_data= last_track_size= nwa; - num_sessions= 1; - } else { - sessions= burn_disc_get_sessions(disc, &num_sessions); - for (session_no= 0; session_norequest_to_abort); - session_no++) { - tracks = burn_session_get_tracks(sessions[session_no], &num_tracks); - if (tracks==NULL) - continue; - for(track_no= 0; track_norequest_to_abort); - track_no++) { - track_count++; - is_data= 0; - burn_track_get_entry(tracks[track_no], &toc_entry); - if (toc_entry.extensions_valid & 1) { - /* DVD extension valid */ - lba= toc_entry.start_lba; - } else { - lba= burn_msf_to_lba(toc_entry.pmin, toc_entry.psec, toc_entry.pframe); - } - sprintf(respt, "Media content: session %2d ", session_no+1); - sprintf(respt+strlen(respt), "track %2d %s lba: %9d\n", - track_count, ((toc_entry.control&7)<4?"audio":"data "), lba); - if(!(flag&1)) - Xorriso_result(xorriso,0); - last_track_start= lba; - if((toc_entry.control&7)>=4) /* data track */ - is_data= 1; - } - burn_session_get_leadout_entry(sessions[session_no], &toc_entry); - if (toc_entry.extensions_valid & 1) { - lba= toc_entry.start_lba; - burn_lba_to_msf(lba, &pmin, &psec, &pframe); - } else { - lba= burn_msf_to_lba(pmin, psec, pframe); - lba= burn_msf_to_lba(toc_entry.pmin, toc_entry.psec, toc_entry.pframe); - } - sprintf(respt, "Media content: session %2d ", session_no+1); - sprintf(respt+strlen(respt), "leadout lba: %9d\n", lba); - if(!(flag&1)) - Xorriso_result(xorriso,0); - last_track_size= lba - last_track_start; - if(is_data) - num_data+= last_track_size; - } - } - if(xorriso->request_to_abort) - return(1); - Sfile_scale(((double) num_data) * 2048.0, mem_text,5,1e4,1); - sprintf(respt, "Media summary: %d session%s, %d data blocks, %s\n", - num_sessions, (num_sessions==1 ? "" : "s"), num_data, mem_text); - Xorriso_result(xorriso,0); - - if (s == BURN_DISC_APPENDABLE && nwa!=0) { - ret= isoburn_disc_track_lba_nwa(drive, NULL, 0, &lba, &nwa); - if(ret>0) { - sprintf(respt, "Media nwa : %ds\n", nwa); - if(!(flag&1)) - Xorriso_result(xorriso,0); - } - } - - if (disc!=NULL) - burn_disc_free(disc); - Xorriso_process_msg_queues(xorriso,0); - return(1); -} - - -int Xorriso_show_devices(struct XorrisO *xorriso, int flag) -{ - char adr[BURN_DRIVE_ADR_LEN]; - int i; - struct burn_drive_info *drive_list= NULL; - unsigned int drive_count; - char *respt, perms[8]; - struct stat stbuf; - - sprintf(xorriso->info_text, "Beginning to scan for devices ...\n"); - Xorriso_info(xorriso,0); - - burn_drive_clear_whitelist(); - while(!burn_drive_scan(&drive_list, &drive_count)) { - Xorriso_process_msg_queues(xorriso,0); - usleep(100000); - } - Xorriso_process_msg_queues(xorriso,0); - if(drive_count <= 0) { - - /* >>> was a drive_list created at all ? */ - /* >>> must it be freed ? */ - - sprintf(xorriso->info_text, "No drives found"); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); - return(0); - } - sprintf(xorriso->info_text, "Full drive scan done\n"); - Xorriso_info(xorriso,0); - - respt= xorriso->result_line; - for(i= 0; i < drive_count && !(xorriso->request_to_abort); i++) { - if(burn_drive_get_adr(&(drive_list[i]), adr)<=0) - strcpy(adr, "-get_adr_failed-"); - Xorriso_process_msg_queues(xorriso,0); - if(stat(adr,&stbuf)==-1) { - sprintf(perms,"errno=%d",errno); - } else { - strcpy(perms,"------"); - if(stbuf.st_mode&S_IRUSR) perms[0]= 'r'; - if(stbuf.st_mode&S_IWUSR) perms[1]= 'w'; - if(stbuf.st_mode&S_IRGRP) perms[2]= 'r'; - if(stbuf.st_mode&S_IWGRP) perms[3]= 'w'; - if(stbuf.st_mode&S_IROTH) perms[4]= 'r'; - if(stbuf.st_mode&S_IWOTH) perms[5]= 'w'; - } - sprintf(respt, "%d -dev '%s' %s : '%-8.8s' '%s' \n", - i, adr, perms, drive_list[i].vendor, drive_list[i].product); - Xorriso_result(xorriso,0); - } - burn_drive_info_free(drive_list); - Xorriso_process_msg_queues(xorriso,0); - return(1); -} - - -int Xorriso_tell_media_space(struct XorrisO *xorriso, - int *media_space, int *free_space, int flag) -{ - int ret; - struct burn_drive_info *dinfo; - struct burn_drive *drive; - struct burn_write_opts *burn_options; - - (*free_space)= (*media_space)= 0; - - ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive, - "on attempt to -tell_media_space", 2); - if(ret<=0) - return(0); - - ret= Xorriso_make_write_options(xorriso, drive, &burn_options, 0); - if(ret<=0) - return(-1); - (*free_space)= (*media_space)= - burn_disc_available_space(drive, burn_options) / (off_t) 2048; - burn_write_opts_free(burn_options); - - if(xorriso->volset_change_pending) { - ret= Xorriso_write_session(xorriso, 1); - if(ret>0) - (*free_space)-= ret; - } - Xorriso_process_msg_queues(xorriso,0); - return(1); -} - - -/* @param flag bit0=fast , bit1=deformat - @return 0=failure, did not touch media , -1=failure, altered media - 1=success, altered media , 2=success, did not touch media -*/ -int Xorriso_blank_media(struct XorrisO *xorriso, int flag) -{ - int ret, do_deformat= 0; - struct burn_drive_info *dinfo; - struct burn_drive *drive; - enum burn_disc_status disc_state; - struct burn_progress p; - double percent = 1.0; - int current_profile; - char current_profile_name[80]; - char mode_names[4][80]= {"all", "fast", "deformat", "deformat_quickest"}; - - ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive, - "on attempt to -blank", 2); - if(ret<=0) - return(0); - - burn_disc_get_profile(drive, ¤t_profile, current_profile_name); - - /* >>> */; - - disc_state = isoburn_disc_get_status(drive); - if(current_profile == 0x13) { /* overwriteable DVD-RW */ - /* Depending on flag bit1 formatted DVD-RW will get blanked to sequential - state or pseudo blanked by invalidating an eventual ISO image. */ - if(flag&2) - do_deformat= 1; - } else if(current_profile == 0x14) { /* sequential DVD-RW */ - if((flag&1) && !(flag&2)) { - sprintf(xorriso->info_text, - "-blank: DVD-RW present. Mode 'fast' defaulted to mode 'all'."); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); - sprintf(xorriso->info_text, - "Mode 'deformat_quickest' produces single-session-only media."); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "HINT", 0); - flag&= ~1; - } - } else if(disc_state == BURN_DISC_BLANK) { - sprintf(xorriso->info_text,"Blank media detected. Will leave it untouched"); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); - return 2; - } else if(disc_state==BURN_DISC_FULL || disc_state==BURN_DISC_APPENDABLE) { - ; - } else if(disc_state == BURN_DISC_EMPTY) { - sprintf(xorriso->info_text,"No media detected in drive"); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); - return 0; - } else { - sprintf(xorriso->info_text, "Unsuitable drive and media state"); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); - return 0; - } - if(!isoburn_disc_erasable(drive)) { - sprintf(xorriso->info_text, "Media is not of erasable type"); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); - return 0; - } - if(xorriso->do_dummy) { - sprintf(xorriso->info_text, - "-dummy mode prevents blanking of media in mode '%s'.", - mode_names[flag&3]); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); - return(1); - } - sprintf(xorriso->info_text, "Beginning to blank media in mode '%s'.\n", - mode_names[flag&3]); - Xorriso_info(xorriso,0); - - if(do_deformat) - burn_disc_erase(drive, (flag&1)); - else - isoburn_disc_erase(drive, (flag&1)); - usleep(1000000); - while (burn_drive_get_status(drive, &p) != BURN_DRIVE_IDLE) { - if(p.sectors>0 && p.sector>=0) /* display 1 to 99 percent */ - percent = 1.0 + ((double) p.sector+1.0) / ((double) p.sectors) * 98.0; - sprintf(xorriso->info_text, "Blanking ( %.1f%% done )", percent); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "UPDATE", 0); - usleep(1000000); - } - Xorriso_process_msg_queues(xorriso,0); - sprintf(xorriso->info_text, "Blanking done\n"); - Xorriso_info(xorriso,0); - return(1); -} - -/* @return 0=failure, did not touch media , -1=failure, altered media - 1=success, altered media , 2=success, did not touch media -*/ -int Xorriso_format_media(struct XorrisO *xorriso, int flag) -{ - int ret, mode_flag= 0; - struct burn_drive_info *dinfo; - struct burn_drive *drive; - int current_profile; - char current_profile_name[80]; - - ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive, - "on attempt to -format", 2); - if(ret<=0) - return(0); - - burn_disc_get_profile(drive, ¤t_profile, current_profile_name); - if(current_profile == 0x14) { - ; /* ok DVD-RW sequential */ - } else if(current_profile == 0x1a) { - mode_flag= 2; - } else { - sprintf(xorriso->info_text, - "Can only -format DVD+RW and sequential DVD-RW"); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); - sprintf(xorriso->info_text,"Media current: %s (%4.4xh)", - current_profile_name, current_profile); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); - return 0; - } - - if(xorriso->do_dummy) { - sprintf(xorriso->info_text, "-dummy mode prevents formatting of media."); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); - return(1); - } - sprintf(xorriso->info_text, "Beginning to format media.\n"); - Xorriso_info(xorriso, 0); - burn_disc_format(drive, (off_t) 0, mode_flag); - - ret= Xorriso_pacifier_loop(xorriso, drive, 0); - if(ret<=0) - return(ret); - - Xorriso_process_msg_queues(xorriso,0); - sprintf(xorriso->info_text, "Formatting done\n"); - Xorriso_info(xorriso,0); - return(1); -} - - -/* @param boss_iter If not NULL then this is an iterator suitable for - iso_dir_iter_remove() which is then to be used instead - of iso_node_remove(). - @param flag bit0= remove whole sub tree: rm -r - bit1= remove empty directory: rmdir - bit2= recursion: do not reassure in mode 2 "tree" - bit3= this is for overwriting and not for plain removal - @return <=0 = error - 1 = removed simple node - 2 = removed directory or tree - 3 = did not remove on user revocation -*/ -int Xorriso_rmi(struct XorrisO *xorriso, void *boss_iter, - char *path, int flag) -{ - int ret, is_dir= 0, pl, not_removed= 0, fret; - IsoNode *victim_node, *node; - IsoDir *boss_node, *root_dir; - IsoDirIter *iter= NULL; - IsoImage *volume; - char *sub_name, *name; - -#ifdef Xorriso_fat_local_meM - char sfe[5*SfileadrL], sub_path[2*SfileadrL]; -#else - char *sfe= NULL, *sub_path= NULL; - - /* Avoiding large local memory objects in order to save stack space */ - sfe= malloc(5*SfileadrL); - sub_path= malloc(2*SfileadrL); - if(sfe==NULL || sub_path==NULL) { - Xorriso_no_malloc_memory(xorriso, &sfe, 0); - {ret= -1; goto ex;} - } -#endif /* ! Xorriso_fat_local_meM */ - - ret= Xorriso_get_volume(xorriso, &volume, 0); - if(ret<=0) - goto ex; - - if(Xorriso_much_too_long(xorriso, strlen(path), 0)<=0) - {ret= 0; goto ex;} - ret= Xorriso_node_from_path(xorriso, volume, path, &victim_node, 0); - if(ret<=0) - goto ex; - root_dir= iso_image_get_root(volume); - if(((void *) root_dir) == ((void *) victim_node)) { - sprintf(xorriso->info_text, "May not delete root directory"); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); - {ret= 0; goto ex;} - } - - if(LIBISO_ISDIR(victim_node)) - is_dir= 1; - if(!is_dir) { - if(flag&2) { /* rmdir */ - sprintf(xorriso->info_text, "%s in loaded ISO image is not a directory", - Text_shellsafe(path, sfe, 0)); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); - ret= 0; goto ex; - } - } else { - if(flag&1) { /* rm -r */ - if(xorriso->do_reassure==1 && !xorriso->request_not_to_ask) { - /* Iterate over subordinates and delete them */ - - ret= iso_dir_get_children((IsoDir *) victim_node, &iter); - Xorriso_process_msg_queues(xorriso,0); - if(ret<0) { -cannot_create_iter:; - sprintf(xorriso->info_text, "Cannot create IsoDirIter object"); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); - ret= -1; goto ex; - } - pl= strlen(path); - strcpy(sub_path, path); - if(pl==0 || sub_path[pl-1]!='/') { - sub_path[pl++]= '/'; - sub_path[pl]= 0; - } - sub_name= sub_path+pl; - while(iso_dir_iter_next(iter, &node) == 1 - && !xorriso->request_to_abort) { - name= (char *) iso_node_get_name(node); - if(Xorriso_much_too_long(xorriso, pl+1+strlen(name), 0)<=0) - {ret= 0; goto rm_r_problem_handler;} - strcpy(sub_name, name); - ret= Xorriso_rmi(xorriso, iter, sub_path, (flag&(1|2|8))|4); - if(ret==3 || ret<=0 || xorriso->request_to_abort) { -rm_r_problem_handler:; - not_removed= 1; - fret= Xorriso_eval_problem_status(xorriso, ret, 1|2); - if(fret<0) - goto dir_not_removed; - } - } - if(not_removed) { -dir_not_removed:; - sprintf(xorriso->info_text, "Directory not removed: %s", - Text_shellsafe(path, sfe, 0)); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); - if(ret>0) - ret= 3; - goto ex; - } - } - } else { - if(!(flag&2)) { /* not rmdir */ - sprintf(xorriso->info_text, "%s in loaded ISO image is a directory", - Text_shellsafe(path, sfe, 0)); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); - ret= 0; goto ex; - } - - ret= iso_dir_get_children((IsoDir *) victim_node, &iter); - Xorriso_process_msg_queues(xorriso,0); - if(ret<0) - goto cannot_create_iter; - if(ret>0) { - if(iso_dir_iter_next(iter, &node) == 1) { - sprintf(xorriso->info_text, - "Directory not empty on attempt to delete: %s", - Text_shellsafe(path, sfe, 0)); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); - ret= 0; goto ex; - } - } - } - } - - if(xorriso->request_to_abort) - {ret= 3; goto ex;} - boss_node= iso_node_get_parent(victim_node); - Xorriso_process_msg_queues(xorriso,0); - if(boss_node==NULL) { - sprintf(xorriso->info_text, - "Cannot find parent node of %s in loaded ISO image", - Text_shellsafe(path, sfe, 0)); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); - ret= 0; goto ex; - } - - while((xorriso->do_reassure==1 || (xorriso->do_reassure==2 && !(flag&4))) - && !xorriso->request_not_to_ask) { - /* ls -ld */ - Xorriso_ls_filev(xorriso, xorriso->wdi, 1, &path, (off_t) 0, 1|2|8); - if(is_dir) /* du -s */ - Xorriso_ls_filev(xorriso, xorriso->wdi, 1, &path, (off_t) 0, 2|4); - if(flag&8) - sprintf(xorriso->info_text, - "File exists. Remove ? n= keep old, y= remove, x= abort, @= stop asking\n"); - else - sprintf(xorriso->info_text, - "Remove above file ? n= keep it, y= remove it, x= abort, @= stop asking\n"); - Xorriso_info(xorriso, 4); - ret= Xorriso_request_confirmation(xorriso, 1|2|4|16); - if(ret<=0) - goto ex; - if(xorriso->request_to_abort) { - sprintf(xorriso->info_text, - "Removal operation aborted by user before file: %s", - Text_shellsafe(path, sfe, 0)); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); - ret= 3; goto ex; - } - if(ret==3) - continue; - if(ret==6) /* yes */ - break; - if(ret==4) { /* yes, do not ask again */ - xorriso->request_not_to_ask= 1; - break; - } - if(ret==1) { /* no */ - sprintf(xorriso->info_text, "Kept in existing state: %s", - Text_shellsafe(path, sfe, 0)); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); - ret= 3; goto ex; - } - } - - if(boss_iter!=NULL) { - ret= iso_dir_iter_remove((IsoDirIter *) boss_iter); - if(ret<0) - ret= -1; - } else - ret= iso_node_remove(victim_node); - Xorriso_process_msg_queues(xorriso,0); - if(ret==-1) { - sprintf(xorriso->info_text, - "Internal failure to remove %s from loaded ISO image", - Text_shellsafe(path, sfe, 0)); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); - ret= -1; goto ex; - } - xorriso->volset_change_pending= 1; - ret= 1+!!is_dir; -ex:; - -#ifndef Xorriso_fat_local_meM - if(sfe!=NULL) - free(sfe); - if(sub_path!=NULL) - free(sub_path); -#endif /* ! Xorriso_fat_local_meM */ - - if(iter!=NULL) - iso_dir_iter_free(iter); - return(ret); -} - - -int Xorriso__node_name_cmp(const void *node1, const void *node2) -{ - char *name1, *name2; - - name1= (char *) iso_node_get_name(*((IsoNode **) node1)); - name2= (char *) iso_node_get_name(*((IsoNode **) node2)); - return(strcmp(name1,name2)); -} - - -/* @param flag bit0= only accept directory nodes - bit1= do not report memory usage as DEBUG - bit2= do not apply search pattern but accept any node -*/ -int Xorriso_sorted_node_array(struct XorrisO *xorriso, - IsoDir *dir_node, - int *nodec, IsoNode ***node_array, - off_t boss_mem, int flag) -{ - int i, ret, failed_at; - char *npt; - IsoDirIter *iter= NULL; - IsoNode *node; - off_t mem; - - mem= ((*nodec)+1)*sizeof(IsoNode *); - ret= Xorriso_check_temp_mem_limit(xorriso, mem+boss_mem, flag&2); - if(ret<=0) - return(ret); - - *node_array= calloc(sizeof(IsoNode *), (*nodec)+1); - if(*node_array==NULL) { - sprintf(xorriso->info_text, - "Cannot allocate memory for %d directory entries", *nodec); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); - return(-1); - } - - ret= iso_dir_get_children(dir_node, &iter); - if(ret<0) { - sprintf(xorriso->info_text, "Cannot create IsoDirIter object"); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); - return(-1); - } - - for(i= 0; iso_dir_iter_next(iter, &node) == 1 && i<*nodec; ) { - npt= (char *) iso_node_get_name(node); - if(!(flag&4)) { - ret= Xorriso_regexec(xorriso, npt, &failed_at, 0); - if(ret) - continue; /* no match */ - } - if(flag&1) - if(!LIBISO_ISDIR(node)) - continue; - (*node_array)[i++]= node; - } - iso_dir_iter_free(iter); - *nodec= i; - if(*nodec<=0) - return(1); - qsort(*node_array, *nodec, sizeof(IsoNode *), Xorriso__node_name_cmp); - return(1); -} - - -/* @param flag bit0= do not only sum up sizes but also print subdirs -*/ -int Xorriso_show_du_subs(struct XorrisO *xorriso, IsoDir *dir_node, - char *abs_path, char *rel_path, off_t *size, - off_t boss_mem, int flag) -{ - int i, ret, no_sort= 0, filec= 0, l; - IsoDirIter *iter= NULL; - IsoNode *node, **node_array= NULL; - char *name; - off_t sub_size, report_size, mem= 0; - -#ifdef Xorriso_fat_local_meM - char path[SfileadrL], show_path[SfileadrL], sfe[5*SfileadrL]; -#else /* Xorriso_fat_local_meM */ - char *path= NULL, *show_path= NULL, *sfe= NULL; - - sfe= malloc(5*SfileadrL); - path= malloc(SfileadrL); - show_path= malloc(SfileadrL); - if(path==NULL || show_path==NULL || sfe==NULL) { - Xorriso_no_malloc_memory(xorriso, &sfe, 0); - {ret= -1; goto ex;} - } - -#endif /* ! Xorriso_fat_local_meM */ - - *size= 0; - ret= iso_dir_get_children(dir_node, &iter); - if(ret<0) { -cannot_create_iter:; - Xorriso_process_msg_queues(xorriso,0); - sprintf(xorriso->info_text, "Cannot obtain ISO directory iterator"); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); - {ret= -1; goto ex;} - } - for(i= 0; iso_dir_iter_next(iter, &node) == 1; ) { - sub_size= 0; - name= (char *) iso_node_get_name(node); - strcpy(show_path, rel_path); - if(Sfile_add_to_path(show_path, name, 0)<=0) - goto much_too_long; - if(LIBISO_ISDIR(node)) { - strcpy(path, abs_path); - if(Sfile_add_to_path(path, name, 0)<=0) { -much_too_long:; - Xorriso_much_too_long(xorriso, strlen(path)+strlen(name)+1, 2); - {ret= -1; goto ex;} - } - filec++; - l= strlen(rel_path)+1; - mem+= l; - if(l % sizeof(char *)) - mem+= sizeof(char *)-(l % sizeof(char *)); - if(flag&1) /* diving and counting is done further below */ - continue; - ret= Xorriso_show_du_subs(xorriso, (IsoDir *) node, - path, show_path, &sub_size, boss_mem, 0); - if(ret<0) - goto ex; - if(ret==0) - continue; - } - - if(LIBISO_ISREG(node)) { - sub_size+= iso_file_get_size((IsoFile *) node)+2048; -/* - sub_size+= iso_file_get_size((IsoFile *) node)+strlen(name)+1; -*/ - } - - if(sub_size>0) - (*size)+= sub_size; - Xorriso_process_msg_queues(xorriso,0); - } - - if(filec<=0 || !(flag&1)) - {ret= 1; goto ex;} - - /* Reset iteration */ - iso_dir_iter_free(iter); - iter= NULL; - Xorriso_process_msg_queues(xorriso,0); - - ret= Xorriso_sorted_node_array(xorriso, dir_node, &filec, &node_array, - boss_mem, 1|2|4); - if(ret<0) - goto ex; - if(ret==0) { - no_sort= 1; - ret= iso_dir_get_children(dir_node, &iter); - if(ret<0) - goto cannot_create_iter; - } - - for(i= 0; (no_sort || irequest_to_abort); i++) { - if(no_sort) { - ret= iso_dir_iter_next(iter, &node); - if(ret!=1) - break; - if(!LIBISO_ISDIR(node)) - continue; - } else - node= node_array[i]; - - sub_size= 0; - name= (char *) iso_node_get_name(node); - strcpy(show_path, rel_path); - if(Sfile_add_to_path(show_path, name, 0)<=0) - goto much_too_long; - strcpy(path, abs_path); - if(Sfile_add_to_path(path, name, 0)<=0) - goto much_too_long; - ret= Xorriso_show_du_subs(xorriso, (IsoDir *) node, - path, show_path, &sub_size, boss_mem+mem, flag&1); - if(ret<0) - goto ex; - - if(LIBISO_ISREG(node)) { - sub_size+= iso_file_get_size((IsoFile *) node)+2048; -/* - sub_size+= iso_tree_node_get_size((IsoFile *) node)+strlen(name)+1; -*/ - } - if(sub_size>0) - (*size)+= sub_size; - report_size= sub_size/1024; - if(report_size*1024result_line, "%7.f ",(double) (report_size)); - sprintf(xorriso->result_line+strlen(xorriso->result_line), "%s\n", - Text_shellsafe(show_path, sfe, 0)); - Xorriso_result(xorriso, 0); - } - ret= 1; -ex:; - -#ifndef Xorriso_fat_local_meM - if(sfe!=NULL) - free(sfe); - if(path!=NULL) - free(path); - if(show_path!=NULL) - free(show_path); -#endif /* ! Xorriso_fat_local_meM */ - - if(iter!=NULL) - iso_dir_iter_free(iter); - if(node_array!=NULL) - free((char *) node_array); - Xorriso_process_msg_queues(xorriso,0); - return(ret); -} - - -/* @param flag bit0= *node is already valid */ -int Xorriso_fake_stbuf(struct XorrisO *xorriso, char *path, struct stat *stbuf, - IsoNode **node, int flag) -{ - int ret; - IsoImage *volume; - - memset((char *) stbuf, 0, sizeof(struct stat)); - if(!(flag&1)) { - ret= Xorriso_get_volume(xorriso, &volume, 0); - if(ret<=0) - return(-1); - ret= Xorriso_node_from_path(xorriso, volume, path, node, 1); - if(ret<=0) - *node= NULL; - } - if(*node==NULL) - return(0); - - /* >>> stbuf->st_dev */ - /* >>> stbuf->st_ino */ - - stbuf->st_mode= iso_node_get_permissions(*node) & 07777; - if(LIBISO_ISDIR(*node)) - stbuf->st_mode|= S_IFDIR; - else if(LIBISO_ISREG(*node)) - stbuf->st_mode|= S_IFREG; - else if(LIBISO_ISLNK(*node)) - stbuf->st_mode|= S_IFLNK; - else if(LIBISO_ISLNK(*node)) - stbuf->st_mode|= S_IFCHR; - else if(LIBISO_ISBLK(*node)) - stbuf->st_mode|= S_IFBLK; - else if(LIBISO_ISFIFO(*node)) - stbuf->st_mode|= S_IFIFO; - else if(LIBISO_ISSOCK(*node)) - stbuf->st_mode|= S_IFSOCK; - - /* >>> NG How to represent LIBISO_BOOT ? */ - - - /* >>> With directories this should be : number of subdirs + 2 */ - /* >>> ??? How to obtain RR hardlink number for other types ? */ - stbuf->st_nlink= 1; - - stbuf->st_uid= iso_node_get_uid(*node); - stbuf->st_gid= iso_node_get_gid(*node); - - /* >>> stbuf->st_rdev */ - - if(LIBISO_ISREG(*node)) - stbuf->st_size= iso_file_get_size((IsoFile *) *node)+2048; - else - stbuf->st_size= 0; - - stbuf->st_blksize= 2048; - stbuf->st_blocks= stbuf->st_size / (off_t) 2048; - if(stbuf->st_blocks * (off_t) 2048 != stbuf->st_size) - stbuf->st_blocks++; - - stbuf->st_atime= iso_node_get_atime(*node); - stbuf->st_mtime= iso_node_get_mtime(*node); - stbuf->st_ctime= iso_node_get_ctime(*node); - return(1); -} - - -int Xorriso_sorted_dir_i(struct XorrisO *xorriso, IsoDir *dir_node, - int *filec, char ***filev, off_t boss_mem, int flag) -{ - int i,j,ret; - IsoDirIter *iter= NULL; - IsoNode *node; - char *name; - off_t mem; - - (*filec)= 0; - (*filev)= NULL; - - ret= iso_dir_get_children(dir_node, &iter); - if(ret<0) { -cannot_iter:; - Xorriso_process_msg_queues(xorriso,0); - sprintf(xorriso->info_text, "Cannot obtain ISO directory iterator"); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); - {ret= -1; goto ex;} - } - mem= 0; - for(i= 0; iso_dir_iter_next(iter, &node) == 1; ) { - name= (char *) iso_node_get_name(node); - mem+= sizeof(char *)+strlen(name)+8; - (*filec)++; - } - iso_dir_iter_free(iter); - iter= NULL; - if(*filec==0) - {ret= 1; goto ex;} - - ret= Xorriso_check_temp_mem_limit(xorriso, mem+boss_mem, 2); - if(ret<=0) - goto ex; - (*filev)= (char **) calloc(*filec, sizeof(char *)); - if(*filev==NULL) - {ret= -1; goto ex; } - ret= iso_dir_get_children(dir_node, &iter); - if(ret<0) - goto cannot_iter; - for(i= 0; i<*filec; i++) { - ret= iso_dir_iter_next(iter, &node); - if(ret!=1) - break; - name= (char *) iso_node_get_name(node); - (*filev)[i]= strdup(name); - if((*filev)[i]==NULL) { - for(j= 0; jresult_line; - - ret= Xorriso_get_volume(xorriso, &volume, 0); - if(ret<=0) - return(ret); - - Sort_argv(filec, filev, 0); - - /* Count valid nodes, warn of invalid ones */ - for(i= 0; iinfo_text, "Not found in ISO image: %s", - Text_shellsafe(path, sfe, 0)); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0); - was_error++; - continue; - } - } - - if((flag&8) && !(flag&(2|4))) { - sprintf(xorriso->info_text, "Valid ISO nodes found: %d\n", filec-was_error); - Xorriso_info(xorriso,1); - if(filec-was_error<=0) - return(!was_error); - } - - passes= 1+!(flag&(4|8)); - for(pass= 0; passrequest_to_abort); i++) { - rpt[0]= 0; - ret= Xorriso_make_abs_adr(xorriso, wd, filev[i], path, 1|2|4); - if(ret<=0) - continue; - ret= Xorriso_fake_stbuf(xorriso, path, &stbuf, &node, 0); - if(ret<=0) - continue; - if(LIBISO_ISDIR(node) && !(flag&(4|8))) { - if(pass==0) - continue; - if(filec>1) { - strcpy(xorriso->result_line, "\n"); - Xorriso_result(xorriso,0); - sprintf(xorriso->result_line, "%s:\n", Text_shellsafe(filev[i], sfe,0)); - Xorriso_result(xorriso,0); - } - ret= Xorriso_sorted_dir_i(xorriso, - (IsoDir *) node, &dfilec, &dfilev, boss_mem, 0); - if(ret<=0) { - - /* >>> libisofs iterator loop and single item Xorriso_lsx_filev() */; - - } else { - if(flag&1) { - sprintf(xorriso->result_line, "total %d\n", dfilec); - Xorriso_result(xorriso,0); - } - Xorriso_ls_filev(xorriso, path, - dfilec, dfilev, boss_mem, (flag&1)|2|8); - } - if(dfilec>0) - Sfile_destroy_argv(&dfilec, &dfilev, 0); - continue; - } else - if(pass>0) - continue; - link_target[0]= 0; - if((flag&5)==1) { /* -ls_l */ - ret= Xorriso_format_ls_l(xorriso, &stbuf, 0); - if(ret<=0) - continue; - if(LIBISO_ISLNK(node)) { - if(Sfile_str(link_target, (char *) iso_symlink_get_dest( - (IsoSymlink *) node), 0)<=0) - link_target[0]= 0; - } - } else if(flag&4) { /* -du or -dus */ - size= stbuf.st_size; - if(S_ISDIR(stbuf.st_mode)) { - ret= Xorriso_show_du_subs(xorriso, (IsoDir *) node, - path, filev[i], &size, boss_mem, flag&1); - if(ret<0) - return(-1); - if(ret==0) - continue; - } - sprintf(rpt, "%7.f ",(double) (size/1024)); - } - if(link_target[0] && (flag&5)==1) - sprintf(xorriso->result_line+strlen(xorriso->result_line), "%s -> %s\n", - Text_shellsafe(filev[i], sfe, 0), - Text_shellsafe(link_target, sfe2, 0)); - else - sprintf(xorriso->result_line+strlen(xorriso->result_line), "%s\n", - Text_shellsafe(filev[i], sfe, 0)); - Xorriso_result(xorriso, 0); - } - return(!was_error); -} - - -/* This function needs less buffer memory than Xorriso_ls_filev() but cannot - perform structured pattern matching as done by Xorriso_expand_pattern() - for subsequent Xorriso_ls_filev(). - @param flag bit0= long format - bit1= only check for directory existence - bit2= do not apply search pattern but accept any file -*/ -int Xorriso_ls(struct XorrisO *xorriso, int flag) -{ - int ret, is_dir= 0, i, filec= 0, failed_at, no_sort= 0; - IsoNode *node, **node_array= NULL; - IsoDir *dir_node; - IsoImage *volume; - IsoDirIter *iter= NULL; - char sfe[5*SfileadrL], sfe2[5*SfileadrL], link_target[SfileadrL], *npt, *rpt; - struct stat stbuf; - - rpt= xorriso->result_line; - - ret= Xorriso_get_volume(xorriso, &volume, 0); - if(ret<=0) - return(ret); - - ret= Xorriso_node_from_path(xorriso, volume, xorriso->wdi, &node, 0); - if(ret<=0) - goto wdi_is_not_a_dir; - if(LIBISO_ISDIR(node)) - is_dir= 1; - if(!is_dir) { -wdi_is_not_a_dir:; - sprintf(xorriso->info_text, - "Working directory path does not lead to a directory in ISO image"); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); - ret= 0; goto ex; - } - if(flag&2) - {ret= 1; goto ex;} - - dir_node= (IsoDir *) node; - ret= iso_dir_get_children(dir_node, &iter); - if(ret<0) { -cannot_create_iter:; - Xorriso_process_msg_queues(xorriso,0); - sprintf(xorriso->info_text, "Cannot obtain ISO directory iterator"); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); - {ret= -1; goto ex;} - } - Xorriso_process_msg_queues(xorriso,0); - - for(i= 0; iso_dir_iter_next(iter, &node) == 1; ) { - npt= (char *) iso_node_get_name(node); - if(!(flag&4)) { - ret= Xorriso_regexec(xorriso, npt, &failed_at, 0); - if(ret) - continue; /* no match */ - } - filec++; - } - /* Reset iteration */ - iso_dir_iter_free(iter); - iter= NULL; - Xorriso_process_msg_queues(xorriso,0); - - sprintf(xorriso->info_text, "Valid ISO nodes found: %d\n", filec); - Xorriso_info(xorriso,1); - - ret= Xorriso_sorted_node_array(xorriso, dir_node, &filec, &node_array, 0, - flag&4); - if(ret<0) - goto ex; - if(ret==0) { - no_sort= 1; - ret= iso_dir_get_children(dir_node, &iter); - if(ret<0) - goto cannot_create_iter; - } - - for(i= 0; irequest_to_abort); i++) { - if(no_sort) { - ret= iso_dir_iter_next(iter, &node); - if(ret!=1) - break; - npt= (char *) iso_node_get_name(node); - if(!(flag&4)) { - ret= Xorriso_regexec(xorriso, npt, &failed_at, 0); - if(ret) - continue; /* no match */ - } - } else - node= node_array[i]; - - npt= (char *) iso_node_get_name(node); - link_target[0]= 0; - if(LIBISO_ISLNK(node)) { - if(Sfile_str(link_target, (char *) iso_symlink_get_dest( - (IsoSymlink *) node), 0)<=0) - link_target[0]= 0; - } - rpt[0]= 0; - if(flag&1) { - ret= Xorriso_fake_stbuf(xorriso, "", &stbuf, &node, 1); - if(ret<=0) - continue; - ret= Xorriso_format_ls_l(xorriso, &stbuf, 0); - if(ret<=0) - continue; - } - if(link_target[0] && (flag&1)) - sprintf(xorriso->result_line+strlen(xorriso->result_line), "%s -> %s\n", - Text_shellsafe(npt, sfe, 0), - Text_shellsafe(link_target, sfe2, 0)); - else - sprintf(xorriso->result_line+strlen(xorriso->result_line), "%s\n", - Text_shellsafe(npt, sfe, 0)); - Xorriso_result(xorriso, 0); - } - - ret= 1; -ex:; - if(iter!=NULL) - iso_dir_iter_free(iter); - Xorriso_process_msg_queues(xorriso,0); - if(node_array!=NULL) - free((char *) node_array); - return(1); -} - - -int Xorriso_rename(struct XorrisO *xorriso, char *origin, char *dest, int flag) -{ - int ret, ol, dest_ret; - char sfe[5*SfileadrL], eff_dest[SfileadrL], dir_adr[SfileadrL], *cpt; - char *leafname, eff_origin[SfileadrL], sfe2[5*SfileadrL], *old_leafname; - IsoImage *volume; - IsoDir *origin_dir, *dest_dir; - IsoNode *node, *iso_node; - - ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, origin, eff_origin, 0); - if(ret<=0) - return(ret); - dest_ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, dest, eff_dest,1); - if(dest_ret<0) - return(dest_ret); - if(dest_ret==0) { /* obtain eff_dest address despite it does not exist */ - ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, dest, eff_dest, 2); - if(ret<=0) - return(ret); - } - - /* Prevent that destination is a subordinate of origin - (that would be a black hole plopping out of the universe) */ - ol= strlen(eff_origin); - if(ol==0) { - sprintf(xorriso->info_text, "May not rename root directory"); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); - return(0); - } else if(strcmp(eff_origin, eff_dest)==0) { - sprintf(xorriso->info_text, "Ignored attempt to rename %s to itself", - Text_shellsafe(eff_origin,sfe,0)); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0); - return(0); - } else if(strncmp(eff_origin, eff_dest, ol)==0 && - (eff_dest[ol]==0 || eff_dest[ol]=='/')) { - sprintf(xorriso->info_text, - "May not rename %s to its own sub address %s", - Text_shellsafe(eff_origin,sfe,0), Text_shellsafe(eff_dest,sfe2,0)); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); - return(0); - } - - /* Check whether destination exists and may be not overwriteable */ - if(dest_ret==2 && xorriso->do_overwrite!=1) { - sprintf(xorriso->info_text, "Renaming may not overwrite directory: %s", - Text_shellsafe(eff_dest, sfe, 0)); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); - return(0); - } else if (dest_ret==1 && !xorriso->do_overwrite) { - sprintf(xorriso->info_text, "Renaming may not overwite: %s", - Text_shellsafe(eff_dest, sfe, 0)); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); - return(0); - } else if(dest_ret>0) { - ret= Xorriso_rmi(xorriso, NULL, eff_dest, 1|8); - if(ret<=0) - return(0); - if(ret==3) { - sprintf(xorriso->info_text, "User revoked renaming of: %s", - Text_shellsafe(eff_origin, sfe, 0)); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); - return(0); - } - } - - /* Ensure existence of destination directory */ - strcpy(dir_adr, eff_dest); - cpt= strrchr(dir_adr, '/'); - if(cpt==NULL) - cpt= dir_adr+strlen(dir_adr); - *cpt= 0; - if(dir_adr[0]!=0) { - ret= Xorriso_graft_in(xorriso, NULL, dir_adr, 1); - if(ret<=0) - return(ret); - } - - /* Move node */ - ret= Xorriso_get_volume(xorriso, &volume, 0); - if(ret<=0) - return(ret); - Xorriso_node_from_path(xorriso, volume, dir_adr, &iso_node, 0); - dest_dir= (IsoDir *) iso_node; - strcpy(dir_adr, eff_origin); - cpt= strrchr(dir_adr, '/'); - if(cpt==NULL) - cpt= dir_adr+strlen(dir_adr); - *cpt= 0; - Xorriso_node_from_path(xorriso, volume, dir_adr, &iso_node, 0); - origin_dir= (IsoDir *) iso_node; - Xorriso_node_from_path(xorriso, volume, eff_origin, &node, 0); - if(dest_dir==NULL || origin_dir==NULL || node==NULL) { - Xorriso_process_msg_queues(xorriso,0); - sprintf(xorriso->info_text, - "Internal error on rename: confirmed node turns out as NULL"); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); - return(-1); - } - ret= iso_node_take(node); - if(ret<0) { - Xorriso_process_msg_queues(xorriso,0); - sprintf(xorriso->info_text, - "Internal error on rename: failed to take node"); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); - return(-1); - } - ret= iso_dir_add_node(dest_dir, node, 0); - if(ret<0) { - Xorriso_process_msg_queues(xorriso,0); - sprintf(xorriso->info_text, - "Internal error on rename: failed to insert node"); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); - return(-1); - } - leafname= strrchr(eff_dest, '/'); - if(leafname==NULL) - leafname= eff_dest; - else - leafname++; - - old_leafname= (char *) iso_node_get_name(node); - if(strcmp(leafname, old_leafname)!=0) - ret= iso_node_set_name(node, leafname); - if(ret<0) { - Xorriso_process_msg_queues(xorriso,0); - sprintf(xorriso->info_text, "Internal error on rename: failed to set name"); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); - return(-1); - } - Xorriso_process_msg_queues(xorriso,0); - return(1); -} - - -/* @param flag bit0= do not produce info message on success - @return 1=success, - 0=was already directory, -1=was other type, -2=other error -*/ -int Xorriso_mkdir(struct XorrisO *xorriso, char *path, int flag) -{ - int ret; - char eff_path[SfileadrL], sfe[5*SfileadrL]; - - ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, path, eff_path, 1); - if(ret<0) - return(-2); - if(ret>0) { - sprintf(xorriso->info_text,"-mkdir: Address already existing %s", - Text_shellsafe(eff_path, sfe, 0)); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, - (ret==2 ? "WARNING" : "SORRY"), 0); - return(-1+(ret==2)); - } - ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, path, eff_path, 2); - if(ret<0) - return(-2); - ret= Xorriso_graft_in(xorriso, NULL, eff_path, 1); - if(ret<=0) - return(-2); - if(!(flag&1)) { - sprintf(xorriso->info_text, "Created directory in ISO image: %s\n", - Text_shellsafe(eff_path,sfe,0)); - Xorriso_info(xorriso, 0); - } - return(1); -} - - -/* @param flag bit0= count results rather than storing them - bit1= this is a recursion - bit2= prepend wd (automatically done if wd[0]!=0) -*/ -int Xorriso_obtain_pattern_files_i( - struct XorrisO *xorriso, char *wd, IsoDir *dir, - int *filec, char **filev, int count_limit, off_t *mem, - int *dive_count, int flag) -{ - int ret, failed_at; - IsoDirIter *iter= NULL; - IsoNode *node; - char *name; - -#ifdef Xorriso_fat_local_meM - char adr[SfileadrL]; -#else /* Xorriso_fat_local_meM */ - char *adr= NULL; - - adr= malloc(SfileadrL); - if(adr==NULL) { - Xorriso_no_malloc_memory(xorriso, &adr, 0); - {ret= -1; goto ex;} - } -#endif /* ! Xorriso_fat_local_meM */ - - - if(!(flag&2)) - *dive_count= 0; - else - (*dive_count)++; - ret= Xorriso_check_for_root_pattern(xorriso, filec, filev, count_limit, - mem, (flag&1)|2); - if(ret!=2) - goto ex; - - ret= iso_dir_get_children(dir, &iter); - if(ret<0) { - Xorriso_process_msg_queues(xorriso,0); - sprintf(xorriso->info_text, "Cannot obtain ISO directory iterator"); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); - {ret= -1; goto ex;} - } - while(iso_dir_iter_next(iter, &node) == 1) { - name= (char *) iso_node_get_name(node); - ret= Xorriso_make_abs_adr(xorriso, wd, name, adr, flag&4); - if(ret<=0) - goto ex; - ret= Xorriso_regexec(xorriso, adr, &failed_at, 1); - if(ret) { /* no match */ - if(failed_at <= *dive_count) /* no hope for a match */ - continue; - - if(!LIBISO_ISDIR(node)) { - - /* >>> How to deal with softlinks ? */ - - continue; - } - /* dive deeper */ - ret= Xorriso_obtain_pattern_files_i( - xorriso, adr, (IsoDir *) node, - filec, filev, count_limit, mem, dive_count, flag|2); - if(ret<=0) - goto ex; - } else { - ret= Xorriso_register_matched_adr(xorriso, adr, count_limit, - filec, filev, mem, (flag&1)|2); - if(ret<=0) - goto ex; - } - } - ret= 1; -ex:; - -#ifndef Xorriso_fat_local_meM - if(adr!=NULL) - free(adr); -#endif /* ! Xorriso_fat_local_meM */ - - if(flag&2) - (*dive_count)--; - return(ret); -} - - -/* @param flag bit0= a match count !=1 is a SORRY event - bit1= with bit0 tolerate 0 matches if pattern is a constant -*/ -int Xorriso_expand_pattern(struct XorrisO *xorriso, - int num_patterns, char **patterns, int extra_filec, - int *filec, char ***filev, off_t *mem, int flag) -{ - int ret, count= 0, abs_adr= 0, i, was_count, was_filec; - int nonconst_mismatches= 0, dive_count= 0; - char sfe[5*SfileadrL]; - IsoImage *volume; - IsoDir *dir= NULL, *root_dir; - IsoNode *iso_node; - - *filec= 0; - *filev= NULL; - - xorriso->search_mode= 3; - xorriso->structured_search= 1; - - ret= Xorriso_get_volume(xorriso, &volume, 0); - if(ret<=0) - return(ret); - root_dir= iso_image_get_root(volume); - if(root_dir==NULL) { - Xorriso_process_msg_queues(xorriso,0); - sprintf(xorriso->info_text, - "While expanding pattern : Cannot obtain root node of ISO image"); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); - ret= -1; goto ex; - } - - for(i= 0; iwdi does not exist yet, but one may - not use it as base for relative address searches. - */ - ret= Xorriso_node_from_path(xorriso, volume, xorriso->wdi, &iso_node, 1); - dir= (IsoDir *) iso_node; - if(ret<=0) { - Xorriso_process_msg_queues(xorriso,0); - sprintf(xorriso->info_text, - "While expanding pattern %s : Working directory does not exist in ISO image", - Text_shellsafe(patterns[i], sfe, 0)); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); - ret= 0; goto ex; - } - if(!LIBISO_ISDIR((IsoNode *) dir)) { - sprintf(xorriso->info_text, - "Working directory path does not lead to a directory in ISO image"); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); - ret= 0; goto ex; - } - } - - /* count the matches */ - was_count= count; - ret= Xorriso_obtain_pattern_files_i(xorriso, "", dir, &count, NULL, 0, - mem, &dive_count, 1 | abs_adr); - if(ret<=0) - goto ex; - if(was_count==count && strcmp(patterns[i],"*")!=0 && (flag&3)!=1) { - count++; - Xorriso_eval_nonmatch(xorriso, patterns[i], &nonconst_mismatches, mem, 0); - } - } - - ret= Xorriso_check_matchcount(xorriso, count, nonconst_mismatches, - num_patterns, patterns, flag&1); - if(ret<=0) - goto ex; - count+= extra_filec; - mem+= extra_filec*sizeof(char *); - if(count<=0) - {ret= 0; goto ex;} - ret= Xorriso_alloc_pattern_mem(xorriso, *mem, count, filev, 0); - if(ret<=0) - goto ex; - /* now store addresses */ - for(i= 0; iinfo_text,"Permissions now: %-5.5o %s", - mode, Text_shellsafe(path, sfe, 0)); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0); - xorriso->volset_change_pending= 1; - Xorriso_process_msg_queues(xorriso,0); - return(1); -} - - -int Xorriso_set_uid(struct XorrisO *xorriso, char *in_path, uid_t uid, - int flag) -{ - int ret; - IsoNode *node; - - ret= Xorriso_get_node_by_path(xorriso, in_path, NULL, &node, 0); - if(ret<=0) - return(ret); - iso_node_set_uid(node, uid); - iso_node_set_ctime(node, time(NULL)); - xorriso->volset_change_pending= 1; - Xorriso_process_msg_queues(xorriso,0); - return(1); -} - - -int Xorriso_set_gid(struct XorrisO *xorriso, char *in_path, gid_t gid, - int flag) -{ - int ret; - IsoNode *node; - - ret= Xorriso_get_node_by_path(xorriso, in_path, NULL, &node, 0); - if(ret<=0) - return(ret); - iso_node_set_gid(node, gid); - iso_node_set_ctime(node, time(NULL)); - xorriso->volset_change_pending= 1; - Xorriso_process_msg_queues(xorriso,0); - return(1); -} - - -/* @parm flag bit0= atime, bit1= ctime, bit2= mtime, bit8=no auto ctime */ -int Xorriso_set_time(struct XorrisO *xorriso, char *in_path, time_t t, - int flag) -{ - int ret; - IsoNode *node; - - ret= Xorriso_get_node_by_path(xorriso, in_path, NULL, &node, 0); - if(ret<=0) - return(ret); - if(flag&1) - iso_node_set_atime(node, t); - if(flag&2) - iso_node_set_ctime(node, t); - if(flag&4) - iso_node_set_mtime(node, t); - if(!(flag&(2|256))) - iso_node_set_ctime(node, time(NULL)); - xorriso->volset_change_pending= 1; - Xorriso_process_msg_queues(xorriso,0); - return(1); -} - - -int Xorriso_findi_action(struct XorrisO *xorriso, struct FindjoB *job, - char *abs_path, char *show_path, - IsoNode *node, int depth, int flag) -{ - int ret= 0, type, action= 0; - uid_t user= 0; - gid_t group= 0; - time_t date= 0; - mode_t mode_or= 0, mode_and= ~1; - char *target, sfe[5*SfileadrL]; - struct FindjoB *subjob; - struct stat dir_stbuf; - - action= Findjob_get_action_parms(job, &target, &user, &group, - &mode_and, &mode_or, &type, &date, &subjob, 0); - if(action<0) - action= 0; - - if(action==1) { - /* >>> rm */; - } else if(action==2) { - - /* >>> rm_r */; - - } else if(action==3) { - - /* >>> mv target */; - - } else if(action==4) { /* chown */ - ret= Xorriso_set_uid(xorriso, abs_path, user, 0); - } else if(action==5) { /* chgrp */ - ret= Xorriso_set_gid(xorriso, abs_path, group, 0); - } else if(action==6) { /* chmod */ - ret= Xorriso_set_st_mode(xorriso, abs_path, mode_and, mode_or, 0); - } else if(action==7) { /* alter_date */ - ret= Xorriso_set_time(xorriso, abs_path, date, type&7); - } else if(action==8) { /* lsdl */ - ret= Xorriso_ls_filev(xorriso, "", 1, &abs_path, (off_t) 0, 1|2|8); - } else if(action>=9 && action<=13) { /* actions which have own findjobs */ - Findjob_set_start_path(subjob, abs_path, 0); - ret= Xorriso_findi(xorriso, subjob, NULL, abs_path, &dir_stbuf, depth, 0); - } else { - sprintf(xorriso->result_line, "%s\n", Text_shellsafe(show_path, sfe, 0)); - Xorriso_result(xorriso, 0); - ret= 1; - } - return(ret); -} - - -int Xorriso_findi(struct XorrisO *xorriso, struct FindjoB *job, - void *dir_node_generic, char *dir_path, - struct stat *dir_stbuf, int depth, int flag) -{ - int ret, action= 0; - IsoDirIter *iter= NULL; - IsoDir *dir_node; - IsoNode *node, *iso_node; - IsoImage *volume; - struct stat stbuf; - char *name; -#ifdef Xorriso_fat_local_meM - char path[SfileadrL], abs_path[SfileadrL]; -#else /* Xorriso_fat_local_meM */ - char *path= NULL, *abs_path= NULL; - - path= malloc(SfileadrL); - abs_path= malloc(SfileadrL); - if(path==NULL || abs_path==NULL) { - Xorriso_no_malloc_memory(xorriso, &path, 0); - {ret= -1; goto ex;} - } -#endif /* ! Xorriso_fat_local_meM */ - - action= Findjob_get_action(job, 0); - if(action<0) - action= 0; - - dir_node= (IsoDir *) dir_node_generic; - if(dir_node==NULL) { - ret= Xorriso_get_volume(xorriso, &volume, 0); - if(ret<=0) - {ret= -1; goto ex;} - ret= Xorriso_make_abs_adr(xorriso, xorriso->wdi, dir_path, path, 1|2|4); - if(ret<=0) - goto ex; - ret= Xorriso_node_from_path(xorriso, volume, path, &iso_node, 0); - dir_node= (IsoDir *) iso_node; - if(ret<=0) - {ret= 0; goto ex;} - ret= Xorriso_fake_stbuf(xorriso, "", dir_stbuf, &iso_node, 1); - dir_node= (IsoDir *) iso_node; - if(ret<=0) - goto ex; - - name= strrchr(dir_path, '/'); - if(name==NULL) - name= dir_path; - else - name++; - ret= Findjob_test(job, name, NULL, dir_stbuf, depth, 0); - if(ret<0) - goto ex; - if(ret>0) { - ret= Xorriso_findi_action(xorriso, job, path, dir_path, - (IsoNode *) dir_node, depth, 0); - if(ret<=0) - goto ex; - } - } - if(!LIBISO_ISDIR((IsoNode *) dir_node)) - {ret= 2; goto ex;} - - ret= iso_dir_get_children(dir_node, &iter); - if(ret<0) { - Xorriso_process_msg_queues(xorriso,0); - sprintf(xorriso->info_text, "Cannot obtain ISO directory iterator"); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); - {ret= -1; goto ex;} - } - while(iso_dir_iter_next(iter, &node) == 1 && !xorriso->request_to_abort) { - name= (char *) iso_node_get_name(node); - ret= Xorriso_make_abs_adr(xorriso, dir_path, name, path, 4); - if(ret<=0) - goto ex; - ret= Xorriso_fake_stbuf(xorriso, "", &stbuf, &node, 1); - if(ret<0) - goto ex; - if(ret==0) - continue; - - ret= Findjob_test(job, name, dir_stbuf, &stbuf, depth, 0); - if(ret<0) - goto ex; - if(ret>0) { - ret= Xorriso_make_abs_adr(xorriso, xorriso->wdi, path, abs_path, 1|4); - if(ret<=0) - goto ex; - ret= Xorriso_findi_action(xorriso, job, abs_path, path, node, depth, 0); - if(ret<=0) { - if(Xorriso_eval_problem_status(xorriso, ret, 1|2)<0) - goto ex; - } - } - - if(S_ISDIR(stbuf.st_mode)) { - ret= Xorriso_findi(xorriso, job, (void *) node, path, - &stbuf, depth+1, flag); - if(ret<0) - goto ex; - } - } - - ret= 1; -ex:; - -#ifndef Xorriso_fat_local_meM - if(path!=NULL) - free(path); - if(abs_path!=NULL) - free(abs_path); -#endif /* ! Xorriso_fat_local_meM */ - - Xorriso_process_msg_queues(xorriso,0); - if(iter!=NULL) - iso_dir_iter_free(iter); - return(ret); -} - - -/* @param flag bit0= do not mark image as changed */ -int Xorriso_set_volid(struct XorrisO *xorriso, char *volid, int flag) -{ - int ret; - IsoImage *volume; - - ret= Xorriso_get_volume(xorriso, &volume, 0); - if(ret<=0) - return(ret); - iso_image_set_volume_id(volume, volid); - if(!(flag&1)) - xorriso->volset_change_pending= 1; - Xorriso_process_msg_queues(xorriso,0); - sprintf(xorriso->info_text,"Volume ID: '%s'",iso_image_get_volume_id(volume)); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0); - return(1); -} - - -int Xorriso_get_volid(struct XorrisO *xorriso, char volid[33], int flag) -{ - int ret; - IsoImage *volume; - - ret= Xorriso_get_volume(xorriso, &volume, 0); - if(ret<=0) - return(ret); - strncpy(volid, iso_image_get_volume_id(volume), 32); - volid[32]= 0; - return(1); -} - diff --git a/libisoburn/trunk/test/xorriso.txt b/libisoburn/trunk/test/xorriso.txt deleted file mode 100644 index 56e8cc88..00000000 --- a/libisoburn/trunk/test/xorriso.txt +++ /dev/null @@ -1,49 +0,0 @@ - --------------------------------------------------------------------------- -The architecture of the xorriso application is planned as follows: - -The main program module creates a xorriso object, calls startup-file reading, -argument reading, and eventual dialog shell function. - -The xorriso class module implements the xorriso state object and above three -main functions. These functions rely on a common interpreter of a list of -words as described in man xorriso, paragraph "Command processing". -The list may contain more than one command with its parameters. It is intended -to be either the list of program arguments or a list parsed from a single -input line. - -The interpreter converts the words command-wise into suitable parameters -for an actor function which performs the command's action resp. a setter -function which brings the command's setting into effect. The interpreter then -calls this function immediately and synchronously. - -These option functions form a well documented API which may be used by -interpreters of things other than words. E.g. by a GUI module or as libxorriso. - -xorriso will encapsulate libisoburn, libisofs and libburn. Although i know -it is not popular, i propose to link it with the object files of those -libraries and not against external library objects. - -(Did i watch somebody having an allergy against external programs ? -I got an allergy against .so . My immune system mistakes them for .DLL .) - - ->>> currently a stub for xorriso is derived from the source of scdbackup_askme. - --------------------------------------------------------------------------- -Emerging man page is now in text/xorriso.1 - -( Needs enhancement in libisofs: - -cut_out disk_path startbyte bytecount iso_rr_path - Cut out a piece of file disk_path and insert it into the ISO - image under the given iso_rr_path. - This is advised for files > 2 GiB - 2 KiB if you are not - certain that all your systems with ISO filesystem driver can - handle such large files. Depending on the libisofs - implementation, files of larger size may generate SORRY - events if they are processed uncut. - When reading those files pieces from media, you will have to - concatenate them in the correct sequence: - cat /mnt/file_part1 /mnt/file_part2 > $HOME/file -) - diff --git a/libisoburn/trunk/test/xorriso_timestamp.h b/libisoburn/trunk/test/xorriso_timestamp.h deleted file mode 100644 index f6cea9a7..00000000 --- a/libisoburn/trunk/test/xorriso_timestamp.h +++ /dev/null @@ -1 +0,0 @@ -#define Xorriso_timestamP "2008.01.25.175353" diff --git a/libisoburn/trunk/test/xorrisoburn.h b/libisoburn/trunk/test/xorrisoburn.h deleted file mode 100644 index e205eb23..00000000 --- a/libisoburn/trunk/test/xorrisoburn.h +++ /dev/null @@ -1,138 +0,0 @@ - - -/* 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, - - Provided under GPL version 2. - - This file contains the inner isofs- and burn-library interface of xorriso. -*/ - -#ifndef Xorrisoburn_includeD -#define Xorrisoburn_includeD yes - -struct XorrisO; -struct FindjoB; - -int Xorriso_startup_libraries(struct XorrisO *xorriso, int flag); - -/* @param flag bit0= global shutdown of libraries */ -int Xorriso_detach_libraries(struct XorrisO *xorriso, int flag); - -int Xorriso_create_empty_iso(struct XorrisO *xorriso, int flag); - -/* @param flag bit0=aquire as isoburn input drive - bit1=aquire as libburn output drive (as isoburn drive if bit0) - @return <=0 failure , 1=success , 2=neither readable or writeable -*/ -int Xorriso_aquire_drive(struct XorrisO *xorriso, char *adr, int flag); - -int Xorriso_give_up_drive(struct XorrisO *xorriso, int flag); - -int Xorriso_write_session(struct XorrisO *xorriso, int flag); - -/* @param flag bit0=graft in as empty directory, not as copy from disk - @return <=0 = error , 1 = added simple node , 2 = added directory -*/ -int Xorriso_graft_in(struct XorrisO *xorriso, char *disk_path, char *img_path, - int flag); - -int Xorriso__text_to_sev(char *severity_name, int *severity_number,int flag); - -/* @param flag bit0=report about output drive - bit1=short report form -*/ -int Xorriso_toc(struct XorrisO *xorriso, int flag); - -int Xorriso_show_devices(struct XorrisO *xorriso, int flag); - -int Xorriso_tell_media_space(struct XorrisO *xorriso, - int *media_space, int *free_space, int flag); - -int Xorriso_blank_media(struct XorrisO *xorriso, int flag); - -int Xorriso_format_media(struct XorrisO *xorriso, int flag); - -/* @param boss_iter Opaque internal handle. Use NULL outside xorrisoburn.c : - If not NULL then this is an iterator suitable for - iso_tree_node_remove_iter() which is then to be used instead - of iso_tree_node_remove(). - @param flag bit0= remove whole sub tree: rm -r - bit1= remove empty directory: rmdir - bit2= recursion: do not reassure in mode 2 "tree" - bit3= this is for overwriting and not for plain removal - @return <=0 = error - 1 = removed simple node - 2 = removed directory or tree - 3 = did not remove on user revocation -*/ -int Xorriso_rmi(struct XorrisO *xorriso, void *boss_iter, - char *path, int flag); - -/* @param flag bit0= long format - bit1= do not print count of nodes - bit2= du format - bit3= print directories as themselves (ls -d) -*/ -int Xorriso_ls_filev(struct XorrisO *xorriso, char *wd, - int filec, char **filev, off_t boss_mem, int flag); - -/* This function needs less buffer memory than Xorriso_ls_filev() but cannot - perform structured pattern matching. - @param flag bit0= long format - bit1= only check for directory existence - bit2= do not apply search pattern but accept any file -*/ -int Xorriso_ls(struct XorrisO *xorriso, int flag); - -/* @param wd Path to prepend in case img_path is not absolute - @param img_path Absolute or relative path to be normalized - @param eff_path returns resulting effective path. - Must provide at least SfileadrL bytes of storage. - @param flag bit0= do not produce problem events (unless faulty path format) - bit1= work purely literally, do not use libisofs - bit2= (with bit1) this is an address in the disk world - @return -1 = faulty path format, 0 = not found , - 1 = found simple node , 2 = found directory -*/ -int Xorriso_normalize_img_path(struct XorrisO *xorriso, char *wd, - char *img_path, char eff_path[], int flag); - -int Xorriso_rename(struct XorrisO *xorriso, char *origin, char *dest,int flag); - -/* @param flag bit0= do not produce info message on success - @return 1=success, 0=was already directory, -1=was other type, -2=bad path -*/ -int Xorriso_mkdir(struct XorrisO *xorriso, char *img_path, int flag); - -/* @param flag bit0= a match count !=1 is a SORRY event */ -int Xorriso_expand_pattern(struct XorrisO *xorriso, - int num_patterns, char **patterns, int extra_filec, - int *filec, char ***filev, off_t *mem, int flag); - -int Xorriso_set_st_mode(struct XorrisO *xorriso, char *path, - mode_t mode_and, mode_t mode_or, int flag); - -int Xorriso_set_uid(struct XorrisO *xorriso, char *in_path, uid_t uid, - int flag); - -int Xorriso_set_gid(struct XorrisO *xorriso, char *in_path, gid_t gid, - int flag); - -/* @parm flag bit0= atime, bit1= ctime, bit2= mtime, bit8=no auto ctime */ -int Xorriso_set_time(struct XorrisO *xorriso, char *in_path, time_t t, - int flag); - -int Xorriso_findi(struct XorrisO *xorriso, struct FindjoB *job, - void *dir_node_generic, char *dir_path, - struct stat *dir_stbuf, int depth, int flag); - -int Xorriso_set_volid(struct XorrisO *xorriso, char *volid, int flag); - -int Xorriso_get_volid(struct XorrisO *xorriso, char volid[33], int flag); - -#endif /* Xorrisoburn_includeD */ - diff --git a/libisoburn/trunk/test/README b/libisoburn/trunk/xorriso/README similarity index 100% rename from libisoburn/trunk/test/README rename to libisoburn/trunk/xorriso/README diff --git a/libisoburn/trunk/test/changelog.txt b/libisoburn/trunk/xorriso/changelog.txt similarity index 100% rename from libisoburn/trunk/test/changelog.txt rename to libisoburn/trunk/xorriso/changelog.txt diff --git a/libisoburn/trunk/test/compare_file.c b/libisoburn/trunk/xorriso/compare_file.c similarity index 100% rename from libisoburn/trunk/test/compare_file.c rename to libisoburn/trunk/xorriso/compare_file.c diff --git a/libisoburn/trunk/test/compile_xorriso.sh b/libisoburn/trunk/xorriso/compile_xorriso.sh similarity index 51% rename from libisoburn/trunk/test/compile_xorriso.sh rename to libisoburn/trunk/xorriso/compile_xorriso.sh index b2b5683b..ca7d763a 100755 --- a/libisoburn/trunk/test/compile_xorriso.sh +++ b/libisoburn/trunk/xorriso/compile_xorriso.sh @@ -5,10 +5,10 @@ # to be executed in a common parent of the directories given with # $isofs $isoburn $burn -isofs=./libisofs-develop/libisofs +isofs=./nglibisofs-develop/src burn=./libburn-develop/libburn -isoburn=./libisoburn-develop/og_src -xorr=./libisoburn-develop/test +isoburn=./libisoburn-develop/libisoburn +xorr=./libisoburn-develop/xorriso debug_opts="-O2" def_opts= @@ -16,8 +16,7 @@ largefile_opts="-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE=1" do_strip=0 static_opts= warn_opts="-Wall" -nglibisofs=0 -gen= +nglibisofs=1 for i in "$@" do @@ -40,21 +39,7 @@ do echo " -do_strip apply program strip to compiled programs." echo " -g produce debuggable programm." echo " -static compile with cc option -static." - echo " -nglibisofs ... will fail at compile time." - echo " -oglibisofs ... might fail at run time." exit 0 - elif test "$i" = "-nglibisofs" - then - nglibisofs=1 - isofs=./nglibisofs-develop/src - isoburn=./libisoburn-develop/ng_src - gen=-nglibisofs - elif test "$i" = "-oglibisofs" - then - nglibisofs=0 - isofs=./libisofs-develop/libisofs - isoburn=./libisoburn-develop/og_src - gen=-oglibisofs elif test "$i" = "-static" then static_opts="-static" @@ -62,59 +47,35 @@ do done libisofs= -if test "$nglibisofs" = 1 -then - libisofs="$libisofs $isofs"/buffer.o - libisofs="$libisofs $isofs"/builder.o - libisofs="$libisofs $isofs"/data_source.o - libisofs="$libisofs $isofs"/ecma119.o - libisofs="$libisofs $isofs"/ecma119_tree.o - libisofs="$libisofs $isofs"/eltorito.o - libisofs="$libisofs $isofs"/filesrc.o - libisofs="$libisofs $isofs"/fs_image.o - libisofs="$libisofs $isofs"/fs_local.o - libisofs="$libisofs $isofs"/fsource.o - libisofs="$libisofs $isofs"/image.o - libisofs="$libisofs $isofs"/iso1999.o - libisofs="$libisofs $isofs"/joliet.o - libisofs="$libisofs $isofs"/libiso_msgs.o - libisofs="$libisofs $isofs"/messages.o - libisofs="$libisofs $isofs"/node.o - libisofs="$libisofs $isofs"/rockridge.o - libisofs="$libisofs $isofs"/rockridge_read.o - libisofs="$libisofs $isofs"/stream.o - libisofs="$libisofs $isofs"/tree.o - libisofs="$libisofs $isofs"/util.o - libisofs="$libisofs $isofs"/util_htable.o - libisofs="$libisofs $isofs"/util_rbtree.o - xorrisoburn_c="ng_xorrisoburn.c" -else - libisofs="$libisofs $isofs"/data_source.o - libisofs="$libisofs $isofs"/ecma119.o - libisofs="$libisofs $isofs"/ecma119_read.o - libisofs="$libisofs $isofs"/ecma119_read_rr.o - libisofs="$libisofs $isofs"/ecma119_tree.o - libisofs="$libisofs $isofs"/eltorito.o - libisofs="$libisofs $isofs"/exclude.o - libisofs="$libisofs $isofs"/file.o - libisofs="$libisofs $isofs"/file_src.o - libisofs="$libisofs $isofs"/hash.o - libisofs="$libisofs $isofs"/joliet.o - libisofs="$libisofs $isofs"/libiso_msgs.o - libisofs="$libisofs $isofs"/messages.o - libisofs="$libisofs $isofs"/rockridge.o - libisofs="$libisofs $isofs"/susp.o - libisofs="$libisofs $isofs"/tree.o - libisofs="$libisofs $isofs"/util.o - libisofs="$libisofs $isofs"/volume.o - xorrisoburn_c="xorrisoburn.c" -fi +libisofs="$libisofs $isofs"/buffer.o +libisofs="$libisofs $isofs"/builder.o +libisofs="$libisofs $isofs"/data_source.o +libisofs="$libisofs $isofs"/ecma119.o +libisofs="$libisofs $isofs"/ecma119_tree.o +libisofs="$libisofs $isofs"/eltorito.o +libisofs="$libisofs $isofs"/filesrc.o +libisofs="$libisofs $isofs"/fs_image.o +libisofs="$libisofs $isofs"/fs_local.o +libisofs="$libisofs $isofs"/fsource.o +libisofs="$libisofs $isofs"/image.o +libisofs="$libisofs $isofs"/iso1999.o +libisofs="$libisofs $isofs"/joliet.o +libisofs="$libisofs $isofs"/libiso_msgs.o +libisofs="$libisofs $isofs"/messages.o +libisofs="$libisofs $isofs"/node.o +libisofs="$libisofs $isofs"/rockridge.o +libisofs="$libisofs $isofs"/rockridge_read.o +libisofs="$libisofs $isofs"/stream.o +libisofs="$libisofs $isofs"/tree.o +libisofs="$libisofs $isofs"/util.o +libisofs="$libisofs $isofs"/util_htable.o +libisofs="$libisofs $isofs"/util_rbtree.o timestamp="$(date -u '+%Y.%m.%d.%H%M%S')" echo "Version timestamp : $(sed -e 's/#define Xorriso_timestamP "//' -e 's/"$//' "$xorr"/xorriso_timestamp.h)" echo "Build timestamp : $timestamp" -echo "compiling program $xorr/xorriso.c $static_opts $debug_opts $def_opts $gen" +echo "compiling program $xorr/xorriso.c $static_opts $debug_opts $def_opts" cc -I. -DXorriso_with_maiN -DXorriso_with_regeX -DXorriso_with_readlinE \ $warn_opts \ $static_opts \ @@ -128,7 +89,7 @@ cc -I. -DXorriso_with_maiN -DXorriso_with_regeX -DXorriso_with_readlinE \ \ "$xorr"/xorriso.c \ \ - "$xorr"/"$xorrisoburn_c" \ + "$xorr"/xorrisoburn.c \ \ "$burn"/async.o \ "$burn"/debug.o \ diff --git a/libisoburn/trunk/test/configure_ac.txt b/libisoburn/trunk/xorriso/configure_ac.txt similarity index 100% rename from libisoburn/trunk/test/configure_ac.txt rename to libisoburn/trunk/xorriso/configure_ac.txt diff --git a/libisoburn/trunk/test/convert_man_to_html.sh b/libisoburn/trunk/xorriso/convert_man_to_html.sh similarity index 93% rename from libisoburn/trunk/test/convert_man_to_html.sh rename to libisoburn/trunk/xorriso/convert_man_to_html.sh index acd30e6c..f73f24aa 100755 --- a/libisoburn/trunk/test/convert_man_to_html.sh +++ b/libisoburn/trunk/xorriso/convert_man_to_html.sh @@ -5,16 +5,16 @@ # # Generates a HTML version of man page xorriso.1 # -# To be executed within the libburn toplevel directory (eg. ./libisoburn-0.1.0) +# To be executed in the libisoburn toplevel directory (eg. ./libisoburn-0.1.0) # # set -x -man_dir=$(pwd)"/test" +man_dir=$(pwd)"/xorriso" export MANPATH="$man_dir" manpage="xorriso" -raw_html=$(pwd)/"test/raw_man_1_xorriso.html" -htmlpage=$(pwd)/"test/man_1_xorriso.html" +raw_html=$(pwd)/"xorriso/raw_man_1_xorriso.html" +htmlpage=$(pwd)/"xorriso/man_1_xorriso.html" if test -r "$man_dir"/"$manpage".1 then @@ -87,6 +87,7 @@ then -e 's/-outdev \/dev\/sr0 -blank fast \\ -commit -eject all/-outdev \/dev\/sr0 -blank fast -commit -eject all/' \ -e 's/See section FILES/See section FILES<\/A>/' \ -e 's/See section EXAMPLES/See section EXAMPLES<\/A>/' \ + -e 's/<\/body>/

(HTML generated from '"$manpage"'.1 on '"$(date)"' by '$(basename "$0")' )<\/CENTER><\/FONT><\/body>/' \ <"$2" >"$htmlpage" set +x diff --git a/libisoburn/trunk/test/make_timestamp.sh b/libisoburn/trunk/xorriso/make_timestamp.sh similarity index 51% rename from libisoburn/trunk/test/make_timestamp.sh rename to libisoburn/trunk/xorriso/make_timestamp.sh index cee74657..d6cfcb57 100755 --- a/libisoburn/trunk/test/make_timestamp.sh +++ b/libisoburn/trunk/xorriso/make_timestamp.sh @@ -1,9 +1,9 @@ #!/bin/sh -# Create version timestamp test/xorriso_timestamp.h +# Create version timestamp xorriso/xorriso_timestamp.h # to be executed within ./libisoburn-develop timestamp="$(date -u '+%Y.%m.%d.%H%M%S')" echo "Version timestamp : $timestamp" -echo '#define Xorriso_timestamP "'"$timestamp"'"' >test/xorriso_timestamp.h +echo '#define Xorriso_timestamP "'"$timestamp"'"' >xorriso/xorriso_timestamp.h diff --git a/libisoburn/trunk/test/make_xorriso_standalone.sh b/libisoburn/trunk/xorriso/make_xorriso_standalone.sh similarity index 84% rename from libisoburn/trunk/test/make_xorriso_standalone.sh rename to libisoburn/trunk/xorriso/make_xorriso_standalone.sh index 8f3583fe..26f1c1b9 100755 --- a/libisoburn/trunk/test/make_xorriso_standalone.sh +++ b/libisoburn/trunk/xorriso/make_xorriso_standalone.sh @@ -88,13 +88,13 @@ copy_files \ \ "$lone_dir" -copy_files test/configure_ac.txt "$lone_dir"/configure.ac +copy_files xorriso/configure_ac.txt "$lone_dir"/configure.ac -copy_files test/xorriso_makefile_am.txt "$lone_dir"/Makefile.am +copy_files xorriso/xorriso_makefile_am.txt "$lone_dir"/Makefile.am -copy_files test/xorriso_pc_in.txt "$lone_dir"/xorriso.pc.in +copy_files xorriso/xorriso_pc_in.txt "$lone_dir"/xorriso.pc.in -copy_files test/README "$lone_dir"/README +copy_files xorriso/README "$lone_dir"/README echo "See end of xorriso/changelog.txt" >"$lone_dir"/TODO @@ -103,24 +103,22 @@ echo "See end of xorriso/changelog.txt" >"$lone_dir"/TODO create_dir "$lone_dir"/libisoburn copy_files \ - ng_src/*.[ch] \ + libisoburn/*.[ch] \ "$lone_dir"/libisoburn -test/convert_man_to_html.sh +xorriso/convert_man_to_html.sh create_dir "$lone_dir"/xorriso copy_files \ - test/ng_xorrisoburn.[ch] \ - test/xorriso.[ch1] \ - test/xorriso_private.h \ - test/xorriso_timestamp.h \ - test/changelog.txt \ - test/xorriso_eng.html \ - test/man_1_xorriso.html \ + xorriso/xorrisoburn.[ch] \ + xorriso/xorriso.[ch1] \ + xorriso/xorriso_private.h \ + xorriso/xorriso_timestamp.h \ + xorriso/changelog.txt \ + xorriso/xorriso_eng.html \ + xorriso/man_1_xorriso.html \ "$lone_dir"/xorriso -mv "$lone_dir"/xorriso/ng_xorrisoburn.h "$lone_dir"/xorriso/xorrisoburn.h -mv "$lone_dir"/xorriso/ng_xorrisoburn.c "$lone_dir"/xorriso/xorrisoburn.c # >>> create compile_xorriso.sh for standalone diff --git a/libisoburn/trunk/test/xorriso.1 b/libisoburn/trunk/xorriso/xorriso.1 similarity index 100% rename from libisoburn/trunk/test/xorriso.1 rename to libisoburn/trunk/xorriso/xorriso.1 diff --git a/libisoburn/trunk/test/xorriso.c b/libisoburn/trunk/xorriso/xorriso.c similarity index 99% rename from libisoburn/trunk/test/xorriso.c rename to libisoburn/trunk/xorriso/xorriso.c index 851e8511..dfbec692 100644 --- a/libisoburn/trunk/test/xorriso.c +++ b/libisoburn/trunk/xorriso/xorriso.c @@ -1,15 +1,15 @@ /* - ( cd .. ; libisoburn-develop/test/compile_xorriso.sh -g ) + ( cd .. ; libisoburn-develop/xorriso/compile_xorriso.sh -g ) or cc -g -DXorriso_with_maiN -DXorriso_with_regeX -DXorriso_with_readlinE \ -DXorriso_build_timestamP='"'"$(date -u '+%Y.%m.%d.%H%M%S')"'"' \ -Wall -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE \ - -o test/xorriso \ - test/xorriso.c test/xorrisoburn.c \ + -o xorriso/xorriso \ + xorriso/xorriso.c xorriso/xorrisoburn.c \ -lpthread -lreadline -lburn -lisofs -lisoburn or @@ -18,7 +18,7 @@ or -DXorriso_build_timestamP='"'"$(date -u '+%Y.%m.%d.%H%M%S')"'"' \ -Wall -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE \ -c \ - test/xorriso.c test/xorrisoburn.c + xorriso/xorriso.c xorriso/xorrisoburn.c */ diff --git a/libisoburn/trunk/test/xorriso.h b/libisoburn/trunk/xorriso/xorriso.h similarity index 100% rename from libisoburn/trunk/test/xorriso.h rename to libisoburn/trunk/xorriso/xorriso.h diff --git a/libisoburn/trunk/test/xorriso_eng.html b/libisoburn/trunk/xorriso/xorriso_eng.html similarity index 100% rename from libisoburn/trunk/test/xorriso_eng.html rename to libisoburn/trunk/xorriso/xorriso_eng.html diff --git a/libisoburn/trunk/test/xorriso_makefile_am.txt b/libisoburn/trunk/xorriso/xorriso_makefile_am.txt similarity index 100% rename from libisoburn/trunk/test/xorriso_makefile_am.txt rename to libisoburn/trunk/xorriso/xorriso_makefile_am.txt diff --git a/libisoburn/trunk/test/xorriso_pc_in.txt b/libisoburn/trunk/xorriso/xorriso_pc_in.txt similarity index 100% rename from libisoburn/trunk/test/xorriso_pc_in.txt rename to libisoburn/trunk/xorriso/xorriso_pc_in.txt diff --git a/libisoburn/trunk/test/xorriso_private.h b/libisoburn/trunk/xorriso/xorriso_private.h similarity index 100% rename from libisoburn/trunk/test/xorriso_private.h rename to libisoburn/trunk/xorriso/xorriso_private.h diff --git a/libisoburn/trunk/xorriso/xorriso_timestamp.h b/libisoburn/trunk/xorriso/xorriso_timestamp.h new file mode 100644 index 00000000..5be3b285 --- /dev/null +++ b/libisoburn/trunk/xorriso/xorriso_timestamp.h @@ -0,0 +1 @@ +#define Xorriso_timestamP "2008.01.26.002011" diff --git a/libisoburn/trunk/test/xorrisoburn.c b/libisoburn/trunk/xorriso/xorrisoburn.c similarity index 80% rename from libisoburn/trunk/test/xorrisoburn.c rename to libisoburn/trunk/xorriso/xorrisoburn.c index f4bb1291..31abcf08 100644 --- a/libisoburn/trunk/test/xorrisoburn.c +++ b/libisoburn/trunk/xorriso/xorrisoburn.c @@ -22,6 +22,7 @@ /* ------------------------------------------------------------------------ */ +#ifndef Xorriso_standalonE /* The library which does the ISO 9660 / RockRidge manipulations */ #include @@ -42,10 +43,33 @@ /* 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); +#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))) + /* ------------------------------------------------------------------------ */ @@ -84,7 +108,8 @@ int Xorriso_startup_libraries(struct XorrisO *xorriso, int flag) print_sev= xorriso->report_about_text; } else print_sev= "NEVER"; - iso_msgs_set_severities(queue_sev, print_sev, "libisofs : "); + + iso_set_msgs_severities(queue_sev, print_sev, "libsofs : "); burn_msgs_set_severities(queue_sev, print_sev, "libburn : "); /* ??? >>> do we want united queues ? */ @@ -105,6 +130,10 @@ int Xorriso_startup_libraries(struct XorrisO *xorriso, int flag) 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); @@ -136,10 +165,41 @@ int Xorriso_get_drive_handles(struct XorrisO *xorriso, } +/* @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; - struct iso_volset *volset; + IsoImage *volset; struct isoburn_read_opts ropts; struct burn_drive_info *dinfo= NULL; struct burn_drive *drive= NULL; @@ -151,20 +211,23 @@ int Xorriso_create_empty_iso(struct XorrisO *xorriso, int flag) return(ret); } if(xorriso->in_volset_handle!=NULL) { - iso_volset_free((struct iso_volset *) xorriso->in_volset_handle); + iso_image_unref((IsoImage *) xorriso->in_volset_handle); xorriso->in_volset_handle= NULL; + xorriso->loaded_volid[0]= 0; xorriso->volset_change_pending= 0; } memset(&ropts, sizeof(ropts), 0); ropts.pretend_blank= 1; - ret= isoburn_read_volset(drive, &ropts, &volset); + ropts.input_charset= NULL; + ret= isoburn_read_image(drive, &ropts, &volset); Xorriso_process_msg_queues(xorriso,0); if(ret<=0) { sprintf(xorriso->info_text, "Failed to create new empty ISO image object"); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); return(-1); } - xorriso->in_volset_handle= volset; + xorriso->in_volset_handle= (void *) volset; + Xorriso_update_volid(xorriso, 0); xorriso->volset_change_pending= 0; return(1); } @@ -182,8 +245,9 @@ int Xorriso_aquire_drive(struct XorrisO *xorriso, char *adr, int flag) struct burn_drive_info *dinfo= NULL, *out_dinfo, *in_dinfo; struct burn_drive *drive, *out_drive, *in_drive; enum burn_disc_status state; - struct iso_volset *volset; + IsoImage *volset = NULL; struct isoburn_read_opts ropts; + char adr_data[SfileadrL], *libburn_adr; if((flag&3)==0) { sprintf(xorriso->info_text, @@ -195,12 +259,25 @@ int Xorriso_aquire_drive(struct XorrisO *xorriso, char *adr, int flag) 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, "SORRY", 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, adr, 1); + 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) { @@ -208,13 +285,13 @@ int Xorriso_aquire_drive(struct XorrisO *xorriso, char *adr, int flag) "on attempt to compare new indev with outdev", 0); if(ret<=0) goto ex; - ret= burn_drive_equals_adr(in_drive, adr, 1); + 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, adr, 1); + 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); @@ -225,6 +302,12 @@ int Xorriso_aquire_drive(struct XorrisO *xorriso, char *adr, int flag) 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; @@ -247,9 +330,8 @@ int Xorriso_aquire_drive(struct XorrisO *xorriso, char *adr, int flag) if(ret<=0) return(ret); } else { - iso_volset_ref(xorriso->in_volset_handle); - ret= isoburn_attach_volset(drive, - (struct iso_volset *) xorriso->in_volset_handle); + 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"); @@ -262,7 +344,7 @@ int Xorriso_aquire_drive(struct XorrisO *xorriso, char *adr, int flag) } if(xorriso->in_volset_handle!=NULL) - iso_volset_free((struct iso_volset *) xorriso->in_volset_handle); + iso_image_unref((IsoImage *) xorriso->in_volset_handle); xorriso->in_volset_handle= NULL; /* check for invalid state */ @@ -277,30 +359,45 @@ int Xorriso_aquire_drive(struct XorrisO *xorriso, char *adr, int flag) 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; - if(isoburn_read_volset(drive, &ropts, &volset) <= 0) { + Xorriso_set_image_severities(xorriso, 1); /* No DEBUG messages */ + 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, "SORRY", 0); ret= 3; goto ex; } - xorriso->in_volset_handle= volset; + 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_volset_ref(xorriso->in_volset_handle); - isoburn_attach_volset(out_drive, xorriso->in_volset_handle); + 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: if(ret<=0) { @@ -323,8 +420,17 @@ 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, @@ -340,15 +446,16 @@ int Xorriso_give_up_drive(struct XorrisO *xorriso, int flag) xorriso->indev[0]= 0; if(xorriso->in_volset_handle!=NULL) - iso_volset_free((struct iso_volset *) xorriso->in_volset_handle); + 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 drive up", 2); + "on attempt to give up drive", 2); if(!in_is_out_too) { if(drive!=NULL) isoburn_drive_release(drive,!!(flag&4)); @@ -377,6 +484,8 @@ 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); @@ -385,7 +494,9 @@ int Xorriso_make_write_options( return(0); } burn_write_opts_set_simulate(*burn_options, !!xorriso->do_dummy); - burn_write_opts_set_multi(*burn_options, !xorriso->do_close); + 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); @@ -413,25 +524,30 @@ int Xorriso_write_session(struct XorrisO *xorriso, int flag) if(ret<=0) return(0); + memset(&sopts, 0, sizeof(sopts)); + sopts.level= 2; - sopts.flags= ECMA119_ROCKRIDGE; - if(xorriso->do_joliet) - sopts.flags|= ECMA119_JOLIET; - sopts.relaxed_constraints= 0; - sopts.copy_eltorito= 1; - sopts.no_cache_inodes= 0; + 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.default_mode= 1; - sopts.replace_dir_mode= xorriso->do_global_mode; + sopts.replace_dir_mode= 2*!!xorriso->do_global_mode; sopts.dir_mode= xorriso->global_dir_mode; - sopts.replace_file_mode= xorriso->do_global_mode; + sopts.replace_file_mode= 2*!!xorriso->do_global_mode; sopts.file_mode= xorriso->global_file_mode; - sopts.replace_uid= (xorriso->do_global_uid); + sopts.replace_uid= 2*!!xorriso->do_global_uid; sopts.uid= xorriso->global_uid; - sopts.replace_gid= (xorriso->do_global_gid); + sopts.replace_gid= 2*!!xorriso->do_global_gid; sopts.gid= xorriso->global_gid; - sopts.input_charset= NULL; - sopts.ouput_charset= NULL; + sopts.output_charset= NULL; sopts.fifo_size= xorriso->fs * 2048; if(xorriso->out_drive_handle == xorriso->in_drive_handle || @@ -501,7 +617,8 @@ int Xorriso_write_session(struct XorrisO *xorriso, int flag) 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/2048, (int) writecounter/2048); + (int) (readcounter/ (off_t) 2048), + (int) (writecounter/ (off_t) 2048)); Xorriso_info(xorriso, 0); } } @@ -549,9 +666,15 @@ int Xorriso_pacifier_loop(struct XorrisO *xorriso, struct burn_drive *drive, progress.sector, progress.sectors); ret= isoburn_get_fifo_status(drive, &size, &free_bytes, &status_text); if(ret>0 ) + sprintf(xorriso->info_text+strlen(xorriso->info_text), + " [fifo %s, %2d%% fill, size=%d , free=%d]", status_text, + (int) (100.0-100.0*((double) free_bytes)/(double) size), + size, free_bytes); +/* sprintf(xorriso->info_text+strlen(xorriso->info_text), " [fifo %s, %2d%% fill]", status_text, (int) (100.0-100.0*((double) free_bytes)/(double) size)); +*/ } else if(drive_status == BURN_DRIVE_CLOSING_SESSION || drive_status == BURN_DRIVE_CLOSING_TRACK) sprintf(xorriso->info_text, @@ -575,15 +698,15 @@ int Xorriso_pacifier_loop(struct XorrisO *xorriso, struct burn_drive *drive, } -int Xorriso_get_volume(struct XorrisO *xorriso, struct iso_volume **volume, +int Xorriso_get_volume(struct XorrisO *xorriso, IsoImage **volume, int flag) { if(xorriso->in_volset_handle==NULL) { Xorriso_process_msg_queues(xorriso,0); - sprintf(xorriso->info_text,"No volset is loaded."); - if(xorriso->indev[0]==0) + sprintf(xorriso->info_text,"No ISO image present."); + if(xorriso->indev[0]==0 && xorriso->outdev[0]==0) sprintf(xorriso->info_text+strlen(xorriso->info_text), - " No -dev or -indev is selected."); + " No -dev, -indev, or -outdev selected."); else sprintf(xorriso->info_text+strlen(xorriso->info_text), " Possible program error with drive '%s'.", xorriso->indev); @@ -591,12 +714,36 @@ int Xorriso_get_volume(struct XorrisO *xorriso, struct iso_volume **volume, Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); return(0); } - *volume= iso_volset_get_volume( - (struct iso_volset *) xorriso->in_volset_handle, 0); + *volume= (IsoImage *) xorriso->in_volset_handle; return(*volume != NULL); } +/* @param flag bit0=do not complain about non existent node */ +int Xorriso_node_from_path(struct XorrisO *xorriso, IsoImage *volume, + char *path, IsoNode **node, int flag) +{ + int ret; + char sfe[5*SfileadrL], *path_pt; + + path_pt= path; + if(path[0]==0) + path_pt= "/"; + *node= NULL; + ret= iso_tree_path_to_node(volume, path_pt, node); + Xorriso_process_msg_queues(xorriso,0); + if(ret<=0) { + if(!(flag&1)) { + sprintf(xorriso->info_text, "Cannot find path %s in loaded ISO image", + Text_shellsafe(path_pt, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + } + return(0); + } + return(1); +} + + /* @param eff_path returns resulting effective path. Must provide at least SfileadrL bytes of storage. @param flag bit0= do not produce problem events (unless faulty path format) @@ -609,9 +756,9 @@ int Xorriso_normalize_img_path(struct XorrisO *xorriso, char *wd, char *img_path, char eff_path[], int flag) { int ret, is_dir= 0, done= 0; - struct iso_volume *volume; - struct iso_tree_node_dir *dir= NULL; - struct iso_tree_node *node= NULL; + IsoImage *volume; + IsoDir *dir= NULL; + IsoNode *node= NULL; char path[SfileadrL], *apt, *npt, sfe[5*SfileadrL], *cpt; eff_path[0]= 0; @@ -661,7 +808,7 @@ int Xorriso_normalize_img_path(struct XorrisO *xorriso, char *wd, continue; if(strcmp(apt,"..")==0) { if(!(flag&2)) { - node= (struct iso_tree_node *) dir; + node= (IsoNode *) dir; if(node==NULL) { bonked_root:; sprintf(xorriso->info_text, @@ -670,7 +817,7 @@ bonked_root:; Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); return(-1); } - dir= iso_tree_node_get_parent(node); + dir= iso_node_get_parent(node); } /* truncate eff_path */; cpt= strrchr(eff_path, '/'); @@ -689,17 +836,12 @@ much_too_long:; return(-1); } if(!(flag&2)) { - dir= (struct iso_tree_node_dir *) node; - node= iso_tree_volume_path_to_node(volume,eff_path); - if(node==NULL) { - sprintf(xorriso->info_text, "Cannot find in ISO image: %s", - Text_shellsafe(eff_path, sfe, 0)); - if(!(flag&1)) - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); - return(0); - } + dir= (IsoDir *) node; + ret= Xorriso_node_from_path(xorriso, volume, eff_path, &node, flag&1); + if(ret<=0) + return(0); if(dir==NULL) /* could be false with "/dir/.." */ - dir= iso_tree_node_get_parent(node); + dir= iso_node_get_parent(node); is_dir= LIBISO_ISDIR(node); } } @@ -709,11 +851,11 @@ much_too_long:; int Xorriso_get_node_by_path(struct XorrisO *xorriso, char *in_path, char *eff_path, - struct iso_tree_node **node, int flag) + IsoNode **node, int flag) { int ret; - char sfe[5*SfileadrL], path[SfileadrL]; - struct iso_volume *volume; + char path[SfileadrL]; + IsoImage *volume; ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, in_path, path, 0); if(ret<=0) @@ -723,37 +865,34 @@ int Xorriso_get_node_by_path(struct XorrisO *xorriso, ret= Xorriso_get_volume(xorriso, &volume, 0); if(ret<=0) return(ret); - *node= iso_tree_volume_path_to_node(volume,path); - if(*node==NULL) { - sprintf(xorriso->info_text, "Not found in ISO image: %s", - Text_shellsafe(path, sfe, 0)); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + ret= Xorriso_node_from_path(xorriso, volume, path, node, 0); + if(ret<=0) return(0); - } return(1); } int Xorriso_transfer_properties(struct XorrisO *xorriso, struct stat *stbuf, - struct iso_tree_node *node, int flag) + IsoNode *node, int flag) { - iso_tree_node_set_permissions(node, stbuf->st_mode & 07777); - iso_tree_node_set_uid(node, stbuf->st_uid); - iso_tree_node_set_gid(node, stbuf->st_gid); - iso_tree_node_set_atime(node, stbuf->st_atime); - iso_tree_node_set_mtime(node, stbuf->st_mtime); - iso_tree_node_set_ctime(node, stbuf->st_ctime); + iso_node_set_permissions(node, stbuf->st_mode & 07777); + iso_node_set_uid(node, stbuf->st_uid); + iso_node_set_gid(node, stbuf->st_gid); + iso_node_set_atime(node, stbuf->st_atime); + iso_node_set_mtime(node, stbuf->st_mtime); + iso_node_set_ctime(node, stbuf->st_ctime); return(1); } /* @param flag bit0= recursion is active */ -int Xorriso_add_tree(struct XorrisO *xorriso, struct iso_tree_node_dir *dir, +int Xorriso_add_tree(struct XorrisO *xorriso, IsoDir *dir, char *img_dir_path, char *disk_dir_path, struct LinkiteM *link_stack, int flag) { - struct iso_volume *volume; - struct iso_tree_node *node; + IsoImage *volume; + IsoNode *node; + IsoSymlink *iso_symlink; int ret, target_is_dir, source_is_dir, source_is_link, fret, was_failure= 0; int do_not_dive; struct DirseQ *dirseq= NULL; @@ -880,18 +1019,23 @@ cannot_lstat:; source_is_dir= 1; if(dir_dev != stbuf.st_dev && !xorriso->do_follow_mount) do_not_dive= 1; + +#ifdef NIX } else if(!(S_ISREG(stbuf.st_mode) || S_ISLNK(stbuf.st_mode))) { sprintf(xorriso->info_text,"Source file %s %s non-supported file type", Text_shellsafe(disk_path, sfe, 0), source_is_link ? "leads to" : "is of"); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); ret= 0; goto was_problem; +#endif /* NIX */ + } /* does a node exist with this name ? */ - node= iso_tree_volume_path_to_node(volume,img_path); - if(node!=NULL) { - target_is_dir= (iso_tree_node_get_type(node)==LIBISO_NODE_DIR); + node= NULL; + ret= Xorriso_node_from_path(xorriso, volume, img_path, &node, 1); + if(ret>0) { + target_is_dir= LIBISO_ISDIR(node); if(!(target_is_dir && source_is_dir)) { Xorriso_process_msg_queues(xorriso,0); @@ -921,25 +1065,28 @@ cannot_lstat:; if(node==NULL) { if(S_ISLNK(stbuf.st_mode)) { + /* ??? NG : A80107 : is this solved now ? */ /* <<< One should rather change libisofs so that iso_tree_add_node() adds a disk_link as RR link, if RR is enabled */ - node= iso_tree_add_symlink(dir, img_name, link_target); - if(node!=NULL) { + ret= iso_tree_add_new_symlink(dir, img_name, link_target, &iso_symlink); + node= (IsoNode *) iso_symlink; + if(ret>0) { ret= Xorriso_transfer_properties(xorriso, &stbuf, node, 0); if(ret<=0) goto was_problem; } else {ret= 0; goto was_problem;} - } else - node= iso_tree_add_node(dir, srcpt); + } else { + ret= iso_tree_add_node(volume, dir, srcpt, &node); + if(ret<0) + goto was_problem; + } } - if(node == NULL) { + if(node==NULL) { Xorriso_process_msg_queues(xorriso,0); - sprintf(xorriso->info_text, - "While grafting %s=%s : libisofs_errno = %d", - Text_shellsafe(img_path,sfe,0), Text_shellsafe(disk_path,sfe2,0), - libisofs_errno); + sprintf(xorriso->info_text, "Grafting failed: %s = %s", + Text_shellsafe(img_path,sfe,0), Text_shellsafe(disk_path,sfe2,0)); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); ret=0; goto was_problem; } @@ -950,7 +1097,7 @@ cannot_lstat:; Text_shellsafe(disk_path, sfe, 0)); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); } else { - ret= Xorriso_add_tree(xorriso, (struct iso_tree_node_dir *) node, + ret= Xorriso_add_tree(xorriso, (IsoDir *) node, img_path, disk_path, own_link_stack, 1); } if(ret<=0) @@ -995,10 +1142,10 @@ ex: int Xorriso_graft_in(struct XorrisO *xorriso, char *disk_path, char *img_path, int flag) { - struct iso_volume *volume; - char path[SfileadrL], *apt, *npt, *cpt, sfe[5*SfileadrL]; - struct iso_tree_node_dir *dir; - struct iso_tree_node *node; + IsoImage *volume; + char path[SfileadrL], *apt, *npt, *cpt, sfe[5*SfileadrL], sfe2[5*SfileadrL]; + IsoDir *dir, *hdir; + IsoNode *node; int done= 0, is_dir= 0, l, ret, target_is_dir, source_is_dir; struct stat stbuf; @@ -1043,14 +1190,18 @@ int Xorriso_graft_in(struct XorrisO *xorriso, char *disk_path, char *img_path, Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "SORRY", 0); return(0); } - if(S_ISDIR(stbuf.st_mode)) + if(S_ISDIR(stbuf.st_mode)) { is_dir= 1; - else if(!(S_ISREG(stbuf.st_mode) || S_ISLNK(stbuf.st_mode))) { + +#ifdef NIX + } else if(!(S_ISREG(stbuf.st_mode) || S_ISLNK(stbuf.st_mode))) { Xorriso_process_msg_queues(xorriso,0); sprintf(xorriso->info_text, "Source file '%s' is of non-supported file type", disk_path); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); return(0); +#endif /* NIX */ + } else { l= strlen(img_path); if(l>0) @@ -1066,7 +1217,7 @@ int Xorriso_graft_in(struct XorrisO *xorriso, char *disk_path, char *img_path, } } - dir= iso_volume_get_root(volume); + dir= iso_image_get_root(volume); if(dir==NULL) { Xorriso_process_msg_queues(xorriso,0); sprintf(xorriso->info_text, @@ -1089,9 +1240,9 @@ int Xorriso_graft_in(struct XorrisO *xorriso, char *disk_path, char *img_path, continue; } source_is_dir= (is_dir || (flag&1) || !done); - node= iso_tree_volume_path_to_node(volume,path); - if(node!=NULL) { - target_is_dir= (iso_tree_node_get_type(node)==LIBISO_NODE_DIR); + ret= Xorriso_node_from_path(xorriso, volume, path, &node, 1); + if(ret>0) { + target_is_dir= LIBISO_ISDIR(node); if(!(target_is_dir && source_is_dir)) { Xorriso_process_msg_queues(xorriso,0); @@ -1117,21 +1268,24 @@ int Xorriso_graft_in(struct XorrisO *xorriso, char *disk_path, char *img_path, Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); return(0); } - dir= (struct iso_tree_node_dir *) node; + dir= (IsoDir *) node; } handle_path_node:; if(node==NULL && source_is_dir) { /* make a directory */ - dir= iso_tree_add_dir(dir, apt); - if(dir==NULL) { + ret= iso_tree_add_new_dir(dir, apt, &hdir); + if(ret<0) { Xorriso_process_msg_queues(xorriso,0); sprintf(xorriso->info_text, "While grafting '%s' : could not insert '%s'", img_path, path); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); return(0); } + dir= hdir; xorriso->volset_change_pending= 1; - iso_tree_node_set_ctime((struct iso_tree_node *) dir, time(NULL)); + iso_node_set_ctime((IsoNode *) dir, time(NULL)); + iso_node_set_uid((IsoNode *) dir, geteuid()); + iso_node_set_gid((IsoNode *) dir, getegid()); /* >>> copy properties from correspondent directory in disk_path if there is any */; @@ -1143,22 +1297,22 @@ attach_source:; /* directory node was created above */; } else if(is_dir) { + Xorriso_transfer_properties(xorriso, &stbuf, (IsoNode *) dir, 0); ret= Xorriso_add_tree(xorriso, dir, img_path, disk_path, NULL, 0); if(ret<=0) return(ret); } else { - node= iso_tree_add_node(dir, disk_path); - if(node == NULL) { + ret= iso_tree_add_node(volume, dir, disk_path, &node); + if(ret<0) { Xorriso_process_msg_queues(xorriso,0); - sprintf(xorriso->info_text, - "While grafting '%s'='%s' : libisofs_errno = %d", - img_path, disk_path, libisofs_errno); + sprintf(xorriso->info_text, "Grafting failed: %s = %s", + Text_shellsafe(img_path,sfe,0), Text_shellsafe(disk_path,sfe2,0)); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); return(0); } xorriso->volset_change_pending= 1; - iso_tree_node_set_name(node, apt); + iso_node_set_name(node, apt); } } else *npt= '/'; @@ -1190,8 +1344,8 @@ int Xorriso_process_msg_queues(struct XorrisO *xorriso, int flag) for(pass= 0; pass< 2; pass++) { while(1) { if(pass==0) - ret= iso_msgs_obtain("ALL", &error_code, xorriso->info_text, &os_errno, - severity); + ret= iso_obtain_msgs("ALL", &error_code, + xorriso->info_text, &os_errno, severity); else ret= burn_msgs_obtain("ALL", &error_code, xorriso->info_text, &os_errno, severity); @@ -1219,7 +1373,7 @@ int Xorriso_toc(struct XorrisO *xorriso, int flag) int num_sessions= 0, num_tracks= 0, lba= 0, nwa= -1, pmin, psec, pframe, ret; int track_count= 0, session_no, track_no, profile_no= -1; int last_track_start= 0, last_track_size= -1, num_data= 0, is_data= 0; - int is_inout_drive= 0; + int is_inout_drive= 0, drive_role; char profile_name[80],*respt,*devadr; struct burn_disc *disc= NULL; struct burn_session **sessions; @@ -1256,9 +1410,15 @@ int Xorriso_toc(struct XorrisO *xorriso, int flag) ret= burn_disc_get_profile(drive, &profile_no, profile_name); if (profile_no > 0 && ret > 0) { if (profile_name[0]) - sprintf(respt+strlen(respt), "%s\n", profile_name); + sprintf(respt+strlen(respt), "%s", profile_name); else - sprintf(respt+strlen(respt), "%4.4Xh\n", profile_no); + sprintf(respt+strlen(respt), "%4.4Xh", profile_no); + drive_role= burn_drive_get_drive_role(drive); + if(drive_role==2) + sprintf(respt+strlen(respt), ", overwriteable"); + else if(drive_role==0 || drive_role==3) + sprintf(respt+strlen(respt), ", sequential"); + strcat(respt, "\n"); } else sprintf(respt+strlen(respt), "is not recognizable\n"); Xorriso_result(xorriso,0); @@ -1613,26 +1773,9 @@ int Xorriso_format_media(struct XorrisO *xorriso, int flag) } -int Xorriso_node_from_path(struct XorrisO *xorriso, struct iso_volume *volume, - char *path, struct iso_tree_node **node, int flag) -{ - char sfe[5*SfileadrL]; - - *node= iso_tree_volume_path_to_node(volume, path); - Xorriso_process_msg_queues(xorriso,0); - if(*node==NULL) { - sprintf(xorriso->info_text, "Cannot find path %s in loaded ISO image", - Text_shellsafe(path, sfe, 0)); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); - return(0); - } - return(1); -} - - /* @param boss_iter If not NULL then this is an iterator suitable for - iso_tree_node_remove_iter() which is then to be used instead - of iso_tree_node_remove(). + iso_dir_iter_remove() which is then to be used instead + of iso_node_remove(). @param flag bit0= remove whole sub tree: rm -r bit1= remove empty directory: rmdir bit2= recursion: do not reassure in mode 2 "tree" @@ -1646,10 +1789,10 @@ int Xorriso_rmi(struct XorrisO *xorriso, void *boss_iter, char *path, int flag) { int ret, is_dir= 0, pl, not_removed= 0, fret; - struct iso_tree_node *victim_node, *node; - struct iso_tree_node_dir *boss_node, *root_dir; - struct iso_tree_iter *iter= NULL; - struct iso_volume *volume; + IsoNode *victim_node, *node; + IsoDir *boss_node, *root_dir; + IsoDirIter *iter= NULL; + IsoImage *volume; char *sub_name, *name; #ifdef Xorriso_fat_local_meM @@ -1675,7 +1818,7 @@ int Xorriso_rmi(struct XorrisO *xorriso, void *boss_iter, ret= Xorriso_node_from_path(xorriso, volume, path, &victim_node, 0); if(ret<=0) goto ex; - root_dir= iso_volume_get_root(volume); + root_dir= iso_image_get_root(volume); if(((void *) root_dir) == ((void *) victim_node)) { sprintf(xorriso->info_text, "May not delete root directory"); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); @@ -1695,10 +1838,15 @@ int Xorriso_rmi(struct XorrisO *xorriso, void *boss_iter, if(flag&1) { /* rm -r */ if(xorriso->do_reassure==1 && !xorriso->request_not_to_ask) { /* Iterate over subordinates and delete them */ - /* this might become standard if access permissions get respected */ - iter= iso_tree_node_children((struct iso_tree_node_dir *) victim_node); + ret= iso_dir_get_children((IsoDir *) victim_node, &iter); Xorriso_process_msg_queues(xorriso,0); + if(ret<0) { +cannot_create_iter:; + sprintf(xorriso->info_text, "Cannot create IsoDirIter object"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + ret= -1; goto ex; + } pl= strlen(path); strcpy(sub_path, path); if(pl==0 || sub_path[pl-1]!='/') { @@ -1706,9 +1854,9 @@ int Xorriso_rmi(struct XorrisO *xorriso, void *boss_iter, sub_path[pl]= 0; } sub_name= sub_path+pl; - while((node= iso_tree_iter_next(iter)) != NULL - && !xorriso->request_to_abort) { - name= (char *) iso_tree_node_get_name(node); + while(iso_dir_iter_next(iter, &node) == 1 + && !xorriso->request_to_abort) { + name= (char *) iso_node_get_name(node); if(Xorriso_much_too_long(xorriso, pl+1+strlen(name), 0)<=0) {ret= 0; goto rm_r_problem_handler;} strcpy(sub_name, name); @@ -1739,22 +1887,25 @@ dir_not_removed:; ret= 0; goto ex; } - iter= iso_tree_node_children((struct iso_tree_node_dir *) victim_node); + ret= iso_dir_get_children((IsoDir *) victim_node, &iter); Xorriso_process_msg_queues(xorriso,0); - if(iso_tree_iter_next(iter)!=NULL) { - sprintf(xorriso->info_text, - "Directory not empty on attempt to delete: %s", - Text_shellsafe(path, sfe, 0)); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); - ret= 0; goto ex; + if(ret<0) + goto cannot_create_iter; + if(ret>0) { + if(iso_dir_iter_next(iter, &node) == 1) { + sprintf(xorriso->info_text, + "Directory not empty on attempt to delete: %s", + Text_shellsafe(path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + ret= 0; goto ex; + } } } } if(xorriso->request_to_abort) {ret= 3; goto ex;} - - boss_node= iso_tree_node_get_parent(victim_node); + boss_node= iso_node_get_parent(victim_node); Xorriso_process_msg_queues(xorriso,0); if(boss_node==NULL) { sprintf(xorriso->info_text, @@ -1804,11 +1955,11 @@ dir_not_removed:; } if(boss_iter!=NULL) { - ret= iso_tree_node_remove_iter((struct iso_tree_iter *) boss_iter); + ret= iso_dir_iter_remove((IsoDirIter *) boss_iter); if(ret<0) ret= -1; } else - ret= iso_tree_node_remove(boss_node, victim_node); + ret= iso_node_remove(victim_node); Xorriso_process_msg_queues(xorriso,0); if(ret==-1) { sprintf(xorriso->info_text, @@ -1829,7 +1980,7 @@ ex:; #endif /* ! Xorriso_fat_local_meM */ if(iter!=NULL) - iso_tree_iter_free(iter); + iso_dir_iter_free(iter); return(ret); } @@ -1838,8 +1989,8 @@ int Xorriso__node_name_cmp(const void *node1, const void *node2) { char *name1, *name2; - name1= (char *) iso_tree_node_get_name(*((struct iso_tree_node **) node1)); - name2= (char *) iso_tree_node_get_name(*((struct iso_tree_node **) node2)); + name1= (char *) iso_node_get_name(*((IsoNode **) node1)); + name2= (char *) iso_node_get_name(*((IsoNode **) node2)); return(strcmp(name1,name2)); } @@ -1849,22 +2000,22 @@ int Xorriso__node_name_cmp(const void *node1, const void *node2) bit2= do not apply search pattern but accept any node */ int Xorriso_sorted_node_array(struct XorrisO *xorriso, - struct iso_tree_node_dir *dir_node, - int *nodec, struct iso_tree_node ***node_array, + IsoDir *dir_node, + int *nodec, IsoNode ***node_array, off_t boss_mem, int flag) { int i, ret, failed_at; char *npt; - struct iso_tree_iter *iter= NULL; - struct iso_tree_node *node; + IsoDirIter *iter= NULL; + IsoNode *node; off_t mem; - mem= ((*nodec)+1)*sizeof(struct iso_tree_node *); + mem= ((*nodec)+1)*sizeof(IsoNode *); ret= Xorriso_check_temp_mem_limit(xorriso, mem+boss_mem, flag&2); if(ret<=0) return(ret); - *node_array= calloc(sizeof(struct iso_tree_node *), (*nodec)+1); + *node_array= calloc(sizeof(IsoNode *), (*nodec)+1); if(*node_array==NULL) { sprintf(xorriso->info_text, "Cannot allocate memory for %d directory entries", *nodec); @@ -1872,9 +2023,15 @@ int Xorriso_sorted_node_array(struct XorrisO *xorriso, return(-1); } - iter= iso_tree_node_children(dir_node); - for(i= 0; (node= iso_tree_iter_next(iter)) != NULL && i<*nodec; ) { - npt= (char *) iso_tree_node_get_name(node); + ret= iso_dir_get_children(dir_node, &iter); + if(ret<0) { + sprintf(xorriso->info_text, "Cannot create IsoDirIter object"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + return(-1); + } + + for(i= 0; iso_dir_iter_next(iter, &node) == 1 && i<*nodec; ) { + npt= (char *) iso_node_get_name(node); if(!(flag&4)) { ret= Xorriso_regexec(xorriso, npt, &failed_at, 0); if(ret) @@ -1885,25 +2042,24 @@ int Xorriso_sorted_node_array(struct XorrisO *xorriso, continue; (*node_array)[i++]= node; } + iso_dir_iter_free(iter); *nodec= i; if(*nodec<=0) return(1); - qsort(*node_array, *nodec, sizeof(struct iso_tree_node *), - Xorriso__node_name_cmp); + qsort(*node_array, *nodec, sizeof(IsoNode *), Xorriso__node_name_cmp); return(1); } /* @param flag bit0= do not only sum up sizes but also print subdirs */ -int Xorriso_show_du_subs(struct XorrisO *xorriso, - struct iso_tree_node_dir *dir_node, +int Xorriso_show_du_subs(struct XorrisO *xorriso, IsoDir *dir_node, char *abs_path, char *rel_path, off_t *size, off_t boss_mem, int flag) { int i, ret, no_sort= 0, filec= 0, l; - struct iso_tree_iter *iter= NULL; - struct iso_tree_node *node, **node_array= NULL; + IsoDirIter *iter= NULL; + IsoNode *node, **node_array= NULL; char *name; off_t sub_size, report_size, mem= 0; @@ -1923,16 +2079,17 @@ int Xorriso_show_du_subs(struct XorrisO *xorriso, #endif /* ! Xorriso_fat_local_meM */ *size= 0; - iter= iso_tree_node_children(dir_node); - if(iter==NULL) { + ret= iso_dir_get_children(dir_node, &iter); + if(ret<0) { +cannot_create_iter:; Xorriso_process_msg_queues(xorriso,0); sprintf(xorriso->info_text, "Cannot obtain ISO directory iterator"); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); {ret= -1; goto ex;} } - for(i= 0; (node= iso_tree_iter_next(iter)) != NULL; ) { + for(i= 0; iso_dir_iter_next(iter, &node) == 1; ) { sub_size= 0; - name= (char *) iso_tree_node_get_name(node); + name= (char *) iso_node_get_name(node); strcpy(show_path, rel_path); if(Sfile_add_to_path(show_path, name, 0)<=0) goto much_too_long; @@ -1950,17 +2107,21 @@ much_too_long:; mem+= sizeof(char *)-(l % sizeof(char *)); if(flag&1) /* diving and counting is done further below */ continue; - ret= Xorriso_show_du_subs(xorriso, (struct iso_tree_node_dir *) node, + ret= Xorriso_show_du_subs(xorriso, (IsoDir *) node, path, show_path, &sub_size, boss_mem, 0); if(ret<0) goto ex; if(ret==0) continue; } + + if(LIBISO_ISREG(node)) { + sub_size+= iso_file_get_size((IsoFile *) node)+2048; /* - sub_size+= iso_tree_node_get_size(node)+strlen(name)+1; + sub_size+= iso_file_get_size((IsoFile *) node)+strlen(name)+1; */ - sub_size+= iso_tree_node_get_size(node)+2048; + } + if(sub_size>0) (*size)+= sub_size; Xorriso_process_msg_queues(xorriso,0); @@ -1970,7 +2131,7 @@ much_too_long:; {ret= 1; goto ex;} /* Reset iteration */ - iso_tree_iter_free(iter); + iso_dir_iter_free(iter); iter= NULL; Xorriso_process_msg_queues(xorriso,0); @@ -1980,13 +2141,15 @@ much_too_long:; goto ex; if(ret==0) { no_sort= 1; - iter= iso_tree_node_children(dir_node); + ret= iso_dir_get_children(dir_node, &iter); + if(ret<0) + goto cannot_create_iter; } for(i= 0; (no_sort || irequest_to_abort); i++) { if(no_sort) { - node= iso_tree_iter_next(iter); - if(node==NULL) + ret= iso_dir_iter_next(iter, &node); + if(ret!=1) break; if(!LIBISO_ISDIR(node)) continue; @@ -1994,21 +2157,24 @@ much_too_long:; node= node_array[i]; sub_size= 0; - name= (char *) iso_tree_node_get_name(node); + name= (char *) iso_node_get_name(node); strcpy(show_path, rel_path); if(Sfile_add_to_path(show_path, name, 0)<=0) goto much_too_long; strcpy(path, abs_path); if(Sfile_add_to_path(path, name, 0)<=0) goto much_too_long; - ret= Xorriso_show_du_subs(xorriso, (struct iso_tree_node_dir *) node, + ret= Xorriso_show_du_subs(xorriso, (IsoDir *) node, path, show_path, &sub_size, boss_mem+mem, flag&1); if(ret<0) goto ex; + + if(LIBISO_ISREG(node)) { + sub_size+= iso_file_get_size((IsoFile *) node)+2048; /* - sub_size+= iso_tree_node_get_size(node)+strlen(name)+1; + sub_size+= iso_tree_node_get_size((IsoFile *) node)+strlen(name)+1; */ - sub_size+= iso_tree_node_get_size(node)+2048; + } if(sub_size>0) (*size)+= sub_size; report_size= sub_size/1024; @@ -2032,7 +2198,7 @@ ex:; #endif /* ! Xorriso_fat_local_meM */ if(iter!=NULL) - iso_tree_iter_free(iter); + iso_dir_iter_free(iter); if(node_array!=NULL) free((char *) node_array); Xorriso_process_msg_queues(xorriso,0); @@ -2042,17 +2208,19 @@ ex:; /* @param flag bit0= *node is already valid */ int Xorriso_fake_stbuf(struct XorrisO *xorriso, char *path, struct stat *stbuf, - struct iso_tree_node **node, int flag) + IsoNode **node, int flag) { int ret; - struct iso_volume *volume; + IsoImage *volume; memset((char *) stbuf, 0, sizeof(struct stat)); if(!(flag&1)) { ret= Xorriso_get_volume(xorriso, &volume, 0); if(ret<=0) return(-1); - *node= iso_tree_volume_path_to_node(volume,path); + ret= Xorriso_node_from_path(xorriso, volume, path, node, 1); + if(ret<=0) + *node= NULL; } if(*node==NULL) return(0); @@ -2060,52 +2228,65 @@ int Xorriso_fake_stbuf(struct XorrisO *xorriso, char *path, struct stat *stbuf, /* >>> stbuf->st_dev */ /* >>> stbuf->st_ino */ - stbuf->st_mode= iso_tree_node_get_permissions(*node); + stbuf->st_mode= iso_node_get_permissions(*node) & 07777; if(LIBISO_ISDIR(*node)) stbuf->st_mode|= S_IFDIR; else if(LIBISO_ISREG(*node)) stbuf->st_mode|= S_IFREG; else if(LIBISO_ISLNK(*node)) stbuf->st_mode|= S_IFLNK; + else if(LIBISO_ISLNK(*node)) + stbuf->st_mode|= S_IFCHR; + else if(LIBISO_ISBLK(*node)) + stbuf->st_mode|= S_IFBLK; + else if(LIBISO_ISFIFO(*node)) + stbuf->st_mode|= S_IFIFO; + else if(LIBISO_ISSOCK(*node)) + stbuf->st_mode|= S_IFSOCK; + + /* >>> NG How to represent LIBISO_BOOT ? */ + /* >>> With directories this should be : number of subdirs + 2 */ /* >>> ??? How to obtain RR hardlink number for other types ? */ stbuf->st_nlink= 1; - stbuf->st_uid= iso_tree_node_get_uid(*node); - stbuf->st_gid= iso_tree_node_get_gid(*node); + stbuf->st_uid= iso_node_get_uid(*node); + stbuf->st_gid= iso_node_get_gid(*node); /* >>> stbuf->st_rdev */ - stbuf->st_size= iso_tree_node_get_size(*node); + if(LIBISO_ISREG(*node)) + stbuf->st_size= iso_file_get_size((IsoFile *) *node)+2048; + else + stbuf->st_size= 0; stbuf->st_blksize= 2048; stbuf->st_blocks= stbuf->st_size / (off_t) 2048; if(stbuf->st_blocks * (off_t) 2048 != stbuf->st_size) stbuf->st_blocks++; - stbuf->st_atime= iso_tree_node_get_atime(*node); - stbuf->st_mtime= iso_tree_node_get_mtime(*node); - stbuf->st_ctime= iso_tree_node_get_ctime(*node); + stbuf->st_atime= iso_node_get_atime(*node); + stbuf->st_mtime= iso_node_get_mtime(*node); + stbuf->st_ctime= iso_node_get_ctime(*node); return(1); } -int Xorriso_sorted_dir_i(struct XorrisO *xorriso, - struct iso_tree_node_dir *dir_node, +int Xorriso_sorted_dir_i(struct XorrisO *xorriso, IsoDir *dir_node, int *filec, char ***filev, off_t boss_mem, int flag) { int i,j,ret; - struct iso_tree_iter *iter= NULL; - struct iso_tree_node *node; + IsoDirIter *iter= NULL; + IsoNode *node; char *name; off_t mem; (*filec)= 0; (*filev)= NULL; - iter= iso_tree_node_children(dir_node); - if(iter==NULL) { + ret= iso_dir_get_children(dir_node, &iter); + if(ret<0) { cannot_iter:; Xorriso_process_msg_queues(xorriso,0); sprintf(xorriso->info_text, "Cannot obtain ISO directory iterator"); @@ -2113,12 +2294,13 @@ cannot_iter:; {ret= -1; goto ex;} } mem= 0; - for(i= 0; (node= iso_tree_iter_next(iter)) != NULL; ) { - name= (char *) iso_tree_node_get_name(node); + for(i= 0; iso_dir_iter_next(iter, &node) == 1; ) { + name= (char *) iso_node_get_name(node); mem+= sizeof(char *)+strlen(name)+8; (*filec)++; } - iso_tree_iter_free(iter); + iso_dir_iter_free(iter); + iter= NULL; if(*filec==0) {ret= 1; goto ex;} @@ -2128,11 +2310,14 @@ cannot_iter:; (*filev)= (char **) calloc(*filec, sizeof(char *)); if(*filev==NULL) {ret= -1; goto ex; } - iter= iso_tree_node_children(dir_node); - if(iter==NULL) + ret= iso_dir_get_children(dir_node, &iter); + if(ret<0) goto cannot_iter; for(i= 0; i<*filec; i++) { - name= (char *) iso_tree_node_get_name(iso_tree_iter_next(iter)); + ret= iso_dir_iter_next(iter, &node); + if(ret!=1) + break; + name= (char *) iso_node_get_name(node); (*filev)[i]= strdup(name); if((*filev)[i]==NULL) { for(j= 0; jinfo_text, "Not found in ISO image: %s", Text_shellsafe(path, sfe, 0)); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0); @@ -2219,7 +2404,7 @@ int Xorriso_ls_filev(struct XorrisO *xorriso, char *wd, Xorriso_result(xorriso,0); } ret= Xorriso_sorted_dir_i(xorriso, - (struct iso_tree_node_dir *) node, &dfilec, &dfilev, boss_mem, 0); + (IsoDir *) node, &dfilec, &dfilev, boss_mem, 0); if(ret<=0) { /* >>> libisofs iterator loop and single item Xorriso_lsx_filev() */; @@ -2244,14 +2429,14 @@ int Xorriso_ls_filev(struct XorrisO *xorriso, char *wd, if(ret<=0) continue; if(LIBISO_ISLNK(node)) { - if(Sfile_str(link_target, (char *) iso_tree_node_symlink_get_dest( - (struct iso_tree_node_symlink *) node), 0)<=0) + if(Sfile_str(link_target, (char *) iso_symlink_get_dest( + (IsoSymlink *) node), 0)<=0) link_target[0]= 0; } } else if(flag&4) { /* -du or -dus */ size= stbuf.st_size; if(S_ISDIR(stbuf.st_mode)) { - ret= Xorriso_show_du_subs(xorriso, (struct iso_tree_node_dir *) node, + ret= Xorriso_show_du_subs(xorriso, (IsoDir *) node, path, filev[i], &size, boss_mem, flag&1); if(ret<0) return(-1); @@ -2283,10 +2468,10 @@ int Xorriso_ls_filev(struct XorrisO *xorriso, char *wd, int Xorriso_ls(struct XorrisO *xorriso, int flag) { int ret, is_dir= 0, i, filec= 0, failed_at, no_sort= 0; - struct iso_tree_node *node, **node_array= NULL; - struct iso_tree_node_dir *dir_node; - struct iso_volume *volume; - struct iso_tree_iter *iter= NULL; + IsoNode *node, **node_array= NULL; + IsoDir *dir_node; + IsoImage *volume; + IsoDirIter *iter= NULL; char sfe[5*SfileadrL], sfe2[5*SfileadrL], link_target[SfileadrL], *npt, *rpt; struct stat stbuf; @@ -2311,12 +2496,19 @@ wdi_is_not_a_dir:; if(flag&2) {ret= 1; goto ex;} - dir_node= (struct iso_tree_node_dir *) node; - iter= iso_tree_node_children(dir_node); + dir_node= (IsoDir *) node; + ret= iso_dir_get_children(dir_node, &iter); + if(ret<0) { +cannot_create_iter:; + Xorriso_process_msg_queues(xorriso,0); + sprintf(xorriso->info_text, "Cannot obtain ISO directory iterator"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + {ret= -1; goto ex;} + } Xorriso_process_msg_queues(xorriso,0); - for(i= 0; (node= iso_tree_iter_next(iter)) != NULL; ) { - npt= (char *) iso_tree_node_get_name(node); + for(i= 0; iso_dir_iter_next(iter, &node) == 1; ) { + npt= (char *) iso_node_get_name(node); if(!(flag&4)) { ret= Xorriso_regexec(xorriso, npt, &failed_at, 0); if(ret) @@ -2325,7 +2517,7 @@ wdi_is_not_a_dir:; filec++; } /* Reset iteration */ - iso_tree_iter_free(iter); + iso_dir_iter_free(iter); iter= NULL; Xorriso_process_msg_queues(xorriso,0); @@ -2338,15 +2530,17 @@ wdi_is_not_a_dir:; goto ex; if(ret==0) { no_sort= 1; - iter= iso_tree_node_children(dir_node); + ret= iso_dir_get_children(dir_node, &iter); + if(ret<0) + goto cannot_create_iter; } for(i= 0; irequest_to_abort); i++) { if(no_sort) { - node= iso_tree_iter_next(iter); - if(node==NULL) + ret= iso_dir_iter_next(iter, &node); + if(ret!=1) break; - npt= (char *) iso_tree_node_get_name(node); + npt= (char *) iso_node_get_name(node); if(!(flag&4)) { ret= Xorriso_regexec(xorriso, npt, &failed_at, 0); if(ret) @@ -2355,11 +2549,11 @@ wdi_is_not_a_dir:; } else node= node_array[i]; - npt= (char *) iso_tree_node_get_name(node); + npt= (char *) iso_node_get_name(node); link_target[0]= 0; if(LIBISO_ISLNK(node)) { - if(Sfile_str(link_target, (char *) iso_tree_node_symlink_get_dest( - (struct iso_tree_node_symlink *) node), 0)<=0) + if(Sfile_str(link_target, (char *) iso_symlink_get_dest( + (IsoSymlink *) node), 0)<=0) link_target[0]= 0; } rpt[0]= 0; @@ -2384,7 +2578,7 @@ wdi_is_not_a_dir:; ret= 1; ex:; if(iter!=NULL) - iso_tree_iter_free(iter); + iso_dir_iter_free(iter); Xorriso_process_msg_queues(xorriso,0); if(node_array!=NULL) free((char *) node_array); @@ -2396,10 +2590,10 @@ int Xorriso_rename(struct XorrisO *xorriso, char *origin, char *dest, int flag) { int ret, ol, dest_ret; char sfe[5*SfileadrL], eff_dest[SfileadrL], dir_adr[SfileadrL], *cpt; - char *leafname, eff_origin[SfileadrL], sfe2[5*SfileadrL]; - struct iso_volume *volume; - struct iso_tree_node_dir *origin_dir, *dest_dir; - struct iso_tree_node *node; + char *leafname, eff_origin[SfileadrL], sfe2[5*SfileadrL], *old_leafname; + IsoImage *volume; + IsoDir *origin_dir, *dest_dir; + IsoNode *node, *iso_node; ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, origin, eff_origin, 0); if(ret<=0) @@ -2473,16 +2667,16 @@ int Xorriso_rename(struct XorrisO *xorriso, char *origin, char *dest, int flag) ret= Xorriso_get_volume(xorriso, &volume, 0); if(ret<=0) return(ret); - dest_dir= (struct iso_tree_node_dir *) - iso_tree_volume_path_to_node(volume,dir_adr); + Xorriso_node_from_path(xorriso, volume, dir_adr, &iso_node, 0); + dest_dir= (IsoDir *) iso_node; strcpy(dir_adr, eff_origin); cpt= strrchr(dir_adr, '/'); if(cpt==NULL) cpt= dir_adr+strlen(dir_adr); *cpt= 0; - origin_dir= (struct iso_tree_node_dir *) - iso_tree_volume_path_to_node(volume,dir_adr); - node= iso_tree_volume_path_to_node(volume,eff_origin); + Xorriso_node_from_path(xorriso, volume, dir_adr, &iso_node, 0); + origin_dir= (IsoDir *) iso_node; + Xorriso_node_from_path(xorriso, volume, eff_origin, &node, 0); if(dest_dir==NULL || origin_dir==NULL || node==NULL) { Xorriso_process_msg_queues(xorriso,0); sprintf(xorriso->info_text, @@ -2490,22 +2684,37 @@ int Xorriso_rename(struct XorrisO *xorriso, char *origin, char *dest, int flag) Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); return(-1); } - ret= iso_tree_node_take(origin_dir, node); - if(ret==-1) { + ret= iso_node_take(node); + if(ret<0) { Xorriso_process_msg_queues(xorriso,0); sprintf(xorriso->info_text, "Internal error on rename: failed to take node"); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); return(-1); } - iso_tree_add_child(dest_dir, node); + ret= iso_dir_add_node(dest_dir, node, 0); + if(ret<0) { + Xorriso_process_msg_queues(xorriso,0); + sprintf(xorriso->info_text, + "Internal error on rename: failed to insert node"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + return(-1); + } leafname= strrchr(eff_dest, '/'); if(leafname==NULL) leafname= eff_dest; else leafname++; - iso_tree_node_set_name(node, leafname); - + + old_leafname= (char *) iso_node_get_name(node); + if(strcmp(leafname, old_leafname)!=0) + ret= iso_node_set_name(node, leafname); + if(ret<0) { + Xorriso_process_msg_queues(xorriso,0); + sprintf(xorriso->info_text, "Internal error on rename: failed to set name"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + return(-1); + } Xorriso_process_msg_queues(xorriso,0); return(1); } @@ -2550,13 +2759,13 @@ int Xorriso_mkdir(struct XorrisO *xorriso, char *path, int flag) bit2= prepend wd (automatically done if wd[0]!=0) */ int Xorriso_obtain_pattern_files_i( - struct XorrisO *xorriso, char *wd, struct iso_tree_node_dir *dir, + struct XorrisO *xorriso, char *wd, IsoDir *dir, int *filec, char **filev, int count_limit, off_t *mem, int *dive_count, int flag) { int ret, failed_at; - struct iso_tree_iter *iter= NULL; - struct iso_tree_node *node; + IsoDirIter *iter= NULL; + IsoNode *node; char *name; #ifdef Xorriso_fat_local_meM @@ -2581,15 +2790,15 @@ int Xorriso_obtain_pattern_files_i( if(ret!=2) goto ex; - iter= iso_tree_node_children(dir); - if(iter==NULL) { + ret= iso_dir_get_children(dir, &iter); + if(ret<0) { Xorriso_process_msg_queues(xorriso,0); sprintf(xorriso->info_text, "Cannot obtain ISO directory iterator"); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); {ret= -1; goto ex;} } - while((node= iso_tree_iter_next(iter)) != NULL) { - name= (char *) iso_tree_node_get_name(node); + while(iso_dir_iter_next(iter, &node) == 1) { + name= (char *) iso_node_get_name(node); ret= Xorriso_make_abs_adr(xorriso, wd, name, adr, flag&4); if(ret<=0) goto ex; @@ -2606,7 +2815,7 @@ int Xorriso_obtain_pattern_files_i( } /* dive deeper */ ret= Xorriso_obtain_pattern_files_i( - xorriso, adr, (struct iso_tree_node_dir *) node, + xorriso, adr, (IsoDir *) node, filec, filev, count_limit, mem, dive_count, flag|2); if(ret<=0) goto ex; @@ -2641,8 +2850,9 @@ int Xorriso_expand_pattern(struct XorrisO *xorriso, int ret, count= 0, abs_adr= 0, i, was_count, was_filec; int nonconst_mismatches= 0, dive_count= 0; char sfe[5*SfileadrL]; - struct iso_volume *volume; - struct iso_tree_node_dir *dir= NULL, *root_dir; + IsoImage *volume; + IsoDir *dir= NULL, *root_dir; + IsoNode *iso_node; *filec= 0; *filev= NULL; @@ -2653,7 +2863,7 @@ int Xorriso_expand_pattern(struct XorrisO *xorriso, ret= Xorriso_get_volume(xorriso, &volume, 0); if(ret<=0) return(ret); - root_dir= iso_volume_get_root(volume); + root_dir= iso_image_get_root(volume); if(root_dir==NULL) { Xorriso_process_msg_queues(xorriso,0); sprintf(xorriso->info_text, @@ -2676,9 +2886,9 @@ int Xorriso_expand_pattern(struct XorrisO *xorriso, It is not an error if xorriso->wdi does not exist yet, but one may not use it as base for relative address searches. */ - dir= (struct iso_tree_node_dir *) - iso_tree_volume_path_to_node(volume,xorriso->wdi); - if(dir==NULL) { + ret= Xorriso_node_from_path(xorriso, volume, xorriso->wdi, &iso_node, 1); + dir= (IsoDir *) iso_node; + if(ret<=0) { Xorriso_process_msg_queues(xorriso,0); sprintf(xorriso->info_text, "While expanding pattern %s : Working directory does not exist in ISO image", @@ -2686,7 +2896,7 @@ int Xorriso_expand_pattern(struct XorrisO *xorriso, Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); ret= 0; goto ex; } - if(!LIBISO_ISDIR((struct iso_tree_node *) dir)) { + if(!LIBISO_ISDIR((IsoNode *) dir)) { sprintf(xorriso->info_text, "Working directory path does not lead to a directory in ISO image"); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); @@ -2756,16 +2966,16 @@ int Xorriso_set_st_mode(struct XorrisO *xorriso, char *in_path, { mode_t mode= 0; int ret; - struct iso_tree_node *node; + IsoNode *node; char sfe[5*SfileadrL], path[SfileadrL]; ret= Xorriso_get_node_by_path(xorriso, in_path, path, &node, 0); if(ret<=0) return(ret); - mode= iso_tree_node_get_permissions(node); + mode= iso_node_get_permissions(node); mode= (mode & mode_and) | mode_or; - iso_tree_node_set_permissions(node, mode); - iso_tree_node_set_ctime(node, time(NULL)); + iso_node_set_permissions(node, mode); + iso_node_set_ctime(node, time(NULL)); sprintf(xorriso->info_text,"Permissions now: %-5.5o %s", mode, Text_shellsafe(path, sfe, 0)); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0); @@ -2779,13 +2989,13 @@ int Xorriso_set_uid(struct XorrisO *xorriso, char *in_path, uid_t uid, int flag) { int ret; - struct iso_tree_node *node; + IsoNode *node; ret= Xorriso_get_node_by_path(xorriso, in_path, NULL, &node, 0); if(ret<=0) return(ret); - iso_tree_node_set_uid(node, uid); - iso_tree_node_set_ctime(node, time(NULL)); + iso_node_set_uid(node, uid); + iso_node_set_ctime(node, time(NULL)); xorriso->volset_change_pending= 1; Xorriso_process_msg_queues(xorriso,0); return(1); @@ -2796,13 +3006,13 @@ int Xorriso_set_gid(struct XorrisO *xorriso, char *in_path, gid_t gid, int flag) { int ret; - struct iso_tree_node *node; + IsoNode *node; ret= Xorriso_get_node_by_path(xorriso, in_path, NULL, &node, 0); if(ret<=0) return(ret); - iso_tree_node_set_gid(node, gid); - iso_tree_node_set_ctime(node, time(NULL)); + iso_node_set_gid(node, gid); + iso_node_set_ctime(node, time(NULL)); xorriso->volset_change_pending= 1; Xorriso_process_msg_queues(xorriso,0); return(1); @@ -2814,19 +3024,19 @@ int Xorriso_set_time(struct XorrisO *xorriso, char *in_path, time_t t, int flag) { int ret; - struct iso_tree_node *node; + IsoNode *node; ret= Xorriso_get_node_by_path(xorriso, in_path, NULL, &node, 0); if(ret<=0) return(ret); if(flag&1) - iso_tree_node_set_atime(node, t); + iso_node_set_atime(node, t); if(flag&2) - iso_tree_node_set_ctime(node, t); + iso_node_set_ctime(node, t); if(flag&4) - iso_tree_node_set_mtime(node, t); + iso_node_set_mtime(node, t); if(!(flag&(2|256))) - iso_tree_node_set_ctime(node, time(NULL)); + iso_node_set_ctime(node, time(NULL)); xorriso->volset_change_pending= 1; Xorriso_process_msg_queues(xorriso,0); return(1); @@ -2835,9 +3045,9 @@ int Xorriso_set_time(struct XorrisO *xorriso, char *in_path, time_t t, int Xorriso_findi_action(struct XorrisO *xorriso, struct FindjoB *job, char *abs_path, char *show_path, - struct iso_tree_node *node, int depth, int flag) + IsoNode *node, int depth, int flag) { - int ret, type, action= 0; + int ret= 0, type, action= 0; uid_t user= 0; gid_t group= 0; time_t date= 0; @@ -2888,22 +3098,21 @@ int Xorriso_findi(struct XorrisO *xorriso, struct FindjoB *job, struct stat *dir_stbuf, int depth, int flag) { int ret, action= 0; - struct iso_tree_iter *iter= NULL; - struct iso_tree_node_dir *dir_node; - struct iso_tree_node *node; - struct iso_volume *volume; + IsoDirIter *iter= NULL; + IsoDir *dir_node; + IsoNode *node, *iso_node; + IsoImage *volume; struct stat stbuf; char *name; #ifdef Xorriso_fat_local_meM - char path[SfileadrL], sfe[5*SfileadrL]; + char path[SfileadrL], abs_path[SfileadrL]; #else /* Xorriso_fat_local_meM */ - char *path= NULL, *sfe= NULL, *abs_path= NULL; + char *path= NULL, *abs_path= NULL; - sfe= malloc(5*SfileadrL); path= malloc(SfileadrL); abs_path= malloc(SfileadrL); - if(sfe==NULL || path==NULL || abs_path==NULL) { - Xorriso_no_malloc_memory(xorriso, &sfe, 0); + if(path==NULL || abs_path==NULL) { + Xorriso_no_malloc_memory(xorriso, &path, 0); {ret= -1; goto ex;} } #endif /* ! Xorriso_fat_local_meM */ @@ -2912,7 +3121,7 @@ int Xorriso_findi(struct XorrisO *xorriso, struct FindjoB *job, if(action<0) action= 0; - dir_node= (struct iso_tree_node_dir *) dir_node_generic; + dir_node= (IsoDir *) dir_node_generic; if(dir_node==NULL) { ret= Xorriso_get_volume(xorriso, &volume, 0); if(ret<=0) @@ -2920,12 +3129,12 @@ int Xorriso_findi(struct XorrisO *xorriso, struct FindjoB *job, ret= Xorriso_make_abs_adr(xorriso, xorriso->wdi, dir_path, path, 1|2|4); if(ret<=0) goto ex; - dir_node= (struct iso_tree_node_dir *) - iso_tree_volume_path_to_node(volume, path); - if(dir_node==NULL) + ret= Xorriso_node_from_path(xorriso, volume, path, &iso_node, 0); + dir_node= (IsoDir *) iso_node; + if(ret<=0) {ret= 0; goto ex;} - ret= Xorriso_fake_stbuf(xorriso, "", dir_stbuf, - (struct iso_tree_node **) &dir_node, 1); + ret= Xorriso_fake_stbuf(xorriso, "", dir_stbuf, &iso_node, 1); + dir_node= (IsoDir *) iso_node; if(ret<=0) goto ex; @@ -2939,23 +3148,23 @@ int Xorriso_findi(struct XorrisO *xorriso, struct FindjoB *job, goto ex; if(ret>0) { ret= Xorriso_findi_action(xorriso, job, path, dir_path, - (struct iso_tree_node *) dir_node, depth, 0); + (IsoNode *) dir_node, depth, 0); if(ret<=0) goto ex; } } - if(!LIBISO_ISDIR((struct iso_tree_node *) dir_node)) + if(!LIBISO_ISDIR((IsoNode *) dir_node)) {ret= 2; goto ex;} - iter= iso_tree_node_children(dir_node); - if(iter==NULL) { + ret= iso_dir_get_children(dir_node, &iter); + if(ret<0) { Xorriso_process_msg_queues(xorriso,0); sprintf(xorriso->info_text, "Cannot obtain ISO directory iterator"); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); {ret= -1; goto ex;} } - while((node= iso_tree_iter_next(iter)) != NULL && !xorriso->request_to_abort){ - name= (char *) iso_tree_node_get_name(node); + while(iso_dir_iter_next(iter, &node) == 1 && !xorriso->request_to_abort) { + name= (char *) iso_node_get_name(node); ret= Xorriso_make_abs_adr(xorriso, dir_path, name, path, 4); if(ret<=0) goto ex; @@ -2969,11 +3178,6 @@ int Xorriso_findi(struct XorrisO *xorriso, struct FindjoB *job, if(ret<0) goto ex; if(ret>0) { - -#ifdef NIX - sprintf(xorriso->result_line, "%s\n", Text_shellsafe(path, sfe, 0)); - Xorriso_result(xorriso, 0); -#else ret= Xorriso_make_abs_adr(xorriso, xorriso->wdi, path, abs_path, 1|4); if(ret<=0) goto ex; @@ -2982,8 +3186,6 @@ int Xorriso_findi(struct XorrisO *xorriso, struct FindjoB *job, if(Xorriso_eval_problem_status(xorriso, ret, 1|2)<0) goto ex; } -#endif /* ! NIX */ - } if(S_ISDIR(stbuf.st_mode)) { @@ -2998,8 +3200,6 @@ int Xorriso_findi(struct XorrisO *xorriso, struct FindjoB *job, ex:; #ifndef Xorriso_fat_local_meM - if(sfe!=NULL) - free(sfe); if(path!=NULL) free(path); if(abs_path!=NULL) @@ -3008,30 +3208,40 @@ ex:; Xorriso_process_msg_queues(xorriso,0); if(iter!=NULL) - iso_tree_iter_free(iter); + iso_dir_iter_free(iter); return(ret); } +/* @param flag bit0= do not mark image as changed */ int Xorriso_set_volid(struct XorrisO *xorriso, char *volid, int flag) { int ret; - struct iso_volume *volume; + IsoImage *volume; ret= Xorriso_get_volume(xorriso, &volume, 0); if(ret<=0) return(ret); - iso_volume_set_volume_id(volume, volid); + iso_image_set_volume_id(volume, volid); + if(!(flag&1)) + xorriso->volset_change_pending= 1; Xorriso_process_msg_queues(xorriso,0); + sprintf(xorriso->info_text,"Volume ID: '%s'",iso_image_get_volume_id(volume)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0); return(1); } int Xorriso_get_volid(struct XorrisO *xorriso, char volid[33], int flag) { - /* OG dummy */; - volid[0]= 0; + int ret; + IsoImage *volume; + + ret= Xorriso_get_volume(xorriso, &volume, 0); + if(ret<=0) + return(ret); + strncpy(volid, iso_image_get_volume_id(volume), 32); + volid[32]= 0; return(1); } - - + diff --git a/libisoburn/trunk/test/ng_xorrisoburn.h b/libisoburn/trunk/xorriso/xorrisoburn.h similarity index 100% rename from libisoburn/trunk/test/ng_xorrisoburn.h rename to libisoburn/trunk/xorriso/xorrisoburn.h