New -find and -findx action list_extattr

This commit is contained in:
2011-08-25 19:00:46 +00:00
parent dc83e4dcf3
commit 8c98fb039d
10 changed files with 350 additions and 55 deletions

View File

@ -650,9 +650,10 @@ int Xorriso_option_find(struct XorrisO *xorriso, int argc, char **argv,
int *idx, int flag)
{
int ret, i, end_idx, type= 0, action, deleter= 0, start_lba, count;
int list_extattr_head= 0, bsl_mem;
struct FindjoB *job, *first_job= NULL, *new_job;
char *start_path, *path= NULL, *cpt, *other_path_start= NULL;
char *access_acl_text= NULL, *default_acl_text= NULL;
char *start_path, *path= NULL, *cpt, *other_path_start= NULL, *cd_pt;
char *access_acl_text= NULL, *default_acl_text= NULL, *list_extattr_mode;
struct stat dir_stbuf;
uid_t user= 0;
@ -666,6 +667,7 @@ int Xorriso_option_find(struct XorrisO *xorriso, int argc, char **argv,
Xorriso_alloc_meM(other_path_start, char, SfileadrL);
start_path= ".";
list_extattr_mode= "e";
if(end_idx > *idx && start_path[0]!=0)
start_path= argv[*idx];
ret= Findjob_new(&first_job, start_path, 0);
@ -1050,6 +1052,13 @@ not_enough_exec_arguments:;
} else if(strcmp(cpt, "clear_merge")==0) {
Findjob_set_action_target(job, 43, NULL, 0);
xorriso->update_flags&= ~1; /* End update_merge mode for node adding */
} else if(strcmp(cpt, "list_extattr")==0) {
if(i+1>=end_idx)
goto not_enough_exec_arguments;
i++;
Findjob_set_action_target(job, 44, argv[i], 0);
list_extattr_head= 1;
list_extattr_mode= argv[i];
} else {
sprintf(xorriso->info_text, "-find -exec: unknown action ");
Text_shellsafe(argv[i], xorriso->info_text, 1);
@ -1063,6 +1072,33 @@ sorry_ex:;
{ret= 0; goto ex;}
}
}
if(list_extattr_head) {
sprintf(xorriso->result_line,
"# Output of xorriso %s action list_extattr\n",
(flag & 1) ? "-findx" : "-find");
Xorriso_result(xorriso, 0);
strcpy(xorriso->result_line, "cd ");
if(start_path[0] == '/')
strcat(xorriso->result_line, "/");
else {
cd_pt= (flag & 1) ? xorriso->wdx : xorriso->wdi;
if(cd_pt[0] == 0)
cd_pt= "/";
ret= Xorriso_append_extattr_comp(xorriso, cd_pt, strlen(cd_pt),
list_extattr_mode, 0);
if(ret <= 0)
goto ex;
}
strcat(xorriso->result_line, "\n");
/* temporarily disable -backslash_codes with result output */
bsl_mem= xorriso->bsl_interpretation;
xorriso->bsl_interpretation= 0;
Xorriso_result(xorriso, 0);
xorriso->bsl_interpretation= bsl_mem;
sprintf(xorriso->result_line, "c=\"setextattr\"\n\n");
Xorriso_result(xorriso, 0);
}
if(flag&1)
ret= Xorriso_findx(xorriso, first_job, "", start_path, &dir_stbuf, 0, NULL,
0);
@ -1647,8 +1683,8 @@ int Xorriso_option_help(struct XorrisO *xorriso, int flag)
" chmod, chmod_r, alter_date, alter_date_r, lsdl, compare,",
" rm, rm_r, compare, update, report_damage, report_lba,",
" getfacl, setfacl, getfattr, setfattr, get_any_xattr,",
" get_md5, check_md5, make_md5, set_filter, show_stream,",
" mkisofs_r, hide, find.",
" list_extattr, get_md5, check_md5, make_md5,",
" set_filter, show_stream, mkisofs_r, hide, find.",
" params are their arguments except iso_rr_path.",
" -mkdir iso_rr_path [...]",
" Create empty directories if they do not exist yet.",