New find tests -has_acl, -has_no_acl, new action getfacl, new option getfacl_r

This commit is contained in:
2009-01-23 14:08:31 +00:00
parent 41619c2763
commit e7036f90dc
6 changed files with 101 additions and 23 deletions

View File

@ -2308,6 +2308,7 @@ struct FindjoB {
int end_lba;
int damage_filter; /* -1=only undamaged , 0=all , 1=only damaged */
int commit_filter; /* bit0= test -pending_data : uncommitted regular files */
int acl_filter; /* -1=only without ACL , 0=all , 1=only with ACL */
void *wanted_node; /* if not NULL, then only this node address matches */
@ -2335,6 +2336,7 @@ struct FindjoB {
21= report_damage
22= report_lba
23= internal:memorize path of last matching node in found_path
24= getfacl
*/
int action;
char *target;
@ -2362,6 +2364,7 @@ int Findjob_new(struct FindjoB **o, char *start_path, int flag)
m->end_lba= -1;
m->damage_filter= 0;
m->commit_filter= 0;
m->acl_filter= 0;
m->wanted_node= NULL;
m->action= 0; /* print */
m->target= NULL; /* a mere pointer, not managed memory */
@ -2504,6 +2507,27 @@ int Findjob_get_commit_filter(struct FindjoB *o, int *commit_filter, int flag)
}
/* @param value -1= files without ACL, 0= all files, 1= only files with ACL
*/
int Findjob_set_acl_filter(struct FindjoB *o, int value, int flag)
{
if(value < 0)
o->acl_filter= -1;
else if(value > 0)
o->acl_filter= 1;
else
o->acl_filter= 0;
return(1);
}
int Findjob_get_acl_filter(struct FindjoB *o, int *acl_filter, int flag)
{
*acl_filter= o->acl_filter;
return(1);
}
int Findjob_set_wanted_node(struct FindjoB *o, void *wanted_node, int flag)
{
o->wanted_node= wanted_node;
@ -12742,6 +12766,10 @@ not_enough_arguments:;
Findjob_set_lba_range(job, start_lba, count, 0);
} else if(strcmp(argv[i], "-pending_data")==0) {
Findjob_set_commit_filter(job, 1, 1, 0);
} else if(strcmp(argv[i], "-has_acl")==0) {
Findjob_set_acl_filter(job, 1, 0);
} else if(strcmp(argv[i], "-has_no_acl")==0) {
Findjob_set_acl_filter(job, -1, 0);
} else if(strcmp(argv[i], "-exec")==0) {
if(i+1>=end_idx)
goto not_enough_arguments;
@ -12882,6 +12910,8 @@ not_enough_arguments:;
Findjob_set_action_target(job, 21, NULL, 0);
} else if(strcmp(cpt, "report_lba")==0) {
Findjob_set_action_target(job, 22, NULL, 0);
} else if(strcmp(cpt, "getfacl")==0) {
Findjob_set_action_target(job, 24, NULL, 0);
} else {
sprintf(xorriso->info_text, "-find -exec: unknown action %s",
Text_shellsafe(argv[i], sfe, 0));
@ -13008,8 +13038,8 @@ int Xorriso_option_fs(struct XorrisO *xorriso, char *size, int flag)
}
/* Option -getfacl */
/* @param flag >>> ??? bit0=recursive (-getfacl_r)
/* Option -getfacl , -getfacl_r */
/* @param flag bit0=recursive -getfacl_r
*/
int Xorriso_option_getfacl(struct XorrisO *xorriso,
int argc, char **argv, int *idx, int flag)
@ -13018,6 +13048,7 @@ int Xorriso_option_getfacl(struct XorrisO *xorriso,
int optc= 0;
char **optv= NULL;
struct FindjoB *job= NULL;
struct stat dir_stbuf;
ret= Xorriso_opt_args(xorriso, "-getfacl", argc, argv, *idx, &end_idx, &optc,
&optv, 0);
@ -13025,11 +13056,17 @@ int Xorriso_option_getfacl(struct XorrisO *xorriso,
goto ex;
for(i= 0; i<optc; i++) {
if(flag&1) {
/* >>> set up findjob and run it */;
ret= Findjob_new(&job, optv[i], 0);
if(ret<=0) {
Xorriso_no_findjob(xorriso, "-getfacl_r", 0);
{ret= -1; goto ex;}
}
Findjob_set_action_target(job, 24, NULL, 0);
ret= Xorriso_findi(xorriso, job, NULL, (off_t) 0,
NULL, optv[i], &dir_stbuf, 0, 0);
Findjob_destroy(&job, 0);
} else {
ret= Xorriso_getfacl(xorriso, optv[i], NULL, 0);
ret= Xorriso_getfacl(xorriso, NULL, optv[i], NULL, 0);
}
if(ret>0 && !xorriso->request_to_abort)
continue; /* regular bottom of loop */
@ -13356,7 +13393,8 @@ int Xorriso_option_help(struct XorrisO *xorriso, int flag)
" -lsdx pattern [***] like -lsx but listing directories as single items.",
" -lslx pattern [***] like -lsx but also telling some file attributes.",
" -lsdlx pattern [***] like -lsdx but also telling some file attributes.",
" -getfacl pattern [***] list eventual ACLs of the given files.",
" -getfacl pattern [***] list eventual ACLs of the given files.",
" -getfacl_r pattern [***] like -getfacl but listing whole file trees.",
"",
" -du pattern [***] recursively lists sizes of files or directories in the",
" ISO image which match one of the shell parser patterns.",
@ -15642,7 +15680,7 @@ int Xorriso_count_args(struct XorrisO *xorriso, int argc, char **argv,
"compare_l","cpr","cpri","cp_rax","cp_rx","cpax","cpx",
"du","dui","dus","dusi","dux","dusx","extract_l",
"file_size_limit","find","findi","findx",
"getfacl","getfacli",
"getfacl","getfacli","getfacl_r","getfacl_ri",
"ls","lsi","lsl","lsli","lsd","lsdi","lsdl","lsdli",
"lsx","lslx","lsdx","lsdlx","map_l","mv","mvi","mkdir","mkdiri",
"not_paths","rm","rmi","rm_r","rm_ri","rmdir","rmdiri","update_l",
@ -15994,6 +16032,9 @@ next_command:;
} else if(strcmp(cmd,"getfacl")==0 || strcmp(cmd,"getfacli")==0) {
ret= Xorriso_option_getfacl(xorriso, argc, argv, idx, 0);
} else if(strcmp(cmd,"getfacl_r")==0 || strcmp(cmd,"getfacl_ri")==0) {
ret= Xorriso_option_getfacl(xorriso, argc, argv, idx, 1);
} else if(strcmp(cmd,"gid")==0) {
(*idx)++;
ret= Xorriso_option_gid(xorriso,arg1,0);