xorriso  1.5.4.pl02
About: GNU xorriso creates, loads, manipulates and writes ISO 9660 filesystem images with Rock Ridge extensions. It is suitable for incremental data backup and for production of bootable ISO 9660 images. GNU xorriso is a statical compilation of the libraries libburn, libisofs, libisoburn, and libjte.
  Fossies Dox: xorriso-1.5.4.pl02.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

iso_img.c
Go to the documentation of this file.
1 
2 /* xorriso - creates, loads, manipulates and burns ISO 9660 filesystem images.
3 
4  Copyright 2007-2020 Thomas Schmitt, <scdbackup@gmx.net>
5 
6  Provided under GPL version 2 or later.
7 
8  This file contains functions which operate on ISO images and their
9  global properties.
10 */
11 
12 #ifdef HAVE_CONFIG_H
13 #include "../config.h"
14 #endif
15 
16 #include <ctype.h>
17 #include <sys/types.h>
18 #include <unistd.h>
19 #include <stdlib.h>
20 #include <stdio.h>
21 #include <string.h>
22 #include <sys/stat.h>
23 #include <sys/time.h>
24 #include <time.h>
25 #include <errno.h>
26 
27 #include <sys/wait.h>
28 
29 #include "xorriso.h"
30 #include "xorriso_private.h"
31 #include "xorrisoburn.h"
32 
33 #include "lib_mgt.h"
34 #include "iso_img.h"
35 #include "iso_tree.h"
36 #include "drive_mgt.h"
37 
38 
39 int Xorriso_set_ignore_aclea(struct XorrisO *xorriso, int flag)
40 {
41  int ret, hflag;
42  IsoImage *volume;
43 
44  ret= Xorriso_get_volume(xorriso, &volume, 1);
45  if(ret<=0)
46  return(ret);
47  hflag= (~xorriso->do_aaip) & 1;
48  if((xorriso->ino_behavior & (1 | 2)) && !(xorriso->do_aaip & (4 | 16)))
49  hflag|= 2;
50  if(xorriso->do_aaip & 1024)
51  hflag|= 8;
52  iso_image_set_ignore_aclea(volume, hflag);
53  return(1);
54 }
55 
56 
57 int Xorriso_update_volid(struct XorrisO *xorriso, int flag)
58 {
59  int gret, sret= 1;
60 
61  gret= Xorriso_get_volid(xorriso, xorriso->loaded_volid, 0);
62  if(gret<=0 || (!xorriso->volid_default) || xorriso->loaded_volid[0]==0)
63  sret= Xorriso_set_volid(xorriso, xorriso->volid, 1);
64  return(gret>0 && sret>0);
65 }
66 
67 
68 int Xorriso_create_empty_iso(struct XorrisO *xorriso, int flag)
69 {
70  int ret;
71  IsoImage *volset;
72  struct isoburn_read_opts *ropts;
73  struct burn_drive_info *dinfo= NULL;
74  struct burn_drive *drive= NULL;
75 
76  if(xorriso->out_drive_handle != NULL) {
77  ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive,
78  "on attempt to attach volset to drive", 2);
79  if(ret<=0)
80  return(ret);
81  }
82  if(xorriso->in_volset_handle!=NULL) {
84  xorriso->in_volset_handle= NULL;
85  Sectorbitmap_destroy(&(xorriso->in_sector_map), 0);
86  Xorriso_destroy_di_array(xorriso, 0);
87  Xorriso_destroy_hln_array(xorriso, 0);
88  xorriso->loaded_volid[0]= 0;
89  xorriso->volset_change_pending= 0;
90  xorriso->boot_count= 0;
91  xorriso->no_volset_present= 0;
92  }
93 
94  ret= isoburn_ropt_new(&ropts, 0);
95  if(ret<=0)
96  return(ret);
97  /* Note: no return before isoburn_ropt_destroy() */
100  isoburn_ropt_set_data_cache(ropts, 1, 1, 0);
101  isoburn_set_read_pacifier(drive, NULL, NULL);
103 
104  ret= isoburn_read_image(drive, ropts, &volset);
105  Xorriso_process_msg_queues(xorriso,0);
106  isoburn_ropt_destroy(&ropts, 0);
107  if(ret<=0) {
108  sprintf(xorriso->info_text, "Failed to create new empty ISO image object");
109  Xorriso_report_iso_error(xorriso, "", ret, xorriso->info_text, 0, "FATAL",
110  0);
111  return(-1);
112  }
113  xorriso->in_volset_handle= (void *) volset;
114  xorriso->in_sector_map= NULL;
115  Xorriso_update_volid(xorriso, 0);
116  xorriso->volset_change_pending= 0;
117  xorriso->boot_count= 0;
118  xorriso->system_area_clear_loaded=
119  (strcmp(xorriso->system_area_disk_path, "/dev/zero") == 0);
120  xorriso->no_volset_present= 0;
121  return(1);
122 }
123 
124 
125 int Xorriso_record_boot_info(struct XorrisO *xorriso, int flag)
126 {
127  int ret;
128  struct burn_drive_info *dinfo;
129  struct burn_drive *drive;
130  IsoImage *image;
131  ElToritoBootImage *bootimg;
132  IsoFile *bootimg_node;
133  IsoBoot *bootcat_node;
134 
135  xorriso->loaded_boot_bin_lba= -1;
136  xorriso->loaded_boot_cat_path[0]= 0;
137  ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive,
138  "on attempt to record boot LBAs", 0);
139  if(ret<=0)
140  return(0);
141  image= isoburn_get_attached_image(drive);
142  if(image == NULL)
143  return(0);
144  ret= iso_image_get_boot_image(image, &bootimg,
145  &bootimg_node, &bootcat_node);
146  iso_image_unref(image); /* release obtained reference */
147  if(ret != 1)
148  return(0);
149  if(bootimg_node != NULL)
150  Xorriso__file_start_lba((IsoNode *) bootimg_node,
151  &(xorriso->loaded_boot_bin_lba), 0);
152  if(bootcat_node != NULL)
153  Xorriso_path_from_lba(xorriso, (IsoNode *) bootcat_node, 0,
154  xorriso->loaded_boot_cat_path, 0);
155  return(1);
156 }
157 
158 
159 int Xorriso_assert_volid(struct XorrisO *xorriso, int msc1, int flag)
160 {
161  int ret, image_blocks;
162  char volid[33];
163  struct burn_drive_info *dinfo;
164  struct burn_drive *drive;
165 
166  if(xorriso->assert_volid[0] == 0)
167  return(1);
168  ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive,
169  "on attempt to perform -assert_volid", 0);
170  if(ret<=0)
171  return(0);
172  ret= isoburn_read_iso_head(drive, msc1, &image_blocks, volid, 1);
173  Xorriso_process_msg_queues(xorriso,0);
174  if(ret <= 0) {
175  sprintf(xorriso->info_text,
176  "-assert_volid: Cannot determine Volume Id at LBA %d.", msc1);
177  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0,
178  xorriso->assert_volid_sev, 0);
179  return(0);
180  }
181  ret= Sregex_match(xorriso->assert_volid, volid, 0);
182  if(ret < 0)
183  return(2);
184  if(ret == 0) {
185  strcpy(xorriso->info_text,
186  "-assert_volid: Volume id does not match pattern: ");
187  Text_shellsafe(xorriso->assert_volid, xorriso->info_text, 1);
188  strcat(xorriso->info_text, " <> ");
189  Text_shellsafe(volid, xorriso->info_text, 1);
190  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0,
191  xorriso->assert_volid_sev, 0);
192  return(0);
193  }
194  return(ret);
195 }
196 
197 
198 /* @return <0 yes , 0 no , <0 error */
199 int Xorriso_is_isohybrid(struct XorrisO *xorriso, IsoFile *bootimg_node,
200  int flag)
201 {
202  int ret;
203  unsigned char buf[68];
204  void *data_stream= NULL;
205 
206  ret= Xorriso_iso_file_open(xorriso, "", (void *) bootimg_node,
207  &data_stream, 1);
208  if(ret <= 0)
209  return(-1);
210  ret= Xorriso_iso_file_read(xorriso, data_stream, (char *) buf, 68, 0);
211  Xorriso_iso_file_close(xorriso, &data_stream, 0);
212  if(ret <= 0)
213  return(0);
214  if(buf[64] == 0xfb && buf[65] == 0xc0 && buf[66] == 0x78 && buf[67] == 0x70)
215  return(1);
216  return(0);
217 }
218 
219 
220 int Xorriso_image_has_md5(struct XorrisO *xorriso, int flag)
221 {
222  int ret;
223  IsoImage *image;
224  uint32_t start_lba, end_lba;
225  char md5[16];
226 
227  ret= Xorriso_get_volume(xorriso, &image, 0);
228  if(ret<=0)
229  return(ret);
230  ret= iso_image_get_session_md5(image, &start_lba, &end_lba, md5, 0);
231  Xorriso_process_msg_queues(xorriso,0);
232  if(ret <= 0)
233  return(0);
234  return(1);
235 }
236 
237 
238 static const char *un0(const char *text)
239 {
240  if(text == NULL)
241  return("");
242  return(text);
243 }
244 
245 
246 static int Xorriso_report_pvd_time(struct XorrisO *xorriso, char *head,
247  char *pvd_time, int flag)
248 {
249  char *msg, hr[17];
250  int at;
251 
252  msg= xorriso->result_line;
253  strncpy(hr, pvd_time, 16);
254  hr[16]= 0;
255  sprintf(msg, "%s %s\n", head, hr);
256  Xorriso_result(xorriso,0);
257  if(pvd_time[16] != 0) {
258  at= abs(pvd_time[16]);
259  sprintf(msg, "%2.2s. Time Zone: %c%-2.2d:%-2.2d\n", head,
260  pvd_time[16] > 0 ? '+' : '-', at / 4, (at - (at / 4) * 4) * 15);
261  Xorriso_result(xorriso,0);
262  }
263  return(1);
264 }
265 
266 
267 int Xorriso_pvd_info(struct XorrisO *xorriso, int flag)
268 {
269  int ret, msc1= -1, msc2, i;
270  IsoImage *image;
271  struct burn_drive_info *dinfo;
272  struct burn_drive *drive;
273  char *msg, block_head[8], *crt, *mdt, *ext, *eft;
274  off_t head_count;
275 
276  msg= xorriso->result_line;
277  ret= Xorriso_get_volume(xorriso, &image, 0);
278  if(ret<=0)
279  return(ret);
280  ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive, "", 16);
281  if(ret > 0) {
282  ret= Xorriso_msinfo(xorriso, &msc1, &msc2, 1 | 4);
283  if(ret<0)
284  return(ret);
285  Xorriso_toc(xorriso, 128);
286  if(msc1 >= 0) {
287  for(i = msc1 + 16; i < msc1 + 32; i++) {
288  ret= burn_read_data(drive, (off_t) i * (off_t) 2048, block_head,
289  (off_t) sizeof(block_head), &head_count, 2);
290  if(ret <= 0) {
291  i= msc1 + 32;
292  break;
293  }
294  if(block_head[0] == 1 && strncmp(block_head + 1, "CD001", 5) == 0)
295  break;
296  }
297  if(i < msc1 + 32) {
298  sprintf(msg, "PVD address : %ds\n", i);
299  Xorriso_result(xorriso,0);
300  }
301  }
302  }
303  sprintf(msg, "Volume Id : %s\n", un0(iso_image_get_volume_id(image)));
304  Xorriso_result(xorriso,0);
305  sprintf(msg, "Volume Set Id: %s\n", xorriso->volset_id);
306  Xorriso_result(xorriso,0);
307  sprintf(msg, "Publisher Id : %s\n", xorriso->publisher);
308  Xorriso_result(xorriso,0);
309  sprintf(msg, "Preparer Id : %s\n",
311  Xorriso_result(xorriso,0);
312  sprintf(msg, "App Id : %s\n", xorriso->application_id);
313  Xorriso_result(xorriso,0);
314  sprintf(msg, "System Id : %s\n", xorriso->system_id);
315  Xorriso_result(xorriso,0);
316  sprintf(msg, "CopyrightFile: %s\n", xorriso->copyright_file);
317  Xorriso_result(xorriso,0);
318  sprintf(msg, "Abstract File: %s\n", xorriso->abstract_file);
319  Xorriso_result(xorriso,0);
320  sprintf(msg, "Biblio File : %s\n", xorriso->biblio_file);
321  Xorriso_result(xorriso,0);
322 
323  ret= iso_image_get_pvd_times(image, &crt, &mdt, &ext, &eft);
324  if(ret != ISO_SUCCESS)
325  crt= mdt= ext= eft= " "; /* Need 17 bytes. Last byte 0. */
326  Xorriso_report_pvd_time(xorriso, "Creation Time:", crt, 0);
327  Xorriso_report_pvd_time(xorriso, "Modif. Time :", mdt, 0);
328  Xorriso_report_pvd_time(xorriso, "Expir. Time :", ext, 0);
329  Xorriso_report_pvd_time(xorriso, "Eff. Time :", eft, 0);
330  return(1);
331 }
332 
333 
334 /* @param flag bit0= do not mark image as changed */
335 int Xorriso_set_volid(struct XorrisO *xorriso, char *volid, int flag)
336 {
337  int ret;
338  IsoImage *volume;
339 
340  if(xorriso->in_volset_handle == NULL)
341  return(2);
342  ret= Xorriso_get_volume(xorriso, &volume, 0);
343  if(ret<=0)
344  return(ret);
345  if(iso_image_get_volume_id(volume) == NULL ||
346  strcmp(iso_image_get_volume_id(volume), volid) != 0)
347  if(!(flag&1))
348  Xorriso_set_change_pending(xorriso, 1);
349  iso_image_set_volume_id(volume, volid);
350  Xorriso_process_msg_queues(xorriso,0);
351  sprintf(xorriso->info_text,"Volume ID: '%s'",iso_image_get_volume_id(volume));
352  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0);
353  return(1);
354 }
355 
356 
357 int Xorriso_get_volid(struct XorrisO *xorriso, char volid[33], int flag)
358 {
359  int ret;
360  IsoImage *volume;
361 
362  ret= Xorriso_get_volume(xorriso, &volume, 0);
363  if(ret<=0)
364  return(ret);
365  strncpy(volid, iso_image_get_volume_id(volume), 32);
366  volid[32]= 0;
367  return(1);
368 }
369 
370 
371 /*
372  bit0= do only report non-default settings
373  bit1= do only report to fp
374  bit2= is_default
375  bit3= append -boot_image any next
376  bit4= concentrate boot options
377  bit5= override load_size by "full"
378 */
379 int Xorriso_boot_item_status(struct XorrisO *xorriso, char *cat_path,
380  char *bin_path, int platform_id,
381  int patch_isolinux, int emul, off_t load_size,
382  unsigned char *id_string,
383  unsigned char *selection_crit, char *form,
384  char *filter, FILE *fp, int flag)
385 {
386  int is_default, no_defaults, i, is_default_id= 0, ret;
387  char *line, *bspec= NULL, zeros[28], *partition_entry;
388  off_t file_size;
389  struct stat stbuf;
390 
391  Xorriso_alloc_meM(bspec, char, SfileadrL + 80);
392 
393  no_defaults= flag & 1;
394  line= xorriso->result_line;
395  if(flag & 32)
396  load_size= -1;
397 
398  if((flag & 16) && bin_path[0] != 0) {
399  /* Concentrate boot options. */
400  memset(zeros, 0, 28);
401  if(memcmp(id_string, zeros, 28) == 0 &&
402  memcmp(selection_crit, zeros, 20) == 0)
403  is_default_id= 1;
404 
405  /* -boot_image isolinux dir= ... */
406  bspec[0]= 0;
407  if(strcmp(form, "isolinux") != 0 && strcmp(form, "any") != 0)
408  ;
409  else if(strcmp(bin_path, "/isolinux.bin") == 0 &&
410  strcmp(cat_path, "/boot.cat") == 0)
411  strcpy(bspec, "dir=/");
412  else if(strcmp(bin_path, "/isolinux/isolinux.bin") == 0 &&
413  strcmp(cat_path, "/isolinux/boot.cat") == 0)
414  strcpy(bspec, "dir=/isolinux");
415  else if(strcmp(xorriso->boot_image_bin_path,
416  "/boot/isolinux/isolinux.bin") == 0
417  && strcmp(xorriso->boot_image_cat_path,
418  "/boot/isolinux/boot.cat") == 0)
419  strcpy(bspec, "dir=/boot/isolinux");
420  memset(zeros, 0, 28);
421  if(bspec[0] && platform_id == 0 && (patch_isolinux & 0x3ff) == 1 &&
422  load_size == 2048 && is_default_id && emul == 0) {
423  sprintf(line, "-boot_image isolinux %s\n", bspec);
424  Xorriso_status_result(xorriso,filter,fp,flag&2);
425  {ret= 1; goto ex;};
426  }
427 
428  file_size= 0;
429  ret= Xorriso_iso_lstat(xorriso, bin_path, &stbuf, 2 | 4);
430  if(ret == 0) {
431  file_size= ((stbuf.st_size / (off_t) 512) +
432  !!(stbuf.st_size % (off_t) 512)) * 512;
433  if(flag & 32)
434  load_size= file_size * 512;
435  }
436  if(platform_id == 0xef && (patch_isolinux & 0x3ff) == 0 &&
437  load_size / 512 == file_size && is_default_id && emul == 0) {
438  sprintf(line, "-boot_image any efi_path=");
439  Text_shellsafe(bin_path, line, 1);
440  strcat(line, "\n");
441  Xorriso_status_result(xorriso,filter,fp,flag&2);
442  {ret= 1; goto ex;};
443  }
444  }
445 
446  is_default= (bin_path[0] == 0) || (flag & 4);
447  sprintf(line, "-boot_image %s bin_path=", form);
448  Text_shellsafe(bin_path, line, 1);
449  strcat(line, "\n");
450  if(!(is_default && no_defaults))
451  Xorriso_status_result(xorriso,filter,fp,flag&2);
452 
453  is_default= (emul == 0);
454  sprintf(line, "-boot_image %s emul_type=%s\n",
455  form, emul == 2 ? "diskette" : emul == 1 ? "hard_disk" : "no_emulation");
456  if(!(is_default && no_defaults))
457  Xorriso_status_result(xorriso,filter,fp,flag&2);
458 
459  is_default= (platform_id == 0 || (flag & 4));
460  sprintf(line, "-boot_image %s platform_id=0x%-2.2x\n", form, platform_id);
461  if(!(is_default && no_defaults))
462  Xorriso_status_result(xorriso,filter,fp,flag&2);
463 
464  is_default= ((patch_isolinux & 1) == 0 || bin_path[0] == 0 || (flag & 4));
465  sprintf(line, "-boot_image %s boot_info_table=%s\n",
466  (patch_isolinux & 2) ? "grub" : form,
467  (patch_isolinux & 1) ? "on" : "off");
468  if(!(is_default && no_defaults))
469  Xorriso_status_result(xorriso,filter,fp,flag&2);
470 
471  is_default= ((patch_isolinux & 512) == 0 || bin_path[0] == 0 || (flag & 4));
472  sprintf(line, "-boot_image grub grub2_boot_info=%s\n",
473  (patch_isolinux & 512) ? "on" : "off");
474  if(!(is_default && no_defaults))
475  Xorriso_status_result(xorriso,filter,fp,flag&2);
476 
477  if(flag & 32) {
478  is_default= 0;
479  sprintf(line, "-boot_image %s load_size=full", form);
480  } else {
481  is_default= (load_size == 2048 || (flag & 4));
482  sprintf(line, "-boot_image %s load_size=%lu\n",
483  form, (unsigned long) load_size);
484  }
485  if(!(is_default && no_defaults))
486  Xorriso_status_result(xorriso,filter,fp,flag&2);
487 
488  is_default= 1;
489  if(!(flag & 4))
490  for(i= 0; i < 20; i++)
491  if(selection_crit[i])
492  is_default= 0;
493  sprintf(line, "-boot_image %s sel_crit=", form);
494  for(i= 0; i < 20; i++)
495  sprintf(line + strlen(line), "%-2.2X", (unsigned int) selection_crit[i]);
496  strcat(line, "\n");
497  if(!(is_default && no_defaults))
498  Xorriso_status_result(xorriso,filter,fp,flag&2);
499 
500  is_default= 1;
501  if(!(flag & 4))
502  for(i= 0; i < 28; i++)
503  if(id_string[i])
504  is_default= 0;
505  sprintf(line, "-boot_image %s id_string=", form);
506  for(i= 0; i < 28; i++)
507  sprintf(line + strlen(line), "%-2.2X", (unsigned int) id_string[i]);
508  strcat(line, "\n");
509  if(!(is_default && no_defaults))
510  Xorriso_status_result(xorriso,filter,fp,flag&2);
511 
512  is_default= 1;
513  partition_entry= "";
514  if((patch_isolinux & 0x0fc) == (1 << 2))
515  partition_entry= "gpt_basdat";
516  else if((patch_isolinux & 0x0fc) == (2 << 2))
517  partition_entry= "gpt_hfsplus";
518  if(partition_entry[0]) {
519  sprintf(line, "-boot_image isolinux partition_entry=%s\n", partition_entry);
520  Xorriso_status_result(xorriso, filter, fp, flag & 2);
521  is_default= 0;
522  }
523  if(patch_isolinux & (1 << 8)) {
524  sprintf(line, "-boot_image isolinux partition_entry=apm_hfsplus\n");
525  Xorriso_status_result(xorriso, filter, fp, flag & 2);
526  is_default= 0;
527  }
528  if(is_default && !no_defaults) {
529  sprintf(line, "-boot_image isolinux partition_entry=off\n");
530  Xorriso_status_result(xorriso, filter, fp, flag & 2);
531  }
532 
533  ret= 1;
534 ex:;
535  Xorriso_free_meM(bspec);
536  return(ret);
537 }
538 
539 
540 int Xorriso_status_hppa(struct XorrisO *xorriso, char *what, char *value,
541  char *filter, FILE *fp, int flag)
542 {
543  char *line;
544 
545  line= xorriso->result_line;
546  if(value == NULL)
547  return(1);
548  sprintf(line, "-boot_image any hppa_%s=", what);
549  Text_shellsafe(value, line, 1);
550  strcat(line, "\n");
551  Xorriso_status_result(xorriso, filter, fp, flag & 2);
552  return(1);
553 }
554 
555 
556 /*
557  bit0= do only report non-default settings
558  bit1= do only report to fp
559 */
560 int Xorriso_boot_status_non_mbr(struct XorrisO *xorriso, IsoImage *image,
561  char *filter, FILE *fp, int flag)
562 {
563  int i, num_boots, sa_type;
564  char *paths[15], *line;
565  int ret;
566  char num[4];
567  char *cmdline, *bootloader, *kernel_32, *kernel_64, *ramdisk;
568 
569  line= xorriso->result_line;
570 
571  sa_type= (xorriso->system_area_options & 0xfc) >> 2;
572  if(sa_type == 3) {
573  sprintf(line, "-boot_image any sparc_label=");
574  Text_shellsafe(xorriso->ascii_disc_label, line, 1);
575  strcat(line, "\n");
576  Xorriso_status_result(xorriso, filter, fp, flag & 2);
577  sprintf(line, "-boot_image grub grub2_sparc_core=");
578  Text_shellsafe(xorriso->grub2_sparc_core, line, 1);
579  strcat(line, "\n");
580  Xorriso_status_result(xorriso, filter, fp, flag & 2);
581  return(0);
582  } else if(sa_type == 1 || sa_type == 2) {
583  num_boots= iso_image_get_mips_boot_files(image, paths, 0);
584  Xorriso_process_msg_queues(xorriso, 0);
585  if(num_boots > 0) {
586  if(sa_type == 2)
587  num_boots= 1;
588  for(i= 0; i < num_boots; i++) {
589  sprintf(line, "-boot_image any mips%s_path=", sa_type ==2 ? "el" : "");
590  Text_shellsafe(paths[i], line, 1);
591  strcat(line, "\n");
592  Xorriso_status_result(xorriso, filter, fp, flag & 2);
593  }
594  }
595  return(num_boots);
596  } else if(sa_type == 4 || sa_type == 5) {
597  ret= iso_image_get_hppa_palo(image, &cmdline, &bootloader, &kernel_32,
598  &kernel_64, &ramdisk);
599  if(ret == 1) {
600  Xorriso_status_hppa(xorriso, "cmdline", cmdline, filter, fp, 0);
601  Xorriso_status_hppa(xorriso, "bootloader", bootloader, filter, fp, 0);
602  Xorriso_status_hppa(xorriso, "kernel_32", kernel_32, filter, fp, 0);
603  Xorriso_status_hppa(xorriso, "kernel_64", kernel_64, filter, fp, 0);
604  Xorriso_status_hppa(xorriso, "ramdisk", ramdisk, filter, fp, 0);
605  sprintf(num, "%d", sa_type);
606  Xorriso_status_hppa(xorriso, "hdrversion", num, filter, fp, 0);
607  }
608  return(0);
609  } else if(sa_type == 6) {
610  ret= iso_image_get_alpha_boot(image, &bootloader);
611  if (ret == 1 && bootloader != NULL) {
612  sprintf(line, "-boot_image any alpha_boot=");
613  Text_shellsafe(bootloader, line, 1);
614  strcat(line, "\n");
615  Xorriso_status_result(xorriso, filter, fp, flag & 2);
616  }
617  return(0);
618  }
619  return(0);
620 }
621 
622 
623 /*
624  bit0= do only report non-default settings
625  bit1= do only report to fp
626 */
627 int Xorriso_append_part_status(struct XorrisO *xorriso, IsoImage *image,
628  char *filter, FILE *fp, int flag)
629 {
630  int i, l, is_default;
631 
632  is_default= (xorriso->appended_as_gpt == 0);
633  sprintf(xorriso->result_line, "-boot_image any appended_part_as=%s\n",
634  xorriso->appended_as_gpt ? "gpt" : "mbr");
635  if(!(is_default && (flag & 1)))
636  Xorriso_status_result(xorriso, filter, fp, flag & 2);
637  for(i= 0; i < Xorriso_max_appended_partitionS; i++) {
638  if(xorriso->appended_partitions[i] == NULL)
639  continue;
640  sprintf(xorriso->result_line, "-append_partition %d ", i + 1);
641  l= strlen(xorriso->result_line);
642  if(xorriso->appended_part_gpt_flags[i] & 1) {
644  xorriso->result_line + l, 0);
645  strcpy(xorriso->result_line + l + 32, " ");
646  } else {
647  sprintf(xorriso->result_line + l, "0x%2.2x ",
648  (unsigned int) xorriso->appended_part_types[i]);
649  }
650  Text_shellsafe(xorriso->appended_partitions[i], xorriso->result_line, 1);
651  strcat(xorriso->result_line, "\n");
652  Xorriso_status_result(xorriso, filter, fp, flag & 2);
653  }
654  return(1);
655 }
656 
657 
658 /*
659  bit0= do only report non-default settings
660  bit1= do only report to fp
661 */
662 int Xorriso_boot_image_status(struct XorrisO *xorriso, char *filter, FILE *fp,
663  int flag)
664 {
665  int ret, i, num_boots, hflag;
666  int is_default, no_defaults;
667  char *path= NULL, *form= "any", *line, *hpt;
668  struct burn_drive_info *dinfo;
669  struct burn_drive *drive;
670  IsoImage *image= NULL;
671  ElToritoBootImage **boots = NULL;
672  IsoFile **bootnodes = NULL;
673  int platform_id, patch, load_size;
674  enum eltorito_boot_media_type media_type;
675  unsigned char id_string[29], sel_crit[21];
676 
677  Xorriso_alloc_meM(path, char, SfileadrL);
678  line= xorriso->result_line;
679  no_defaults= flag & 1;
680 
681  ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive,
682  "on attempt to print boot info", 2 | 16);
683  if(ret<=0)
684  goto no_image;
685  image= isoburn_get_attached_image(drive);
686  Xorriso_process_msg_queues(xorriso,0);
687  if(image == NULL)
688  goto no_image;
689 
690  ret= Xorriso_boot_status_non_mbr(xorriso, image, filter, fp, flag & 3);
691  if(ret < 0) /* == 0 is normal */
692  {ret= 0; goto ex;}
693 
694  if(xorriso->boot_count == 0 && xorriso->boot_image_bin_path[0] == 0) {
695 no_image:;
696  if(xorriso->patch_isolinux_image & 1) {
697  sprintf(line, "-boot_image %s patch\n",
698  xorriso->patch_isolinux_image & 2 ? "grub" : form);
699  is_default= 0;
700  } else if(xorriso->keep_boot_image) {
701  sprintf(line, "-boot_image %s keep\n", form);
702  is_default= 0;
703  } else {
704  sprintf(line, "-boot_image %s discard\n", form);
705  is_default= 1;
706  }
707  if(!(is_default && no_defaults))
708  Xorriso_status_result(xorriso,filter,fp,flag&2);
709  goto report_open_item;
710  }
711 
712  is_default= (xorriso->boot_image_cat_path[0] == 0);
713  sprintf(line,"-boot_image %s cat_path=", form);
714  Text_shellsafe(xorriso->boot_image_cat_path, line, 1);
715  strcat(line, "\n");
716  if(!(is_default && no_defaults))
717  Xorriso_status_result(xorriso,filter,fp,flag&2);
718 
719  is_default= !xorriso->boot_image_cat_hidden;
720  hpt= Xorriso__hide_mode_text(xorriso->boot_image_cat_hidden & 63, 0);
721  if(hpt != NULL)
722  sprintf(line, "-boot_image %s cat_hidden=%s\n", form, hpt);
723  Xorriso_free_meM(hpt);
724  if(!(is_default && no_defaults))
725  Xorriso_status_result(xorriso,filter,fp,flag&2);
726 
727  if(xorriso->boot_count > 0) {
728 
729  /* show attached boot image info */;
730 
731  ret= iso_image_get_all_boot_imgs(image, &num_boots, &boots, &bootnodes, 0);
732  Xorriso_process_msg_queues(xorriso,0);
733  if(ret == 1 && num_boots > 0) {
734  for(i= 0; i < num_boots; i++) {
735  ret= Xorriso_path_from_node(xorriso, (IsoNode *) bootnodes[i], path, 0);
736  if(ret <= 0)
737  continue;
738  platform_id= el_torito_get_boot_platform_id(boots[i]);
739  patch= el_torito_get_isolinux_options(boots[i], 0);
740  el_torito_get_boot_media_type(boots[i], &media_type);
741  load_size= el_torito_get_load_size(boots[i]) * 512;
742  el_torito_get_id_string(boots[i], id_string);
743  el_torito_get_selection_crit(boots[i], sel_crit);
744  if(media_type == ELTORITO_FLOPPY_EMUL)
745  media_type= 2;
746  else if(media_type == ELTORITO_HARD_DISC_EMUL)
747  media_type= 1;
748  else
749  media_type= 0;
750  ret= Xorriso_boot_item_status(xorriso, xorriso->boot_image_cat_path,
751  path, platform_id, patch, media_type,
752  load_size, id_string, sel_crit, "any",
753  filter, fp, 16 | (flag & 3));
754  if(ret <= 0)
755  continue;
756  sprintf(line,"-boot_image %s next\n", form);
757  Xorriso_status_result(xorriso,filter,fp,flag&2);
758  }
759  }
760  }
761 
762  /* Show pending boot image info */
763  if(strcmp(xorriso->boot_image_bin_form, "isolinux") == 0 ||
764  strcmp(xorriso->boot_image_bin_form, "grub") == 0)
765  form= xorriso->boot_image_bin_form;
766 
767  if(xorriso->boot_count > 0 &&
768  xorriso->boot_platform_id == 0 &&
769  xorriso->patch_isolinux_image == 0 &&
770  xorriso->boot_image_bin_path[0] == 0 &&
771  xorriso->boot_image_emul == 0 &&
772  xorriso->boot_image_load_size == 4 * 512) {
773  for(i= 0; i < 20; i++)
774  if(xorriso->boot_selection_crit[i])
775  break;
776  if(i >= 20)
777  for(i= 0; i < 28; i++)
778  if(xorriso->boot_id_string[i])
779  break;
780  if(i >= 28)
781  {ret= 1; goto ex;} /* Images registered, pending is still default */
782  }
783 
784 report_open_item:;
785  hflag= 16;
786  if(xorriso->boot_platform_id == 0xef && !xorriso->boot_efi_default)
787  hflag= 0;
788  ret= Xorriso_boot_item_status(xorriso, xorriso->boot_image_cat_path,
789  xorriso->boot_image_bin_path, xorriso->boot_platform_id,
790  xorriso->patch_isolinux_image, xorriso->boot_image_emul,
791  xorriso->boot_image_load_size, xorriso->boot_id_string,
792  xorriso->boot_selection_crit, form,
793  filter, fp, hflag | (flag & 3));
794  if(ret <= 0)
795  goto ex;
796 
797  ret = Xorriso_append_part_status(xorriso, image, filter, fp, flag & 3);
798  if(ret <= 0)
799  goto ex;
800 
801  ret= 1;
802 ex:
803  if(boots != NULL)
804  free(boots);
805  if(bootnodes != NULL)
806  free(bootnodes);
807  if(image != NULL)
808  iso_image_unref(image);
809  Xorriso_free_meM(path);
810  return(ret);
811 }
812 
813 
815  int flag)
816 {
817  unsigned int platform_id;
818 
819  platform_id= el_torito_get_boot_platform_id(bootimg);
820  if(platform_id != 0)
821  sprintf(line + strlen(line),
822  " , platform_id=0x%-2.2X ", (unsigned int) platform_id);
823  if(el_torito_seems_boot_info_table(bootimg, 0))
824  sprintf(line + strlen(line), " , boot_info_table=on");
825  if(el_torito_seems_boot_info_table(bootimg, 1))
826  sprintf(line + strlen(line), " , grub2_boot_info=on");
827  return(1);
828 }
829 
830 
831 /* @param flag bit0= no output if no boot record was found
832  bit1= short form
833  bit3= report to info channel (else to result channel)
834 */
835 int Xorriso_show_boot_info(struct XorrisO *xorriso, int flag)
836 {
837  int ret, bin_path_valid= 0, i, num_boots, sa_count;
838  char *respt, *path= NULL, **sa_report= NULL, *sa_summary= NULL;
839  unsigned char *lb0= NULL;
840  struct burn_drive_info *dinfo;
841  struct burn_drive *drive;
842  IsoImage *image= NULL;
843  ElToritoBootImage *bootimg, **boots = NULL;
844  IsoFile *bootimg_node, **bootnodes = NULL;
845  IsoBoot *bootcat_node;
846 
847  Xorriso_alloc_meM(path, char, SfileadrL);
848  Xorriso_alloc_meM(lb0, unsigned char, 2048);
849 
850  respt= xorriso->result_line;
851 
852  if(xorriso->boot_count > 0) {
853  if(!(flag & 1)) {
854  sprintf(respt, "Boot record : (overridden by -boot_image any next)\n");
855  Xorriso_toc_line(xorriso, flag & 8);
856  }
857  ret= 1; goto ex;
858  }
859 
860  ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive,
861  "on attempt to print boot info", 16);
862  if(ret<=0)
863  goto no_boot;
864  image= isoburn_get_attached_image(drive);
865  if(image == NULL) {
866  ret= 0;
867 no_boot:;
868  if(!(flag & 1)) {
869  sprintf(respt, "Boot record : none\n");
870  Xorriso_toc_line(xorriso, flag & 8);
871  }
872  goto ex;
873  }
874 
875  ret= iso_image_report_system_area(image, &sa_report, &sa_count, 0);
876  if(ret > 0 && sa_report != NULL)
877  for(i= 0; i < sa_count; i++)
878  if(strncmp(sa_report[i], "System area summary: ", 21) == 0) {
879  Xorriso_alloc_meM(sa_summary, char, strlen(sa_report[i] + 21) + 1);
880  strcpy(sa_summary, sa_report[i] + 21);
881  break;
882  }
883  if(sa_report != NULL)
884  iso_image_report_system_area(image, &sa_report, &sa_count, 1 << 15);
885  Xorriso_process_msg_queues(xorriso,0);
886 
887  /* Using the nodes with extreme care . They might be deleted meanwhile. */
888  ret= iso_image_get_boot_image(image, &bootimg, &bootimg_node, &bootcat_node);
889  if(ret != 1) {
890  if(sa_summary == NULL)
891  goto no_boot;
892  sprintf(respt, "Boot record : (system area only) , %s\n", sa_summary);
893  Xorriso_toc_line(xorriso, flag & 8);
894  ret= 1; goto ex;
895  }
896  ret= iso_image_get_all_boot_imgs(image, &num_boots, &boots, &bootnodes, 0);
897  Xorriso_process_msg_queues(xorriso,0);
898  if(ret != 1) {
899  num_boots= 0;
900  } else {
901  ret= Xorriso_path_from_node(xorriso, (IsoNode *) bootnodes[0], path, 0);
902  if(ret > 0)
903  bin_path_valid= 1;
904  }
905  sprintf(respt, "Boot record : El Torito");
906  if(sa_summary != NULL)
907  sprintf(respt + strlen(respt), " , %s", sa_summary);
908 
909  strcat(respt, "\n");
910  Xorriso_toc_line(xorriso, flag & 8);
911  if(flag & 2)
912  {ret= 1; goto ex;}
913 
914  if(xorriso->loaded_boot_cat_path[0]) {
915  sprintf(respt, "Boot catalog : ");
916  Text_shellsafe(xorriso->loaded_boot_cat_path, respt, 1);
917  strcat(respt, "\n");
918  } else {
919  sprintf(respt, "Boot catalog : -not-found-at-load-time-\n");
920  }
921  Xorriso_toc_line(xorriso, flag & 8);
922 
923  if(bin_path_valid) {
924  sprintf(respt, "Boot image : ");
925  Text_shellsafe(path, respt, 1);
926  } else if(xorriso->loaded_boot_bin_lba <= 0) {
927  sprintf(respt, "Boot image : -not-found-at-load-time-");
928  } else {
929  sprintf(respt, "Boot image : -not-found-any-more-by-lba=%d",
930  xorriso->loaded_boot_bin_lba);
931  }
932  Xorriso__append_boot_params(respt, bootimg, 0);
933  strcat(respt, "\n");
934  Xorriso_toc_line(xorriso, flag & 8);
935 
936  if(num_boots > 1) {
937  for(i= 1; i < num_boots; i++) {
938  ret= Xorriso_path_from_node(xorriso, (IsoNode *) bootnodes[i], path, 0);
939  if(ret > 0) {
940  sprintf(respt, "Boot image : ");
941  Text_shellsafe(path, respt, 1);
942  } else
943  sprintf(respt, "Boot image : -not-found-any-more-");
944  Xorriso__append_boot_params(respt, boots[i], 0);
945  strcat(respt, "\n");
946  Xorriso_toc_line(xorriso, flag & 8);
947  }
948  }
949  ret= 1;
950 ex:;
951  if(boots != NULL)
952  free(boots);
953  if(bootnodes != NULL)
954  free(bootnodes);
955  if(image != NULL)
956  iso_image_unref(image); /* release obtained reference */
957  Xorriso_free_meM(path);
958  Xorriso_free_meM(lb0);
959  Xorriso_free_meM(sa_summary);
960  return(ret);
961 }
962 
963 
964 /* @param flag bit0=silently return 0 if no volume/image is present
965 */
966 int Xorriso_get_volume(struct XorrisO *xorriso, IsoImage **volume,
967  int flag)
968 {
969  *volume= NULL;
970  if(xorriso->in_volset_handle==NULL) {
971  if(flag & 1)
972  return(0);
973  Xorriso_process_msg_queues(xorriso,0);
974  sprintf(xorriso->info_text,"No ISO image present.");
975  if(xorriso->indev[0]==0 && xorriso->outdev[0]==0)
976  sprintf(xorriso->info_text+strlen(xorriso->info_text),
977  " No -dev, -indev, or -outdev selected.");
978  else
979  sprintf(xorriso->info_text+strlen(xorriso->info_text),
980  " Possible program error with drive '%s'.", xorriso->indev);
981 
982  if(!xorriso->no_volset_present)
983  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
984  xorriso->no_volset_present= 1;
985  return(0);
986  }
987  *volume= (IsoImage *) xorriso->in_volset_handle;
988  xorriso->no_volset_present= 0;
989  return(*volume != NULL);
990 }
991 
992 
993 /* @param flag bit0= do not return 1 on volset_change_pending != 1
994 */
995 int Xorriso_change_is_pending(struct XorrisO *xorriso, int flag)
996 {
997  if(flag & 1)
998  return(xorriso->volset_change_pending == 1);
999  return(!!xorriso->volset_change_pending);
1000 }
1001 
1002 
1003 /* @param flag bit0= do not set hln_change_pending */
1004 int Xorriso_set_change_pending(struct XorrisO *xorriso, int flag)
1005 {
1006  int ret;
1007  IsoImage *image;
1008 
1009  ret= Xorriso_get_volume(xorriso, &image, 1);
1010  if(ret <= 0)
1011  return ret;
1012  /* Do not override mark of -as mkisofs -print-size */
1013  if(xorriso->volset_change_pending != 2)
1014  xorriso->volset_change_pending= 1;
1015  if(!(flag & 1))
1016  xorriso->hln_change_pending= 1;
1017  return(1);
1018 }
1019 
1020 
1021 /**
1022  @param flag bit0= print mount command to result channel rather than
1023  performing it
1024  bit1= do not allow prefixes with cmd
1025  bit2= interpret unprefixed cmd as shell:
1026 */
1027 int Xorriso_mount(struct XorrisO *xorriso, char *dev, int adr_mode,
1028  char *adr_value, char *cmd, int flag)
1029 {
1030  int ret, lba, track, session, params_flag= 0, is_safe= 0, is_extra_drive= 0;
1031  int give_up= 0, mount_chardev= 0, status, aquire_flag= 0;
1032  char volid[33], *devadr, *mount_command= NULL, *adr_data= NULL, *adr_pt;
1033  char *dev_path, *libburn_adr= NULL;
1034  char *dpt, *sysname= "";
1035  struct stat stbuf;
1036  struct burn_drive_info *dinfo= NULL;
1037  struct burn_drive *drive= NULL;
1038 
1039  Xorriso_alloc_meM(mount_command, char, SfileadrL);
1040  Xorriso_alloc_meM(adr_data, char, 163);
1041  Xorriso_alloc_meM(libburn_adr, char, BURN_DRIVE_ADR_LEN + SfileadrL);
1042 
1043  devadr= dev;
1044  adr_pt= adr_value;
1045  if(strcmp(dev, "indev") == 0) {
1046  ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive,
1047  "on attempt to perform -mount \"indev\"", 0);
1048  if(ret<=0)
1049  goto ex;
1050  dev_path= devadr= xorriso->indev;
1051  if(strncmp(dev_path, "stdio:", 6) == 0)
1052  dev_path+= 6;
1053  else if(strncmp(dev_path, "mmc:", 4) == 0)
1054  dev_path+= 4;
1055  if(xorriso->in_drive_handle == xorriso->out_drive_handle)
1056  give_up= 3;
1057  else
1058  give_up= 1;
1059  } else if(strcmp(dev, "outdev") == 0) {
1060  ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive,
1061  "on attempt to perform -mount \"outdev\"",
1062  2);
1063  if(ret<=0)
1064  goto ex;
1065  dev_path= devadr= xorriso->outdev;
1066  if(strncmp(dev_path, "stdio:", 6) == 0)
1067  dev_path+= 6;
1068  else if(strncmp(dev_path, "mmc:", 4) == 0)
1069  dev_path+= 4;
1070  if(xorriso->in_drive_handle == xorriso->out_drive_handle)
1071  give_up= 3;
1072  else
1073  give_up= 2;
1074  } else {
1075  is_extra_drive= 1;
1076  dev_path= dev;
1077  if(strncmp(dev_path, "stdio:", 6) == 0)
1078  dev_path+= 6;
1079  else if(strncmp(dev_path, "mmc:", 4) == 0)
1080  dev_path+= 4;
1081 
1082  /* do only accept regular files and block devices */
1083  ret= stat(dev_path, &stbuf);
1084  if(ret == -1) {
1085  sprintf(xorriso->info_text, "Cannot determine properties of file ");
1086  Text_shellsafe(dev_path, xorriso->info_text, 1);
1087  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
1088  ret= 0; goto ex;
1089  }
1090  ret= System_uname(&sysname, NULL, NULL, NULL, 0);
1091  if(ret > 0 && strcmp(sysname, "FreeBSD") == 0)
1092  mount_chardev= 1;
1093  if(!(S_ISREG(stbuf.st_mode) || (S_ISBLK(stbuf.st_mode) && !mount_chardev)
1094  || (S_ISCHR(stbuf.st_mode) && !mount_chardev))) {
1095  sprintf(xorriso->info_text,
1096  "File object is not suitable as mount device: ");
1097  Text_shellsafe(dev_path, xorriso->info_text, 1);
1098  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
1099  ret= 0; goto ex;
1100  }
1101 
1102  /* Acquire drive as direct libburn address or via stdio: prefix */
1103  if(strncmp(dev, "mmc:", 4) == 0)
1104  ret= burn_drive_convert_fs_adr(dev + 4, libburn_adr);
1105  else
1106  ret= burn_drive_convert_fs_adr(dev, libburn_adr);
1107  Xorriso_process_msg_queues(xorriso,0);
1108  if(ret < 0)
1109  {ret= -1; goto ex;}
1110  if(ret == 0 && strncmp(dev, "stdio:", 6) != 0 &&
1111  strncmp(dev, "mmc:", 4) != 0)
1112  sprintf(libburn_adr, "stdio:%s", dev);
1114  (xorriso->drives_exclusive && !(xorriso->mount_opts_flag & 1)) |
1115  (xorriso->linux_scsi_dev_family << 2), 0, 0);
1116  aquire_flag= 1;
1117  if((xorriso->toc_emulation_flag & 2) && adr_mode == 3)
1118  aquire_flag|= 16;
1119  if(xorriso->toc_emulation_flag & 4)
1120  aquire_flag|= 128;
1121  if(xorriso->toc_emulation_flag & 8)
1122  aquire_flag|= 512;
1123  ret= isoburn_drive_aquire(&dinfo, libburn_adr, aquire_flag);
1124  burn_preset_device_open(1 | (xorriso->linux_scsi_dev_family << 2), 0, 0);
1125  Xorriso_process_msg_queues(xorriso,0);
1126  if(ret <= 0)
1127  {ret= 0; goto ex;}
1128  drive= dinfo[0].drive;
1129  }
1130 
1131  if(adr_mode == 4 && strlen(adr_pt) <= 80) {
1132  ret= Xorriso__bourne_to_reg(adr_pt, adr_data, 0);
1133  if(ret == 1) {
1134  params_flag|= 4;
1135  adr_pt= adr_data;
1136  }
1137  }
1138  ret= isoburn_get_mount_params(drive, adr_mode, adr_pt, &lba, &track,
1139  &session, volid, params_flag);
1140  Xorriso_process_msg_queues(xorriso,0);
1141  if(ret <= 0)
1142  goto ex;
1143  if(((session <= 0 || track <= 0) && !(aquire_flag & 16)) || ret == 2) {
1144  Xorriso_msgs_submit(xorriso, 0,
1145  "-mount : Given address does not point to an ISO 9660 session",
1146  0, "FAILURE", 0);
1147  ret= 0; goto ex;
1148  }
1149  if(strstr(devadr, "stdio:") == devadr)
1150  devadr+= 6;
1151  if(strstr(devadr, "mmc:") == devadr)
1152  devadr+= 4;
1153  ret= Xorriso_make_mount_cmd(xorriso, cmd, lba, track, session, volid, devadr,
1154  mount_command, (flag & (2 | 4)) | ((flag & 4) << 1));
1155  if(ret <= 0)
1156  goto ex;
1157  if(ret == 2)
1158  is_safe= 1;
1159 
1160  if(is_extra_drive) {
1161  isoburn_drive_release(drive, 0);
1162  burn_drive_info_free(dinfo);
1163  drive= NULL;
1164  } else if(give_up > 0 && !((flag & 1) || (xorriso->mount_opts_flag & 1))) {
1165  ret= Xorriso_give_up_drive(xorriso, give_up);
1166  if(ret <= 0)
1167  goto ex;
1168  }
1169  Xorriso_process_msg_queues(xorriso,0);
1170 
1171  sprintf(xorriso->info_text, "Volume id : ");
1172  Text_shellsafe(volid, xorriso->info_text, 1);
1173  strcat(xorriso->info_text, "\n");
1174  Xorriso_info(xorriso, 0);
1175  if(flag & 1) {
1176  sprintf(xorriso->result_line, "%s\n", mount_command);
1177  Xorriso_result(xorriso,0);
1178  } else {
1179  sprintf(xorriso->info_text, "Mount command: %s\n", mount_command);
1180  Xorriso_info(xorriso, 0);
1181  if(!is_safe) {
1182  Xorriso_msgs_submit(xorriso, 0,
1183  "-mount : Will not perform mount command which stems from command template.",
1184  0, "SORRY", 0);
1185  sprintf(xorriso->result_line, "%s\n", mount_command);
1186  Xorriso_result(xorriso,0);
1187  } else {
1188  ret= Xorriso_execv(xorriso, mount_command, 0, NULL, "/bin:/sbin",
1189  NULL, NULL, NULL, &status, 1);
1190  if(WIFEXITED(status) && WEXITSTATUS(status) != 0) {
1191  sprintf(xorriso->info_text,
1192  "-mount : mount command failed with exit value %d",
1193  (int) WEXITSTATUS(status));
1194  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
1195  ret= 0; goto ex;
1196  }
1197  sprintf(xorriso->info_text, "\nMounted session %d of device ", session);
1198  Text_shellsafe(dev_path, xorriso->info_text, 1);
1199  dpt= strchr(cmd, ':');
1200  if(dpt == NULL)
1201  dpt= cmd ;
1202  else
1203  dpt++;
1204  sprintf(xorriso->info_text + strlen(xorriso->info_text), " as directory ");
1205  Text_shellsafe(dpt, xorriso->info_text, 1);
1206  strcat(xorriso->info_text, "\n");
1207  Xorriso_info(xorriso, 0);
1208  }
1209  }
1210  ret= 1;
1211 ex:;
1212  if(is_extra_drive && drive != NULL) {
1213  isoburn_drive_release(drive, 0);
1214  burn_drive_info_free(dinfo);
1215  Xorriso_process_msg_queues(xorriso,0);
1216  }
1217  Xorriso_free_meM(mount_command);
1218  Xorriso_free_meM(adr_data);
1219  Xorriso_free_meM(libburn_adr);
1220  return(ret);
1221 }
1222 
1223 
1224 /* @param flag bit0= give up all boot file paths
1225  bit1= refuse if already a path is added
1226 */
1227 int Xorriso_add_mips_boot_file(struct XorrisO *xorriso, char *path, int flag)
1228 {
1229  int ret;
1230  IsoImage *image;
1231  char *paths[15];
1232 
1233  ret= Xorriso_get_volume(xorriso, &image, 0);
1234  if(ret <= 0)
1235  return ret;
1236  if(flag & 1) {
1237  iso_image_give_up_mips_boot(image, 0);
1238  Xorriso_process_msg_queues(xorriso,0);
1239  return(1);
1240  }
1241  if(flag & 2) {
1242  ret= iso_image_get_mips_boot_files(image, paths, 0);
1243  Xorriso_process_msg_queues(xorriso,0);
1244  if(ret < 0)
1245  goto report_error;
1246  if(ret > 0) {
1247  Xorriso_msgs_submit(xorriso, 0,
1248  "There is already a boot image file registered.",
1249  0, "FAILURE", 0);
1250  return(0);
1251  }
1252  }
1253  ret = iso_image_add_mips_boot_file(image, path, 0);
1254  Xorriso_process_msg_queues(xorriso,0);
1255  if (ret < 0) {
1256 report_error:;
1257  Xorriso_report_iso_error(xorriso, "", ret,
1258  "Error when adding MIPS boot file",
1259  0, "FAILURE", 1);
1260  return(0);
1261  }
1262  return(1);
1263 }
1264 
1265 
1266 /* @param flag bit0= Give up HP-PA boot parameters
1267 */
1268 int Xorriso_set_hppa_boot_parm(struct XorrisO *xorriso, char *text, char *what,
1269  int flag)
1270 {
1271  int ret;
1272  IsoImage *image;
1273  char *par[5];
1274 
1275  ret= Xorriso_get_volume(xorriso, &image, 0);
1276  if(ret <= 0)
1277  return(ret);
1278  par[0]= par[1]= par[2]= par[3]= par[4]= NULL;
1279  if(flag & 1) {
1280  /* Give up HP-PA boot parameters */
1281  iso_image_set_hppa_palo(image, par[0], par[1], par[2], par[3], par[4],
1282  1);
1283  return(1);
1284  }
1285  if(strcmp(what, "cmdline") == 0) {
1286  par[0]= text;
1287  } else if(strcmp(what, "bootloader") == 0) {
1288  par[1]= text;
1289  } else if(strcmp(what, "kernel_32") == 0 || strcmp(what, "kernel-32") == 0) {
1290  par[2]= text;
1291  } else if(strcmp(what, "kernel_64") == 0 || strcmp(what, "kernel-64") == 0) {
1292  par[3]= text;
1293  } else if(strcmp(what, "ramdisk") == 0) {
1294  par[4]= text;
1295  } else if(strcmp(what, "hdrversion") == 0) {
1296  if(strcmp(text, "4") == 0) {
1297  xorriso->system_area_options= (xorriso->system_area_options & ~0xfc) |
1298  (4 << 2);
1299  } else if(strcmp(text, "5") == 0) {
1300  xorriso->system_area_options= (xorriso->system_area_options & ~0xfc) |
1301  (5 << 2);
1302  } else {
1303  strcpy(xorriso->info_text, "Unsupported HP-PA PALO header version ");
1304  Text_shellsafe(text, xorriso->info_text, 1);
1305  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
1306  return(0);
1307  }
1308  return(1);
1309  } else {
1310  strcpy(xorriso->info_text,
1311  "HP-PA boot parameter name not recognized: hppa_");
1312  Text_shellsafe(what, xorriso->info_text, 1);
1313  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
1314  return(0);
1315  }
1316  ret= iso_image_set_hppa_palo(image, par[0], par[1], par[2], par[3], par[4],
1317  0);
1318  if (ret < 0) {
1319  Xorriso_report_iso_error(xorriso, "", ret,
1320  "Error when adding HP-PA boot parameter",
1321  0, "FAILURE", 1);
1322  return(0);
1323  }
1324  return(1);
1325 }
1326 
1327 
1328 /* @param flag bit0= Give up DEC Alpha boot parameters
1329 */
1330 int Xorriso_set_alpha_boot(struct XorrisO *xorriso, char *path, int flag)
1331 {
1332  int ret;
1333  IsoImage *image;
1334 
1335  ret= Xorriso_get_volume(xorriso, &image, 0);
1336  if(ret <= 0)
1337  return(ret);
1338  if(flag & 1) {
1339  /* Give up boot parameters */
1340  iso_image_set_alpha_boot(image, NULL, 1);
1341  return(1);
1342  }
1343  ret= iso_image_set_alpha_boot(image, path, 0);
1344  if (ret < 0) {
1345  Xorriso_report_iso_error(xorriso, "", ret,
1346  "Error when adding DEC Alpha boot loader",
1347  0, "FAILURE", 1);
1348  return(0);
1349  }
1350  return(1);
1351 }
1352 
1353 
1354 /* @param flag bit0= do not set xorriso->system_area_options, just check
1355  bit1= only check for grub2_mbr <-> isolinux partition_table
1356 */
1357 int Xorriso_coordinate_system_area(struct XorrisO *xorriso, int sa_type,
1358  int options, char *cmd, int flag)
1359 {
1360  int old_type, old_options, new_options;
1361  static char *type_names[7] = {
1362  "MBR", "MIPS Big Endian Volume Header", "MIPS Little Endian Boot Block",
1363  "SUN Disk Label", "HP-PA PALO v4", "HP-PA PALO v5",
1364  "DEC Alpha SRM Boot Block"};
1365  static int num_names = 7;
1366 
1367  old_type= (xorriso->system_area_options & 0xfc) >> 2;
1368  old_options= xorriso->system_area_options & 0x3c03;
1369  new_options= options & 0x3c03;
1370  if(((options & (1 << 14)) && (xorriso->system_area_options & 2)) ||
1371  ((options & 2) && (xorriso->system_area_options & (1 << 14))))
1372  goto reject;
1373  if(flag & 2)
1374  return(1);
1375  if((old_type != 0 || old_options != 0) &&
1376  (old_type != sa_type || (old_options != 0 && old_options != new_options))){
1377 reject:;
1378  sprintf(xorriso->info_text, "%s : First sector already occupied by %s",
1379  cmd, old_type < num_names ?
1380  type_names[old_type] : "other boot facility");
1381  if(old_type == 0 && (old_options & 2))
1382  strcat(xorriso->info_text, " for ISOLINUX isohybrid");
1383  else if (old_type == 0 && (xorriso->system_area_options & (1 << 14))) {
1384  strcat(xorriso->info_text, " for GRUB2 patching");
1385  if(old_type == 0 && (old_options & 1))
1386  strcat(xorriso->info_text, " with partition table");
1387  } else if(old_type == 0 && (old_options & 1))
1388  strcat(xorriso->info_text, " for partition table");
1389  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
1390  goto hint_revoke;
1391  }
1392  if(!(flag & 1))
1393  xorriso->system_area_options= (xorriso->system_area_options & ~0x3cff) |
1394  ((sa_type << 2) & 0xfc) | (options & 0x3c03);
1395  return(1);
1396 
1397 hint_revoke:;
1398  if(old_type == 0)
1399  sprintf(xorriso->info_text, "Revokable by -boot_image any discard");
1400  else if(old_type == 1 || old_type == 2)
1401  sprintf(xorriso->info_text, "Revokable by -boot_image any mips_discard");
1402  else if(old_type == 3)
1403  sprintf(xorriso->info_text, "Revokable by -boot_image any sparc_discard");
1404  if(old_type < 4)
1405  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "HINT", 0);
1406  return(0);
1407 }
1408 
1409 
1410 int Xorriso_gpt_crc(struct XorrisO *xorriso, char *path, int flag)
1411 {
1412  int ret;
1413  char *buf = NULL;
1414  FILE *fp = NULL;
1415  uint32_t crc;
1416 
1417  Xorriso_alloc_meM(buf, char, 32 * 1024);
1418 
1419  ret= Xorriso_afile_fopen(xorriso, path, "rb", &fp, 0);
1420  if(ret <= 0)
1421  goto ex;
1422  ret= fread(buf, 1, 32 * 1024, fp);
1423  if(ret == 0) {
1424  strcpy(xorriso->info_text,
1425  "No bytes readable for GPT CRC from ");
1426  Text_shellsafe(path, xorriso->info_text, 1);
1427  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0);
1428  ret= 0; goto ex;
1429  }
1430  crc= iso_crc32_gpt((unsigned char *) buf, ret, 0);
1431  sprintf(xorriso->result_line, "0x%8.8x\n", (unsigned int) crc);
1432  Xorriso_result(xorriso, 0);
1433  ret= 1;
1434 ex:;
1435  if(fp != NULL && fp != stdin)
1436  fclose(fp);
1437  Xorriso_free_meM(buf);
1438  return(ret);
1439 }
1440 
1441 
1442 static int Xorriso_split_report_line(struct XorrisO *xorriso, char *line,
1443  int num_limit,
1444  char *name, char **contentpt,
1445  double *num, int *num_count,
1446  char **textpt, int flag)
1447 {
1448  int i;
1449  char *spt, *ept, *cpt;
1450 
1451  if(strlen(line) < 21) {
1452 undigestible:
1453  sprintf(xorriso->info_text,
1454  "Undigestible report line with -report_* mode cmd: '%s'", line);
1455  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
1456  return(0);
1457  }
1458  if(line[19] != ':')
1459  goto undigestible;
1460  strncpy(name, line, 20);
1461  name[20]= 0;
1462 
1463  for(spt= line + 20; *spt == ' '; spt++);
1464  *textpt= *contentpt= spt;
1465  *num_count= 0;
1466  for(i= 0; i < num_limit; i++) {
1467  /* Get word */
1468  for(spt= *textpt; *spt == ' '; spt++);
1469  if(*spt == 0) {
1470  *textpt= spt;
1471  break;
1472  }
1473  for(ept= spt + 1; *ept != ' ' && *ept != 0; ept++);
1474  /* Look for decimal number */
1475  if(ept - spt > 16)
1476  break;
1477  for(cpt= spt; cpt < ept; cpt++)
1478  if(*cpt < '0' || *cpt > '9')
1479  break;
1480  if(cpt != ept)
1481  break;
1482  sscanf(spt, "%lf", num + *num_count);
1483  (*num_count)++;
1484  *textpt= ept;
1485  }
1486  /* Set *textpt to next non-blank */
1487  for(; **textpt == ' '; (*textpt)++);
1488  return(1);
1489 }
1490 
1491 
1492 int Xorriso_record_cmd_line(struct XorrisO *xorriso, char *buf,
1493  char **cmds, int *cmd_count, int flag)
1494 {
1495  int ret;
1496 
1497  if(flag & 1) {
1498  (*cmd_count)++;
1499  ret= 1; goto ex;
1500  }
1501  Xorriso_alloc_meM(cmds[*cmd_count], char, strlen(buf) + 1);
1502  strcpy(cmds[*cmd_count], buf);
1503  (*cmd_count)++;
1504  ret= 1;
1505 ex:;
1506  return(ret);
1507 }
1508 
1509 
1510 /* @param flag bit0= zeroize MBR partition table
1511  bit1= zeroize GPT
1512  bit2= zeroize APM
1513  bit30= Source imported_iso rather than local_fs
1514 */
1515 int Xorriso_add_intvl_adr(struct XorrisO *xorriso, char *buf,
1516  uint64_t start_adr, uint64_t end_adr, char *suffix,
1517  int flag)
1518 {
1519  char *path;
1520 
1521  sprintf(buf + strlen(buf), "--interval:%s:%.f%s-%.f%s:",
1522  ((flag & (1 << 30)) ? "imported_iso" : "local_fs"),
1523  (double) start_adr, suffix, (double) end_adr, suffix);
1524  if(flag & 1)
1525  strcat(buf, "zero_mbrpt,");
1526  if(flag & 2)
1527  strcat(buf, "zero_gpt,");
1528  if(flag & 4)
1529  strcat(buf, "zero_apm,");
1530  if(buf[strlen(buf) - 1] == ',')
1531  buf[strlen(buf) - 1] = 0;
1532  strcat(buf, ":");
1533  path= xorriso->indev;
1534  if(strncmp(path, "stdio:", 6) == 0)
1535  path+= 6;
1536  Text_shellsafe(path, buf, 1);
1537  return(1);
1538 }
1539 
1540 
1541 int Xorriso_add_offset_size(struct XorrisO *xorriso, char *buf,
1542  off_t byte_offset, off_t byte_size, int flag)
1543 {
1544  strcat(buf, " ");
1545  Sfile_off_t_text(buf + strlen(buf), byte_offset, 0);
1546  strcat(buf, " ");
1547  Sfile_off_t_text(buf + strlen(buf), byte_size, 0);
1548  return(1);
1549 }
1550 
1551 
1555  unsigned int ld_seg, hdpt, platform_id;
1556  unsigned long int lba, extract_size;
1557  char pltf[8], b[8], emul[8], boot_image_type[16];
1559 };
1560 
1561 
1562 /* @param ptype 0= unknown, 1= gpt-basdat, 2=gpt-hfsplus, 3=EFI
1563  @param flag bit0= isohybrid
1564 */
1565 static int Xorriso_register_eltorito_gpt(struct XorrisO *xorriso,
1566  struct elto_img_par *et_img,
1567  int ptype,
1568  int *efi_boot_part, int *first_efi,
1569  int flag)
1570 {
1571  if(flag & 1) {
1572  if(ptype == 1 || ptype == 3)
1573  et_img->do_gpt_basdat= 1;
1574  else if(ptype == 2)
1575  et_img->do_gpt_hfsplus= 1;
1576  return(1);
1577  } else if(*first_efi && et_img->platform_id == 0xef) {
1578  *efi_boot_part= 1;
1579  return(1);
1580  }
1581  if(et_img->platform_id == 0xef)
1582  *first_efi= 0;
1583  return(0);
1584 }
1585 
1586 
1587 /* @param ptype 0= unknown, 1= gpt-basdat, 2=gpt-hfsplus, 3=EFI
1588  @param flag bit0= isohybrid
1589 */
1590 static int Xorriso_search_eltorito_path(struct XorrisO *xorriso,
1591  struct elto_img_par *et_imgs,
1592  int elto_count, char *path, int ptype,
1593  int *found, int *efi_boot_part,
1594  int flag)
1595 {
1596  int first_efi= 1, et_idx, ret;
1597 
1598  for(et_idx= 0; et_idx < elto_count; et_idx++) {
1599  if(strcmp(et_imgs[et_idx].path, path) != 0)
1600  continue;
1601  ret= Xorriso_register_eltorito_gpt(xorriso, et_imgs + et_idx,
1602  ptype, efi_boot_part, &first_efi, flag);
1603  if(ret > 0)
1604  break;
1605  }
1606  *found= et_idx;
1607  if(et_idx < elto_count)
1608  return(1);
1609  return(0);
1610 }
1611 
1612 
1613 static int Xorriso_search_eltorito_lba(struct XorrisO *xorriso,
1614  struct elto_img_par *et_imgs,
1615  int elto_count,
1616  unsigned int lba,
1617  int *found, int flag)
1618 {
1619  int et_idx;
1620 
1621  for(et_idx= 0; et_idx < elto_count; et_idx++)
1622  if(et_imgs[et_idx].lba == lba)
1623  break;
1624  *found= et_idx;
1625  if(et_idx < elto_count)
1626  return(1);
1627  return(0);
1628 }
1629 
1630 
1631 int Xorriso_highest_data_block(struct XorrisO *xorriso, uint32_t *high_block,
1632  int flag)
1633 {
1634  int ret;
1635  struct FindjoB *job= NULL;
1636  struct stat dir_stbuf;
1637 
1638  *high_block= 0;
1639  ret= Findjob_new(&job, "/", 0);
1640  if(ret <= 0) {
1641  Xorriso_no_findjob(xorriso, "[internal:last_data_file_block]", 0);
1642  {ret= -1; goto ex;}
1643  }
1644  Findjob_set_action_type(job, 58, 0, 0);
1645  ret= Xorriso_findi(xorriso, job, NULL, (off_t) 0,
1646  NULL, "/", &dir_stbuf, 0, 0);
1647  if(ret <= 0)
1648  goto ex;
1649  Findjob_get_last_data_file_block(job, high_block, 0);
1650 ex:;
1651  Findjob_destroy(&job, 0);
1652  return(ret);
1653 }
1654 
1655 
1656 /* @param flag bit0= do not record but only count
1657  bit1= as_mkisofs
1658  bit2= no sorry messages
1659 */
1660 static int Xorriso_scan_report_lines(struct XorrisO *xorriso,
1661  char **et_lines, int et_line_count,
1662  char **sa_lines, int sa_line_count,
1663  char **cmds, int *cmd_count,
1664  char **boot_imgs, int *boot_img_count,
1665  int flag)
1666 {
1667  int ret= 0, i, num_count, mkisofs, line_count, idx, et_idx, isohybrid= 0;
1668  int ptype, gpt_idx, j, pad, mbr_idx;
1669  int efi_boot_part= 0, full_sparc_part= 0, have_sparc_part= 0, fe_dummy= 1;
1670  int appended_as_gpt= 0, have_prep= 0, did_sysarea= 0, cared_for_apm= 0;
1671  int cared_for_sparc= 0, have_hfsplus= 0;
1672  int have_sysarea= 0, ptable_killer, imported_iso, have_alpha_ldr_path= 0;
1673  int have_protective_msdos= 0, part_like_isohybrid= 0;
1674 
1675 #ifdef Not_any_more_because_padding_is_now_after_partitions
1676  int appended_partition= 0;
1677 #endif
1678 
1679  int iso_mbr_part_type= -1, iso_gpt_part_idx= -1;
1680  unsigned int prev_pltf= 0;
1681  unsigned long int sa_options= 0, partno, id_tag, perms, start_cyl;
1682  unsigned long int part_status, part_type, mbr_start_block, mbr_num_blocks;
1683  unsigned long int partition_offset= 0;
1684  uint32_t high_block= 0, indev_blocks;
1685  char name[24], *textpt, *contentpt, *buf= NULL, part_type_text[37];
1686  char **lines= NULL;
1687  double num[8];
1688  char *cat_path= "";
1689  struct elto_img_par *et_imgs= NULL;
1690  int elto_count= 0;
1691  uint32_t mbr_parts_end= 0, extract_size;
1692  struct FindjoB *job= NULL;
1693  struct stat dir_stbuf;
1694  IsoImage *image;
1695  char *volid, *crt, *mdt, *ext, *eft, uuid[17], *uuid_time;
1696  char **app_pseudo_paths= NULL;
1697  struct tm tm_erg;
1698  int was_force_bootable= 0, have_mbr_force_bootable= 0;
1699  uint64_t gpt_bheader_block= 0, start_block, num_blocks;
1700  uint64_t img_blocks= 0, iso_part_blocks;
1701 
1702  struct mbr_par {
1703  uint8_t ptype;
1704  uint64_t start_block;
1705  uint64_t block_count;
1706  int appended;
1707  int has_path;
1708  };
1709  struct mbr_par *mbrpts= NULL;
1710  int mbr_count= 0;
1711 
1712  struct gpt_par {
1713  int ptype; /* 0= unknown, 1= gpt-basdat, 2=gpt-hfsplus, 3=EFI */
1714  uint8_t type_guid[16];
1715  int is_gap;
1716  int has_path;
1717  char *path;
1718  uint64_t start_block;
1719  uint64_t block_count;
1720  };
1721  struct gpt_par *gpts= NULL;
1722  int gpt_count= 0;
1723 
1724  struct apm_par {
1725  int ptype; /* bit0= type Apple_HFS , bit1= name HFSPLUS_Hybrid */
1726  char *path;
1727  };
1728  struct apm_par *apms= NULL;
1729  int apm_count= 0;
1730 
1731 #define Xorriso_record_cmd_linE { \
1732  ret= Xorriso_record_cmd_line(xorriso, buf, cmds, cmd_count, flag & 1); \
1733  buf[0]= 0; \
1734  if(ret <= 0) \
1735  goto ex; \
1736  }
1737 #define Xorriso_record_boot_imglinE { \
1738  ret= Xorriso_record_cmd_line(xorriso, buf, boot_imgs, boot_img_count, \
1739  flag & 1); \
1740  buf[0]= 0; \
1741  if(ret <= 0) \
1742  goto ex; \
1743  }
1744 
1745 /* 2 exp 19 blocks = 1 GiB */
1746 #define Xorriso_max_endless_uefi_sizE (1 << 19)
1747 
1748  mkisofs= !!(flag & 2);
1749  imported_iso= (!mkisofs) << 30;
1750 
1751  *cmd_count= 0;
1752  *boot_img_count= 0;
1753  line_count= et_line_count + sa_line_count;
1754  if(line_count <= 0)
1755  {ret= 1; goto ex;}
1756 
1757  Xorriso_alloc_meM(buf, char, 80 + SfileadrL);
1758  Xorriso_alloc_meM(lines, char *, line_count);
1759  for(i= 0; i < et_line_count; i++)
1760  lines[i]= et_lines[i];
1761  for(i= 0; i < sa_line_count; i++)
1762  lines[i + et_line_count]= sa_lines[i];
1763 
1764  /* Pre-scan to establish context */
1765  for(i= 0; i < line_count; i++) {
1766  ret= Xorriso_split_report_line(xorriso, lines[i], 8, name, &contentpt,
1767  num, &num_count, &textpt, 0);
1768  if(ret <= 0)
1769  goto ex;
1770  if(strcmp(name, "System area options:") == 0) {
1771  sscanf(contentpt, "%lx", &sa_options);
1772 
1773  } else if(strcmp(name, "System area summary:") == 0) {
1774  have_sysarea= 1;
1775 
1776  } else if(strcmp(name, "El Torito boot img :") == 0) {
1777  if(num[0] > elto_count)
1778  elto_count= num[0];
1779 
1780  } else if(strcmp(name, "PReP boot partition:") == 0) {
1781  have_prep= 1;
1782 
1783  } else if(strcmp(name, "MBR partition :") == 0) {
1784  if(num[0] > mbr_count)
1785  mbr_count= num[0];
1786  if(strcmp(textpt, "0x80 0x00 0 1") == 0)
1787  have_mbr_force_bootable= 1;
1788 
1789  } else if(strcmp(name, "GPT partition name :") == 0) {
1790  if(num[0] > gpt_count)
1791  gpt_count= num[0];
1792 
1793  } else if(strcmp(name, "APM partition name :") == 0) {
1794  if(num[0] > apm_count)
1795  apm_count= num[0];
1796 
1797  } else if(strcmp(name, "ISO image size/512 :") == 0) {
1798  img_blocks= num[0];
1799 
1800  } else if(strcmp(name, "Partition offset :") == 0 &&
1801  (num[0] == 0 || num[0] == 16)) {
1802  partition_offset= num[0];
1803 
1804  }
1805  }
1806 
1807  ret= Xorriso_highest_data_block(xorriso, &high_block, 0);
1808  if(ret < 0)
1809  goto ex;
1810  if(ret == 0)
1811  high_block = img_blocks / 4 - 1;
1812 
1813  if(elto_count > 0) {
1814  Xorriso_alloc_meM(et_imgs, struct elto_img_par, elto_count);
1815  for(et_idx= 0; et_idx < elto_count; et_idx++) {
1816  et_imgs[et_idx].path= NULL;
1817  et_imgs[et_idx].ldsiz= -1;
1818  }
1819  Xorriso_alloc_meM(app_pseudo_paths, char *, elto_count);
1820  for(i= 0; i < elto_count; i++)
1821  app_pseudo_paths[i]= NULL;
1822  for(i= 0; i < elto_count; i++) {
1823  Xorriso_alloc_meM(app_pseudo_paths[i], char, 80);
1824  app_pseudo_paths[i][0]= 0;
1825  }
1826  }
1827  if(mbr_count > 0)
1828  Xorriso_alloc_meM(mbrpts, struct mbr_par, mbr_count);
1829  if(gpt_count > 0) {
1830  Xorriso_alloc_meM(gpts, struct gpt_par, gpt_count);
1831  for(gpt_idx= 0; gpt_idx < gpt_count; gpt_idx++)
1832  gpts[gpt_idx].path= NULL;
1833  }
1834  if(apm_count > 0) {
1835  Xorriso_alloc_meM(apms, struct apm_par, apm_count);
1836  for(i= 0; i < apm_count; i++)
1837  apms[i].path= NULL;
1838  }
1839 
1840  ptable_killer= (mbr_count > 0) | ((gpt_count > 0) << 1) |
1841  ((apm_count > 0) << 2);
1842 
1843  /* Report volume id and GRUB2 modification date */;
1844  ret= Xorriso_get_volume(xorriso, &image, 0);
1845  if(ret <= 0)
1846  goto ex;
1847  if(mkisofs)
1848  sprintf(buf, "-V ");
1849  else
1850  sprintf(buf, "-volid ");
1851  volid= (char *) un0(iso_image_get_volume_id(image));
1852  Text_shellsafe(volid, buf, 1);
1854  ret= iso_image_get_pvd_times(image, &crt, &mdt, &ext, &eft);
1855  if(ret == ISO_SUCCESS) {
1856  uuid_time= crt;
1857  /* If Creation Time is bad and Modification Time is ok: use the latter */
1858  ret= Decode_ecma119_format(&tm_erg, crt, 0);
1859  if(ret <= 0 || strlen(crt) != 16) {
1860  ret= Decode_ecma119_format(&tm_erg, mdt, 0);
1861  if(!(ret <= 0 || strlen(mdt) != 16))
1862  uuid_time= mdt;
1863  }
1864  pad= 0;
1865  for(j= 0; j < 16; j++) {
1866  if(pad) {
1867  uuid[j]= '0';
1868  } else if(uuid_time[j] == 0) {
1869  pad= 1;
1870  uuid[j]= '0';
1871  } else if(uuid_time[j] < '0' || uuid_time[j] > '9') {
1872  uuid[j]= '0';
1873  } else {
1874  uuid[j]= uuid_time[j];
1875  }
1876  }
1877  uuid[16]= 0;
1878  ret= Decode_ecma119_format(&tm_erg, uuid, 0);
1879  if(!(ret <= 0 || strlen(uuid) != 16)) {
1880  if(mkisofs)
1881  sprintf(buf, "--modification-date=");
1882  else
1883  sprintf(buf, "-volume_date uuid ");
1884  Text_shellsafe(uuid, buf, 1);
1886  }
1887  }
1888 
1889  /* First pass: set up objects, record El Torito and info needed in 2nd pass */
1890  for(i= 0; i < line_count; i++) {
1891  buf[0]= 0;
1892  ret= Xorriso_split_report_line(xorriso, lines[i], 8, name, &contentpt,
1893  num, &num_count, &textpt, 0);
1894  if(ret <= 0)
1895  goto ex;
1896 
1897  if(strcmp(name, "El Torito cat path :") == 0) {
1898  cat_path= textpt;
1899 
1900  } else if(strcmp(name, "El Torito catalog :") == 0) {
1901  strcpy(buf, "eltorito_catalog.img/");
1902  Xorriso_add_offset_size(xorriso, buf, ((off_t) num[0]) * 2048,
1903  ((off_t) num[1]) * 2048, 0);
1905 
1906  } else if(strcmp(name, "El Torito boot img :") == 0) {
1907  /* Platform Id, bootability, emulation, load segment,
1908  Hard disk emulation partition type, Load size
1909  */
1910  idx= num[0] - 1;
1911  sscanf(contentpt, "%d %s %s %s %x %x %d %lu",
1912  &(et_imgs[idx].n), et_imgs[idx].pltf, et_imgs[idx].b,
1913  et_imgs[idx].emul, &(et_imgs[idx].ld_seg), &(et_imgs[idx].hdpt),
1914  &(et_imgs[idx].ldsiz), &(et_imgs[idx].lba));
1915  if(strcmp(et_imgs[idx].pltf, "BIOS") == 0)
1916  et_imgs[idx].platform_id= 0;
1917  else if(strcmp(et_imgs[idx].pltf, "PPC") == 0)
1918  et_imgs[idx].platform_id= 1;
1919  else if(strcmp(et_imgs[idx].pltf, "Mac") == 0)
1920  et_imgs[idx].platform_id= 2;
1921  else if(strcmp(et_imgs[idx].pltf, "UEFI") == 0)
1922  et_imgs[idx].platform_id= 0xef;
1923  else
1924  sscanf(et_imgs[idx].pltf, "%x", &(et_imgs[idx].platform_id));
1925 
1926  strcpy(et_imgs[idx].boot_image_type, "any");
1927  et_imgs[idx].boot_info_table= 0;
1928  et_imgs[idx].grub2_boot_info= 0;
1929  et_imgs[idx].path= et_imgs[idx].id_string= et_imgs[idx].sel_crit= "";
1930  et_imgs[idx].do_gpt_basdat= et_imgs[idx].do_gpt_hfsplus= 0;
1931  et_imgs[idx].do_apm_hfsplus= 0;
1932  et_imgs[idx].extract_size= (et_imgs[idx].ldsiz + 3) / 4;
1933 
1934  } else if(strcmp(name, "El Torito img path :") == 0) {
1935  idx= num[0] - 1;
1936  et_imgs[idx].path= textpt;
1937  ret= Xorriso_iso_lstat(xorriso, et_imgs[idx].path, &dir_stbuf, 0);
1938  if(ret == 0) {
1939  extract_size = (dir_stbuf.st_size + 2047) / 2048;
1940  if(extract_size > et_imgs[idx].extract_size)
1941  et_imgs[idx].extract_size= extract_size;
1942  }
1943 
1944  } else if(strcmp(name, "El Torito img blks :") == 0) {
1945  idx= num[0] - 1;
1946  if(num[1] > et_imgs[idx].extract_size)
1947  et_imgs[idx].extract_size= num[1];
1948 
1949  } else if(strcmp(name, "El Torito img opts :") == 0) {
1950  idx= num[0] - 1;
1951  if(strstr(textpt, "boot-info-table") != NULL)
1952  et_imgs[idx].boot_info_table= 1;
1953  if(strstr(textpt, "isohybrid-suitable") != NULL)
1954  strcpy(et_imgs[idx].boot_image_type, "isolinux");
1955  if(strstr(textpt, "grub2-boot-info") != NULL) {
1956  strcpy(et_imgs[idx].boot_image_type, "grub");
1957  et_imgs[idx].grub2_boot_info= 1;
1958  }
1959 
1960  } else if(strcmp(name, "El Torito id string:") == 0) {
1961  idx= num[0] - 1;
1962  et_imgs[idx].id_string= textpt;
1963 
1964  } else if(strcmp(name, "El Torito sel crit :") == 0) {
1965  idx= num[0] - 1;
1966  et_imgs[idx].sel_crit= textpt;
1967 
1968  } else if(strcmp(name, "System area summary:") == 0) {
1969  if(strstr(textpt, "protective-msdos-label") != NULL)
1970  have_protective_msdos= 1;
1971 
1972  } else if(strcmp(name, "MBR partition :") == 0) {
1973  sscanf(contentpt, "%lu 0x%lx 0x%lx %lu %lu",
1974  &partno, &part_status, &part_type, &mbr_start_block,
1975  &mbr_num_blocks);
1976  idx= partno - 1;
1977  mbrpts[idx].ptype= part_type;
1978  mbrpts[idx].start_block= mbr_start_block;
1979  mbrpts[idx].block_count= mbr_num_blocks;
1980  if(mbr_num_blocks > 0 && mbr_start_block + mbr_num_blocks > mbr_parts_end)
1981  mbr_parts_end= mbr_start_block + mbr_num_blocks;
1982  if(mbr_start_block == partition_offset * 4 &&
1983  (mbr_start_block + mbr_num_blocks) >= high_block * 4 &&
1984  iso_mbr_part_type < 0)
1985  iso_mbr_part_type = part_type;
1986 
1987  } else if(strcmp(name, "MBR partition path :") == 0) {
1988  idx= num[0] - 1;
1989  mbrpts[idx].has_path= 1;
1990 
1991  } else if(strcmp(name, "GPT lba range :") == 0) {
1992  gpt_bheader_block= num[2];
1993 
1994  } else if(strcmp(name, "GPT type GUID :") == 0) {
1995  idx= num[0] - 1;
1996  if(strcmp(textpt, "a2a0d0ebe5b9334487c068b6b72699c7") == 0)
1997  gpts[idx].ptype= 1; /* Basic data */
1998  else if(strcmp(textpt, "005346480000aa11aa1100306543ecac") == 0)
1999  gpts[idx].ptype= 2; /* HFS+ */
2000  else if(strcmp(textpt, "28732ac11ff8d211ba4b00a0c93ec93b") == 0)
2001  gpts[idx].ptype= 3; /* EFI System Partition */
2002  else
2003  gpts[idx].ptype= 0;
2004  Xorriso_parse_guid(xorriso, textpt, gpts[idx].type_guid, 1);
2005 
2006  } else if(strcmp(name, "GPT start and size :") == 0) {
2007  idx= num[0] - 1;
2008  if(num[2] > 0)
2009  appended_as_gpt= 1;
2010  start_block= gpts[idx].start_block= num[1];
2011  num_blocks= gpts[idx].block_count= num[2];
2012  if(start_block == partition_offset * 4 &&
2013  (start_block + num_blocks) >= high_block * 4 &&
2014  iso_gpt_part_idx < 0)
2015  iso_gpt_part_idx= idx;
2016 
2017  } else if(strcmp(name, "GPT partition path :") == 0) {
2018  idx= num[0] - 1;
2019  gpts[idx].has_path= 1;
2020  gpts[idx].path= textpt;
2021 
2022  } else if(strcmp(name, "GPT partition name :") == 0) {
2023  idx= num[0] - 1;
2024  if(strstr(contentpt, " 470061007000") != NULL) /* "Gap"... */
2025  gpts[idx].is_gap= 1;
2026 
2027  } else if(strcmp(name, "APM partition name :") == 0) {
2028  idx= num[0] - 1;
2029  if(strcmp(textpt, "HFSPLUS_Hybrid") == 0)
2030  apms[idx].ptype|= 2;
2031 
2032  } else if(strcmp(name, "APM partition type :") == 0) {
2033  idx= num[0] - 1;
2034  if(strcmp(textpt, "Apple_HFS") == 0)
2035  apms[idx].ptype|= 1;
2036 
2037  } else if(strcmp(name, "APM partition path :") == 0) {
2038  idx= num[0] - 1;
2039  apms[idx].path= textpt;
2040 
2041  } else if(strcmp(name, "DEC Alpha ldr path :") == 0) {
2042  have_alpha_ldr_path= 1;
2043 
2044  }
2045  }
2046 
2047  if(appended_as_gpt && !have_protective_msdos) {
2048  if(mbr_count != 1) {
2049  appended_as_gpt= 0;
2050  } else if(mbrpts[0].ptype != 0xee || mbrpts[0].start_block != 1) {
2051  appended_as_gpt= 0;
2052  } else if(gpt_bheader_block != mbrpts[0].block_count) {
2053  appended_as_gpt= 0;
2054  }
2055  }
2056 
2057  iso_part_blocks= img_blocks;
2058  for(mbr_idx = 0; mbr_idx < mbr_count; mbr_idx++) {
2059  if(mbrpts[mbr_idx].start_block == partition_offset * 4) {
2060  iso_part_blocks= mbrpts[mbr_idx].block_count + partition_offset * 4;
2061  break;
2062  }
2063  }
2064 
2065  /* Second pass: scan for System Area info */
2066  for(i= 0; i < line_count; i++) {
2067  buf[0]= 0;
2068  ret= Xorriso_split_report_line(xorriso, lines[i], 8, name, &contentpt,
2069  num, &num_count, &textpt, 0);
2070  if(ret <= 0)
2071  goto ex;
2072 
2073  if(strcmp(name, "System area options:") == 0) {
2074  if((sa_options & 0x3c00) == 0x0400) {
2075  if(mkisofs)
2076  sprintf(buf, "-chrp-boot-part ");
2077  else
2078  sprintf(buf, "-boot_image any chrp_boot_part=on ");
2079  }
2080 
2081  } else if(strcmp(name, "System area summary:") == 0) {
2082  if(strstr(textpt, "isohybrid") != NULL) {
2083  isohybrid= 1;
2084  if(mkisofs)
2085  sprintf(buf, "-isohybrid-mbr ");
2086  else
2087  sprintf(buf, "-boot_image isolinux system_area=");
2088  Xorriso_add_intvl_adr(xorriso, buf, (uint64_t) 0, (uint64_t) 15, "s",
2089  imported_iso | ptable_killer);
2091  strcpy(buf, "mbr_code_isohybrid.img/");
2092  Xorriso_add_offset_size(xorriso, buf, (off_t) 0, (off_t) 446, 0);
2094  did_sysarea= 1;
2095  }
2096  if(strstr(textpt, "grub2-mbr") != NULL) {
2097  if(mkisofs)
2098  sprintf(buf, "--grub2-mbr ");
2099  else
2100  sprintf(buf, "-boot_image grub grub2_mbr=");
2101  Xorriso_add_intvl_adr(xorriso, buf, (uint64_t) 0, (uint64_t) 15, "s",
2102  imported_iso | ptable_killer);
2104  strcpy(buf, "mbr_code_grub2.img/");
2105  Xorriso_add_offset_size(xorriso, buf, (off_t) 0, (off_t) 446, 0);
2107  did_sysarea= 1;
2108  }
2109  if(strstr(textpt, "protective-msdos-label") != NULL) {
2110  if(mkisofs)
2111  sprintf(buf, "--protective-msdos-label");
2112  else
2113  sprintf(buf, "-boot_image any partition_table=on");
2115  }
2116  if(strstr(textpt, "cyl-align-off") != NULL) {
2117  if(mkisofs)
2118  sprintf(buf, "-partition_cyl_align off");
2119  else
2120  sprintf(buf, "-boot_image any partition_cyl_align=off");
2121  } else if(strstr(textpt, "cyl-align-all") != NULL) {
2122  if(mkisofs)
2123  sprintf(buf, "-partition_cyl_align all");
2124  else
2125  sprintf(buf, "-boot_image any partition_cyl_align=all");
2126  } else if(strstr(textpt, "cyl-align-") != NULL) {
2127  if(mkisofs)
2128  sprintf(buf, "-partition_cyl_align on");
2129  else
2130  sprintf(buf, "-boot_image any partition_cyl_align=on");
2131  } else
2132  buf[0]= 0;
2133 
2134  } else if(strcmp(name, "Partition offset :") == 0 &&
2135  (num[0] == 0 || num[0] == 16)) {
2136  if(mkisofs)
2137  sprintf(buf, "-partition_offset %.f", num[0]);
2138  else
2139  sprintf(buf, "-boot_image any partition_offset=%.f", num[0]);
2140 
2141  } else if(strcmp(name, "MBR heads per cyl :") == 0 &&
2142  (num[0] > 0 && num[0] <= 255)) {
2143  if(mkisofs)
2144  sprintf(buf, "-partition_hd_cyl %.f", num[0]);
2145  else
2146  sprintf(buf, "-boot_image any partition_hd_cyl=%.f", num[0]);
2147 
2148  } else if(strcmp(name, "MBR secs per head :") == 0 &&
2149  (num[0] > 0 && num[0] <= 63)) {
2150  if(mkisofs)
2151  sprintf(buf, "-partition_sec_hd %.f", num[0]);
2152  else
2153  sprintf(buf, "-boot_image any partition_sec_hd=%.f", num[0]);
2154 
2155  } else if(strcmp(name, "MBR partition :") == 0) {
2156  sscanf(contentpt, "%lu 0x%lx 0x%lx %lu %lu",
2157  &partno, &part_status, &part_type, &mbr_start_block,
2158  &mbr_num_blocks);
2159  if(mbr_num_blocks > 0 && part_type != 0x00 && part_type != 0xee &&
2160  (iso_part_blocks <= mbr_start_block ||
2161  (have_protective_msdos && img_blocks == mbr_parts_end &&
2162  partno > 1))) {
2163  if(!appended_as_gpt) {
2164  sprintf(buf, "-append_partition %lu 0x%lx ", partno, part_type);
2165  Xorriso_add_intvl_adr(xorriso, buf, (uint64_t) mbr_start_block,
2166  ((uint64_t) mbr_start_block) + mbr_num_blocks - 1,
2167  "d", imported_iso);
2169  if(partno >= 1 && (int) partno <= mbr_count)
2170  mbrpts[partno - 1].appended= 1;
2171 
2172 #ifdef Not_any_more_because_padding_is_now_after_partitions
2173  appended_partition= 1;
2174 #endif
2175 
2176  }
2177  if(part_type == 0xef) {
2178  sprintf(buf, "mbr_part%lu_efi.img/", partno);
2179  Xorriso_add_offset_size(xorriso, buf, ((off_t) mbr_start_block) * 512,
2180  ((off_t) mbr_num_blocks) * 512, 0);
2182  }
2183  } else if(part_type == 0x41 && have_prep) {
2184  if(mkisofs) {
2185  sprintf(buf, "-prep-boot-part ");
2186  } else {
2187  sprintf(buf, "-boot_image any prep_boot_part=");
2188  }
2189  Xorriso_add_intvl_adr(xorriso, buf, (uint64_t) mbr_start_block,
2190  ((uint64_t) mbr_start_block) + mbr_num_blocks - 1,
2191  "d", imported_iso);
2193  sprintf(buf, "mbr_part%lu_prep.img/", partno);
2194  Xorriso_add_offset_size(xorriso, buf, ((off_t) mbr_start_block) * 512,
2195  ((off_t) mbr_num_blocks) * 512, 0);
2197  } else if(part_type == 0xef) {
2198  sprintf(buf, "mbr_part%lu_efi.img/", partno);
2199  Xorriso_add_offset_size(xorriso, buf, ((off_t) mbr_start_block) * 512,
2200  ((off_t) mbr_num_blocks) * 512, 0);
2202  }
2203  if((part_status & 0x80) && !was_force_bootable) {
2204  was_force_bootable= 1;
2205  if(buf[0]) {
2207  }
2208  if(mkisofs)
2209  sprintf(buf, "--mbr-force-bootable");
2210  else
2211  sprintf(buf, "-boot_image any mbr_force_bootable=on");
2212  }
2213  } else if(strcmp(name, "MBR partition path :") == 0) {
2214  idx= num[0] - 1;
2215  if(mbrpts[idx].ptype == 0x41) {
2216  sprintf(xorriso->info_text,
2217  "Cannot make proposal to mark PReP partition by data file: ");
2218  Text_shellsafe(textpt, xorriso->info_text, 1);
2219  if(!(flag & 5))
2220  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
2221  continue;
2222  }
2223  ptype= 0;
2224  if(mbrpts[idx].ptype == 0xef)
2225  ptype= 3;
2226  ret= Xorriso_search_eltorito_path(xorriso, et_imgs, elto_count,
2227  textpt, ptype,
2228  &et_idx, &efi_boot_part, !!isohybrid);
2229  if(ret <= 0) {
2230  sprintf(xorriso->info_text,
2231  "Cannot make proposal to mark data file as MBR partition without being an El Torito boot image : ");
2232  Text_shellsafe(textpt, xorriso->info_text, 1);
2233  if(!(flag & 5))
2234  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
2235  } else {
2236  for(gpt_idx= 0; gpt_idx < gpt_count; gpt_idx++) {
2237  if(gpts[gpt_idx].path != NULL)
2238  if(strcmp(gpts[gpt_idx].path, textpt) == 0)
2239  break;
2240  }
2241  if(gpt_idx >= gpt_count) {
2242  sprintf(xorriso->info_text,
2243  "Cannot make proposal to mark data file as MBR partition without being in GPT : ");
2244  Text_shellsafe(textpt, xorriso->info_text, 1);
2245  if(!(flag & 5))
2246  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
2247  }
2248  }
2249 
2250  } else if(strcmp(name, "GPT disk GUID :") == 0) {
2251 
2252  /* >>> ??? need command to set disk GUID */;
2253 
2254  } else if(strcmp(name, "GPT partition name :") == 0) {
2255 
2256  /* >>> ??? need command to set partition name for partition number */;
2257 
2258  } else if(strcmp(name, "GPT partition GUID :") == 0) {
2259 
2260  /* >>> ??? need command to set partition GUID for partition number */;
2261 
2262  } else if(strcmp(name, "GPT partition flags:") == 0) {
2263 
2264  /* >>> check whether 0x1000000000000001 . Else: complain */;
2265 
2266  } else if(strcmp(name, "GPT partition path :") == 0) {
2267  idx= num[0] - 1;
2268  ret= Xorriso_search_eltorito_path(xorriso, et_imgs, elto_count,
2269  textpt, gpts[idx].ptype,
2270  &et_idx, &efi_boot_part, !!isohybrid);
2271  if(ret <= 0) {
2272  sprintf(xorriso->info_text,
2273  "Cannot make proposal to mark data file as GPT partition : ");
2274  Text_shellsafe(textpt, xorriso->info_text, 1);
2275  if(!(flag & 5))
2276  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
2277  }
2278 
2279  } else if(strcmp(name, "GPT start and size :") == 0) {
2280  idx= num[0] - 1;
2281  if(gpts[idx].ptype == 3)
2282  part_type= 0xef;
2283  else
2284  part_type= 0xcd;
2285 
2286  if(high_block * 4 < num[1] && num[2] > 0 && !gpts[idx].is_gap) {
2287  for(mbr_idx = 0; mbr_idx < mbr_count; mbr_idx++) {
2288  if(mbrpts[mbr_idx].start_block == num[1]) {
2289  if(mbrpts[mbr_idx].block_count != num[2] && !(flag & 1)) {
2290  sprintf(xorriso->info_text,
2291  "GPT partition %d has same start block as MBR partition %d but different block count (%.f <> %.f)",
2292  idx + 1, mbr_idx + 1, num[2],
2293  (double) mbrpts[mbr_idx].block_count);
2294  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING",
2295  0);
2296  }
2297  break;
2298  }
2299  }
2300  if(mbr_idx >= mbr_count) {
2301  if(appended_as_gpt == 1) {
2302  appended_as_gpt= 2;
2303  Xorriso__format_guid(gpts[idx].type_guid, part_type_text, 0);
2304  } else {
2305  sprintf(part_type_text, "0x%lx", part_type);
2306  }
2307  sprintf(buf, "-append_partition %d %s ", idx + 1, part_type_text);
2308  Xorriso_add_intvl_adr(xorriso, buf, (uint64_t) num[1],
2309  (uint64_t) (num[1] + num[2] - 1.0), "d",
2310  imported_iso);
2312 
2313 #ifdef Not_any_more_because_padding_is_now_after_partitions
2314  appended_partition= 1;
2315 #endif
2316 
2317  }
2318 
2319  /* Check for isohybri-ish MBR and GPT mix */
2320  if((mbr_count == 1 || (mbr_count == 2 && have_mbr_force_bootable)) &&
2321  mbrpts[0].ptype == 0xee && have_protective_msdos) {
2322  /* real GPT (+/- mbr_force_bootable) is not -part_like_isohybrid */
2323  ret= 0;
2324  } else {
2325  ret= Xorriso_search_eltorito_lba(xorriso, et_imgs, elto_count,
2326  (unsigned int) (num[1] / 4.0),
2327  &et_idx, 0);
2328  }
2329  if(ret > 0) {
2330  if(!(et_imgs[et_idx].do_gpt_basdat ||
2331  et_imgs[et_idx].do_gpt_hfsplus ||
2332  part_like_isohybrid)) {
2333  if(mkisofs)
2334  sprintf(buf, "-part_like_isohybrid");
2335  else
2336  sprintf(buf, "-boot_image any part_like_isohybrid=on");
2338  part_like_isohybrid= 1;
2339  appended_as_gpt= 0;
2340  }
2341  /* mark el torito for -isohybrid-gpt-... */
2342  Xorriso_register_eltorito_gpt(xorriso, et_imgs + et_idx,
2343  gpts[idx].ptype, &efi_boot_part,
2344  &fe_dummy, 1);
2345  }
2346 
2347  } else if(gpts[idx].ptype == 3 && gpts[idx].has_path == 0 &&
2348  img_blocks >= num[1] + num[2] && !efi_boot_part) {
2349  if(mkisofs)
2350  sprintf(buf, "-efi-boot-part ");
2351  else
2352  sprintf(buf, "-boot_image any efi_boot_part=");
2353  Xorriso_add_intvl_adr(xorriso, buf, (uint64_t) num[1],
2354  (uint64_t) (num[1] + num[2] - 1.0), "d",
2355  imported_iso);
2356  efi_boot_part= 2;
2358  }
2359 
2360  if(gpts[idx].ptype == 2 &&
2361  (img_blocks / 2 > num[2] || num[1] >= img_blocks)) {
2362  /* Obviously not a HFS+ tree covering the ISO */
2363  sprintf(buf, "gpt_part%d_hfsplus.img/", idx + 1);
2364  Xorriso_add_offset_size(xorriso, buf, ((off_t) num[1]) * 512,
2365  ((off_t) num[2]) * 512, 0);
2367  } else if(gpts[idx].ptype == 3) {
2368  sprintf(buf, "gpt_part%d_efi.img/", idx + 1);
2369  Xorriso_add_offset_size(xorriso, buf, ((off_t) num[1]) * 512,
2370  ((off_t) num[2]) * 512, 0);
2372  }
2373 
2374  } else if(strcmp(name, "APM block size :") == 0) {
2375  if(mkisofs)
2376  sprintf(buf, "-apm-block-size %.f", num[0]);
2377  else
2378  sprintf(buf, "-boot_image any apm_block_size=%.f", num[0]);
2379 
2380  } else if(strcmp(name, "APM partition name :") == 0) {
2381 
2382  /* >>> ??? need command to set APM partition name for partition number */;
2383 
2384  } else if(strcmp(name, "APM partition path :") == 0) {
2385  idx= num[0] - 1;
2386  /* Check El Torito EFI boot images for same path */
2387  for(et_idx= 0; isohybrid && et_idx < elto_count; et_idx++)
2388  if(strcmp(et_imgs[et_idx].path, textpt) == 0) {
2389  if(apms[idx].ptype == 1) {
2390  et_imgs[et_idx].do_apm_hfsplus= 1;
2391  cared_for_apm= 1;
2392  }
2393  break;
2394  }
2395 
2396  } else if(strcmp(name, "APM start and size :") == 0) {
2397  idx= num[0] - 1;
2398 
2399  if(num[1] + num[2] <= img_blocks && apms[idx].ptype == 3 &&
2400  apms[idx].path == NULL && !have_hfsplus) {
2401 
2402  /* >>> HFS+ magic number */;
2403  /* >>> Read byte 1024 and 1025 after partition start
2404  Must be {'H', '+'} (0x482b big endian)
2405  */;
2406  /* ??? >>> Do this recognition in libisofs ? */
2407 
2408  if(mkisofs)
2409  sprintf(buf, "-hfsplus");
2410  else
2411  sprintf(buf, "-hfsplus on");
2413 
2414  /* Report commands for blessings and creator-type */
2415  ret= Findjob_new(&job, "/", 0);
2416  if(ret <= 0) {
2417  Xorriso_no_findjob(xorriso, "xorriso", 0);
2418  {ret= -1; goto ex;}
2419  }
2420  Findjob_set_action_target(job, 53, NULL, 0);
2421  xorriso->show_hfs_cmd_count= *cmd_count;
2422  xorriso->show_hfs_cmds= cmds;
2423  xorriso->show_hfs_cmd_flag= (flag & 1) | ((!!mkisofs) << 1);
2424  ret= Xorriso_findi(xorriso, job, NULL, (off_t) 0, NULL, "/",
2425  &dir_stbuf, 0, 0);
2426  *cmd_count= xorriso->show_hfs_cmd_count;
2427  if(ret <= 0)
2428  goto ex;
2429  have_hfsplus= 1;
2430  cared_for_apm= 1;
2431  }
2432 
2433  } else if(strcmp(name, "MIPS-BE boot path :") == 0) {
2434  if(mkisofs)
2435  sprintf(buf, "-mips-boot ");
2436  else
2437  sprintf(buf, "-boot_image any mips_path=");
2438  Text_shellsafe(textpt, buf, 1);
2439 
2440  } else if(strcmp(name, "MIPS-LE boot path :") == 0) {
2441  if(mkisofs)
2442  sprintf(buf, "-mipsel-boot ");
2443  else
2444  sprintf(buf, "-boot_image any mipsel_path=");
2445  Text_shellsafe(textpt, buf, 1);
2446 
2447  } else if(strcmp(name, "SUN SPARC disklabel:") == 0) {
2448  if(mkisofs)
2449  sprintf(buf, "-sparc-label ");
2450  else
2451  sprintf(buf, "-boot_image any sparc_label=");
2452  Text_shellsafe(textpt, buf, 1);
2453 
2454  } else if(strcmp(name, "SPARC GRUB2 path :") == 0) {
2455  if(mkisofs) {
2456  sprintf(buf, "-B ,");
2458  sprintf(buf, "--grub2-sparc-core ");
2459  } else
2460  sprintf(buf, "-boot_image grub grub2_sparc_core=");
2461  Text_shellsafe(textpt, buf, 1);
2462  cared_for_sparc= 1;
2463 
2464  } else if(strcmp(name, "SUN SPARC partition:") == 0) {
2465  have_sparc_part= 1;
2466  partno= id_tag= perms= num_blocks= 0;
2467  start_cyl= 0xffffffff;
2468  sscanf(contentpt, "%lu 0x%lx 0x%lx %lu %lu",
2469  &partno, &id_tag, &perms, &start_cyl, &mbr_num_blocks);
2470  if(partno > 0 && partno < 9 && start_cyl == 0 &&
2471  mbr_num_blocks >= img_blocks - 600 && mbr_num_blocks <= img_blocks &&
2472  ((partno == 1 && id_tag == 4) || (partno > 1 && id_tag == 2)))
2473  full_sparc_part|= (1 << (partno - 1));
2474 
2475  } else if(strcmp(name, "PALO header version:") == 0) {
2476  if(mkisofs)
2477  sprintf(buf, "-hppa-hdrversion %.f", num[0]);
2478  else
2479  sprintf(buf, "-boot_image any hppa_hdrversion=%.f", num[0]);
2480 
2481  } else if(strcmp(name, "HP-PA cmdline :") == 0) {
2482  if(mkisofs)
2483  sprintf(buf, "-hppa-cmdline ");
2484  else
2485  sprintf(buf, "-boot_image any hppa_cmdline=");
2486  Text_shellsafe(textpt, buf, 1);
2487 
2488  } else if(strcmp(name, "HP-PA 32-bit kernel:") == 0) {
2489  if(mkisofs)
2490  sprintf(buf, "-hppa-kernel-32 ");
2491  else
2492  sprintf(buf, "-boot_image any hppa_kernel_32=");
2493  Text_shellsafe(textpt, buf, 1);
2494 
2495  } else if(strcmp(name, "HP-PA 64-bit kernel:") == 0) {
2496  if(mkisofs)
2497  sprintf(buf, "-hppa-kernel-64 ");
2498  else
2499  sprintf(buf, "-boot_image any hppa_kernel_64=");
2500  Text_shellsafe(textpt, buf, 1);
2501 
2502  } else if(strcmp(name, "HP-PA ramdisk :") == 0) {
2503  if(mkisofs)
2504  sprintf(buf, "-hppa-ramdisk ");
2505  else
2506  sprintf(buf, "-boot_image any hppa_ramdisk=");
2507  Text_shellsafe(textpt, buf, 1);
2508 
2509  } else if(strcmp(name, "HP-PA bootloader :") == 0) {
2510  if(mkisofs)
2511  sprintf(buf, "-hppa-bootloader ");
2512  else
2513  sprintf(buf, "-boot_image any hppa_bootloader=");
2514  Text_shellsafe(textpt, buf, 1);
2515 
2516  } else if(strcmp(name, "DEC Alpha ldr adr :") == 0) {
2517  if(!have_alpha_ldr_path) {
2518  sprintf(xorriso->info_text,
2519  "Cannot enable DEC Alpha boot loader because it is not a data file in the ISO filesystem");
2520  if(!(flag & 5))
2521  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
2522  }
2523 
2524  } else if(strcmp(name, "DEC Alpha ldr path :") == 0) {
2525  if(mkisofs)
2526  sprintf(buf, "-alpha-boot ");
2527  else
2528  sprintf(buf, "-boot_image any alpha_boot=");
2529  Text_shellsafe(textpt, buf, 1);
2530 
2531  }
2532 
2533  if(buf[0])
2535  }
2536 
2537  if(appended_as_gpt == 2) {
2538  if(mkisofs)
2539  sprintf(buf, "-appended_part_as_gpt");
2540  else
2541  sprintf(buf, "-boot_image any appended_part_as=gpt");
2543  }
2544 
2545  if(have_sparc_part) {
2546  if(full_sparc_part == 255) {
2547  if(mkisofs) {
2548  sprintf(buf, "-G ");
2549  Xorriso_add_intvl_adr(xorriso, buf, (uint64_t) 0, (uint64_t) 15, "s",
2550  imported_iso);
2552  did_sysarea= 1;
2553  sprintf(buf, "-B ...");
2555  } else {
2556  sprintf(buf, "-boot_image any system_area=");
2557  Xorriso_add_intvl_adr(xorriso, buf, (uint64_t) 0, (uint64_t) 15, "s",
2558  imported_iso);
2560  did_sysarea= 1;
2561  for(i= 2; i <= 8; i++) {
2562  sprintf(buf, "-append_partition %d 0x00 .", i);
2564  }
2565  }
2566  cared_for_sparc= 1;
2567  } else if(!cared_for_sparc) {
2568  sprintf(xorriso->info_text,
2569  "Cannot enable SUN Disk Label because of non-trivial partition layout");
2570  if(!(flag & 5))
2571  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
2572  }
2573  }
2574  if(have_sysarea && !did_sysarea) {
2575  /* Zeroize old partition tables from -indev */
2576  if(mkisofs)
2577  sprintf(buf, "-G ");
2578  else
2579  sprintf(buf, "-boot_image any system_area=");
2580  Xorriso_add_intvl_adr(xorriso, buf, (uint64_t) 0, (uint64_t) 15, "s",
2581  imported_iso | ptable_killer);
2583  did_sysarea= 1;
2584  }
2585  if(have_sysarea) {
2586  strcpy(buf, "systemarea.img/");
2587  Xorriso_add_offset_size(xorriso, buf, (off_t) 0, (off_t) 16 * 2048, 0);
2589  }
2590  if(iso_mbr_part_type >= 0) {
2591  if(mkisofs)
2592  sprintf(buf, "-iso_mbr_part_type 0x%2.2x",
2593  (unsigned int) iso_mbr_part_type);
2594  else
2595  sprintf(buf, "-boot_image any iso_mbr_part_type=0x%2.2x",
2596  (unsigned int) iso_mbr_part_type);
2598 
2599  } else if(iso_gpt_part_idx >= 0) {
2600  if(mkisofs)
2601  sprintf(buf, "-iso_mbr_part_type ");
2602  else
2603  sprintf(buf, "-boot_image any iso_mbr_part_type=");
2604  Xorriso__format_guid(gpts[iso_gpt_part_idx].type_guid, buf + strlen(buf),
2605  0);
2607 
2608  }
2609 
2610  /* Issue commands related to El Torito */
2611  if(elto_count <= 0)
2612  goto after_el_torito;
2613 
2614  if(efi_boot_part == 1) {
2615  if(mkisofs)
2616  sprintf(buf, "-efi-boot-part --efi-boot-image");
2617  else
2618  sprintf(buf, "-boot_image any efi_boot_part=--efi-boot-image");
2620  }
2621  if(cat_path[0]) {
2622  if(mkisofs)
2623  sprintf(buf, "-c ");
2624  else
2625  sprintf(buf, "-boot_image any cat_path=");
2626  Text_shellsafe(cat_path, buf, 1);
2627  } else {
2628  if(mkisofs)
2629  sprintf(buf, "--boot-catalog-hide");
2630  else
2631  sprintf(buf, "-boot_image any cat_hidden=on");
2632  }
2634  for(idx= 0; idx < elto_count; idx++) {
2635  if(strcmp(et_imgs[idx].pltf, "UEFI") == 0 &&
2636  et_imgs[idx].extract_size <= 0) {
2637  ret= Xorriso_obtain_indev_readsize(xorriso, &indev_blocks, 0);
2638  if(ret > 0) {
2639  if(indev_blocks > et_imgs[idx].lba &&
2640  indev_blocks - et_imgs[idx].lba <= Xorriso_max_endless_uefi_sizE)
2641  et_imgs[idx].extract_size= indev_blocks - et_imgs[idx].lba;
2642  }
2643  if(et_imgs[idx].extract_size <= 0)
2644  continue;
2645  }
2646  sprintf(buf, "eltorito_img%d_", idx + 1);
2647  for(j= 0; j < 4 && et_imgs[idx].pltf[j] != 0; j++) {
2648  buf[strlen(buf) + 1]= 0;
2649  buf[strlen(buf)]= tolower(et_imgs[idx].pltf[j]);
2650  }
2651  strcat(buf, ".img/");
2652  Xorriso_add_offset_size(xorriso, buf, ((off_t) et_imgs[idx].lba) * 2048,
2653  ((off_t) et_imgs[idx].extract_size) * 2048, 0);
2655 
2656  if(et_imgs[idx].ld_seg != 0 && et_imgs[idx].ld_seg != 0x07c0) {
2657  if(!(flag & 5)) {
2658  sprintf(xorriso->info_text,
2659  "Cannot enable EL Torito boot image #%d because its Load Segment is neither 0x0 nor 0x7c0",
2660  idx + 1);
2661  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
2662  }
2663  continue;
2664  }
2665  if(idx > 0) {
2666  if(mkisofs)
2667  sprintf(buf, "-eltorito-alt-boot");
2668  else
2669  sprintf(buf, "-boot_image any next");
2671  }
2672  if(et_imgs[idx].path[0] == 0) {
2673  /* Check whether appended partition */;
2674  for(i= 0; i < mbr_count; i++)
2675  if((mbrpts[i].appended || !mbrpts[i].has_path) &&
2676  mbrpts[i].start_block == ((uint64_t) et_imgs[idx].lba) * 4 &&
2677  (mbrpts[i].block_count == (uint64_t) et_imgs[idx].ldsiz ||
2678  et_imgs[idx].ldsiz == 0 || et_imgs[idx].ldsiz == 1))
2679  break;
2680  if (i < mbr_count) {
2681  if(!mbrpts[i].appended) {
2682  mbrpts[i].appended= 1;
2683  if(!appended_as_gpt) {
2684  sprintf(buf, "-append_partition %lu 0x%lx ", (unsigned long) i + 1,
2685  (unsigned long) mbrpts[i].ptype);
2686  Xorriso_add_intvl_adr(xorriso, buf,
2687  (uint64_t) mbrpts[i].start_block,
2688  ((uint64_t) mbrpts[i].start_block) +
2689  mbrpts[i].block_count - 1,
2690  "d", imported_iso);
2692 
2693 #ifdef Not_any_more_because_padding_is_now_after_partitions
2694  appended_partition= 1;
2695 #endif
2696 
2697  buf[0]= 0;
2698  }
2699  }
2700  sprintf(app_pseudo_paths[idx],
2701  "--interval:appended_partition_%d_start_%lus_size_%lud:all::",
2702  i + 1,
2703  (unsigned long) et_imgs[idx].lba,
2704  (unsigned long) mbrpts[i].block_count);
2705  et_imgs[idx].path= app_pseudo_paths[idx];
2706  }
2707  if (et_imgs[idx].path[0] == 0 && efi_boot_part != 2) {
2708  for(i= 0; i < gpt_count; i++) {
2709  if(have_protective_msdos && (
2710  gpts[i].start_block == ((uint64_t) et_imgs[idx].lba) * 4 &&
2711  (gpts[i].block_count == (uint64_t) et_imgs[idx].ldsiz ||
2712  et_imgs[idx].ldsiz == 0 || et_imgs[idx].ldsiz == 1)))
2713  break;
2714  }
2715  if (i < gpt_count) {
2716  sprintf(app_pseudo_paths[idx],
2717  "--interval:appended_partition_%d_start_%lus_size_%lud:all::",
2718  i + 1,
2719  (unsigned long) et_imgs[idx].lba,
2720  (unsigned long) gpts[i].block_count);
2721  et_imgs[idx].path= app_pseudo_paths[idx];
2722  }
2723  }
2724 
2725  if (et_imgs[idx].path[0] == 0) {
2726 
2727  /* >>> need way to exploit .extract_size by cutting out from ISO */;
2728 
2729  }
2730 
2731  if (et_imgs[idx].path[0] == 0) {
2732  if(!(flag & 5)) {
2733  sprintf(xorriso->info_text,
2734  "Cannot enable EL Torito boot image #%d because it is not a data file in the ISO filesystem",
2735  idx + 1);
2736  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
2737  }
2738  buf[0]= 0;
2739  continue;
2740  }
2741  }
2742  if(et_imgs[idx].platform_id != 0xef) {
2743  if(mkisofs) {
2744  if(prev_pltf != et_imgs[idx].platform_id) {
2745  sprintf(buf, "-eltorito-platform 0x%2.2x", et_imgs[idx].platform_id);
2747  }
2748  prev_pltf= et_imgs[idx].platform_id;
2749  sprintf(buf, "-b ");
2750  } else {
2751  sprintf(buf, "-boot_image %s bin_path=", et_imgs[idx].boot_image_type);
2752  }
2753  } else {
2754  if(mkisofs)
2755  sprintf(buf, "-e ");
2756  else
2757  sprintf(buf, "-boot_image %s efi_path=", et_imgs[idx].boot_image_type);
2758  }
2759  Text_shellsafe(et_imgs[idx].path, buf, 1);
2761  if(!mkisofs) {
2762  sprintf(buf, "-boot_image any platform_id=0x%2.2x",
2763  et_imgs[idx].platform_id);
2765  }
2766  if(strcmp(et_imgs[idx].emul, "none") == 0) {
2767  if(mkisofs)
2768  sprintf(buf, "-no-emul-boot");
2769  else
2770  sprintf(buf, "-boot_image any emul_type=no_emulation");
2771  } else if(strcmp(et_imgs[idx].emul, "hd") == 0) {
2772  if(mkisofs)
2773  sprintf(buf, "-hard-disk-boot");
2774  else
2775  sprintf(buf, "-boot_image any emul_type=hard_disk");
2776  } else {
2777  if(mkisofs)
2778  buf[0]= 0;
2779  else
2780  sprintf(buf, "-boot_image any emul_type=diskette");
2781  }
2782  if(buf[0])
2784  if(et_imgs[idx].ldsiz >= 0) {
2785  if(mkisofs)
2786  sprintf(buf, "-boot-load-size %d", et_imgs[idx].ldsiz);
2787  else
2788  sprintf(buf, "-boot_image any load_size=%d", et_imgs[idx].ldsiz * 512);
2790  }
2791  if(et_imgs[idx].boot_info_table) {
2792  if(mkisofs)
2793  sprintf(buf, "-boot-info-table");
2794  else
2795  sprintf(buf, "-boot_image any boot_info_table=on");
2797  }
2798  if(et_imgs[idx].grub2_boot_info) {
2799  if(mkisofs)
2800  sprintf(buf, "--grub2-boot-info");
2801  else
2802  sprintf(buf, "-boot_image grub grub2_boot_info=on");
2804  }
2805  if(et_imgs[idx].id_string[0] != 0) {
2806  if(mkisofs)
2807  sprintf(buf, "-eltorito-id ");
2808  else
2809  sprintf(buf, "-boot_image any id_string=");
2810  Text_shellsafe(et_imgs[idx].id_string, buf, 1);
2812  }
2813  if(et_imgs[idx].sel_crit[0] != 0) {
2814  if(mkisofs)
2815  sprintf(buf, "-eltorito-selcrit ");
2816  else
2817  sprintf(buf, "-boot_image any sel_crit=");
2818  Text_shellsafe(et_imgs[idx].sel_crit, buf, 1);
2820  }
2821  if(et_imgs[idx].do_gpt_basdat) {
2822  if(mkisofs)
2823  sprintf(buf, "-isohybrid-gpt-basdat");
2824  else
2825  sprintf(buf, "-boot_image isolinux partition_entry=gpt_basdat");
2827  }
2828  if(et_imgs[idx].do_gpt_hfsplus) {
2829  if(mkisofs)
2830  sprintf(buf, "-isohybrid-gpt-hfsplus");
2831  else
2832  sprintf(buf, "-boot_image isolinux partition_entry=gpt_hfsplus");
2834  }
2835  if(et_imgs[idx].do_apm_hfsplus) {
2836  if(mkisofs)
2837  sprintf(buf, "-isohybrid-apm-hfsplus");
2838  else
2839  sprintf(buf, "-boot_image isolinux partition_entry=apm_hfsplus");
2841  }
2842  }
2843 after_el_torito:
2844 
2845  if((apm_count > 0 && !cared_for_apm) && !(flag & 5)) {
2846  sprintf(xorriso->info_text,
2847  "Cannot make proposal to produce APM of loaded image");
2848  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
2849  }
2850 
2851 #ifdef Not_any_more_because_padding_is_now_after_partitions
2852 
2853  if(appended_partition) {
2854  if(mkisofs)
2855  sprintf(buf, "-no-pad");
2856  else
2857  sprintf(buf, "-padding 0");
2859  }
2860 
2861 #endif /* Not_any_more_because_padding_is_now_after_partitions */
2862 
2863  ret= 1;
2864 ex:
2865  xorriso->show_hfs_cmds= NULL;
2866  Findjob_destroy(&job, 0);
2867  Xorriso_free_meM(apms);
2868  Xorriso_free_meM(gpts);
2869  Xorriso_free_meM(mbrpts);
2870  if(app_pseudo_paths != NULL) {
2871  for(i= 0; i < elto_count; i++)
2872  if(app_pseudo_paths[i] != NULL)
2873  Xorriso_free_meM(app_pseudo_paths[i]);
2874  Xorriso_free_meM(app_pseudo_paths);
2875  }
2876  Xorriso_free_meM(et_imgs);
2877  Xorriso_free_meM(lines);
2878  Xorriso_free_meM(buf);
2879  return(ret);
2880 
2881 #undef Xorriso_record_cmd_linE
2882 #undef Xorriso_record_boot_imglinE
2883 #undef Xorriso_max_endless_uefi_sizE
2884 
2885 }
2886 
2887 
2888 /* @param flag bit0= currently not significant:
2889  report is about El Torito rather than System Area
2890  bit1= report -as mkisofs options in cmds
2891  bit2= no sorry messages
2892  bit15= dispose cmds and boot_imgs
2893 */
2894 static int Xorriso_report_to_cmd(struct XorrisO *xorriso,
2895  char **et_lines, int et_line_count,
2896  char **sa_lines, int sa_line_count,
2897  char ***cmds, int *cmd_count,
2898  char ***boot_imgs, int *boot_img_count,
2899  int flag)
2900 {
2901  int ret= 0, i;
2902 
2903  if(flag & (1 << 15))
2904  {ret= 1; goto ex;}
2905  *cmds= NULL;
2906  *cmd_count= 0;
2907 
2908  /* Count commands */
2909  ret= Xorriso_scan_report_lines(xorriso, et_lines, et_line_count,
2910  sa_lines, sa_line_count, *cmds, cmd_count,
2911  *boot_imgs, boot_img_count,
2912  1 | (flag & 6));
2913  if(ret <= 0)
2914  goto ex;
2915 
2916  if(*cmd_count <= 0 && *boot_img_count <= 0)
2917  {ret= 2; goto ex;}
2918  if(*cmd_count > 0) {
2919  Xorriso_alloc_meM(*cmds, char *, *cmd_count);
2920  for(i= 0; i < *cmd_count; i++)
2921  (*cmds)[i]= NULL;
2922  }
2923  if(*boot_img_count > 0) {
2924  Xorriso_alloc_meM(*boot_imgs, char *, *boot_img_count);
2925  for(i= 0; i < *boot_img_count; i++)
2926  (*boot_imgs)[i]= NULL;
2927  }
2928 
2929  /* Record commands */
2930  ret= Xorriso_scan_report_lines(xorriso, et_lines, et_line_count,
2931  sa_lines, sa_line_count, *cmds, cmd_count,
2932  *boot_imgs, boot_img_count,
2933  flag & 6);
2934  if(ret <= 0)
2935  goto ex;
2936 
2937  ret= 1;
2938 ex:
2939  if(ret <= 0 || (flag & (1 << 15))) {
2940  if(*cmds != NULL) {
2941  for(i= 0; i < *cmd_count; i++)
2942  if((*cmds)[i] != NULL)
2943  Xorriso_free_meM((*cmds)[i]);
2944  Xorriso_free_meM(*cmds);
2945  *cmds= NULL;
2946  }
2947  if(*boot_imgs != NULL) {
2948  for(i= 0; i < *boot_img_count; i++)
2949  if((*boot_imgs)[i] != NULL)
2950  Xorriso_free_meM((*boot_imgs)[i]);
2951  Xorriso_free_meM(*boot_imgs);
2952  *boot_imgs= NULL;
2953  }
2954  }
2955  return(ret);
2956 }
2957 
2958 
2959 
2960 static void Xorriso_report_lines(struct XorrisO *xorriso,
2961  char **lines, int line_count)
2962 {
2963  int i;
2964 
2965  for(i = 0; i < line_count ; i++) {
2966  sprintf(xorriso->result_line, "%s\n", lines[i]);
2967  Xorriso_result(xorriso,0);
2968  }
2969 }
2970 
2971 
2972 /* @param flag bit0= report El Torito rather than System Area
2973  bit1= with form "cmd" do not report but rather execute
2974 */
2975 int Xorriso_report_system_area(struct XorrisO *xorriso, char *form, int flag)
2976 {
2977  int ret, line_count, cmd_count= 0, et_line_count= 0, sa_line_count= 0;
2978  int do_cmd= 0, as_mkisofs= 0, i, bin_count, boot_img_count= 0;
2979  char **lines = NULL, **et_lines= NULL, **sa_lines= NULL, **cmds= NULL;
2980  char **boot_imgs= NULL;
2981  uint8_t guid[16];
2982  IsoImage *image;
2983 
2984  if(strcmp(form, "cmd") == 0 || strcmp(form, "as_mkisofs") == 0 || (flag & 2))
2985  do_cmd= 1;
2986  if(strcmp(form, "as_mkisofs") == 0)
2987  as_mkisofs= 1;
2988 
2989  if(strcmp(form, "help") == 0) {
2990  if(flag & 1)
2991  ret= iso_image_report_el_torito(NULL, &et_lines, &et_line_count, 1);
2992  else
2993  ret= iso_image_report_system_area(NULL, &sa_lines, &sa_line_count, 1);
2994  if(ret <= 0)
2995  goto ex;
2996  sprintf(xorriso->result_line,
2997 "------------------------------------------------------------------------------\n");
2998  Xorriso_result(xorriso, 0);
2999  if(flag & 1)
3000  sprintf(xorriso->result_line, "With -report_el_torito \"plain\":\n");
3001  else
3002  sprintf(xorriso->result_line, "With -report_system_area \"plain\":\n");
3003  Xorriso_result(xorriso, 0);
3004  sprintf(xorriso->result_line,
3005 "------------------------------------------------------------------------------\n");
3006  Xorriso_result(xorriso, 0);
3007  sprintf(xorriso->result_line, "\n");
3008  Xorriso_result(xorriso, 0);
3009 
3010  } else if(strcmp(form, "") == 0 || strcmp(form, "plain") == 0 || do_cmd) {
3011  ret= Xorriso_get_volume(xorriso, &image, 0);
3012  if(ret <= 0)
3013  goto ex;
3014  if(do_cmd || (flag & 1))
3015  ret= iso_image_report_el_torito(image, &et_lines, &et_line_count, 0);
3016  if(ret < 0)
3017  goto ex;
3018  if(do_cmd || !(flag & 1))
3019  ret= iso_image_report_system_area(image, &sa_lines, &sa_line_count, 0);
3020  if(ret < 0)
3021  goto ex;
3022  if(do_cmd) {
3023  ret= Xorriso_report_to_cmd(xorriso, et_lines, et_line_count,
3024  sa_lines, sa_line_count, &cmds, &cmd_count,
3025  &boot_imgs, &boot_img_count,
3026  (flag & 1) | (as_mkisofs << 1));
3027  if(ret <= 0)
3028  goto ex;
3029  }
3030 
3031  } else if(strncmp(form, "gpt_crc_of:", 11) == 0 && !(flag & 1)) {
3032  ret = Xorriso_gpt_crc(xorriso, form + 11, 0);
3033  goto ex;
3034 
3035  } else if(strcmp(form, "make_guid") == 0 && !(flag & 1)) {
3036  ret= Xorriso_make_guid(xorriso, xorriso->result_line, 0);
3037  if(ret < 0)
3038  goto ex;
3039  strcat(xorriso->result_line, "\n");
3040  Xorriso_result(xorriso,0);
3041  goto ex;
3042 
3043  } else if(strcmp(form, "gpt_disk_guid") == 0 && !(flag & 1)) {
3044  ret= Xorriso_get_volume(xorriso, &image, 0);
3045  if(ret <= 0)
3046  goto ex;
3047  ret= iso_image_report_system_area(image, &sa_lines, &sa_line_count, 0);
3048  if(ret <= 0)
3049  goto ex;
3050  for(i= 0; i < sa_line_count; i++) {
3051  if(strncmp(sa_lines[i], "GPT disk GUID : ", 26) == 0) {
3052  ret= Hex_to_bin(sa_lines[i] + 26, 16, &bin_count, guid, 0);
3053  if(ret < 0 || bin_count != 16)
3054  break;
3055  Xorriso_format_guid(xorriso, guid, xorriso->result_line, 0);
3056  strcat(xorriso->result_line, "\n");
3057  Xorriso_result(xorriso,0);
3058  ret= 1;
3059  goto ex;
3060  }
3061  }
3062  ret= 1;
3063  goto ex;
3064 
3065  } else {
3066  sprintf(xorriso->info_text,
3067  "%s form parameter not recognized: ",
3068  flag & 1 ? "-report_el_torito" : "-report_system_area");
3069  Text_shellsafe(form, xorriso->info_text, 1);
3070  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
3071  ret= 0; goto ex;
3072  }
3073  if(ret < 0)
3074  goto ex;
3075  if(flag & 1) {
3076  lines= et_lines;
3077  line_count= et_line_count;
3078  } else {
3079  lines= sa_lines;
3080  line_count= sa_line_count;
3081  }
3082  if(!do_cmd) {
3083  if(lines == NULL || ret == 0) {
3084  if(flag & 1)
3085  strcpy(xorriso->info_text, "No El Torito information was loaded");
3086  else
3087  strcpy(xorriso->info_text, "No System Area was loaded");
3088  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
3089  ret= 2; goto ex;
3090  }
3091  if(line_count == 0) {
3092  if(flag & 1)
3093  strcpy(xorriso->info_text, "No El Torito information available");
3094  else
3095  strcpy(xorriso->info_text, "System Area only contains 0-bytes");
3096  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
3097  ret= 2; goto ex;
3098  }
3099  }
3100  if(flag & 2) {
3101  if(cmd_count > 0) {
3102  ret= Xorriso_execute_option(xorriso,
3103  "-boot_image any discard -boot_image any system_area=/dev/zero",
3104  1 | 16);
3105  if(ret <= 0)
3106  goto ex;
3107  for(i= 0; i < cmd_count; i++) {
3108  ret= Xorriso_execute_option(xorriso, cmds[i], 1 | 16);
3109  if(ret <= 0)
3110  goto ex;
3111  }
3112  sprintf(xorriso->info_text,
3113  "Replayed %d boot related commands", cmd_count);
3114  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
3115  } else {
3116  Xorriso_msgs_submit(xorriso, 0,
3117  "No proposals available for boot related commands",
3118  0, "NOTE", 0);
3119  ret= 2; goto ex;
3120  }
3121  } else if(do_cmd) {
3122  Xorriso_report_lines(xorriso, cmds, cmd_count);
3123  } else {
3124  Xorriso_report_lines(xorriso, lines, line_count);
3125  }
3126  ret= 1;
3127 ex:;
3128  Xorriso_report_to_cmd(xorriso, NULL, 0, NULL, 0, &cmds, &cmd_count,
3129  &boot_imgs, &boot_img_count, 1 << 15);
3130  if(et_lines != NULL)
3131  iso_image_report_el_torito(NULL, &et_lines, &et_line_count, 1 << 15);
3132  if(sa_lines != NULL)
3133  iso_image_report_system_area(NULL, &sa_lines, &sa_line_count, 1 << 15);
3134  return(ret);
3135 }
3136 
3137 
3138 /* @param flag bit15= dispose imgs
3139  */
3140 int Xorriso_list_boot_images(struct XorrisO *xorriso,
3141  char ***imgs, int *img_count, int flag)
3142 {
3143  int ret, cmd_count= 0, et_line_count= 0, sa_line_count= 0, boot_img_count= 0;
3144  char **et_lines= NULL, **sa_lines= NULL, **cmds= NULL, **boot_imgs= NULL;
3145  IsoImage *image;
3146 
3147  if(flag & (1 << 15)) {
3148  boot_imgs= *imgs;
3149  boot_img_count= *img_count;
3150  Xorriso_report_to_cmd(xorriso, NULL, 0, NULL, 0, &cmds, &cmd_count,
3151  &boot_imgs, &boot_img_count, 1 << 15);
3152  *imgs= NULL;
3153  *img_count= 0;
3154  return(1);
3155  }
3156 
3157  *imgs= NULL;
3158  *img_count= 0;
3159 
3160  ret= Xorriso_get_volume(xorriso, &image, 0);
3161  if(ret <= 0)
3162  goto ex;
3163  ret= iso_image_report_el_torito(image, &et_lines, &et_line_count, 0);
3164  if(ret < 0)
3165  goto ex;
3166  ret= iso_image_report_system_area(image, &sa_lines, &sa_line_count, 0);
3167  if(ret < 0)
3168  goto ex;
3169  ret= Xorriso_report_to_cmd(xorriso, et_lines, et_line_count,
3170  sa_lines, sa_line_count, &cmds, &cmd_count,
3171  &boot_imgs, &boot_img_count, 4);
3172  if(ret <= 0)
3173  goto ex;
3174  *imgs= boot_imgs;
3175  *img_count= boot_img_count;
3176  boot_imgs= NULL;
3177  boot_img_count= 0;
3178  ret= 1;
3179 ex:;
3180  Xorriso_report_to_cmd(xorriso, NULL, 0, NULL, 0, &cmds, &cmd_count,
3181  &boot_imgs, &boot_img_count, 1 << 15);
3182  if(et_lines != NULL)
3183  iso_image_report_el_torito(NULL, &et_lines, &et_line_count, 1 << 15);
3184  if(sa_lines != NULL)
3185  iso_image_report_system_area(NULL, &sa_lines, &sa_line_count, 1 << 15);
3186  return(ret);
3187 }
3188 
int Xorriso_destroy_di_array(struct XorrisO *xorriso, int flag)
Definition: base_obj.c:699
int Xorriso_destroy_hln_array(struct XorrisO *xorriso, int flag)
Definition: base_obj.c:675
int isoburn_drive_aquire(struct burn_drive_info *drive_infos[], char *adr, int flag)
Definition: burn_wrap.c:545
int isoburn_get_mount_params(struct burn_drive *d, int adr_mode, char *adr_value, int *lba, int *track, int *session, char volid[33], int flag)
Definition: burn_wrap.c:2105
int isoburn_read_iso_head(struct burn_drive *d, int lba, int *image_blocks, char *info, int flag)
Definition: burn_wrap.c:1301
void isoburn_drive_release(struct burn_drive *drive, int eject)
Definition: burn_wrap.c:1039
int Sectorbitmap_destroy(struct SectorbitmaP **o, int flag)
Definition: check_media.c:276
int Xorriso_afile_fopen(struct XorrisO *xorriso, char *filename, char *mode, FILE **ret_fp, int flag)
Definition: disk_ops.c:1780
int Xorriso_make_mount_cmd(struct XorrisO *xorriso, char *cmd, int lba, int track, int session, char *volid, char *devadr, char result[4096], int flag)
Definition: disk_ops.c:1831
int burn_drive_convert_fs_adr(char *path, char adr[])
Definition: drive.c:2338
void burn_drive_info_free(struct burn_drive_info drive_infos[])
Definition: drive.c:1528
int Xorriso_toc_line(struct XorrisO *xorriso, int flag)
Definition: drive_mgt.c:962
int Xorriso_msinfo(struct XorrisO *xorriso, int *msc1, int *msc2, int flag)
Definition: drive_mgt.c:2268
int Xorriso_obtain_indev_readsize(struct XorrisO *xorriso, uint32_t *blocks, int flag)
Definition: drive_mgt.c:3606
int Xorriso_get_drive_handles(struct XorrisO *xorriso, struct burn_drive_info **dinfo, struct burn_drive **drive, char *attempt, int flag)
Definition: drive_mgt.c:3511
int Xorriso_toc(struct XorrisO *xorriso, int flag)
Definition: drive_mgt.c:1033
int Xorriso_give_up_drive(struct XorrisO *xorriso, int flag)
Definition: drive_mgt.c:762
int iso_image_get_all_boot_imgs(IsoImage *image, int *num_boots, ElToritoBootImage ***boots, IsoFile ***bootnodes, int flag)
Definition: eltorito.c:724
int el_torito_get_boot_platform_id(ElToritoBootImage *bootimg)
Definition: eltorito.c:73
int el_torito_get_boot_media_type(ElToritoBootImage *bootimg, enum eltorito_boot_media_type *media_type)
Definition: eltorito.c:237
int iso_image_get_boot_image(IsoImage *image, ElToritoBootImage **boot, IsoFile **imgnode, IsoBoot **catnode)
Definition: eltorito.c:676
int el_torito_get_selection_crit(ElToritoBootImage *bootimg, uint8_t crit[20])
Definition: eltorito.c:171
int el_torito_get_id_string(ElToritoBootImage *bootimg, uint8_t id_string[28])
Definition: eltorito.c:156
int el_torito_get_isolinux_options(ElToritoBootImage *bootimg, int flag)
Definition: eltorito.c:231
int el_torito_seems_boot_info_table(ElToritoBootImage *bootimg, int flag)
Definition: eltorito.c:179
int el_torito_get_load_size(ElToritoBootImage *bootimg)
Definition: eltorito.c:114
static off_t file_size(struct burn_source *source)
Definition: file.c:96
int Findjob_set_action_target(struct FindjoB *o, int action, char *target, int flag)
Definition: findjob.c:1163
int Findjob_set_action_type(struct FindjoB *o, int action, int type, int flag)
Definition: findjob.c:1172
int Findjob_destroy(struct FindjoB **o, int flag)
Definition: findjob.c:401
int Findjob_new(struct FindjoB **o, char *start_path, int flag)
Definition: findjob.c:355
int Findjob_get_last_data_file_block(struct FindjoB *o, uint32_t *lba, int flag)
Definition: findjob.c:1112
#define SfileadrL
int iso_image_report_el_torito(IsoImage *image, char ***reply, int *line_count, int flag)
Definition: fs_image.c:5763
int iso_image_report_system_area(IsoImage *image, char ***result, int *line_count, int flag)
Definition: fs_image.c:5615
int iso_image_add_mips_boot_file(IsoImage *image, char *path, int flag)
Definition: image.c:862
void iso_image_unref(IsoImage *image)
Definition: image.c:225
int iso_image_set_hppa_palo(IsoImage *img, char *cmdline, char *bootloader, char *kernel_32, char *kernel_64, char *ramdisk, int flag)
Definition: image.c:1035
int iso_image_get_pvd_times(IsoImage *image, char **creation_time, char **modification_time, char **expiration_time, char **effective_time)
Definition: image.c:481
int iso_image_get_hppa_palo(IsoImage *img, char **cmdline, char **bootloader, char **kernel_32, char **kernel_64, char **ramdisk)
Definition: image.c:1066
int iso_image_get_session_md5(IsoImage *image, uint32_t *start_lba, uint32_t *end_lba, char md5[16], int flag)
Definition: image.c:832
int iso_image_give_up_mips_boot(IsoImage *image, int flag)
Definition: image.c:886
int iso_image_get_alpha_boot(IsoImage *img, char **boot_loader_path)
Definition: image.c:1092
const char * iso_image_get_volume_id(const IsoImage *image)
Definition: image.c:358
void iso_image_set_volume_id(IsoImage *image, const char *volume_id)
Definition: image.c:352
const char * iso_image_get_data_preparer_id(const IsoImage *image)
Definition: image.c:385
void iso_image_set_ignore_aclea(IsoImage *image, int what)
Definition: image.c:610
int iso_image_get_mips_boot_files(IsoImage *image, char *paths[15], int flag)
Definition: image.c:874
int iso_image_set_alpha_boot(IsoImage *img, char *boot_loader_path, int flag)
Definition: image.c:1079
void burn_preset_device_open(int exclusive, int blocking, int abort_on_busy)
Definition: init.c:204
int Xorriso_update_volid(struct XorrisO *xorriso, int flag)
Definition: iso_img.c:57
int Xorriso_set_hppa_boot_parm(struct XorrisO *xorriso, char *text, char *what, int flag)
Definition: iso_img.c:1268
int Xorriso_set_ignore_aclea(struct XorrisO *xorriso, int flag)
Definition: iso_img.c:39
int Xorriso_set_volid(struct XorrisO *xorriso, char *volid, int flag)
Definition: iso_img.c:335
int Xorriso_boot_item_status(struct XorrisO *xorriso, char *cat_path, char *bin_path, int platform_id, int patch_isolinux, int emul, off_t load_size, unsigned char *id_string, unsigned char *selection_crit, char *form, char *filter, FILE *fp, int flag)
Definition: iso_img.c:379
int Xorriso_set_change_pending(struct XorrisO *xorriso, int flag)
Definition: iso_img.c:1004
#define Xorriso_record_cmd_linE
static int Xorriso_report_to_cmd(struct XorrisO *xorriso, char **et_lines, int et_line_count, char **sa_lines, int sa_line_count, char ***cmds, int *cmd_count, char ***boot_imgs, int *boot_img_count, int flag)
Definition: iso_img.c:2894
int Xorriso_boot_image_status(struct XorrisO *xorriso, char *filter, FILE *fp, int flag)
Definition: iso_img.c:662
int Xorriso_boot_status_non_mbr(struct XorrisO *xorriso, IsoImage *image, char *filter, FILE *fp, int flag)
Definition: iso_img.c:560
int Xorriso__append_boot_params(char *line, ElToritoBootImage *bootimg, int flag)
Definition: iso_img.c:814
int Xorriso_get_volid(struct XorrisO *xorriso, char volid[33], int flag)
Definition: iso_img.c:357
static int Xorriso_scan_report_lines(struct XorrisO *xorriso, char **et_lines, int et_line_count, char **sa_lines, int sa_line_count, char **cmds, int *cmd_count, char **boot_imgs, int *boot_img_count, int flag)
Definition: iso_img.c:1660
int Xorriso_report_system_area(struct XorrisO *xorriso, char *form, int flag)
Definition: iso_img.c:2975
int Xorriso_add_offset_size(struct XorrisO *xorriso, char *buf, off_t byte_offset, off_t byte_size, int flag)
Definition: iso_img.c:1541
int Xorriso_status_hppa(struct XorrisO *xorriso, char *what, char *value, char *filter, FILE *fp, int flag)
Definition: iso_img.c:540
int Xorriso_record_cmd_line(struct XorrisO *xorriso, char *buf, char **cmds, int *cmd_count, int flag)
Definition: iso_img.c:1492
int Xorriso_change_is_pending(struct XorrisO *xorriso, int flag)
Definition: iso_img.c:995
static int Xorriso_report_pvd_time(struct XorrisO *xorriso, char *head, char *pvd_time, int flag)
Definition: iso_img.c:246
int Xorriso_create_empty_iso(struct XorrisO *xorriso, int flag)
Definition: iso_img.c:68
int Xorriso_show_boot_info(struct XorrisO *xorriso, int flag)
Definition: iso_img.c:835
static int Xorriso_search_eltorito_path(struct XorrisO *xorriso, struct elto_img_par *et_imgs, int elto_count, char *path, int ptype, int *found, int *efi_boot_part, int flag)
Definition: iso_img.c:1590
static int Xorriso_search_eltorito_lba(struct XorrisO *xorriso, struct elto_img_par *et_imgs, int elto_count, unsigned int lba, int *found, int flag)
Definition: iso_img.c:1613
int Xorriso_gpt_crc(struct XorrisO *xorriso, char *path, int flag)
Definition: iso_img.c:1410
int Xorriso_is_isohybrid(struct XorrisO *xorriso, IsoFile *bootimg_node, int flag)
Definition: iso_img.c:199
static int Xorriso_split_report_line(struct XorrisO *xorriso, char *line, int num_limit, char *name, char **contentpt, double *num, int *num_count, char **textpt, int flag)
Definition: iso_img.c:1442
int Xorriso_append_part_status(struct XorrisO *xorriso, IsoImage *image, char *filter, FILE *fp, int flag)
Definition: iso_img.c:627
int Xorriso_mount(struct XorrisO *xorriso, char *dev, int adr_mode, char *adr_value, char *cmd, int flag)
Definition: iso_img.c:1027
int Xorriso_assert_volid(struct XorrisO *xorriso, int msc1, int flag)
Definition: iso_img.c:159
int Xorriso_image_has_md5(struct XorrisO *xorriso, int flag)
Definition: iso_img.c:220
int Xorriso_pvd_info(struct XorrisO *xorriso, int flag)
Definition: iso_img.c:267
int Xorriso_highest_data_block(struct XorrisO *xorriso, uint32_t *high_block, int flag)
Definition: iso_img.c:1631
int Xorriso_set_alpha_boot(struct XorrisO *xorriso, char *path, int flag)
Definition: iso_img.c:1330
int Xorriso_list_boot_images(struct XorrisO *xorriso, char ***imgs, int *img_count, int flag)
Definition: iso_img.c:3140
#define Xorriso_record_boot_imglinE
int Xorriso_add_mips_boot_file(struct XorrisO *xorriso, char *path, int flag)
Definition: iso_img.c:1227
int Xorriso_coordinate_system_area(struct XorrisO *xorriso, int sa_type, int options, char *cmd, int flag)
Definition: iso_img.c:1357
static const char * un0(const char *text)
Definition: iso_img.c:238
int Xorriso_record_boot_info(struct XorrisO *xorriso, int flag)
Definition: iso_img.c:125
static void Xorriso_report_lines(struct XorrisO *xorriso, char **lines, int line_count)
Definition: iso_img.c:2960
static int Xorriso_register_eltorito_gpt(struct XorrisO *xorriso, struct elto_img_par *et_img, int ptype, int *efi_boot_part, int *first_efi, int flag)
Definition: iso_img.c:1565
int Xorriso_add_intvl_adr(struct XorrisO *xorriso, char *buf, uint64_t start_adr, uint64_t end_adr, char *suffix, int flag)
Definition: iso_img.c:1515
#define Xorriso_max_endless_uefi_sizE
int Xorriso_get_volume(struct XorrisO *xorriso, IsoImage **volume, int flag)
Definition: iso_img.c:966
int Xorriso_findi(struct XorrisO *xorriso, struct FindjoB *job, void *boss_iter, off_t boss_mem, void *dir_node_generic, char *dir_path, struct stat *dir_stbuf, int depth, int flag)
Definition: iso_manip.c:3355
int Xorriso__file_start_lba(IsoNode *node, int *lba, int flag)
Definition: iso_tree.c:2259
int Xorriso_iso_lstat(struct XorrisO *xorriso, char *path, struct stat *stbuf, int flag)
Definition: iso_tree.c:363
int Xorriso_path_from_node(struct XorrisO *xorriso, IsoNode *in_node, char path[4096], int flag)
Definition: iso_tree.c:399
int Xorriso_path_from_lba(struct XorrisO *xorriso, IsoNode *node, int lba, char path[4096], int flag)
Definition: iso_tree.c:459
int isoburn_ropt_destroy(struct isoburn_read_opts **o, int flag)
Definition: isoburn.c:886
int isoburn_ropt_set_data_cache(struct isoburn_read_opts *o, int cache_tiles, int tile_blocks, int flag)
Definition: isoburn.c:896
int isoburn_ropt_new(struct isoburn_read_opts **new_o, int flag)
Definition: isoburn.c:842
int isoburn_ropt_set_extensions(struct isoburn_read_opts *o, int ext)
Definition: isoburn.c:949
int isoburn_ropt_set_input_charset(struct isoburn_read_opts *o, char *input_charset)
Definition: isoburn.c:1027
int isoburn_ropt_set_truncate_mode(struct isoburn_read_opts *o, int mode, int length)
Definition: isoburn.c:1075
int isoburn_set_read_pacifier(struct burn_drive *drive, int(*read_pacifier)(IsoImage *, IsoFileSource *), void *read_handle)
Definition: isofs_wrap.c:706
int isoburn_read_image(struct burn_drive *d, struct isoburn_read_opts *read_opts, IsoImage **image)
Definition: isofs_wrap.c:142
IsoImage * isoburn_get_attached_image(struct burn_drive *d)
Definition: isofs_wrap.c:92
int Xorriso_report_iso_error(struct XorrisO *xorriso, char *victim, int iso_error_code, char msg_text[], int os_errno, char min_severity[], int flag)
Definition: lib_mgt.c:430
int Xorriso_format_guid(struct XorrisO *xorriso, uint8_t guid[16], char *line, int flag)
Definition: lib_mgt.c:1009
int Xorriso_make_guid(struct XorrisO *xorriso, char *line, int flag)
Definition: lib_mgt.c:1020
int Xorriso_process_msg_queues(struct XorrisO *xorriso, int flag)
Definition: lib_mgt.c:519
int burn_read_data(struct burn_drive *d, off_t byte_address, char data[], off_t data_size, off_t *data_count, int flag)
Definition: read.c:441
#define BURN_DRIVE_ADR_LEN
Definition: libburn.h:1041
#define isoburn_ropt_pretend_blank
Definition: libisoburn.h:930
#define ISO_SUCCESS
Definition: libisofs.h:8719
eltorito_boot_media_type
Definition: libisofs.h:334
@ ELTORITO_HARD_DISC_EMUL
Definition: libisofs.h:336
@ ELTORITO_FLOPPY_EMUL
Definition: libisofs.h:335
uint32_t iso_crc32_gpt(unsigned char *data, int count, int flag)
Definition: system_area.c:2513
int Xorriso__bourne_to_reg(char bourne_expr[], char reg_expr[], int flag)
Definition: misc_funct.c:1162
int Sregex_match(char *pattern, char *text, int flag)
Definition: misc_funct.c:1006
char * Text_shellsafe(char *in_text, char *out_text, int flag)
Definition: misc_funct.c:1044
int Xorriso__format_guid(uint8_t guid[16], char *text, int flag)
Definition: misc_funct.c:1341
char * Xorriso__hide_mode_text(int hide_mode, int flag)
Definition: misc_funct.c:1273
int Hex_to_bin(char *hex, int bin_size, int *bin_count, unsigned char *bin_data, int flag)
Definition: misc_funct.c:1080
int System_uname(char **sysname, char **release, char **version, char **machine, int flag)
Definition: misc_funct.c:794
int Decode_ecma119_format(struct tm *erg, char *text, int flag)
Definition: misc_funct.c:461
int Xorriso_execute_option(struct XorrisO *xorriso, char *line, int flag)
Definition: parse_exec.c:2126
int Xorriso_execv(struct XorrisO *xorriso, char *cmd, int in_argc, char **in_argv, char *env_path, int *stdin_pipe, int *stdout_pipe, pid_t *forked_pid, int *status, int flag)
Definition: parse_exec.c:2973
int Xorriso_iso_file_open(struct XorrisO *xorriso, char *pathname, void *node_pt, void **stream, int flag)
Definition: read_run.c:66
int Xorriso_iso_file_close(struct XorrisO *xorriso, void **stream, int flag)
Definition: read_run.c:169
int Xorriso_iso_file_read(struct XorrisO *xorriso, void *stream, char *buf, int count, int flag)
Definition: read_run.c:145
int Sfile_off_t_text(char text[80], off_t num, int flag)
Definition: sfile.c:389
#define Xorriso_free_meM(pt)
Definition: sfile.h:27
#define Xorriso_alloc_meM(pt, typ, count)
Definition: sfile.h:19
Definition: node.h:149
Definition: node.h:100
int system_area_options
char publisher[129]
unsigned char boot_id_string[29]
char volset_id[129]
int boot_image_cat_hidden
char boot_image_bin_form[16]
uint8_t appended_part_gpt_flags[8]
int linux_scsi_dev_family
char boot_image_cat_path[4096]
int keep_boot_image
char abstract_file[38]
int boot_platform_id
char indev[4096]
int show_hfs_cmd_count
int boot_image_emul
int appended_as_gpt
int boot_efi_default
char system_id[33]
int ino_behavior
char volid[33]
char result_line[10 *4096]
int volset_change_pending
char loaded_boot_cat_path[4096]
int no_volset_present
struct SectorbitmaP * in_sector_map
unsigned char boot_selection_crit[21]
char * appended_partitions[8]
int drives_exclusive
char info_text[10 *4096]
uint8_t appended_part_type_guids[8][16]
char ascii_disc_label[129]
char system_area_disk_path[4096]
int mount_opts_flag
int file_name_limit
int show_hfs_cmd_flag
char ** show_hfs_cmds
int volid_default
void * in_volset_handle
char * in_charset
int system_area_clear_loaded
int hln_change_pending
char boot_image_bin_path[4096]
void * out_drive_handle
char loaded_volid[33]
off_t boot_image_load_size
char assert_volid[4096]
void * in_drive_handle
char outdev[4096]
char copyright_file[38]
char application_id[129]
char assert_volid_sev[80]
char grub2_sparc_core[4096]
int patch_isolinux_image
int toc_emulation_flag
int loaded_boot_bin_lba
char biblio_file[38]
uint8_t appended_part_types[8]
struct burn_drive * drive
Definition: libburn.h:664
enum burn_disc_status status
Definition: transport.h:204
int start_lba
Definition: transport.h:341
int end_lba
Definition: transport.h:342
char * id_string
Definition: iso_img.c:1558
char b[8]
Definition: iso_img.c:1557
char emul[8]
Definition: iso_img.c:1557
char * path
Definition: iso_img.c:1558
unsigned int ld_seg
Definition: iso_img.c:1555
unsigned int platform_id
Definition: iso_img.c:1555
unsigned long int lba
Definition: iso_img.c:1556
int do_gpt_basdat
Definition: iso_img.c:1554
unsigned int hdpt
Definition: iso_img.c:1555
int grub2_boot_info
Definition: iso_img.c:1553
char pltf[8]
Definition: iso_img.c:1557
int do_gpt_hfsplus
Definition: iso_img.c:1554
char boot_image_type[16]
Definition: iso_img.c:1557
unsigned long int extract_size
Definition: iso_img.c:1556
int do_apm_hfsplus
Definition: iso_img.c:1554
char * sel_crit
Definition: iso_img.c:1558
int boot_info_table
Definition: iso_img.c:1553
int Xorriso_msgs_submit(struct XorrisO *xorriso, int error_code, char msg_text[], int os_errno, char severity[], int flag)
Definition: text_io.c:2504
int Xorriso_no_findjob(struct XorrisO *xorriso, char *cmd, int flag)
Definition: text_io.c:4110
int Xorriso_info(struct XorrisO *xorriso, int flag)
Definition: text_io.c:2367
int Xorriso_status_result(struct XorrisO *xorriso, char *filter, FILE *fp, int flag)
Definition: text_io.c:2687
int Xorriso_result(struct XorrisO *xorriso, int flag)
Definition: text_io.c:2337
int Xorriso_parse_guid(struct XorrisO *xorriso, char *text, uint8_t guid[16], int flag)
Definition: write_run.c:3764
#define Xorriso_max_appended_partitionS