diff --git a/xorriso/xorriso.c b/xorriso/xorriso.c index 97081310..7b84e41a 100644 --- a/xorriso/xorriso.c +++ b/xorriso/xorriso.c @@ -5,7 +5,7 @@ or - cc -g -DXorriso_with_maiN -DXorriso_with_regeX -DXorriso_with_readlinE \ + cc -g -DXorriso_with_maiN -DXorriso_with_readlinE \ -DXorriso_build_timestamP='"'"$(date -u '+%Y.%m.%d.%H%M%S')"'"' \ -Wall -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE \ -o xorriso/xorriso \ @@ -14,7 +14,7 @@ or or - cc -g -DXorriso_with_regeX -DXorriso_with_readlinE \ + cc -g -DXorriso_with_readlinE \ -DXorriso_build_timestamP='"'"$(date -u '+%Y.%m.%d.%H%M%S')"'"' \ -Wall -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE \ -c \ @@ -1742,6 +1742,248 @@ return: } +#ifndef Xorriso_sregex_externaL + +/* ---------------------------------- LstrinG --------------------------- */ + +struct LstrinG { + char *text; + struct LstrinG *prev,*next; +}; + +int Lstring_destroy(struct LstrinG **lstring, int flag); + + +/* + @param flag Bitfield for control purposes + bit0= insert before link rather than after it + bit1= do not copy data (e.g. because *data is invalid) +*/ +int Lstring_new_binary(struct LstrinG **lstring, char *data, int data_len, + struct LstrinG *link, int flag) +{ + int ret; + struct LstrinG *s; + + s= TSOB_FELD(struct LstrinG,1); + if(s==NULL) + return(-1); + s->text= NULL; + s->next= s->prev= NULL; + + if(data_len<=0) + {ret= -1; goto failed;} + s->text= Smem_malloC(data_len); + if(s->text==NULL) + {ret= -1; goto failed;} + if(!(flag&2)) + memcpy(s->text,data,data_len); + + if(link==NULL) { + ; + } else if(flag&1) { + s->next= link; + s->prev= link->prev; + if(link->prev!=NULL) + link->prev->next= s; + link->prev= s; + } else { + s->prev= link; + s->next= link->next; + if(link->next!=NULL) + link->next->prev= s; + link->next= s; + } + *lstring= s; + return(1); +failed:; + *lstring= s; + Lstring_destroy(lstring,0); + return(-1); +} + + +/* + @param flag Bitfield for control purposes + bit0= insert before link rather than after it +*/ +int Lstring_new(struct LstrinG **lstring, char *text, struct LstrinG *link, + int flag) +{ + int ret; + + ret= Lstring_new_binary(lstring,text,strlen(text)+1,link,flag&1); + return(ret); +} + + +/* + @param flag Bitfield for control purposes + bit0= do not set *lstring to NULL +*/ +int Lstring_destroy(struct LstrinG **lstring, int flag) +{ + struct LstrinG *s; + + s= *lstring; + if(s==NULL) + return(0); + if(s->prev!=NULL) + s->prev->next= s->next; + if(s->next!=NULL) + s->next->prev= s->prev; + if(s->text!=NULL) + Smem_freE(s->text); + Smem_freE((char *) s); + if(!(flag&1)) + *lstring= NULL; + return(1); +} + + +int Lstring_destroy_all(struct LstrinG **lstring, int flag) +{ + struct LstrinG *s,*next; + + if((*lstring)==NULL) + return(0); + for(s= *lstring; s->prev!=NULL; s= s->prev); + for(;s!=NULL;s= next){ + next= s->next; + Lstring_destroy(&s,0); + } + *lstring= NULL; + return(1); +} + + +/* + @param flag Bitfield for control purposes + bit0= return first lstring which begins with text + bit1= do not rewind list before starting to search + bit2= advance to lstring->next before starting to search +*/ +int Lstring_find_text(struct LstrinG *lstring, char *text, + struct LstrinG **found, int flag) +{ + struct LstrinG *s; + + if(lstring==NULL) + return(0); + if(!(flag&2)) + for(s= lstring; s->prev!=NULL; s= s->prev); + else + s= lstring; + if(flag&4) + if(s!=NULL) + s= s->next; + if(flag&1) { + for(;s!=NULL;s= s->next) + if(strncmp(s->text,text,strlen(text))==0) + {*found= s; return(1);} + } else { + for(;s!=NULL;s= s->next) + if(strcmp(s->text,text)==0) + {*found= s; return(1);} + } + return(0); +} + + +/* + @param flag Bitfield for control purposes + bit0= return first lstring which begins with text + bit1= do not rewind list before starting to search + bit2= advance to lstring->next before starting to search +*/ +int Lstring_is_listed(struct LstrinG *lstring, char *text, int flag) +{ + struct LstrinG *s; + int ret; + + ret= Lstring_find_text(lstring,text,&s,flag&7); + return(ret); +} + + +int Lstring_copy_all(source,target,flag) +struct LstrinG *source; +struct LstrinG **target; +int flag; +{ + struct LstrinG *s,*t; + + if(source==NULL) + return(0); + for(s= source; s->prev!=NULL; s= s->prev); + t= *target; + if(t!=NULL) + for(;t->next!=NULL;t=t->next); + for(;s!=NULL;s= s->next){ + if(Lstring_new(&t,s->text,t,0)<=0) + return(-1); + if((*target)==NULL) + *target= t; + } + return(1); +} + + +int Lstring_append(struct LstrinG *entry, char *text, int flag) +{ + struct LstrinG *target= NULL,*newby; + + if(entry!=NULL) + for(target= entry; target->next!=NULL; target= target->next); + if(Lstring_new(&newby,text,target,0)<=0) + return(-1); + return(1); +} + + +int Lstring_revert(struct LstrinG **start, int flag) +{ + struct LstrinG *current,*last,*tr,*next; + + if((*start)==NULL) + return(0); + for(current= *start; current!=NULL; current= next) { + next= current->next; + last= current; + tr= current->next; + current->next= current->prev; + current->prev= tr; + } + last->prev= (*start)->next; + (*start)->next= NULL; + *start= last; + return(1); +} + + +/* Not imported from stic/src/sregex.c : + int Lstring_from_separator_list(result,list_text,link,sep,flag) +*/ + + +int Lstring_append_binary(struct LstrinG **entry, char *data, int data_len, + int flag) +{ + struct LstrinG *target= NULL,*newby; + + if(*entry!=NULL) + for(target= *entry; target->next!=NULL; target= target->next); + if(Lstring_new_binary(&newby, data, data_len, target, 0)<=0) + return(-1); + if(*entry!=NULL) + *entry= newby; + return(1); +} + + +#endif /* Xorriso_sregex_externaL */ + + /* ------------------------------ LinkiteM -------------------------------- */ struct LinkiteM { @@ -1833,10 +2075,8 @@ struct FindjoB { char *start_path; char *name_expr; -#ifdef Xorriso_with_regeX regex_t name_re; regmatch_t name_match; -#endif /* b = blockdev c = chardev @@ -1925,9 +2165,7 @@ int Findjob_destroy(struct FindjoB **o, int flag) if(m->start_path!=NULL) free(m->start_path); if(m->name_expr!=NULL) { -#ifdef Xorriso_with_regeX regfree(&(m->name_re)); -#endif free(m->name_expr); } Findjob_destroy(&(m->subjob), 0); @@ -1963,9 +2201,7 @@ int Findjob_set_name_expr(struct FindjoB *o, char *name_expr, int flag) char regexpr[2*SfileadrL+2]; if(o->name_expr!=NULL) { -#ifdef Xorriso_with_regeX regfree(&(o->name_re)); -#endif free(o->name_expr); o->name_expr= NULL; } @@ -2002,11 +2238,7 @@ int Findjob_test(struct FindjoB *o, char *name, int ret; if(o->name_expr!=NULL) { -#ifdef Xorriso_with_regeX ret= regexec(&(o->name_re),name,1,&(o->name_match),0); -#else - ret= !(strcmp(name, o->name_expr)==0 || strcmp(o->name_expr, "*")==0); -#endif if(ret!=0) return(0); } @@ -2345,6 +2577,163 @@ int Splitpart__compose(char *adr, int partno, int total_parts, /* ---------------------------- End SplitparT ------------------------- */ +/* ------------------------------ ExclusionS ------------------------------ */ + +struct ExclusionS { + + /* Absolute input patterns which lead to not_paths */ + struct LstrinG *not_paths_descr; + + /* Actually banned absolute paths */ + struct LstrinG *not_paths; + + /* Input patterns which lead to not_leafs */ + struct LstrinG *not_leafs_descr; + + /* Compiled not_leaf patterns. Caution: not char[] but regex_t */ + struct LstrinG *not_leafs; + +}; + + +int Exclusions_new(struct ExclusionS **o, int flag) +{ + struct ExclusionS *m; + + m= *o= TSOB_FELD(struct ExclusionS, 1); + if(m==NULL) + return(-1); + m->not_paths_descr= NULL; + m->not_paths= NULL; + m->not_leafs_descr= NULL; + m->not_leafs= NULL; + return(1); +} + + +int Exclusions_destroy(struct ExclusionS **o, int flag) +{ + struct LstrinG *s,*next; + + if((*o)==NULL) + return(0); + Lstring_destroy_all(&((*o)->not_paths_descr), 0); + Lstring_destroy_all(&((*o)->not_paths), 0); + Lstring_destroy_all(&((*o)->not_leafs_descr), 0); + for(s= (*o)->not_leafs; s!=NULL; s= next){ + next= s->next; + regfree((regex_t *) s->text); + Lstring_destroy(&s, 0); + } + (*o)= NULL; + return(1); +} + + +int Exclusions_add_not_paths(struct ExclusionS *o, int descrc, char **descrs, + int pathc, char **paths, int flag) +{ + struct LstrinG *s, *new_s; + int i, ret; + + s= NULL; + if(o->not_paths_descr!=NULL) + for(s= o->not_paths_descr; s->next!=NULL; s= s->next); + for(i= 0; inot_paths_descr==NULL) + o->not_paths_descr= new_s; + s= new_s; + } + s= NULL; + if(o->not_paths!=NULL) + for(s= o->not_paths; s->next!=NULL; s= s->next); + for(i= 0; inot_paths==NULL) + o->not_paths= new_s; + s= new_s; + } + return(1); +} + + +/* @return -1=cannot store , 0=cannot compile regex , 1=ok +*/ +int Exclusions_add_not_leafs(struct ExclusionS *o, char *not_leafs_descr, + regex_t *re, int flag) +{ + int ret; + + ret= Lstring_append_binary(&(o->not_leafs_descr), + not_leafs_descr, strlen(not_leafs_descr)+1, 0); + if(ret<=0) + return(-1); + ret= Lstring_append_binary(&(o->not_leafs), (char *) re, sizeof(regex_t), 0); + if(ret<=0) + return(-1); + return(1); +} + + +/* @return 0=no match , 1=not_paths , 2=not_leafs, <0=error +*/ +int Exclusions_match(struct ExclusionS *o, char *abs_path, int flag) +{ + struct LstrinG *s; + char leaf[SfileadrL], *leaf_pt; + regmatch_t match[1]; + int ret, was_non_slash; + + /* test abs_paths */ + for(s= o->not_paths; s!=NULL; s= s->next) + if(strcmp(abs_path, s->text)==0) + return(1); + + /* determine leafname */ + was_non_slash= 0; + for(leaf_pt= abs_path+strlen(abs_path); leaf_pt>leaf; leaf_pt--) { + if(*leaf_pt=='/') { + if(was_non_slash) { + leaf_pt++; + break; + } + } else if(*leaf_pt!=0) + was_non_slash= 1; + } + if(strlen(leaf_pt)>=SfileadrL) + return(-1); + strcpy(leaf, leaf_pt); + leaf_pt= strchr(leaf, '/'); + if(leaf_pt!=NULL) + *leaf_pt= 0; + + /* test with leaf expressions */ + for(s= o->not_leafs; s!=NULL; s= s->next) { + ret= regexec((regex_t *) s->text, leaf, 1, match, 0); + if(ret==0) + return(2); + } + return(0); +} + + +int Exclusions_get_descrs(struct ExclusionS *o, + struct LstrinG **not_paths_descr, + struct LstrinG **not_leafs_descr, int flag) +{ + *not_paths_descr= o->not_paths_descr; + *not_leafs_descr= o->not_leafs_descr; + return(1); +} + + +/* ---------------------------- End ExclusionS ---------------------------- */ + /* ------------------------------- Xorriso -------------------------------- */ /** The list of startup file names */ @@ -2360,7 +2749,7 @@ static char Xorriso_sys_rc_nameS[Xorriso_rc_nuM][80]= { int Xorriso_new(struct XorrisO ** xorriso,char *progname, int flag) { - int i; + int i, ret; struct XorrisO *m; *xorriso= m= TSOB_FELD(struct XorrisO,1); @@ -2428,6 +2817,7 @@ int Xorriso_new(struct XorrisO ** xorriso,char *progname, int flag) m->do_iso_rr_pattern= 1; m->do_disk_pattern= 2; m->temp_mem_limit= 16*1024*1024; + m->disk_exclusions= NULL; m->use_stdin= 0; m->result_page_length= 0; m->result_page_width= 80; @@ -2451,10 +2841,8 @@ int Xorriso_new(struct XorrisO ** xorriso,char *progname, int flag) m->return_with_value= 32; m->eternal_problem_status= 0; m->eternal_problem_status_text[0]= 0; -#ifdef Xorriso_with_regeX m->re= NULL; /* >>> ??? how to initialize m->match[0] ? */ -#endif /* Xorriso_with_regeX */ m->re_constants= NULL; m->re_count= 0; m->re_fill= 0; @@ -2484,7 +2872,14 @@ int Xorriso_new(struct XorrisO ** xorriso,char *progname, int flag) m->result_open_line_len= 0; m->info_text[0]= 0; + ret= Exclusions_new(&(m->disk_exclusions), 0); + if(ret<=0) + goto failure; + return(1); +failure:; + Xorriso_destroy(xorriso, 0); + return(-1); } @@ -2492,7 +2887,6 @@ int Xorriso_destroy_re(struct XorrisO *m, int flag) { int i; -#ifdef Xorriso_with_regeX if(m->re!=NULL) { for(i=0;ire_fill;i++) { if(m->re_constants!=NULL) @@ -2503,7 +2897,6 @@ int Xorriso_destroy_re(struct XorrisO *m, int flag) free((char *) m->re); m->re= NULL; } -#endif /* Xorriso_with_regeX */ if(m->re_constants!=NULL) { for(i=0;ire_fill;i++) @@ -2527,6 +2920,7 @@ int Xorriso_destroy(struct XorrisO **xorriso, int flag) if(m==NULL) return(0); Xorriso_destroy_re(m,0); + Exclusions_destroy(&(m->disk_exclusions), 0); Xorriso_detach_libraries(m, flag&1); free((char *) m); @@ -3076,18 +3470,6 @@ int Xorriso_prepare_regex(struct XorrisO *xorriso, char *adr, int flag) wd= xorriso->wdx; else wd= xorriso->wdi; -#ifndef Xorriso_with_regeX - - if(xorriso->search_mode==2 || - (xorriso->search_mode==3 && xorriso->structured_search==0)) { -no_regex_available:; - sprintf(xorriso->info_text,"%s : regular expressions not implemented", - xorriso->progname); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); - return(0); - } - -#endif /* ! Xorriso_with_regeX */ if(xorriso->search_mode>=2 && xorriso->search_mode<=4) { if(xorriso->search_mode==3 || xorriso->search_mode==4) { @@ -3122,13 +3504,9 @@ no_regex_available:; cpt++; } count= i+1; - -#ifdef Xorriso_with_regeX xorriso->re= TSOB_FELD(regex_t,count); if(xorriso->re==NULL) return(-1); -#endif /* Xorriso_with_regeX */ - xorriso->re_constants= TSOB_FELD(char *,count); if(xorriso->re_constants==NULL) return(-1); @@ -3170,11 +3548,7 @@ no_regex_available:; free(xorriso->re_constants[xorriso->re_fill-1]); xorriso->re_constants[xorriso->re_fill-1]= NULL; } else -#ifdef Xorriso_with_regeX regfree(&(xorriso->re[xorriso->re_fill-1])); -#else /* Xorriso_with_regeX */ - ; -#endif /* ! Xorriso_with_regeX */ (xorriso->re_fill)--; goto next_adr_part; } @@ -3188,22 +3562,8 @@ no_regex_available:; <=0) return(-1); } else { - -#ifdef Xorriso_with_regeX if(regcomp(&(xorriso->re[xorriso->re_fill]),xorriso->reg_expr,0)!=0) goto cannot_compile; -#else /* Xorriso_with_regeX */ - if(!warned_of_regex) { - sprintf(xorriso->info_text, - "No wildcards get recognized besides single '*'"); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING",0); - warned_of_regex= 1; - } - if(Sregex_string(&(xorriso->re_constants[xorriso->re_fill]),adr_part,0) - <=0) - return(-1); -#endif /* ! Xorriso_with_regeX */ - } xorriso->re_fill++; next_adr_part:; @@ -3251,7 +3611,6 @@ next_adr_part:; } xorriso->re_fill= 1; } else { -#ifdef Xorriso_with_regeX xorriso->re= TSOB_FELD(regex_t,1); if(xorriso->re==NULL) return(-1); @@ -3262,15 +3621,6 @@ cannot_compile:; Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE",0); return(0); } -#else /* Xorriso_with_regeX */ - sprintf(xorriso->info_text, - "No wildcards get recognized besides single '*'"); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING",0); - Xorriso_info(xorriso,0); - if(Sregex_string(&(xorriso->re_constants[0]),adr,0)<=0) - return(-1); - xorriso->re_fill= 1; -#endif /* ! Xorriso_with_regeX */ } } @@ -3291,9 +3641,7 @@ int Xorriso_regexec(struct XorrisO *xorriso, char *to_match, int *failed_at, int ret,i,re_start= 0,reg_nomatch= -1; char *cpt,*npt,adr_part[SfileadrL],*mpt; -#ifdef Xorriso_with_regeX reg_nomatch= REG_NOMATCH; -#endif /* Xorriso_with_regeX */ *failed_at= 0; if(!(xorriso->structured_search && xorriso->re_count>0)) { @@ -3305,12 +3653,7 @@ int Xorriso_regexec(struct XorrisO *xorriso, char *to_match, int *failed_at, return(reg_nomatch); return(0); } -#ifdef Xorriso_with_regeX ret= regexec(&(xorriso->re[0]),to_match,1,xorriso->match,0); -#else - ret= reg_nomatch; -#endif /* ! Xorriso_with_regeX */ - return(ret); } @@ -3338,15 +3681,9 @@ int Xorriso_regexec(struct XorrisO *xorriso, char *to_match, int *failed_at, if(strcmp(xorriso->re_constants[i],mpt)!=0) return(reg_nomatch); } else { - -#ifdef Xorriso_with_regeX ret= regexec(&(xorriso->re[i]),mpt,1,xorriso->match,0); if(ret!=0) return(ret); -#else - return(reg_nomatch); -#endif /* ! Xorriso_with_regeX */ - } if(npt==NULL) { if(i>=xorriso->re_fill-1) @@ -3486,9 +3823,10 @@ int Xorriso_status(struct XorrisO *xorriso, char *filter, FILE *fp, int flag) -options_from_file:${resume_state_file}_pos */ { - int is_default,no_defaults,i; + int is_default, no_defaults, i, ret; char *line, sfe[5*SfileadrL], mode[80], *form, *treatment; static char channel_prefixes[4][4]= {".","R","I","M"}; + struct LstrinG *paths, *leafs; no_defaults= flag&1; line= xorriso->result_line; @@ -3610,6 +3948,18 @@ int Xorriso_status(struct XorrisO *xorriso, char *filter, FILE *fp, int flag) if(!(is_default && no_defaults)) Xorriso_status_result(xorriso,filter,fp,flag&2); + ret= Exclusions_get_descrs(xorriso->disk_exclusions, &paths, &leafs, 0); + if(ret>0) { + for(; paths!=NULL; paths= paths->next) { + sprintf(line,"-not_paths %s --\n", Text_shellsafe(paths->text, sfe, 0)); + Xorriso_status_result(xorriso,filter,fp,flag&2); + } + for(; leafs!=NULL; leafs= leafs->next) { + sprintf(line,"-not_leaf %s\n", Text_shellsafe(leafs->text, sfe, 0)); + Xorriso_status_result(xorriso,filter,fp,flag&2); + } + } + is_default= (xorriso->do_iso_rr_pattern==1); sprintf(line,"-iso_rr_pattern %s\n", (xorriso->do_iso_rr_pattern == 1 ? "on" : @@ -4304,8 +4654,12 @@ int Xorriso_find_compare(struct XorrisO *xorriso, void *boss_iter, if(ret<=0) return(ret); - /* >>> compare exclusions against disk_path resp. leaf name */; - /* >>> eventually return 3 */ + /* compare exclusions against disk_path resp. leaf name */ + ret= Xorriso_path_is_excluded(xorriso, disk_path, 0); + if(ret<0) + return(ret); + if(ret>0) + return(3); follow_links= (xorriso->do_follow_links || (xorriso->do_follow_param && !(flag&2))) <<28; @@ -4763,7 +5117,7 @@ int Xorriso_end_idx(struct XorrisO *xorriso, If expansion is enabled, the vector might be allocated, else it is a pointer into the argv input vector. Thus the release of that memory is an expert task to be done by this - function only. Use bit8 for that. Wiith bit8 parameter argc MUST be the + function only. Use bit8 for that. With bit8 parameter argc MUST be the same value as with the call which might have allocated memory. @param xorriso The environment object @param argc Length of argv @@ -4807,7 +5161,8 @@ int Xorriso_opt_args(struct XorrisO *xorriso, char *cmd, Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); return(0); } - *end_idx= Xorriso_end_idx(xorriso, argc, argv, idx, (flag&1) || do_expand); + *end_idx= Xorriso_end_idx(xorriso, argc, argv, idx, + ((flag&1) || do_expand) | (flag&2)); if(*end_idx<0) return(*end_idx); if((flag&16) && (*end_idx)>idx) @@ -6031,9 +6386,11 @@ int Xorriso_findx(struct XorrisO *xorriso, struct FindjoB *job, if(ret<=0) goto ex; abs_dir_path= abs_dir_path_data; - - /* >>> compare exclusions against abs_path resp. leaf name */; - + ret= Xorriso_path_is_excluded(xorriso, abs_dir_path, 0); + if(ret<0) + goto ex; + if(ret>0) + {ret= 0; goto ex;} ret= lstat(abs_dir_path, dir_stbuf); if(ret==-1) {ret= 0; goto ex;} @@ -6093,9 +6450,11 @@ int Xorriso_findx(struct XorrisO *xorriso, struct FindjoB *job, ret= Xorriso_make_abs_adr(xorriso, dir_path, name, path, 4); if(ret<=0) goto ex; - - /* >>> compare exclusions against abs_path resp. leaf name */; - + ret= Xorriso_path_is_excluded(xorriso, abs_path, 0); + if(ret<0) + goto ex; + if(ret>0) + continue; ret= lstat(abs_path, &stbuf); if(ret==-1) continue; @@ -7081,6 +7440,20 @@ int Xorriso_write_session_log(struct XorrisO *xorriso, int flag) return(1); } + +int Xorriso_path_is_excluded(struct XorrisO *xorriso, char *path, int flag) +{ + int ret; + + ret= Exclusions_match(xorriso->disk_exclusions, path, 0); + if(ret<0) { + sprintf(xorriso->info_text, + "Error during disk file exclusion decision"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + } + return(ret); +} + /* ---------------------------- Options API ------------------------ */ @@ -9286,6 +9659,89 @@ int Xorriso_option_no_rc(struct XorrisO *xorriso, int flag) } +/* Option -not_leaf */ +int Xorriso_option_not_leaf(struct XorrisO *xorriso, char *pattern, int flag) +{ + regex_t re; + char regexpr[2*SfileadrL+2], sfe[5*SfileadrL]; + int ret; + + Xorriso__bourne_to_reg(pattern, regexpr, 0); + if(regcomp(&re, regexpr, 0)!=0) + goto cannot_add; + ret= Exclusions_add_not_leafs(xorriso->disk_exclusions, pattern, &re, 0); + if(ret<=0) { +cannot_add:; + sprintf(xorriso->info_text,"Cannot add pattern: -not_leaf %s", + Text_shellsafe(pattern, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(ret); + } + return(1); +} + + +/* Option -not_paths */ +int Xorriso_option_not_paths(struct XorrisO *xorriso, int argc, char **argv, + int *idx, int flag) +{ + int ret, end_idx, num_descr, dummy, optc= 0, i; + char **descr= NULL, **optv= NULL, sfe[5*SfileadrL], eff_path[SfileadrL]; + + + end_idx= Xorriso_end_idx(xorriso, argc, argv, *idx, + xorriso->do_disk_pattern==1); + if(end_idx<=0) + return(end_idx); + num_descr= end_idx - *idx; + if(num_descr<=0) + {ret= 1; goto ex;} + + /* produce absolute patterns */ + descr= TSOB_FELD(char *, num_descr); + if(descr==NULL) { +no_memory:; + Xorriso_no_pattern_memory(xorriso, sizeof(char *) * (off_t) num_descr, 0); + ret= -1; goto ex; + } + for(i= 0; iwdx, argv[i+*idx], + eff_path, 2|4); + if(ret<=0) + goto ex; + descr[i]= strdup(eff_path); + if(descr[i]==NULL) + goto no_memory; + } + + ret= Xorriso_opt_args(xorriso, "-not_paths", + num_descr, descr, 0, &dummy, &optc, &optv, 2); + if(ret<=0) + goto ex; + ret= Exclusions_add_not_paths(xorriso->disk_exclusions, + num_descr, descr, optc, optv, 0); + if(ret<=0) { + sprintf(xorriso->info_text,"Cannot add path list: -not_paths %s%s --", + Text_shellsafe(argv[*idx], sfe, 0), (num_descr>1 ? " ..." : "")); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + } +ex:; + (*idx)= end_idx; + Xorriso_opt_args(xorriso, "-not_paths", + num_descr, descr, 0, &dummy, &optc, &optv, 256); + if(descr!=NULL) { + for(i= 0; idisk_exclusions), 0); + ret= Exclusions_new(&(xorriso->disk_exclusions), 0); + return(ret); +} + + /* Options -rm alias -rmi , -rm_r alias -rm_ri , -rmdir alias -rmdiri */ /* @param flag bit0=recursive , bit1= remove empty directory: rmdir */ int Xorriso_option_rmi(struct XorrisO *xorriso, int argc, char **argv, @@ -10452,6 +10919,9 @@ next_command:; } else if(strcmp(cmd,"no_rc")==0) { ret= Xorriso_option_no_rc(xorriso, 0); + } else if(strcmp(cmd,"not_paths")==0) { + ret= Xorriso_option_not_paths(xorriso, argc, argv, idx, 0); + } else if(strcmp(cmd,"options_from_file")==0) { (*idx)++; ret= Xorriso_option_options_from_file(xorriso,arg1,0); @@ -10524,6 +10994,9 @@ next_command:; (*idx)++; ret= Xorriso_option_reassure(xorriso, arg1, 0); + } else if(strcmp(cmd,"revoke_exclusions")==0) { + ret= Xorriso_option_revoke_exclusions(xorriso, 0); + } else if(strcmp(cmd,"report_about")==0) { (*idx)++; ret= Xorriso_option_report_about(xorriso, arg1, 0); diff --git a/xorriso/xorriso.h b/xorriso/xorriso.h index 6e7aa83c..34e8f16b 100644 --- a/xorriso/xorriso.h +++ b/xorriso/xorriso.h @@ -344,6 +344,13 @@ int Xorriso_option_mvi(struct XorrisO *xorriso, int argc, char **argv, /* Option -no_rc */ int Xorriso_option_no_rc(struct XorrisO *xorriso, int flag); +/* Option -not_leaf */ +int Xorriso_option_not_leaf(struct XorrisO *xorriso, char *pattern, int flag); + +/* Option -not_paths */ +int Xorriso_option_not_paths(struct XorrisO *xorriso, int argc, char **argv, + int *idx, int flag); + /* Option -options_from_file*/ /* @return <=0 error , 1 = success , 3 = request to end program run */ int Xorriso_option_options_from_file(struct XorrisO *xorriso, char *adr, @@ -390,6 +397,9 @@ int Xorriso_option_pwdi(struct XorrisO *xorriso, int flag); /* Option -pwdx */ int Xorriso_option_pwdx(struct XorrisO *xorriso, int flag); +/* Option -reassure "on"|"tree"|"off" */ +int Xorriso_option_reassure(struct XorrisO *xorriso, char *mode, int flag); + /* Option -report_about */ int Xorriso_option_report_about(struct XorrisO *xorriso, char *severity, int flag); @@ -398,8 +408,8 @@ int Xorriso_option_report_about(struct XorrisO *xorriso, char *severity, int Xorriso_option_return_with(struct XorrisO *xorriso, char *severity, int exit_value, int flag); -/* Option -reassure "on"|"tree"|"off" */ -int Xorriso_option_reassure(struct XorrisO *xorriso, char *mode, int flag); +/* Option -revoke_exclusions */ +int Xorriso_option_revoke_exclusions(struct XorrisO *xorriso, int flag); /* Options -rm alias -rmi , -rm_r alias -rm_ri , -rmdir alias -rmdiri */ /* @param flag bit0=recursive , bit2= remove empty directory: rmdir */ diff --git a/xorriso/xorriso_private.h b/xorriso/xorriso_private.h index ce753b6e..4be95496 100644 --- a/xorriso/xorriso_private.h +++ b/xorriso/xorriso_private.h @@ -46,6 +46,8 @@ typedef int (*Cleanup_app_handler_T)(); struct LinkiteM; +struct ExclusionS; + /* maximum number of history lines to be reported with -status:long_history */ #define Xorriso_status_history_maX 100 @@ -164,6 +166,8 @@ struct XorrisO { /* the global context of xorriso */ int temp_mem_limit; + struct ExclusionS *disk_exclusions; + int use_stdin; /* use raw stdin even if readline support is compiled */ int result_page_length; int result_page_width; @@ -355,6 +359,9 @@ int Xorriso_update_interpreter(struct XorrisO *xorriso, void *boss_iter, int compare_result, char *disk_path, char *iso_rr_path, int flag); +int Xorriso_path_is_excluded(struct XorrisO *xorriso, char *path, int flag); + + int Sfile_str(char target[SfileadrL], char *source, int flag); double Sfile_microtime(int flag); diff --git a/xorriso/xorriso_timestamp.h b/xorriso/xorriso_timestamp.h index f71695d6..267af300 100644 --- a/xorriso/xorriso_timestamp.h +++ b/xorriso/xorriso_timestamp.h @@ -1 +1 @@ -#define Xorriso_timestamP "2008.05.02.072505" +#define Xorriso_timestamP "2008.05.02.204942" diff --git a/xorriso/xorrisoburn.c b/xorriso/xorrisoburn.c index a4e76fe1..ef172fcf 100644 --- a/xorriso/xorrisoburn.c +++ b/xorriso/xorrisoburn.c @@ -1638,7 +1638,12 @@ cannot_open_dir:; {ret= -1; goto ex;} } - /* >>> compare exclusions against disk_path resp. name */; + /* compare exclusions against disk_path resp. name */ + ret= Xorriso_path_is_excluded(xorriso, disk_path, 0); + if(ret<0) + {ret= -1; goto ex;} + if(ret>0) + continue; strcpy(img_name, name); if(Xorriso_much_too_long(xorriso, strlen(img_path), 0)<=0) @@ -1901,9 +1906,11 @@ int Xorriso_graft_in(struct XorrisO *xorriso, void *boss_iter, struct stat stbuf; - /* >>> compare exclusions against disk_path resp. name - but no leaf patter if flag&4 */; - + /* compare exclusions against disk_path resp. name */ + /* >>> ??? why not !(flag&4) ? : "but no leaf patter if flag&4 */; + ret= Xorriso_path_is_excluded(xorriso, disk_path, 0); + if(ret!=0) + return(ret); for(cpt= img_path; 1; cpt++) { cpt= strstr(cpt,"/.");