libisoburn  1.5.4
About: libisoburn is a frontend for the libraries libburn and libisofs which enables creation and expansion of ISO-9660 filesystems on all media and file types supported by libburn. It implements the API and command interpreter of program xorriso, and installs this program as small dynamically linked binary. xorriso is suitable for incremental data backup and for production of bootable ISO 9660 images. A statically linked version is available as GNU xorriso.
  Fossies Dox: libisoburn-1.5.4.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

isoburn.h File Reference
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
 

Macros

#define Libisoburn_target_head_sizE   (32*2048)
 
#define Libisoburn_max_appended_partitionS   8
 
#define Libisoburn_disc_label_sizE   129
 
#define Libisoburn_default_cache_tileS   32
 Default settings for above cache_tiles, tile_blocks in newly created struct isoburn_read_opts. More...
 
#define Libisoburn_default_tile_blockS   32
 
#define Libisoburn_cache_max_sizE   (1024 * 512)
 Maximum size of the cache in 2 kB blocks (1 GB) More...
 
#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. More...
 
int isoburn_invalidate_iso (struct isoburn *o, int flag)
 Alters and writes the first 64 kB of a "medium" to invalidate an ISO image. More...
 
int isoburn_find_emulator (struct isoburn **pt, struct burn_drive *drive, int flag)
 Get an eventual isoburn object which is wrapped around the drive. More...
 
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. More...
 
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. More...
 
IsoDataSource * isoburn_data_source_new (struct burn_drive *d, uint32_t displacement, int displacement_sign, int cache_tiles, int tile_blocks)
 Get a data source suitable for read from a drive using burn_read_data() function. More...
 
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(). More...
 
int isoburn_adjust_target_iso_head (struct isoburn *o, uint32_t offst, int flag)
 Check whether the size of target_iso_head matches the given partition offset. More...
 
int isoburn_root_defaults (IsoImage *image, int flag)
 Initialize the root directory attributes of a freshly created image. More...
 

Macro Definition Documentation

◆ Libisoburn_cache_max_sizE

#define Libisoburn_cache_max_sizE   (1024 * 512)

Maximum size of the cache in 2 kB blocks (1 GB)

Definition at line 283 of file isoburn.h.

◆ Libisoburn_default_cache_tileS

#define Libisoburn_default_cache_tileS   32

Default settings for above cache_tiles, tile_blocks in newly created struct isoburn_read_opts.

Definition at line 278 of file isoburn.h.

◆ Libisoburn_default_tile_blockS

#define Libisoburn_default_tile_blockS   32

Definition at line 279 of file isoburn.h.

◆ Libisoburn_disc_label_sizE

#define Libisoburn_disc_label_sizE   129

Definition at line 62 of file isoburn.h.

◆ Libisoburn_max_appended_partitionS

#define Libisoburn_max_appended_partitionS   8

Definition at line 57 of file isoburn.h.

◆ Libisoburn_nwa_alignemenT

#define Libisoburn_nwa_alignemenT   32

Definition at line 778 of file isoburn.h.

◆ Libisoburn_overwriteable_starT

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

Definition at line 811 of file isoburn.h.

◆ Libisoburn_target_head_sizE

#define Libisoburn_target_head_sizE   (32*2048)

Definition at line 51 of file isoburn.h.

◆ Libisoburn_toc_scan_alignemenT

#define Libisoburn_toc_scan_alignemenT   16

Definition at line 785 of file isoburn.h.

◆ Libisoburn_toc_scan_max_gaP

#define Libisoburn_toc_scan_max_gaP   65536

Definition at line 792 of file isoburn.h.

Function Documentation

◆ isoburn_adjust_target_iso_head()

int isoburn_adjust_target_iso_head ( struct isoburn o,
uint32_t  offst,
int  flag 
)

Check whether the size of target_iso_head matches the given partition offset.

Eventually adjust size.

Definition at line 368 of file isoburn.c.

370 {
371  uint8_t *new_buf;
372  uint32_t new_size;
373 
374  if((uint32_t) o->target_iso_head_size ==
375  Libisoburn_target_head_sizE + 2048 * offst)
376  return(1);
377  new_size= Libisoburn_target_head_sizE + 2048 * offst;
378  new_buf= calloc(1, new_size);
379  if(new_buf == NULL) {
380  isoburn_msgs_submit(o, 0x00060000,
381  "Cannot re-allocate overwrite buffer", 0, "FATAL", 0);
382  return(-1);
383  }
384  memcpy(new_buf, o->target_iso_head,
385  (uint32_t) o->target_iso_head_size < new_size ?
386  (uint32_t) o->target_iso_head_size : new_size);
387  free(o->target_iso_head);
388  o->target_iso_head= new_buf;
389  o->target_iso_head_size= new_size;
390  if(o->nwa == o->zero_nwa)
393  return(1);
394 }
int isoburn_msgs_submit(struct isoburn *o, int error_code, char msg_text[], int os_errno, char severity[], int flag)
Definition: isoburn.c:340
#define Libisoburn_overwriteable_starT
Definition: isoburn.h:811
#define Libisoburn_target_head_sizE
Definition: isoburn.h:51
int nwa
Definition: isoburn.h:104
uint8_t * target_iso_head
Definition: isoburn.h:134
int zero_nwa
Definition: isoburn.h:98
int target_iso_head_size
Definition: isoburn.h:133

References isoburn_msgs_submit(), Libisoburn_overwriteable_starT, Libisoburn_target_head_sizE, isoburn::nwa, isoburn::target_iso_head, isoburn::target_iso_head_size, and isoburn::zero_nwa.

Referenced by isoburn_inspect_partition(), and isoburn_make_iso_write_opts().

◆ isoburn_by_idx()

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

Definition at line 302 of file isoburn.c.

305 {
306  int i,abs_idx;
307  struct isoburn *npt;
308 
309  if(flag&2)
310  for(;o->prev!=NULL;o= o->prev);
311  abs_idx= (idx>0?idx:-idx);
312  *pt= o;
313  for(i= 0;(i<abs_idx || (flag&1)) && *pt!=NULL;i++) {
314  if(idx>0)
315  npt= o->next;
316  else
317  npt= o->prev;
318  if(npt==NULL && (flag&1))
319  break;
320  *pt= npt;
321  }
322  return(*pt!=NULL);
323 }
struct isoburn * prev
Definition: isoburn.h:79
struct isoburn * next
Definition: isoburn.h:80

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

◆ isoburn_count()

int isoburn_count ( struct isoburn o,
int  flag 
)

Definition at line 289 of file isoburn.c.

291 {
292  int counter= 0;
293 
294  if(flag&2)
295  for(;o->prev!=NULL;o= o->prev);
296  for(;o!=NULL;o= o->next)
297  counter++;
298  return(counter);
299 }

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

◆ isoburn_data_source_new()

IsoDataSource* isoburn_data_source_new ( struct burn_drive *  d,
uint32_t  displacement,
int  displacement_sign,
int  cache_tiles,
int  tile_blocks 
)

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

Parameters
ddrive to read from. Must be grabbed.
displacementwill be added or subtracted to any block address
displacement_sign+1 = add , -1= subtract , else keep unaltered
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 325 of file data_source.c.

328 {
329  IsoDataSource *src;
330  struct isoburn_cached_drive *icd= NULL;
331  int ret;
332 
333  if (d==NULL)
334  return NULL;
335  src = malloc(sizeof(IsoDataSource));
336  if (src == NULL)
337  return NULL;
338  ret = isoburn_cached_drive_new(&icd, d, cache_tiles, tile_blocks, 0);
339  if (ret <= 0) {
340  free(src);
341  return NULL;
342  }
343  src->version = 0;
344  src->refcount = 1;
345  src->read_block = ds_read_block;
346  src->open = ds_open;
347  src->close = ds_close;
348  src->free_data = ds_free_data;
349  src->data = icd;
350  icd->displacement = displacement;
352  return src;
353 }
static int ds_close(IsoDataSource *src)
Definition: data_source.c:202
static int ds_open(IsoDataSource *src)
Definition: data_source.c:196
static void ds_free_data(IsoDataSource *src)
Definition: data_source.c:301
static int isoburn_cached_drive_new(struct isoburn_cached_drive **o, struct burn_drive *d, int cache_tiles, int tile_blocks, int flag)
Definition: data_source.c:268
int ds_read_block(IsoDataSource *src, uint32_t lba, uint8_t *buffer)
Definition: data_source.c:80
uint32_t displacement
Offset to be applied to all block addresses to compensate for an eventual displacement of the block a...
Definition: data_source.c:70

References isoburn_cached_drive::displacement, isoburn_cached_drive::displacement_sign, ds_close(), ds_free_data(), ds_open(), ds_read_block(), isoburn_cached_drive_new(), and isoburn_cached_drive::tile_blocks.

Referenced by isoburn_read_image().

◆ isoburn_data_source_shutdown()

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
srcThe data source to be disabled
flagunused yet
Returns
<=0 is failure , >0 success

Definition at line 313 of file data_source.c.

314 {
315  struct isoburn_cached_drive *icd;
316 
317  if(src==NULL)
318  return(0);
319  icd= (struct isoburn_cached_drive *) src->data;
320  icd->drive= NULL;
321  return(1);
322 }
struct burn_drive * drive
Definition: data_source.c:54

References isoburn_cached_drive::drive.

Referenced by isoburn_prepare_disc_aux().

◆ isoburn_destroy()

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

Definition at line 178 of file isoburn.c.

179 {
180  struct isoburn *o;
181 
182  o= *objpt;
183  if(o==NULL)
184  return(0);
185 
186  /* >>> mutex */
187 
188  if(o==isoburn_list_start)
190  if(o->prev!=NULL)
191  o->prev->next= o->next;
192  if(o->next!=NULL)
193  o->next->prev= o->prev;
194 
195  /* >>> end mutex */
196 
197  if(o->image!=NULL)
198  iso_image_unref(o->image);
199  if(o->toc!=NULL)
200  isoburn_toc_entry_destroy(&(o->toc), 1); /* all */
201  if(o->iso_source!=NULL)
202  burn_source_free(o->iso_source);
203  if(o->iso_data_source!=NULL)
204  iso_data_source_unref(o->iso_data_source);
205  if(o->target_iso_head != NULL)
206  free(o->target_iso_head);
207  free((char *) o);
208  *objpt= NULL;
209  return(1);
210 }
int isoburn_toc_entry_destroy(struct isoburn_toc_entry **o, int flag)
Definition: isoburn.c:89
struct isoburn * isoburn_list_start
Definition: isoburn.c:112
struct isoburn_toc_entry * toc
Definition: isoburn.h:123
struct burn_source * iso_source
Definition: isoburn.h:154
IsoDataSource * iso_data_source
Definition: isoburn.h:149
IsoImage * image
Definition: isoburn.h:142

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

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

◆ isoburn_destroy_all()

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

Definition at line 213 of file isoburn.c.

214 {
215  struct isoburn *o,*n;
216 
217  o= *objpt;
218  if(o==NULL)
219  return(0);
220  for(;o->prev!=NULL;o= o->prev);
221  for(;o!=NULL;o= n) {
222  n= o->next;
223  isoburn_destroy(&o,0);
224  }
225  *objpt= NULL;
226  return(1);
227 }
int isoburn_destroy(struct isoburn **objpt, int flag)
Definition: isoburn.c:178

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

Referenced by isoburn_finish(), and isoburn_initialize().

◆ isoburn_find_by_drive()

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

Definition at line 326 of file isoburn.c.

327 {
328  struct isoburn *o;
329 
330  *pt= NULL;
331  for(o= isoburn_list_start;o!=NULL;o= o->next)
332  if(o->drive==d) {
333  *pt= o;
334  return(1);
335  }
336  return(0);
337 }
struct burn_drive * drive
Definition: isoburn.h:70

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

Referenced by isoburn_disc_get_status().

◆ isoburn_find_emulator()

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
ptEventually 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.
driveThe drive to be searched for
flagunused yet
Returns
-1 unsuitable medium, 0 generic medium, 1 emulated medium.

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

Returns
-1 unsuitable medium, 0 generic medium, 1 emulated medium.

Definition at line 627 of file burn_wrap.c.

629 {
630  int ret;
631 
632  ret= isoburn_find_by_drive(pt, drive, 0);
633  if(ret<=0)
634  return(0);
635  if((*pt)->emulation_mode==-1) {
636  isoburn_msgs_submit(*pt, 0x00060000,
637  "Unsuitable drive and medium state", 0, "FAILURE", 0);
638  return(-1);
639  }
640  if((*pt)->emulation_mode==0)
641  return(0);
642  return(1);
643 }
int isoburn_find_by_drive(struct isoburn **pt, struct burn_drive *d, int flag)
Definition: isoburn.c:326

Referenced by isoburn_activate_session(), isoburn_attach_image(), isoburn_attach_start_lba(), isoburn_cancel_prepared_write(), isoburn_disc_available_space(), isoburn_disc_erasable(), isoburn_disc_erase(), isoburn_disc_get_msc1(), isoburn_disc_pretend_full_uncond(), 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_attached_start_lba(), isoburn_get_fifo_status(), isoburn_get_img_partition_offset(), isoburn_get_min_start_byte(), isoburn_get_mount_params(), isoburn_needs_emulation(), isoburn_prepare_blind_grow(), isoburn_prepare_disc_aux(), isoburn_read_image(), isoburn_read_iso_head(), isoburn_set_msc1(), isoburn_set_read_pacifier(), isoburn_set_truncate(), isoburn_toc_drive_get_disc(), and isoburn_welcome_media().

◆ isoburn_get_emulation_mode()

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

◆ isoburn_get_msc2()

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
oThe isoburn object to be inquired
optsIf not NULL: write parameters to be set on drive before query
msc2The value to be used with iso_write_opts_set_ms_block()
flagunused yet
Returns
<=0 is failure , >0 success

Definition at line 865 of file burn_wrap.c.

867 {
868  int ret, lba, nwa;
869 
870  if(o->fabricated_msc2>=0)
871  *msc2= o->fabricated_msc2;
872  else {
873  ret= isoburn_disc_track_lba_nwa(o->drive, opts, 0, &lba, &nwa);
874  if(ret<=0)
875  return(ret);
876  *msc2= nwa;
877  }
878  return(1);
879 }
int isoburn_disc_track_lba_nwa(struct burn_drive *d, struct burn_write_opts *opts, int trackno, int *lba, int *nwa)
Use this with trackno==0 to obtain the predicted start block number of the new session.
Definition: burn_wrap.c:831
int fabricated_msc2
Definition: isoburn.h:92

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

Referenced by isoburn_make_iso_write_opts().

◆ isoburn_get_next()

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

Definition at line 244 of file isoburn.c.

245 {
246  *pt= o->next;
247  return(1);
248 }

References isoburn::next.

◆ isoburn_get_prev()

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

Definition at line 237 of file isoburn.c.

238 {
239  *pt= o->prev;
240  return(1);
241 }

References isoburn::prev.

◆ isoburn_get_target_volset()

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

◆ isoburn_invalidate_iso()

int isoburn_invalidate_iso ( struct isoburn o,
int  flag 
)

Alters and writes the first 64 kB of a "medium" to invalidate an ISO image.

(It shall stay restorable by skilled humans, though). The result shall especially keep libisoburn from accepting the medium image as ISO filesystem.

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

Definition at line 673 of file isofs_wrap.c.

674 {
675  int end_ed_found= 0, i;
676  char *head;
677 
678  head= (char *) o->target_iso_head;
679  /*
680  * replace CD001 with CDXX1 in PVM.
681  */
682  memcpy(head + 16 * 2048 + 1, "CDXX1", 5);
683 
684  /* Invalidate further ECMA-119 volume descriptors and possible UDF volume
685  recognition sequence */
686  for(i= 17 * 2048; i < 32 * 2048; i+= 2048) {
687  if(end_ed_found) {
688  if(head[i] == 0 && strncmp(head + i + 1, "BEA01", 5) == 0)
689  memcpy(head + i + 1, "BEAX1", 5);
690  else if(head[i] == 0 && strncmp(head + i + 1, "NSR", 3) == 0)
691  memcpy(head + i + 1, "NSRX", 4);
692  else if(head[i] == 0 && strncmp(head + i + 1, "TEA", 3) == 0)
693  memcpy(head + i + 1, "TEAX", 4);
694  } else if(strncmp(head + i + 1, "CD001", 5) == 0) {
695  if(((unsigned char *) head)[i] == 0xff)
696  end_ed_found= 1;
697  memcpy(head + i + 3, "XX", 2);
698  }
699  }
700 
701  return isoburn_activate_session(o->drive);
702 }
int isoburn_activate_session(struct burn_drive *drive)
Call this after isoburn_disc_write has finished and burn_drive_wrote_well() indicates success.
Definition: isofs_wrap.c:393

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

Referenced by isoburn_disc_erase().

◆ isoburn_link()

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

Definition at line 251 of file isoburn.c.

255 {
256 
257  /* >>> mutex */
258 
259  if(isoburn_list_start==NULL ||
260  (isoburn_list_start==link && (flag&1)))
262  if(o->prev!=NULL)
263  o->prev->next= o->next;
264  if(o->next!=NULL)
265  o->next->prev= o->prev;
266  o->prev= o->next= NULL;
267  if(link==NULL)
268  return(1);
269  if(flag&1) {
270  o->next= link;
271  o->prev= link->prev;
272  if(o->prev!=NULL)
273  o->prev->next= o;
274  link->prev= o;
275  } else {
276  o->prev= link;
277  o->next= link->next;
278  if(o->next!=NULL)
279  o->next->prev= o;
280  link->next= o;
281  }
282 
283  /* >>> end mutex */
284 
285  return(1);
286 }

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

Referenced by isoburn_new().

◆ isoburn_msgs_submit()

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

Definition at line 340 of file isoburn.c.

342 {
343  int ret, use_drive_method= 0;
344 
345  if(o!=NULL)
346  if(o->msgs_submit!=NULL)
347  use_drive_method= 1;
348  if(use_drive_method) {
349  ret= o->msgs_submit(o->msgs_submit_handle, error_code, msg_text, os_errno,
350  severity, o->msgs_submit_flag);
351  return(ret);
352  }
353  if(libisoburn_default_msgs_submit != NULL) {
355  error_code, msg_text, os_errno, severity,
357  return(ret);
358  }
359  /* Fallback: use message queue of libburn */
360  burn_msgs_submit(error_code, msg_text, os_errno, severity, NULL);
361  return(1);
362 }
int(* libisoburn_default_msgs_submit)(void *handle, int error_code, char msg_text[], int os_errno, char severity[], int flag)
Definition: isoburn.c:51
int libisoburn_default_msgs_submit_flag
Definition: isoburn.c:54
void * libisoburn_default_msgs_submit_handle
Definition: isoburn.c:53
int(* msgs_submit)(void *handle, int error_code, char msg_text[], int os_errno, char severity[], int flag)
Definition: isoburn.h:163
int msgs_submit_flag
Definition: isoburn.h:166
void * msgs_submit_handle
Definition: isoburn.h:165

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_adjust_target_iso_head(), isoburn_attach_image(), isoburn_disc_get_msc1(), isoburn_disc_get_status(), isoburn_disc_write(), isoburn_emulate_toc(), isoburn_igopt_new(), isoburn_igopt_set_gpt_guid(), isoburn_igopt_set_hfsp_block_size(), isoburn_igopt_set_part_flag(), isoburn_igopt_set_part_type_guid(), isoburn_igopt_set_partition_img(), isoburn_igopt_set_rr_reloc(), isoburn_igopt_set_untranslated_name_len(), isoburn_inspect_partition(), isoburn_make_iso_write_opts(), isoburn_make_toc_entry(), isoburn_new(), isoburn_prepare_disc_aux(), isoburn_read_image(), isoburn_read_iso_head_parse(), isoburn_ropt_new(), isoburn_ropt_set_data_cache(), isoburn_set_msc1(), isoburn_set_start_byte(), isoburn_set_truncate(), isoburn_start_emulation(), isoburn_toc_entry_new(), and isoburn_welcome_media().

◆ isoburn_new()

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

Definition at line 115 of file isoburn.c.

116 {
117  struct isoburn *o;
118  int ret;
119 
120  *objpt= o= (struct isoburn *) malloc(sizeof(struct isoburn));
121  if(o==NULL) {
122  isoburn_msgs_submit(NULL, 0x00060000,
123  "Cannot allocate memory for isoburn control object",
124  0, "FATAL", 0);
125  return(-1);
126  }
127 
128  o->drive= NULL;
129  o->emulation_mode= 0;
130  o->fabricated_msc1= -1;
131  o->fabricated_msc2= -1;
133  o->min_start_byte= o->zero_nwa * 2048;
134  o->nwa= o->zero_nwa;
135  o->truncate= 0;
136  o->iso_source= NULL;
137  o->fabricated_disc_status= BURN_DISC_UNREADY;
138  o->media_read_error= 0;
139  o->toc= NULL;
140  o->wrote_well= -1;
143  o->target_iso_head= NULL;
144  o->image= NULL;
145  o->image_start_lba= -1;
146  o->iso_data_source= NULL;
147  o->read_pacifier= NULL;
148  o->read_pacifier_handle= NULL;
149  o->msgs_submit= NULL;
150  o->msgs_submit_handle= NULL;
151  o->msgs_submit_flag= 0;
152  o->do_tao= 0;
153  o->do_fsync= 1;
154  o->prev= NULL;
155  o->next= NULL;
156  o->target_iso_head= calloc(1, o->target_iso_head_size);
157  if(o->target_iso_head == NULL) {
158  isoburn_report_iso_error(ISO_OUT_OF_MEM, "Cannot allocate overwrite buffer",
159  0, "FATAL", 0);
160  goto failed;
161  }
162  ret= iso_image_new("ISOIMAGE", &o->image);
163  if(ret<0) {
164  isoburn_report_iso_error(ret, "Cannot create image object", 0, "FATAL", 0);
165  goto failed;
166  }
167  ret= isoburn_root_defaults(o->image, 0);
168  if(ret <= 0)
169  goto failed;
171  return(1);
172 failed:;
173  isoburn_destroy(objpt, 0);
174  return(-1);
175 }
int isoburn_report_iso_error(int iso_error_code, char msg_text[], int os_errno, char min_severity[], int flag)
Definition: burn_wrap.c:1221
int isoburn_link(struct isoburn *o, struct isoburn *link, int flag)
Definition: isoburn.c:251
int isoburn_root_defaults(IsoImage *image, int flag)
Initialize the root directory attributes of a freshly created image.
Definition: isofs_wrap.c:129
void * read_pacifier_handle
Definition: isoburn.h:160
int do_fsync
Definition: isoburn.h:172
int image_start_lba
Definition: isoburn.h:145
off_t min_start_byte
Definition: isoburn.h:101
int wrote_well
Definition: isoburn.h:129
int truncate
Definition: isoburn.h:108
int(* read_pacifier)(IsoImage *, IsoFileSource *)
Definition: isoburn.h:157
int do_tao
Definition: isoburn.h:169
int emulation_mode
Definition: isoburn.h:75
uint32_t loaded_partition_offset
Definition: isoburn.h:138
int fabricated_msc1
Definition: isoburn.h:85
enum burn_disc_status fabricated_disc_status
Definition: isoburn.h:114
int media_read_error
Definition: isoburn.h:118

References isoburn::do_fsync, isoburn::do_tao, isoburn::drive, isoburn::emulation_mode, isoburn::fabricated_disc_status, isoburn::fabricated_msc1, isoburn::fabricated_msc2, isoburn::image, isoburn::image_start_lba, isoburn::iso_data_source, isoburn::iso_source, isoburn_destroy(), isoburn_link(), isoburn_list_start, isoburn_msgs_submit(), isoburn_report_iso_error(), isoburn_root_defaults(), Libisoburn_overwriteable_starT, Libisoburn_target_head_sizE, isoburn::loaded_partition_offset, isoburn::media_read_error, 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::target_iso_head_size, isoburn::toc, isoburn::truncate, isoburn::wrote_well, and isoburn::zero_nwa.

Referenced by isoburn_welcome_media().

◆ isoburn_report_iso_error()

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

Definition at line 1221 of file burn_wrap.c.

1223 {
1224  int error_code, iso_sev, min_sev, ret;
1225  char *sev_text_pt, *msg_text_pt= NULL;
1226 
1227  error_code= iso_error_get_code(iso_error_code);
1228  if(error_code < 0x00030000 || error_code >= 0x00040000)
1229  error_code= (error_code & 0xffff) | 0x00050000;
1230 
1231  if(iso_error_code<0)
1232  msg_text_pt= (char *) iso_error_to_msg(iso_error_code);
1233  if(msg_text_pt==NULL)
1234  msg_text_pt= msg_text;
1235  iso_sev= iso_error_get_severity(iso_error_code);
1236  sev_text_pt= min_severity;
1237  isoburn__text_to_sev(min_severity, &min_sev, 0);
1238  if(min_sev < iso_sev)
1239  isoburn__sev_to_text(iso_sev, &sev_text_pt, 0);
1240  ret= iso_msgs_submit(error_code, msg_text_pt, os_errno, sev_text_pt, 0);
1241  return(ret);
1242 }
int isoburn__sev_to_text(int severity, char **severity_name, int flag)
Definition: burn_wrap.c:1196
int isoburn__text_to_sev(char *severity_name, int *severity_number, int flag)
Definition: burn_wrap.c:1209

References isoburn__sev_to_text(), and isoburn__text_to_sev().

Referenced by isoburn_conv_name_chars(), isoburn_igopt_set_efi_bootp(), isoburn_igopt_set_prep_partition(), isoburn_make_iso_write_opts(), isoburn_new(), isoburn_prepare_disc_aux(), and isoburn_read_image().

◆ isoburn_root_defaults()

int isoburn_root_defaults ( IsoImage *  image,
int  flag 
)

Initialize the root directory attributes of a freshly created image.

Definition at line 129 of file isofs_wrap.c.

130 {
131  IsoNode *root_node;
132  mode_t root_mode= 0755;
133 
134  root_node= (IsoNode *) iso_image_get_root(image);
135  iso_node_set_permissions(root_node, root_mode);
136  return(1);
137 }

References isoburn::image.

Referenced by isoburn_new(), and isoburn_read_image().

◆ isoburn_set_start_byte()

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 medium. The aligned value will be divided by 2048 and then put into o->nwa .

Parameters
oThe isoburn object to be programmed.
valueThe start address in bytes
flagunused yet
Returns
<=0 is failure , >0 success

Definition at line 1081 of file burn_wrap.c.

1082 {
1083  int ret;
1084  struct burn_drive *drive = o->drive;
1085  struct burn_multi_caps *caps= NULL;
1086 
1087  ret= burn_disc_get_multi_caps(drive, BURN_WRITE_NONE, &caps, 0);
1088  if(ret<=0)
1089  goto ex;
1090  if(!caps->start_adr) {
1091  isoburn_msgs_submit(o, 0x00060000,
1092  "Cannot set start byte address with this type of media",
1093  0, "FAILURE", 0);
1094  {ret= 0; goto ex;}
1095  }
1096  o->min_start_byte= value;
1097  if(value % caps->start_alignment)
1098  value+= caps->start_alignment - (value % caps->start_alignment);
1099  o->nwa= value/2048;
1100  if(o->nwa < o->zero_nwa)
1101  o->zero_nwa= 0;
1102  /* If suitable for media alignment, round up to Libisoburn_nwa_alignemenT */
1103  if((o->nwa % Libisoburn_nwa_alignemenT) &&
1104  ((Libisoburn_nwa_alignemenT*2048) % caps->start_alignment)==0 )
1106  ret= 1;
1107 ex:
1108  if(caps!=NULL)
1109  burn_disc_free_multi_caps(&caps);
1110  return(ret);
1111 }
#define Libisoburn_nwa_alignemenT
Definition: isoburn.h:778

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

Referenced by isoburn_start_emulation().

◆ isoburn_start_emulation()

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
oA freshly created isoburn object. isoburn_create_data_source() was already called, nevertheless.
flagbit0= read-only
Returns
<=0 error , 1 = success

Definition at line 537 of file isofs_wrap.c.

538 {
539  int ret, i, capacity = -1, role, dummy;
540  off_t data_count, to_read;
541  struct burn_drive *drive;
542  struct ecma119_pri_vol_desc *pvm;
543  enum burn_disc_status s;
544  char *path= NULL, *msg= NULL;
545 
546  path= calloc(1, BURN_DRIVE_ADR_LEN);
547  msg= calloc(1, 2 * BURN_DRIVE_ADR_LEN);
548  if(path == NULL || msg == NULL)
549  {ret= -1; goto ex;}
550 
551  if(o==NULL) {
552  isoburn_msgs_submit(NULL, 0x00060000,
553  "Program error: isoburn_start_emulation: o==NULL",
554  0, "FATAL", 0);
555  {ret= -1; goto ex;}
556  }
557 
558  drive= o->drive;
559 
560  if(flag & 1)
561  o->fabricated_disc_status= BURN_DISC_FULL;
562 
563  /* We can assume 0 as start block for image.
564  The data there point to the most recent session.
565  */
566  role = burn_drive_get_drive_role(drive);
567  ret = burn_get_read_capacity(drive, &capacity, 0);
568  if (ret <= 0)
569  capacity = -1;
570  if (role == 5) { /* random access write-only medium */
571  s = burn_disc_get_status(drive);
573  burn_disc_track_lba_nwa(drive, NULL, 0, &dummy, &(o->nwa));
574  if(o->nwa < o->zero_nwa)
575  o->zero_nwa= 0;
576  {ret= 1; goto ex;}
577  } else if (capacity > 0 || role == 2 || role == 4) {
578  /* Might be a block device on a system where libburn cannot determine its
579  size. Try to read anyway. */
580  to_read = o->target_iso_head_size;
581  memset(o->target_iso_head, 0, to_read);
582  if(capacity > 0 && (off_t) capacity * (off_t) 2048 < to_read)
583  to_read = (off_t) capacity * (off_t) 2048;
584  ret = burn_read_data(drive, (off_t) 0, (char*)o->target_iso_head,
585  to_read, &data_count, 32 | 8);
586  if (ret <= 0) {
587  /* an error means a disc with no ISO image */
588  o->media_read_error= 1;
589  if (ret == -2) {
590  path[0]= 0;
591  burn_drive_d_get_adr(drive, path);
592  sprintf(msg, "Pseudo drive '%s' does not allow reading", path);
593  isoburn_msgs_submit(NULL, 0x00060000, msg, 0, "NOTE", 0);
594  o->fabricated_disc_status= BURN_DISC_BLANK;
595  } else if (capacity > 0)
596  o->fabricated_disc_status= BURN_DISC_FULL;
597  else if(!(flag & 1))
598  o->fabricated_disc_status= BURN_DISC_BLANK;
599  {ret= 1; goto ex;}
600  }
601  } else {
602  /* No read capacity means blank medium */
603  if(!(flag & 1))
604  o->fabricated_disc_status= BURN_DISC_BLANK;
605  {ret= 1; goto ex;}
606  }
607 
608  /* check first 64K. If 0's, the disc is treated as a blank disc, and thus
609  overwritten without extra check. */
611  while (i && !o->target_iso_head[i-1])
612  --i;
613 
614  if (!i) {
615  if(!(flag & 1))
616  o->fabricated_disc_status= BURN_DISC_BLANK;
617  {ret= 1; goto ex;}
618  }
619 
620  pvm = (struct ecma119_pri_vol_desc *)(o->target_iso_head + 16 * 2048);
621 
622  if (strncmp((char*)pvm->std_identifier, "CD001", 5) == 0) {
623  off_t size;
624 
625  /* sanity check */
626  if (pvm->vol_desc_type[0] != 1 || pvm->vol_desc_version[0] != 1
627  || pvm->file_structure_version[0] != 1 ) {
628  /* TODO for now I treat this as a full disc */
629  o->fabricated_disc_status= BURN_DISC_FULL;
630  {ret= 1; goto ex;}
631  }
632 
633  /* ok, PVM found, set size */
634  size = (off_t) iso_read_lsb(pvm->vol_space_size, 4);
635  ret= isoburn_inspect_partition(o, (uint32_t) size, 0);
636  if (ret <= 0)
637  goto ex;
638  size *= (off_t) 2048; /* block size in bytes */
639  isoburn_set_start_byte(o, size, 0);
640  if(!(flag & 1))
641  o->fabricated_disc_status= BURN_DISC_APPENDABLE;
642  } else if (strncmp((char*)pvm->std_identifier, "CDXX1", 5) == 0 ||
643  (strncmp((char*)pvm->std_identifier, "CDxx1", 5) == 0 &&
644  pvm->vol_desc_type[0] == 'x')) {
645 
646  /* empty image */
647  isoburn_set_start_byte(o, o->zero_nwa * 2048, 0);
648  if(!(flag & 1))
649  o->fabricated_disc_status= BURN_DISC_BLANK;
650  } else {
651  /* treat any disc in an unknown format as full */
652  o->fabricated_disc_status= BURN_DISC_FULL;
653  }
654 
655  ret= 1;
656 ex:;
657  if(path != NULL)
658  free(path);
659  if(msg != NULL)
660  free(msg);
661  return(ret);
662 }
int isoburn_set_start_byte(struct isoburn *o, off_t value, int flag)
Set the start address for an emulated add-on session.
Definition: burn_wrap.c:1081
static int isoburn_inspect_partition(struct isoburn *o, uint32_t img_size, int flag)
Definition: isofs_wrap.c:447
static uint32_t iso_read_lsb(const uint8_t *buf, int bytes)
Definition: isofs_wrap.c:78
uint8_t file_structure_version[(882) -(882)+1]
Definition: isofs_wrap.c:71
uint8_t vol_desc_type[(1) -(1)+1]
Definition: isofs_wrap.c:42
uint8_t std_identifier[(6) -(2)+1]
Definition: isofs_wrap.c:43
uint8_t vol_desc_version[(7) -(7)+1]
Definition: isofs_wrap.c:44
uint8_t vol_space_size[(88) -(81)+1]
Definition: isofs_wrap.c:49

References isoburn::drive, isoburn::fabricated_disc_status, ecma119_pri_vol_desc::file_structure_version, iso_read_lsb(), isoburn_inspect_partition(), isoburn_msgs_submit(), isoburn_set_start_byte(), Libisoburn_target_head_sizE, isoburn::media_read_error, isoburn::nwa, ecma119_pri_vol_desc::std_identifier, isoburn::target_iso_head, isoburn::target_iso_head_size, ecma119_pri_vol_desc::vol_desc_type, ecma119_pri_vol_desc::vol_desc_version, ecma119_pri_vol_desc::vol_space_size, and isoburn::zero_nwa.

Referenced by isoburn_welcome_media().

◆ isoburn_toc_entry_destroy()

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

Definition at line 89 of file isoburn.c.

90 {
91  if(*o==NULL)
92  return(0);
93  if(flag&1)
94  isoburn_toc_entry_destroy(&((*o)->next), flag);
95  if((*o)->volid != NULL)
96  free((*o)->volid);
97  free((char *) (*o));
98  *o= NULL;
99  return(1);
100 }

Referenced by isoburn_destroy(), and isoburn_emulate_toc().

◆ isoburn_toc_entry_new()

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

Definition at line 60 of file isoburn.c.

62 {
63  struct isoburn_toc_entry *o, *s;
64 
65  *objpt= o= (struct isoburn_toc_entry *)
66  malloc(sizeof(struct isoburn_toc_entry));
67  if(o==NULL) {
68  isoburn_msgs_submit(NULL, 0x00060000,
69  "Cannot allocate memory for isoburn toc entry",
70  0, "FATAL", 0);
71  return(-1);
72  }
73  o->session= 0;
74  o->track_no= 0;
75  o->start_lba= -1;
76  o->track_blocks= 0;
77  o->volid= NULL;
78  o->next= NULL;
79  if(boss!=NULL) {
80  for(s= boss; s->next!=NULL; s= s->next);
81  s->next= o;
82  }
83  return(1);
84 }
Definition: isoburn.h:27
int start_lba
Definition: isoburn.h:30
struct isoburn_toc_entry * next
Definition: isoburn.h:34
int session
Definition: isoburn.h:28
char * volid
Definition: isoburn.h:32
int track_blocks
Definition: isoburn.h:31
int track_no
Definition: isoburn.h:29

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