libisoburn-0.3.4/libisoburn/isoburn.h File Reference

#include <stdint.h>

Include dependency graph for isoburn.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  isoburn_toc_entry
struct  isoburn
struct  isoburn_read_opts
 Options for image reading. More...
struct  isoburn_imgen_opts
 Options for image generation by libisofs and image transport to libburn. More...
struct  isoburn_toc_track
struct  isoburn_toc_session
struct  isoburn_toc_disc

Defines

#define Libisoburn_target_head_sizE   (32*2048)
#define Libisoburn_nwa_alignemenT   32
#define Libisoburn_toc_scan_alignemenT   16
#define Libisoburn_toc_scan_max_gaP   65536
#define Libisoburn_overwriteable_starT   ((off_t) (Libisoburn_target_head_sizE/2048))

Functions

int isoburn_toc_entry_new (struct isoburn_toc_entry **objpt, struct isoburn_toc_entry *boss, int flag)
int isoburn_toc_entry_destroy (struct isoburn_toc_entry **o, int flag)
int isoburn_new (struct isoburn **objpt, int flag)
int isoburn_destroy (struct isoburn **objpt, int flag)
int isoburn_get_emulation_mode (struct isoburn *o, int *pt, int flag)
int isoburn_get_target_volset (struct isoburn *o, IsoImage **pt, int flag)
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)
int isoburn_report_iso_error (int iso_error_code, char default_msg_text[], int os_errno, char min_severity[], int flag)
int isoburn_start_emulation (struct isoburn *o, int flag)
 Initialize the emulation of multi-session on random access media.
int isoburn_invalidate_iso (struct isoburn *o, int flag)
 Alters and writes the first 64 kB of a "media" to invalidate an ISO image.
int isoburn_find_emulator (struct isoburn **pt, struct burn_drive *drive, int flag)
 Get an eventual isoburn object which is wrapped around the drive.
int isoburn_msgs_submit (struct isoburn *o, int error_code, char msg_text[], int os_errno, char severity[], int flag)
int isoburn_set_start_byte (struct isoburn *o, off_t value, int flag)
 Set the start address for an emulated add-on session.
int isoburn_get_msc2 (struct isoburn *o, struct burn_write_opts *opts, int *msc2, int flag)
 Obtains the image address offset to be used with image generation.
IsoDataSource * isoburn_data_source_new (struct burn_drive *d)
 Get a data source suitable for read from a drive using burn_read_data() function.
int isoburn_data_source_shutdown (IsoDataSource *src, int flag)
 Disable read capabilities of a data source which was originally created by isoburn_data_source_new().


Define Documentation

#define Libisoburn_nwa_alignemenT   32

Definition at line 452 of file isoburn.h.

Referenced by isoburn_emulate_toc(), and isoburn_set_start_byte().

#define Libisoburn_overwriteable_starT   ((off_t) (Libisoburn_target_head_sizE/2048))

Definition at line 482 of file isoburn.h.

Referenced by isoburn_emulate_toc(), and isoburn_new().

#define Libisoburn_target_head_sizE   (32*2048)

#define Libisoburn_toc_scan_alignemenT   16

Definition at line 459 of file isoburn.h.

#define Libisoburn_toc_scan_max_gaP   65536

Definition at line 466 of file isoburn.h.

Referenced by isoburn_emulate_toc().


Function Documentation

int isoburn_by_idx ( struct isoburn o,
int  idx,
struct isoburn **  pt,
int  flag 
)

Definition at line 277 of file isoburn.c.

References isoburn::next, and isoburn::prev.

00278        : bit0= fetch first (idx<0) or last (idx>0) item in list
00279          bit1= address from start of list */
00280 {
00281  int i,abs_idx;
00282  struct isoburn *npt;
00283 
00284  if(flag&2)
00285    for(;o->prev!=NULL;o= o->prev);
00286  abs_idx= (idx>0?idx:-idx);
00287  *pt= o;
00288  for(i= 0;(i<abs_idx || (flag&1)) && *pt!=NULL;i++) {
00289    if(idx>0)
00290      npt= o->next;
00291    else
00292      npt= o->prev;
00293    if(npt==NULL && (flag&1))
00294  break;
00295    *pt= npt;
00296  }
00297  return(*pt!=NULL);
00298 }

int isoburn_count ( struct isoburn o,
int  flag 
)

Definition at line 264 of file isoburn.c.

References isoburn::next, and isoburn::prev.

00265        : bit1= count from start of list */
00266 {
00267  int counter= 0;
00268 
00269  if(flag&2)
00270    for(;o->prev!=NULL;o= o->prev);
00271  for(;o!=NULL;o= o->next)
00272    counter++;
00273  return(counter);
00274 }

IsoDataSource* isoburn_data_source_new ( struct burn_drive *  d  ) 

Get a data source suitable for read from a drive using burn_read_data() function.

Parameters:
d drive to read from. Must be grabbed.
Returns:
the data source, NULL on error. Must be freed with libisofs iso_data_source_unref() function. Note: this doesn't release the drive.

Definition at line 224 of file data_source.c.

References isoburn_cache_tile::age, isoburn_cache_tile::cache_hits, isoburn_cache_tile::cache_lba, isoburn_cached_drive::current_age, isoburn_cached_drive::drive, ds_close(), ds_free_data(), ds_open(), ds_read_block(), isoburn_cache_tile::last_aligned_error_lba, isoburn_cache_tile::last_error_lba, Libisoburn_cache_tileS, and isoburn_cached_drive::tiles.

Referenced by isoburn_read_image().

00225 {
00226  IsoDataSource *ret;
00227  struct isoburn_cached_drive *icd= NULL;
00228  int i;
00229 
00230  if (d==NULL)
00231    return NULL;
00232  ret = malloc(sizeof(IsoDataSource));
00233  icd = calloc(1,sizeof(struct isoburn_cached_drive));
00234  if (ret == NULL || icd == NULL)
00235    return NULL;
00236  ret->refcount = 1;
00237  ret->read_block = ds_read_block;
00238  ret->open = ds_open;
00239  ret->close = ds_close;
00240  ret->free_data = ds_free_data;
00241  ret->data = icd;
00242  icd->drive = d;
00243  icd->current_age= 0;
00244  for(i= 0; i<Libisoburn_cache_tileS; i++) {
00245    icd->tiles[i].cache_lba = 0xffffffff;
00246    icd->tiles[i].cache_hits = 0;
00247    icd->tiles[i].last_error_lba = 0xffffffff;
00248    icd->tiles[i].last_aligned_error_lba = 0xffffffff;
00249    icd->tiles[i].age= 0;
00250  }
00251  return ret;
00252 }

int isoburn_data_source_shutdown ( IsoDataSource *  src,
int  flag 
)

Disable read capabilities of a data source which was originally created by isoburn_data_source_new().

After this any attempt to read will yield a FATAL programming error event. This is usually done to allow libburn to release the drive while libisofs still holds a reference to the data source object. libisofs is not supposed to use this object for reading any more, nevertheless. The disabled state of the data source is a safety fence around this daring situation.

Parameters:
src The data source to be disabled
flag unused yet
Returns:
<=0 is failure , >0 success

Definition at line 212 of file data_source.c.

References isoburn_cached_drive::drive.

Referenced by isoburn_prepare_disc_aux().

00213 {
00214  struct isoburn_cached_drive *icd;
00215 
00216  if(src==NULL)
00217    return(0);
00218  icd= (struct isoburn_cached_drive *) src->data;
00219  icd->drive= NULL;
00220  return(1);
00221 }

int isoburn_destroy ( struct isoburn **  objpt,
int  flag 
)

Definition at line 155 of file isoburn.c.

References isoburn::image, isoburn::iso_data_source, isoburn::iso_source, isoburn_toc_entry_destroy(), isoburn::next, isoburn::prev, and isoburn::toc.

Referenced by isoburn_destroy_all(), isoburn_drive_aquire(), isoburn_drive_grab(), isoburn_drive_release(), and isoburn_new().

00156 {
00157  struct isoburn *o;
00158 
00159  o= *objpt;
00160  if(o==NULL)
00161    return(0);
00162 
00163  /* >>> mutex */
00164 
00165  if(o==isoburn_list_start)
00166    isoburn_list_start= o->next;
00167  if(o->prev!=NULL)
00168    o->prev->next= o->next;
00169  if(o->next!=NULL)
00170    o->next->prev= o->prev;
00171 
00172  /* >>> end mutex */
00173 
00174  if(o->image!=NULL)
00175    iso_image_unref(o->image);
00176  if(o->toc!=NULL)
00177    isoburn_toc_entry_destroy(&(o->toc), 1); /* all */
00178  if(o->iso_source!=NULL)
00179    burn_source_free(o->iso_source);
00180  if(o->iso_data_source!=NULL)
00181    iso_data_source_unref(o->iso_data_source);
00182  free((char *) o);
00183  *objpt= NULL;
00184  return(1);
00185 }

int isoburn_destroy_all ( struct isoburn **  objpt,
int  flag 
)

Definition at line 188 of file isoburn.c.

References isoburn_destroy(), isoburn::next, and isoburn::prev.

Referenced by isoburn_finish(), and isoburn_initialize().

00189 {
00190  struct isoburn *o,*n;
00191 
00192  o= *objpt;
00193  if(o==NULL)
00194    return(0);
00195  for(;o->prev!=NULL;o= o->prev);
00196  for(;o!=NULL;o= n) {
00197    n= o->next;
00198    isoburn_destroy(&o,0);
00199  }
00200  *objpt= NULL;
00201  return(1);
00202 }

int isoburn_find_by_drive ( struct isoburn **  pt,
struct burn_drive *  d,
int  flag 
)

Definition at line 301 of file isoburn.c.

References isoburn::drive, and isoburn::next.

Referenced by isoburn_find_emulator().

00302 {
00303  struct isoburn *o;
00304 
00305  *pt= NULL;
00306  for(o= isoburn_list_start;o!=NULL;o= o->next)
00307    if(o->drive==d) {
00308      *pt= o;
00309      return(1);
00310    }
00311  return(0);
00312 }

int isoburn_find_emulator ( struct isoburn **  pt,
struct burn_drive *  drive,
int  flag 
)

Get an eventual isoburn object which is wrapped around the drive.

Parameters:
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.
drive The drive to be searched for
flag unused yet
Returns:
-1 unsuitable media, 0 generic media, 1 emulated media.
Get an eventual isoburn object which is wrapped around the drive.

Returns:
-1 unsuitable media, 0 generic media, 1 emulated media.

Definition at line 474 of file burn_wrap.c.

References isoburn_find_by_drive(), and isoburn_msgs_submit().

Referenced by isoburn_activate_session(), isoburn_attach_image(), isoburn_cancel_prepared_write(), isoburn_disc_available_space(), isoburn_disc_erasable(), isoburn_disc_erase(), isoburn_disc_get_msc1(), isoburn_disc_get_status(), isoburn_disc_track_lba_nwa(), isoburn_disc_write(), isoburn_drive_aquire(), isoburn_drive_release(), isoburn_drive_set_msgs_submit(), isoburn_drive_wrote_well(), isoburn_emulate_toc(), isoburn_get_attached_image(), isoburn_get_fifo_status(), isoburn_get_min_start_byte(), isoburn_get_mount_params(), isoburn_needs_emulation(), isoburn_prepare_blind_grow(), isoburn_prepare_disc_aux(), isoburn_read_image(), isoburn_set_msc1(), isoburn_set_read_pacifier(), and isoburn_toc_drive_get_disc().

00476 {
00477  int ret;
00478 
00479  ret= isoburn_find_by_drive(pt, drive, 0);
00480  if(ret<=0)
00481    return(0);
00482  if((*pt)->emulation_mode==-1) {
00483    isoburn_msgs_submit(*pt, 0x00060000,
00484                     "Unsuitable drive and media state", 0, "FAILURE", 0);
00485    return(-1);
00486  }
00487  if((*pt)->emulation_mode==0)
00488    return(0);
00489  return(1);
00490 } 

int isoburn_get_emulation_mode ( struct isoburn o,
int *  pt,
int  flag 
)

int isoburn_get_msc2 ( struct isoburn o,
struct burn_write_opts *  opts,
int *  msc2,
int  flag 
)

Obtains the image address offset to be used with image generation.

This is either the (emulated) drive nwa or a value set by isoburn_prepare_blind_grow(). In any case this is the address to tell to iso_write_opts_set_ms_block().

Parameters:
o The isoburn object to be inquired
opts If not NULL: write parameters to be set on drive before query
msc2 The value to be used with iso_write_opts_set_ms_block()
flag unused yet
Returns:
<=0 is failure , >0 success

Definition at line 650 of file burn_wrap.c.

References isoburn::drive, isoburn::fabricated_msc2, isoburn_disc_track_lba_nwa(), and isoburn::nwa.

Referenced by isoburn_prepare_disc_aux().

00652 {
00653  int ret, lba, nwa;
00654 
00655  if(o->fabricated_msc2>=0)
00656    *msc2= o->fabricated_msc2;
00657  else {
00658    ret= isoburn_disc_track_lba_nwa(o->drive, opts, 0, &lba, &nwa);
00659    if(ret<=0)
00660      return(ret);
00661    *msc2= nwa;
00662  }
00663  return(1);
00664 }

int isoburn_get_next ( struct isoburn o,
struct isoburn **  pt,
int  flag 
)

Definition at line 219 of file isoburn.c.

References isoburn::next.

00220 {
00221  *pt= o->next;
00222  return(1);
00223 }

int isoburn_get_prev ( struct isoburn o,
struct isoburn **  pt,
int  flag 
)

Definition at line 212 of file isoburn.c.

References isoburn::prev.

00213 {
00214  *pt= o->prev;
00215  return(1);
00216 }

int isoburn_get_target_volset ( struct isoburn o,
IsoImage **  pt,
int  flag 
)

int isoburn_invalidate_iso ( struct isoburn o,
int  flag 
)

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.

Parameters:
o A fully activated isoburn object. isoburn_start_emulation() was already called.
Returns:
<=0 error , 1 = success

Definition at line 390 of file isofs_wrap.c.

References isoburn::drive, isoburn_activate_session(), and isoburn::target_iso_head.

Referenced by isoburn_disc_erase().

00391 {
00392  /* 
00393   * replace CD001 with CDXX1 in PVM.
00394   * I think this is enought for invalidating an iso image
00395   */
00396  strncpy((char*)o->target_iso_head + 16 * 2048 + 1, "CDXX1", 5);
00397  return isoburn_activate_session(o->drive);
00398 }

int isoburn_link ( struct isoburn o,
struct isoburn link,
int  flag 
)

Definition at line 226 of file isoburn.c.

References isoburn::next, and isoburn::prev.

Referenced by isoburn_new().

00230 {
00231 
00232  /* >>> mutex */
00233 
00234  if(isoburn_list_start==NULL ||
00235     (isoburn_list_start==link && (flag&1)))
00236    isoburn_list_start= o;
00237  if(o->prev!=NULL)
00238    o->prev->next= o->next;
00239  if(o->next!=NULL)
00240    o->next->prev= o->prev;
00241  o->prev= o->next= NULL;
00242  if(link==NULL)
00243    return(1);
00244  if(flag&1) {
00245    o->next= link;
00246    o->prev= link->prev;
00247    if(o->prev!=NULL)
00248      o->prev->next= o;
00249    link->prev= o;
00250  } else {
00251    o->prev= link;
00252    o->next= link->next;
00253    if(o->next!=NULL)
00254      o->next->prev= o;
00255    link->next= o;
00256  }
00257 
00258  /* >>> end mutex */
00259 
00260  return(1);
00261 }

int isoburn_msgs_submit ( struct isoburn o,
int  error_code,
char  msg_text[],
int  os_errno,
char  severity[],
int  flag 
)

Definition at line 315 of file isoburn.c.

References libisoburn_default_msgs_submit, libisoburn_default_msgs_submit_flag, libisoburn_default_msgs_submit_handle, isoburn::msgs_submit, isoburn::msgs_submit_flag, and isoburn::msgs_submit_handle.

Referenced by ds_read_block(), isoburn_attach_image(), isoburn_disc_get_msc1(), isoburn_disc_write(), isoburn_emulate_toc(), isoburn_find_emulator(), isoburn_igopt_new(), isoburn_make_toc_entry(), isoburn_new(), isoburn_prepare_disc_aux(), isoburn_read_image(), isoburn_read_iso_head_parse(), isoburn_ropt_new(), isoburn_set_msc1(), isoburn_set_start_byte(), isoburn_start_emulation(), and isoburn_toc_entry_new().

00317 {
00318  int ret, use_drive_method= 0;
00319 
00320  if(o!=NULL)
00321    if(o->msgs_submit!=NULL)
00322      use_drive_method= 1;
00323  if(use_drive_method) {
00324    ret= o->msgs_submit(o->msgs_submit_handle, error_code, msg_text, os_errno,
00325                        severity, o->msgs_submit_flag);
00326    return(ret);
00327  }
00328  if(libisoburn_default_msgs_submit != NULL) {
00329    ret= libisoburn_default_msgs_submit(libisoburn_default_msgs_submit_handle,
00330                                      error_code, msg_text, os_errno, severity,
00331                                      libisoburn_default_msgs_submit_flag);
00332    return(ret);
00333  }
00334  /* Fallback: use message queue of libburn */
00335  burn_msgs_submit(error_code, msg_text, os_errno, severity, NULL);
00336  return(1);
00337 }

int isoburn_new ( struct isoburn **  objpt,
int  flag 
)

Definition at line 106 of file isoburn.c.

References isoburn::drive, isoburn::emulation_mode, isoburn::fabricated_disc_status, isoburn::fabricated_msc1, isoburn::fabricated_msc2, isoburn::image, isoburn::iso_data_source, isoburn::iso_source, isoburn_destroy(), isoburn_link(), isoburn_msgs_submit(), isoburn_report_iso_error(), Libisoburn_overwriteable_starT, Libisoburn_target_head_sizE, isoburn::min_start_byte, isoburn::msgs_submit, isoburn::msgs_submit_flag, isoburn::msgs_submit_handle, isoburn::next, isoburn::nwa, isoburn::prev, isoburn::read_pacifier, isoburn::read_pacifier_handle, isoburn::target_iso_head, isoburn::toc, isoburn::truncate, isoburn::wrote_well, and isoburn::zero_nwa.

Referenced by isoburn_welcome_media().

00107 {
00108  struct isoburn *o;
00109  int i, ret;
00110 
00111  *objpt= o= (struct isoburn *) malloc(sizeof(struct isoburn));
00112  if(o==NULL) {
00113    isoburn_msgs_submit(NULL, 0x00060000,
00114                        "Cannot allocate memory for isoburn control object",
00115                        0, "FATAL", 0);
00116    return(-1);
00117  }
00118 
00119  o->drive= NULL;
00120  o->emulation_mode= 0;
00121  o->fabricated_msc1= -1;
00122  o->fabricated_msc2= -1;
00123  o->zero_nwa= Libisoburn_overwriteable_starT;
00124  o->min_start_byte= o->zero_nwa * 2048;
00125  o->nwa= o->zero_nwa;
00126  o->truncate= 0;
00127  o->iso_source= NULL;
00128  o->fabricated_disc_status= BURN_DISC_UNREADY;
00129  o->toc= NULL;
00130  o->wrote_well= -1;
00131  for(i=0;i<Libisoburn_target_head_sizE;i++)
00132    o->target_iso_head[i]= 0;
00133  o->image= NULL;
00134  o->iso_data_source= NULL;
00135  o->read_pacifier= NULL;
00136  o->read_pacifier_handle= NULL;
00137  o->msgs_submit= NULL;
00138  o->msgs_submit_handle= NULL;
00139  o->msgs_submit_flag= 0;
00140  o->prev= NULL;
00141  o->next= NULL;
00142  ret= iso_image_new("ISOIMAGE", &o->image);
00143  if(ret<0) {
00144    isoburn_report_iso_error(ret, "Cannot create image", 0, "FATAL", 0);
00145    goto failed;
00146  }
00147  isoburn_link(o, isoburn_list_start, 1);
00148  return(1);
00149 failed:;
00150  isoburn_destroy(objpt, 0);
00151  return(-1);
00152 }

int isoburn_report_iso_error ( int  iso_error_code,
char  default_msg_text[],
int  os_errno,
char  min_severity[],
int  flag 
)

Definition at line 941 of file burn_wrap.c.

References isoburn__sev_to_text(), and isoburn__text_to_sev().

Referenced by isoburn_new(), isoburn_prepare_disc_aux(), and isoburn_read_image().

00943 {
00944  int error_code, iso_sev, min_sev, ret;
00945  char *sev_text_pt, *msg_text_pt= NULL;
00946 
00947  error_code= iso_error_get_code(iso_error_code);
00948  if(error_code < 0x00030000 || error_code >= 0x00040000)
00949    error_code= (error_code & 0xffff) | 0x00050000;
00950 
00951  if(iso_error_code<0)
00952    msg_text_pt= (char *) iso_error_to_msg(iso_error_code);
00953  if(msg_text_pt==NULL)
00954    msg_text_pt= msg_text;
00955  iso_sev= iso_error_get_severity(iso_error_code);
00956  sev_text_pt= min_severity;
00957  isoburn__text_to_sev(min_severity, &min_sev, 0);
00958  if(min_sev < iso_sev) 
00959    isoburn__sev_to_text(iso_sev, &sev_text_pt, 0);
00960  ret= iso_msgs_submit(error_code, msg_text_pt, os_errno, sev_text_pt, 0);
00961  return(ret);
00962 }

int isoburn_set_start_byte ( struct isoburn o,
off_t  value,
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 .

Parameters:
o The isoburn object to be programmed.
value The start address in bytes
flag unused yet
Returns:
<=0 is failure , >0 success

Definition at line 803 of file burn_wrap.c.

References isoburn::drive, isoburn_msgs_submit(), Libisoburn_nwa_alignemenT, isoburn::min_start_byte, and isoburn::nwa.

Referenced by isoburn_start_emulation().

00804 {
00805  int ret;
00806  struct burn_drive *drive = o->drive;
00807  struct burn_multi_caps *caps= NULL;
00808  
00809  ret= burn_disc_get_multi_caps(drive, BURN_WRITE_NONE, &caps, 0);
00810  if(ret<=0)
00811    goto ex;
00812  if(!caps->start_adr) {
00813    isoburn_msgs_submit(o, 0x00060000,
00814                        "Cannot set start byte address with this type of media",
00815                        0, "FAILURE", 0);
00816    {ret= 0; goto ex;}
00817  }
00818  o->min_start_byte= value;
00819  if(value % caps->start_alignment)
00820    value+= caps->start_alignment - (value % caps->start_alignment);
00821  o->nwa= value/2048;
00822  /* If suitable for media alignment, round up to Libisoburn_nwa_alignemenT */
00823  if((o->nwa % Libisoburn_nwa_alignemenT) &&
00824      ((Libisoburn_nwa_alignemenT*2048) % caps->start_alignment)==0 )
00825    o->nwa+= Libisoburn_nwa_alignemenT - (o->nwa % Libisoburn_nwa_alignemenT);
00826  ret= 1;
00827 ex:
00828  if(caps!=NULL)
00829    burn_disc_free_multi_caps(&caps);
00830  return(ret);
00831 }

int isoburn_start_emulation ( struct isoburn o,
int  flag 
)

Initialize the emulation of multi-session on random access media.

The need for emulation is confirmed already.

Parameters:
o A freshly created isoburn object. isoburn_create_data_source() was already called, nevertheless.
Returns:
<=0 error , 1 = success

Definition at line 313 of file isofs_wrap.c.

References isoburn::drive, isoburn::fabricated_disc_status, iso_read_lsb(), isoburn_msgs_submit(), isoburn_set_start_byte(), Libisoburn_target_head_sizE, isoburn::target_iso_head, and isoburn::zero_nwa.

Referenced by isoburn_welcome_media().

00314 {
00315  int ret, i;
00316  off_t data_count;
00317  struct burn_drive *drive;
00318  struct ecma119_pri_vol_desc *pvm;
00319  
00320  if(o==NULL) {
00321    isoburn_msgs_submit(NULL, 0x00060000,
00322                        "Program error: isoburn_start_emulation: o==NULL",
00323                        0, "FATAL", 0);
00324    return -1;
00325  }
00326 
00327  drive= o->drive;
00328 
00329  /* we can assume 0 as start block for image */
00330  /* TODO what about ms? where we validate valid iso image in ms disc? */
00331  ret = burn_read_data(drive, (off_t) 0, (char*)o->target_iso_head, 
00332                       (off_t) Libisoburn_target_head_sizE, &data_count, 2);
00333 
00334  /* an error means an empty disc */
00335  if (ret <= 0) {
00336    o->fabricated_disc_status= BURN_DISC_BLANK;
00337    return 1;
00338  }
00339 
00340  /* check first 64K. If 0's, the disc is treated as a blank disc, and thus
00341     overwritten without extra check. */
00342  i = Libisoburn_target_head_sizE;
00343  while (i && !o->target_iso_head[i-1]) 
00344    --i;
00345 
00346  if (!i) {
00347    o->fabricated_disc_status= BURN_DISC_BLANK;
00348    return 1;
00349  }
00350 
00351  pvm = (struct ecma119_pri_vol_desc *)(o->target_iso_head + 16 * 2048);
00352 
00353  if (!strncmp((char*)pvm->std_identifier, "CD001", 5)) {
00354    off_t size;
00355 
00356    /* sanity check */
00357    if (pvm->vol_desc_type[0] != 1 || pvm->vol_desc_version[0] != 1 
00358        || pvm->file_structure_version[0] != 1 ) {
00359      /* TODO for now I treat this as a full disc */
00360      o->fabricated_disc_status= BURN_DISC_FULL;
00361      return 1;
00362    }
00363 
00364    /* ok, PVM found, set size */
00365    size = (off_t) iso_read_lsb(pvm->vol_space_size, 4);
00366    size *= (off_t) 2048; /* block size in bytes */
00367    isoburn_set_start_byte(o, size, 0);
00368    o->fabricated_disc_status= BURN_DISC_APPENDABLE;
00369  } else if (!strncmp((char*)pvm->std_identifier, "CDXX1", 5)) {
00370 
00371    /* empty image */
00372    isoburn_set_start_byte(o, o->zero_nwa * 2048, 0);
00373    o->fabricated_disc_status= BURN_DISC_BLANK;
00374  } else {
00375    /* treat any disc in an unknown format as full */
00376    o->fabricated_disc_status= BURN_DISC_FULL;
00377  }
00378  return 1;
00379 }

int isoburn_toc_entry_destroy ( struct isoburn_toc_entry **  o,
int  flag 
)

Definition at line 82 of file isoburn.c.

References isoburn_toc_entry_destroy().

Referenced by isoburn_destroy(), isoburn_emulate_toc(), and isoburn_toc_entry_destroy().

00083 {
00084  if(*o==NULL)
00085    return(0);
00086  if(flag&1)
00087    isoburn_toc_entry_destroy(&((*o)->next), flag);
00088  free((char *) (*o));   
00089  *o= NULL;
00090  return(1);
00091 }

int isoburn_toc_entry_new ( struct isoburn_toc_entry **  objpt,
struct isoburn_toc_entry boss,
int  flag 
)

Definition at line 54 of file isoburn.c.

References isoburn_msgs_submit(), isoburn_toc_entry::next, isoburn_toc_entry::session, isoburn_toc_entry::start_lba, isoburn_toc_entry::track_blocks, and isoburn_toc_entry::track_no.

Referenced by isoburn_make_toc_entry().

00056 {
00057  struct isoburn_toc_entry *o, *s;
00058 
00059  *objpt= o= (struct isoburn_toc_entry *)
00060             malloc(sizeof(struct isoburn_toc_entry));
00061  if(o==NULL) {
00062    isoburn_msgs_submit(NULL, 0x00060000,
00063                        "Cannot allocate memory for isoburn toc entry",
00064                        0, "FATAL", 0);
00065    return(-1);
00066  }
00067  o->session= 0;
00068  o->track_no= 0;
00069  o->start_lba= -1;
00070  o->track_blocks= 0;
00071  o->next= NULL;
00072  if(boss!=NULL) {
00073    for(s= boss; s->next!=NULL; s= s->next);
00074    s->next= o;
00075  }
00076  return(1);
00077 }


Generated on Fri May 1 12:03:18 2009 for libisoburn by  doxygen 1.5.8