New -check_media option data_to="-" for standard output

This commit is contained in:
Thomas Schmitt 2020-09-30 21:07:50 +02:00
parent 56b2d88667
commit 588578f9a8
7 changed files with 103 additions and 46 deletions

View File

@ -210,6 +210,7 @@ char *Spotlist__quality_name(int quality, char name[80], int bad_limit,
{ {
if(quality == Xorriso_read_quality_untesteD || if(quality == Xorriso_read_quality_untesteD ||
quality == Xorriso_read_quality_tao_enD || quality == Xorriso_read_quality_tao_enD ||
(quality == Xorriso_read_quality_md5_mismatcH && quality > bad_limit) ||
quality == Xorriso_read_quality_off_tracK) quality == Xorriso_read_quality_off_tracK)
strcpy(name, "0 "); strcpy(name, "0 ");
else if(quality <= bad_limit) else if(quality <= bad_limit)
@ -603,7 +604,7 @@ int Checkmediajob_destroy(struct CheckmediajoB **o, int flag)
{ {
if((*o) == NULL) if((*o) == NULL)
return(0); return(0);
if((*o)->data_to_fd != -1) if((*o)->data_to_fd != -1 && strcmp((*o)->data_to_path, "-") == 0)
close((*o)->data_to_fd); close((*o)->data_to_fd);
Sectorbitmap_destroy(&((*o)->sector_map), 0); Sectorbitmap_destroy(&((*o)->sector_map), 0);
free((char *) *o); free((char *) *o);
@ -1081,8 +1082,12 @@ int Xorriso_open_job_data_to(struct XorrisO *xorriso,
{ {
if(job->data_to_path[0] == 0) if(job->data_to_path[0] == 0)
return(2); return(2);
job->data_to_fd= open(job->data_to_path, O_RDWR | O_CREAT | O_BINARY, if(strcmp(job->data_to_path, "-") == 0) {
S_IRUSR | S_IWUSR); job->data_to_fd= 1;
} else {
job->data_to_fd= open(job->data_to_path, O_RDWR | O_CREAT | O_BINARY,
S_IRUSR | S_IWUSR);
}
if(job->data_to_fd == -1) { if(job->data_to_fd == -1) {
sprintf(xorriso->info_text, "Cannot open path "); sprintf(xorriso->info_text, "Cannot open path ");
Text_shellsafe(job->data_to_path, xorriso->info_text, 1); Text_shellsafe(job->data_to_path, xorriso->info_text, 1);

View File

@ -3082,7 +3082,9 @@ abort_check:;
} }
if(write_amount > 0) { if(write_amount > 0) {
if(job->data_to_fd >= 0) { if(job->data_to_fd >= 0) {
ret= lseek(job->data_to_fd, ret= 0;
if(strcmp(job->data_to_path, "-") != 0)
ret= lseek(job->data_to_fd,
((off_t) (i + from_lba)) * (off_t) 2048 + job->data_to_offset, ((off_t) (i + from_lba)) * (off_t) 2048 + job->data_to_offset,
SEEK_SET); SEEK_SET);
if(ret == -1) { if(ret == -1) {
@ -3426,7 +3428,7 @@ libburn_whole_disc:;
ret= 1; ret= 1;
ex:; ex:;
if(job->data_to_fd != -1) if(job->data_to_fd != -1 && strcmp(job->data_to_path, "-") != 0)
close(job->data_to_fd); close(job->data_to_fd);
job->data_to_fd= -1; job->data_to_fd= -1;

View File

@ -1761,7 +1761,7 @@ int Xorriso_option_check_media(struct XorrisO *xorriso,
int argc, char **argv, int *idx, int flag) int argc, char **argv, int *idx, int flag)
{ {
int ret, i, count, lba, blocks, quality, pass, was_md5= 0, was_event= 0; int ret, i, count, lba, blocks, quality, pass, was_md5= 0, was_event= 0;
int end_idx, old_idx, os_errno; int end_idx, old_idx, os_errno, to_info= 0;
char quality_name[80], *head_buffer= NULL; char quality_name[80], *head_buffer= NULL;
struct SpotlisT *spotlist= NULL; struct SpotlisT *spotlist= NULL;
struct CheckmediajoB *job= NULL; struct CheckmediajoB *job= NULL;
@ -1781,6 +1781,7 @@ int Xorriso_option_check_media(struct XorrisO *xorriso,
if(ret <= 0) if(ret <= 0)
goto ex; goto ex;
to_info= (strcmp(job->data_to_path, "-") == 0);
if((job->report_mode == 1 || job->report_mode == 2) && job->use_dev == 1) { if((job->report_mode == 1 || job->report_mode == 2) && job->use_dev == 1) {
sprintf(xorriso->info_text, sprintf(xorriso->info_text,
"-check_media: cannot report=*files while use=outdef"); "-check_media: cannot report=*files while use=outdef");
@ -1793,6 +1794,12 @@ int Xorriso_option_check_media(struct XorrisO *xorriso,
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
ret= 0; goto ex; ret= 0; goto ex;
} }
if(job->patch_lba0 && to_info) {
sprintf(xorriso->info_text,
"-check_media: cannot apply patch_lba0= while data_to= is \"-\"");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
ret= 0; goto ex;
}
if(job->use_dev == 2) { if(job->use_dev == 2) {
if(job->sector_map_path[0] == 0) { if(job->sector_map_path[0] == 0) {
@ -1847,7 +1854,12 @@ int Xorriso_option_check_media(struct XorrisO *xorriso,
sprintf(xorriso->result_line, sprintf(xorriso->result_line,
"MD5 checks : lba , size , result\n"); "MD5 checks : lba , size , result\n");
} }
Xorriso_result(xorriso,0); if(to_info) {
strcpy(xorriso->info_text, xorriso->result_line);
Xorriso_info(xorriso, 0);
} else {
Xorriso_result(xorriso, 0);
}
count= Spotlist_count(spotlist, 0); count= Spotlist_count(spotlist, 0);
for(i= 0; i < count; i++) { for(i= 0; i < count; i++) {
ret= Spotlist_get_item(spotlist, i, &lba, &blocks, &quality, 0); ret= Spotlist_get_item(spotlist, i, &lba, &blocks, &quality, 0);
@ -1871,7 +1883,12 @@ int Xorriso_option_check_media(struct XorrisO *xorriso,
pass == 0 ? "Media region " : "MD5 tag range", pass == 0 ? "Media region " : "MD5 tag range",
lba, blocks, Spotlist__quality_name(quality, quality_name, lba, blocks, Spotlist__quality_name(quality, quality_name,
xorriso->check_media_bad_limit, 0)); xorriso->check_media_bad_limit, 0));
Xorriso_result(xorriso,0); if(to_info) {
strcpy(xorriso->info_text, xorriso->result_line);
Xorriso_info(xorriso, 0);
} else {
Xorriso_result(xorriso, 0);
}
} }
} }
} }

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 XORRISO 1 "Version 1.5.3, Sep 11, 2020" .TH XORRISO 1 "Version 1.5.3, Sep 30, 2020"
.\" 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:
@ -4754,7 +4754,18 @@ gives the number of report list items after which to abort.
Value \-1 means unlimited item number. Value \-1 means unlimited item number.
.br .br
\fBdata_to=disk_path\fR \fBdata_to=disk_path\fR
copies the valid blocks to the given file. copies the valid blocks to the given file, which must support random access
writing, unless disk_path is "\-" which means standard output.
.br
In the latter case, patch_lba0= settings other than "off" yield failure.
Further the usual result messages of \-check_media get redirected to the info
channel. But beware of result messages from other commands. Beware of \-*dev "\-"
which redirect standard output to standard error. Keep the run simple:
.br
xorriso \-indev /dev/sr0 \-check_media data_to=\- \-\- | md5sum
.br
xorriso \-outdev /dev/sr0 \-check_media data_to=\- use=outdev \\
what=disc min_lba=0 max_lba=999999 \-\- | sha256sum
.br .br
\fBevent=severity\fR \fBevent=severity\fR
sets the given severity for a problem event which shall be issued at sets the given severity for a problem event which shall be issued at

View File

@ -3989,7 +3989,18 @@ transmission errors.
gives the number of report list items after which to abort. gives the number of report list items after which to abort.
Value -1 means unlimited item number. Value -1 means unlimited item number.
data_to=disk_path data_to=disk_path
copies the valid blocks to the given file. copies the valid blocks to the given file, which must support
random access writing, unless disk_path is "-" which means
standard output.
In the latter case, patch_lba0= settings other than "off"
yield failure. Further the usual result messages of
-check_media get redirected to the info channel. But beware
of result messages from other commands. Beware of -*dev "-"
which redirect standard output to standard error. Keep the
run simple:
xorriso -indev /dev/sr0 -check_media data_to=- - | md5sum
xorriso -outdev /dev/sr0 -check_media data_to=- use=outdev \
what=disc min_lba=0 max_lba=999999 - | sha256sum
event=severity event=severity
sets the given severity for a problem event which shall be sets the given severity for a problem event which shall be
issued at the end of a check run if data blocks were issued at the end of a check run if data blocks were
@ -5419,8 +5430,8 @@ File: xorriso.info, Node: CommandIdx, Next: ConceptIdx, Prev: Legal, Up: Top
* -cdx sets working directory on disk: Navigate. (line 15) * -cdx sets working directory on disk: Navigate. (line 15)
* -changes_pending overrides change status: Writing. (line 12) * -changes_pending overrides change status: Writing. (line 12)
* -charset sets input/output character set: Charset. (line 54) * -charset sets input/output character set: Charset. (line 54)
* -check_md5 verifies file checksum: Verify. (line 173) * -check_md5 verifies file checksum: Verify. (line 184)
* -check_md5_r verifies file tree checksums: Verify. (line 187) * -check_md5_r verifies file tree checksums: Verify. (line 198)
* -check_media reads media block by block: Verify. (line 21) * -check_media reads media block by block: Verify. (line 21)
* -check_media_defaults sets -check_media options: Verify. (line 40) * -check_media_defaults sets -check_media options: Verify. (line 40)
* -chgrp sets group in ISO image: Manip. (line 49) * -chgrp sets group in ISO image: Manip. (line 49)
@ -5923,8 +5934,8 @@ File: xorriso.info, Node: ConceptIdx, Prev: CommandIdx, Up: Top
* Verify, compare ISO and disk file, -compare: Navigate. (line 131) * Verify, compare ISO and disk file, -compare: Navigate. (line 131)
* Verify, compare ISO and disk tree, -compare_r: Navigate. (line 143) * Verify, compare ISO and disk tree, -compare_r: Navigate. (line 143)
* Verify, compare ISO and disk, -compare_l: Navigate. (line 147) * Verify, compare ISO and disk, -compare_l: Navigate. (line 147)
* Verify, file checksum, -check_md5: Verify. (line 173) * Verify, file checksum, -check_md5: Verify. (line 184)
* Verify, file tree checksums, -check_md5_r: Verify. (line 187) * Verify, file tree checksums, -check_md5_r: Verify. (line 198)
* Verify, preset -check_media, -check_media_defaults: Verify. (line 40) * Verify, preset -check_media, -check_media_defaults: Verify. (line 40)
* Write, block size, -dvd_obs: SetWrite. (line 336) * Write, block size, -dvd_obs: SetWrite. (line 336)
* Write, bootability, -boot_image: Bootable. (line 75) * Write, bootability, -boot_image: Bootable. (line 75)
@ -5985,33 +5996,33 @@ Node: DialogCtl190767
Node: Inquiry193369 Node: Inquiry193369
Node: Navigate202251 Node: Navigate202251
Node: Verify210708 Node: Verify210708
Node: Restore221179 Node: Restore221857
Node: Emulation230345 Node: Emulation231023
Node: Scripting240801 Node: Scripting241479
Node: Frontend248584 Node: Frontend249262
Node: Examples258210 Node: Examples258888
Node: ExDevices259388 Node: ExDevices260066
Node: ExCreate260049 Node: ExCreate260727
Node: ExDialog261349 Node: ExDialog262027
Node: ExGrowing262620 Node: ExGrowing263298
Node: ExModifying263429 Node: ExModifying264107
Node: ExBootable263939 Node: ExBootable264617
Node: ExCharset264494 Node: ExCharset265172
Node: ExPseudo265390 Node: ExPseudo266068
Node: ExCdrecord266317 Node: ExCdrecord266995
Node: ExMkisofs266637 Node: ExMkisofs267315
Node: ExGrowisofs268534 Node: ExGrowisofs269212
Node: ExException269687 Node: ExException270365
Node: ExTime270145 Node: ExTime270823
Node: ExIncBackup270603 Node: ExIncBackup271281
Node: ExRestore274629 Node: ExRestore275307
Node: ExRecovery275575 Node: ExRecovery276253
Node: Files276147 Node: Files276825
Node: Environ277481 Node: Environ278159
Node: Seealso278229 Node: Seealso278907
Node: Bugreport278946 Node: Bugreport279624
Node: Legal279537 Node: Legal280215
Node: CommandIdx280549 Node: CommandIdx281227
Node: ConceptIdx298165 Node: ConceptIdx298843
 
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 XORRISO 1 "Version 1.5.3, Sep 11, 2020" @c man .TH XORRISO 1 "Version 1.5.3, Sep 30, 2020"
@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:
@ -5477,7 +5477,18 @@ gives the number of report list items after which to abort.
Value -1 means unlimited item number. Value -1 means unlimited item number.
@* @*
@item data_to=disk_path @item data_to=disk_path
copies the valid blocks to the given file. copies the valid blocks to the given file, which must support random access
writing, unless disk_path is "-" which means standard output.
@*
In the latter case, patch_lba0= settings other than "off" yield failure.
Further the usual result messages of -check_media get redirected to the info
channel. But beware of result messages from other commands. Beware of -*dev "-"
which redirect standard output to standard error. Keep the run simple:
@*
xorriso -indev /dev/sr0 -check_media data_to=- -- | md5sum
@*
xorriso -outdev /dev/sr0 -check_media data_to=- use=outdev \
what=disc min_lba=0 max_lba=999999 -- | sha256sum
@* @*
@item event=severity @item event=severity
sets the given severity for a problem event which shall be issued at sets the given severity for a problem event which shall be issued at

View File

@ -1 +1 @@
#define Xorriso_timestamP "2020.08.26.142853" #define Xorriso_timestamP "2020.09.30.190728"