First code for -setfattr (have to fix some ACL problems before going on)

This commit is contained in:
Thomas Schmitt 2009-02-08 13:21:36 +00:00
parent f4910bc02e
commit 2abedac499
4 changed files with 94 additions and 2 deletions

View File

@ -15654,6 +15654,83 @@ ex:;
} }
/* Options -setfattr alias -setfattri, -setfattr_r alias -setfattr_ri */
/* @param flag bit0=recursive -setfattr_r
*/
int Xorriso_option_setfattri(struct XorrisO *xorriso, char *name, char *value,
int argc, char **argv, int *idx, int flag)
{
int i, ret, was_failure= 0, end_idx, fret, hflag;
int optc= 0;
size_t value_length, num_attrs= 1;
char **optv= NULL, *name_pt;
struct FindjoB *job= NULL;
struct stat dir_stbuf;
ret= Xorriso_opt_args(xorriso, "-setfattr", argc, argv, *idx, &end_idx, &optc,
&optv, 0);
if(ret <= 0)
goto ex;
for(i= 0; i<optc; i++) {
if(flag&1) {
ret= Findjob_new(&job, optv[i], 0);
if(ret<=0) {
Xorriso_no_findjob(xorriso, "-setfattr_r", 0);
{ret= -1; goto ex;}
}
Findjob_set_action_text_2(job, 27, name, value, 0);
ret= Xorriso_findi(xorriso, job, NULL, (off_t) 0,
NULL, optv[i], &dir_stbuf, 0, 0);
Findjob_destroy(&job, 0);
} else {
ret= 1;
value_length= strlen(value);
hflag= 2;
name_pt= name;
if(name[0] == 0) {
sprintf(xorriso->info_text,
"-setfattr: Empty attribute name is not allowed");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
ret= 0; goto ex;
} else if(strcmp(name, "--remove-all") == 0) {
if(value[0]) {
sprintf(xorriso->info_text,
"-setfattr: Value is not empty with pseudo name --remove-all");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
ret= 0; goto ex;
}
num_attrs= 0;
hflag= 0;
} else if(name[0] == '-') {
name_pt++;
hflag|= 4;
} else if(name[0] == '=' || name[0] == '+') {
name_pt++;
}
ret= Xorriso_setfattr(xorriso, NULL, optv[i],
num_attrs, &name_pt, &value_length, &value, hflag);
}
if(ret>0 && !xorriso->request_to_abort)
continue; /* regular bottom of loop */
was_failure= 1;
fret= Xorriso_eval_problem_status(xorriso, ret, 1|2);
if(fret>=0)
continue;
ret= 0; goto ex;
}
ret= 1;
ex:;
(*idx)= end_idx;
Xorriso_opt_args(xorriso, "-setfattr", argc, argv, *idx, &end_idx,
&optc, &optv, 256);
Findjob_destroy(&job, 0);
if(ret<=0)
return(ret);
return(!was_failure);
}
/* Option -speed */ /* Option -speed */
int Xorriso_option_speed(struct XorrisO *xorriso, char *speed, int flag) int Xorriso_option_speed(struct XorrisO *xorriso, char *speed, int flag)
{ {
@ -16190,7 +16267,7 @@ int Xorriso_count_args(struct XorrisO *xorriso, int argc, char **argv,
"lsx","lslx","lsdx","lsdlx","map_l","mv","mvi","mkdir","mkdiri", "lsx","lslx","lsdx","lsdlx","map_l","mv","mvi","mkdir","mkdiri",
"not_paths","rm","rmi","rm_r","rm_ri","rmdir","rmdiri","update_l", "not_paths","rm","rmi","rm_r","rm_ri","rmdir","rmdiri","update_l",
"setfacl","setfacli","setfacl_list","setfacl_listi", "setfacl","setfacli","setfacl_list","setfacl_listi",
"setfacl_r","setfacl_ri", "setfacl_r","setfacl_ri","setfattr","setfattri","setfattr_r","setfattr_ri",
"" ""
}; };
@ -16834,6 +16911,10 @@ next_command:;
(*idx)+= 1; (*idx)+= 1;
ret= Xorriso_option_setfacli(xorriso, arg1, argc, argv, idx, 1); ret= Xorriso_option_setfacli(xorriso, arg1, argc, argv, idx, 1);
} else if(strcmp(cmd,"setfattr")==0 || strcmp(cmd,"setfattri")==0) {
(*idx)+= 2;
ret= Xorriso_option_setfattri(xorriso, arg1, arg2, argc, argv, idx, 0);
} else if(strcmp(cmd,"speed")==0) { } else if(strcmp(cmd,"speed")==0) {
(*idx)++; (*idx)++;
ret= Xorriso_option_speed(xorriso, arg1, 0); ret= Xorriso_option_speed(xorriso, arg1, 0);

View File

@ -680,6 +680,12 @@ int Xorriso_option_setfacl_listi(struct XorrisO *xorriso, char *disk_path,
int Xorriso_option_setfacli(struct XorrisO *xorriso, char *acl_text, int Xorriso_option_setfacli(struct XorrisO *xorriso, char *acl_text,
int argc, char **argv, int *idx, int flag); int argc, char **argv, int *idx, int flag);
/* Options -setfattr alias -setfattri, -setfattr_r alias -setfattr_ri */
/* @param flag bit0=recursive -setfattr_r
*/
int Xorriso_option_setfattri(struct XorrisO *xorriso, char *name, char *value,
int argc, char **argv, int *idx, int flag);
/* Option -speed */ /* Option -speed */
int Xorriso_option_speed(struct XorrisO *xorriso, char *speed, int flag); int Xorriso_option_speed(struct XorrisO *xorriso, char *speed, int flag);

View File

@ -1 +1 @@
#define Xorriso_timestamP "2009.02.07.142605" #define Xorriso_timestamP "2009.02.08.132116"

View File

@ -416,6 +416,11 @@ int Xorriso_set_ignore_aclea(struct XorrisO *xorriso, int flag);
int Xorriso_setfacl(struct XorrisO *xorriso, void *in_node, char *path, int Xorriso_setfacl(struct XorrisO *xorriso, void *in_node, char *path,
char *access_text, char *default_text, int flag); char *access_text, char *default_text, int flag);
int Xorriso_setfattr(struct XorrisO *xorriso, void *in_node, char *path,
size_t num_attrs, char **names,
size_t *value_lengths, char **values, int flag);
/* A pseudo file type for El-Torito bootsectors as in man 2 stat : /* A pseudo file type for El-Torito bootsectors as in man 2 stat :
For now take the highest possible value. For now take the highest possible value.
*/ */