New find actions get_md5, get_any_xattr, test -has_any_xattr

This commit is contained in:
2009-08-10 12:30:49 +00:00
parent e17765578a
commit 5ddf5f9abf
4 changed files with 90 additions and 13 deletions

View File

@ -7502,7 +7502,7 @@ int Xorriso_findi_action(struct XorrisO *xorriso, struct FindjoB *job,
gid_t group= 0;
time_t date= 0;
mode_t mode_or= 0, mode_and= ~1;
char *target, *text_2, sfe[5*SfileadrL], *iso_prefix;
char *target, *text_2, sfe[5*SfileadrL], *iso_prefix, md5[16];
struct FindjoB *subjob;
struct stat dir_stbuf;
@ -7588,7 +7588,12 @@ int Xorriso_findi_action(struct XorrisO *xorriso, struct FindjoB *job,
iso_prefix, target, 0);
if(ret==2)
deleted= 1;
} else if(action == 33) {
ret= Xorriso_getfattr(xorriso, (void *) node, show_path, NULL, 8);
} else if(action == 34) {
ret= Xorriso_get_md5(xorriso, (void *) node, show_path, md5, 0);
if(ret >= 0)
ret= 1;
} else { /* includes : 15 in_iso */
sprintf(xorriso->result_line, "%s\n", Text_shellsafe(show_path, sfe, 0));
Xorriso_result(xorriso, 0);
@ -7734,7 +7739,9 @@ return:
value= (ret == 1);
break; case 6: /* -has_xattr */
ret = Xorriso_getfattr(xorriso, (void *) node, "", NULL, 64);
case 14: /* -has_any_xattr */
ret = Xorriso_getfattr(xorriso, (void *) node, "", NULL,
64 | (8 * (ftest->test_type == 14)));
if(ret < 0) {
value= -1;
Xorriso_process_msg_queues(xorriso, 0);
@ -10373,6 +10380,7 @@ ok:;
/*
@param flag bit0= do not remove leading slash
bit1= append flatly to result_line and put out
*/
int Xorriso_getfname(struct XorrisO *xorriso, char *path, int flag)
{
@ -10387,7 +10395,12 @@ int Xorriso_getfname(struct XorrisO *xorriso, char *path, int flag)
strlen(path + path_offset), 8);
if(ret <= 0)
return(-1);
sprintf(xorriso->result_line, "# file: %s\n", bsl_path[0] ? bsl_path : ".");
if(flag & 2) {
sprintf(xorriso->result_line + strlen(xorriso->result_line),
"%s\n", bsl_path[0] ? bsl_path : ".");
} else {
sprintf(xorriso->result_line, "# file: %s\n", bsl_path[0] ? bsl_path : ".");
}
free(bsl_path);
bsl_path= NULL;
/* temporarily disable -backslash_codes with result output */
@ -10607,9 +10620,10 @@ ex:;
/*
@param flag bit0= do not report to result but only retrieve attr text
bit1= path is disk_path
bit3= do not ignore eventual non-user attributes.
bit5= in case of symbolic link on disk: inquire link target
bit6= check for existence of user namespaceL xattr,
return 0 or 1
bit6= check for existence of xattr, return 0 or 1
(depends also on bit3)
*/
int Xorriso_getfattr(struct XorrisO *xorriso, void *in_node, char *path,
char **attr_text, int flag)
@ -10621,7 +10635,7 @@ int Xorriso_getfattr(struct XorrisO *xorriso, void *in_node, char *path,
if(attr_text != NULL)
*attr_text= NULL;
ret= Xorriso_get_attrs(xorriso, in_node, path, &num_attrs, &names,
&value_lengths, &values, flag & (2 | 32));
&value_lengths, &values, flag & (2 | 8 | 32));
if(ret <= 0)
goto ex;
if(flag & 64) {
@ -12138,3 +12152,48 @@ ex:;
}
/*
@param flag bit0= do not report to result but only retrieve md5 text
bit6= check for existence of md5, return 0 or 1
*/
int Xorriso_get_md5(struct XorrisO *xorriso, void *in_node, char *path,
char md5[16], int flag)
{
int ret= 1, i;
char *wpt;
IsoImage *image;
IsoNode *node;
ret= Xorriso_get_volume(xorriso, &image, 0);
if(ret <= 0)
goto ex;
node= (IsoNode *) in_node;
if(node == NULL) {
ret= Xorriso_get_node_by_path(xorriso, path, NULL, &node, 0);
if(ret<=0)
goto ex;
}
if(!LIBISO_ISREG(node))
return(0);
ret= iso_file_get_md5(image, (IsoFile *) node, md5, 0);
Xorriso_process_msg_queues(xorriso,0);
if(ret <= 0)
goto ex;
if(flag & 1)
{ret= 1; goto ex;}
wpt= xorriso->result_line;
for(i= 0; i < 16; i++) {
sprintf(wpt, "%2.2x", ((unsigned char *) md5)[i]);
wpt+= 2;
}
strcpy(wpt, " ");
wpt+= 2;
Xorriso_getfname(xorriso, path, 1 | 2);
ret= 1;
ex:;
return(ret);
}