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