libisoburn-0.4.8.pl00/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 496 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 526 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 503 of file isoburn.h.

#define Libisoburn_toc_scan_max_gaP   65536

Definition at line 510 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 280 of file isoburn.c.

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

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

int isoburn_count ( struct isoburn o,
int  flag 
)

Definition at line 267 of file isoburn.c.

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

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

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 158 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().

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

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

Definition at line 191 of file isoburn.c.

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

Referenced by isoburn_finish(), and isoburn_initialize().

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

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

Definition at line 304 of file isoburn.c.

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

Referenced by isoburn_find_emulator().

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

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 508 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().

00510 {
00511  int ret;
00512 
00513  ret= isoburn_find_by_drive(pt, drive, 0);
00514  if(ret<=0)
00515    return(0);
00516  if((*pt)->emulation_mode==-1) {
00517    isoburn_msgs_submit(*pt, 0x00060000,
00518                     "Unsuitable drive and media state", 0, "FAILURE", 0);
00519    return(-1);
00520  }
00521  if((*pt)->emulation_mode==0)
00522    return(0);
00523  return(1);
00524 } 

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 694 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().

00696 {
00697  int ret, lba, nwa;
00698 
00699  if(o->fabricated_msc2>=0)
00700    *msc2= o->fabricated_msc2;
00701  else {
00702    ret= isoburn_disc_track_lba_nwa(o->drive, opts, 0, &lba, &nwa);
00703    if(ret<=0)
00704      return(ret);
00705    *msc2= nwa;
00706  }
00707  return(1);
00708 }

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

Definition at line 222 of file isoburn.c.

References isoburn::next.

00223 {
00224  *pt= o->next;
00225  return(1);
00226 }

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

Definition at line 215 of file isoburn.c.

References isoburn::prev.

00216 {
00217  *pt= o->prev;
00218  return(1);
00219 }

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 404 of file isofs_wrap.c.

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

Referenced by isoburn_disc_erase().

00405 {
00406  /* 
00407   * replace CD001 with CDXX1 in PVM.
00408   * I think this is enought for invalidating an iso image
00409   */
00410  strncpy((char*)o->target_iso_head + 16 * 2048 + 1, "CDXX1", 5);
00411  return isoburn_activate_session(o->drive);
00412 }

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

Definition at line 229 of file isoburn.c.

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

Referenced by isoburn_new().

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

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

Definition at line 318 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(), isoburn_toc_entry_new(), and isoburn_welcome_media().

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

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

Definition at line 109 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().

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

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

Definition at line 985 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().

00987 {
00988  int error_code, iso_sev, min_sev, ret;
00989  char *sev_text_pt, *msg_text_pt= NULL;
00990 
00991  error_code= iso_error_get_code(iso_error_code);
00992  if(error_code < 0x00030000 || error_code >= 0x00040000)
00993    error_code= (error_code & 0xffff) | 0x00050000;
00994 
00995  if(iso_error_code<0)
00996    msg_text_pt= (char *) iso_error_to_msg(iso_error_code);
00997  if(msg_text_pt==NULL)
00998    msg_text_pt= msg_text;
00999  iso_sev= iso_error_get_severity(iso_error_code);
01000  sev_text_pt= min_severity;
01001  isoburn__text_to_sev(min_severity, &min_sev, 0);
01002  if(min_sev < iso_sev) 
01003    isoburn__sev_to_text(iso_sev, &sev_text_pt, 0);
01004  ret= iso_msgs_submit(error_code, msg_text_pt, os_errno, sev_text_pt, 0);
01005  return(ret);
01006 }

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 847 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().

00848 {
00849  int ret;
00850  struct burn_drive *drive = o->drive;
00851  struct burn_multi_caps *caps= NULL;
00852  
00853  ret= burn_disc_get_multi_caps(drive, BURN_WRITE_NONE, &caps, 0);
00854  if(ret<=0)
00855    goto ex;
00856  if(!caps->start_adr) {
00857    isoburn_msgs_submit(o, 0x00060000,
00858                        "Cannot set start byte address with this type of media",
00859                        0, "FAILURE", 0);
00860    {ret= 0; goto ex;}
00861  }
00862  o->min_start_byte= value;
00863  if(value % caps->start_alignment)
00864    value+= caps->start_alignment - (value % caps->start_alignment);
00865  o->nwa= value/2048;
00866  /* If suitable for media alignment, round up to Libisoburn_nwa_alignemenT */
00867  if((o->nwa % Libisoburn_nwa_alignemenT) &&
00868      ((Libisoburn_nwa_alignemenT*2048) % caps->start_alignment)==0 )
00869    o->nwa+= Libisoburn_nwa_alignemenT - (o->nwa % Libisoburn_nwa_alignemenT);
00870  ret= 1;
00871 ex:
00872  if(caps!=NULL)
00873    burn_disc_free_multi_caps(&caps);
00874  return(ret);
00875 }

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 308 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().

00309 {
00310  int ret, i, capacity = -1, role;
00311  off_t data_count, to_read;
00312  struct burn_drive *drive;
00313  struct ecma119_pri_vol_desc *pvm;
00314  
00315  if(o==NULL) {
00316    isoburn_msgs_submit(NULL, 0x00060000,
00317                        "Program error: isoburn_start_emulation: o==NULL",
00318                        0, "FATAL", 0);
00319    return -1;
00320  }
00321 
00322  drive= o->drive;
00323 
00324  /* We can assume 0 as start block for image.
00325     The data there point to the most recent session.
00326  */
00327  role = burn_drive_get_drive_role(drive);
00328  ret = burn_get_read_capacity(drive, &capacity, 0);
00329  if (ret <= 0)
00330    capacity = -1;
00331  if (capacity > 0 || role == 2) {
00332    /* Might be a block device on a system where libburn cannot determine its
00333       size.  Try to read anyway. */
00334    memset(o->target_iso_head, 0, Libisoburn_target_head_sizE);
00335    to_read = Libisoburn_target_head_sizE;
00336    if(capacity > 0 && (off_t) capacity * (off_t) 2048 < to_read)
00337      to_read = (off_t) capacity * (off_t) 2048;
00338    ret = burn_read_data(drive, (off_t) 0, (char*)o->target_iso_head, 
00339                         to_read, &data_count, 2);
00340    if (ret <= 0) {
00341      /* an error means a disc with no ISO image */
00342      if (capacity > 0)
00343        o->fabricated_disc_status= BURN_DISC_FULL;
00344      else
00345         o->fabricated_disc_status= BURN_DISC_BLANK;
00346      return 1;
00347    }
00348  } else {
00349    /* No read capacity means blank media */
00350    o->fabricated_disc_status= BURN_DISC_BLANK;
00351    return 1;
00352  }
00353 
00354  /* check first 64K. If 0's, the disc is treated as a blank disc, and thus
00355     overwritten without extra check. */
00356  i = Libisoburn_target_head_sizE;
00357  while (i && !o->target_iso_head[i-1]) 
00358    --i;
00359 
00360  if (!i) {
00361    o->fabricated_disc_status= BURN_DISC_BLANK;
00362    return 1;
00363  }
00364 
00365  pvm = (struct ecma119_pri_vol_desc *)(o->target_iso_head + 16 * 2048);
00366 
00367  if (!strncmp((char*)pvm->std_identifier, "CD001", 5)) {
00368    off_t size;
00369 
00370    /* sanity check */
00371    if (pvm->vol_desc_type[0] != 1 || pvm->vol_desc_version[0] != 1 
00372        || pvm->file_structure_version[0] != 1 ) {
00373      /* TODO for now I treat this as a full disc */
00374      o->fabricated_disc_status= BURN_DISC_FULL;
00375      return 1;
00376    }
00377 
00378    /* ok, PVM found, set size */
00379    size = (off_t) iso_read_lsb(pvm->vol_space_size, 4);
00380    size *= (off_t) 2048; /* block size in bytes */
00381    isoburn_set_start_byte(o, size, 0);
00382    o->fabricated_disc_status= BURN_DISC_APPENDABLE;
00383  } else if (!strncmp((char*)pvm->std_identifier, "CDXX1", 5)) {
00384 
00385    /* empty image */
00386    isoburn_set_start_byte(o, o->zero_nwa * 2048, 0);
00387    o->fabricated_disc_status= BURN_DISC_BLANK;
00388  } else {
00389    /* treat any disc in an unknown format as full */
00390    o->fabricated_disc_status= BURN_DISC_FULL;
00391  }
00392  return 1;
00393 }

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

Definition at line 83 of file isoburn.c.

References isoburn_toc_entry_destroy().

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

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

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, isoburn_toc_entry::track_no, and isoburn_toc_entry::volid.

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->volid= NULL;
00072  o->next= NULL;
00073  if(boss!=NULL) {
00074    for(s= boss; s->next!=NULL; s= s->next);
00075    s->next= o;
00076  }
00077  return(1);
00078 }


Generated by  doxygen 1.6.2