New -as mkisofs option -log-file

This commit is contained in:
Thomas Schmitt 2012-04-11 16:32:21 +00:00
parent 44b653d79b
commit 1d184f9276
8 changed files with 100 additions and 26 deletions

View File

@ -301,6 +301,7 @@ int Xorriso_new(struct XorrisO ** xorriso,char *progname, int flag)
m->logfile_fp[i]= NULL; m->logfile_fp[i]= NULL;
} }
m->pktlog_fp= NULL; m->pktlog_fp= NULL;
m->stderr_fp= NULL;
for(i= 0; i < Xorriso_max_outlist_stacK; i++) { for(i= 0; i < Xorriso_max_outlist_stacK; i++) {
m->result_msglists[i]= NULL; m->result_msglists[i]= NULL;
m->info_msglists[i]= NULL; m->info_msglists[i]= NULL;

View File

@ -831,6 +831,7 @@ int Xorriso_genisofs_help(struct XorrisO *xorriso, int flag)
" --old-root-no-md5 Do not record and use MD5 with -old-root", " --old-root-no-md5 Do not record and use MD5 with -old-root",
" --old-root-no-ino Do not use disk inode numbers with -old-root", " --old-root-no-ino Do not use disk inode numbers with -old-root",
" --old-root-devno Use disk device numbers with -old-root", " --old-root-devno Use disk device numbers with -old-root",
" -log-file LOG_FILE Re-direct messages to LOG_FILE",
" --no_rc Do not execute startup files", " --no_rc Do not execute startup files",
" -v, -verbose Verbose", " -v, -verbose Verbose",
" -version Print the current version", " -version Print the current version",
@ -985,6 +986,35 @@ int Xorriso_genisofs(struct XorrisO *xorriso, char *whom,
Xorriso_alloc_meM(indev, char, SfileadrL+8); Xorriso_alloc_meM(indev, char, SfileadrL+8);
Xorriso_alloc_meM(old_root, char, SfileadrL); Xorriso_alloc_meM(old_root, char, SfileadrL);
for(i= 0; i<argc; i++) {
if(strcmp(argv[i], "-log-file") == 0 ||
strcmp(argv[i], "--log-file") == 0 ) {
if(i + 1 >= argc)
goto not_enough_args;
i+= 1;
if(argv[i][0]) {
sprintf(xorriso->info_text, "re-directing all messages to %s\n",
argv[i]);
Xorriso_info(xorriso, 0);
}
ret= Xorriso_write_to_channel(xorriso, argv[i], 2,
8 | ((argv[i][0] == 0) << 15));
if(ret <= 0) {
sprintf(xorriso->info_text, "Cannot open logfile: %s", argv[i]);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno * (ret == 0),
"SORRY", 0);
was_failure= 1;
fret= Xorriso_eval_problem_status(xorriso, ret, 1|2);
if(fret < 0)
{ret= 0; goto ex;}
}
if(argv[i][0] == 0) {
sprintf(xorriso->info_text, "Revoked stderr message redirection");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
}
}
}
strcpy(ra_text, xorriso->report_about_text); strcpy(ra_text, xorriso->report_about_text);
weight_list= TSOB_FELD(int, (argc / 3) + 1); weight_list= TSOB_FELD(int, (argc / 3) + 1);
@ -1181,6 +1211,8 @@ int Xorriso_genisofs(struct XorrisO *xorriso, char *whom,
} else if(strcmp(argpt, "--no-emul-toc")==0) { } else if(strcmp(argpt, "--no-emul-toc")==0) {
with_emul_toc= 0; with_emul_toc= 0;
xorriso->no_emul_toc|= 1; xorriso->no_emul_toc|= 1;
} else if(strcmp(argpt, "-log-file") == 0) {
/* already handled before this loop */;
} else { } else {
was_other_option= 1; was_other_option= 1;
hargv[0]= argpt; hargv[0]= argpt;
@ -1669,6 +1701,9 @@ rr_reloc_dir:;
goto problem_handler_2; goto problem_handler_2;
Xorriso_relax_compliance(xorriso, "deep_paths_off:long_paths_off", 0); Xorriso_relax_compliance(xorriso, "deep_paths_off:long_paths_off", 0);
} else if(strcmp(argpt, "-log-file") == 0) {
/* was already handled before this loop */;
} else if(argpt[0]=='-' && argpt[1]!=0) { } else if(argpt[0]=='-' && argpt[1]!=0) {
hargv[0]= argpt; hargv[0]= argpt;
ret= Xorriso_genisofs_count_args(xorriso, argc - i, hargv, &count, 1); ret= Xorriso_genisofs_count_args(xorriso, argc - i, hargv, &count, 1);

View File

@ -526,7 +526,8 @@ int Xorriso_write_to_channel(struct XorrisO *xorriso,
bit0= eventually backslash encode linefeeds bit0= eventually backslash encode linefeeds
bit1= text is the name of the log file for the given channel bit1= text is the name of the log file for the given channel
bit2= text is the name of the consolidated packet log file for all channels bit2= text is the name of the consolidated packet log file for all channels
bit15= with bit1 or bit2: close depicted log file bit3= text is the name of the stderr redirection file
bit15= with bit1 to bit3: close depicted log file
*/ */
{ {
char *rpt, *npt, *text= NULL; char *rpt, *npt, *text= NULL;
@ -559,6 +560,10 @@ bit15= with bit1 or bit2: close depicted log file
fclose(pktlog_fp); fclose(pktlog_fp);
xorriso->pktlog_fp= pktlog_fp= NULL; xorriso->pktlog_fp= pktlog_fp= NULL;
} }
if((flag & 8) && xorriso->stderr_fp != NULL) {
fclose(xorriso->stderr_fp);
xorriso->stderr_fp= NULL;
}
if(flag&(1<<15)) if(flag&(1<<15))
{ret= 1; goto ex;} {ret= 1; goto ex;}
if((flag&2)) { if((flag&2)) {
@ -579,7 +584,13 @@ bit15= with bit1 or bit2: close depicted log file
Sfile_datestr(time(0),1|2|256)); Sfile_datestr(time(0),1|2|256));
fflush(pktlog_fp); fflush(pktlog_fp);
} }
if(flag&(2|4)) if(flag & 8) {
truncate(text, (off_t) 0);
xorriso->stderr_fp= fopen(text, "a");
if(xorriso->stderr_fp == NULL)
{ret= 0; goto ex;}
}
if(flag & (2| 4 | 8))
{ret= 1; goto ex;} {ret= 1; goto ex;}
/* Eventually perform backslash encoding of non-printable characters */ /* Eventually perform backslash encoding of non-printable characters */
@ -628,8 +639,13 @@ bit15= with bit1 or bit2: close depicted log file
printf("%s",text); printf("%s",text);
fflush(stdout); fflush(stdout);
} }
if(channel_no==2 || channel_no==3) if(channel_no==2 || channel_no==3) {
fprintf(stderr,"%s",text); if(xorriso->stderr_fp != NULL) {
fprintf(xorriso->stderr_fp, "%s", text);
fflush(xorriso->stderr_fp);
} else
fprintf(stderr, "%s", text);
}
if(logfile_fp!=NULL) { if(logfile_fp!=NULL) {
fprintf(logfile_fp,"%s",text); fprintf(logfile_fp,"%s",text);
fflush(logfile_fp); fflush(logfile_fp);

View File

@ -514,6 +514,7 @@ struct XorrisO { /* the global context of xorriso */
char logfile[4][SfileadrL]; char logfile[4][SfileadrL];
FILE *logfile_fp[4]; FILE *logfile_fp[4];
FILE *pktlog_fp; FILE *pktlog_fp;
FILE *stderr_fp;
struct Xorriso_lsT *result_msglists[Xorriso_max_outlist_stacK]; struct Xorriso_lsT *result_msglists[Xorriso_max_outlist_stacK];
struct Xorriso_lsT *info_msglists[Xorriso_max_outlist_stacK]; struct Xorriso_lsT *info_msglists[Xorriso_max_outlist_stacK];
int msglist_flags[Xorriso_max_outlist_stacK]; /* bit0= result is redirected int msglist_flags[Xorriso_max_outlist_stacK]; /* bit0= result is redirected

View File

@ -1 +1 @@
#define Xorriso_timestamP "2012.04.10.071539" #define Xorriso_timestamP "2012.04.11.163237"

View File

@ -9,7 +9,7 @@
.\" First parameter, NAME, should be all caps .\" First parameter, NAME, should be all caps
.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
.\" other parameters are allowed: see man(7), man(1) .\" other parameters are allowed: see man(7), man(1)
.TH XORRISOFS 1 "Version 1.2.3, Apr 02, 2012" .TH XORRISOFS 1 "Version 1.2.3, Apr 11, 2012"
.\" Please adjust this date whenever revising the manpage. .\" Please adjust this date whenever revising the manpage.
.\" .\"
.\" Some roff macros, for reference: .\" Some roff macros, for reference:
@ -1105,6 +1105,12 @@ original mkisofs description texts.
Suppress most messages of the program run, except those which indicate Suppress most messages of the program run, except those which indicate
problems or errors. problems or errors.
.TP .TP
\fB\-log-file\fR disk_path
.br
Truncate file disk_path to 0 size and redirect to it all messages which would
normally appear on stderr. \-log\-file with empty text as disk_path re\-enables
output to stderr.
.TP
\fB\-v\fR \fB\-v\fR
.br .br
Enable the output of informational program messages. Enable the output of informational program messages.

View File

@ -1095,6 +1095,11 @@ File: xorrisofs.info, Node: Miscellaneous, Next: ExSimple, Prev: Jigdo, Up:
Suppress most messages of the program run, except those which Suppress most messages of the program run, except those which
indicate problems or errors. indicate problems or errors.
-log-file disk_path
Truncate file disk_path to 0 size and redirect to it all messages
which would normally appear on stderr. -log-file with empty text
as disk_path re-enables output to stderr.
-v -v
Enable the output of informational program messages. Enable the output of informational program messages.
@ -1641,6 +1646,7 @@ File: xorrisofs.info, Node: CommandIdx, Next: ConceptIdx, Prev: Legal, Up: T
(line 107) (line 107)
* -joliet-long allow longer Joliet names: SetExtras. (line 110) * -joliet-long allow longer Joliet names: SetExtras. (line 110)
* -l allow 31 characters in ISO file names: SetCompl. (line 63) * -l allow 31 characters in ISO file names: SetCompl. (line 63)
* -log-file redirect stderr messages: Miscellaneous. (line 28)
* -m exclude disk files from inserting: SetInsert. (line 35) * -m exclude disk files from inserting: SetInsert. (line 35)
* -M set path for loading existing ISO image: Loading. (line 11) * -M set path for loading existing ISO image: Loading. (line 11)
* -max-iso9660-filenames allow 37 characters in ISO file names: SetCompl. * -max-iso9660-filenames allow 37 characters in ISO file names: SetCompl.
@ -1697,10 +1703,10 @@ File: xorrisofs.info, Node: CommandIdx, Next: ConceptIdx, Prev: Legal, Up: T
* -untranslated-filenames very relaxed filename rules: SetCompl. * -untranslated-filenames very relaxed filename rules: SetCompl.
(line 36) (line 36)
* -untranslated_name_len untranslated file names: SetCompl. (line 39) * -untranslated_name_len untranslated file names: SetCompl. (line 39)
* -v enable verbous messages: Miscellaneous. (line 28) * -v enable verbous messages: Miscellaneous. (line 33)
* -V set Volume Id: ImageId. (line 13) * -V set Volume Id: ImageId. (line 13)
* -verbose enable verbous messages: Miscellaneous. (line 31) * -verbose enable verbous messages: Miscellaneous. (line 36)
* -version report program version: Miscellaneous. (line 34) * -version report program version: Miscellaneous. (line 39)
* -volid set Volume Id: ImageId. (line 23) * -volid set Volume Id: ImageId. (line 23)
* -volset set Volume Set Id: ImageId. (line 26) * -volset set Volume Set Id: ImageId. (line 26)
* -x exclude disk files from inserting: SetInsert. (line 45) * -x exclude disk files from inserting: SetInsert. (line 45)
@ -1826,6 +1832,7 @@ File: xorrisofs.info, Node: ConceptIdx, Prev: CommandIdx, Up: Top
* MBR, append partition, -append_partition: SystemArea. (line 86) * MBR, append partition, -append_partition: SystemArea. (line 86)
* MBR, sectors per head, -partition_sec_hd: SystemArea. (line 58) * MBR, sectors per head, -partition_sec_hd: SystemArea. (line 58)
* MD5, record and load, --md5: SetExtras. (line 77) * MD5, record and load, --md5: SetExtras. (line 77)
* Message output, redirect stderr, -log-file: Miscellaneous. (line 28)
* Message output, suppress, -quiet: Miscellaneous. (line 24) * Message output, suppress, -quiet: Miscellaneous. (line 24)
* Mountability, by non-trivial partition 1, -partition_offset: SystemArea. * Mountability, by non-trivial partition 1, -partition_offset: SystemArea.
(line 46) (line 46)
@ -1842,7 +1849,7 @@ File: xorrisofs.info, Node: ConceptIdx, Prev: CommandIdx, Up: Top
* Permissions, for all directories, -dir-mode: SetProduct. (line 60) * Permissions, for all directories, -dir-mode: SetProduct. (line 60)
* Preparer Id, set, -p: ImageId. (line 54) * Preparer Id, set, -p: ImageId. (line 54)
* Problems, reporting: Bugreport. (line 6) * Problems, reporting: Bugreport. (line 6)
* Program version, report, -version: Miscellaneous. (line 34) * Program version, report, -version: Miscellaneous. (line 39)
* Publisher Id, set, -p, -publisher: ImageId. (line 30) * Publisher Id, set, -p, -publisher: ImageId. (line 30)
* Rock Ridge, (always enabled), -R, -rock: SetExtras. (line 8) * Rock Ridge, (always enabled), -R, -rock: SetExtras. (line 8)
* Rock Ridge, _definition: Standards. (line 14) * Rock Ridge, _definition: Standards. (line 14)
@ -1857,7 +1864,7 @@ File: xorrisofs.info, Node: ConceptIdx, Prev: CommandIdx, Up: Top
* System Id, set, -sysid: ImageId. (line 49) * System Id, set, -sysid: ImageId. (line 49)
* Table-of-content, emulation off, --no-emul-toc: SetProduct. (line 44) * Table-of-content, emulation off, --no-emul-toc: SetProduct. (line 44)
* Table-of-content, emulation, --emul-toc: SetProduct. (line 35) * Table-of-content, emulation, --emul-toc: SetProduct. (line 35)
* Verbosity, high, -v, -verbose: Miscellaneous. (line 28) * Verbosity, high, -v, -verbose: Miscellaneous. (line 33)
* Volume Id, set, -V, -volid: ImageId. (line 13) * Volume Id, set, -V, -volid: ImageId. (line 13)
* Volume Set Id, set, -volset: ImageId. (line 26) * Volume Set Id, set, -volset: ImageId. (line 26)
* xattr, record and load, --xattr: SetExtras. (line 70) * xattr, record and load, --xattr: SetExtras. (line 70)
@ -1887,19 +1894,19 @@ Node: SystemArea33162
Node: Charset39496 Node: Charset39496
Node: Jigdo40522 Node: Jigdo40522
Node: Miscellaneous44789 Node: Miscellaneous44789
Node: Examples45953 Node: Examples46162
Node: ExSimple46439 Node: ExSimple46648
Node: ExGraft46918 Node: ExGraft47127
Node: ExMkisofs48165 Node: ExMkisofs48374
Node: ExGrowisofs49418 Node: ExGrowisofs49627
Node: ExIncBackup50590 Node: ExIncBackup50799
Node: ExIncBckAcc53698 Node: ExIncBckAcc53907
Node: ExBootable55374 Node: ExBootable55583
Node: Files57466 Node: Files57675
Node: Seealso58540 Node: Seealso58749
Node: Bugreport59196 Node: Bugreport59405
Node: Legal59777 Node: Legal59986
Node: CommandIdx60592 Node: CommandIdx60801
Node: ConceptIdx72575 Node: ConceptIdx72857
 
End Tag Table End Tag Table

View File

@ -50,7 +50,7 @@
@c man .\" First parameter, NAME, should be all caps @c man .\" First parameter, NAME, should be all caps
@c man .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection @c man .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
@c man .\" other parameters are allowed: see man(7), man(1) @c man .\" other parameters are allowed: see man(7), man(1)
@c man .TH XORRISOFS 1 "Version 1.2.3, Apr 02, 2012" @c man .TH XORRISOFS 1 "Version 1.2.3, Apr 11, 2012"
@c man .\" Please adjust this date whenever revising the manpage. @c man .\" Please adjust this date whenever revising the manpage.
@c man .\" @c man .\"
@c man .\" Some roff macros, for reference: @c man .\" Some roff macros, for reference:
@ -1521,6 +1521,14 @@ original mkisofs description texts.
Suppress most messages of the program run, except those which indicate Suppress most messages of the program run, except those which indicate
problems or errors. problems or errors.
@c man .TP @c man .TP
@item -log-file disk_path
@kindex -log-file redirect stderr messages
@cindex Message output, redirect stderr, -log-file
@*
Truncate file disk_path to 0 size and redirect to it all messages which would
normally appear on stderr. -log-file with empty text as disk_path re-enables
output to stderr.
@c man .TP
@item -v @item -v
@kindex -v enable verbous messages @kindex -v enable verbous messages
@cindex Verbosity, high, -v, -verbose @cindex Verbosity, high, -v, -verbose