New commands -lfa_flags, -lsattr, -lsattrd, -chattr, -chattr_r, -find test -has_lfa_flags, -find actions lsattrd, chattr
This commit is contained in:
@ -1733,16 +1733,19 @@ int Xorriso_truncate_path_comps(struct XorrisO *xorriso, char *path,
|
||||
bit1= do not print count of nodes
|
||||
bit2= du format
|
||||
bit3= print directories as themselves (ls -d)
|
||||
bit4= lsattr format
|
||||
bit5= do not look for truncated versions of path component
|
||||
*/
|
||||
int Xorriso_ls_filev(struct XorrisO *xorriso, char *wd,
|
||||
int filec, char **filev, off_t boss_mem, int flag)
|
||||
{
|
||||
int i, ret, was_error= 0, dfilec= 0, pass, passes, hidden_state= 0;
|
||||
int is_ls= 0, is_lsl= 0, max_bit;
|
||||
uint64_t lfa_flags;
|
||||
IsoNode *node;
|
||||
IsoImage *volume;
|
||||
char *path= NULL, *link_target= NULL, *rpt, **dfilev= NULL;
|
||||
char *a_text= NULL, *d_text= NULL, *namept;
|
||||
char *a_text= NULL, *d_text= NULL, *namept, *lfa_text= NULL;
|
||||
off_t size;
|
||||
struct stat stbuf;
|
||||
|
||||
@ -1775,7 +1778,10 @@ int Xorriso_ls_filev(struct XorrisO *xorriso, char *wd,
|
||||
}
|
||||
}
|
||||
|
||||
if((flag&8) && !(flag&(2|4))) {
|
||||
is_ls= !(flag & (4 | 16));
|
||||
is_lsl= is_ls && (flag & 1);
|
||||
|
||||
if((flag&8) && !(flag & (2 | 4 | 16))) {
|
||||
sprintf(xorriso->info_text, "Valid ISO nodes found: %d\n", filec-was_error);
|
||||
Xorriso_info(xorriso,1);
|
||||
if(filec-was_error<=0)
|
||||
@ -1814,7 +1820,7 @@ int Xorriso_ls_filev(struct XorrisO *xorriso, char *wd,
|
||||
Xorriso_result(xorriso,0);
|
||||
}
|
||||
Xorriso_ls_filev(xorriso, path,
|
||||
dfilec, dfilev, boss_mem, (flag & 1) | 2 | 8);
|
||||
dfilec, dfilev, boss_mem, (flag & (1 | 16)) | 2 | 8);
|
||||
}
|
||||
if(dfilec>0)
|
||||
Sfile_destroy_argv(&dfilec, &dfilev, 0);
|
||||
@ -1823,7 +1829,7 @@ int Xorriso_ls_filev(struct XorrisO *xorriso, char *wd,
|
||||
if(pass>0)
|
||||
continue;
|
||||
link_target[0]= 0;
|
||||
if((flag&5)==1) { /* -ls_l */
|
||||
if(is_lsl) { /* -ls_l */
|
||||
iso_node_get_acl_text(node, &a_text, &d_text, 16);
|
||||
hidden_state= Xorriso_node_eff_hidden(xorriso, node, 0);
|
||||
ret= Xorriso_format_ls_l(xorriso, &stbuf,
|
||||
@ -1851,9 +1857,35 @@ int Xorriso_ls_filev(struct XorrisO *xorriso, char *wd,
|
||||
sprintf(rpt, "%-7.f ",(double) (size/1024));
|
||||
else
|
||||
sprintf(rpt, "%7.f ",(double) (size/1024));
|
||||
} else if(flag & 16) { /* -lsattr */
|
||||
ret= iso_node_get_lfa_flags(node, &lfa_flags, &max_bit, 0);
|
||||
if(ret < 0) {
|
||||
Xorriso_report_iso_error(xorriso, path, ret,
|
||||
"Error when obtaining lsattr flags of ISO node",
|
||||
0, "WARNING", 1 | 2);
|
||||
{ret= -1; goto ex;}
|
||||
} else if(ret >= 0) {
|
||||
if(ret == 0)
|
||||
lfa_flags= 0;
|
||||
ret= iso_util_encode_lfa_flags(lfa_flags, &lfa_text, 1);
|
||||
if(ret == (int) ISO_LFA_UNKNOWN_BIT) {
|
||||
sprintf(xorriso->info_text,
|
||||
"Cannot convert all flag bits for -lsattr : 0x%lX",
|
||||
(unsigned long) lfa_flags);
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0);
|
||||
} else if(ret < 0) {
|
||||
Xorriso_report_iso_error(xorriso, path, ret,
|
||||
"Error when converting lsattr flags to text",
|
||||
0, "WARNING", 1 | 2);
|
||||
{ret= -1; goto ex;}
|
||||
}
|
||||
sprintf(rpt, "%-22s ", lfa_text);
|
||||
if(lfa_text != NULL)
|
||||
free(lfa_text);
|
||||
}
|
||||
}
|
||||
Xorriso_truncate_path_comps(xorriso, filev[i], path, &namept, 0);
|
||||
if(link_target[0] && (flag&5)==1) {
|
||||
if(link_target[0] && is_lsl) {
|
||||
Xorriso_esc_filepath(xorriso, namept, xorriso->result_line, 1);
|
||||
strcat(xorriso->result_line, " -> ");
|
||||
Xorriso_esc_filepath(xorriso, link_target, xorriso->result_line, 1 | 2);
|
||||
@ -2882,3 +2914,51 @@ int Xorriso_warn_if_not_bootcat(struct XorrisO *xorriso, char *prefix,
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
@param in_node if not NULL and not flag bit1: omit path resolution
|
||||
@param flag bit1= path is disk_path
|
||||
bit5= in case of symbolic link on disk: inquire link target
|
||||
@return <0 = ok , 0= no lfa_flags at node , <0 = libisofs error
|
||||
*/
|
||||
int Xorriso_get_lfa_flags(struct XorrisO *xorriso, void *in_node, char *path,
|
||||
uint64_t *lfa_flags, int *max_bit, int flag)
|
||||
{
|
||||
int ret, os_errno;
|
||||
IsoNode *node;
|
||||
|
||||
*lfa_flags= 0;
|
||||
|
||||
if(flag & 2)
|
||||
goto from_disk;
|
||||
|
||||
node= (IsoNode *) in_node;
|
||||
if(node == NULL) {
|
||||
ret= Xorriso_get_node_by_path(xorriso, path, NULL, &node, 0);
|
||||
if(ret <= 0)
|
||||
return(ret);
|
||||
}
|
||||
ret= iso_node_get_lfa_flags(node, lfa_flags, max_bit, 0);
|
||||
if(ret < 0) {
|
||||
Xorriso_process_msg_queues(xorriso, 0);
|
||||
Xorriso_report_iso_error(xorriso, path, ret,
|
||||
"Error when obtaining lsattr flags of ISO node",
|
||||
0, "WARNING", 1);
|
||||
return(-1);
|
||||
}
|
||||
if(ret == 0)
|
||||
return(0);
|
||||
return(1);
|
||||
|
||||
from_disk:;
|
||||
ret= iso_local_get_lfa_flags(path, lfa_flags, max_bit, &os_errno, flag & 32);
|
||||
if(ret < 0) {
|
||||
Xorriso_process_msg_queues(xorriso, 0);
|
||||
Xorriso_report_iso_error(xorriso, path, ret,
|
||||
"Error when obtaining lsattr flags of disk file",
|
||||
os_errno, "WARNING", 1);
|
||||
return(-1);
|
||||
}
|
||||
return(1);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user