New option -read_mkisofsrc interprets .mkisofsrc
This commit is contained in:
parent
6ab8ffc137
commit
10233adb87
@ -95,6 +95,7 @@ int Xorriso_new(struct XorrisO ** xorriso,char *progname, int flag)
|
||||
for(i=0;i<m->rc_filename_count-1;i++)
|
||||
strcpy(m->rc_filenames[i],Xorriso_sys_rc_nameS[i]);
|
||||
m->rc_filenames[m->rc_filename_count-1][0]= 0;
|
||||
m->mkisofsrc_done= 0;
|
||||
|
||||
m->wdi[0]= 0;
|
||||
strcpy(m->wdx, m->initial_wdx);
|
||||
|
@ -1741,6 +1741,8 @@ int Xorriso_option_help(struct XorrisO *xorriso, int flag)
|
||||
" -no-emul-boot|-b|-c|-boot-info-table|-boot-load-size|-G]",
|
||||
" Perform some mkisofs gestures, understand pathspecs as mkisofs",
|
||||
" does. Commit happens outside emulation at usual occasions.",
|
||||
" -read_mkisofsrc",
|
||||
" Read and interpret the .mkisofsrc configuration file.",
|
||||
" -as cdrecord [-help|-v|dev=|speed=|blank=|fs=|-eject|-atip|padsize=|-multi]",
|
||||
" path|-",
|
||||
" Perform some cdrecord gestures, eventually write at most one",
|
||||
|
@ -349,6 +349,15 @@ int Xorriso_option_pwdx(struct XorrisO *xorriso, int flag)
|
||||
}
|
||||
|
||||
|
||||
int Xorriso_option_read_mkisofsrc(struct XorrisO *xorriso, int flag)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret= Xorriso_read_mkisofsrc(xorriso, 0);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
|
||||
/* Option -reassure "on"|"tree"|"off" */
|
||||
int Xorriso_option_reassure(struct XorrisO *xorriso, char *mode, int flag)
|
||||
{
|
||||
@ -1561,6 +1570,8 @@ int Xorriso_option_version(struct XorrisO *xorriso, int flag)
|
||||
|
||||
|
||||
/* Option -volid */
|
||||
/* @param flag bit0= do not warn of problematic volid
|
||||
*/
|
||||
int Xorriso_option_volid(struct XorrisO *xorriso, char *volid, int flag)
|
||||
{
|
||||
int warn_shell= 0, warn_ecma= 0, i, ret;
|
||||
@ -1579,17 +1590,17 @@ int Xorriso_option_volid(struct XorrisO *xorriso, char *volid, int flag)
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
|
||||
return(0);
|
||||
}
|
||||
if(warn_shell) {
|
||||
if(warn_shell && !(flag & 1)) {
|
||||
sprintf(xorriso->info_text,
|
||||
"-volid text problematic as automatic mount point name");
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0);
|
||||
}
|
||||
if(xorriso->do_joliet && strlen(volid)>16) {
|
||||
if(xorriso->do_joliet && strlen(volid)>16 && !(flag & 1)) {
|
||||
sprintf(xorriso->info_text,
|
||||
"-volid text is too long for Joliet (%d > 16)",(int) strlen(volid));
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0);
|
||||
}
|
||||
if(warn_ecma) {
|
||||
if(warn_ecma && !(flag & 1)) {
|
||||
sprintf(xorriso->info_text,
|
||||
"-volid text does not comply to ISO 9660 / ECMA 119 rules");
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0);
|
||||
|
@ -449,7 +449,8 @@ int Xorriso_count_args(struct XorrisO *xorriso, int argc, char **argv,
|
||||
"ban_stdio_write","close_filter_list","commit","devices","end",
|
||||
"for_backup", "help",
|
||||
"list_formats","no_rc","print_size","pvd_info","pwd","pwdi","pwdx",
|
||||
"rollback","rollback_end","tell_media_space","toc","version",
|
||||
"read_mkisofsrc","rollback","rollback_end",
|
||||
"tell_media_space","toc","version",
|
||||
""
|
||||
};
|
||||
static char arg1_commands[][40]= {
|
||||
@ -1136,6 +1137,9 @@ next_command:;
|
||||
(*idx)++;
|
||||
ret= Xorriso_option_path_list(xorriso, arg1, 1);
|
||||
|
||||
} else if(strcmp(cmd,"read_mkisofsrc")==0) {
|
||||
ret= Xorriso_option_read_mkisofsrc(xorriso, 0);
|
||||
|
||||
} else if(strcmp(cmd,"reassure")==0) {
|
||||
(*idx)++;
|
||||
ret= Xorriso_option_reassure(xorriso, arg1, 0);
|
||||
@ -1594,6 +1598,144 @@ ex:;
|
||||
}
|
||||
|
||||
|
||||
int Xorriso_read_as_mkisofsrc(struct XorrisO *xorriso, char *path, int flag)
|
||||
{
|
||||
int ret, linecount= 0;
|
||||
FILE *fp= NULL;
|
||||
char *sret, line[SfileadrL], *cpt, *wpt;
|
||||
|
||||
ret= Xorriso_afile_fopen(xorriso, path, "rb", &fp, 1 | 2);
|
||||
if(ret <= 0)
|
||||
{ret= 0; goto ex;}
|
||||
while(1) {
|
||||
sret= Sfile_fgets_n(line, SfileadrL - 1, fp, 0);
|
||||
if(sret == NULL) {
|
||||
if(ferror(fp))
|
||||
{ret= 0; goto ex;}
|
||||
break;
|
||||
}
|
||||
linecount++;
|
||||
|
||||
/* Interpret line */
|
||||
if(line[0] == 0 || line[0] == '#')
|
||||
continue;
|
||||
cpt= strchr(line, '=');
|
||||
if(cpt == NULL) {
|
||||
|
||||
/* >>> ??? complain ? abort reading ? */;
|
||||
|
||||
continue;
|
||||
}
|
||||
*cpt= 0;
|
||||
/* Names are not case sensitive */
|
||||
for(wpt= line; wpt < cpt; wpt++)
|
||||
if(*wpt >= 'a' && *wpt <= 'z')
|
||||
*wpt= toupper(*wpt);
|
||||
/* Remove trailing whitespace from name */
|
||||
for(wpt= cpt - 1; wpt >= line ; wpt--)
|
||||
if(*wpt == ' ' || *wpt == '\t')
|
||||
*wpt= 0;
|
||||
else
|
||||
break;
|
||||
/* Remove trailing whitespace from value */
|
||||
for(wpt= cpt + 1 + strlen(cpt + 1) - 1; wpt >= cpt; wpt--)
|
||||
if(*wpt == ' ' || *wpt == '\t')
|
||||
*wpt= 0;
|
||||
else
|
||||
break;
|
||||
/* Remove leading whitespace from value */
|
||||
for(cpt++; *cpt == ' ' || *cpt == '\t'; cpt++);
|
||||
|
||||
if(strcmp(line, "APPI") == 0) {
|
||||
ret= Xorriso_option_application_id(xorriso, cpt, 0);
|
||||
} else if(strcmp(line, "COPY") == 0) {
|
||||
|
||||
/* >>> to come: -copyright_file */;
|
||||
|
||||
ret= 1;
|
||||
} else if(strcmp(line, "ABST") == 0) {
|
||||
|
||||
/* >>> to come: -abstract_file */;
|
||||
|
||||
ret= 1;
|
||||
} else if(strcmp(line, "BIBL") == 0) {
|
||||
|
||||
/* >>> to come: -biblio_file */;
|
||||
|
||||
ret= 1;
|
||||
} else if(strcmp(line, "PREP") == 0) {
|
||||
/* Not planned to come */
|
||||
ret= 1;
|
||||
} else if(strcmp(line, "PUBL") == 0) {
|
||||
ret= Xorriso_option_publisher(xorriso, cpt, 0);
|
||||
} else if(strcmp(line, "SYSI") == 0) {
|
||||
ret= Xorriso_option_system_id(xorriso, cpt, 0);
|
||||
} else if(strcmp(line, "VOLI") == 0) {
|
||||
ret= Xorriso_option_volid(xorriso, cpt, 1);
|
||||
} else if(strcmp(line, "VOLS") == 0) {
|
||||
ret= Xorriso_option_volset_id(xorriso, cpt, 0);
|
||||
} else if(strcmp(line, "HFS_TYPE") == 0) {
|
||||
/* Not planned to come */
|
||||
ret= 1;
|
||||
} else if(strcmp(line, "HFS_CREATOR") == 0) {
|
||||
/* Not planned to come */
|
||||
ret= 1;
|
||||
} else {
|
||||
|
||||
/* >>> ??? complain ? abort reading ? */;
|
||||
|
||||
}
|
||||
}
|
||||
xorriso->mkisofsrc_done= 1;
|
||||
ret= 1;
|
||||
ex:
|
||||
if(fp != NULL)
|
||||
fclose(fp);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
|
||||
/* ./.mkisofsrc , getenv("MKISOFSRC") ,
|
||||
$HOME/.mkisofsrc , $(basename $0)/.mkisofsrc
|
||||
*/
|
||||
int Xorriso_read_mkisofsrc(struct XorrisO *xorriso, int flag)
|
||||
{
|
||||
char path[SfileadrL], *cpt;
|
||||
int ret;
|
||||
|
||||
ret= Xorriso_read_as_mkisofsrc(xorriso, "./.mkisofsrc", 0);
|
||||
if(ret > 0)
|
||||
return(ret);
|
||||
cpt= getenv("MKISOFSRC");
|
||||
if(cpt != NULL) {
|
||||
strncpy(path, cpt, SfileadrL - 1);
|
||||
path[SfileadrL - 1]= 0;
|
||||
ret= Xorriso_read_as_mkisofsrc(xorriso, path, 0);
|
||||
if(ret > 0)
|
||||
return(ret);
|
||||
}
|
||||
cpt= getenv("HOME");
|
||||
if(cpt != NULL) {
|
||||
strncpy(path, cpt, SfileadrL - 1 - 11);
|
||||
path[SfileadrL - 1 - 11]= 0;
|
||||
strcat(path, "/.mkisofsrc");
|
||||
ret= Xorriso_read_as_mkisofsrc(xorriso, path, 0);
|
||||
if(ret > 0)
|
||||
return(ret);
|
||||
}
|
||||
strcpy(path, xorriso->progname);
|
||||
cpt= strrchr(path, '/');
|
||||
if(cpt != NULL) {
|
||||
strcpy(cpt + 1, ".mkisofsrc");
|
||||
ret= Xorriso_read_as_mkisofsrc(xorriso, path, 0);
|
||||
if(ret > 0)
|
||||
return(ret);
|
||||
}
|
||||
/* no .mkisofsrc file found */
|
||||
return(2);
|
||||
}
|
||||
|
||||
|
||||
int Xorriso_read_rc(struct XorrisO *xorriso, int flag)
|
||||
{
|
||||
int ret,i,was_failure= 0,fret;
|
||||
@ -1618,6 +1760,11 @@ int Xorriso_read_rc(struct XorrisO *xorriso, int flag)
|
||||
continue;
|
||||
return(ret);
|
||||
}
|
||||
if(xorriso->argument_emulation == 1 && !xorriso->mkisofsrc_done) {
|
||||
ret= Xorriso_read_mkisofsrc(xorriso, 0);
|
||||
if(ret <= 0)
|
||||
was_failure= 1;
|
||||
}
|
||||
return(!was_failure);
|
||||
}
|
||||
|
||||
|
@ -86,6 +86,7 @@ int Xorriso_path_is_hidden(struct XorrisO *xorriso, char *path, int flag);
|
||||
int Xorriso_normalize_acl_text(struct XorrisO *xorriso, char *in_text,
|
||||
char **access_acl_text, char **default_acl_text, int flag);
|
||||
|
||||
int Xorriso_read_mkisofsrc(struct XorrisO *xorriso, int flag);
|
||||
|
||||
#endif /* ! Xorriso_pvt_cmd_includeD */
|
||||
|
||||
|
@ -28,7 +28,7 @@
|
||||
#include "sfile.h"
|
||||
|
||||
|
||||
/* @param flag bit0= do not clip of carriage return at line end
|
||||
/* @param flag bit0= do not clip off carriage return at line end
|
||||
*/
|
||||
char *Sfile_fgets_n(char *line, int maxl, FILE *fp, int flag)
|
||||
{
|
||||
|
@ -9,7 +9,7 @@
|
||||
.\" First parameter, NAME, should be all caps
|
||||
.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
|
||||
.\" other parameters are allowed: see man(7), man(1)
|
||||
.TH XORRISO 1 "Jun 24, 2010"
|
||||
.TH XORRISO 1 "Jun 25, 2010"
|
||||
.\" Please adjust this date whenever revising the manpage.
|
||||
.\"
|
||||
.\" Some roff macros, for reference:
|
||||
@ -389,8 +389,9 @@ An \fBMBR\fR contains boot code and a partition table. It does not hamper
|
||||
CDROM booting. The new MBR of a follow-up session can get in effect
|
||||
only on overwriteable media.
|
||||
.br
|
||||
Emulation -as mkisofs supports the example options out of the ISOLINUX wiki.
|
||||
It also supports the options used in GRUB script grub-mkrescue.
|
||||
Emulation -as mkisofs supports the example options out of the ISOLINUX wiki,
|
||||
the options used in GRUB script grub-mkrescue, and the example in the
|
||||
FreeBSD AvgLiveCD wiki.
|
||||
.br
|
||||
The support for other boot image types is sparse.
|
||||
.br
|
||||
@ -3184,7 +3185,8 @@ Personality "\fBmkisofs\fR" accepts the options listed with:
|
||||
.br
|
||||
-as mkisofs -help --
|
||||
.br
|
||||
Among them: -R (always on), -r, -J, -o, -M, -C, -path-list, -m, -exclude-list,
|
||||
Among them: -R (always on), -r, -J, -o, -M, -C, -dir-mode, -file-mode,
|
||||
-path-list, -m, -exclude-list,
|
||||
-f, -print-size, -pad, -no-pad, -V, -v, -version, -graft-points, -z,
|
||||
-no-emul-boot, -b, -c, -boot-info-table, -boot-load-size, -input-charset, -G,
|
||||
-output-charset, -U, -hide, -hide-joliet, -hide-list, -hide-joliet-list,
|
||||
@ -3293,6 +3295,20 @@ to the command line arguments. I.e. all arguments will be interpreted cdrecord
|
||||
style until "--" is encountered and an eventual commit happens.
|
||||
From then on, options are interpreted as xorriso options.
|
||||
.TP
|
||||
\fB\-read_mkisofsrc\fR
|
||||
Try one by one to open for reading:
|
||||
./.mkisofsrc , $MKISOFSRC , $HOME/.mkisofsrc , $(basename $0)/.mkisofs
|
||||
.br
|
||||
On success interpret the file content as of man mkisofs CONFIGURATION,
|
||||
and end this command. Do not try further files.
|
||||
The last address is used only if start argument 0 has a non-trivial basename.
|
||||
.br
|
||||
The reader currently interprets the following NAME=VALUE pairs:
|
||||
APPI (-application_id) , PUBL (-publisher) , SYSI (-system_id) ,
|
||||
VOLI (-volid) , VOLS (-volset_id)
|
||||
.br
|
||||
Any other lines will be silently ignored.
|
||||
.TP
|
||||
\fB\-pacifier\fR behavior_code
|
||||
Control behavior of UPDATE pacifiers during write operations.
|
||||
The following behavior codes are defined:
|
||||
|
@ -1015,6 +1015,9 @@ int Xorriso_option_pwdi(struct XorrisO *xorriso, int flag);
|
||||
/* Option -pwdx */
|
||||
int Xorriso_option_pwdx(struct XorrisO *xorriso, int flag);
|
||||
|
||||
/* Option -read_mkisofsrc */
|
||||
int Xorriso_option_read_mkisofsrc(struct XorrisO *xorriso, int flag);
|
||||
|
||||
/* Option -reassure "on"|"tree"|"off" */
|
||||
int Xorriso_option_reassure(struct XorrisO *xorriso, char *mode, int flag);
|
||||
|
||||
@ -1139,6 +1142,8 @@ int Xorriso_option_use_readline(struct XorrisO *xorriso, char *mode, int flag);
|
||||
int Xorriso_option_version(struct XorrisO *xorriso, int flag);
|
||||
|
||||
/* Option -volid */
|
||||
/* @param flag bit0= do not warn of problematic volid
|
||||
*/
|
||||
int Xorriso_option_volid(struct XorrisO *xorriso, char *volid, int flag);
|
||||
|
||||
/* Option -volset_id */
|
||||
|
@ -345,7 +345,8 @@ needs of GRUB resp. ISOLINUX. An *MBR* contains boot code and a
|
||||
partition table. It does not hamper CDROM booting. The new MBR of a
|
||||
follow-up session can get in effect only on overwriteable media.
|
||||
Emulation -as mkisofs supports the example options out of the ISOLINUX
|
||||
wiki. It also supports the options used in GRUB script grub-mkrescue.
|
||||
wiki, the options used in GRUB script grub-mkrescue, and the example in
|
||||
the FreeBSD AvgLiveCD wiki.
|
||||
The support for other boot image types is sparse.
|
||||
|
||||
*ACL* are an advanced way of controlling access permissions to file
|
||||
@ -2847,14 +2848,14 @@ programs trigger comparable actions.
|
||||
|
||||
Personality "*mkisofs*" accepts the options listed with:
|
||||
-as mkisofs -help --
|
||||
Among them: -R (always on), -r, -J, -o, -M, -C, -path-list, -m,
|
||||
-exclude-list, -f, -print-size, -pad, -no-pad, -V, -v, -version,
|
||||
-graft-points, -z, -no-emul-boot, -b, -c, -boot-info-table,
|
||||
-boot-load-size, -input-charset, -G, -output-charset, -U, -hide,
|
||||
-hide-joliet, -hide-list, -hide-joliet-list, file paths and
|
||||
pathspecs. A lot of options are not supported and lead to failure
|
||||
of the mkisofs emulation. Some are ignored, but better do not rely
|
||||
on this tolerance.
|
||||
Among them: -R (always on), -r, -J, -o, -M, -C, -dir-mode,
|
||||
-file-mode, -path-list, -m, -exclude-list, -f, -print-size, -pad,
|
||||
-no-pad, -V, -v, -version, -graft-points, -z, -no-emul-boot, -b,
|
||||
-c, -boot-info-table, -boot-load-size, -input-charset, -G,
|
||||
-output-charset, -U, -hide, -hide-joliet, -hide-list,
|
||||
-hide-joliet-list, file paths and pathspecs. A lot of options are
|
||||
not supported and lead to failure of the mkisofs emulation. Some
|
||||
are ignored, but better do not rely on this tolerance.
|
||||
-graft-points is equivalent to -pathspecs on. Note that pathspecs
|
||||
without "=" are interpreted differently than with xorriso option
|
||||
-add. Directories get merged with the root directory of the ISO
|
||||
@ -2935,6 +2936,18 @@ programs trigger comparable actions.
|
||||
an eventual commit happens. From then on, options are interpreted
|
||||
as xorriso options.
|
||||
|
||||
-read_mkisofsrc
|
||||
Try one by one to open for reading: ./.mkisofsrc , $MKISOFSRC ,
|
||||
$HOME/.mkisofsrc , $(basename $0)/.mkisofs
|
||||
On success interpret the file content as of man mkisofs
|
||||
CONFIGURATION, and end this command. Do not try further files.
|
||||
The last address is used only if start argument 0 has a
|
||||
non-trivial basename.
|
||||
The reader currently interprets the following NAME=VALUE pairs:
|
||||
APPI (-application_id) , PUBL (-publisher) , SYSI (-system_id) ,
|
||||
VOLI (-volid) , VOLS (-volset_id)
|
||||
Any other lines will be silently ignored.
|
||||
|
||||
-pacifier behavior_code
|
||||
Control behavior of UPDATE pacifiers during write operations. The
|
||||
following behavior codes are defined:
|
||||
@ -3795,7 +3808,7 @@ File: xorriso.info, Node: CommandIdx, Next: ConceptIdx, Prev: Legal, Up: Top
|
||||
* -out_charset sets output character set: SetWrite. (line 122)
|
||||
* -outdev aquires a drive for output: AqDrive. (line 29)
|
||||
* -overwrite enables overwriting in ISO: SetInsert. (line 127)
|
||||
* -pacifier controls pacifier text form: Emulation. (line 107)
|
||||
* -pacifier controls pacifier text form: Emulation. (line 119)
|
||||
* -padding sets amount of image padding: SetWrite. (line 205)
|
||||
* -page set terminal geometry: DialogCtl. (line 15)
|
||||
* -paste_in copies file into disk file: Restore. (line 117)
|
||||
@ -3813,6 +3826,8 @@ File: xorriso.info, Node: CommandIdx, Next: ConceptIdx, Prev: Legal, Up: Top
|
||||
* -pwdx tells working directory on disk: Navigate. (line 23)
|
||||
* -quoted_not_list sets exclusions: SetInsert. (line 72)
|
||||
* -quoted_path_list inserts paths from disk file: Insert. (line 80)
|
||||
* -read_mkisofsrc searches and reads .mkisofsrc file: Emulation.
|
||||
(line 107)
|
||||
* -reassure enables confirmation question: DialogCtl. (line 28)
|
||||
* -report_about controls verbosity: Exception. (line 55)
|
||||
* -return_with controls exit value: Exception. (line 39)
|
||||
@ -3822,7 +3837,7 @@ File: xorriso.info, Node: CommandIdx, Next: ConceptIdx, Prev: Legal, Up: Top
|
||||
* -rollback discards pending changes: Writing. (line 9)
|
||||
* -rollback_end ends program without writing: Scripting. (line 125)
|
||||
* -rom_toc_scan searches for sessions: Loading. (line 184)
|
||||
* -scdbackup_tag enables scdbackup checksum tag: Emulation. (line 117)
|
||||
* -scdbackup_tag enables scdbackup checksum tag: Emulation. (line 129)
|
||||
* -scsi_log reports SCSI commands: Scripting. (line 113)
|
||||
* -session_log logs written sessions: Scripting. (line 104)
|
||||
* -session_string composes session info line: Inquiry. (line 56)
|
||||
@ -3867,7 +3882,7 @@ File: xorriso.info, Node: ConceptIdx, Prev: CommandIdx, Up: Top
|
||||
|