diff --git a/libisoburn/trunk/xorriso/xorriso.1 b/libisoburn/trunk/xorriso/xorriso.1 index 3a905300..11f997a3 100644 --- a/libisoburn/trunk/xorriso/xorriso.1 +++ b/libisoburn/trunk/xorriso/xorriso.1 @@ -2,7 +2,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 "Apr 21, 2009" +.TH XORRISO 1 "Apr 23, 2009" .\" Please adjust this date whenever revising the manpage. .\" .\" Some roff macros, for reference: @@ -1137,7 +1137,7 @@ External filters may also be banned totally at compile time of xorriso. By default they are banned if xorriso runs under setuid permission. .TP \fB\-set_filter\fR name iso_rr_path [***] -Apply an -external_filter or a built--in filter to the given data files in the +Apply an -external_filter or a built-in filter to the given data files in the ISO image. If the filter suffix is not empty , then it will be applied to the file name. Renaming only happens if the filter really gets attached and is not revoked by @@ -1223,9 +1223,11 @@ if all its tests match. Available tests are: .br \fB\-name\fR pattern : -Pattern is not expanded but used for comparison with -the particular file names of the eventual directory tree underneath -iso_rr_path. +Matches if pattern matches the file leaf name. +.br +\fB\-wholename\fR pattern : +Matches if pattern matches the file path as it would be printed by action +"echo". Character '/' is not special but can be matched by wildcards. .br \fB\-type\fR type_letter : Matches files files of the given type: @@ -1258,9 +1260,16 @@ Matches files which have ACL or any xattr. \fB\-has_filter\fR : Matches files which are filtered by -set_filter. .br +\fB\-prune\fR : +If this test is reached and the tested file is a directory then -find will not +dive into that directory. This test itself does always match. +.br \fB\-decision\fR "yes"|"no" : -If this test is reached then the evaluation ends immediatly and action -is performed if the decision is not "no", "0", or "false". See operator -if. +If this test is reached then the evaluation ends immediately and action +is performed if the decision is "yes" or "true". See operator -if. +.br +\fB\-true\fR and \fB\-false\fR : +Always match resp. match not. Evaluation goes on. .br Available operators are: .br @@ -1277,10 +1286,9 @@ Matches if both neighboring tests or expressions match. \fB\-or\fR : Matches if at least one of both neighboring tests or expressions matches. .br -\fB\-sub\fR ... \fB\-subend\fR : +\fB\-sub\fR ... \fB\-subend\fR or \fB(\fR ... \fB)\fR : Enclose a sub expression which gets evaluated first before it -is processed by neighboring operators. The same meaning have "(" and ")". -.br +is processed by neighboring operators. Normal precedence is: -not, -or , -and. .br \fB\-if\fR ... \fB\-then\fR\ ... \fB\-elseif\fR ... \fB\-then\fR ... @@ -1293,7 +1301,7 @@ is evaluated. There may be more than one -elseif. Neither -else nor -elseif are mandatory. If -else is missing and would be hit, then the result is a non-match. .br --if expressions are the main use case for the test -decision. +-if-expressions are the main use case for above test -decision. Default action is \fBecho\fR, i.e. to print the address of the found file. Other actions are certain @@ -1707,7 +1715,7 @@ can be revoked individually by appending "_off". Like "deep_paths_off". .br Rule keywords are: .br -"omit_version" do not add versions (";1") to the file names. +"omit_version" do not add versions (";1") to ISO file names. .br "deep_paths" allow ISO file paths deeper than 8 levels. .br @@ -1715,7 +1723,7 @@ Rule keywords are: .br "long_names" allow up to 37 characters with ISO file names. .br -"no_force_dots" do not add a dot to filenames which have none. +"no_force_dots" do not add a dot to ISO file names which have none. .br "lowercase" allow lowercase characters in ISO file names. .br @@ -1742,7 +1750,7 @@ Default setting is .br "clear:deep_paths:long_paths:always_gmt:old_rr". .br -Note: The term "ISO file" means the plain ISO 9660 names wnd attributes +Note: The term "ISO file" means the plain ISO 9660 names and attributes which get visible if the reader ignores Rock Ridge. .TP \fB\-volid\fR text diff --git a/libisoburn/trunk/xorriso/xorriso.c b/libisoburn/trunk/xorriso/xorriso.c index 8154b04b..aa397eb2 100644 --- a/libisoburn/trunk/xorriso/xorriso.c +++ b/libisoburn/trunk/xorriso/xorriso.c @@ -2611,7 +2611,7 @@ int Exprnode_is_defined(struct ExprnodE *fnode, int flag) int Exprnode_own_value(struct XorrisO *xorriso, struct ExprnodE *fnode, - void *node, char *name, + void *node, char *name, char *path, struct stat *boss_stbuf, struct stat *stbuf, int flag) /* flag: @@ -2629,9 +2629,10 @@ return: (also from Exprtest_match() and Exprnode_tree_value() ) return(1); if(fnode->sub!=NULL) { ret= Exprnode_tree_value(xorriso, fnode->sub, -1, - node, name, boss_stbuf, stbuf, 0); + node, name, path, boss_stbuf, stbuf, 0); } else { - ret= Exprtest_match(xorriso, fnode->test, node, name, boss_stbuf, stbuf, 0); + ret= Exprtest_match(xorriso, fnode->test, node, name, path, + boss_stbuf, stbuf, 0); } if(ret<0) return(ret); @@ -2656,7 +2657,7 @@ int Exprnode_op(int value1, int value2, int op, int flag) int Exprnode_tree_value(struct XorrisO *xorriso, struct ExprnodE *fnode, - int left_value, void *node, char *name, + int left_value, void *node, char *name, char *path, struct stat *boss_stbuf, struct stat *stbuf, int flag) /* bit0-7= testmode: 0=head , 1=filename @@ -2686,7 +2687,7 @@ return: (also from Nntpftest_match() and Nntpfnode_own_value() ) } } fnode->composed_value= fnode->own_value= - Exprnode_own_value(xorriso, fnode, node, name, boss_stbuf, stbuf, 0); + Exprnode_own_value(xorriso, fnode, node, name, path, boss_stbuf, stbuf, 0); if(fnode->own_value < 0 || fnode->own_value > 1) return(fnode->own_value); @@ -2707,7 +2708,7 @@ return: (also from Nntpftest_match() and Nntpfnode_own_value() ) } } value= Exprnode_tree_value(xorriso, fnode->right,fnode->composed_value, - node, name, boss_stbuf, stbuf, 0); + node, name, path, boss_stbuf, stbuf, 0); if(value<0 || value>1) return(value); fnode->composed_value= value; @@ -2725,7 +2726,7 @@ return: (also from Nntpftest_match() and Nntpfnode_own_value() ) } } value= Exprnode_tree_value(xorriso, fnode->right,fnode->own_value, - node, name, boss_stbuf, stbuf, 0); + node, name, path, boss_stbuf, stbuf, 0); if(value<0||value>1) return(value); } else @@ -2746,7 +2747,7 @@ ex: branch= fnode->false_branch; if(branch!=NULL) { ret= Exprnode_tree_value(xorriso, branch, -1, - node, name, boss_stbuf, stbuf, 0); + node, name, path, boss_stbuf, stbuf, 0); if(ret<0) return(ret); if(ret>1) @@ -2775,6 +2776,7 @@ int Findjob_new(struct FindjoB **o, char *start_path, int flag) m->invert= 0; m->use_shortcuts= 1; m->action= 0; /* print */ + m->prune= 0; m->target= NULL; /* a mere pointer, not managed memory */ m->text_2= NULL; /* a mere pointer, not managed memory */ m->user= 0; @@ -3153,6 +3155,8 @@ improper_range:; } +/* @param flag bit0= -wholename rather than -name +*/ int Findjob_set_name_expr(struct FindjoB *o, char *name_expr, int flag) { char regexpr[2*SfileadrL+2]; @@ -3167,7 +3171,7 @@ int Findjob_set_name_expr(struct FindjoB *o, char *name_expr, int flag) if(ret <= 0) return(ret); t= o->cursor->test; - t->test_type= 1; + t->test_type= (flag & 1 ? 13 : 1); name_re= (regex_t *) calloc(1, sizeof(regex_t)); if(name_re == NULL) return(-1); @@ -3365,6 +3369,15 @@ int Findjob_set_false(struct FindjoB *o, int value, int flag) } +int Findjob_set_prune(struct FindjoB *o, int flag) +{ + int ret; + + ret= Findjob_set_prop_filter(o, 12, 0, 0); + return(ret); +} + + int Findjob_set_found_path(struct FindjoB *o, char *path, int flag) { if(o->found_path != NULL) @@ -3414,13 +3427,13 @@ int Findjob_get_action_parms(struct FindjoB *o, char **target, char **text_2, int Findjob_test_2(struct XorrisO *xorriso, struct FindjoB *o, - void *node, char *name, + void *node, char *name, char *path, struct stat *boss_stbuf, struct stat *stbuf, int flag) { int ret; ret= Exprnode_tree_value(xorriso, o->test_tree, -1, - node, name, boss_stbuf, stbuf, 0); + node, name, path, boss_stbuf, stbuf, 0); if(ret == 3) ret= 1; else if(ret == 2) @@ -10328,7 +10341,8 @@ int Xorriso_findx(struct XorrisO *xorriso, struct FindjoB *job, #ifdef Xorriso_findjob_on_expR - ret= Findjob_test_2(xorriso, job, NULL, namept, NULL, dir_stbuf, 0); + ret= Findjob_test_2(xorriso, job, NULL, namept, dir_path, NULL, dir_stbuf, + 0); #else /* Xorriso_findjob_on_expR */ @@ -10401,7 +10415,7 @@ int Xorriso_findx(struct XorrisO *xorriso, struct FindjoB *job, #ifdef Xorriso_findjob_on_expR - ret= Findjob_test_2(xorriso, job, NULL, name, dir_stbuf, &stbuf, 0); + ret= Findjob_test_2(xorriso, job, NULL, name, path, dir_stbuf, &stbuf, 0); #else /* Xorriso_findjob_on_expR */ @@ -14753,7 +14767,7 @@ int Xorriso_option_find(struct XorrisO *xorriso, int argc, char **argv, if(i+1>=end_idx) { not_enough_arguments:; sprintf(xorriso->info_text, - "-find[ix]: not enough arguments with -exec %s", + "-find[ix]: not enough arguments with test %s", Text_shellsafe(argv[i], sfe, 0)); goto sorry_ex; } @@ -14764,6 +14778,17 @@ not_enough_arguments:; Text_shellsafe(argv[i], sfe, 0)); goto sorry_ex; } + } else if(strcmp(argv[i], "-wholename")==0) { + if(i+1>=end_idx) + goto not_enough_arguments; + i++; + ret= Findjob_set_name_expr(job, argv[i], 1); + if(ret<=0) { + sprintf(xorriso->info_text, + "-find[ix]: cannot set -wholename expression %s", + Text_shellsafe(argv[i], sfe, 0)); + goto sorry_ex; + } } else if(strcmp(argv[i], "-type")==0) { if(i+1>=end_idx) goto not_enough_arguments; @@ -14824,7 +14849,8 @@ not_enough_arguments:; goto not_enough_arguments; i++; ret= Findjob_set_decision(job, argv[i], 0); - + } else if(strcmp(argv[i], "-prune") == 0) { + ret= Findjob_set_prune(job, 0); } else if(strcmp(argv[i], "-sub") == 0 || strcmp(argv[i], "(") == 0) { ret= Findjob_open_bracket(job, 0); } else if(strcmp(argv[i], "-subend") == 0 || strcmp(argv[i], ")") == 0) { @@ -14849,8 +14875,13 @@ not_enough_arguments:; #endif /* Xorriso_findjob_on_expR */ } else if(strcmp(argv[i], "-exec")==0) { - if(i+1>=end_idx) - goto not_enough_arguments; + if(i+1>=end_idx) { +not_enough_exec_arguments:; + sprintf(xorriso->info_text, + "-find[ix]: not enough arguments with -exec %s", + Text_shellsafe(argv[i], sfe, 0)); + goto sorry_ex; + } i++; cpt= argv[i]; if(*cpt=='-') @@ -14868,14 +14899,14 @@ not_enough_arguments:; /* >>> not implemented yet */; } else if(strcmp(cpt, "mv")==0) { if(i+1>=end_idx) - goto not_enough_arguments; + goto not_enough_exec_arguments; i++; Findjob_set_action_target(job, 3, argv[i], 0); #endif } else if(strcmp(cpt, "chown")==0 || strcmp(cpt, "chown_r")==0) { if(i+1>=end_idx) - goto not_enough_arguments; + goto not_enough_exec_arguments; i++; ret= Xorriso_convert_uidstring(xorriso, argv[i], &user, 0); if(ret<=0) @@ -14887,7 +14918,7 @@ not_enough_arguments:; } } else if(strcmp(cpt, "chgrp")==0 || strcmp(cpt, "chgrp_r")==0) { if(i+1>=end_idx) - goto not_enough_arguments; + goto not_enough_exec_arguments; i++; ret= Xorriso_convert_gidstring(xorriso, argv[i], &group, 0); if(ret<=0) @@ -14899,7 +14930,7 @@ not_enough_arguments:; } } else if(strcmp(cpt, "chmod")==0 || strcmp(cpt, "chmod_r")==0) { if(i+1>=end_idx) - goto not_enough_arguments; + goto not_enough_exec_arguments; i++; ret= Xorriso_convert_modstring(xorriso, "-find -exec chmod", argv[i], &mode_and, &mode_or, 0); @@ -14912,7 +14943,7 @@ not_enough_arguments:; } } else if(strcmp(cpt, "alter_date")==0 || strcmp(cpt, "alter_date_r")==0){ if(i+2>=end_idx) - goto not_enough_arguments; + goto not_enough_exec_arguments; i+= 2; ret= Xorriso_convert_datestring(xorriso, "-find -exec alter_date", argv[i-1], argv[i], &type, &date, 0); @@ -14937,7 +14968,7 @@ not_enough_arguments:; } else if(strcmp(cpt, "compare")==0 || strcmp(cpt, "update")==0) { if(i+1>=end_idx) - goto not_enough_arguments; + goto not_enough_exec_arguments; i++; action= 14; if(strcmp(cpt, "update")==0) @@ -14961,7 +14992,7 @@ not_enough_arguments:; strcmp(cpt, "empty_iso_dir")==0 || strcmp(cpt, "is_full_in_iso")==0) { if(i+1>=end_idx) - goto not_enough_arguments; + goto not_enough_exec_arguments; i++; ret= Xorriso_make_abs_adr(xorriso, xorriso->wdi, argv[i], other_path_start, 1|2|4); @@ -14992,7 +15023,7 @@ not_enough_arguments:; Findjob_set_action_target(job, 24, NULL, 0); } else if(strcmp(cpt, "setfacl")==0) { if(i+1>=end_idx) - goto not_enough_arguments; + goto not_enough_exec_arguments; i++; ret= Xorriso_normalize_acl_text(xorriso, argv[i], &access_acl_text, &default_acl_text, 0); @@ -15004,7 +15035,7 @@ not_enough_arguments:; Findjob_set_action_target(job, 26, NULL, 0); } else if(strcmp(cpt, "setfattr")==0) { if(i + 2 >= end_idx) - goto not_enough_arguments; + goto not_enough_exec_arguments; i+= 2; /* check input */ ret= Xorriso_path_setfattr(xorriso, NULL, "", argv[i - 1], @@ -15014,7 +15045,7 @@ not_enough_arguments:; Findjob_set_action_text_2(job, 27, argv[i - 1], argv[i], 0); } else if(strcmp(cpt, "set_filter")==0) { if(i + 1 >= end_idx) - goto not_enough_arguments; + goto not_enough_exec_arguments; i+= 1; Findjob_set_action_target(job, 28, argv[i], 0); if(!(flag&2)) { @@ -15447,9 +15478,10 @@ int Xorriso_option_help(struct XorrisO *xorriso, int flag) " -find iso_rr_path [test [op] [test ...]] [-exec action [params]]", " performs an action on files below the given directory in", " the ISO image. Tests:", -" -name pattern, -type b|c|d|p|f|l|s|e, -pending_data,", -" -lba_range start count, -damaged, -has_acl, -has_xattr,", -" -has_aaip, -has_filter, -decision yes|no", +" -name pattern, -wholename pattern, -type b|c|d|p|f|l|s|e,", +" -pending_data, -lba_range start count, -damaged,", +" -has_acl, -has_xattr, -has_aaip, -has_filter,", +" -prune, -decision yes|no, -true, -false", " Operators: -not, -or, -and, -sub, (, -subend, ),", " -if, -then, -elseif, -else, -endif", " Action may be one of: echo, chown, chown_r, chgrp, chgrp_r", @@ -15458,7 +15490,6 @@ int Xorriso_option_help(struct XorrisO *xorriso, int flag) " 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 [...]", " Create empty directories if they do not exist yet.", " -rmdir iso_rr_path [***]", @@ -15599,9 +15630,9 @@ int Xorriso_option_help(struct XorrisO *xorriso, int flag) "", " -findx disk_path [-name pattern] [-type t] [-exec action [params]]", " Like -find but operating on local filesystem. Most -exec", -" actions are defaulted to action is always echo. Supported", -" actions are: in_iso, not_in_iso, is_full_in_iso,", -" add_missing, empty_iso_dir.", +" actions are defaulted to action echo. Supported actions are:", +" in_iso, not_in_iso, is_full_in_iso, add_missing,", +" empty_iso_dir", "", " -compare disk_path iso_rr_path", " compare attributes and in case of regular data files the", diff --git a/libisoburn/trunk/xorriso/xorriso_private.h b/libisoburn/trunk/xorriso/xorriso_private.h index 6418ca00..f0e8c72e 100644 --- a/libisoburn/trunk/xorriso/xorriso_private.h +++ b/libisoburn/trunk/xorriso/xorriso_private.h @@ -763,7 +763,9 @@ struct ExprtesT { 8= -has_filter 9= -wanted_node IsoNode *arg1 (for internal use, arg1 not allocated) 10= -pending_data - 11= -decision *arg1 ("y", "1", "n", "0") + 11= -decision char *arg1 ("yes", "no") + 12= -prune + 13= -wholename char *arg1 (regex_t in *arg2) */ int test_type; @@ -864,6 +866,7 @@ struct FindjoB { 29= show_stream */ int action; + int prune; /* action specific parameters */ char *target; @@ -890,14 +893,14 @@ struct FindjoB { int Exprtest_match(struct XorrisO *xorriso, struct ExprtesT *ftest, - void *node_pt, char *name, + void *node_pt, char *name, char *path, struct stat *boss_stbuf, struct stat *stbuf, int flag); int Exprnode_destroy(struct ExprnodE **fnode, int flag); int Exprnode_tree_value(struct XorrisO *xorriso, struct ExprnodE *fnode, - int left_value, void *node, char *name, + int left_value, void *node, char *name, char *path, struct stat *boss_stbuf, struct stat *stbuf, int flag); @@ -939,7 +942,7 @@ int Findjob_elseif(struct FindjoB *job, int flag); int Findjob_endif(struct FindjoB *job, int flag); int Findjob_test_2(struct XorrisO *xorriso, struct FindjoB *o, - void *node, char *name, + void *node, char *name, char *path, struct stat *boss_stbuf, struct stat *stbuf, int flag); int Findjob_set_action_found_path(struct FindjoB *o, int flag); diff --git a/libisoburn/trunk/xorriso/xorriso_timestamp.h b/libisoburn/trunk/xorriso/xorriso_timestamp.h index a5cdd7ce..03faae1a 100644 --- a/libisoburn/trunk/xorriso/xorriso_timestamp.h +++ b/libisoburn/trunk/xorriso/xorriso_timestamp.h @@ -1 +1 @@ -#define Xorriso_timestamP "2009.04.22.173648" +#define Xorriso_timestamP "2009.04.23.103301" diff --git a/libisoburn/trunk/xorriso/xorrisoburn.c b/libisoburn/trunk/xorriso/xorrisoburn.c index 7173c5dc..2da33416 100644 --- a/libisoburn/trunk/xorriso/xorrisoburn.c +++ b/libisoburn/trunk/xorriso/xorrisoburn.c @@ -6635,7 +6635,7 @@ int Xorriso_findi_action(struct XorrisO *xorriso, struct FindjoB *job, #ifdef Xorriso_findjob_on_expR int Exprtest_match(struct XorrisO *xorriso, struct ExprtesT *ftest, - void *node_pt, char *name, + void *node_pt, char *name, char *path, struct stat *boss_stbuf, struct stat *stbuf, int flag) /* return: @@ -6801,11 +6801,18 @@ return: } break; case 11: /* -decision */ - value= 3; + value= 2; decision= (char *) arg1; - if(strcmp(decision, "no") == 0 || strcmp(decision, "false") == 0 || - strcmp(decision, "0") == 0) - value= 2; + if(strcmp(decision, "yes") == 0 || strcmp(decision, "true") == 0) + value= 3; + + break; case 12: /* -prune */ + value= 1; + ftest->boss->prune= 1; + + break; case 13: /* -wholename *arg1 (regex in *arg2) */ + ret= regexec(arg2, path, 1, &name_match, 0); + value= !ret; break; default: @@ -6826,15 +6833,17 @@ ex:; } +/* @return <0 = error , 0 = no match , 1 = match */ int Xorriso_findi_test(struct XorrisO *xorriso, struct FindjoB *job, - IsoNode *node, char *name, + IsoNode *node, char *name, char *path, struct stat *boss_stbuf, struct stat *stbuf, int depth, int flag) { int ret; - ret= Findjob_test_2(xorriso, job, node, name, boss_stbuf, stbuf, 1); - if(ret<=0) + job->prune= 0; + ret= Findjob_test_2(xorriso, job, node, name, path, boss_stbuf, stbuf, 1); + if(ret <= 0) return(ret); return(1); } @@ -6842,7 +6851,7 @@ int Xorriso_findi_test(struct XorrisO *xorriso, struct FindjoB *job, #else /* Xorriso_findjob_on_expR */ int Xorriso_findi_test(struct XorrisO *xorriso, struct FindjoB *job, - IsoNode *node, char *name, + IsoNode *node, char *name, char *path, struct stat *boss_stbuf, struct stat *stbuf, int depth, int flag) { @@ -7026,10 +7035,12 @@ int Xorriso_findi(struct XorrisO *xorriso, struct FindjoB *job, else name++; - ret= Xorriso_findi_test(xorriso, job, iso_node, name, NULL, dir_stbuf, + ret= Xorriso_findi_test(xorriso, job, iso_node, name, path, NULL, dir_stbuf, depth, 0); if(ret<0) goto ex; + if(job->prune) + no_dive= 1; if(ret>0) { ret= Xorriso_findi_action(xorriso, job, (IsoDirIter *) boss_iter, boss_mem, @@ -7095,10 +7106,12 @@ int Xorriso_findi(struct XorrisO *xorriso, struct FindjoB *job, handling of the find start path with mount points. Dangerous to change. */ - ret= Xorriso_findi_test(xorriso, job, node, name, dir_stbuf, &stbuf, + ret= Xorriso_findi_test(xorriso, job, node, name, path, dir_stbuf, &stbuf, depth, 0); if(ret<0) goto ex; + if(job->prune) + no_dive= 1; if(ret>0) { ret= Xorriso_make_abs_adr(xorriso, xorriso->wdi, path, abs_path, 1|2|4); if(ret<=0)