Made behavior of -as mkisofs with unknown options more similar to original

This commit is contained in:
Thomas Schmitt 2010-07-08 15:59:45 +00:00
parent 54142334d0
commit 9d2a592879
2 changed files with 120 additions and 9 deletions

View File

@ -494,6 +494,108 @@ ex:;
}
/* This function shall know all options of mkisofs, genisoimage, xorrisofs, ...
and the number of arguments which they expect and consume.
*/
int Xorriso_genisofs_count_args(struct XorrisO *xorriso, int argc, char **argv,
int *count, int flag)
{
int i;
char *cmd;
static char partial_options[][41]= {
"errctl=",
"isolinux_mbr=", "--modification-date=",
""
};
static char arg0_options[][41]= {
"-allow-leading-dots", "-ldots", "-allow-lowercase", "-allow-multidot",
"-cache-inodes", "-no-cache-inodes", "-eltorito-alt-boot",
"-hard-disk-boot", "-no-emul-boot", "-no-boot", "-boot-info-table",
"-check-oldnames", "-d", "-D", "-dvd-video", "-f", "-gui", "-graft-points",
"-hide-joliet-trans-tbl", "-hide-rr-moved", "-J", "-joliet-long", "-l",
"-L", "-max-iso9660-filenames", "-N", "-nobak", "-no-bak",
"-no-limit-pathtables", "-force-rr", "-no-rr",
"-no-split-symlink-components", "-no-split-symlink-fields", "-pad",
"-no-pad", "-posix-H", "-posix-L", "-posix-P", "-print-size",
"-quiet", "-R", "-r", "-relaxed-filenames", "-rrip110", "-rrip112",
"-split-output", "-T", "-UDF", "-udf", "-udf-symlinks", "-no-udf-symlinks",
"-U", "-no-iso-translate", "-v", "-XA", "-xa", "-z",
"-hfs", "-no-hfs", "-apple", "-probe", "-no-desktop", "-mac-name",
"-part", "-icon-position", "-chrp-t", "-hfs-unlock", "--cap", "--netatalk",
"--double", "--ethershare", "--ushare", "--exchange", "--sgi", "--xinet",
"--macbin", "--single", "--dave", "--sfm", "--osx-double", "--osx-hfs",
"-debug", "-omit-period", "-disable-deep-relocation", "-joliet",
"-full-iso9660-filenames", "-follow-links", "-help",
"-transparent-compression",
"-omit-version-number", "-rational-rock", "-rock", "-translation-table",
"-untranslated-filenames", "-verbose", "-version", "-g", "-h",
"-no-mac-files", "-chrp-boot",
"--hardlinks", "--acl", "--xattr", "--md5", "--for_backup",
"--protective-msdos-label", "--boot-catalog-hide", "--no-emul-toc",
""
};
static char arg1_options[][41]= {
"-abstract", "-A", "-appid", "-biblio", "-b", "-B", "-boot-load-seg",
"-boot-load-size", "-C", "-c", "-check-session", "-copyright",
"-dir-mode", "-file-mode", "-G", "-gid", "-hide", "-hide-list",
"-hidden", "-hidden-list", "-hide-joliet", "-hide-joliet-list",
"-hide-udf", "-hide-udf-list", "-input-charset", "-output-charset",
"-iso-level", "-jcharset", "-log-file", "-m", "-exclude-list", "-M",
"-dev", "-new-dir-mode", "-o", "-path-list", "-publisher", "-p", "-root",
"-old-root", "-s", "-sectype", "-sort", "-sparc-boot", "-sparc-label",
"-stream-media-size", "-stream-file-name", "-sunx86-boot", "-sunx86-label",
"-sysid", "-table-name", "-ucs-level", "-uid", "-V", "-volset",
"-volset-size", "-volset-seqno", "-x", "-P",
"-map", "-magic", "-hfs-creator", "-hfs-type", "-boot-hfs-file", "-auto",
"-cluster-size", "-hide-hfs", "-hide-hfs-list", "-hfs-volid",
"-root-info", "-prep-boot", "-input-hfs-charset", "-output-hfs-charset",
"-hfs-bless", "-hfs-parms",
"-eltorito-boot", "-generic-boot", "-eltorito-catalog", "-cdrecord-params",
"-errctl", "-exclude", "-prev-session", "-output", "-use-fileversion",
"-volid", "-old-exclude",
"-alpha-boot", "-hppa-cmdline", "-hppa-kernel-32", "-hppa-kernel-64",
"-hppa-bootloader", "-hppa-ramdisk", "-mips-boot", "-mipsel-boot",
"-jigdo-jigdo", "-jigdo-template", "-jigdo-min-file-size",
"-jigdo-force-md5", "-jigdo-exclude", "-jigdo-map", "-md5-list",
"--stdio_sync", "--quoted_path_list", "--efi-boot", "--embedded-boot",
"-isohybrid-mbr",
""
};
static char arg2_options[][41]= {
"--scdbackup_tag", "--sort-weight",
""
};
static char final_options[][41]= {
"-find",
""
};
cmd= argv[0];
*count= 0;
for(i=0; partial_options[i][0]!=0; i++)
if(strncmp(partial_options[i], cmd, strlen(partial_options[i]))==0)
return(1);
for(i=0; arg0_options[i][0]!=0; i++)
if(strcmp(arg0_options[i], cmd)==0)
return(1);
*count= 1;
for(i=0; arg1_options[i][0]!=0; i++)
if(strcmp(arg1_options[i], cmd)==0)
return(1);
*count= 2;
for(i=0; arg2_options[i][0]!=0; i++)
if(strcmp(arg2_options[i], cmd)==0)
return(1);
*count= argc - 1;
for(i=0; final_options[i][0]!=0; i++)
if(strcmp(final_options[i], cmd)==0)
return(1);
*count= 0;
return(0);
}
/* @param flag bit0= do not report eventual ignore decision
*/
int Xorriso_genisofs_ignore(struct XorrisO *xorriso, char *whom,
@ -740,7 +842,7 @@ int Xorriso_genisofs(struct XorrisO *xorriso, char *whom,
int ret, i, j, was_path= 0, was_other_option= 0, mem_graft_points, mem;
int do_print_size= 0, fd, idx, iso_level= 0, no_emul_boot= 0;
int option_b= 0, was_failure= 0, fret, lower_r= 0, zero= 0;
int dir_mode= -1, file_mode= -1;
int dir_mode= -1, file_mode= -1, count;
mode_t mode_and, mode_or;
int with_boot_image= 0, with_cat_path= 0;
int *weight_list= NULL, weight_count= 0;
@ -907,7 +1009,9 @@ int Xorriso_genisofs(struct XorrisO *xorriso, char *whom,
Xorriso_option_stdio_sync(xorriso, argv[i], 0);
} else
was_other_option= 1;
ret= Xorriso_genisofs_count_args(xorriso, argc - i, argv + i, &count, 0);
if(ret > 0)
i+= count; /* skip eventual arguments of known option */
continue; /* regular bottom of loop */
problem_handler_1:;
was_failure= 1;
@ -1092,7 +1196,8 @@ not_enough_args:;
xorriso->do_disk_pattern= mem;
if(ret<=0)
goto problem_handler_2;
} else if(strcmp(argv[i], "-v")==0 || strcmp(argv[i], "-quiet")==0) {
} else if(strcmp(argv[i], "-v")==0 || strcmp(argv[i], "-verbose")==0 ||
strcmp(argv[i], "-quiet")==0) {
/* was already handled in first argument scan */;
} else if(strcmp(argv[i], "-iso-level")==0) {
@ -1193,12 +1298,17 @@ not_enough_args:;
goto problem_handler_2;
file_mode= mode_or;
} else if(argv[i][0]=='-' && argv[i][1]!=0) {
sprintf(xorriso->info_text, "-as %s: Unknown option %s",
whom, Text_shellsafe(argv[i], sfe, 0));
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
ret= Xorriso_genisofs_count_args(xorriso, argc - i, argv + i, &count, 1);
if(ret > 0) {
sprintf(xorriso->info_text, "-as %s: Unsupported option %s",
whom, Text_shellsafe(argv[i], sfe, 0));
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
i+= count;
goto problem_handler_2;
} else
goto is_pathspec_2;
} else {
int zero= 0;
is_pathspec_2:;
/* implementing mkisofs tendency to map single-path pathspecs to / */
if((!xorriso->allow_graft_points) ||
Fileliste__target_source_limit(argv[i], '=', &ept, 0)<=0) {
@ -1225,6 +1335,7 @@ not_enough_args:;
add_pt= argv[i];
mem_graft_points= xorriso->allow_graft_points;
xorriso->allow_graft_points= 1;
zero= 0;
ret= Xorriso_option_add(xorriso, 1, &add_pt, &zero, was_path<<1);
xorriso->allow_graft_points= mem_graft_points;
if(ret<=0)

View File

@ -1 +1 @@
#define Xorriso_timestamP "2010.07.06.114503"
#define Xorriso_timestamP "2010.07.08.155900"