"Fossies" - the Fresh Open Source Software Archive

Member "libisoburn-1.5.4/xorriso/emulators.c" (18 Nov 2020, 105825 Bytes) of package /linux/misc/libisoburn-1.5.4.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "emulators.c" see the Fossies "Dox" file reference documentation and the last Fossies "Diffs" side-by-side code changes report: 1.5.0_vs_1.5.2.

    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 the implementation of emulators for mkisofs and cdrecord.
    9 */
   10 
   11 #ifdef HAVE_CONFIG_H
   12 #include "../config.h"
   13 #endif
   14 
   15 #include <ctype.h>
   16 #include <sys/types.h>
   17 #include <unistd.h>
   18 #include <stdlib.h>
   19 #include <stdio.h>
   20 #include <string.h>
   21 #include <sys/stat.h>
   22 #include <sys/time.h>
   23 #include <time.h>
   24 #include <fcntl.h>
   25 #include <errno.h>
   26 
   27 #include "xorriso.h"
   28 #include "xorriso_private.h"
   29 #include "xorrisoburn.h"
   30 
   31 
   32 int Xorriso_cdrskin_uses_stdout(struct XorrisO *xorriso, int argc, char **argv,
   33                                 int flag)
   34 {
   35  int i;
   36 
   37  for(i= 0; i < argc; i++) {
   38    if(strcmp(argv[i], "dev=-") == 0 ||
   39       strcmp(argv[i], "dev=stdio:/dev/fd/1") == 0 ||
   40       strcmp(argv[i], "-dev=-") == 0 ||
   41       strcmp(argv[i], "-dev=stdio:/dev/fd/1") == 0)
   42      return(1);
   43  }
   44  return(0);
   45 }
   46 
   47 
   48 int Xorriso_cdrskin_help(struct XorrisO *xorriso, int flag)
   49 {
   50  static char helptext[][80]= {
   51 "Usage: xorriso -as cdrecord [options|source_addresses]",
   52 "Note: This is not cdrecord. See xorriso -help, xorriso -version, man xorrecord",
   53 "Options:",
   54 "\t-version\tprint version information and exit emulation",
   55 "\t--devices\tprint list of available MMC drives and exit emulation",
   56 "\tdev=target\tpseudo-SCSI target to use as CD-Recorder",
   57 "\tdrive_scsi_dev_family=sr|scd|sg\t\tselect Linux device type",
   58 "\t--drive_not_exclusive\tdo not try to prevent use of busy drive",
   59 "\t-v\t\tincrement verbose level by one",
   60 "\t-V\t\tincrement SCSI command transport verbose level by one",
   61 "\t-checkdrive\tcheck if a driver for the drive is present",
   62 "\t-inq\t\tdo an inquiry for the drive",
   63 "\tspeed=#\t\tset speed of drive",
   64 "\tblank=type\tblank a CD-RW disc (see blank=help)",
   65 "\tfs=#\t\tSet fifo size to # (0 to disable, default is 4 MB)",
   66 "\t-eject\t\teject the disk after doing the work",
   67 "\t-dummy\t\tdo everything with laser turned off",
   68 "\t-msinfo\t\tretrieve multi-session info for mkisofs >= 1.10",
   69 "\t-toc\t\tretrieve and print TOC/PMA data",
   70 "\t-atip\t\tretrieve media state, print \"Is *erasable\"",
   71 "\t-multi\t\tgenerate a TOC that allows multi session",
   72 "\t--multi_if_possible\tapply -multi if the medium supports it",
   73 "\t-waiti\t\twait until input is available before opening SCSI",
   74 "\t-tao\t\tWrite disk in TAO mode.",
   75 "\t-dao\t\tWrite disk in SAO mode.",
   76 "\t-sao\t\tWrite disk in SAO mode.",
   77 "\ttsize=#\t\tannounces exact size of source data",
   78 "\tpadsize=#\tAmount of padding",
   79 "\t-data\t\tSubsequent tracks are CD-ROM data mode 1 (default)",
   80 "\t-isosize\tUse iso9660 file system size for next data track",
   81 "\t-pad\t\tpadsize=30k",
   82 "\t-nopad\t\tDo not pad",
   83 "\tminbuf=\t\tKeep drive buffer hungry",
   84 "\tmodesty_on_drive=\tLike minbuf=, but with more parameters",
   85 "\t-immed\t\tEquivalent to minbuf=75",
   86 "\t--grow_overwriteable_iso\temulate multi-session on DVD+RW, BD-RE",
   87 "\twrite_start_address=#\t\twrite to byte address on DVD+RW, BD-RE",
   88 "\tstream_recording=on|number\ttry to get full speed on DVD-RAM, BD",
   89 "\tuse_immed_bit=on|off|default\tcontrol use of Immed bit",
   90 "\tdvd_obs=default|32k|64k\t\tbytes per DVD/BD write operation",
   91 "\tstdio_sync=on|off|end|number\twhether to fsync output to \"stdio:\"",
   92 "\t--no_rc\t\tDo not execute xorriso startup files",
   93 "\t-help\t\tprint this text to stderr and exit emulation",
   94 "Actually this is the integrated ISO RockRidge filesystem manipulator xorriso",
   95 "lending its libburn capabilities to a very limited cdrecord emulation. Only",
   96 "a single data track can be burnt to blank, appendable or overwritable media.",
   97 "A much more elaborate cdrecord emulator is cdrskin from the libburn package.",
   98 "",
   99 #ifdef Xorriso_GNU_xorrisO
  100 "Report bugs to: bug-xorriso@gnu.org , or in private to: scdbackup@gmx.net .",
  101 "xorriso home page: <https://www.gnu.org/software/xorriso/>",
  102 "General help using GNU software: <https://www.gnu.org/gethelp/>",
  103 #else
  104 "Report any bugs to bug-xorriso@gnu.org or in private to scdbackup@gmx.net .",
  105 #endif
  106 "@End_of_helptexT@"
  107 };
  108  int i;
  109 
  110  for(i= 0; strcmp(helptext[i], "@End_of_helptexT@")!=0; i++) {
  111    sprintf(xorriso->info_text, "%s\n", helptext[i]);
  112    Xorriso_info(xorriso,0);
  113  }
  114  return(1);
  115 }
  116 
  117 
  118 /* micro version of cdrskin */
  119 int Xorriso_cdrskin(struct XorrisO *xorriso, char *whom, int argc, char **argv,
  120                     int flag)
  121 {
  122  int ret, i, k, mem_do_close, aq_ret, eject_ret, msc1, msc2, hflag;
  123  int do_atip= 0, do_checkdrive= 0, do_eject= 0, do_scanbus= 0;
  124  int do_toc= 0, do_verbous= 0, do_version= 0, do_help= 0, do_waiti= 0;
  125  int do_multi= 0, do_msinfo= 0, do_grow= 0, do_isosize= 0, do_xa1= 0;
  126  int do_auto_close= 0;
  127  double write_start_address= -1.0, tsize= -1.0, mem_auto_close;
  128  char *track_source= NULL, *dev_adr= NULL, *cpt;
  129  char mem_report_about_text[80], *report_about= "SORRY", blank_mode[80];
  130  char speed[80], *argpt;
  131 
  132  /* cdrecord 2.01 options which are not scheduled for implementation, yet */
  133  static char ignored_partial_options[][41]= {
  134    "timeout=", "debug=", "kdebug=", "kd=", "driver=", "ts=",
  135    "pregap=", "defpregap=", "mcn=", "isrc=", "index=", "textfile=",
  136    "pktsize=", "cuefile=",
  137    "gracetime=",
  138 
  139    "assert_write_lba=", "fifo_start_at=", "dev_translation=",
  140    "fallback_program=",
  141    "tao_to_sao_tsize=", 
  142    
  143    "direct_write_amount=", "msifile=",
  144 
  145    ""
  146  };
  147  static char ignored_full_options[][41]= {
  148    "-d", "-silent", "-s", "-setdropts", "-prcap",
  149    "-reset", "-abort", "-overburn", "-ignsize", "-useinfo",
  150    "-fix", "-nofix",
  151    "-raw", "-raw96p", "-raw16",
  152    "-clone", "-text",
  153    "-cdi", "-preemp", "-nopreemp", "-copy", "-nocopy",
  154    "-scms", "-shorttrack", "-noshorttrack", "-packet", "-noclose",
  155    "-media-info", "-minfo",
  156    "-load", "-lock", "-raw96r", "-swab",
  157    "-force", "-format",
  158 
  159    "--adjust_speed_to_drive", "--allow_emulated_drives", "--allow_setuid",
  160    "--allow_untested_media", "--any_track", "--demand_a_drive", 
  161    "--fifo_disable", "--fifo_start_empty", "--fill_up_media",
  162    "--list_ignored_options", "--no_rc", "--no_convert_fs_adr",
  163    "--prodvd_cli_compatible", "--single_track", 
  164    "--tell_media_space",
  165 
  166    ""
  167  };
  168 
  169 static char blank_help[][80]= {
  170 "Blanking options:",
  171 "\tall\t\tblank the entire disk",
  172 "\tdisc\t\tblank the entire disk",
  173 "\tdisk\t\tblank the entire disk",
  174 "\tfast\t\tminimally blank the entire disk",
  175 "\tminimal\t\tminimally blank the entire disk",
  176 "\tas_needed\tblank or format medium to make it ready for (re-)use",
  177 "\tdeformat\t\tblank a formatted DVD-RW",
  178 "\tdeformat_quickest\tminimally blank a formatted DVD-RW to DAO only",
  179 "\tformat_overwrite\tformat a DVD-RW to \"Restricted Overwrite\"",
  180 "@End_of_helptexT@"
  181 };
  182 
  183  mem_do_close= xorriso->do_close;
  184  mem_auto_close= xorriso->auto_close;
  185  Xorriso_alloc_meM(track_source, char, SfileadrL);
  186  Xorriso_alloc_meM(dev_adr, char, SfileadrL);
  187 
  188  strcpy(mem_report_about_text, xorriso->report_about_text);
  189 
  190  track_source[0]= 0;
  191  dev_adr[0]= 0;
  192  blank_mode[0]= 0;
  193  speed[0]= 0;
  194 
  195  if(xorriso->in_drive_handle != NULL) {
  196    ret= Xorriso_option_dev(xorriso, "", 1|32); /* give up indev */
  197    if(ret!=1)
  198      goto ex;
  199  }
  200 
  201 
  202  /* Assess plan, make settings */
  203  for(i= 0; i<argc; i++) {
  204    sprintf(xorriso->info_text, "-as %s: ", whom);
  205    Text_shellsafe(argv[i], xorriso->info_text, 1);
  206    Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0);
  207 
  208    argpt= argv[i];
  209    if (strncmp(argpt, "--", 2) == 0 && strlen(argpt) > 3)
  210      argpt++;
  211 
  212    for(k=0;ignored_partial_options[k][0]!=0;k++) {
  213      if(argpt[0]=='-')
  214        if(strncmp(argpt+1,ignored_partial_options[k],
  215                             strlen(ignored_partial_options[k]))==0) {
  216          argpt++;
  217          goto no_volunteer;
  218        }
  219      if(strncmp(argpt,ignored_partial_options[k],
  220                         strlen(ignored_partial_options[k]))==0)
  221        goto no_volunteer;
  222    }
  223    for(k=0;ignored_full_options[k][0]!=0;k++)
  224      if(strcmp(argpt,ignored_full_options[k])==0)
  225        goto no_volunteer;
  226    if(0) {
  227 no_volunteer:;
  228      sprintf(xorriso->info_text, "-as %s: Ignored option ", whom);
  229      Text_shellsafe(argpt, xorriso->info_text, 1);
  230      Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
  231  continue;
  232    }
  233 
  234    if(strcmp(argpt, "-atip")==0) {
  235      do_atip= 1;
  236    } else if(strcmp(argpt, "-audio")==0) {
  237      sprintf(xorriso->info_text, "-as %s: Option -audio not supported.", whom);
  238      Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
  239      ret= 0; goto ex;
  240    } else if(strncmp(argpt, "-blank=", 7)==0 ||
  241              strncmp(argpt, "blank=", 6)==0) {
  242      cpt= strchr(argpt, '=')+1;
  243      if(strcmp(cpt,"all")==0 || strcmp(cpt,"disc")==0
  244         || strcmp(cpt,"disk")==0) {
  245        strcpy(blank_mode, "all");
  246      } else if(strcmp(cpt,"fast")==0 || strcmp(cpt,"minimal")==0) {
  247        strcpy(blank_mode, "fast");
  248      } else if(strcmp(cpt,"help")==0) {
  249        strcpy(blank_mode, "help");
  250      } else if(strcmp(cpt,"deformat")==0 ||
  251                strcmp(cpt,"deformat_sequential")==0 ||
  252                strcmp(cpt,"deformat_quickest")==0 ||
  253                strcmp(cpt,"deformat_sequential_quickest")==0) {
  254        strcpy(blank_mode, cpt);
  255      } else if(strcmp(cpt,"format_overwrite")==0) {
  256        strcpy(blank_mode, "format_overwrite");
  257      } else if(strcmp(cpt,"as_needed")==0) {
  258        strcpy(blank_mode, "as_needed");
  259      } else {
  260        sprintf(xorriso->info_text, "-as %s: blank=", whom);
  261        Text_shellsafe(cpt, xorriso->info_text, 1);
  262        strcat(xorriso->info_text, " not supported. See blank=help .");
  263        Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
  264        ret= 0; goto ex;
  265      }
  266    } else if(strcmp(argpt, "-checkdrive")==0) {
  267      do_checkdrive= 1;
  268    } else if(strcmp(argpt, "-dao")==0) {
  269      xorriso->do_tao= -1;
  270    } else if(strcmp(argpt, "-data")==0) {
  271      /* ok */;
  272    } else if(strncmp(argpt, "-dev=", 5)==0 ||
  273              strncmp(argpt, "dev=", 4)==0) {
  274      cpt= strchr(argpt, '=')+1;
  275      strcpy(dev_adr, cpt);
  276    } else if(strcmp(argv[i], "--devices")==0) {      /* intentional: argv[i] */
  277      do_scanbus= 2;
  278    } else if(strcmp(argv[i], "--drive_not_exclusive") == 0) { /* intentional */
  279      Xorriso_option_drive_access(xorriso, "shared:unrestricted", 0);
  280    } else if(strncmp(argpt,"driveropts=", 11)==0 ||
  281              strncmp(argpt,"-driveropts=", 12)==0) {
  282      if(strcmp(argpt+11, "help")==0) {
  283        fprintf(stderr,"Driver options:\n");
  284        fprintf(stderr,
  285                "burnfree\tPrepare writer to use BURN-Free technology\n");
  286      } 
  287    } else if(strcmp(argpt, "-dummy")==0) {
  288      xorriso->do_dummy= 1;
  289    } else if(strncmp(argpt, "-dvd_obs=", 9)==0 ||
  290              strncmp(argpt, "dvd_obs=", 8)==0) {
  291      cpt= strchr(argpt, '=') + 1;
  292      Xorriso_option_dvd_obs(xorriso, cpt, 0);
  293    } else if(strcmp(argpt, "-eject")==0) {
  294      do_eject= 1;
  295    } else if(strncmp(argpt, "-fs=", 4)==0 || strncmp(argpt, "fs=", 3)==0) {
  296      cpt= strchr(argpt, '=')+1;
  297      ret= Xorriso_option_fs(xorriso, cpt, 0);
  298      if(ret<=0)
  299        goto ex;
  300    } else if(strcmp(argv[i], "--grow_overwriteable_iso")==0 ||
  301              strcmp(argv[i], "--grow_overwritable_iso")==0 ||
  302              strcmp(argv[i], "--grow_overriteable_iso")==0
  303              ) { /* (A history of typos) */
  304                                                      /* intentional: argv[i] */
  305      do_grow= 1;
  306    } else if(strcmp(argpt, "-help")==0) {
  307      do_help= 1;
  308    } else if(strcmp(argpt, "-isosize")==0) {
  309      do_isosize= 1;
  310    } else if(strcmp(argpt, "-inq")==0) {
  311      do_checkdrive= 2;
  312    } else if(strcmp(argpt, "-mode2")==0) {
  313      Xorriso_msgs_submit(xorriso, 0,
  314                      "Defaulting option -mode2 to option -data", 0, "NOTE", 0);
  315    } else if(strcmp(argpt, "-msinfo")==0) {
  316      do_msinfo= 1;
  317    } else if(strcmp(argpt, "-multi")==0) {
  318      do_multi= 1;
  319      do_auto_close= 0;
  320    } else if(strcmp(argv[i], "--multi_if_possible") == 0) {
  321      do_multi= 1;
  322      do_auto_close= 1;
  323    } else if(strcmp(argpt, "-nopad")==0) {
  324      xorriso->padding= 0;
  325    } else if(strcmp(argv[i], "--no_rc")==0) { /* intentional: argv[i] */
  326      /* already performed in Xorriso_prescan_args */;
  327    } else if(strcmp(argpt, "-pad")==0) {
  328      xorriso->padding= 15*2048;
  329    } else if(strncmp(argpt, "-padsize=", 9)==0 ||
  330              strncmp(argpt, "padsize=", 8)==0) {
  331      cpt= strchr(argpt, '=')+1;
  332      ret= Xorriso_option_padding(xorriso, cpt, 0);
  333      if(ret<=0)
  334        goto ex;
  335    } else if(strcmp(argpt, "-sao")==0) {
  336      xorriso->do_tao= -1;
  337    } else if(strcmp(argpt, "-scanbus")==0) {
  338      sprintf(xorriso->info_text, "-as %s: Option -scanbus not supported.",
  339              whom);
  340      Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
  341      ret= 0; goto ex;
  342    } else if(strncmp(argpt, "-speed=", 7)==0 ||
  343              strncmp(argpt, "speed=", 6)==0) {
  344      cpt= strchr(argpt, '=')+1;
  345      strncpy(speed, cpt, 79);
  346      speed[79]= 0;
  347    } else if(strncmp(argpt, "-stream_recording=", 18)==0 ||
  348              strncmp(argpt, "stream_recording=", 17)==0) {
  349      cpt= strchr(argpt, '=')+1;
  350      Xorriso_option_stream_recording(xorriso, cpt, 0);
  351 
  352    } else if(strncmp(argpt, "-use_immed_bit=", 15) == 0 ||
  353              strncmp(argpt, "use_immed_bit=", 14) == 0) {
  354      cpt= strchr(argpt, '=') + 1;
  355      Xorriso_option_use_immed_bit(xorriso, cpt, 0);
  356 
  357    } else if(strcmp(argpt, "-immed") == 0) {
  358      Xorriso_option_modesty_on_drive(xorriso, "75", 0);
  359 
  360    } else if(strncmp(argpt, "-minbuf=", 8) == 0 ||
  361              strncmp(argpt, "minbuf=", 7) == 0 ||
  362              strncmp(argpt, "-modesty_on_drive=", 18) == 0 ||
  363              strncmp(argpt, "modesty_on_drive=", 17) == 0) {
  364      cpt= strchr(argpt, '=') + 1;
  365      Xorriso_option_modesty_on_drive(xorriso, cpt, 0);
  366 
  367    } else if(strncmp(argpt, "-drive_scsi_dev_family=", 23) == 0 ||
  368              strncmp(argpt, "drive_scsi_dev_family=", 22) == 0) {
  369      cpt= strchr(argpt, '=') + 1;
  370      Xorriso_option_scsi_dev_family(xorriso, cpt, 0);
  371 
  372    } else if(strncmp(argpt, "-stdio_sync=", 12)==0 ||
  373              strncmp(argpt, "stdio_sync=", 11)==0) {
  374      cpt= strchr(argpt, '=') + 1;
  375      Xorriso_option_stdio_sync(xorriso, cpt, 0);
  376    } else if(strcmp(argpt, "-tao")==0) {
  377      xorriso->do_tao= 1;
  378    } else if(strcmp(argpt, "-toc")==0 || strcmp(argv[i], "--long_toc")==0) {
  379                                              /* intentional: argpt , argv[i] */
  380      do_toc= 1;
  381    } else if(strncmp(argpt, "-tsize=", 7)==0 ||
  382              strncmp(argpt, "tsize=", 6)==0) {
  383      cpt= strchr(argpt, '=')+1;
  384      tsize= Scanf_io_size(cpt, 1);
  385      if(tsize > 1024.0*1024.0*1024.0*1024.0*1024.0) {
  386        sprintf(xorriso->info_text, "-as %s: much too large: %s",whom, argpt);
  387        Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
  388        ret= 0; goto ex;
  389      }
  390    } else if(strcmp(argv[i], "-V")==0 || strcmp(argpt,"-Verbose")==0) {
  391      Xorriso_option_scsi_log(xorriso, "on", 0);
  392    } else if(strcmp(argv[i], "-v")==0 || strcmp(argpt,"-verbose")==0) {
  393      do_verbous++;
  394    } else if(strcmp(argv[i], "-vv")==0) { /* intentional: argv[i] */
  395      do_verbous+= 2;
  396    } else if(strcmp(argv[i], "-vvv")==0) { /* intentional: argv[i] */
  397      do_verbous+= 3;
  398    } else if(strcmp(argpt, "-version")==0) {
  399      do_version= 1;
  400    } else if(strcmp(argpt, "-waiti")==0) {
  401      do_waiti= 1;
  402    } else if(strncmp(argv[i], "write_start_address=", 20)==0) {
  403                                                      /* intentional: argv[i] */
  404      write_start_address= Scanf_io_size(argv[i]+20,0);
  405    } else if(strcmp(argpt, "-xa")==0) {
  406      Xorriso_msgs_submit(xorriso, 0,
  407                         "Defaulting option -xa to option -data", 0, "NOTE", 0);
  408    } else if(strcmp(argpt, "-xa1")==0) {
  409      if(do_xa1 == 0)
  410        do_xa1= 1;
  411    } else if(strcmp(argv[i], "--xa1-ignore")==0) { /* intentional: argv[i] */
  412      do_xa1= -1;
  413    } else if(strcmp(argpt, "-xa2")==0) {
  414      Xorriso_msgs_submit(xorriso, 0,
  415                        "Defaulting option -xa2 to option -data", 0, "NOTE", 0);
  416    } else if(strcmp(argpt, "-xamix")==0) {
  417      Xorriso_msgs_submit(xorriso, 0,
  418    "Option -xamix not implemented and data not yet convertible to other modes",
  419                          0, "FATAL", 0);
  420      ret= 0; goto ex;
  421    } else if(argpt[0]=='-' && argpt[1]!=0) {
  422      sprintf(xorriso->info_text, "-as %s: Unknown option ", whom);
  423      Text_shellsafe(argv[i], xorriso->info_text, 1);
  424      Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
  425      ret= 0; goto ex;
  426    } else {
  427      if(track_source[0]) {
  428        sprintf(xorriso->info_text, "-as %s: Surplus track source ", whom);
  429        Text_shellsafe(argv[i], xorriso->info_text, 1);
  430        Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
  431        sprintf(xorriso->info_text, "First and only track source is ");
  432        Text_shellsafe(track_source, xorriso->info_text, 1);
  433        Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
  434        ret= 0; goto ex;
  435      }
  436      if(Sfile_str(track_source, argv[i], 0)<=0)
  437        {ret= -1; goto ex;}
  438    }
  439  }
  440 
  441  /* Perform actions */
  442  Xorriso_option_report_about(xorriso, "NOTE", 0);
  443  if(do_version) {
  444    sprintf(xorriso->result_line, "Cdrecord 2.01-Emulation Copyright (C) 2019 see libburnia-project.org xorriso\n");
  445    Xorriso_result(xorriso, 1);
  446    Xorriso_option_version(xorriso, 0);
  447  }
  448 
  449  if(do_help) {
  450    Xorriso_cdrskin_help(xorriso, 0);
  451  }
  452  if(strcmp(blank_mode, "help")==0) {
  453    for(i= 0; strcmp(blank_help[i], "@End_of_helptexT@")!=0; i++) {
  454      sprintf(xorriso->info_text, "%s\n", blank_help[i]);
  455      Xorriso_info(xorriso,0);
  456    }
  457  }
  458  if(do_help || strcmp(blank_mode, "help") == 0 || do_version) {
  459    ret= 1; goto ex;
  460  }
  461 
  462  if(do_verbous<=0)
  463    report_about= "NOTE";
  464  else if(do_verbous<=2)
  465    report_about= "UPDATE";
  466  else if(do_verbous==3)
  467    report_about= "DEBUG";
  468  else
  469    report_about= "ALL";
  470  Xorriso_option_report_about(xorriso, report_about, 0);
  471 
  472  if(do_scanbus) {
  473    if(do_scanbus==1)
  474      /* >>> would need -scanbus compatible output and input format */;
  475    else
  476      Xorriso_option_devices(xorriso, 0);
  477    ret= 1; goto ex;
  478  }
  479 
  480  if(!(do_checkdrive || do_atip || do_toc || blank_mode[0] || track_source[0] ||
  481       do_eject || do_msinfo)) {
  482    sprintf(xorriso->info_text,
  483            "-as cdrskin: No option specified, which would cause an action.");
  484    Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
  485    ret= 1; goto ex;
  486  }
  487 
  488  if(do_waiti) {
  489    sprintf(xorriso->info_text,
  490        "xorriso: Option -waiti pauses program until input appears at stdin\n");
  491    Xorriso_info(xorriso,0);
  492    sprintf(xorriso->result_line, "Waiting for data on stdin...\n");
  493    Xorriso_result(xorriso, 1);
  494    for(ret= 0; ret==0; )
  495      ret= Wait_for_input(0,1000000,0);
  496    if(ret<0 || feof(stdin)) {
  497      Xorriso_msgs_submit(xorriso, 0,
  498                     "stdin produces exception rather than data", 0, "NOTE", 0);
  499    }
  500    sprintf(xorriso->info_text, "xorriso: Option -waiti pausing is done.\n");
  501  }
  502  if(dev_adr[0]) {
  503    hflag= 2 | 64;       /* ts B11201 no more:  | 32 */
  504    if(!do_grow)
  505      hflag|= 8; /* consider overwritables as blank */
  506    ret= Xorriso_option_dev(xorriso, dev_adr, hflag);
  507    if(ret<=0)
  508      goto ex;
  509  }
  510 
  511  if(xorriso->out_drive_handle==NULL) {
  512    sprintf(xorriso->info_text, "-as %s: No output drive selected", whom);
  513    Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
  514    ret= 0; goto ex;
  515  }
  516 
  517  if(do_msinfo) {
  518    ret= Xorriso_msinfo(xorriso, &msc1, &msc2, 2 | !!do_grow);
  519    if(ret<=0)
  520      goto ex;
  521    sprintf(xorriso->result_line, "%d,%d\n", msc1, msc2);
  522    Xorriso_result(xorriso, 1);
  523  }
  524 
  525  if(speed[0]) {
  526    ret= Xorriso_option_speed(xorriso, speed, 0);
  527    if(ret<=0)
  528      goto ex;
  529  }
  530 
  531  if(do_checkdrive) {
  532    ret= Xorriso_atip(xorriso, 2-(do_checkdrive==2));
  533    if(ret<=0)
  534      goto ex;
  535  }
  536  if(do_atip) {
  537    ret= Xorriso_atip(xorriso, 0);
  538    if(ret<=0)
  539      goto ex;
  540  }
  541  if(do_toc) {
  542    ret= Xorriso_option_toc(xorriso, 0);
  543    if(ret<=0)
  544      goto ex;
  545  }
  546  if(strcmp(blank_mode, "format_overwrite")==0) {
  547    ret= Xorriso_option_blank(xorriso, "fast", 1);
  548    if(ret<=0)
  549      goto ex;
  550  } else if(blank_mode[0]) {
  551    ret= Xorriso_option_blank(xorriso, blank_mode, 0);
  552    if(ret<=0)
  553      goto ex;
  554  }
  555  if(track_source[0]) {
  556    xorriso->do_close= !do_multi;
  557    xorriso->auto_close= do_auto_close;
  558    ret= Xorriso_burn_track(xorriso, (off_t) write_start_address,
  559                            track_source, (off_t) tsize,
  560                    (!!do_grow) | ((!!do_isosize) << 1) | ((do_xa1 == 1) << 2));
  561    if(ret == 2) {
  562      ret= Xorriso_retry_burn_track(xorriso, (off_t) write_start_address,
  563                            track_source, (off_t) tsize,
  564                    (!!do_grow) | ((!!do_isosize) << 1) | ((do_xa1 == 1) << 2));
  565    }
  566    aq_ret= Xorriso_reaquire_outdev(xorriso, 2*(ret>0));
  567    if(ret<=0 && ret<aq_ret)
  568      goto ex;
  569    if(aq_ret<=0)
  570      {ret= aq_ret; goto ex;}
  571  }
  572 
  573  ret= 1;
  574 ex:;
  575  if(do_eject && ret>=0) {
  576    eject_ret= Xorriso_option_eject(xorriso, "out", 0);
  577    if(eject_ret<ret)
  578      ret= eject_ret;
  579  }
  580  if(ret<=0) {
  581    sprintf(xorriso->info_text, "-as %s: Job could not be performed properly.",
  582            whom);
  583    Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
  584  }
  585  Xorriso_option_report_about(xorriso, mem_report_about_text, 0);
  586  xorriso->do_close= mem_do_close;
  587  xorriso->auto_close= mem_auto_close;
  588  Xorriso_free_meM(dev_adr);
  589  Xorriso_free_meM(track_source);
  590  return(ret);
  591 }
  592 
  593 
  594 /* This function shall know all options of mkisofs, genisoimage, xorrisofs, ...
  595    and the number of arguments which they expect and consume.
  596 */
  597 int Xorriso_genisofs_count_args(struct XorrisO *xorriso, int argc, char **argv,
  598                                 int *count, int flag)
  599 {
  600  int i;
  601  char *cmd;
  602 
  603  static char partial_options[][41]= {
  604     "errctl=",
  605     "isolinux_mbr=", "--modification-date=",
  606     ""
  607  };
  608  static char arg0_options[][41]= {
  609     "-allow-leading-dots", "-ldots", "-allow-lowercase", "-allow-multidot",
  610     "-cache-inodes", "-no-cache-inodes", "-eltorito-alt-boot",
  611     "-hard-disk-boot", "-no-emul-boot", "-no-boot", "-boot-info-table",
  612     "-check-oldnames", "-d", "-D", "-dvd-video", "-f", "-gui", "-graft-points",
  613     "-hide-joliet-trans-tbl", "-hide-rr-moved", "-J", "-joliet-long", "-l",
  614     "-L", "-max-iso9660-filenames", "-N", "-nobak", "-no-bak",
  615     "-no-limit-pathtables", "-force-rr", "-no-rr",
  616     "-no-split-symlink-components", "-no-split-symlink-fields", "-pad",
  617     "-no-pad", "-posix-H", "-posix-L", "-posix-P", "-print-size",
  618     "-quiet", "-R", "-r", "-relaxed-filenames", "-rrip110", "-rrip112",
  619     "-split-output", "-T", "-UDF", "-udf", "-udf-symlinks", "-no-udf-symlinks",
  620     "-U", "-no-iso-translate", "-v", "-XA", "-xa", "-z",
  621     "-hfs", "-no-hfs", "-apple", "-probe", "-no-desktop", "-mac-name",
  622     "-part", "-icon-position", "-chrp-t", "-hfs-unlock", "--cap", "--netatalk",
  623     "--double", "--ethershare", "--ushare", "--exchange", "--sgi", "--xinet",
  624     "--macbin", "--single", "--dave", "--sfm", "--osx-double", "--osx-hfs",
  625     "-debug", "-omit-period", "-disable-deep-relocation", "-joliet",
  626     "-full-iso9660-filenames", "-follow-links", "-help",
  627     "-transparent-compression",
  628     "-omit-version-number", "-rational-rock", "-rock", "-translation-table",
  629     "-untranslated-filenames", "-verbose", "-version", "-g", "-h",
  630     "-no-mac-files", "-chrp-boot",
  631     "--hardlinks", "--acl", "--xattr", "--xattr-any", "--md5", "--for_backup",
  632     "--protective-msdos-label", "--boot-catalog-hide", "--no-emul-toc",
  633     "--emul-toc", "-disallow_dir_id_ext", "--old-empty",
  634     "--old-root-no-md5", "--old-root-devno", "--old-root-no-ino",
  635     "--no_rc", "--norock", "-hfsplus", "-fat", "-chrp-boot-part",
  636     "-isohybrid-gpt-basdat", "-isohybrid-gpt-hfsplus",
  637     "-isohybrid-apm-hfsplus", "--grub2-boot-info", "-joliet-utf16",
  638     "-appended_part_as_gpt", "-appended_part_as_apm", "--mbr-force-bootable",
  639     "-part_like_isohybrid", "--zisofs-version-2", "--zisofs2-susp-z2",
  640     "--zisofs2-susp-zf",
  641     ""
  642  };
  643  static char arg1_options[][41]= {
  644     "-abstract", "-A", "-appid", "--application_use",
  645     "-biblio", "-b", "-B", "-boot-load-seg",
  646     "-boot-load-size", "-C", "-c", "-check-session", "-copyright",
  647     "-dir-mode", "-eltorito-id", "-eltorito-selcrit",
  648     "-file-mode", "-G", "-gid", "-hide", "-hide-list",
  649     "-hidden", "-hidden-list", "-hide-joliet", "-hide-joliet-list",
  650     "-hide-hfsplus", "-hide-hfsplus-list",
  651     "-hide-udf", "-hide-udf-list", "-input-charset", "-output-charset",
  652     "-iso-level", "-jcharset", "-log-file", "-m", "-exclude-list", "-M",
  653     "-dev", "-new-dir-mode", "-o", "-p", "-preparer",
  654     "-path-list", "-publisher", "-root",
  655     "-old-root", "-s", "-sectype", "-sort", "-sparc-boot", "-sparc-label",
  656     "-stream-media-size", "-stream-file-name", "-sunx86-boot", "-sunx86-label",
  657     "-sysid", "-table-name", "-ucs-level", "-uid", "-V", "-volset",
  658     "-volset-size", "-volset-seqno", "-x", "-P",
  659     "-map", "-magic", "-hfs-creator", "-hfs-type", "-boot-hfs-file", "-auto",
  660     "-cluster-size", "-hide-hfs", "-hide-hfs-list", "-hfs-volid",
  661     "-root-info", "-prep-boot", "-input-hfs-charset", "-output-hfs-charset",
  662     "-hfs-bless", "-hfs-parms", 
  663     "-eltorito-boot", "-generic-boot", "-eltorito-catalog", "-cdrecord-params",
  664     "-errctl", "-exclude", "-prev-session", "-output", "-use-fileversion",
  665     "-volid", "-old-exclude",
  666     "-alpha-boot", "-hppa-cmdline", "-hppa-kernel-32", "-hppa-kernel-64",
  667     "-hppa-bootloader", "-hppa-ramdisk", "-mips-boot", "-mipsel-boot",
  668     "-jigdo-jigdo", "-jigdo-template", "-jigdo-min-file-size",
  669     "-jigdo-force-md5", "-jigdo-force-checksum",
  670     "-md5-list", "-checksum-list",
  671     "-jigdo-exclude", "-jigdo-map",
  672     "-jigdo-template-compress", "-jigdo-checksum-algorithm",
  673     "-checksum_algorithm_iso", "-checksum_algorithm_template",
  674     "--stdio_sync", "--quoted_path_list", "--efi-boot", "--embedded-boot",
  675     "-isohybrid-mbr", "-e", "-partition_offset", "-partition_hd_cyl",
  676     "-partition_sec_hd", "-partition_cyl_align", "-untranslated_name_len",
  677     "-rr_reloc_dir", "-hfsplus-serial-no", "-prep-boot-part", "-efi-boot-part",
  678     "-hfsplus-block-size", "-apm-block-size", "--grub2-mbr",
  679     "--grub2-sparc-core", "--sort-weight-list", "--sort-weight-patterns",
  680     "-hppa-hdrversion", "-file_name_limit", "--set_all_file_dates",
  681     "--gpt_disk_guid", "-iso_mbr_part_type", "-eltorito-platform",
  682     ""
  683  };
  684  static char arg2_options[][41]= {
  685     "-hfs-bless-by", "--scdbackup_tag", "--sort-weight",
  686     ""
  687  };
  688  static char arg3_options[][41]= {
  689     "-append_partition", "-hfsplus-file-creator-type",
  690     ""
  691  };
  692  static char final_options[][41]= {
  693     "-find",
  694     ""
  695  };
  696 
  697  cmd= argv[0];
  698  *count= 0;
  699  for(i=0; partial_options[i][0]!=0; i++)
  700    if(strncmp(partial_options[i], cmd, strlen(partial_options[i]))==0)
  701      return(1);
  702  for(i=0; arg0_options[i][0]!=0; i++)
  703    if(strcmp(arg0_options[i], cmd)==0)
  704      return(1);
  705  *count= 1;
  706  for(i=0; arg1_options[i][0]!=0; i++)
  707    if(strcmp(arg1_options[i], cmd)==0)
  708      return(1);
  709  *count= 2;
  710  for(i=0; arg2_options[i][0]!=0; i++)
  711    if(strcmp(arg2_options[i], cmd)==0)
  712      return(1);
  713  *count= 3;
  714  for(i=0; arg3_options[i][0]!=0; i++)
  715    if(strcmp(arg3_options[i], cmd)==0)
  716      return(1);
  717  *count= argc - 1;
  718  for(i=0; final_options[i][0]!=0; i++)
  719    if(strcmp(final_options[i], cmd)==0)
  720      return(1);
  721  *count= 0;
  722  return(0); 
  723 }
  724 
  725 
  726 /* @param flag bit0= do not report eventual ignore decision
  727 */
  728 int Xorriso_genisofs_ignore(struct XorrisO *xorriso, char *whom,
  729                             char *argpt, int *i, int flag)
  730 {
  731  /* mkisofs 2.01 options which are not scheduled for implementation, yet */
  732  static char ignored_arg0_options[][41]= {
  733    "-allow-leading-dots", "-ldots", "-allow-multidot",
  734    "-cache-inodes", "-check-oldnames",
  735    "-L", "-no-bak", "-no-cache-inodes",
  736    "-no-split-symlink-components", "-no-split-symlink-fields", "-nobak",
  737    "-force-rr", "-T", "-translation-table",
  738    "-no-iso-translate",
  739    ""
  740  };
  741  static char ignored_arg1_options[][41]= {
  742    "-check-session", "-hide-hfs", "-hide-hfs-list",
  743    "-table-name", "-volset-seqno", "-volset-size", "-sort",
  744    ""
  745  };
  746  int k;
  747 
  748  for(k=0;ignored_arg0_options[k][0]!=0;k++)
  749    if(strcmp(argpt,ignored_arg0_options[k])==0)
  750      goto no_volunteer;
  751  for(k=0;ignored_arg1_options[k][0]!=0;k++)
  752    if(strcmp(argpt,ignored_arg1_options[k])==0) {
  753      (*i)++;
  754      goto no_volunteer;
  755    }
  756  return(0);
  757 no_volunteer:;
  758  sprintf(xorriso->info_text, "-as %s: Ignored option ", whom);
  759  Text_shellsafe(argpt, xorriso->info_text, 1);
  760  if(!(flag & 1))
  761    Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
  762  return(1);
  763 }
  764 
  765 
  766 int Xorriso_genisofs_add_boot(struct XorrisO *xorriso, int flag)
  767 {
  768  int ret;
  769 
  770  if(xorriso->boot_img_size_default && xorriso->boot_image_emul == 0)
  771    xorriso->boot_img_full_size= 1;
  772  ret= Xorriso_attach_boot_image(xorriso, 0);
  773  if(ret <= 0)
  774    xorriso->boot_image_bin_path[0]= 0;
  775  return(ret);
  776 }
  777 
  778 
  779 int Xorriso_genisofs_help(struct XorrisO *xorriso, int flag)
  780 {
  781  static char helptext[][160]= {
  782 "Usage: xorriso -as mkisofs [options] file...",
  783 "Note: This is not mkisofs. See xorriso -help, xorriso -version, man xorrisofs",
  784 "Options:",
  785 "  -f, -follow-links           Follow symbolic links",
  786 "  -graft-points               Allow to use graft points for filenames",
  787 "  -help                       Print option help",
  788 "  -hfsplus                    Generate HFS+ filesystem",
  789 "  -hfsplus-file-creator-type CREATOR TYPE iso_rr_path",
  790 "                              Attach creator and type to a File",
  791 "  -hfs-bless FOLDER_NAME      Name of Folder to be blessed",
  792 "  -hfs-bless-by BLESS_TYPE ISO_RR_PATH",
  793 "                              Bless ISO_RR_PATH by BLESS_TYPE {p,i,s,9,x}",
  794 "  -hfsplus-serial-no HEXSTRING",
  795 "                              HFS serial number: 16 characters [0-9a-fA-F]",
  796 "  -hfsplus-block-size NUMBER  Set HFS+ block size",
  797 "  -apm-block-size NUMBER      Set Apple Partition Map block size",
  798 "  -hide GLOBFILE              Hide ISO9660/RR file",
  799 "  -hide-list FILE             File with list of ISO9660/RR files to hide",
  800 "  -hide-joliet GLOBFILE       Hide Joliet file",
  801 "  -hide-joliet-list FILE      File with list of Joliet files to hide",
  802 "  -hide-hfsplus GLOBFILE      Hide HFS+ file",
  803 "  -hide-hfsplus-list FILE     File with list of HFS+ files to hide",
  804 "  -input-charset CHARSET      Local input charset for file name conversion",
  805 "  -output-charset CHARSET     Output charset for file name conversion",
  806 "  -iso-level LEVEL            Set ISO9660 conformance level (1..3) or 4 for ISO9660 version 2",
  807 "  -disallow_dir_id_ext        Do not allow dot in ISO directory names",
  808 "  -J, -joliet                 Generate Joliet directory information",
  809 "  -joliet-long                Allow Joliet file names to be 103 Unicode characters",
  810 "  -joliet-utf16               Encode Joliet names in UTF-16BE rather than UCS-2",
  811 "  -U, -untranslated-filenames Allow Untranslated filenames (for HPUX & AIX - violates ISO9660).",
  812 "  -untranslated_name_len LEN  Allow up to LEN (1..96) name characters (heavily violates ISO9660).",
  813 "  -allow-lowercase            Allow lower case characters in addition to the current character set (violates ISO9660)",
  814 "  -relaxed-filenames          Allow 7 bit ASCII except lower case characters (violates ISO9660)",
  815 "  -d, -omit-period            Omit trailing periods from filenames (violates ISO9660)",
  816 "  -l, -full-iso9660-filenames Allow full 31 character filenames for ISO9660 names",
  817 "  -max-iso9660-filenames      Allow 37 character filenames for ISO9660 names (violates ISO9660)",
  818 "  -N, -omit-version-number    Omit version number from ISO9660 filename (violates ISO9660)",
  819 "  -D, -disable-deep-relocation",
  820 "                              Disable deep directory relocation (violates ISO9660)",
  821 "  -hide-rr-moved              Relocate deep directories to /.rr_moved",
  822 "  -rr_reloc_dir NAME          Set deep directory relocation target in root",
  823 "  -uid uid                    Make the owner of all files this uid.",
  824 "  -gid gid                    Make the group owner of all files this gid.",
  825 "  -o FILE, -output FILE       Set output file name",
  826 "  -m GLOBFILE, -exclude GLOBFILE",
  827 "                              Exclude file name",
  828 "  -x FILE, -old-exclude FILE  Exclude file name",
  829 "  -exclude-list FILE          File with list of file names to exclude",
  830 "  -pad                        Pad output by 300k (default)",
  831 "  -no-pad                     Do not pad output",
  832 "  -M FILE, -prev-session FILE Set path to previous session to merge",
  833 "  -C PARAMS, -cdrecord-params PARAMS",
  834 "                              Magic paramters from cdrecord",
  835 "  -dir-mode mode              Make the mode of all directories this mode.",
  836 "  -file-mode mode             Make the mode of all plain files this mode.",
  837 "  -path-list FILE             File with list of pathnames to process",
  838 "  --quoted_path_list FILE     File with list of quoted pathnames to process",
  839 "  -print-size                 Print estimated filesystem size and exit",
  840 "  -quiet                      Run quietly",
  841 "  -gui                        Switch behaviour for GUI",
  842 "  -R, -rock                   Generate Rock Ridge directory information",
  843 "  -r, -rational-rock          Generate rationalized Rock Ridge directory information",
  844 "  --norock                    Disable Rock Ridge. (Strongly discouraged !)",
  845 "  -file_name_limit LEN        Set truncation limit for Rock Ridge names",
  846 "  --hardlinks                 Record eventual hard link relations of files",
  847 "  --acl                       Record eventual ACLs of files",
  848 "  --xattr                     Record eventual user space xattr of files",
  849 "  --xattr-any                 Record xattr of any namespace, not only user.",
  850 "  --md5                       Compute and record MD5 checksums of data files",
  851 "  --scdbackup_tag PATH NAME   With --md5 record a scdbackup checksum tag",
  852 "  --for_backup                Use all options which improve backup fidelity",
  853 "  -V ID, -volid ID            Set Volume ID",
  854 "  -volset ID                  Set Volume set ID",
  855 "  -publisher PUB              Set Volume publisher",
  856 "  -A ID, -appid ID            Set Application ID",
  857 "  -sysid ID                   Set System ID",
  858 "  -p PREP, -preparer PREP     Set Volume preparer",
  859 "  -abstract FILE              Set Abstract filename",
  860 "  -biblio FILE                Set Bibliographic filename",
  861 "  -copyright FILE             Set Copyright filename",
  862 "  --application_use CHAR|PATH  Set content of Application Use field",
  863 "  -jigdo-jigdo FILE           Produce a jigdo .jigdo file as well as the .iso",
  864 "  -jigdo-template FILE        Produce a jigdo .template file as well as the .iso",
  865 "  -jigdo-min-file-size SIZE   Minimum size for a file to be listed in the jigdo file", 
  866 "  -jigdo-force-checksum PTRN  Pattern(s) where files MUST match an externally-supplied checksum",
  867 "  -jigdo-force-md5 PATTERN    Outdated alias of -jigdo-force-checksum",
  868 "  -jigdo-exclude PATTERN      Pattern(s) to exclude from the jigdo file",
  869 "  -jigdo-map PATTERN1=PATTERN2",
  870 "                              Pattern(s) to map paths (e.g. Debian=/mirror/debian)",
  871 "  -checksum-list FILE         File containing checksums of the files that should be checked",
  872 "  -md5-list FILE              Outdated alias of -checksum-list",
  873 "  -jigdo-checksum-algorithm ALGORITHM",
  874 "                              Choose algorithm for file matching checksums: md5, sha256",
  875 "                              Expected in the -checksum-list FILE, written into .jigdo file.",
  876 "  -jigdo-template-compress ALGORITHM",
  877 "                              Choose to use gzip or bzip2 compression for template data; default is gzip",
  878 "  -checksum_algorithm_iso alg1,alg2,...",
  879 "                              Specify the checksum types desired for the output image (in .jigdo)",
  880 "  -checksum_algorithm_template alg1,alg2,...",
  881 "                              Specify the checksum types desired for the output jigdo template",
  882 "  -eltorito-platform          Set El Torito platform id for the next boot entry",
  883 "  -b FILE, -eltorito-boot FILE",
  884 "                              Set El Torito boot image name",
  885 "  -eltorito-alt-boot          Start specifying alternative El Torito boot parameters",
  886 "  --efi-boot FILE             Set El Torito EFI boot image name and type",
  887 "  -e FILE                     Set EFI boot image name (more rawly)",
  888 "  -c FILE, -eltorito-catalog FILE",
  889 "                              Set El Torito boot catalog name",
  890 "  --boot-catalog-hide         Hide boot catalog from ISO9660/RR and Joliet",
  891 "  -boot-load-size #           Set numbers of load sectors",
  892 "  -hard-disk-boot             Boot image is a hard disk image",
  893 "  -no-emul-boot               Boot image is 'no emulation' image",
  894 "  -boot-info-table            Patch boot image with info table",
  895 "  --grub2-boot-info           Patch boot image at byte 2548",
  896 "  -eltorito-id ID             Set El Torito Id String",
  897 "  -eltorito-selcrit HEXBYTES  Set El Torito Selection Criteria",
  898 "  -isohybrid-gpt-basdat       Mark El Torito boot image as Basic Data in GPT",
  899 "  -isohybrid-gpt-hfsplus      Mark El Torito boot image as HFS+ in GPT",
  900 "  -isohybrid-apm-hfsplus      Mark El Torito boot image as HFS+ in APM",
  901 "  -part_like_isohybrid        Mark in MBR, GPT, APM without -isohybrid-mbr",
  902 "  -iso_mbr_part_type          Set type byte or GUID of ISO partition in MBR",
  903 "                              or type GUID if a GPT ISO partition emerges.",
  904 "  --gpt_disk_guid GUID        Set GPT disk GUID or choose automatic GUID",
  905 "  -G FILE, -generic-boot FILE Set generic boot image name",
  906 "  --embedded-boot FILE        Alias of -G",
  907 "  --protective-msdos-label    Patch System Area by partition table",
  908 "  --mbr-force-bootable        Enforce existence of bootable flag in MBR",
  909 "  -partition_offset LBA       Make image mountable by first partition, too",
  910 "  -partition_sec_hd NUMBER    Define number of sectors per head",
  911 "  -partition_hd_cyl NUMBER    Define number of heads per cylinder",
  912 "  -partition_cyl_align MODE   Control cylinder alignment: off, on, auto, all",
  913 "  -mips-boot FILE             Set mips boot image name (relative to image root)",
  914 "  -mipsel-boot FILE           Set mipsel boot image name (relative to image root)",
  915 "  -B FILES, -sparc-boot FILES Set sparc boot image names",
  916 "  -sparc-label label text     Set sparc boot disk label",
  917 "  -hppa-cmdline CMDLINE       Set hppa boot command line",
  918 "  -hppa-kernel-32 FILE        Set hppa 32-bit image name (relative to image root)",
  919 "  -hppa-kernel-64 FILE        Set hppa 64-bit image name (relative to image root)",
  920 "  -hppa-bootloader FILE       Set hppa boot loader file name (relative to image root)",
  921 "  -hppa-ramdisk FILE          Set hppa ramdisk file name (relative to image root)",
  922 "  -hppa-hdrversion NUMBER     Set hppa PALO header version to 4 or 5",
  923 "  -alpha-boot FILE            Set alpha boot image name (relative to image root)",
  924 "  --grub2-sparc-core FILE     Set path of core file for disk label patching",
  925 "  -efi-boot-part DISKFILE|--efi-boot-image",
  926 "                              Set data source for EFI System Partition",
  927 "  -chrp-boot-part             Mark ISO image size by MBR partition type 0x96",
  928 "  -chrp-boot                  Alias of -chrp-boot-part",
  929 "  -prep-boot-part DISKFILE    Set data source for MBR partition type 0x41",
  930 "  -append_partition NUMBER TYPE FILE",
  931 "                              Append FILE after image. TYPE is hex: 0x.. or",
  932 "                              a GUID to be used if -appended_part_as_gpt.",
  933 "  -appended_part_as_gpt       mark appended partitions in GPT instead of MBR.",
  934 "  -appended_part_as_apm       mark appended partitions in APM.",
  935 "  --modification-date=YYYYMMDDhhmmsscc",
  936 "                              Override date of creation and modification",
  937 "  --set_all_file_dates TIME   Override mtime, atime, ctime in all files",
  938 "  -isohybrid-mbr FILE         Set SYSLINUX mbr/isohdp[fp]x*.bin for isohybrid",
  939 "  --grub2-mbr FILE            Set GRUB2 MBR for boot image address patching",
  940 #ifdef Xorriso_with_isohybriD
  941 "  isolinux_mbr=on|auto|off    Control eventual isohybrid MBR generation",
  942 #endif
  943 "  --sort-weight NUMBER FILE   Set LBA weight number to file or file tree",
  944 "  --sort-weight-list DISKFILE Read list of NUMBER FILE pairs for --sort-weight",
  945 "  --sort-weight-patterns DISKFILE  --sort-weight-list with pattern expansion",
  946 "  --stdio_sync on|off|number  Control forced output to disk files",
  947 "  --no-emul-toc               Save 64 kB size on random access output files",
  948 "  --emul-toc                  Multi-session history on such output files",
  949 "  --old-empty                 Use old style block addresses for empty files",
  950 "  -z, -transparent-compression",
  951 "                              Enable transparent compression of files",
  952 "  --zisofs-version-2          Enable processing of zisofs version 2 files",
  953 "  --zisofs2-susp-z2           Produce Z2 entries for zisofs version 2",
  954 "  --zisofs2-susp-zf           Produce ZF entries for zisofs version 2",
  955 "  -root DIR                   Set root directory for all new files and directories",
  956 "  -old-root DIR               Set root directory in previous session that is searched for files",
  957 "  --old-root-no-md5           Do not record and use MD5 with -old-root",
  958 "  --old-root-no-ino           Do not use disk inode numbers with -old-root",
  959 "  --old-root-devno            Use disk device numbers with -old-root",
  960 "  -log-file LOG_FILE          Re-direct messages to LOG_FILE",
  961 "  --no_rc                     Do not execute startup files",
  962 "  -v, -verbose                Verbose",
  963 "  -version                    Print the current version",
  964 "",
  965 #ifdef Xorriso_GNU_xorrisO
  966 "Report bugs to: bug-xorriso@gnu.org , or in private to: scdbackup@gmx.net .",
  967 "xorriso home page: <https://www.gnu.org/software/xorriso/>",
  968 "General help using GNU software: <https://www.gnu.org/gethelp/>",
  969 #else
  970 "Report any bugs to bug-xorriso@gnu.org or in private to scdbackup@gmx.net .",
  971 #endif
  972 "@End_of_helptexT@"
  973 };
  974 
  975  char ra_text[80];
  976  int i;
  977 
  978  strcpy(ra_text, xorriso->report_about_text);
  979 
  980  Xorriso_option_report_about(xorriso, "NOTE", 0);
  981  for(i= 0; strcmp(helptext[i], "@End_of_helptexT@")!=0; i++) {
  982    sprintf(xorriso->info_text, "%s\n", helptext[i]);
  983    Xorriso_info(xorriso, 1 | 2);
  984  }
  985  Xorriso_option_report_about(xorriso, ra_text, 0);
  986  return(1);
  987 }
  988 
  989 
  990 /* Perform hiding.
  991    Cumbersome: The paths and patterns apply to the disk address and not
  992    to the Rock Ridge address. Actually even the literal form of the
  993    mkisofs pathspec would matter (e.g. "./" versus "").
  994    But xorriso normalizes disk_paths before further processing. Thus
  995    the literal form does not matter.
  996    @param hide_attrs
  997           bit0= hide in ISO/RR
  998           bit1= hide in Joliet
  999           bit2= hide in HFS+
 1000           bit3 to bit5 are reserved for future hidings
 1001 */
 1002 int Xorriso_genisofs_hide(struct XorrisO *xorriso, char *whom,
 1003                           char *pattern, int hide_attrs, int flag)
 1004 {
 1005  int zero= 0, ret;
 1006  char *argv[1];
 1007 
 1008  if((hide_attrs & 63) == 0)
 1009    return(2);
 1010 
 1011  if(strchr(pattern, '/') != NULL) {
 1012    argv[0]= pattern;
 1013    ret= Xorriso_option_not_paths(xorriso, 1, argv, &zero,
 1014                                  4 | ((hide_attrs & 63) << 8));
 1015  } else {
 1016    ret= Xorriso_option_not_leaf(xorriso, pattern, hide_attrs & 63);
 1017  }
 1018  return(ret);
 1019 }
 1020 
 1021 
 1022 /* @param flag bit0= quoted list */
 1023 int Xorriso_genisofs_hide_list(struct XorrisO *xorriso, char *whom,
 1024                                char *adr, int hide_attrs, int flag)
 1025 {
 1026  int ret, linecount= 0, argc= 0, was_failure= 0, i, fret;
 1027  char **argv= NULL, *id= "";
 1028  FILE *fp= NULL;
 1029 
 1030  if(adr[0]==0) {
 1031    if (hide_attrs & 2)
 1032      id = "joliet-";
 1033    else if (hide_attrs & 4)
 1034      id = "hfsplus-";
 1035    sprintf(xorriso->info_text,
 1036           "Empty file name given with -as %s -hide-%slist", whom, id);
 1037    Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0);
 1038    return(0);
 1039  }
 1040  ret= Xorriso_afile_fopen(xorriso, adr, "rb", &fp, 0);
 1041  if(ret <= 0)
 1042    return(0);
 1043  while(1) {
 1044    ret= Xorriso_read_lines(xorriso, fp, &linecount, &argc, &argv,
 1045                            4 | (flag & 1) );
 1046    if(ret <= 0)
 1047      goto ex;
 1048    if(ret == 2)
 1049  break;
 1050    for(i= 0; i < argc; i++) {
 1051      if(argv[i][0] == 0)
 1052    continue;
 1053      ret= Xorriso_genisofs_hide(xorriso, whom, argv[i], hide_attrs, 0);
 1054      if(ret <= 0 || xorriso->request_to_abort) {
 1055        was_failure= 1;
 1056        fret= Xorriso_eval_problem_status(xorriso, ret, 1|2);
 1057        if(fret>=0)
 1058    continue;
 1059        if(ret > 0)
 1060          ret= 0;
 1061        goto ex;
 1062      }
 1063    }
 1064  }
 1065  ret= 1;
 1066 ex:;
 1067  Xorriso_read_lines(xorriso, fp, &linecount, &argc, &argv, 2);
 1068  if(fp != NULL && fp != stdin)
 1069    fclose(fp);
 1070  if(ret<=0)
 1071    return(ret);
 1072  return(!was_failure);
 1073 }
 1074 
 1075 
 1076 /* Strip surplus dash from known single-dash long options */
 1077 int Xorriso_genisofs_strip_dash(struct XorrisO *xorriso, char *arg_in,
 1078                                  char **arg_out, int flag)
 1079 {
 1080  int ret, count;
 1081  char *argv[1];
 1082 
 1083  *arg_out= arg_in;
 1084  if(strlen(arg_in) < 4)
 1085    return(1);
 1086  if(arg_in[0] != '-' || arg_in[1] != '-' || arg_in[2] == '-')
 1087    return(1);
 1088 
 1089  argv[0]= arg_in + 1; 
 1090  ret= Xorriso_genisofs_count_args(xorriso, 1, argv, &count, 0);
 1091  if(ret > 0)
 1092    *arg_out= arg_in + 1;
 1093  return(1);
 1094 }
 1095 
 1096 
 1097 /* Interprets a string of single-char options which have no parameters
 1098    @param flag bit0=check whether string is ok
 1099                bit1=this is pass 1
 1100    @return with flag bit0: 0=no , 1=yes, 2= with bit1: non-pass-1 options seen
 1101            else          : 1 = ok , <= 0 indicates error
 1102 */
 1103 int Xorriso_genisofs_fused_options(struct XorrisO *xorriso, char *whom,
 1104                                    char *opts,
 1105                                    int *option_d, int *iso_level, int *lower_r,
 1106                                    char ra_text[80], int flag)
 1107 {
 1108  int ret, non_pass1= 0;
 1109  char *cpt;
 1110  static char pass1_covered[]= {"fvz"};
 1111  static char covered[]= {"dDfJlNRrTUvz"};
 1112 
 1113  if(flag & 1) {
 1114    for(cpt= opts; *cpt != 0; cpt++) {
 1115      if(strchr(covered, *cpt) == NULL)
 1116        {ret= 0; goto ex;}
 1117      if(flag & 2)
 1118        if(strchr(pass1_covered, *cpt) == NULL)
 1119          non_pass1= 1;
 1120    }
 1121    ret= 1 + non_pass1; goto ex;
 1122  }
 1123  
 1124  for(cpt= opts; *cpt != 0; cpt++) {
 1125    if(*cpt == 'd') {
 1126      if(flag & 2)
 1127  continue;
 1128      Xorriso_relax_compliance(xorriso, "no_force_dots", 0);
 1129    } else if(*cpt == 'D') {
 1130      if(flag & 2)
 1131  continue;
 1132      *option_d= 1;
 1133    } else if(*cpt == 'f') {
 1134      if(!(flag & 2))
 1135  continue;
 1136      ret= Xorriso_option_follow(xorriso, "on", 0);
 1137      if(ret <= 0)
 1138        goto ex;
 1139    } else if(*cpt == 'J') {
 1140      if(flag & 2)
 1141  continue;
 1142      xorriso->do_joliet= 1;
 1143    } else if(*cpt == 'l') {
 1144      if(flag & 2)
 1145  continue;
 1146      if(xorriso->iso_level <= 2)
 1147        Xorriso_relax_compliance(xorriso, "iso_9660_level=2", 0);
 1148      if(*iso_level <= 2)
 1149        *iso_level= 2;
 1150    } else if(*cpt == 'N') {
 1151      if(flag & 2)
 1152  continue;
 1153      Xorriso_relax_compliance(xorriso, "omit_version", 0);
 1154    } else if(*cpt == 'R') {
 1155      if(flag & 2)
 1156  continue;
 1157      xorriso->do_rockridge= 1;
 1158    } else if(*cpt == 'r') {
 1159      if(flag & 2)
 1160  continue;
 1161      xorriso->do_rockridge= 1;
 1162      *lower_r= 1;
 1163    } else if(*cpt == 'T') {
 1164      /* ignored */;
 1165    } else if(*cpt == 'U') {
 1166      if(flag & 2)
 1167  continue;
 1168      Xorriso_relax_compliance(xorriso,
 1169        "no_force_dots:long_paths:long_names:omit_version:full_ascii:lowercase",
 1170                               0);
 1171    } else if(*cpt == 'v') {
 1172      if(!(flag & 2))
 1173  continue;
 1174      strcpy(ra_text, "UPDATE");
 1175    } else if(*cpt == 'z') {
 1176      if(!(flag & 2))
 1177  continue;
 1178      Xorriso_option_zisofs(xorriso, "by_magic=on", 0);
 1179    } else {
 1180      sprintf(xorriso->info_text, "-as %s: Unsupported option -%c", whom, *cpt);
 1181      Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
 1182      ret= 0; goto ex;
 1183    }
 1184  }
 1185  ret= 1; 
 1186 ex:;
 1187  return(ret);
 1188 }
 1189 
 1190 
 1191 /* Implementing mkisofs tendency to map single-path pathspecs to / */
 1192 int Xorriso_graftable_pathspec(struct XorrisO *xorriso, char *in_pathspec,
 1193                                char *pathspec, int flag)
 1194 {
 1195  int ret, l;
 1196  char *esc_wdx= NULL, *eff_path= NULL, *ept;
 1197 
 1198  if((!xorriso->allow_graft_points) || 
 1199    Fileliste__target_source_limit(in_pathspec, '=', &ept, 0) <= 0) {
 1200 
 1201    Xorriso_alloc_meM(esc_wdx, char, SfileadrL);
 1202    Xorriso_alloc_meM(eff_path, char, SfileadrL);
 1203 
 1204    strcpy(esc_wdx, xorriso->wdx);
 1205    if(!xorriso->allow_graft_points) {
 1206      ret= Fileliste__escape_source_path(esc_wdx, SfileadrL, 0);
 1207      if(ret <= 0) {
 1208        Xorriso_msgs_submit(xorriso, 0,
 1209                  "Escaped -cdx directory gets much too long", 0, "FAILURE", 0);
 1210        ret= 0; goto ex;
 1211      }
 1212    }
 1213    ret= Xorriso_normalize_img_path(xorriso, esc_wdx, in_pathspec,
 1214                                    eff_path, 2|4);
 1215    if(ret <= 0)
 1216      {ret= 0; goto ex;}
 1217    ret= Sfile_type(eff_path,
 1218             1 | ((xorriso->do_follow_param || xorriso->do_follow_links) << 2));
 1219    if(ret == 2) {
 1220      strcpy(pathspec, "/=");
 1221    } else {
 1222      pathspec[0]= '/';
 1223      pathspec[1]= 0;
 1224      ret= Sfile_leafname(eff_path, pathspec + 1, 0);
 1225      if(ret>0) {
 1226        if(!xorriso->allow_graft_points) {
 1227          ret= Fileliste__escape_source_path(pathspec, SfileadrL, 0);
 1228          if(ret <= 0) {
 1229            Xorriso_msgs_submit(xorriso, 0,
 1230                       "Escaped leaf name gets much too long", 0, "FAILURE", 0);
 1231            ret= 0; goto ex;
 1232          }
 1233        }
 1234        strcat(pathspec, "=");
 1235      } else
 1236        pathspec[0]= 0;
 1237    }
 1238    l= strlen(pathspec);
 1239    strcat(pathspec, eff_path);
 1240    if(!xorriso->allow_graft_points) {
 1241      ret= Fileliste__escape_source_path(pathspec + l, 2 * SfileadrL - l, 0);
 1242      if(ret <= 0) {
 1243        Xorriso_msgs_submit(xorriso, 0,
 1244                            "Escaped path gets much too long", 0, "FAILURE", 0);
 1245        ret= 0; goto ex;
 1246      }
 1247    }
 1248  } else {
 1249    Sfile_str(pathspec, in_pathspec, 0);
 1250  }
 1251  ret= 1;
 1252 ex:;
 1253  Xorriso_free_meM(esc_wdx);
 1254  Xorriso_free_meM(eff_path);
 1255  return(ret);
 1256 }
 1257 
 1258 
 1259 int Xorriso_genisofs_path_pecul(struct XorrisO *xorriso, int *was_path,
 1260                                 int with_emul_toc, int *allow_dir_id_ext,
 1261                                 int *iso_level, int flag)
 1262 {
 1263  char *sfe= NULL;
 1264  int ret;
 1265 
 1266  if(*was_path) {
 1267    ret= 1; goto ex;
 1268  }
 1269  *was_path= 1;
 1270 
 1271  Xorriso_alloc_meM(sfe, char, 5*SfileadrL);
 1272 
 1273  /* Enforce odd mkisofs defaults on first pathspec */
 1274  xorriso->pacifier_style= 1;
 1275  if(xorriso->allow_dir_id_ext_dflt && *allow_dir_id_ext < 0)
 1276    *allow_dir_id_ext= 1;
 1277  if(*allow_dir_id_ext == 1) {
 1278    Xorriso_relax_compliance(xorriso, "allow_dir_id_ext", 0);
 1279    *allow_dir_id_ext= 2;
 1280  }
 1281  if(xorriso->iso_level_is_default && *iso_level < 0)
 1282    *iso_level= 1;
 1283  if(*iso_level >= 1 && *iso_level <= 3) {
 1284    sprintf(sfe, "iso_9660_level=%d", *iso_level);
 1285    Xorriso_relax_compliance(xorriso, sfe, 0);
 1286    iso_level= 0;
 1287  }
 1288  /* For the sake of compatibility give up emulated multi-session by default
 1289  */
 1290  if(with_emul_toc == 0)
 1291    xorriso->no_emul_toc|= 1;
 1292  /* mkisofs records mtime in ECMA-119 and Joliet
 1293  */
 1294  Xorriso_relax_compliance(xorriso, "rec_mtime", 0);
 1295  /* mkisofs is substantially faster than xorriso by not fsyncing
 1296  */
 1297  if(xorriso->stdio_sync_is_default)
 1298    Xorriso_option_stdio_sync(xorriso, "off", 0);
 1299 
 1300  Xorriso_free_meM(sfe);
 1301  ret= 1;
 1302 ex:;
 1303  return(ret);
 1304 }
 1305 
 1306 
 1307 int Xorriso_genisofs_platform(struct XorrisO *xorriso, char *id, int flag)
 1308 {
 1309  unsigned int u;
 1310  char re_id[64];
 1311 
 1312  if(strcmp(id, "x86") == 0)
 1313    return(0);
 1314  else if(strcmp(id, "PPC") == 0)
 1315    return(1);
 1316  else if(strcmp(id, "Mac") == 0)
 1317    return(2);
 1318  else if(strcmp(id, "efi") == 0)
 1319    return(0xef);
 1320 
 1321  u= 0x100;
 1322  if(strncmp(id, "0x", 2) == 0) {
 1323    sscanf(id + 2, "%x", &u);
 1324  } else {
 1325    sscanf(id, "%u", &u);
 1326    sprintf(re_id, "%u", u);
 1327    if(strcmp(id, re_id) != 0)
 1328      goto wrong_id;
 1329  }
 1330  if(u <= 0xff)
 1331    return((int) u);
 1332 
 1333 wrong_id:;
 1334  sprintf(xorriso->info_text,
 1335          "Unrecognized El Torito Platform Id : '%.16s%s'",
 1336          id, strlen(id) > 16 ? "..." : "");
 1337  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
 1338  sprintf(xorriso->info_text,
 1339          "Recognizable are: x86, PPC, Mac, efi, [0...255], [0x00...0xff]");
 1340  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "HINT", 0);
 1341  return(-1);
 1342 }
 1343 
 1344 
 1345 /* micro emulation of mkisofs */
 1346 int Xorriso_genisofs(struct XorrisO *xorriso, char *whom,
 1347                      int argc, char **argv, int flag)
 1348 {
 1349  int ret, i, j, was_path= 0, was_other_option= 0, mem_graft_points, mem;
 1350  int do_print_size= 0, fd, idx, iso_level= -1, palohdrversion;
 1351  int was_failure= 0, fret, lower_r= 0, zero= 0;
 1352  int dir_mode= -1, file_mode= -1, count, partition_number;
 1353  int allow_dir_id_ext= -1;
 1354  int root_seen= 0, do_md5_mem, option_d= 0, arg_count;
 1355  mode_t mode_and, mode_or;
 1356  int with_boot_image= 0, with_cat_path= 0, with_emul_toc= 0;
 1357  int old_root_md5= 1, old_root_dev= 0, old_root_ino= 1, sort_file_pattern= 0;
 1358  int *weight_list= NULL, weight_count= 0;
 1359  int *delay_opt_list= NULL, delay_opt_count= 0;
 1360  int mkisofs_b_platform_id= 0x00;
 1361  char *sfe= NULL, *adr= NULL, ra_text[80], *pathspec= NULL, *sort_file= NULL;
 1362  char *ept, *add_pt, *eff_path= NULL, *indev= NULL, msc[80], *cpt;
 1363  char *old_root= NULL, *argpt, *hargv[1];
 1364  char *boot_path, partno_text[24], *iso_rr_pt, *disk_pt, *rpt, *wpt;
 1365  char *rm_merge_args[3], *rr_reloc_dir_pt= NULL;
 1366  char *sort_weight_args[4], *bless_args[6], *sa_path;
 1367 
 1368  struct stat stbuf;
 1369 
 1370  Xorriso_alloc_meM(sfe, char, 5*SfileadrL);
 1371  Xorriso_alloc_meM(adr, char, SfileadrL+8);
 1372  Xorriso_alloc_meM(pathspec, char, 2*SfileadrL);
 1373  Xorriso_alloc_meM(eff_path, char, SfileadrL);
 1374  Xorriso_alloc_meM(indev, char, SfileadrL+8);
 1375  Xorriso_alloc_meM(old_root, char, SfileadrL);
 1376  Xorriso_alloc_meM(sort_file, char, SfileadrL);
 1377 
 1378  for(i= 0; i<argc; i++) {
 1379    if(strcmp(argv[i], "-log-file") == 0 ||
 1380       strcmp(argv[i], "--log-file") == 0 ) {
 1381      if(i + 1 >= argc)
 1382        goto not_enough_args;
 1383      i+= 1;
 1384      if(argv[i][0]) {
 1385        sprintf(xorriso->info_text, "re-directing all messages to %s\n",
 1386                argv[i]);
 1387        Xorriso_info(xorriso, 0);
 1388      }
 1389      ret= Xorriso_write_to_channel(xorriso, argv[i], 2,
 1390                                    8 | ((argv[i][0] == 0) << 15));
 1391      if(ret <= 0) {
 1392        sprintf(xorriso->info_text, "Cannot open logfile:  %s", argv[i]);
 1393        Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno * (ret == 0),
 1394                            "SORRY", 0);
 1395        was_failure= 1;
 1396        fret= Xorriso_eval_problem_status(xorriso, ret, 1|2);
 1397        if(fret < 0)
 1398          {ret= 0; goto ex;}
 1399      }
 1400      if(argv[i][0] == 0) {
 1401        sprintf(xorriso->info_text, "Revoked stderr message redirection");
 1402        Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
 1403      }
 1404    }
 1405  }
 1406 
 1407  strcpy(ra_text, xorriso->report_about_text);
 1408 
 1409  weight_list= TSOB_FELD(int, (argc / 3) + 1);
 1410  if(weight_list == NULL) {
 1411    Xorriso_no_malloc_memory(xorriso, NULL, 0);
 1412    {ret= -1; goto ex;}
 1413  }
 1414  delay_opt_list= TSOB_FELD(int, argc + 1);
 1415  if(delay_opt_list == NULL) {
 1416    cpt= (char *) weight_list;
 1417    Xorriso_no_malloc_memory(xorriso, &cpt, 0);
 1418    {ret= -1; goto ex;}
 1419  } 
 1420 
 1421  if(xorriso->boot_image_cat_path[0])
 1422    with_cat_path= -1;
 1423  adr[0]= indev[0]= msc[0]= old_root[0]= sort_file[0]= 0;
 1424  for(i= 0; i<argc; i++) {
 1425    ret= Xorriso_genisofs_strip_dash(xorriso, argv[i], &argpt, 0);
 1426    if(ret <= 0)
 1427      goto ex;
 1428    ret= Xorriso_genisofs_ignore(xorriso, whom, argpt, &i, 1);
 1429    if(ret == 1)
 1430  continue;
 1431    if(strcmp(argpt, "-version")==0) {
 1432      sprintf(xorriso->result_line,
 1433 "mkisofs 2.01-Emulation Copyright (C) 2019 see libburnia-project.org xorriso\n"
 1434             );
 1435      fd= xorriso->dev_fd_1;
 1436      if(fd<0)
 1437        fd= 1;
 1438      ret= write(fd, xorriso->result_line, strlen(xorriso->result_line));
 1439      /* (result of write intentionally ignored) */
 1440      fsync(fd);
 1441      Xorriso_option_version(xorriso, 0);
 1442 
 1443    } else if(strcmp(argpt, "-o")==0 || strcmp(argpt, "-output")==0) {
 1444      if(i+1>=argc)
 1445        goto not_enough_args;
 1446      i++;
 1447      adr[0]= 0;
 1448      if(strcmp(argv[i],"-")!=0 && strncmp(argv[i], "stdio:", 6)!=0)
 1449        strcpy(adr, "stdio:");
 1450      if(Sfile_str(adr+strlen(adr), argv[i], 0)<=0)
 1451        {ret= -1; goto ex;}
 1452    } else if(strcmp(argpt, "-M")==0  || strcmp(argpt, "-dev")==0 ||
 1453              strcmp(argpt, "-prev-session")==0) {
 1454      if(i+1>=argc)
 1455        goto not_enough_args;
 1456      i++;
 1457      if(strncmp(argv[i], "stdio:", 6)!=0)
 1458        strcpy(indev, "stdio:");
 1459      if(Sfile_str(indev+strlen(indev), argv[i], 0)<=0)
 1460        {ret= -1; goto ex;}
 1461    } else if(strcmp(argpt, "-C")==0 ||
 1462              strcmp(argpt, "-cdrecord-params")==0) {
 1463      if(i+1>=argc)
 1464        goto not_enough_args;
 1465      i++;
 1466      strncpy(msc, argv[i], sizeof(msc)-1);
 1467      msc[sizeof(msc)-1]= 0;
 1468    } else if(strcmp(argpt, "-help")==0) {
 1469      Xorriso_genisofs_help(xorriso, 0);
 1470    } else if(strcmp(argpt, "-v")==0 || strcmp(argpt, "-verbose")==0) {
 1471      ret= Xorriso_genisofs_fused_options(xorriso, whom, "v",
 1472                                   &option_d, &iso_level, &lower_r, ra_text, 2);
 1473      if(ret <= 0)
 1474        goto problem_handler_1;
 1475    } else if(strcmp(argpt, "-quiet")==0) {
 1476      strcpy(ra_text, "SORRY");
 1477    } else if(strcmp(argpt, "-f")==0 || strcmp(argpt, "-follow-links")==0) {
 1478      ret= Xorriso_genisofs_fused_options(xorriso, whom, "f",
 1479                                   &option_d, &iso_level, &lower_r, ra_text, 2);
 1480      if(ret <= 0)
 1481        goto problem_handler_1;
 1482    } else if(strcmp(argpt, "-iso-level")==0) {
 1483      if(i+1>=argc)
 1484        goto not_enough_args;
 1485      i++;
 1486      sscanf(argv[i], "%d", &iso_level);
 1487      if(iso_level < 1 || iso_level > 4) {
 1488        sprintf(xorriso->info_text,
 1489                "-as %s: unsupported -iso-level '%s' (use one of: 1,2,3,4)",
 1490                whom, argv[i]);
 1491        Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
 1492        ret= 0; goto problem_handler_1;
 1493      }
 1494      if(iso_level == 4)
 1495        xorriso->do_iso1999= 1;
 1496      else {
 1497        sprintf(sfe, "iso_9660_level=%s", argv[i]);
 1498        ret= Xorriso_relax_compliance(xorriso, sfe, 0);
 1499        if(ret <= 0)
 1500          goto problem_handler_1;
 1501      }
 1502 
 1503    } else if(strcmp(argpt, "-input-charset")==0) {
 1504      if(i+1>=argc)
 1505        goto not_enough_args;
 1506      i++;
 1507      /* -local_charset */
 1508      if(strcmp(argv[i], "default") == 0)
 1509        ret= Xorriso_option_charset(xorriso, "ISO-8859-1", 4);
 1510      else
 1511        ret= Xorriso_option_charset(xorriso, argv[i], 4);
 1512      if(ret <= 0)
 1513        goto problem_handler_1;
 1514    } else if(strcmp(argpt, "-output-charset")==0) {
 1515      if(i+1>=argc)
 1516        goto not_enough_args;
 1517      i++;
 1518      /* -charset */
 1519      if(strcmp(argv[i], "default") == 0)
 1520        ret= Xorriso_option_charset(xorriso, "ISO-8859-1", 3);
 1521      else
 1522        ret= Xorriso_option_charset(xorriso, argv[i], 3);
 1523      if(ret <= 0)
 1524        goto problem_handler_1;
 1525 
 1526    } else if(strcmp(argpt, "-hide") == 0 ||
 1527              strcmp(argpt, "-hide-list") == 0 ||
 1528              strcmp(argpt, "-hide-joliet") == 0 ||
 1529              strcmp(argpt, "-hide-joliet-list") == 0 ||
 1530              strcmp(argpt, "-hide-hfsplus") == 0 ||
 1531              strcmp(argpt, "-hide-hfsplus-list") == 0) {
 1532      if(i+1>=argc)
 1533        goto not_enough_args;
 1534      i++;
 1535      if(strcmp(argpt, "-hide") == 0)
 1536        ret= Xorriso_genisofs_hide(xorriso, whom, argv[i], 1, 0);
 1537      else if(strcmp(argpt, "-hide-list") == 0)
 1538        ret= Xorriso_genisofs_hide_list(xorriso, whom, argv[i], 1, 0);
 1539      else if(strcmp(argpt, "-hide-joliet") == 0) 
 1540        ret= Xorriso_genisofs_hide(xorriso, whom, argv[i], 2, 0);
 1541      else if(strcmp(argpt, "-hide-joliet-list") == 0) 
 1542        ret= Xorriso_genisofs_hide_list(xorriso, whom, argv[i], 2, 0);
 1543      else if(strcmp(argpt, "-hide-hfsplus") == 0)
 1544        ret= Xorriso_genisofs_hide(xorriso, whom, argv[i], 4, 0);
 1545      else if(strcmp(argpt, "-hide-hfsplus-list") == 0)
 1546        ret= Xorriso_genisofs_hide_list(xorriso, whom, argv[i], 4, 0);
 1547      if(ret <= 0)
 1548        goto problem_handler_1;
 1549 
 1550    } else if(strcmp(argpt, "-root") == 0) {
 1551      if(i+1>=argc)
 1552        goto not_enough_args;
 1553      i++;
 1554      /* Always absolute */
 1555      strcpy(eff_path, "/");
 1556      if(Sfile_str(eff_path, argv[i], argv[i][0] != '/') <= 0)
 1557        {ret= -1; goto ex;}
 1558      strcpy(xorriso->wdi, eff_path);
 1559      root_seen= 1;
 1560 
 1561    } else if(strcmp(argpt, "-old-root") == 0) {
 1562      if(i+1>=argc)
 1563        goto not_enough_args;
 1564      i++;
 1565      /* Always absolute */
 1566      strcpy(old_root, "/");
 1567      if(Sfile_str(old_root, argv[i], argv[i][0] != '/') <= 0)
 1568        {ret= -1; goto ex;}
 1569 
 1570    } else if(strcmp(argpt, "--old-root-no-md5")==0) {
 1571      old_root_md5= 0;
 1572    } else if(strcmp(argpt, "--old-root-devno")==0) {
 1573      old_root_dev= 1;
 1574    } else if(strcmp(argpt, "--old-root-no-ino")==0) {
 1575      old_root_ino= 0;
 1576 
 1577    } else if(strcmp(argpt, "-fat") == 0) {
 1578      xorriso->do_fat= 1;
 1579    } else if(strcmp(argpt, "-hfsplus") == 0) {
 1580      /* Already with -indev */
 1581      xorriso->do_hfsplus= 1;
 1582 
 1583    } else if(strcmp(argpt, "--hardlinks")==0) {
 1584      Xorriso_option_hardlinks(xorriso, "on", 0);
 1585    } else if(strcmp(argpt, "--acl")==0) {
 1586      Xorriso_option_acl(xorriso, "on", 0);
 1587    } else if(strcmp(argpt, "--xattr")==0) {
 1588      Xorriso_option_xattr(xorriso, "on", 0);
 1589    } else if(strcmp(argpt, "--xattr-any")==0) {
 1590      Xorriso_option_xattr(xorriso, "any", 0);
 1591    } else if(strcmp(argpt, "--md5")==0) {
 1592      Xorriso_option_md5(xorriso, "on", 0);
 1593    } else if(strcmp(argpt, "--scdbackup_tag")==0) {
 1594      if(i + 2 >= argc)
 1595        goto not_enough_args;
 1596      i+= 2;
 1597      ret= Xorriso_option_scdbackup_tag(xorriso, argv[i-1], argv[i], 0);
 1598      if(ret <= 0)
 1599        goto problem_handler_1;
 1600    } else if(strcmp(argpt, "--for_backup")==0) {
 1601      Xorriso_option_hardlinks(xorriso, "on", 0);
 1602      Xorriso_option_acl(xorriso, "on", 0);
 1603      Xorriso_option_xattr(xorriso, "any", 0);
 1604      Xorriso_option_md5(xorriso, "on", 0);
 1605    } else if(strcmp(argpt, "-z")==0 ||
 1606              strcmp(argpt, "-transparent-compression")==0) {
 1607      Xorriso_option_zisofs(xorriso, "by_magic=on", 0);
 1608    } else if(strcmp(argpt, "--zisofs-version-2") == 0) {
 1609      Xorriso_option_zisofs(xorriso, "by_magic=v2", 0);
 1610    } else if(strcmp(argpt, "--zisofs2-susp-z2") == 0) {
 1611      Xorriso_option_zisofs(xorriso, "susp_z2=on", 0);
 1612    } else if(strcmp(argpt, "--zisofs2-susp-zf") == 0) {
 1613      Xorriso_option_zisofs(xorriso, "susp_z2=off", 0);
 1614    } else if(strcmp(argpt, "--stdio_sync")==0) {
 1615      if(i+1>=argc)
 1616        goto not_enough_args;
 1617      i++;
 1618      Xorriso_option_stdio_sync(xorriso, argv[i], 0);
 1619    } else if(strcmp(argpt, "-disallow_dir_id_ext")==0) {
 1620      allow_dir_id_ext= 0;
 1621    } else if(strcmp(argpt, "--emul-toc")==0) {
 1622      with_emul_toc= 1;
 1623      xorriso->no_emul_toc&= ~1;
 1624    } else if(strcmp(argpt, "--no-emul-toc")==0) {
 1625      with_emul_toc= 0;
 1626      xorriso->no_emul_toc|= 1;
 1627    } else if(strcmp(argpt, "-log-file") == 0) {
 1628      /* already handled before this loop */;
 1629      i++;
 1630    } else if(strcmp(argpt, "-gui") == 0) {
 1631      xorriso->pacifier_interval= 0.25;
 1632    } else if(strcmp(argpt, "-file_name_limit") == 0) {
 1633      if(i+1>=argc)
 1634        goto not_enough_args;
 1635      i++;
 1636      Xorriso_option_file_name_limit(xorriso, argv[i], 0);
 1637    } else {
 1638      if(argv[i][0] == '-') {
 1639        ret= Xorriso_genisofs_fused_options(xorriso, whom, argv[i] + 1,
 1640                               &option_d, &iso_level, &lower_r, ra_text, 1 | 2);
 1641        if(ret != 1)
 1642          was_other_option= 1;
 1643      } else {
 1644        ret= 0;
 1645        was_other_option= 1;
 1646      }
 1647      if(ret > 0) {
 1648        Xorriso_genisofs_fused_options(xorriso, whom, argv[i] + 1,
 1649                                   &option_d, &iso_level, &lower_r, ra_text, 2);
 1650        if(ret <= 0) 
 1651          goto problem_handler_1;
 1652      } else {
 1653        hargv[0]= argpt;
 1654        ret= Xorriso_genisofs_count_args(xorriso, argc - i, hargv, &count, 0);
 1655        if(ret > 0)
 1656          i+= count; /* skip eventual arguments of known option */
 1657      }
 1658    }
 1659  continue; /* regular bottom of loop */
 1660 problem_handler_1:;
 1661    was_failure= 1;
 1662    fret= Xorriso_eval_problem_status(xorriso, ret, 1|2);
 1663    if(fret>=0)
 1664  continue;
 1665    goto ex;
 1666  }
 1667  Xorriso_option_report_about(xorriso, ra_text, 0);
 1668  if(adr[0]) {
 1669    if(strncmp(adr, "stdio:", 6)==0 && strncmp(adr, "stdio:/dev/fd/", 14)!=0) {
 1670      ret= Sfile_type(adr+6, 1);
 1671      if(ret==-1) {
 1672        /* ok */;
 1673      } else if(ret==2 || ret==3) {
 1674        sprintf(xorriso->info_text,
 1675                "-as %s: Cannot accept %s as target: -o %s",
 1676                whom, (ret==3 ? "symbolic link" : "directory"),
 1677                Text_shellsafe(adr+6, sfe, 0));
 1678        Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
 1679        ret= 0; goto ex;
 1680      }
 1681    }
 1682    /* Regard overwritable as blank, truncate regular files on write start */
 1683    ret= Xorriso_option_dev(xorriso, adr, 2|8|16);
 1684    if(ret<=0)
 1685      goto ex;
 1686  }
 1687 
 1688  if(was_other_option && xorriso->out_drive_handle==NULL) {
 1689    ret= Xorriso_option_dev(xorriso, "-", 2|4); /* set outdev to stdout */
 1690    if(ret<=0)
 1691      goto ex;
 1692  }
 1693 
 1694  if(msc[0]) {
 1695    cpt= strchr(msc, ',');
 1696    if(cpt==NULL) {
 1697 illegal_c:;
 1698      sprintf(xorriso->info_text,
 1699              "-as %s: unusable parameter with option -C: %s",
 1700              whom, Text_shellsafe(msc, sfe, 0));
 1701      Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
 1702      {ret= 0; goto ex;}
 1703    } else if(cpt==msc || msc[1]==0)
 1704      goto illegal_c;
 1705    strncpy(sfe, msc, cpt-msc);
 1706    sfe[cpt-msc]= 0;
 1707    if(xorriso->in_drive_handle!=NULL && indev[0]) {
 1708      /* give up indev before setting the load address */
 1709      ret= Xorriso_option_dev(xorriso, "", 1);
 1710      if(ret<=0)
 1711        goto ex;
 1712    }
 1713    /* growisofs submits msc1+16 to avoid a theoretical bug in mkisofs.
 1714       Therefore this bug has to be emulated here. Sigh.
 1715    */
 1716    ret= Xorriso_option_load(xorriso, "sbsector", sfe, 1);
 1717    if(ret<=0)
 1718      goto ex;
 1719    ret= Xorriso_option_grow_blindly(xorriso, cpt+1, 0);
 1720    if(ret<=0)
 1721      goto ex;
 1722  }
 1723 
 1724  if(old_root[0] || root_seen) {
 1725    Xorriso_option_md5(xorriso, old_root_md5 ? "on" : "off", 0);
 1726    Xorriso_option_disk_dev_ino(xorriso,
 1727                                old_root_dev && old_root_ino ? "on" :
 1728                                old_root_ino ? "ino_only" : "off", 0);
 1729    if(!old_root_ino)
 1730      Xorriso_option_hardlinks(xorriso, "without_update", 0);
 1731  }
 1732  if(indev[0]) {
 1733    do_md5_mem= xorriso->do_md5;
 1734    if(xorriso->do_md5 & 1) /* MD5 loading is enabled */
 1735      xorriso->do_md5|= 32; /* Do not check tags of superblock,tree,session
 1736                               because growisofs preserves the first sb tag.*/
 1737    ret= Xorriso_option_dev(xorriso, indev, 1);
 1738    xorriso->do_md5= do_md5_mem;
 1739    if(ret<=0)
 1740      goto ex;
 1741  }
 1742 
 1743  if(!was_other_option)
 1744    {ret= 1; goto ex;}
 1745 
 1746  if(old_root[0]) {
 1747    ret= Xorriso_iso_lstat(xorriso, old_root, &stbuf, 0);
 1748    if(ret >= 0) {
 1749      if(root_seen) {
 1750        ret= Xorriso_mkdir(xorriso, xorriso->wdi, 1 | 2);
 1751        if(ret < 0)
 1752          {ret= -(ret != -1); goto ex;}
 1753      } else {
 1754        strcpy(xorriso->wdi, "/");
 1755      }
 1756      if(strcmp(old_root, xorriso->wdi) != 0) {
 1757        ret= Xorriso_clone_under(xorriso, old_root, xorriso->wdi, 0);
 1758        if(ret <= 0)
 1759          goto ex;
 1760      }
 1761    }
 1762  }
 1763 
 1764  xorriso->padding= 300*1024;
 1765 
 1766  for(i= 0; i<argc; i++) {
 1767    sprintf(xorriso->info_text, "-as %s: %s",
 1768            whom, Text_shellsafe(argv[i], sfe, 0));
 1769    Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0);
 1770    ret= Xorriso_genisofs_strip_dash(xorriso, argv[i], &argpt, 0);
 1771    if(ret <= 0)
 1772      goto ex;
 1773    ret= Xorriso_genisofs_ignore(xorriso, whom, argpt, &i, 0);
 1774    if(ret == 1)
 1775  continue;
 1776    if(strcmp(argpt, "-version")==0) {
 1777      /* was already handled in first argument scan */;
 1778    } else if(strcmp(argpt, "--norock")==0) {
 1779      xorriso->do_rockridge= 0;
 1780      lower_r= 0;
 1781    } else if(strcmp(argpt, "-R")==0 || strcmp(argpt, "-rock")==0) {
 1782      ret= Xorriso_genisofs_fused_options(xorriso, whom, "R",
 1783                                   &option_d, &iso_level, &lower_r, ra_text, 0);
 1784      if(ret <= 0)
 1785        goto problem_handler_2;
 1786    } else if(strcmp(argpt, "-r")==0 || strcmp(argpt, "-rational-rock")==0){
 1787      ret= Xorriso_genisofs_fused_options(xorriso, whom, "r",
 1788                                   &option_d, &iso_level, &lower_r, ra_text, 0);
 1789      if(ret <= 0)
 1790        goto problem_handler_2;
 1791    } else if(strcmp(argpt, "-J")==0 || strcmp(argpt, "-joliet")==0) {
 1792      ret= Xorriso_genisofs_fused_options(xorriso, whom, "J",
 1793                                   &option_d, &iso_level, &lower_r, ra_text, 0);
 1794      if(ret <= 0)
 1795        goto problem_handler_2;
 1796    } else if(strcmp(argpt, "-joliet-long")==0) {
 1797      Xorriso_relax_compliance(xorriso,
 1798                               "joliet_long_paths:joliet_long_names", 0);
 1799    } else if(strcmp(argpt, "-joliet-utf16")==0) {
 1800      Xorriso_relax_compliance(xorriso, "joliet_utf16", 0);
 1801    } else if(strcmp(argpt, "-fat") == 0) {
 1802      /* was already handled in first argument scan */;
 1803    } else if(strcmp(argpt, "-hfs-bless") == 0 ||
 1804              strcmp(argpt, "-hfs-bless-by") == 0 ||
 1805              strcmp(argpt, "-hfsplus-file-creator-type") == 0) {
 1806      arg_count= 1;
 1807      if(strcmp(argpt, "-hfs-bless-by") == 0)
 1808        arg_count= 2;
 1809      else if(strcmp(argpt, "-hfsplus-file-creator-type") == 0)
 1810        arg_count= 3;
 1811      if(i + arg_count >= argc)
 1812        goto not_enough_args;
 1813      /* Memorize command until all pathspecs are processed */
 1814      delay_opt_list[delay_opt_count++]= i;
 1815      if(argv[i] != argpt)
 1816        delay_opt_list[delay_opt_count - 1]|= 1u<<31;
 1817      i+= arg_count;
 1818    } else if(strcmp(argpt, "-hfsplus") == 0) {
 1819      /* was already handled in first argument scan */;
 1820    } else if(strcmp(argpt, "-hfsplus-serial-no") == 0) {
 1821      if(i+1>=argc)
 1822        goto not_enough_args;
 1823      i++;
 1824      sprintf(pathspec, "hfsplus_serial=%.80s", argv[i]);
 1825      ret= Xorriso_option_boot_image(xorriso, "any", pathspec, 0);
 1826      if(ret <= 0)
 1827        goto problem_handler_2;
 1828    } else if(strcmp(argpt, "-hfsplus-block-size") == 0 ||
 1829              strcmp(argpt, "-apm-block-size") == 0) {
 1830      if(i+1>=argc)
 1831        goto not_enough_args;
 1832      i++;
 1833      ret= -1;
 1834      sscanf(argv[i], "%d", &ret);
 1835      if(argpt[1] == 'h')
 1836        sprintf(sfe, "hfsplus_block_size=%d", ret);
 1837      else
 1838        sprintf(sfe, "apm_block_size=%d", ret);
 1839      ret= Xorriso_option_boot_image(xorriso, "any", sfe, 0);
 1840      if(ret <= 0)
 1841        goto problem_handler_2;
 1842 
 1843    } else if(strcmp(argpt, "-graft-points")==0) {
 1844      xorriso->allow_graft_points= 3;
 1845    } else if(strcmp(argpt, "-path-list")==0 ||
 1846              strcmp(argpt, "--quoted_path_list")==0) {
 1847      if(i+1>=argc) {
 1848 not_enough_args:;
 1849        sprintf(xorriso->info_text, "-as %s: Not enough arguments to option %s",
 1850                whom, argv[i]);
 1851        Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
 1852        ret= 0; goto ex;
 1853      }
 1854      i++;
 1855      xorriso->pacifier_style= 1;
 1856      ret= Xorriso_option_path_list(xorriso, argv[i],
 1857                                (strcmp(argpt, "--quoted_path_list") == 0) | 2);
 1858      if(ret<=0)
 1859        goto problem_handler_2;
 1860      ret = Xorriso_genisofs_path_pecul(xorriso, &was_path, with_emul_toc,
 1861                                        &allow_dir_id_ext, &iso_level, 0);
 1862      if(ret <= 0)
 1863        goto ex;
 1864    } else if(strcmp(argpt, "-f")==0 || strcmp(argpt, "-follow-links")==0) {
 1865      /* was already handled in first argument scan */;
 1866    } else if(strcmp(argpt, "-pad")==0) {
 1867      xorriso->padding= 300*1024;
 1868    } else if(strcmp(argpt, "-no-pad")==0) {
 1869      xorriso->padding= 0;
 1870    } else if(strcmp(argpt, "-print-size")==0) {
 1871      do_print_size= 1;
 1872    } else if(strcmp(argpt, "-o")==0 || strcmp(argpt, "-output") == 0) {
 1873      i++;
 1874      /* was already handled in first argument scan */;
 1875    } else if(strcmp(argpt, "-M")==0  || strcmp(argpt, "-dev")==0 ||
 1876              strcmp(argpt, "-prev-session")==0) {
 1877      i++;
 1878      /* was already handled in first argument scan */;
 1879    } else if(strcmp(argpt, "-C")==0 ||
 1880              strcmp(argpt, "-cdrecord-params")==0) {
 1881      i++;
 1882      /* was already handled in first argument scan */;
 1883    } else if(strcmp(argpt, "-help")==0) {
 1884      /* was already handled in first argument scan */;
 1885    } else if(strcmp(argpt, "-V")==0 || strcmp(argpt, "-volid")==0 ||
 1886              strcmp(argpt, "-volset")==0 ||
 1887              strcmp(argpt, "-p")==0 || strcmp(argpt, "-preparer")==0 ||
 1888              strcmp(argpt, "-P")==0 || strcmp(argpt, "-publisher")==0 ||
 1889              strcmp(argpt, "-A")==0 || strcmp(argpt, "-appid")==0 ||
 1890              strcmp(argpt, "--application_use")==0 ||
 1891              strcmp(argpt, "-sysid")==0 ||
 1892              strcmp(argpt, "-biblio")==0 ||
 1893              strcmp(argpt, "-copyright")==0 ||
 1894              strcmp(argpt, "-abstract")==0 ) {
 1895      if(i+1>=argc)
 1896        goto not_enough_args;
 1897      i++;
 1898      ret= 1;
 1899      if(strcmp(argpt, "-V")==0 || strcmp(argpt, "-volid")==0)
 1900        ret= Xorriso_option_volid(xorriso, argv[i], 0);
 1901      else if(strcmp(argpt, "-volset")==0)
 1902        ret= Xorriso_option_volset_id(xorriso, argv[i], 0);
 1903      else if(strcmp(argpt, "-p")==0 ||
 1904              strcmp(argpt, "-preparer")==0)
 1905        ret= Xorriso_option_preparer_id(xorriso, argv[i], 0);
 1906      else if(strcmp(argpt, "-P")==0 ||
 1907              strcmp(argpt, "-publisher")==0)
 1908        ret= Xorriso_option_publisher(xorriso, argv[i], 0);
 1909      else if(strcmp(argpt, "-A")==0 || strcmp(argpt, "-appid")==0)
 1910        ret= Xorriso_option_application_id(xorriso, argv[i], 0);
 1911      else if(strcmp(argpt, "-sysid")==0)
 1912        ret= Xorriso_option_system_id(xorriso, argv[i], 0);
 1913      else if(strcmp(argpt, "-biblio")==0)
 1914        ret= Xorriso_option_biblio_file(xorriso, argv[i], 0);
 1915      else if(strcmp(argpt, "-copyright")==0)
 1916        ret= Xorriso_option_copyright_file(xorriso, argv[i], 0);
 1917      else if(strcmp(argpt, "-abstract")==0)
 1918        ret= Xorriso_option_abstract_file(xorriso, argv[i], 0);
 1919      else if(strcmp(argpt, "--application_use")==0)
 1920        ret= Xorriso_option_application_use(xorriso, argv[i], 0);
 1921      if(ret<=0)
 1922        goto problem_handler_2;
 1923    } else if(strcmp(argpt, "-m")==0 || strcmp(argpt, "-exclude")==0 ||
 1924              strcmp(argpt, "-x")==0 || strcmp(argpt, "-old-exclude")==0) {
 1925      if(i+1>=argc)
 1926        goto not_enough_args;
 1927      i++;
 1928      mem= xorriso->do_disk_pattern;
 1929      xorriso->do_disk_pattern= 1;
 1930      if(strchr(argv[i], '/')!=NULL) {
 1931        idx= i;
 1932        ret= Xorriso_option_not_paths(xorriso, i+1, argv, &idx, 0);
 1933      } else
 1934        ret= Xorriso_option_not_leaf(xorriso, argv[i], 0);
 1935      xorriso->do_disk_pattern= mem;
 1936      if(ret<=0)
 1937        goto problem_handler_2;
 1938    } else if(strcmp(argpt, "-exclude-list")==0) {
 1939      if(i+1>=argc)
 1940        goto not_enough_args;
 1941      i++;
 1942      mem= xorriso->do_disk_pattern;
 1943      xorriso->do_disk_pattern= 1;
 1944      ret= Xorriso_option_not_list(xorriso, argv[i], 0);
 1945      xorriso->do_disk_pattern= mem;
 1946      if(ret<=0)
 1947        goto problem_handler_2;
 1948    } else if(strcmp(argpt, "-v")==0 || strcmp(argpt, "-verbose")==0 ||
 1949              strcmp(argpt, "-quiet")==0) {
 1950      /* was already handled in first argument scan */;
 1951 
 1952    } else if(strcmp(argpt, "-iso-level")==0) {
 1953      i++;
 1954      /* was already handled in first argument scan */;
 1955    } else if(strcmp(argpt, "-no-emul-boot")==0 ||
 1956              strcmp(argpt, "-hard-disk-boot")==0 ||
 1957              strcmp(argpt, "-boot-info-table")==0 ||
 1958              strcmp(argpt, "--grub2-boot-info") == 0 ||
 1959              strncmp(argpt, "isolinux_mbr=", 13)==0 ||
 1960              strcmp(argpt, "-eltorito-alt-boot")==0 ||
 1961              strcmp(argpt, "--protective-msdos-label")==0 ||
 1962              strcmp(argpt, "--mbr-force-bootable")==0 ||
 1963              strcmp(argpt, "--boot-catalog-hide")==0 ||
 1964              strcmp(argpt, "-isohybrid-gpt-basdat")==0 ||
 1965              strcmp(argpt, "-isohybrid-gpt-hfsplus")==0 ||
 1966              strcmp(argpt, "-isohybrid-apm-hfsplus")==0 ||
 1967              strcmp(argpt, "-part_like_isohybrid")==0) {
 1968      delay_opt_list[delay_opt_count++]= i;
 1969      if(argv[i] != argpt)
 1970        delay_opt_list[delay_opt_count - 1]|= 1u<<31;
 1971    } else if(strcmp(argpt, "-b") == 0 ||
 1972              strcmp(argpt, "-eltorito-boot") == 0 ||
 1973              strcmp(argpt, "-eltorito-platform") == 0 ||
 1974              strcmp(argpt, "--efi-boot") == 0 ||
 1975              strcmp(argpt, "-e") == 0 ||
 1976              strcmp(argpt, "-mips-boot") == 0 ||
 1977              strcmp(argpt, "-mipsel-boot") == 0 ||
 1978              strcmp(argpt, "-c") == 0 ||
 1979              strcmp(argpt, "-eltorito-catalog") == 0 ||
 1980              strcmp(argpt, "-boot-load-size") == 0 ||
 1981              strcmp(argpt, "-eltorito-id") == 0 ||
 1982              strcmp(argpt, "-eltorito-selcrit") == 0 ||
 1983              strcmp(argpt, "--embedded-boot")==0 ||
 1984              strcmp(argpt, "-generic-boot")==0 ||
 1985              strcmp(argpt, "-G") == 0 ||
 1986              strcmp(argpt, "-partition_offset") == 0 ||
 1987              strcmp(argpt, "-partition_hd_cyl") == 0 ||
 1988              strcmp(argpt, "-partition_sec_hd") == 0 ||
 1989              strcmp(argpt, "-partition_cyl_align") == 0 ||
 1990              strcmp(argpt, "-isohybrid-mbr") == 0 ||
 1991              strcmp(argpt, "--grub2-mbr") == 0 ||
 1992              strncmp(argpt, "-hppa-", 6) == 0 ||
 1993              strcmp(argpt, "-alpha-boot") == 0 ||
 1994              strcmp(argpt, "--gpt_disk_guid") == 0 ||
 1995              strcmp(argpt, "-iso_mbr_part_type") == 0) { 
 1996      if(i+1>=argc)
 1997        goto not_enough_args;
 1998      delay_opt_list[delay_opt_count++]= i;
 1999      if(argv[i] != argpt)
 2000        delay_opt_list[delay_opt_count - 1]|= 1u<<31;
 2001      i++;
 2002    } else if(strncmp(argpt, "--modification-date=", 20)==0) {
 2003      ret= Xorriso_option_volume_date(xorriso, "uuid", argpt + 20, 0);
 2004      if(ret <= 0)
 2005        goto problem_handler_2;
 2006 
 2007    } else if(strcmp(argpt, "--set_all_file_dates") == 0) {
 2008      if(i+1>=argc)
 2009        goto not_enough_args;
 2010      i++;
 2011      ret= Xorriso_option_volume_date(xorriso, "all_file_dates", argv[i], 0);
 2012      if(ret <= 0)
 2013        goto problem_handler_2;
 2014    } else if(strcmp(argpt, "-input-charset")==0) {
 2015      i++;
 2016      /* was already handled in first argument scan */;
 2017    } else if(strcmp(argpt, "-output-charset")==0) {
 2018      i++;
 2019      /* was already handled in first argument scan */;
 2020    } else if(strcmp(argpt, "--hardlinks")==0 ||
 2021              strcmp(argpt, "--acl")==0 ||
 2022              strcmp(argpt, "--xattr")==0 ||
 2023              strcmp(argpt, "--xattr-any")==0 ||
 2024              strcmp(argpt, "--md5")==0 ||
 2025              strcmp(argpt, "--for_backup")==0) {
 2026      /* was already handled in first argument scan */;
 2027    } else if(strcmp(argpt, "--scdbackup_tag")==0) {
 2028      /* was already handled in first argument scan */;
 2029      i+= 2;
 2030    } else if(strcmp(argpt, "--sort-weight")==0) {
 2031      if(i + 2 >= argc)
 2032        goto not_enough_args;
 2033      i+= 2;
 2034      /* memorize for find runs after pathspecs have been added */
 2035      weight_list[weight_count++]= i - 2;
 2036    } else if(strcmp(argpt, "--sort-weight-list") == 0 ||
 2037              strcmp(argpt, "--sort-weight-patterns") == 0) {
 2038      if(i + 1 >= argc)
 2039        goto not_enough_args;
 2040      i++;
 2041      if(Sfile_str(sort_file, argv[i], 0) <= 0)
 2042        {ret= -1; goto ex;}
 2043      sort_file_pattern= (strcmp(argpt, "--sort-weight-patterns") == 0);
 2044 
 2045    } else if(strcmp(argpt, "-z")==0 ||
 2046              strcmp(argpt, "-transparent-compression")==0 ||
 2047              strcmp(argpt, "--zisofs-version-2") == 0 ||
 2048              strcmp(argpt, "--zisofs2-susp-z2") == 0 ||
 2049              strcmp(argpt, "--zisofs2-susp-zf") == 0) {
 2050      /* was already handled in first argument scan */;
 2051    } else if(strcmp(argpt, "-U") == 0 ||
 2052              strcmp(argpt, "-untranslated-filenames") == 0) {
 2053      ret= Xorriso_genisofs_fused_options(xorriso, whom, "U",
 2054                                   &option_d, &iso_level, &lower_r, ra_text, 0);
 2055      if(ret <= 0)
 2056        goto problem_handler_2;
 2057    } else if(strcmp(argpt, "-untranslated_name_len") == 0) {
 2058      if(i+1>=argc)
 2059        goto not_enough_args;
 2060      i++;
 2061      sprintf(sfe, "untranslated_name_len=%s", argv[i]);
 2062      ret= Xorriso_relax_compliance(xorriso, sfe, 0);
 2063      if(ret <= 0)
 2064        goto problem_handler_2;
 2065    } else if(strcmp(argpt, "-N") == 0 ||
 2066              strcmp(argpt, "-omit-version-number") == 0) {
 2067      ret= Xorriso_genisofs_fused_options(xorriso, whom, "N",
 2068                                   &option_d, &iso_level, &lower_r, ra_text, 0);
 2069      if(ret <= 0)
 2070        goto problem_handler_2;
 2071    } else if(strcmp(argpt, "-l") == 0 ||
 2072              strcmp(argpt, "-full-iso9660-filenames") == 0) {
 2073      ret= Xorriso_genisofs_fused_options(xorriso, whom, "l",
 2074                                   &option_d, &iso_level, &lower_r, ra_text, 0);
 2075      if(ret <= 0)
 2076        goto problem_handler_2;
 2077    } else if(strcmp(argpt, "-max-iso9660-filenames") == 0) {
 2078      Xorriso_relax_compliance(xorriso, "long_names", 0);
 2079    } else if(strcmp(argpt, "-d") == 0 ||
 2080              strcmp(argpt, "-omit-period") == 0) {
 2081      ret= Xorriso_genisofs_fused_options(xorriso, whom, "d",
 2082                                   &option_d, &iso_level, &lower_r, ra_text, 0);
 2083      if(ret <= 0)
 2084        goto problem_handler_2;
 2085    } else if(strcmp(argpt, "-allow-lowercase") == 0) {
 2086      Xorriso_relax_compliance(xorriso, "lowercase", 0);
 2087    } else if(strcmp(argpt, "-relaxed-filenames") == 0) {
 2088      Xorriso_relax_compliance(xorriso, "7bit_ascii", 0);
 2089    } else if(strcmp(argpt, "-hide") == 0 ||
 2090              strcmp(argpt, "-hide-list") == 0 ||
 2091              strcmp(argpt, "-hide-joliet") == 0 ||
 2092              strcmp(argpt, "-hide-joliet-list") == 0 ||
 2093              strcmp(argpt, "-hide-hfsplus") == 0 ||
 2094              strcmp(argpt, "-hide-hfsplus-list") == 0) {
 2095      if(i+1>=argc)
 2096        goto not_enough_args;
 2097      i++;
 2098      /* was already handled in first argument scan */;
 2099    } else if(strcmp(argpt, "-root") == 0 ||
 2100              strcmp(argpt, "-old-root") == 0) {
 2101      if(i+1>=argc)
 2102        goto not_enough_args;
 2103      i++;
 2104      /* was already handled in first argument scan */;
 2105    } else if(strcmp(argpt, "--old-root-no-md5")==0 ||
 2106              strcmp(argpt, "--old-root-devno")==0 ||
 2107              strcmp(argpt, "--old-root-no-ino")==0) {
 2108      /* was already handled in first argument scan */;
 2109    } else if(strcmp(argpt, "-dir-mode") == 0) {
 2110      if(i+1>=argc)
 2111        goto not_enough_args;
 2112      i++;
 2113      ret= Xorriso_convert_modstring(xorriso, "-as mkisofs -dir-mode",
 2114                                     argv[i], &mode_and, &mode_or, 0);
 2115      if(ret<=0)
 2116        goto problem_handler_2;
 2117      dir_mode= mode_or;
 2118    } else if(strcmp(argpt, "-file-mode") == 0) {
 2119      if(i+1>=argc)
 2120        goto not_enough_args;
 2121      i++;
 2122      ret= Xorriso_convert_modstring(xorriso, "-as mkisofs -file-mode",
 2123                                     argv[i], &mode_and, &mode_or, 0);
 2124      if(ret<=0)
 2125        goto problem_handler_2;
 2126      file_mode= mode_or;
 2127    } else if(strcmp(argpt, "-jigdo-jigdo") == 0 ||
 2128              strcmp(argpt, "-jigdo-template") == 0 ||
 2129              strcmp(argpt, "-jigdo-min-file-size") == 0 ||
 2130              strcmp(argpt, "-jigdo-exclude") == 0 ||
 2131              strcmp(argpt, "-jigdo-force-md5") == 0 ||
 2132              strcmp(argpt, "-jigdo-force-checksum") == 0 ||
 2133              strcmp(argpt, "-jigdo-map") == 0 ||
 2134              strcmp(argpt, "-jigdo-checksum-algorithm") == 0 ||
 2135              strcmp(argpt, "-jigdo-template-compress") == 0 ||
 2136              strcmp(argpt, "-checksum_algorithm_iso") == 0 ||
 2137              strcmp(argpt, "-checksum_algorithm_template") == 0 ||
 2138              strcmp(argpt, "-md5-list") == 0 ||
 2139              strcmp(argpt, "-checksum-list") == 0) {
 2140      i++;
 2141      ret= Xorriso_option_jigdo(xorriso, argpt, argv[i], 0);
 2142      if(ret <= 0)
 2143        goto problem_handler_2;
 2144 
 2145    } else if(strcmp(argpt, "-chrp-boot-part") == 0 ||
 2146              strcmp(argpt, "-chrp-boot") == 0) {
 2147      ret= Xorriso_option_boot_image(xorriso, "any", "chrp_boot_part=on", 0);
 2148      if(ret <= 0)
 2149        goto problem_handler_2;
 2150 
 2151    } else if(strcmp(argpt, "-prep-boot-part") == 0) {
 2152      if(i + 1 >= argc)
 2153        goto not_enough_args;
 2154      i++;
 2155      ret= Sfile_str(xorriso->prep_partition, argv[i], 0);
 2156      if(ret <= 0)
 2157        goto ex;
 2158 
 2159    } else if(strcmp(argpt, "-efi-boot-part") == 0) {
 2160      if(i + 1 >= argc)
 2161        goto not_enough_args;
 2162      i++;
 2163      ret= Sfile_str(xorriso->efi_boot_partition, argv[i], 0);
 2164      if(ret <= 0)
 2165        goto ex;
 2166 
 2167    } else if(strcmp(argpt, "-append_partition") == 0) {
 2168      if(i + 3 >= argc)
 2169        goto not_enough_args;
 2170      i+= 3;
 2171      ret= Xorriso_option_append_partition(xorriso, argv[i - 2], argv[i - 1],
 2172                                           argv[i], 0);
 2173      if(ret <= 0)
 2174        goto problem_handler_2;
 2175 
 2176    } else if(strcmp(argpt, "-appended_part_as_gpt") == 0) {
 2177      xorriso->appended_as_gpt= 1;
 2178 
 2179    } else if(strcmp(argpt, "-appended_part_as_apm") == 0) {
 2180      xorriso->appended_as_apm= 1;
 2181 
 2182    } else if(strcmp(argpt, "-B") == 0 ||
 2183              strcmp(argpt, "-sparc-boot") == 0) {
 2184      i++;
 2185      if(strlen(argv[i]) >= SfileadrL)
 2186  continue;
 2187 
 2188      /* Switch system area type to: SUN Disk Label */
 2189      strcpy(pathspec, "sparc_label=");
 2190      strcat(pathspec, xorriso->ascii_disc_label);
 2191      ret= Xorriso_option_boot_image(xorriso, "any", pathspec, 0);
 2192      if(ret <= 0)
 2193        goto problem_handler_2;
 2194 
 2195      /* Interpret list of boot partition images or "..." */;
 2196      cpt= ept= argv[i];
 2197      partition_number= 2;
 2198      while(ept != NULL) {
 2199        ept= strchr(cpt, ',');
 2200        if(ept != NULL) {
 2201          strncpy(pathspec, cpt, ept - cpt);
 2202          pathspec[ept - cpt]= 0;
 2203          cpt= ept + 1;
 2204        } else
 2205          strcpy(pathspec, cpt);
 2206        if(strcmp(pathspec, "...") == 0) {
 2207          for(; partition_number <= 8; partition_number++) {
 2208            sprintf(partno_text, "%d", partition_number);
 2209            ret= Xorriso_option_append_partition(xorriso, partno_text, "0x0",
 2210                                                 ".", 0);
 2211            if(ret <= 0)
 2212              goto problem_handler_2;
 2213          }
 2214        } else {
 2215          if(partition_number > 8) {
 2216            sprintf(xorriso->info_text,
 2217                 "-as %s -sparc-boot %s : Too many boot images", whom, argv[i]);
 2218            Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE",0);
 2219            goto problem_handler_2;
 2220          }
 2221          sprintf(partno_text, "%d", partition_number);
 2222          ret= Xorriso_option_append_partition(xorriso, partno_text, "0x0",
 2223                                               pathspec, 0);
 2224          if(ret <= 0)
 2225            goto problem_handler_2;
 2226          partition_number++;
 2227        }
 2228      }
 2229 
 2230    } else if(strcmp(argpt, "-sparc-label") == 0) {
 2231      if(i+1>=argc)
 2232        goto not_enough_args;
 2233      i++;
 2234      sprintf(sfe, "sparc_label=%s", argv[i]);
 2235      ret= Xorriso_option_boot_image(xorriso, "any", sfe, 0);
 2236      if(ret <= 0)
 2237        goto problem_handler_2;
 2238 
 2239    } else if(strcmp(argpt, "--grub2-sparc-core") == 0) {
 2240      if(i+1>=argc)
 2241        goto not_enough_args;
 2242      i++;
 2243      sprintf(sfe, "grub2_sparc_core=%s", argv[i]);
 2244      ret= Xorriso_option_boot_image(xorriso, "any", sfe, 0);
 2245      if(ret <= 0)
 2246        goto problem_handler_2;
 2247 
 2248    } else if(strcmp(argpt, "--stdio_sync")==0) {
 2249      if(i+1>=argc)
 2250        goto not_enough_args;
 2251      i++;
 2252      /* was already handled in first argument scan */;
 2253 
 2254    } else if(strcmp(argpt, "--emul-toc")==0 ||
 2255              strcmp(argpt, "--no-emul-toc")==0) {
 2256      /* was already handled in first argument scan */;
 2257 
 2258    } else if(strcmp(argpt, "--old-empty")==0) {
 2259      xorriso->do_old_empty= 1;
 2260 
 2261    } else if(strcmp(argpt, "-disallow_dir_id_ext")==0) {
 2262      /* was already handled in first argument scan */;
 2263 
 2264    } else if(strcmp(argpt, "--no_rc")==0) {
 2265      /* was already handled in Xorriso_prescan_args */;
 2266 
 2267    } else if(strcmp(argpt, "-D") == 0 ||
 2268              strcmp(argpt, "-disable-deep-relocation") == 0) {
 2269      ret= Xorriso_genisofs_fused_options(xorriso, whom, "D",
 2270                                   &option_d, &iso_level, &lower_r, ra_text, 0);
 2271      if(ret <= 0)
 2272        goto problem_handler_2;
 2273 
 2274    } else if(strcmp(argpt, "-hide-rr-moved") == 0) {
 2275      rr_reloc_dir_pt= ".rr_moved";
 2276      goto rr_reloc_dir;
 2277 
 2278    } else if(strcmp(argpt, "-rr_reloc_dir") == 0) {
 2279      i++;
 2280      rr_reloc_dir_pt= argv[i];
 2281 rr_reloc_dir:;
 2282      if(rr_reloc_dir_pt[0] == '/')
 2283         rr_reloc_dir_pt++;
 2284      if(strchr(rr_reloc_dir_pt, '/') != NULL) {
 2285        sprintf(xorriso->info_text,
 2286         "-as %s -rr_reloc_dir %s : May only use directories in root directory",
 2287                whom, Text_shellsafe(argv[i], sfe, 0));
 2288        Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE",0);
 2289      }
 2290      ret= Xorriso_option_rr_reloc_dir(xorriso, rr_reloc_dir_pt, 0);
 2291      if(ret <= 0)
 2292        goto problem_handler_2;
 2293      Xorriso_relax_compliance(xorriso, "deep_paths_off:long_paths_off", 0);
 2294 
 2295    } else if(strcmp(argpt, "-log-file") == 0 ||
 2296              strcmp(argpt, "-file_name_limit") == 0) {
 2297      i+= 1;
 2298      /* was already handled before this loop */;
 2299 
 2300    } else if(strcmp(argpt, "-gui") == 0) {
 2301      /* was already handled in first argument scan */;
 2302 
 2303    } else if(strcmp(argpt, "-uid") == 0) {
 2304      if(i + 1 >= argc)
 2305        goto not_enough_args;
 2306      i++;
 2307      ret= Xorriso_option_uid(xorriso, argv[i], 0);
 2308      if(ret <= 0)
 2309        goto problem_handler_2;
 2310 
 2311    } else if(strcmp(argpt, "-gid") == 0) {
 2312      if(i + 1 >= argc)
 2313        goto not_enough_args;
 2314      i++;
 2315      ret= Xorriso_option_gid(xorriso, argv[i], 0);
 2316      if(ret <= 0)
 2317        goto problem_handler_2;
 2318 
 2319    } else if(argpt[0]=='-' && argpt[1]!=0) {
 2320      ret= Xorriso_genisofs_fused_options(xorriso, whom, argv[i] + 1,
 2321                                   &option_d, &iso_level, &lower_r, ra_text, 1);
 2322      if(ret == 1) {
 2323        ret= Xorriso_genisofs_fused_options(xorriso, whom, argv[i] + 1,
 2324                                   &option_d, &iso_level, &lower_r, ra_text, 0);
 2325        if(ret <= 0)
 2326          goto problem_handler_2;
 2327      } else {
 2328        hargv[0]= argpt;
 2329        ret= Xorriso_genisofs_count_args(xorriso, argc - i, hargv, &count, 1);
 2330        if(ret > 0) {
 2331          sprintf(xorriso->info_text, "-as %s: Unsupported option %s",
 2332                  whom, Text_shellsafe(argv[i], sfe, 0));
 2333          Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
 2334          i+= count;
 2335          goto problem_handler_2;
 2336        } else {
 2337          sprintf(xorriso->info_text, "-as %s: Unrecognized option %s",
 2338                  whom, Text_shellsafe(argv[i], sfe, 0));
 2339          Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
 2340          goto problem_handler_2;
 2341        }
 2342      }
 2343    } else {
 2344      ret= Xorriso_graftable_pathspec(xorriso, argv[i], pathspec, 0);
 2345      if(ret <= 0)
 2346        goto problem_handler_2;
 2347      add_pt= pathspec;
 2348 
 2349      if(old_root[0]) {
 2350        /* Split pathspec */
 2351        ret= Fileliste__target_source_limit(add_pt, '=', &ept, 0);
 2352        if(ret > 0) {
 2353          *ept= 0;
 2354          iso_rr_pt= add_pt;
 2355          disk_pt= ept + 1;
 2356        } else {
 2357          iso_rr_pt= "/";
 2358          disk_pt= add_pt;
 2359        }
 2360 
 2361        /* Unescape iso_rr_pt */
 2362        strcpy(eff_path, iso_rr_pt);
 2363        iso_rr_pt= eff_path;
 2364        for(wpt= rpt= iso_rr_pt; *rpt != 0; rpt++) {
 2365          if(*rpt == '\\') {
 2366            if(*(rpt + 1) == '\\')
 2367              rpt++;
 2368            else if(*(rpt + 1) == '=')
 2369        continue;
 2370          }
 2371          *(wpt++) = *rpt;
 2372        }
 2373        *wpt= 0;
 2374 
 2375        if(root_seen) {
 2376          ret= Sfile_prepend_path(xorriso->wdi, iso_rr_pt, 0);
 2377          if(ret<=0) {
 2378            Xorriso_msgs_submit(xorriso, 0, "Effective path gets much too long",
 2379                                0, "FAILURE", 0);
 2380            goto problem_handler_2;
 2381          }
 2382        }
 2383        /* update_merge */
 2384        ret= Xorriso_option_update(xorriso, disk_pt, iso_rr_pt, 1 | 8 | 32);
 2385      } else {
 2386        mem_graft_points= xorriso->allow_graft_points;
 2387        xorriso->allow_graft_points= 3;
 2388        zero= 0;
 2389        ret= Xorriso_option_add(xorriso, 1, &add_pt, &zero,
 2390                                (was_path << 1) | (root_seen << 2));
 2391        xorriso->allow_graft_points= mem_graft_points;
 2392      }
 2393      if(ret<=0)
 2394        goto problem_handler_2;
 2395 
 2396      /* Enforce odd mkisofs defaults on first pathspec */
 2397      ret = Xorriso_genisofs_path_pecul(xorriso, &was_path, with_emul_toc,
 2398                                        &allow_dir_id_ext, &iso_level, 0);
 2399      if(ret <= 0)
 2400        goto ex;
 2401    }
 2402  continue; /* regular bottom of loop */
 2403 problem_handler_2:;
 2404    was_failure= 1;
 2405    fret= Xorriso_eval_problem_status(xorriso, ret, 1|2);
 2406    if(fret>=0)
 2407  continue;
 2408    goto ex;
 2409  }
 2410 
 2411  if(old_root[0]) {
 2412    /* Delete all visited nodes which were not found on disk */
 2413    if(root_seen)
 2414      rm_merge_args[0]= xorriso->wdi;
 2415    else
 2416      rm_merge_args[0]= "/";
 2417    rm_merge_args[1]= "-exec";
 2418    rm_merge_args[2]= "rm_merge";
 2419    zero= 0;
 2420    ret= Xorriso_option_find(xorriso, 3, rm_merge_args, &zero, 2);
 2421    if(ret<=0)
 2422      goto ex;
 2423  }
 2424 
 2425  if(lower_r) {
 2426    static char *lower_r_args[3]= {"/", "-exec", "mkisofs_r"};
 2427    zero= 0;
 2428    ret= Xorriso_option_find(xorriso, 3, lower_r_args, &zero, 2);
 2429    if(ret<=0)
 2430      goto ex;
 2431  }
 2432  if(dir_mode >= 0) {
 2433    static char *dir_mode_args[6]= {"/", "-type", "d", "-exec", "chmod", ""};
 2434    zero= 0;
 2435    sprintf(sfe, "0%o", (unsigned int) dir_mode);
 2436    dir_mode_args[5]= sfe;
 2437    ret= Xorriso_option_find(xorriso, 6, dir_mode_args, &zero, 2);
 2438    if(ret<=0)
 2439      goto ex;
 2440  }
 2441  if(file_mode >= 0) {
 2442    static char *file_mode_args[6]= {"/", "-type", "f", "-exec", "chmod", ""};
 2443    zero= 0;
 2444    sprintf(sfe, "0%o", (unsigned int) file_mode);
 2445    file_mode_args[5]= sfe;
 2446    ret= Xorriso_option_find(xorriso, 6, file_mode_args, &zero, 2);
 2447    if(ret<=0)
 2448      goto ex;
 2449  }
 2450 
 2451  if(sort_file[0]) {
 2452    ret= Xorriso_apply_sort_file(xorriso, sort_file, sort_file_pattern);
 2453    if(ret<=0)
 2454      goto ex;
 2455  }
 2456 
 2457  for(j= 0; j < weight_count; j++) {
 2458    i= weight_list[j];
 2459    /* find argv[i+2] -exec sort_weight argv[i+1] */
 2460    zero= 0;
 2461    sort_weight_args[0]= argv[i + 2];
 2462    sort_weight_args[1]= "-exec";
 2463    sort_weight_args[2]= "sort_weight";
 2464    sort_weight_args[3]= argv[i + 1];
 2465    ret= Xorriso_option_find(xorriso, 4, sort_weight_args, &zero, 2);
 2466    if(ret > 0)
 2467  continue;
 2468    /* Problem handler */
 2469    was_failure= 1;
 2470    fret= Xorriso_eval_problem_status(xorriso, ret, 1|2);
 2471    if(fret>=0)
 2472  continue;
 2473    goto ex;
 2474  }
 2475 
 2476  if(option_d)
 2477    Xorriso_relax_compliance(xorriso, "deep_paths:long_paths", 0);
 2478 
 2479  /* After all pathspecs are added: perform delayed options, mostly boot related
 2480  */
 2481  for(j= 0; j < delay_opt_count; j++) {
 2482    i= delay_opt_list[j] & ~(1u << 31);
 2483    if(delay_opt_list[j] & (1u << 31))
 2484      argpt= argv[i] + 1;
 2485    else
 2486      argpt= argv[i];
 2487    if(strcmp(argpt, "-no-emul-boot")==0) {
 2488      xorriso->boot_image_emul= 0;
 2489      xorriso->boot_emul_default= 0;
 2490    } else if(strcmp(argpt, "-hard-disk-boot")==0) {
 2491      xorriso->boot_image_emul= 1;
 2492      xorriso->boot_emul_default= 0;
 2493    } else if(strcmp(argpt, "-boot-info-table")==0) {
 2494      xorriso->patch_isolinux_image= (xorriso->patch_isolinux_image & ~2) | 1;
 2495    } else if(strcmp(argpt, "--grub2-boot-info") == 0) {
 2496      xorriso->patch_isolinux_image=
 2497                                   (xorriso->patch_isolinux_image & ~2) | 512;
 2498    } else if(strcmp(argpt, "-b") == 0 ||
 2499              strcmp(argpt, "-eltorito-boot") == 0 ||
 2500              strcmp(argpt, "--efi-boot") == 0 ||
 2501              strcmp(argpt, "-e") == 0) {
 2502      i++;
 2503      if(strcmp(argpt, "--efi-boot") == 0) {
 2504        if(xorriso->boot_image_bin_path[0]) {
 2505          ret= Xorriso_genisofs_add_boot(xorriso, 0);
 2506          if(ret <= 0)
 2507            goto problem_handler_boot;
 2508        }
 2509        boot_path= xorriso->boot_image_bin_path;
 2510        xorriso->boot_efi_default= 1;
 2511        xorriso->boot_image_emul= 0;
 2512        xorriso->boot_emul_default= 0;
 2513 
 2514      } else {
 2515        boot_path= xorriso->boot_image_bin_path; 
 2516        if(strcmp(argpt, "-e") == 0)
 2517          xorriso->boot_platform_id= 0xef;
 2518        else
 2519          xorriso->boot_platform_id= mkisofs_b_platform_id;
 2520        xorriso->boot_efi_default= 0;
 2521        if(xorriso->boot_emul_default)
 2522          xorriso->boot_image_emul= 2;
 2523      }
 2524      boot_path[0]= 0;
 2525      if(argv[i][0] != '/' && strncmp(argv[i], "--interval:", 11) != 0)
 2526        strcat(boot_path, "/");
 2527      ret= Sfile_str(boot_path + strlen(boot_path), argv[i], 0);
 2528      if(ret <= 0)
 2529        goto ex;
 2530      if(xorriso->boot_efi_default && xorriso->boot_image_bin_path[0]) {
 2531        ret= Xorriso_genisofs_add_boot(xorriso, 0);
 2532        if(ret <= 0)
 2533          goto problem_handler_boot;
 2534      }
 2535      xorriso->keep_boot_image= 0;
 2536      with_boot_image= 1;
 2537    } else if(strcmp(argpt, "-eltorito-platform") == 0) {
 2538      if(i + 1>=argc)
 2539        goto not_enough_args;
 2540      i++;
 2541      mem= mkisofs_b_platform_id;
 2542      mkisofs_b_platform_id= Xorriso_genisofs_platform(xorriso, argv[i], 0);
 2543      if(mkisofs_b_platform_id < 0) {
 2544        mkisofs_b_platform_id= 0;
 2545        goto problem_handler_boot;
 2546      }
 2547      if(mkisofs_b_platform_id != mem &&
 2548         xorriso->boot_image_bin_path[0] != 0) {
 2549        ret= Xorriso_genisofs_add_boot(xorriso, 0);
 2550        if(ret <= 0)
 2551          goto problem_handler_boot;
 2552      }
 2553 
 2554    } else if(strcmp(argpt, "-c") == 0 ||
 2555              strcmp(argpt, "-eltorito-catalog") == 0) {
 2556      if(i+1>=argc)
 2557        goto not_enough_args;
 2558      i++;
 2559      xorriso->boot_image_cat_path[0]= 0;
 2560      if(argv[i][0] != '/')
 2561        strcat(xorriso->boot_image_cat_path, "/");
 2562      ret= Sfile_str(xorriso->boot_image_cat_path
 2563                     + strlen(xorriso->boot_image_cat_path), argv[i], 0);
 2564      if(ret <= 0)
 2565        goto ex;
 2566      if(with_cat_path == 0)
 2567        with_cat_path= 1;
 2568    } else if(strcmp(argpt, "-boot-load-size") == 0) {
 2569      if(i+1>=argc)
 2570        goto not_enough_args;
 2571      i++;
 2572      if(strcmp(argv[i], "full") == 0) {
 2573        xorriso->boot_img_full_size= 1;
 2574      } else {
 2575        sscanf(argv[i], "%d", &ret);
 2576        xorriso->boot_image_load_size= ret * 512;
 2577      }
 2578      xorriso->boot_img_size_default= 0;
 2579    } else if(strcmp(argpt, "-eltorito-id") == 0 ||
 2580              strcmp(argpt, "-eltorito-selcrit") == 0) {
 2581      if(i+1>=argc)
 2582        goto not_enough_args;
 2583      i++;
 2584      if(strcmp(argpt, "-eltorito-id") == 0)
 2585        sprintf(sfe, "id_string=%s", argv[i]);
 2586      else
 2587        sprintf(sfe, "sel_crit=%s", argv[i]);
 2588      ret= Xorriso_option_boot_image(xorriso, "any", sfe, 0);
 2589      if(ret <= 0)
 2590        goto problem_handler_boot;
 2591    } else if(strncmp(argpt, "isolinux_mbr=", 13)==0) {
 2592      sprintf(sfe, "isohybrid=%s", argpt + 13);
 2593      ret= Xorriso_option_boot_image(xorriso, "isolinux", sfe, 0);
 2594      if(ret <= 0)
 2595        goto problem_handler_boot;
 2596    } else if(strcmp(argpt, "-isohybrid-gpt-basdat") == 0) {
 2597      xorriso->patch_isolinux_image = (xorriso->patch_isolinux_image & ~0x0fc) |
 2598                                      (1 << 2);
 2599    } else if(strcmp(argpt, "-isohybrid-gpt-hfsplus") == 0) {
 2600      xorriso->patch_isolinux_image = (xorriso->patch_isolinux_image & ~0x0fc) |
 2601                                      (2 << 2);
 2602    } else if(strcmp(argpt, "-isohybrid-apm-hfsplus") == 0) {
 2603      xorriso->patch_isolinux_image = xorriso->patch_isolinux_image | (1 << 8);
 2604 
 2605    } else if(strcmp(argpt, "-part_like_isohybrid") == 0) {
 2606      xorriso->part_like_isohybrid= 1;
 2607 
 2608    } else if(strcmp(argpt, "-iso_mbr_part_type") == 0) {
 2609      if(i + 1 >= argc)
 2610        goto not_enough_args;
 2611      i++;
 2612      sprintf(sfe, "iso_mbr_part_type=%s", argv[i]);
 2613      ret= Xorriso_option_boot_image(xorriso, "any", sfe, 0);
 2614      if(ret <= 0)
 2615        goto problem_handler_boot;
 2616 
 2617    } else if(strcmp(argpt, "--gpt_disk_guid") == 0) {
 2618      if(i + 1 >= argc)
 2619        goto not_enough_args;
 2620      i++;
 2621      ret= Xorriso_parse_gpt_guid(xorriso, argv[i], 0);
 2622      if(ret <= 0)
 2623        goto problem_handler_boot;
 2624 
 2625    } else if(strcmp(argpt, "-eltorito-alt-boot")==0) {
 2626      ret= Xorriso_genisofs_add_boot(xorriso, 0);
 2627      if(ret <= 0)
 2628        goto problem_handler_boot;
 2629    } else if(strcmp(argpt, "--embedded-boot")==0 ||
 2630              strcmp(argpt, "-generic-boot")==0 ||
 2631              strcmp(argpt, "-G") == 0 ||
 2632              strcmp(argpt, "-isohybrid-mbr") == 0 ||
 2633              strcmp(argpt, "--grub2-mbr") == 0) {
 2634      if(i+1>=argc)
 2635        goto not_enough_args;
 2636      i++; 
 2637      if(strcmp(argv[i], ".") == 0)
 2638        sa_path= "";
 2639      else
 2640        sa_path= argv[i];
 2641      ret= Xorriso_set_system_area_path(xorriso, sa_path, 0);
 2642      if(ret <= 0)
 2643        goto problem_handler_boot;
 2644      if(strcmp(argpt, "-isohybrid-mbr")==0)
 2645        xorriso->system_area_options=
 2646                                     (xorriso->system_area_options & ~4001) | 2;
 2647      else if(strcmp(argpt, "--grub2-mbr") == 0)
 2648        xorriso->system_area_options= 
 2649                                   (xorriso->system_area_options & ~2) | 0x4000;
 2650    } else if(strcmp(argpt, "--protective-msdos-label")==0) {
 2651      xorriso->system_area_options= (xorriso->system_area_options & ~2) | 1;
 2652 
 2653    } else if(strcmp(argpt, "--mbr-force-bootable") == 0) {
 2654      xorriso->system_area_options= xorriso->system_area_options | (1 << 15);
 2655 
 2656    } else if(strcmp(argpt, "--boot-catalog-hide")==0) {
 2657      xorriso->boot_image_cat_hidden|= 3;
 2658    } else if(strcmp(argpt, "-partition_offset") == 0 ||
 2659              strcmp(argpt, "-partition_sec_hd") == 0 ||
 2660              strcmp(argpt, "-partition_hd_cyl") == 0 ||
 2661              strcmp(argpt, "-partition_cyl_align") == 0) {
 2662      if(i+1>=argc)
 2663        goto not_enough_args;
 2664      i++;
 2665      sprintf(sfe, "%s=%.16s", argpt + 1, argv[i]);
 2666      ret= Xorriso_option_boot_image(xorriso, "any", sfe, 0);
 2667      if(ret <= 0)
 2668        goto problem_handler_boot;
 2669 
 2670    } else if(strcmp(argpt, "-mips-boot") == 0 ||
 2671              strcmp(argpt, "-mipsel-boot") == 0) {
 2672      if(i + 1 >= argc)
 2673        goto not_enough_args;
 2674      i++;
 2675      if(strcmp(argpt, "-mipsel-boot") == 0)
 2676        strcpy(sfe, "mipsel_path=");
 2677      else
 2678        strcpy(sfe, "mips_path=");
 2679      ret= Sfile_str(sfe, argv[i], 1);
 2680      if(ret <= 0)
 2681        goto ex;
 2682 
 2683      ret= Xorriso_option_boot_image(xorriso, "any", sfe, 0);
 2684      if(ret <= 0)
 2685        goto problem_handler_boot;
 2686 
 2687    } else if(strncmp(argpt, "-hppa-", 6) == 0) {
 2688      if(i + 1 >= argc)
 2689        goto not_enough_args;
 2690      i++;
 2691      sprintf(sfe, "-as mkisofs %s %s", argpt, argv[i]);
 2692      palohdrversion= (xorriso->system_area_options >> 2) & 0x3f;
 2693      if(palohdrversion != 4)
 2694        palohdrversion= 5;
 2695      ret= Xorriso_coordinate_system_area(xorriso, palohdrversion, 0, sfe, 0);
 2696      if(ret <= 0)
 2697        goto ex;
 2698      ret= Xorriso_set_hppa_boot_parm(xorriso, argv[i], argpt + 6, 0);
 2699      if(ret <= 0)
 2700        goto problem_handler_boot;
 2701 
 2702    } else if(strcmp(argpt, "-alpha-boot") == 0) {
 2703      if(i + 1 >= argc)
 2704        goto not_enough_args;
 2705      i++;
 2706      sprintf(sfe, "-as mkisofs %s %s", argpt, argv[i]);
 2707      ret= Xorriso_coordinate_system_area(xorriso, 6, 0, sfe, 0);
 2708      if(ret <= 0)
 2709        goto ex;
 2710      ret= Xorriso_set_alpha_boot(xorriso, argv[i], 0);
 2711 
 2712    } else if(strcmp(argpt, "-hfs-bless") == 0) {
 2713      static char *bless_arg_data[6]= {
 2714         "/", "-disk_path", "", "-exec", "set_hfs_bless", "p"};
 2715 
 2716      for(j= 0; j < 6; j++)
 2717        bless_args[j]= bless_arg_data[j];
 2718      bless_args[2]= argv[i + 1];
 2719      zero= 0;
 2720      ret= Xorriso_option_find(xorriso, 6, bless_args, &zero, 2 | 16);
 2721      if(ret<=0)
 2722         goto ex;
 2723      if(ret < 2) {
 2724        sprintf(xorriso->info_text,
 2725                "-hfs-bless: Could not find a data file which stems from underneath disk directory ");
 2726        Text_shellsafe(argv[i + 1], xorriso->info_text, 1);
 2727        Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
 2728        Xorriso_msgs_submit(xorriso, 0,
 2729                  "Consider to use: -hfs-bless-by p ISO_RR_PATH", 0, "HINT", 0);
 2730        goto problem_handler_boot;
 2731      }
 2732 
 2733    } else if(strcmp(argpt, "-hfs-bless-by") == 0) {
 2734      ret= Xorriso_hfsplus_bless(xorriso, argv[i + 2], NULL, argv[i + 1], 0);
 2735      if(ret <= 0)
 2736        goto problem_handler_boot;
 2737 
 2738    } else if(strcmp(argpt, "-hfsplus-file-creator-type") == 0) {
 2739      ret= Xorriso_hfsplus_file_creator_type(xorriso, argv[i + 3], NULL,
 2740                                             argv[i + 1],  argv[i + 2], 0);
 2741      if(ret <= 0)
 2742        goto problem_handler_boot;
 2743 
 2744    }
 2745  continue; /* regular bottom of loop */
 2746 problem_handler_boot:;
 2747    /* Problem handler */
 2748    was_failure= 1;
 2749    fret= Xorriso_eval_problem_status(xorriso, ret, 1|2);
 2750    if(fret>=0)
 2751  continue;
 2752    goto ex;
 2753  }
 2754  if(with_boot_image && with_cat_path == 0)
 2755    strcpy(xorriso->boot_image_cat_path, "/boot.catalog");
 2756  /* The boot catalog has to be hidden separately */
 2757  if(xorriso->boot_image_cat_path[0]) {
 2758    ret= Xorriso_path_is_hidden(xorriso, xorriso->boot_image_cat_path, 0);
 2759    if(ret > 0)
 2760      xorriso->boot_image_cat_hidden|= ret;
 2761    else if(ret < 0)
 2762      was_failure= 1;
 2763  }
 2764 
 2765  /* Enforce the -boot-load-size default of mkisofs */
 2766  if(with_boot_image && xorriso->boot_img_size_default &&
 2767     xorriso->boot_image_emul == 0)
 2768    xorriso->boot_img_full_size= 1;
 2769 
 2770  if(xorriso->no_emul_toc & 1)
 2771    xorriso->do_padding_by_libisofs= 1;
 2772 
 2773  if(do_print_size) {
 2774    ret= Xorriso_option_print_size(xorriso, 1);
 2775    goto ex;
 2776  }
 2777 
 2778  ret= !was_failure;
 2779 ex:;
 2780  if(was_path && (!do_print_size) && !old_root[0])
 2781    Xorriso_pacifier_callback(xorriso, "files added", xorriso->pacifier_count,
 2782                              xorriso->pacifier_total, "", 1);
 2783  if(do_print_size && Xorriso_change_is_pending(xorriso, 1))
 2784    xorriso->volset_change_pending= 2;
 2785  if(weight_list != NULL)
 2786    free(weight_list);
 2787  if(delay_opt_list != NULL)
 2788    free(delay_opt_list);
 2789  Xorriso_free_meM(sort_file);
 2790  Xorriso_free_meM(sfe);
 2791  Xorriso_free_meM(adr);
 2792  Xorriso_free_meM(pathspec);
 2793  Xorriso_free_meM(eff_path);
 2794  Xorriso_free_meM(indev);
 2795  Xorriso_free_meM(old_root);
 2796  return(ret);
 2797 }
 2798 
 2799 
 2800 int Xorriso_as_genisofs(struct XorrisO *xorriso, int argc, char **argv,
 2801                       int *idx, int flag)
 2802 {
 2803  int end_idx, ret, old_idx;
 2804 
 2805  old_idx= *idx;
 2806  end_idx= Xorriso_end_idx(xorriso, argc, argv, *idx, 1);
 2807  (*idx)= end_idx;
 2808  if(end_idx<=0 || old_idx>=argc)
 2809    return(1);
 2810  ret= Xorriso_genisofs(xorriso, "genisofs", end_idx-old_idx, argv+old_idx, 0);
 2811  return(ret);
 2812 }
 2813 
 2814 
 2815 int Xorriso_as_cdrskin(struct XorrisO *xorriso, int argc, char **argv,
 2816                       int *idx, int flag)
 2817 {
 2818  int end_idx, ret, old_idx;
 2819 
 2820  old_idx= *idx;
 2821  end_idx= Xorriso_end_idx(xorriso, argc, argv, *idx, 1);
 2822  (*idx)= end_idx;
 2823  if(end_idx<=0 || old_idx>=argc)
 2824    return(1);
 2825  ret= Xorriso_cdrskin(xorriso, "cdrskin", end_idx-old_idx, argv+old_idx, 0);
 2826  return(ret);
 2827 }
 2828