New -find tests -has_filter, -has_no_filter

This commit is contained in:
Thomas Schmitt 2009-04-07 12:02:53 +00:00
parent 7e3b7f3b7f
commit f9db31f5a1
5 changed files with 55 additions and 4 deletions

View File

@ -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 06, 2009"
.TH XORRISO 1 "Apr 07, 2009"
.\" Please adjust this date whenever revising the manpage.
.\"
.\" Some roff macros, for reference:
@ -1247,6 +1247,10 @@ from user namespace.
.br
match files which have ACL or any xattr resp. have neither of them.
.br
-has_filter , -has_no_filter
.br
match files which are filtered by -set_filter resp. are not.
.br
Default action is "echo",
i.e. to print the address of the found file. Other actions are certain

View File

@ -2467,7 +2467,8 @@ struct FindjoB {
int commit_filter; /* bit0= test -pending_data : uncommitted regular files */
int acl_filter; /* -1=only without ACL , 0=all , 1=only with ACL */
int xattr_filter; /* -1=only without xattr , 0=all , 1=only with xattr */
int aaip_filter; /* -1=only without AA string, 0=all , 1=only with AA */
int aaip_filter; /* -1=only without AA string , 0=all , 1=only with AA */
int filter_filter; /* -1=only unfiltered nodes , 0=all , 1=only filtered */
void *wanted_node; /* if not NULL, then only this node address matches */
@ -2500,6 +2501,7 @@ struct FindjoB {
26= getfattr
27= setfattr
28= set_filter name
29= show_stream
*/
int action;
@ -2533,6 +2535,7 @@ int Findjob_new(struct FindjoB **o, char *start_path, int flag)
m->acl_filter= 0;
m->xattr_filter= 0;
m->aaip_filter= 0;
m->filter_filter= 0;
m->wanted_node= NULL;
m->action= 0; /* print */
m->target= NULL; /* a mere pointer, not managed memory */
@ -2742,6 +2745,27 @@ int Findjob_get_aaip_filter(struct FindjoB *o, int *aaip_filter, int flag)
}
/* @param value -1= files without filter, 0= all files, 1= files with filter
*/
int Findjob_set_filter_filter(struct FindjoB *o, int value, int flag)
{
if(value < 0)
o->filter_filter= -1;
else if(value > 0)
o->filter_filter= 1;
else
o->filter_filter= 0;
return(1);
}
int Findjob_get_filter_filter(struct FindjoB *o, int *value, int flag)
{
*value= o->filter_filter;
return(1);
}
int Findjob_set_wanted_node(struct FindjoB *o, void *wanted_node, int flag)
{
o->wanted_node= wanted_node;
@ -13635,6 +13659,10 @@ not_enough_arguments:;
Findjob_set_aaip_filter(job, 1, 0);
} else if(strcmp(argv[i], "-has_no_aaip")==0) {
Findjob_set_aaip_filter(job, -1, 0);
} else if(strcmp(argv[i], "-has_filter")==0) {
Findjob_set_filter_filter(job, 1, 0);
} else if(strcmp(argv[i], "-has_no_filter")==0) {
Findjob_set_filter_filter(job, -1, 0);
} else if(strcmp(argv[i], "-exec")==0) {
if(i+1>=end_idx)
goto not_enough_arguments;
@ -14239,7 +14267,8 @@ int Xorriso_option_help(struct XorrisO *xorriso, int flag)
" processed. Types: block,char,dir,pipe,file,link,socket.",
" Further tests: -damaged, -undamaged, -lba_range start count,",
" -pending_data, -has_acl, -has_no_acl, -has_xattr,",
" -has_no_xattr, -has_aaip, -has_no_aaip.",
" -has_no_xattr, -has_aaip, -has_no_aaip, -has_filter,",
" -has_no_filter.",
" 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,",

View File

@ -794,6 +794,8 @@ int Findjob_get_xattr_filter(struct FindjoB *o, int *xattr_filter, int flag);
int Findjob_get_aaip_filter(struct FindjoB *o, int *aaip_filter, int flag);
int Findjob_get_filter_filter(struct FindjoB *o, int *value, int flag);
int Findjob_set_wanted_node(struct FindjoB *o, void *wanted_node, int flag);
int Findjob_get_wanted_node(struct FindjoB *o, void **wanted_node, int flag);

View File

@ -1 +1 @@
#define Xorriso_timestamP "2009.04.06.161541"
#define Xorriso_timestamP "2009.04.07.120250"

View File

@ -6663,9 +6663,11 @@ int Xorriso_findi_test(struct XorrisO *xorriso, struct FindjoB *job,
int depth, int flag)
{
int ret, start_lba, end_lba, damage_filter, commit_filter, lba, a_filter;
int is_filtered= 0;
off_t damage_start, damage_end, size;
int lba_count, *file_end_lbas= NULL, *file_start_lbas= NULL, i;
void *wanted_node;
IsoStream *stream;
ret= Findjob_test(job, name, boss_stbuf, stbuf, depth, 1);
if(ret<=0)
@ -6749,6 +6751,20 @@ int Xorriso_findi_test(struct XorrisO *xorriso, struct FindjoB *job,
{ret= 0; goto ex;}
}
Findjob_get_filter_filter(job, &a_filter, 0);
if(a_filter) {
is_filtered= 0;
if(LIBISO_ISREG(node)) {
stream= iso_file_get_stream((IsoFile *) node);
if(iso_stream_get_input_stream(stream, 0) != NULL)
is_filtered= 1;;
}
if(a_filter < 0 && is_filtered)
{ret= 0; goto ex;}
if(a_filter > 0 && !is_filtered)
{ret= 0; goto ex;}
}
Findjob_get_wanted_node(job, &wanted_node, 0);
if(wanted_node != NULL && ((IsoNode *) wanted_node) != node)
{ret= 0; goto ex;}