Commit 784f8f76 authored by Thomas Schmitt's avatar Thomas Schmitt

New -find test -bad_outname, new -find action print_outname

parent 61244da0
......@@ -864,8 +864,8 @@ int Findjob_set_damage_filter(struct FindjoB *o, int value, int flag)
}
int Findjob_set_lba_range(struct FindjoB *o, int start_lba, int count,
int flag)
int Findjob_set_num_filter(struct FindjoB *o, int test_type,
int num1, int num2, int flag)
{
struct ExprtesT *t;
int ret;
......@@ -875,17 +875,28 @@ int Findjob_set_lba_range(struct FindjoB *o, int start_lba, int count,
return(ret);
t= o->cursor->test;
t->test_type= 4;
t->test_type= test_type;
t->arg1= calloc(sizeof(int), 1);
t->arg2= calloc(sizeof(int), 1);
if(t->arg1 == NULL || t->arg2 == NULL)
return(-1);
*((int *) t->arg1)= start_lba;
*((int *) t->arg1)= num1;
*((int *) t->arg2)= num2;
return(1);
}
int Findjob_set_lba_range(struct FindjoB *o, int start_lba, int count,
int flag)
{
int ret, end_lba;
if(start_lba > 0)
*((int *) t->arg2)= start_lba + count - 1;
end_lba= start_lba + count - 1;
else
*((int *) t->arg2)= start_lba - count + 1;
return(1);
end_lba= start_lba - count + 1;
ret= Findjob_set_num_filter(o, 4, start_lba, end_lba, 0);
return(ret);
}
......
......@@ -49,6 +49,7 @@ struct ExprtesT {
18= -has_hfs_crtp char *creator char *type
19= -has_hfs_bless int bless_index
20= -disk_path char *arg1
21= -bad_outname int namespace
*/
int test_type;
......@@ -167,6 +168,7 @@ struct FindjoB {
47= set_hfs_bless blessing
48= get_hfs_bless
49= internal: update creator, type, and blessings from persistent isofs.*
50= print_outname namespace
*/
int action;
int prune;
......@@ -218,6 +220,9 @@ int Findjob_get_start_path(struct FindjoB *o, char **start_path, int flag);
int Findjob_set_commit_filter_2(struct FindjoB *o, int flag);
int Findjob_set_num_filter(struct FindjoB *o, int test_type,
int num1, int num2, int flag);
int Findjob_set_lba_range(struct FindjoB *o, int start_lba, int count,
int flag);
......
......@@ -34,6 +34,7 @@
#include "iso_manip.h"
#include "sort_cmp.h"
#include "parse_exec.h"
#include "write_run.h"
......@@ -2309,6 +2310,91 @@ int Xorriso_estimate_file_size(struct XorrisO *xorriso, struct FindjoB *job,
}
/* @param flag bit0= do not compare but print input and back converted name
*/
int Xorriso_test_outchar(struct XorrisO *xorriso, void *node_pt,
int name_space, int flag)
{
IsoNode *node;
char *result= NULL, *name, *back= NULL;
int ret, relax_mem;
size_t result_len, back_len, i;
struct isoburn_imgen_opts *sopts= NULL;
relax_mem= xorriso->relax_compliance;
node= (IsoNode *) node_pt;
ret= isoburn_igopt_new(&sopts, 0);
if(ret<=0) {
Xorriso_process_msg_queues(xorriso, 0);
ret= -1; goto ex;
}
if(!(flag & 1))
xorriso->relax_compliance|= isoburn_igopt_omit_version_numbers;
ret= Xorriso_make_iso_write_opts(xorriso, NULL, sopts, 0);
if(ret <= 0) {
ret= -1; goto ex;
}
if(iso_node_get_type(node) == LIBISO_DIR)
name_space |= 256;
name_space|= 512; /* no error messages */
name= (char *) iso_node_get_name(node);
if(name == NULL) {
ret= 1; goto ex;
}
ret= isoburn_conv_name_chars(sopts, name, strlen(name), &result, &result_len,
name_space);
if(ret <= 0) {
Xorriso_process_msg_queues(xorriso, 0);
if(flag & 1)
goto print_outname;
ret= 0; goto ex;
}
/* Convert back and compare with original */
ret= isoburn_conv_name_chars(sopts, result, result_len, &back, &back_len,
name_space | (1 << 15));
if(ret <= 0) {
Xorriso_process_msg_queues(xorriso, 0);
if(flag & 1)
goto print_outname;
ret= 0; goto ex;
}
if(flag & 1) {
print_outname:;
Text_shellsafe(name, xorriso->result_line, 0);
strcat(xorriso->result_line, "\n");
Xorriso_result(xorriso, 0);
if(back == NULL)
strcpy(xorriso->result_line, "(file name conversion error)");
else
Text_shellsafe(back, xorriso->result_line, 0);
strcat(xorriso->result_line, "\n");
Xorriso_result(xorriso, 0);
strcpy(xorriso->result_line, "--\n");
Xorriso_result(xorriso, 0);
} else {
for(i= 0; i < back_len; i++)
if(name[i] != back[i])
{ret= 0; goto ex;}
if(name[i] != 0)
{ret= 0; goto ex;}
}
ret= 1;
ex:;
isoburn_igopt_destroy(&sopts, 0);
if(result != NULL)
free(result);
if(back != NULL)
free(back);
xorriso->relax_compliance= relax_mem;
return(ret);
}
int Xorriso_cannot_create_iter(struct XorrisO *xorriso, int iso_error,int flag)
{
Xorriso_process_msg_queues(xorriso,0);
......@@ -2676,6 +2762,11 @@ int Xorriso_findi_action(struct XorrisO *xorriso, struct FindjoB *job,
}
ret= 1;
} else if(action == 50) {
ret= Xorriso_test_outchar(xorriso, (void *) node, type, 1);
if(ret <= 0)
return(ret);
} else { /* includes : 15 in_iso */
Xorriso_esc_filepath(xorriso, show_path, xorriso->result_line, 0);
strcat(xorriso->result_line, "\n");
......@@ -2956,6 +3047,14 @@ return:
break; case 20: /* -disk_path */
value= !! Exprtest_match_disk_name(xorriso, ftest, node, 1);
break; case 21: /* -bad_outname */
ret= Xorriso_test_outchar(xorriso, node, *((int *) arg1), 0);
if(ret < 0) {
value= -1;
goto ex;
}
value= !ret; /* Xorriso_test_outchar() returns 1 for good and 0 for bad */
break; default:
/* >>> complain about unknown test type */;
......
......@@ -660,6 +660,23 @@ ex:;
}
static int Xorriso_determine_name_space(struct XorrisO *xorriso,
char *space_name, int flag)
{
if(strcmp(space_name, "rockridge") == 0)
return(1);
else if(strcmp(space_name, "joliet") == 0)
return(2);
else if(strcmp(space_name, "ecma119") == 0 ||
strcmp(space_name, "iso9660") == 0)
return(3);
else if(strcmp(space_name, "hfsplus") == 0)
return(4);
sprintf(xorriso->info_text, "-find: Unknown output namespace identifier");
return(0);
}
/* Option -find alias -findi, and -findx */
/* @param flag bit0= -findx rather than -findi
bit1= do not reset pacifier, no final pacifier message
......@@ -673,7 +690,7 @@ int Xorriso_option_find(struct XorrisO *xorriso, int argc, char **argv,
int *idx, int flag)
{
int ret, i, end_idx, type= 0, action, deleter= 0, start_lba, count;
int list_extattr_head= 0, bsl_mem, disk_path;
int list_extattr_head= 0, bsl_mem, disk_path, name_space;
struct FindjoB *job, *first_job= NULL, *new_job;
char *start_path, *path= NULL, *cpt, *other_path_start= NULL, *cd_pt;
char *access_acl_text= NULL, *default_acl_text= NULL, *list_extattr_mode;
......@@ -831,6 +848,19 @@ not_enough_arguments:;
sprintf(xorriso->info_text, "-findi: cannot setup -has_hfs_bless test");
goto sorry_ex;
}
} else if(strcmp(argv[i], "-bad_outname")==0) {
if(i + 1 >= end_idx)
goto not_enough_arguments;
i+= 1;
name_space= Xorriso_determine_name_space(xorriso, argv[i], 0);
if(name_space < 0) {
ret= 0; goto sorry_ex;
}
ret= Findjob_set_num_filter(job, 21, name_space, 0, 0);
if(ret <= 0) {
sprintf(xorriso->info_text, "-findi: cannot setup -bad_outname test");
goto sorry_ex;
}
} else if(strcmp(argv[i], "-true") == 0) {
ret= Findjob_set_false(job, -1, 0);
} else if(strcmp(argv[i], "-false") == 0) {
......@@ -1139,6 +1169,16 @@ not_enough_exec_arguments:;
Findjob_set_action_target(job, 47, argv[i], 0);
} else if(strcmp(cpt, "get_hfs_bless")==0) {
Findjob_set_action_target(job, 48, NULL, 0);
} else if(strcmp(cpt, "print_outname")==0) {
if(i+1>=end_idx)
goto not_enough_exec_arguments;
i++;
name_space= Xorriso_determine_name_space(xorriso, argv[i], 0);
if(name_space < 0) {
ret= 0; goto sorry_ex;
}
Findjob_set_action_type(job, 50, name_space, 0);
} else {
sprintf(xorriso->info_text, "-find -exec: unknown action ");
Text_shellsafe(argv[i], xorriso->info_text, 1);
......@@ -1802,7 +1842,7 @@ int Xorriso_option_help(struct XorrisO *xorriso, int flag)
" -type b|c|d|p|f|l|s|e, -pending_data, -hidden,",
" -lba_range start count, -damaged, -has_acl, -has_xattr,",
" -has_aaip, -has_filter, -has_md5, -has_any_xattr,",
" -has_hfs_crtp, -has_hfs_bless,",
" -has_hfs_crtp, -has_hfs_bless, -bad_outname,",
" -prune, -decision yes|no, -true, -false",
" Operators: -not, -or, -and, -sub, (, -subend, ),",
" -if, -then, -elseif, -else, -endif",
......@@ -1812,7 +1852,8 @@ int Xorriso_option_help(struct XorrisO *xorriso, int flag)
" getfacl, setfacl, getfattr, setfattr, get_any_xattr,",
" list_extattr, get_md5, check_md5, make_md5,",
" set_hfs_crtp, get_hfs_crtp, set_hfs_bless, get_hfs_bless,",
" set_filter, show_stream, mkisofs_r, hide, find.",
" set_filter, show_stream, mkisofs_r, hide, print_outname,",
" estimate_size, find",
" params are their parameters except iso_rr_path.",
" -mkdir iso_rr_path [...]",
" Create empty directories if they do not exist yet.",
......
This diff is collapsed.
......@@ -48,6 +48,9 @@ int Xorriso_pacifier_loop(struct XorrisO *xorriso, struct burn_drive *drive,
int Xorriso_set_isolinux_options(struct XorrisO *xorriso,
IsoImage *image, int flag);
int Xorriso_make_iso_write_opts(struct XorrisO *xorriso, IsoImage *image,
struct isoburn_imgen_opts *sopts, int flag);
#endif /* ! Xorriso_pvt_write_run_includeD */
......@@ -9,7 +9,7 @@
.\" First parameter, NAME, should be all caps
.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
.\" other parameters are allowed: see man(7), man(1)
.TH XORRISO 1 "Version 1.3.5, Dec 16, 2013"
.TH XORRISO 1 "Version 1.3.5, Dec 28, 2013"
.\" Please adjust this date whenever revising the manpage.
.\"
.\" Some roff macros, for reference:
......@@ -1039,7 +1039,7 @@ is the Rock Ridge name of a file object in the ISO image.
If no Rock Ridge information is recorded in the loaded ISO image, then you
will see ISO 9660 names which are of limited length and character set.
If no Rock Ridge information shall be stored in an emerging ISO image, then
their names will get mapped to such restricted ISO 9660 names.
their names will get mapped to such restricted ISO 9660 (aka ECMA\-119) names.
.PP
Note that in the ISO image you are as powerful as the superuser. Access
permissions of the existing files in the image do not apply to your write
......@@ -1793,6 +1793,22 @@ in "hfsplus" tree, in all trees ("on"), or not hidden in any tree ("off").
.br
Those which are hidden in some tree match \-not \-hidden "off".
.br
\fB\-bad_outname\fR namespace :
Matches files with names which change when converted forth and back
between the local character set and one of the namespaces "rockridge",
"joliet", "ecma119", "hfsplus".
.br
All applicable \-compliance rules are taken into respect.
Rule "omit_version" is always enabled, because else
namespaces "joliet" and "ecma119" would cause changes with every
non\-directory name.
Consider to also enable rules "no_force_dots" resp. "no_j_force_dots".
.br
The namespaces use different character sets and apply further restrictions
to name length, permissible characters, and mandatory name components.
"rockridge" uses the character set defined by \-out_charset,
"joliet" uses UCS\-2BE, "ecma119" uses ASCII, "hfsplus" uses UTF\-16BE.
.br
\fB\-prune\fR :
If this test is reached and the tested file is a directory then \-find will not
dive into that directory. This test itself does always match.
......@@ -2056,6 +2072,20 @@ E.g.:
.br
\-find / \-disk_name *_secret \-exec hide on
.br
\fBprint_outname\fR
prints in the first line the filename as registered by the program model,
and in the second line the filename after conversion forth and back between
local character set and one of the namespaces "rockridge", "joliet", "ecma119",
or "hfsplus". The third output line is "\-\-" .
.br
The name conversion does not take into respect the possibility of name
collisions in the target namespace. Such collisions are most likely in "joliet"
and "ecma119", where they get resolved by automatic file name changes.
.br
E.g.:
.br
\-find / \-bad_outname joliet \-exec print_outname joliet
.br
\fBestimate_size\fR
prints a lower and an upper estimation of the number of blocks which the
found files together will occupy in the emerging ISO image.
......
This diff is collapsed.
......@@ -50,7 +50,7 @@
@c man .\" First parameter, NAME, should be all caps
@c man .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
@c man .\" other parameters are allowed: see man(7), man(1)
@c man .TH XORRISO 1 "Version 1.3.5, Dec 16, 2013"
@c man .TH XORRISO 1 "Version 1.3.5, Dec 28, 2013"
@c man .\" Please adjust this date whenever revising the manpage.
@c man .\"
@c man .\" Some roff macros, for reference:
......@@ -1299,7 +1299,7 @@ is the Rock Ridge name of a file object in the ISO image.
If no Rock Ridge information is recorded in the loaded ISO image, then you
will see ISO 9660 names which are of limited length and character set.
If no Rock Ridge information shall be stored in an emerging ISO image, then
their names will get mapped to such restricted ISO 9660 names.
their names will get mapped to such restricted ISO 9660 (aka ECMA-119) names.
@c man .PP
@sp 1
Note that in the ISO image you are as powerful as the superuser. Access
......@@ -2174,6 +2174,22 @@ in "hfsplus" tree, in all trees ("on"), or not hidden in any tree ("off").
@*
Those which are hidden in some tree match -not -hidden "off".
@*
@item -bad_outname namespace :
Matches files with names which change when converted forth and back
between the local character set and one of the namespaces "rockridge",
"joliet", "ecma119", "hfsplus".
@*
All applicable -compliance rules are taken into respect.
Rule "omit_version" is always enabled, because else
namespaces "joliet" and "ecma119" would cause changes with every
non-directory name.
Consider to also enable rules "no_force_dots" resp. "no_j_force_dots".
@*
The namespaces use different character sets and apply further restrictions
to name length, permissible characters, and mandatory name components.
"rockridge" uses the character set defined by -out_charset,
"joliet" uses UCS-2BE, "ecma119" uses ASCII, "hfsplus" uses UTF-16BE.
@*
@item -prune :
If this test is reached and the tested file is a directory then -find will not
dive into that directory. This test itself does always match.
......@@ -2455,6 +2471,20 @@ E.g.:
@*
-find / -disk_name *_secret -exec hide on
@*
@item print_outname
prints in the first line the filename as registered by the program model,
and in the second line the filename after conversion forth and back between
local character set and one of the namespaces "rockridge", "joliet", "ecma119",
or "hfsplus". The third output line is "--" .
@*
The name conversion does not take into respect the possibility of name
collisions in the target namespace. Such collisions are most likely in "joliet"
and "ecma119", where they get resolved by automatic file name changes.
@*
E.g.:
@*
-find / -bad_outname joliet -exec print_outname joliet
@*
@item estimate_size
prints a lower and an upper estimation of the number of blocks which the
found files together will occupy in the emerging ISO image.
......
#define Xorriso_timestamP "2013.12.28.194725"
#define Xorriso_timestamP "2013.12.29.120027"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment