Added new action "compare" to -find

This commit is contained in:
Thomas Schmitt 2008-02-28 13:27:44 +00:00
parent 1aac97caf3
commit 41ea389118
4 changed files with 67 additions and 7 deletions

View File

@ -140,7 +140,7 @@ useful to store intermediate states and to continue with image manipulations.
.B Media types and states:
There are two families of media in the MMC standard:
.br
\fBMulti-session\fR media are CD-R, CD-RW, DVD-R, DVD+R, and
\fBMulti-session\fR media are CD-R, CD-RW, DVD-R, DVD+R, DVD+R/DL, and
unformatted DVD-RW. These media provide a table of content which
describes their existing sessions.
.br
@ -694,6 +694,13 @@ E.g.:
.br
-find / -exec lsdl
.br
"compare" performs command -compare with the found file address as iso_rr_path
and the corresponding file address below its argument disk_path_start. For this
the iso_rr_path of the -find command gets replaced by the disk_path_start.
E.g.:
.br
-find / -exec compare /home/thomas
.br
"find" performs another run of -find on the matching file address. It accepts
the same params as -find, except iso_rr_path.
E.g.:
@ -1251,11 +1258,13 @@ always perform action "echo".
.TP
\fB\-compare\fR disk_path iso_rr_path
Compare attributes and eventual data file content of a fileobject in the
local filesystem with a file object in the ISO image. That iso_rr_path may
well point to a image file object which is not yet committed, i.e. of which
local filesystem with a file object in the ISO image. The iso_rr_path may
well point to an image file object which is not yet committed, i.e. of which
the data content still resides in the local filesystem. Such data content is
prone to externally caused changes.
.br
If iso_rr_path is empty then disk_path is used as path in the ISO image too.
.br
Differing attributes are reported in detail, differing content is summarized.
Both to the result channel. In case of no differences no result lines are
emitted.

View File

@ -2392,6 +2392,7 @@ struct FindjoB {
11= chmod_r mode_and mode_or
12= alter_date_r type date
13= find
14= compare disk_equivalent_of_start_path
*/
int action;
char *target;
@ -2470,6 +2471,13 @@ int Findjob_set_start_path(struct FindjoB *o, char *start_path, int flag)
}
int Findjob_get_start_path(struct FindjoB *o, char **start_path, int flag)
{
*start_path= o->start_path;
return(1);
}
int Findjob_set_name_expr(struct FindjoB *o, char *name_expr, int flag)
{
char regexpr[2*SfileadrL+2];
@ -4339,8 +4347,8 @@ int Xorriso_compare_2_files(struct XorrisO *xorriso, char *disk_adr,
wanted= sizeof(buf2);
/*
#define Libisofs_data_read_as_posiX yes
*/
#define Libisofs_data_read_as_posiX yes
#ifndef Libisofs_data_read_as_posiX
/* This functions guarantees to deliver full buffers but fails on
oversized read requests. */
@ -4423,6 +4431,23 @@ int Xorriso_compare_2_files(struct XorrisO *xorriso, char *disk_adr,
}
int Xorriso_find_compare(struct XorrisO *xorriso, char *iso_path,
char *iso_prefix, char *disk_prefix, int flag)
{
int ret;
char disk_path[SfileadrL], adrc[SfileadrL];
if(strncmp(iso_path, iso_prefix, strlen(iso_prefix))!=0)
return(-1);
if(strlen(disk_prefix)+strlen(iso_path)-strlen(iso_prefix)>=SfileadrL)
return(-1);
strcpy(adrc, iso_path+strlen(iso_prefix));
sprintf(disk_path, "%s%s%s", disk_prefix, (adrc[0]=='/' ? "" : "/"), adrc);
ret= Xorriso_compare_2_files(xorriso, disk_path, iso_path, adrc, 2|(1<<29));
return(ret);
}
/* @param flag bit0= count result rather than storing it
bit1= unexpected change of number is a FATAL event
*/
@ -8098,12 +8123,13 @@ int Xorriso_option_find(struct XorrisO *xorriso, int argc, char **argv,
{
int ret, i, end_idx, type= 0;
struct FindjoB *job, *first_job= NULL, *new_job;
char *start_path, sfe[5*SfileadrL], *cpt;
char *start_path, sfe[5*SfileadrL], *cpt, disk_path_start[SfileadrL];
struct stat dir_stbuf;
uid_t user= 0;
gid_t group= 0;
time_t date= 0;
mode_t mode_or= 0, mode_and= ~1;
double mem_lut= 0.0;
end_idx= Xorriso_end_idx(xorriso, argc, argv, *idx, 1);
start_path= ".";
@ -8216,6 +8242,23 @@ not_enough_arguments:;
}
Findjob_set_action_subjob(job, 13, new_job, 0);
job= new_job;
} else if(strcmp(cpt, "compare")==0) {
if(i+1>=end_idx)
goto not_enough_arguments;
i++;
ret= Xorriso_make_abs_adr(xorriso, xorriso->wdi, argv[i],
disk_path_start, 1|2|4);
if(ret<=0)
goto ex;
Findjob_set_action_target(job, 14, disk_path_start, 0);
ret= Xorriso_make_abs_adr(xorriso, xorriso->wdi, start_path,sfe, 1|2|4);
if(ret<=0)
goto ex;
Findjob_set_start_path(job, sfe, 0);
Xorriso_pacifier_reset(xorriso, 0);
mem_lut= xorriso->last_update_time;
} else {
sprintf(xorriso->info_text, "-find -exec: unknown action %s",
Text_shellsafe(argv[i], sfe, 0));
@ -8244,6 +8287,9 @@ sorry_ex:;
else
ret= Xorriso_findi(xorriso, first_job, NULL, start_path, &dir_stbuf, 0, 0);
ex:;
if(mem_lut!=xorriso->last_update_time && mem_lut!=0.0)
Xorriso_pacifier_callback(xorriso, "content bytes read",
xorriso->pacifier_count, 0, "", 1);
Findjob_destroy(&first_job, 0);
(*idx)= end_idx;
return(ret);

View File

@ -1 +1 @@
#define Xorriso_timestamP "2008.02.27.185744"
#define Xorriso_timestamP "2008.02.28.132656"

View File

@ -3719,7 +3719,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, sfe[5*SfileadrL];
char *target, sfe[5*SfileadrL], *iso_prefix;
struct FindjoB *subjob;
struct stat dir_stbuf;
@ -3751,6 +3751,11 @@ int Xorriso_findi_action(struct XorrisO *xorriso, struct FindjoB *job,
} else if(action>=9 && action<=13) { /* actions which have own findjobs */
Findjob_set_start_path(subjob, abs_path, 0);
ret= Xorriso_findi(xorriso, subjob, NULL, abs_path, &dir_stbuf, depth, 0);
} else if(action==14) { /* compare */
Findjob_get_start_path(job, &iso_prefix, 0);
ret= Xorriso_find_compare(xorriso, abs_path, iso_prefix, target, 0);
if(ret>=0)
ret= 1;
} else {
sprintf(xorriso->result_line, "%s\n", Text_shellsafe(show_path, sfe, 0));
Xorriso_result(xorriso, 0);