New options -setfattr, -setfattr_r, new find -exec setfattr
This commit is contained in:
parent
fdabb16ad4
commit
f4e0f103da
@ -8430,7 +8430,7 @@ int Xorriso_lsx_filev(struct XorrisO *xorriso, char *wd,
|
||||
link_target[0]= 0;
|
||||
rpt[0]= 0;
|
||||
if((flag&5)==1) {
|
||||
ret= Xorriso_local_getfacl(xorriso, path, &acl_text, 16);
|
||||
Xorriso_local_getfacl(xorriso, path, &acl_text, 16);
|
||||
ret= Xorriso_format_ls_l(xorriso, &stbuf, (acl_text != NULL) << 1);
|
||||
Xorriso_local_getfacl(xorriso, path, &acl_text, 1 << 15);
|
||||
if(ret<=0)
|
||||
@ -11025,6 +11025,46 @@ int Xorriso_perform_acl_from_list(struct XorrisO *xorriso, char *file_path,
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
@param flag bit0= do not perform setfattr but only check input
|
||||
*/
|
||||
int Xorriso_path_setfattr(struct XorrisO *xorriso, void *in_node, char *path,
|
||||
char *name, size_t value_length, char *value, int flag)
|
||||
{
|
||||
int ret, hflag;
|
||||
size_t num_attrs= 1;
|
||||
char *name_pt;
|
||||
|
||||
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);
|
||||
return(0);
|
||||
} 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);
|
||||
return(0);
|
||||
}
|
||||
num_attrs= 0;
|
||||
hflag= 0;
|
||||
} else if(name[0] == '-') {
|
||||
name_pt++;
|
||||
hflag|= 4;
|
||||
} else if(name[0] == '=' || name[0] == '+') {
|
||||
name_pt++;
|
||||
}
|
||||
if(flag & 1)
|
||||
return(1);
|
||||
ret= Xorriso_setfattr(xorriso, in_node, path,
|
||||
num_attrs, &name_pt, &value_length, &value, hflag);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
|
||||
/* ---------------------------- Options API ------------------------ */
|
||||
|
||||
|
||||
@ -13231,6 +13271,16 @@ not_enough_arguments:;
|
||||
0);
|
||||
} else if(strcmp(cpt, "getfattr")==0) {
|
||||
Findjob_set_action_target(job, 26, NULL, 0);
|
||||
} else if(strcmp(cpt, "setfattr")==0) {
|
||||
if(i + 2 >= end_idx)
|
||||
goto not_enough_arguments;
|
||||
i+= 2;
|
||||
/* check input */
|
||||
ret= Xorriso_path_setfattr(xorriso, NULL, "", argv[i - 1],
|
||||
strlen(argv[i]), argv[i], 1);
|
||||
if(ret <= 0)
|
||||
goto ex;
|
||||
Findjob_set_action_text_2(job, 27, argv[i - 1], argv[i], 0);
|
||||
} else {
|
||||
sprintf(xorriso->info_text, "-find -exec: unknown action %s",
|
||||
Text_shellsafe(argv[i], sfe, 0));
|
||||
@ -13629,6 +13679,12 @@ int Xorriso_option_help(struct XorrisO *xorriso, int flag)
|
||||
" -setfacl_list disk_path",
|
||||
" Read output of getfacl from file disk_path. Set owner,",
|
||||
" group and ACL of the iso_rr_path given by line \"# file:\".",
|
||||
" -setfattr [-]name value iso_rr_path [***]",
|
||||
" Set xattr pair with the given name to the given value, or",
|
||||
" delete pair if name is prefixed with \"-\" and value is",
|
||||
" an empty text.",
|
||||
" -setfattr_r [-]name value iso_rr_path [***]",
|
||||
" Like -setfattr but affecting all files below directories.",
|
||||
" -alter_date type timestring iso_rr_path [***]",
|
||||
" Alter the date entries of a file in the ISO image. type is",
|
||||
" one of \"a\", \"m\", \"b\" for:",
|
||||
@ -13647,7 +13703,7 @@ int Xorriso_option_help(struct XorrisO *xorriso, int flag)
|
||||
" 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,",
|
||||
" getfacl, setfacl, getfattr, find.",
|
||||
" getfacl, setfacl, getfattr, setfattr, find.",
|
||||
" params are their arguments except iso_rr_path.",
|
||||
" echo, lsdl, rm, rm_r, report_damage have no params at all.",
|
||||
" -mkdir iso_rr_path [...]",
|
||||
@ -15662,10 +15718,9 @@ ex:;
|
||||
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 i, ret, was_failure= 0, end_idx, fret;
|
||||
int optc= 0;
|
||||
size_t value_length, num_attrs= 1;
|
||||
char **optv= NULL, *name_pt;
|
||||
char **optv= NULL;
|
||||
struct FindjoB *job= NULL;
|
||||
struct stat dir_stbuf;
|
||||
|
||||
@ -15673,6 +15728,11 @@ int Xorriso_option_setfattri(struct XorrisO *xorriso, char *name, char *value,
|
||||
&optv, 0);
|
||||
if(ret <= 0)
|
||||
goto ex;
|
||||
|
||||
/* check input */
|
||||
ret= Xorriso_path_setfattr(xorriso, NULL, "", name, strlen(value), value, 1);
|
||||
if(ret <= 0)
|
||||
goto ex;
|
||||
|
||||
for(i= 0; i<optc; i++) {
|
||||
if(flag&1) {
|
||||
@ -15687,31 +15747,8 @@ int Xorriso_option_setfattri(struct XorrisO *xorriso, char *name, char *value,
|
||||
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);
|
||||
ret= Xorriso_path_setfattr(xorriso, NULL, optv[i],
|
||||
name, strlen(value), value, 0);
|
||||
}
|
||||
if(ret>0 && !xorriso->request_to_abort)
|
||||
continue; /* regular bottom of loop */
|
||||
@ -16917,6 +16954,10 @@ next_command:;
|
||||
(*idx)+= 2;
|
||||
ret= Xorriso_option_setfattri(xorriso, arg1, arg2, argc, argv, idx, 0);
|
||||
|
||||
} else if(strcmp(cmd,"setfattr_r")==0 || strcmp(cmd,"setfattr_ri")==0) {
|
||||
(*idx)+= 2;
|
||||
ret= Xorriso_option_setfattri(xorriso, arg1, arg2, argc, argv, idx, 1);
|
||||
|
||||
} else if(strcmp(cmd,"speed")==0) {
|
||||
(*idx)++;
|
||||
ret= Xorriso_option_speed(xorriso, arg1, 0);
|
||||
|
@ -1 +1 @@
|
||||
#define Xorriso_timestamP "2009.02.08.151354"
|
||||
#define Xorriso_timestamP "2009.02.09.185940"
|
||||
|
@ -1885,6 +1885,7 @@ int Xorriso_node_get_dev(struct XorrisO *xorriso, IsoNode *node,
|
||||
/* @param flag bit0= *node is already valid
|
||||
bit1= add extra block for size estimation
|
||||
bit2= complain loudely if path is missing in image
|
||||
bit3= stbuf is to be used without eventual ACL
|
||||
*/
|
||||
int Xorriso_fake_stbuf(struct XorrisO *xorriso, char *path, struct stat *stbuf,
|
||||
IsoNode **node, int flag)
|
||||
@ -1907,7 +1908,10 @@ int Xorriso_fake_stbuf(struct XorrisO *xorriso, char *path, struct stat *stbuf,
|
||||
/* >>> stbuf->st_dev */
|
||||
/* >>> stbuf->st_ino */
|
||||
|
||||
stbuf->st_mode= iso_node_get_permissions(*node) & 07777;
|
||||
if(flag & 8)
|
||||
stbuf->st_mode= iso_node_get_perms_wo_acl(*node) & 07777;
|
||||
else
|
||||
stbuf->st_mode= iso_node_get_permissions(*node) & 07777;
|
||||
if(LIBISO_ISDIR(*node))
|
||||
stbuf->st_mode|= S_IFDIR;
|
||||
else if(LIBISO_ISREG(*node))
|
||||
@ -2927,12 +2931,8 @@ int Xorriso_restore_properties(struct XorrisO *xorriso, char *disk_path,
|
||||
#endif /* Xorriso_with_aaiP */
|
||||
|
||||
if(is_dir && (flag&2)) {
|
||||
|
||||
/* >>> ??? need to stack ACL ? */
|
||||
|
||||
/* >>> ??? eventually obtain stbuf wo ACL */
|
||||
|
||||
ret= Xorriso_fake_stbuf(xorriso, "", &stbuf, &node, 1);
|
||||
ret= Xorriso_fake_stbuf(xorriso, "", &stbuf, &node,
|
||||
1 | ((!!(xorriso->do_aaip & 2)) << 3));
|
||||
if(ret<=0)
|
||||
{ret= 0; goto ex;}
|
||||
ret= Permstack_push(&(xorriso->perm_stack), disk_path, &stbuf, 0);
|
||||
@ -6504,6 +6504,9 @@ int Xorriso_findi_action(struct XorrisO *xorriso, struct FindjoB *job,
|
||||
ret= Xorriso_setfacl(xorriso, (void *) node, show_path, target, text_2,0);
|
||||
} else if(action == 26) {
|
||||
ret= Xorriso_getfattr(xorriso, (void *) node, show_path, 0);
|
||||
} else if(action == 27) {
|
||||
ret= Xorriso_path_setfattr(xorriso, (void *) node, show_path,
|
||||
target, strlen(text_2), text_2, 0);
|
||||
} else { /* includes : 15 in_iso */
|
||||
sprintf(xorriso->result_line, "%s\n", Text_shellsafe(show_path, sfe, 0));
|
||||
Xorriso_result(xorriso, 0);
|
||||
@ -9099,7 +9102,7 @@ ex:;
|
||||
}
|
||||
|
||||
|
||||
/* @param node Opaque handle to IsoNode which is to be manipulated
|
||||
/* @param in_node Opaque handle to IsoNode which is to be manipulated
|
||||
instead of path if it is not NULL.
|
||||
@param path is used as address if node is NULL.
|
||||
@param num_attrs Number of attributes
|
||||
@ -9151,6 +9154,7 @@ ex:;
|
||||
return(ret);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
@param flag
|
||||
Bitfield for control purposes
|
||||
|
Loading…
Reference in New Issue
Block a user