New commands -lfa_flags, -lsattr, -lsattrd, -chattr, -chattr_r, -find test -has_lfa_flags, -find actions lsattrd, chattr
This commit is contained in:
@ -40,7 +40,7 @@
|
||||
|
||||
|
||||
/* @param flag bit0= give directory x-permission where is r-permission
|
||||
bit1= do not transfer ACL or xattr
|
||||
bit1= do not transfer ACL, xattr, file attribute flags
|
||||
bit2= record dev,inode (only if enabled by xorriso)
|
||||
bit3= with bit0: pretend to have indeed a directory
|
||||
bit5= transfer ACL or xattr from eventual link target
|
||||
@ -49,7 +49,8 @@ int Xorriso_transfer_properties(struct XorrisO *xorriso, struct stat *stbuf,
|
||||
char *disk_path, IsoNode *node, int flag)
|
||||
{
|
||||
mode_t mode;
|
||||
int ret= 1;
|
||||
int ret= 1, max_bit, os_errno;
|
||||
uint64_t lfa_flags;
|
||||
size_t num_attrs= 0, *value_lengths= NULL;
|
||||
char **names= NULL, **values= NULL;
|
||||
|
||||
@ -74,7 +75,7 @@ int Xorriso_transfer_properties(struct XorrisO *xorriso, struct stat *stbuf,
|
||||
iso_node_set_mtime(node, stbuf->st_mtime);
|
||||
iso_node_set_ctime(node, stbuf->st_ctime);
|
||||
|
||||
if((xorriso->do_aaip & 5) && !(flag & 2)) {
|
||||
if((xorriso->do_aaip & (1 | 4 | 2048)) && !(flag & 2)) {
|
||||
ret= iso_local_get_attrs(disk_path, &num_attrs, &names, &value_lengths,
|
||||
&values, ((xorriso->do_aaip & 1) && !(flag & 2))
|
||||
| ((!(xorriso->do_aaip & 4)) << 2)
|
||||
@ -97,6 +98,26 @@ int Xorriso_transfer_properties(struct XorrisO *xorriso, struct stat *stbuf,
|
||||
0, "FAILURE", 1);
|
||||
ret= 0; goto ex;
|
||||
}
|
||||
if(xorriso->do_aaip & 2048) {
|
||||
ret= iso_local_get_lfa_flags(disk_path, &lfa_flags, &max_bit, &os_errno,
|
||||
(flag & 32));
|
||||
if(ret < 0) {
|
||||
Xorriso_process_msg_queues(xorriso, 0);
|
||||
Xorriso_report_iso_error(xorriso, disk_path, ret,
|
||||
"Error when obtaining file attribute flags",
|
||||
os_errno, "FAILURE", 1 | 2);
|
||||
ret= 0; goto ex;
|
||||
} else if(ret > 0) {
|
||||
ret= iso_node_set_lfa_flags(node, lfa_flags, 0);
|
||||
if(ret < 0) {
|
||||
Xorriso_process_msg_queues(xorriso, 0);
|
||||
Xorriso_report_iso_error(xorriso, "", ret,
|
||||
"Error when setting file attribute flags to image node",
|
||||
0, "FAILURE", 1);
|
||||
ret= 0; goto ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if((flag & 4) && ((xorriso->do_aaip & 16) || !(xorriso->ino_behavior & 2))) {
|
||||
@ -2679,9 +2700,13 @@ int Xorriso_findi_action(struct XorrisO *xorriso, struct FindjoB *job,
|
||||
struct iso_hfsplus_xinfo_data *hfsplus_xinfo;
|
||||
size_t value_length;
|
||||
char *value;
|
||||
uint64_t lfa_flags, chattr_flags;
|
||||
int max_bit;
|
||||
char *lfa_text= NULL;
|
||||
|
||||
action= Findjob_get_action_parms(job, &target, &text_2, &user, &group,
|
||||
&mode_and, &mode_or, &type, &date, &subjob, 0);
|
||||
&mode_and, &mode_or, &type, &date, &subjob,
|
||||
&chattr_flags, 0);
|
||||
if(action<0)
|
||||
action= 0;
|
||||
job->match_count++;
|
||||
@ -2986,6 +3011,29 @@ int Xorriso_findi_action(struct XorrisO *xorriso, struct FindjoB *job,
|
||||
} else if(action == 59) { /* set_to_mtime */
|
||||
ret= Xorriso_set_to_mtime(xorriso, show_path, node, 0);
|
||||
|
||||
} else if(action == 60) { /* lsattrd */
|
||||
ret= Xorriso_get_lfa_flags(xorriso, node, show_path, &lfa_flags, &max_bit,
|
||||
0);
|
||||
if(ret >= 0) {
|
||||
lfa_text= NULL;
|
||||
ret= Xorriso_encode_lfa_flags(xorriso, lfa_flags, &lfa_text, 1);
|
||||
if(ret > 0) {
|
||||
sprintf(xorriso->result_line, "%-22s ", lfa_text);
|
||||
Xorriso_esc_filepath(xorriso, show_path, xorriso->result_line, 1);
|
||||
strcat(xorriso->result_line, "\n");
|
||||
Xorriso_result(xorriso, 0);
|
||||
}
|
||||
if(lfa_text != NULL)
|
||||
free(lfa_text);
|
||||
ret= 1;
|
||||
} else if(ret == 0) {
|
||||
ret= 1;
|
||||
}
|
||||
|
||||
} else if(action == 61) { /* chattr */
|
||||
ret= Xorriso_set_lfa_flags(xorriso, node, show_path, "",
|
||||
chattr_flags, type, 1);
|
||||
|
||||
} else { /* includes : 15 in_iso */
|
||||
Xorriso_esc_filepath(xorriso, show_path, xorriso->result_line, 0);
|
||||
strcat(xorriso->result_line, "\n");
|
||||
@ -3055,9 +3103,10 @@ return:
|
||||
3 = immediate decision : does match
|
||||
*/
|
||||
{
|
||||
int value=0, ret, bless_idx, size_mode, lba_count, i, mask;
|
||||
int value=0, ret, bless_idx, size_mode, lba_count, i, mask, max_bit;
|
||||
off_t range_lba, end_lba, *file_end_lbas= NULL, *file_start_lbas= NULL;
|
||||
off_t start_lba;
|
||||
uint64_t lfa_flags, node_flags;
|
||||
void *arg1, *arg2;
|
||||
char ft, *decision, md5[16], bless_code[17];
|
||||
regmatch_t name_match;
|
||||
@ -3340,6 +3389,17 @@ return:
|
||||
value= 0;
|
||||
}
|
||||
|
||||
break; case 28: /* -has_lfa_flags uint64_t lfa_flags */
|
||||
lfa_flags= *((uint64_t *) ftest->arg1);
|
||||
ret= Xorriso_get_lfa_flags(xorriso, node, path, &node_flags, &max_bit, 0);
|
||||
if(ret <= 0) {
|
||||
if(ret < 0)
|
||||
Xorriso_process_msg_queues(xorriso, 0);
|
||||
value= 0;
|
||||
goto ex;
|
||||
}
|
||||
value= ((node_flags & lfa_flags) == lfa_flags);
|
||||
|
||||
break; default:
|
||||
|
||||
/* >>> complain about unknown test type */;
|
||||
@ -4614,3 +4674,85 @@ ex:;
|
||||
return(ret);
|
||||
}
|
||||
|
||||
|
||||
int Xorriso_decode_chattr_arg(struct XorrisO *xorriso, char *chattr_text,
|
||||
uint64_t *lfa_flags, int *operator, int flag)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if(chattr_text[0] == '=') {
|
||||
*operator= 0;
|
||||
} else if(chattr_text[0] == '+') {
|
||||
*operator= 1;
|
||||
} else if(chattr_text[0] == '-') {
|
||||
*operator= 2;
|
||||
} else if(chattr_text[0] == '.') {
|
||||
*operator= 3;
|
||||
} else {
|
||||
Xorriso_msgs_submit(xorriso, 0,
|
||||
"-chattr argument does not begin by '=', '+', '-', or '.'",
|
||||
0, "SORRY", 0);
|
||||
return(0);
|
||||
}
|
||||
ret= Xorriso_decode_lfa_flags(xorriso, chattr_text + 1, lfa_flags, 0);
|
||||
if(ret <= 0)
|
||||
return(ret);
|
||||
return(1);
|
||||
}
|
||||
|
||||
|
||||
/* @param in_node if not NULL: the node to manipulate
|
||||
@path if in_node is NULL: path to node
|
||||
in any case: path to report with errors
|
||||
@param operator chattr operation mode 0='=', 1='+', 2='-' , 3='.'
|
||||
@param flag bit0= use lfa_flags and operator rather than chattr_text
|
||||
*/
|
||||
int Xorriso_set_lfa_flags(struct XorrisO *xorriso, void *in_node, char *path,
|
||||
char *chattr_text, uint64_t lfa_flags, int operator,
|
||||
int flag)
|
||||
{
|
||||
int ret, max_bit;
|
||||
uint64_t set_flags;
|
||||
IsoNode *node;
|
||||
|
||||
if(in_node != NULL) {
|
||||
node= (IsoNode *) in_node;
|
||||
} else {
|
||||
ret= Xorriso_get_node_by_path(xorriso, path, NULL, &node, 0);
|
||||
if(ret <= 0)
|
||||
return(ret);
|
||||
}
|
||||
if(!(flag & 1)) {
|
||||
ret= Xorriso_decode_chattr_arg(xorriso, chattr_text, &lfa_flags, &operator,
|
||||
0);
|
||||
if(ret <= 0)
|
||||
return(ret);
|
||||
}
|
||||
if(operator == 0) {
|
||||
set_flags= lfa_flags;
|
||||
} else {
|
||||
ret= Xorriso_get_lfa_flags(xorriso, node, path, &set_flags, &max_bit, 0);
|
||||
if(ret < 0)
|
||||
return(ret);
|
||||
if(operator == 1) {
|
||||
set_flags|= lfa_flags;
|
||||
} else if(operator == 2) {
|
||||
set_flags&= ~lfa_flags;
|
||||
} else if(operator == 3) {
|
||||
set_flags&= lfa_flags;
|
||||
}
|
||||
}
|
||||
|
||||
ret= iso_node_set_lfa_flags(node, set_flags, 0);
|
||||
if(ret < 0) {
|
||||
Xorriso_process_msg_queues(xorriso, 0);
|
||||
Xorriso_report_iso_error(xorriso, path, ret,
|
||||
"Error when setting chattr flags of ISO node",
|
||||
0, "SORRY", 1);
|
||||
return(-1);
|
||||
}
|
||||
Xorriso_set_change_pending(xorriso, 0);
|
||||
return(1);
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user