From c84e0e0a44df40cb6d4222191b0fd82df24a20c6 Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Mon, 6 Apr 2009 13:20:05 +0000 Subject: [PATCH] New options -show_stream, -show_stream_r, -exec show_stream --- xorriso/xorriso.1 | 25 ++++++++++++ xorriso/xorriso.c | 42 +++++++++++++++----- xorriso/xorriso_timestamp.h | 2 +- xorriso/xorrisoburn.c | 79 ++++++++++++++++++++++++++++++++++++- xorriso/xorrisoburn.h | 3 ++ 5 files changed, 140 insertions(+), 11 deletions(-) diff --git a/xorriso/xorriso.1 b/xorriso/xorriso.1 index 5f791a2b..b3d450b6 100644 --- a/xorriso/xorriso.1 +++ b/xorriso/xorriso.1 @@ -1356,6 +1356,12 @@ E.g.: .br -find / -type f -exec set_filter gzip -- .br +"show_stream" shows the content stream chain of a data file. +.br +E.g.: +.br + -find / -type f -exec show_stream -- +.br "find" performs another run of -find on the matching file address. It accepts the same params as -find, except iso_rr_path. .br @@ -2391,6 +2397,25 @@ and whether both counterparts match. Perform -compare_r with each of the disk_path arguments. iso_rr_path will be composed from disk_path by replacing disk_prefix by iso_rr_prefix. .TP +\fB\-show_stream\fR iso_rr_path [***] +Display the content stream chain of data files in the ISO image. The chain +consists of the iso_rr_name and one or more streams, separated by " < " marks. +A stream consists of one or more texts in ''-quotation marks, eventually +separated by "." characters. The first text describes the stream type, +the following ones describe its individual properties. +Frequently used types are: +.br + 'disk'.'disk_path' for local filesystem objects. +.br + 'image'.'iso_rr_path' for ISO image file objects. +.br + 'cout'.'disk_path offset count' for -cut_out files. +.br + 'extf'.'filter_name' for external filters. +.TP +\fB\-show_stream_r\fR iso_rr_path [***] +Like -show_stream but working recursively. +.TP .B Evaluation of readability and recovery: .PP It is not uncommon that optical media produce read errors. The reasons may be diff --git a/xorriso/xorriso.c b/xorriso/xorriso.c index 270a1587..8f34b6e5 100644 --- a/xorriso/xorriso.c +++ b/xorriso/xorriso.c @@ -13808,6 +13808,8 @@ not_enough_arguments:; Xorriso_pacifier_reset(xorriso, 0); mem_lut= xorriso->last_update_time; } + } else if(strcmp(cpt, "show_stream")==0) { + Findjob_set_action_target(job, 29, NULL, 0); } else { sprintf(xorriso->info_text, "-find -exec: unknown action %s", Text_shellsafe(argv[i], sfe, 0)); @@ -14241,7 +14243,8 @@ int Xorriso_option_help(struct XorrisO *xorriso, int flag) " Action may be one of: echo, chown, chown_r, chgrp, chgrp_r", " chmod, chmod_r, alter_date, alter_date_r, lsdl, compare,", " rm, rm_r, compare, update, report_damage, report_lba,", -" getfacl, setfacl, getfattr, setfattr, set_filter, find.", +" getfacl, setfacl, getfattr, setfattr, set_filter,", +" show_stream, find.", " params are their arguments except iso_rr_path.", " echo, lsdl, rm, rm_r, report_damage have no params at all.", " -mkdir iso_rr_path [...]", @@ -14382,11 +14385,16 @@ int Xorriso_option_help(struct XorrisO *xorriso, int flag) " -compare disk_path iso_rr_path", " compare attributes and in case of regular data files the", " content of filesystem object and ISO object.", -" -compare_r disk_path iso_rr_path ", +" -compare_r disk_path iso_rr_path", " Like -compare but affecting all files below directories.", " -compare_l disk_prefix iso_rr_prefix disk_path [***]", " Performs -compare_r with each disk_path.", "", +" -show_stream iso_rr_path [***]", +" Show content stream chain of data files in the ISO image.", +" -show_stream_r iso_rr_path [***]", +" Like -show_stream but affecting all files below directories.", +"", "Restore options which copy file objects from ISO image to disk filesystem:", " -osirrox \"on\"|\"device_files\"|\"off\"|\"banned\"", " [:\"concat_split_on\"|\"concat_split_off\"]", @@ -16497,9 +16505,10 @@ out_of_mem:; } -/* Options -set_filter , -set_filter_r */ +/* Options -set_filter , -set_filter_r , -show_stream , -show_stream_r */ /* @param flag bit0=recursive -set_filter_r bit1= do not reset pacifier, no final pacifier message + bit2= -show_stream rather than -set_filter */ int Xorriso_option_set_filter(struct XorrisO *xorriso, char *name, int argc, char **argv, int *idx, int flag) @@ -16509,8 +16518,16 @@ int Xorriso_option_set_filter(struct XorrisO *xorriso, char *name, char **optv= NULL; struct FindjoB *job= NULL; struct stat dir_stbuf; + char *cmd= "-set_filter"; - ret= Xorriso_opt_args(xorriso, "-set_filter", + switch(flag & 5) { + case 0: cmd= "-set_filter"; + break; case 1: cmd= "-set_filter_r"; + break; case 4: cmd= "-show_stream"; + break; case 5: cmd= "-show_stream_r"; + } + + ret= Xorriso_opt_args(xorriso, cmd, argc, argv, *idx, &end_idx, &optc, &optv, 0); if(ret <= 0) goto ex; @@ -16521,17 +16538,20 @@ int Xorriso_option_set_filter(struct XorrisO *xorriso, char *name, if(flag&1) { ret= Findjob_new(&job, optv[i], 0); if(ret<=0) { - Xorriso_no_findjob(xorriso, "-set_filter_r", 0); + Xorriso_no_findjob(xorriso, cmd, 0); {ret= -1; goto ex;} } - Findjob_set_action_target(job, 28, name, 0); + Findjob_set_action_target(job, ((flag & 4) ? 29 : 28), name, 0); Findjob_set_file_type(job, 'f', 0); ret= Xorriso_findi(xorriso, job, NULL, (off_t) 0, NULL, optv[i], &dir_stbuf, 0, 0); Findjob_destroy(&job, 0); } else { ret= 1; - ret= Xorriso_set_filter(xorriso, NULL, optv[i], name, 0); + if(flag & 4) + ret= Xorriso_show_stream(xorriso, NULL, optv[i], 0); + else + ret= Xorriso_set_filter(xorriso, NULL, optv[i], name, 0); } if(ret>0 && !xorriso->request_to_abort) continue; /* regular bottom of loop */ @@ -16547,7 +16567,7 @@ int Xorriso_option_set_filter(struct XorrisO *xorriso, char *name, ret= 1; ex:; (*idx)= end_idx; - Xorriso_opt_args(xorriso, "-set_filter", argc, argv, *idx, &end_idx, + Xorriso_opt_args(xorriso, cmd, argc, argv, *idx, &end_idx, &optc, &optv, 256); Findjob_destroy(&job, 0); if(ret<=0) @@ -17109,7 +17129,7 @@ int Xorriso_count_args(struct XorrisO *xorriso, int argc, char **argv, "setfacl","setfacli","setfacl_list","setfacl_listi", "setfacl_r","setfacl_ri","setfattr","setfattri", "setfattr_list","setfattr_listi","setfattr_r","setfattr_ri", - "set_filter","set_filter_r", + "set_filter","set_filter_r","show_stream","show_stream_r", "" }; @@ -17784,6 +17804,10 @@ next_command:; ret= Xorriso_option_set_filter(xorriso, arg1, argc, argv, idx, strcmp(cmd,"set_filter_r")==0); + } else if(strcmp(cmd,"show_stream")==0 || strcmp(cmd,"show_stream_r")==0) { + ret= Xorriso_option_set_filter(xorriso, "", argc, argv, idx, + (strcmp(cmd,"show_stream_r")==0) | 2 | 4); + } else if(strcmp(cmd,"speed")==0) { (*idx)++; ret= Xorriso_option_speed(xorriso, arg1, 0); diff --git a/xorriso/xorriso_timestamp.h b/xorriso/xorriso_timestamp.h index 94cc38c7..10cbc3f2 100644 --- a/xorriso/xorriso_timestamp.h +++ b/xorriso/xorriso_timestamp.h @@ -1 +1 @@ -#define Xorriso_timestamP "2009.04.06.100802" +#define Xorriso_timestamP "2009.04.06.132007" diff --git a/xorriso/xorrisoburn.c b/xorriso/xorrisoburn.c index 3d891b7f..7c8155c6 100644 --- a/xorriso/xorrisoburn.c +++ b/xorriso/xorrisoburn.c @@ -6638,8 +6638,10 @@ int Xorriso_findi_action(struct XorrisO *xorriso, struct FindjoB *job, } else if(action == 27) { ret= Xorriso_path_setfattr(xorriso, (void *) node, show_path, target, strlen(text_2), text_2, 0); - } else if(action == 28) { + } else if(action == 28) { /* set_filter */ ret= Xorriso_set_filter(xorriso, (void *) node, show_path, target, 1 | 2); + } else if(action == 29) { /* show_stream */ + ret= Xorriso_show_stream(xorriso, (void *) node, show_path, 1 | 2); } else { /* includes : 15 in_iso */ sprintf(xorriso->result_line, "%s\n", Text_shellsafe(show_path, sfe, 0)); Xorriso_result(xorriso, 0); @@ -10279,3 +10281,78 @@ int Xorriso_status_extf(struct XorrisO *xorriso, char *filter, FILE *fp, } return(1); } + + +int Xorriso_show_stream(struct XorrisO *xorriso, void *in_node, + char *path, int flag) +{ + int ret, lba; + IsoNode *node; + IsoFile *file; + IsoStream *stream= NULL, *input_stream; + IsoExternalFilterCommand *cmd; + char type_text[16], *source_path= NULL; + + node= (IsoNode *) in_node; + if(node == NULL) { + ret= Xorriso_get_node_by_path(xorriso, path, NULL, &node, 0); + if(ret <= 0) + goto ex; + } + if(!LIBISO_ISREG(node)) + {ret= 2; goto ex;} + file= (IsoFile *) node; + input_stream= iso_file_get_stream(file); + Text_shellsafe(path, xorriso->result_line, 0); + while(1) { + stream= input_stream; + input_stream= iso_stream_get_input_stream(stream, 0); + if(input_stream == NULL) + break; + ret= iso_stream_get_external_filter(stream, &cmd, 0); + if(ret < 0) { + Xorriso_process_msg_queues(xorriso,0); + Xorriso_report_iso_error(xorriso, "", ret, + "Error when inquiring filter command of node", 0, "FAILURE", 1); + ret= 0; goto ex; + } + strcat(xorriso->result_line, " < "); + strncpy(type_text, stream->class->type, 4); + type_text[4]= 0; + Text_shellsafe(type_text, xorriso->result_line, 1); + if(ret > 0) { + strcat(xorriso->result_line, "."); + Text_shellsafe(cmd->name, xorriso->result_line, 1); + } + if(strlen(xorriso->result_line) > SfileadrL) { + Xorriso_result(xorriso, 0); + xorriso->result_line[0]= 0; + } + } + strcat(xorriso->result_line, " < "); + strncpy(type_text, stream->class->type, 4); + type_text[4]= 0; + if(strcmp(type_text, "fsrc") == 0) { + ret= Xorriso__file_start_lba(node, &lba, 0); + if(ret > 0 && lba > 0) + strcpy(type_text, "image"); + else + strcpy(type_text, "disk"); + } + Text_shellsafe(type_text, xorriso->result_line, 1); + + source_path= iso_stream_get_source_path(stream, 0); + if(source_path != NULL) { + strcat(xorriso->result_line, "."); + Text_shellsafe(source_path, xorriso->result_line, 1); + } + + strcat(xorriso->result_line, "\n"); + Xorriso_result(xorriso, 0); + ret= 1; +ex:; + if(source_path != NULL) + free(source_path); + return(ret); +} + diff --git a/xorriso/xorrisoburn.h b/xorriso/xorrisoburn.h index 871f026d..0b9b4495 100644 --- a/xorriso/xorrisoburn.h +++ b/xorriso/xorrisoburn.h @@ -445,6 +445,9 @@ int Xorriso_status_extf(struct XorrisO *xorriso, char *filter, FILE *fp, int Xorriso_destroy_all_extf(struct XorrisO *xorriso, int flag); +int Xorriso_show_stream(struct XorrisO *xorriso, void *in_node, + char *path, int flag); + /* A pseudo file type for El-Torito bootsectors as in man 2 stat : For now take the highest possible value.