New option -iso_rr_pattern, influencing several options with multiple args

This commit is contained in:
Thomas Schmitt 2007-11-09 19:30:25 +00:00
parent 1ba31e618e
commit 6cc5a50ba4
7 changed files with 387 additions and 128 deletions

View File

@ -198,11 +198,20 @@ characters. Rock Ridge fulfills this demand.
.br
Commands are either actions or settings. They consist of a command word,
followed by zero or more parameter words. If the list of parameter words
is of variable length (indicated by "[...]") then it has to be terminated
by either the word "--" or the end of argument list or an end of an input
line. It is not an error if "--" appears after the parameters of a command
is of variable length (indicated by "[...]" or "[***]") then it has to be
terminated by either the word "--" or the end of argument list or an end of
an input line.
It is not an error if "--" appears after the parameters of a command
with a fixed list length.
.PP
.B Pattern expansion
is a property of some particular commands and not a general
feature. It gets controlled by command -iso_rr_pattern. Commands which
eventually use pattern expansion all have variable argument lists which
are marked in this man page by [***] rather than [...].
.br
Some other commands perform pattern matching unconditionally.
.PP
Command and parameter words are either read from program arguments, where one
argument is one word, or from input lines where words are recognized similar
to the quotation rules of a shell parser.
@ -210,16 +219,16 @@ to the quotation rules of a shell parser.
xorriso is not a shell, although it might appear so on first glimpse.
Be aware that the interaction of quotation marks and pattern symbols like "*"
differs from the usual shell parsers. In xorriso, a quotation mark does not
make a pattern symbol literal. Pattern expansion is a property of some
particular commands and not a general feature.
make a pattern symbol literal.
.PP
When the program begins then it first looks for its startup files and
eventually reads their content as command input lines. Then it interprets
the program arguments as commands and parameters and finally it enters
dialog mode if command -dialog was executed up to then.
.PP
The program ends either by command -end or by the end of program arguments
if not command -dialog was encountered up to that moment.
The program ends either by command -end, or by the end of program arguments
if not command -dialog was encountered up to that moment, or by a problem
event which triggers the threshold of command -abort_on.
.br
.SH OPTIONS
.br
@ -253,21 +262,23 @@ Once set, this command cannot be revoked.
.TP
.B Data manipulations:
.PP
The following commands expect file addresses of two kinds:
.br
.B disk_path
is a path to an object in the local filesystem tree.
.br
.B iso_rr_path
is the Rock Ridge name of a file object in the ISO image. (Do not
confuse with the lowlevel ISO 9660 names visible if Rock Ridge gets ignored.)
.br
The following commands may depend on settings listed further below.
.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
operations. They are intended to be in effect with the read-only mounted image.
.PP
If the iso_rr_path of a newly inserted file leads to an existing
file object in the ISO image, then the following collision handling happens:
file object in the ISO image, then the following
.B collision handling
happens:
.br
If both objects are directories then they get merged by recursively inserting
the subobjects from filesystem into ISO image.
@ -278,6 +289,24 @@ be replaced, not merged.
.PP
The commands in this section alter the ISO image and not the local filesystem.
.TP
\fB\-iso_rr_pattern\fR "on"|"ls"|"off"
Set the pattern expansion mode for the iso_rr_path arguments of several
commands which support this feature.
.br
.B Pattern expansion
converts a list of pattern words into a list of existing file addresses.
Eventual unmatched pattern words appear themselves in that result list, though.
.br
Pattern matching supports the usual shell parser wildcards '*' '?' '[a-z]'
and respects '/' as separator which may only be matched literally.
.br
Setting "off" disables this feature for all commands which are marked in this
man page by "iso_rr_path [***]" or "pattern [***].
Setting "on" enables it for all those commands.
Setting "ls" enables it only for those which are marked by "pattern [***]".
.br
Default is "on".
.TP
\fB\-add\fR path [...]
Insert the given files or directory trees from filesystem
into the ISO image.
@ -295,7 +324,7 @@ into the ISO image.
Use the same rules for generating the ISO addresses as
would be done with shell command cp -r.
.TP
\fB\-rm\fR iso_rr_path [...]
\fB\-rm\fR iso_rr_path [***]
Delete the given files from the ISO image.
.br
Note: This does not free any space on the -indev media, even if
@ -304,23 +333,27 @@ the deletion is committed to that same media.
> The image size will shrink if the image is written to a different
media in modification mode.
.TP
\fB\-rm_r\fR iso_rr_path [...]
\fB\-rm_r\fR iso_rr_path [***]
Delete the given files or directory trees from the ISO image.
See also the note with option -rm.
.TP
\fB\-mv\fR iso_rr_path [...] iso_rr_path
\fB\-mv\fR iso_rr_path [***] iso_rr_path
Rename the given file objects in the ISO tree to the last
argument in the list. Use the same rules as with shell command mv.
.br
If pattern expansion is enabled and if the last argument contains wildcard
characters then it must match exactly one existing file address, or else the
command fails with a SORRY event.
.TP
\fB\-chown\fR uid iso_rr_path [...]
\fB\-chown\fR uid iso_rr_path [***]
Set ownership of file objects in the ISO image. uid may either be a decimal
number or the name of a user known to the operating system.
.TP
\fB\-chgrp\fR gid iso_rr_path [...]
\fB\-chgrp\fR gid iso_rr_path [***]
Set group attribute of file objects in the ISO image. gid may either be a
decimal number or the name of a group known to the operating system.
.TP
\fB\-chmod\fR mode iso_rr_path [...]
\fB\-chmod\fR mode iso_rr_path [***]
Equivalent to shell command chmod in the ISO image.
mode is either an octal number beginning with "0" or a comma separated
list of statements of the form [ugoa]*[+-=][rwxst]* . Like: go-rwx,u+rwx .
@ -337,7 +370,7 @@ r=read, w=write, x=execute|inspect, s=setuid|setgid, t=sticky bit
.br
For octal numbers see man 2 stat.
.TP
\fB\-alter_date\fR type timestring iso_rr_path [...]
\fB\-alter_date\fR type timestring iso_rr_path [***]
Alter the date entries of a file in the ISO image. type is
one of "a", "m", "b" for access time, modification time,
both times.
@ -354,7 +387,8 @@ As produced by program date:
Relative times counted from current clock time:
+|-Number["s"|"h"|"d"|"w"|"m"|"y"]
.br
where "s" means seconds, "h" hours, "d" days, "w" weeks, "m" = 30d, y=365.25d.
where "s" means seconds, "h" hours, "d" days, "w" weeks, "m"=30d,
"y"=365.25d plus 1d added multiplication result.
.br
Absolute seconds counted from Jan 1 1970:
=Number
@ -372,7 +406,7 @@ Create empty directories if they do not exist yet.
Existence as directory generates a WARNING event, existence as
other file cause a SORRY event.
.TP
\fB\-rmdir\fR iso_rr_path [...]
\fB\-rmdir\fR iso_rr_path [***]
Delete empty directories.
.TP
\fB\-\-\fR
@ -457,20 +491,9 @@ SORRY event occured.
.TP
.B Settings for data insertion:
.TP
RockRidge info will be generated by the program unconditionally.
.TP
\fB\-J\fR
Generate Joliet info additional to Rock Ridge info.
.TP
> \fB\-f\fR
Follow symbolic links.
.TP
\fB\-uid\fR uid
User id to be used for all files when inserted into the new ISO tree.
.TP
\fB\-gid\fR gid
Group id for the same purpose.
.TP
\fB\-graft-points\fR
For xorriso action -add this enables pathspecs of the form
.B target=source
@ -478,9 +501,20 @@ like with program mkisofs.
.TP
.B Settings for result writing:
.TP
RockRidge info will be generated by the program unconditionally.
.TP
? \fB\-J\fR
Generate Joliet info additional to Rock Ridge info.
.TP
> \fB\-V\fR volid
Specifies the volume ID.
.TP
\fB\-uid\fR uid
User id to be used for all files when the new ISO tree gets written to media.
.TP
\fB\-gid\fR gid
Group id to be used for all files when the new ISO tree gets written to media.
.TP
\fB\-speed\fR number[k|m|c|d]
Set the burn speed. Default is 0 = maximum speed.
Speed can be given in media dependent numbers or as a
@ -518,7 +552,7 @@ and is one aspect of growisofs -dvd-compat.
.B Exception processing:
.TP
\fB\-abort_on\fR severity
Set the threshhold for events to abort the program.
Set the threshold for events to abort the program.
Events are classified by severity :
"NEVER", "ABORT", "FATAL", "SORRY", "WARNING",
"HINT", "NOTE", "UPDATE", "DEBUG", "ALL"
@ -531,10 +565,10 @@ the setting by this option. Expect not many "ABORT" events to
be ignorable.
.TP
\fB\-report_about\fR severity
Set the threshhold for events to be reported.
Set the threshold for events to be reported.
Events are the same as with -abort_on. Regardless what is
set by -report_about, messages get always reported if they
reach the severity threshhold of -abort_on .
reach the severity threshold of -abort_on .
.br
Event messages are sent to the info channel "I" which is usually stderr
but may be influenced by command -pkt_output.
@ -620,7 +654,7 @@ Tell the current working directory in the ISO image.
\fB\-pwdx\fR
Tell the current working directory on local filesystem.
.TP
\fB\-ls\fR pattern [...]
\fB\-ls\fR pattern [***]
List files from the current working directory in the ISO
image which match shell patterns (i.e. with wildcards '*' '?' '[a-z]').
Note that this resembles rather shell command ls -d than command ls.
@ -629,18 +663,18 @@ Note that this resembles rather shell command ls -d than command ls.
List files from the current working directory on local filesystem
which match shell patterns.
.TP
\fB\-ls_l\fR pattern [...]
\fB\-ls_l\fR pattern [***]
Like -ls but also list some of the file attributes.
Output format resembles shell command ls -ldn.
.TP
> \fB\-ls_lx\fR pattern [...]
Like -lsx but also list some of the file attributes.
.TP
\fB\-du\fR pattern [...]
\fB\-du\fR pattern [***]
Recursively list size of directories and files matching one of the patterns,
similar to shell command du -k.
.TP
\fB\-du_s\fR pattern [...]
\fB\-du_s\fR pattern [***]
List size of directories and files matching one of the patterns,
similar to shell command du -sk.
.TP

View File

@ -1,6 +1,4 @@
/*
( cd .. ; libisoburn-develop/test/compile_xorriso.sh -g )
@ -2245,6 +2243,7 @@ int Xorriso_new(struct XorrisO ** xorriso,char *progname, int flag)
m->dialog= 0;
m->search_mode= 0;
m->structured_search= 1;
m->do_iso_rr_pattern= 1;
m->temp_mem_limit= 16*1024*1024;
m->use_stdin= 0;
m->result_page_length= 0;
@ -2442,7 +2441,7 @@ int Xorriso_request_confirmation(struct XorrisO *xorriso, int flag)
abort_really_text= "done reading";
} else {
abort_req_text= "request to abort";
abort_really_text= "abort";
abort_really_text= "abort this command";
}
ret= Xorriso_dialog_input(xorriso,line,sizeof(line),1);
xorriso->result_line_counter= 0;
@ -2458,7 +2457,7 @@ int Xorriso_request_confirmation(struct XorrisO *xorriso, int flag)
if(flag&1) {
strcpy(previous_line,cpt);
sprintf(xorriso->info_text,
"....... [%s = %s registered. Really %s ? (y/n) ] .......\n",
".... [%s = %s registered. Really %s ? (y/n) ] ....\n",
cpt,abort_req_text,abort_really_text);
Xorriso_info(xorriso,0);
ret= Xorriso_dialog_input(xorriso,line,sizeof(line),1);
@ -3242,6 +3241,11 @@ int Xorriso_status(struct XorrisO *xorriso, char *filter, FILE *fp, int flag)
sprintf(line,"-prog %s\n",Text_shellsafe(xorriso->progname,sfe,0));
Xorriso_status_result(xorriso,filter,fp,flag&2);
if(xorriso->ban_stdio_write) {
sprintf(line,"-ban_stdio_write\n");
Xorriso_status_result(xorriso,filter,fp,flag&2);
}
sprintf(line,"-cd %s\n",
(xorriso->wdi[0] ? Text_shellsafe(xorriso->wdi,sfe,0) : "'/'"));
Xorriso_status_result(xorriso,filter,fp,flag&2);
@ -3249,10 +3253,12 @@ int Xorriso_status(struct XorrisO *xorriso, char *filter, FILE *fp, int flag)
(xorriso->wdx[0] ? Text_shellsafe(xorriso->wdx,sfe,0) : "'/'"));
Xorriso_status_result(xorriso,filter,fp,flag&2);
if(xorriso->ban_stdio_write) {
sprintf(line,"-ban_stdio_write\n");
is_default= (xorriso->do_iso_rr_pattern==1);
sprintf(line,"-iso_rr_pattern %s\n",
(xorriso->do_iso_rr_pattern == 1 ? "on" :
(xorriso->do_iso_rr_pattern == 2 ? "ls" : "off")));
if(!(is_default && no_defaults))
Xorriso_status_result(xorriso,filter,fp,flag&2);
}
is_default= (xorriso->volid[0]==0);
sprintf(line,"-V %s\n",Text_shellsafe(xorriso->volid,sfe,0));
@ -3439,9 +3445,11 @@ ex:
int Xorriso_warn_of_wildcards(struct XorrisO *xorriso, char *path, int flag)
{
if(strchr(path,'*')!=NULL || strchr(path,'?')!=NULL) {
if(strchr(path,'*')!=NULL || strchr(path,'?')!=NULL ||
strchr(path,'[')!=NULL) {
sprintf(xorriso->info_text,
"Xorriso does not support address wildcards '*' and '?'");
"Pattern expansion of wildcards \"*?[\" is disabled%s",
xorriso->do_iso_rr_pattern!=1 ? "command -iso_rr_pattern off" : "");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0);
return(1);
}
@ -3449,7 +3457,7 @@ int Xorriso_warn_of_wildcards(struct XorrisO *xorriso, char *path, int flag)
}
/* @param flag bit0= do not warn of wirldcards
/* @param flag bit0= do not warn of wildcards
*/
int Xorriso_end_idx(struct XorrisO *xorriso,
int argc, char **argv, int idx, int flag)
@ -3466,6 +3474,131 @@ int Xorriso_end_idx(struct XorrisO *xorriso,
}
/* Returns a vector of strings which belong to an open ended arg list.
If expansion is enabled, the vector might be allocated, else it is
a pointer into the argv input vector.
Thus the release of that memory is an expert task to be done by this
function only. Use bit8 for that. Wiith bit8 parameter argc MUST be the
same value as with the call which might have allocated memory.
@param xorriso The environment object
@param argc Length of argv
@param argv The vector with arguments, eventual "--" and then eventual
unrelated words
@param idx Start index in argv of the argument list
@param optc Length of the effective possibly expanded option vector
@param optv The option vector. Maybe a pointer into argv or maybe
an own allocated vector.
@param flag bit0= do not warn of wildcards
bit1= these are disk_paths
bit2= never expand wildcards
bit3= do not expand last argument
bit4= ignore last argument
bit5= demand exactly one match
bit6= with bit allow 0 matches if pattern is a constant
bit8= free the eventually allocated sub_vector
*/
int Xorriso_opt_args(struct XorrisO *xorriso,
int argc, char **argv, int idx,
int *end_idx, int *optc, char ***optv, int flag)
{
int i, do_expand, nump, was_empty= 0, filec= 0, ret;
char **filev= NULL, **patterns= NULL;
off_t mem= 0;
do_expand= xorriso->do_iso_rr_pattern==1 && (!(flag&4)) && (!(flag&2));
if(flag&256) {
if(*optv<argv || *optv>=argv+argc)
Sfile_destroy_argv(optc, optv, 0);
return(1);
}
if(idx>=argc) {
*end_idx= argc;
*optc= 0;
*optv= NULL;
return(-1);
}
*end_idx= Xorriso_end_idx(xorriso, argc, argv, idx, (flag&1) || do_expand);
if(*end_idx<0)
return(*end_idx);
if((flag&16) && (*end_idx)>idx)
(*end_idx)--;
*optc= *end_idx - idx;
*optv= argv+idx;
if(*optc<=0 || !do_expand)
return(1);
patterns= calloc(sizeof(char *), *optc);
if(patterns==NULL) {
no_memory:;
sprintf(xorriso->info_text,
"Cannot allocate enough memory for pattern expansion");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
{ret= -1; goto ex;}
}
nump= 0;
if(flag&8) {
was_empty= 1;
mem+= strlen(argv[idx + *optc - 1])+1+sizeof(char *);
}
for(i= 0; i<*optc-!!(flag&8); i++) {
if(argv[i + idx][0]==0) {
was_empty++;
mem+= sizeof(char *); /* as upper limit for size of an empty string */
continue;
}
patterns[nump++]= argv[i + idx];
}
if(nump<=0) { /* Only empty texts. May the caller get happy with them. */
free(patterns);
return(1);
}
ret= Xorriso_expand_pattern(xorriso, nump, patterns, was_empty,
&filec, &filev, &mem, (flag>>5)&3);
if(ret<=0)
{ret= 0; goto ex;}
for(i= 0; i<was_empty; i++) {
if(i==was_empty-1 && (flag&8))
filev[filec++]= strdup(argv[idx + *optc - 1]);
else
filev[filec++]= strdup("");
if(filev[filec-1]==NULL)
goto no_memory;
}
#ifdef Xorriso_verbous_pattern_expansioN
{ int l;
sprintf(xorriso->info_text, "Pattern expansion yields %d items:", filec);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0);
l= 0;
xorriso->info_text[0]= 0;
for(i= 0; i<filec; i++) {
l= strlen(xorriso->info_text);
if(l>0 && l+1+strlen(filev[i])>60) {
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0);
xorriso->info_text[0]= 0;
l= 0;
}
sprintf(xorriso->info_text+l, " %s", filev[i]);
}
l= strlen(xorriso->info_text);
if(l>0)
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0);
}
#endif /* Xorriso_verbous_pattern_expansioN */
ret= 1;
ex:;
if(ret<=0) {
if(patterns!=NULL)
free((char *) patterns);
Sfile_destroy_argv(&filec, &filev, 0);
} else {
*optc= filec;
*optv= filev;
}
return(ret);
}
int Xorriso_get_problem_status(struct XorrisO *xorriso, char severity[80],
int flag)
{
@ -3716,10 +3849,10 @@ int Xorriso_option_alter_date(struct XorrisO *xorriso,
char *time_type, char *timestring,
int argc, char **argv, int *idx, int flag)
{
int i, end_idx, ret, was_failure= 0, t_type= 0;
int i, ret, was_failure= 0, t_type= 0, end_idx;
time_t t;
end_idx= Xorriso_end_idx(xorriso, argc, argv, *idx, 0);
int optc= 0;
char **optv= NULL;
if(strcmp(time_type, "a")==0)
t_type|= 1;
@ -3740,8 +3873,15 @@ int Xorriso_option_alter_date(struct XorrisO *xorriso,
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
ret= 0; goto ex;
}
for(i= *idx; i<end_idx; i++) {
ret= Xorriso_set_time(xorriso, argv[i], t, t_type);
sprintf(xorriso->info_text, "Understanding timestring '%s' as: %s",
timestring, ctime(&t));
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0);
ret= Xorriso_opt_args(xorriso, argc, argv, *idx, &end_idx, &optc, &optv, 0);
if(ret<=0)
goto ex;
for(i= 0; i<optc; i++) {
ret= Xorriso_set_time(xorriso, optv[i], t, t_type);
if(ret<0)
goto ex;
if(ret==0)
@ -3750,6 +3890,7 @@ int Xorriso_option_alter_date(struct XorrisO *xorriso,
ret= 1;
ex:;
(*idx)= end_idx;
Xorriso_opt_args(xorriso, argc, argv, *idx, &end_idx, &optc, &optv, 256);
if(ret<=0)
return(ret);
return(!was_failure);
@ -3948,17 +4089,19 @@ int Xorriso_option_cdx(struct XorrisO *xorriso, char *disk_path, int flag)
int Xorriso_option_chgrpi(struct XorrisO *xorriso, char *gid,
int argc, char **argv, int *idx, int flag)
{
int i, end_idx, ret, was_failure= 0;
int i, ret, was_failure= 0, end_idx;
gid_t gid_number;
end_idx= Xorriso_end_idx(xorriso, argc, argv, *idx, 0);
int optc= 0;
char **optv= NULL;
ret= Xorriso_convert_gidstring(xorriso, gid, &gid_number, 0);
if(ret<=0)
goto ex;
for(i= *idx; i<end_idx; i++) {
ret= Xorriso_set_gid(xorriso, argv[i], gid_number, 0);
ret= Xorriso_opt_args(xorriso, argc, argv, *idx, &end_idx, &optc, &optv, 0);
if(ret<=0)
goto ex;
for(i= 0; i<optc; i++) {
ret= Xorriso_set_gid(xorriso, optv[i], gid_number, 0);
if(ret<0)
goto ex;
if(ret==0)
@ -3967,6 +4110,7 @@ int Xorriso_option_chgrpi(struct XorrisO *xorriso, char *gid,
ret= 1;
ex:;
(*idx)= end_idx;
Xorriso_opt_args(xorriso, argc, argv, *idx, &end_idx, &optc, &optv, 256); /* clean up */
if(ret<=0)
return(ret);
return(!was_failure);
@ -3977,12 +4121,12 @@ ex:;
int Xorriso_option_chmodi(struct XorrisO *xorriso, char *mode,
int argc, char **argv, int *idx, int flag)
{
int i, end_idx, ret, who_val= 0, was_failure= 0;
int i, ret, who_val= 0, was_failure= 0, end_idx;
unsigned int num;
mode_t mode_and= ~0, mode_or= 0, mode_val, mask;
char sfe[5*SfileadrL], *mpt, *opt, *vpt;
end_idx= Xorriso_end_idx(xorriso, argc, argv, *idx, 0);
int optc= 0;
char **optv= NULL;
if(mode[0]=='0') {
mode_and= 0;
@ -4070,9 +4214,11 @@ unrecognizable:;
ret= 0; goto ex;
}
ret= 1;
for(i= *idx; i<end_idx; i++) {
ret= Xorriso_set_st_mode(xorriso, argv[i], mode_and, mode_or, 0);
ret= Xorriso_opt_args(xorriso, argc, argv, *idx, &end_idx, &optc, &optv, 0);
if(ret<=0)
goto ex;
for(i= 0; i<optc; i++) {
ret= Xorriso_set_st_mode(xorriso, optv[i], mode_and, mode_or, 0);
if(ret<0)
break;
if(ret==0)
@ -4081,6 +4227,7 @@ unrecognizable:;
ret= 1;
ex:;
(*idx)= end_idx;
Xorriso_opt_args(xorriso, argc, argv, *idx, &end_idx, &optc, &optv, 256); /* clean up */
if(ret<=0)
return(ret);
return(!was_failure);
@ -4091,17 +4238,19 @@ ex:;
int Xorriso_option_chowni(struct XorrisO *xorriso, char *uid,
int argc, char **argv, int *idx, int flag)
{
int i, end_idx, ret, was_failure= 0;
int i, ret, was_failure= 0, end_idx;
uid_t uid_number;
end_idx= Xorriso_end_idx(xorriso, argc, argv, *idx, 0);
int optc= 0;
char **optv= NULL;
ret= Xorriso_convert_uidstring(xorriso, uid, &uid_number, 0);
if(ret<=0)
goto ex;
for(i= *idx; i<end_idx; i++) {
ret= Xorriso_set_uid(xorriso, argv[i], uid_number, 0);
ret= Xorriso_opt_args(xorriso, argc, argv, *idx, &end_idx, &optc, &optv, 0);
if(ret<=0)
goto ex;
for(i= 0; i<optc; i++) {
ret= Xorriso_set_uid(xorriso, optv[i], uid_number, 0);
if(ret<0)
goto ex;
if(ret==0)
@ -4110,6 +4259,7 @@ int Xorriso_option_chowni(struct XorrisO *xorriso, char *uid,
ret= 1;
ex:;
(*idx)= end_idx;
Xorriso_opt_args(xorriso, argc, argv, *idx, &end_idx, &optc, &optv, 256); /* clean up */
if(ret<=0)
return(ret);
return(!was_failure);
@ -4335,6 +4485,24 @@ int Xorriso_option_end(struct XorrisO *xorriso, int flag)
}
/* Option -iso_rr_pattern "on"|"ls"|"off" */
int Xorriso_option_iso_rr_pattern(struct XorrisO *xorriso, char *mode,int flag)
{
if(strcmp(mode, "off")==0)
xorriso->do_iso_rr_pattern= 0;
else if(strcmp(mode, "on")==0)
xorriso->do_iso_rr_pattern= 1;
else if(strcmp(mode, "ls")==0)
xorriso->do_iso_rr_pattern= 2;
else {
sprintf(xorriso->info_text, "-iso_rr_pattern: unknown mode '%s'", mode);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
return(0);
}
return(1);
}
/* Option -f */
int Xorriso_option_f(struct XorrisO *xorriso, int flag)
{
@ -4472,6 +4640,8 @@ int Xorriso_option_help(struct XorrisO *xorriso, int flag)
"if they are followed by another option. In dialog and with options read from",
"files, the line end serves as such a mark. With program arguments this mark",
"can be omitted only with the last option in the list of arguments.",
"Options marked by [***] have variable argument length and perform pattern",
"expansion if enabled by -iso_rr_pattern.",
"",
" -add pathspec [...] Insert the given files or directory trees from",
" filesystem into the ISO image. Much like mkisofs.",
@ -4482,34 +4652,34 @@ int Xorriso_option_help(struct XorrisO *xorriso, int flag)
"> -cp_r disk_path [...] iso_rr_path",
" Insert the given files or directory trees from filesystem",
" into the ISO image.",
" -rm iso_rr_path [...]",
" -rm iso_rr_path [***]",
" Delete the given files from the ISO image.",
" -rm_r iso_rr_path [...]",
" -rm_r iso_rr_path [***]",
" Delete the given directory trees from ISO image.",
" -mv iso_rr_path [...] iso_rr_path",
" Rename the given file objects in the ISO tree to the last",
" argument in the list.",
"> -chown uid iso_rr_path [...]",
" -chown uid iso_rr_path [***]",
" Equivalent to chown in the ISO image.",
"> -chgrp gid iso_rr_path [...]",
" -chgrp gid iso_rr_path [***]",
" Equivalent to chgrp in the ISO image.",
"> -chmod mode iso_rr_path [...]",
" -chmod mode iso_rr_path [***]",
" Equivalent to chmod in the ISO image.",
"> -alter_date type timestring iso_rr_path [...]",
" -alter_date type timestring iso_rr_path [***]",
" Alter the date entries of a file in the ISO image. type is",
" one of \"a\", \"m\", \"b\" for:",
" access time, modification time, both times.",
" -mkdir iso_rr_path [...]",
" Create empty directories if they do not exist yet",
" -rmdir iso_rr_path [...]",
" -rmdir iso_rr_path [***]",
" Delete empty directories.",
" -- Mark end of particular action argument list.",
"",
"> -f Follow symbolic links within disk_path.",
"",
" -overwrite \"on\"|\"off\"",
" -overwrite \"on\"|\"nondir\"|\"off\"",
" Allow or disallow to overwrite existing files in ISO image.",
" -reassure \"on\"|\"off\"",
" -reassure \"on\"|\"tree\"|\"off\"",
" If \"on\" then ask the user for \"y\" or \"n\" with any",
" file before deleting or overwriting it in the ISO image.",
"",
@ -4547,22 +4717,26 @@ int Xorriso_option_help(struct XorrisO *xorriso, int flag)
" -pwdi same as -pwd.",
" -pwdx tells the current working directory in the local filesystem.",
"",
" -ls pattern [...] lists files of the ISO image which match one of the",
" -iso_rr_pattern \"on\"|\"ls\"|\"off\"",
" Enable or disable pattern expansions for commands marked",
" by [***]. \"ls\" restricts it to -ls and -du.",
"",
" -ls pattern [***] lists files of the ISO image which match one of the",
" given shell parser patterns. (I.e. wildcards '*' '?')",
" -lsi pattern [...] same as -ls.",
" -lsi pattern [***] same as -ls.",
"> -lsx pattern [...] lists files of the local filesystem which match one",
" of the patterns.",
"",
" -ls_l pattern [...] like -ls but also telling some file attributes.",
" -ls_li pattern [...] same as -ls_l.",
" -ls_l pattern [***] like -ls but also telling some file attributes.",
" -ls_li pattern [***] same as -ls_l.",
"> -ls_lx pattern [...] like -lsx but also telling some file attributes.",
"",
" -du pattern [...] recursively lists sizes of files or directories which",
" -du pattern [***] recursively lists sizes of files or directories which",
" match one of the shell parser patterns.",
" -dui pattern [...] same as -du.",
" -du_s pattern [...] like -du but summing up subdirectories without",
" -dui pattern [***] same as -du.",
" -du_s pattern [***] like -du but summing up subdirectories without",
" listing them explicitely.",
" -dui pattern [...] same as -du_s.",
" -du_si pattern [***] same as -du_s.",
"",
"> -find pattern lists matching files below current working directory in",
" the ISO image.",
@ -4702,6 +4876,8 @@ int Xorriso_option_lsi(struct XorrisO *xorriso, int argc, char **argv,
off_t mem= 0;
end_idx= Xorriso_end_idx(xorriso, argc, argv, *idx, 1);
if(xorriso->do_iso_rr_pattern==0)
flag|= 2;
nump= end_idx - *idx;
if(flag&2) {
@ -4735,7 +4911,7 @@ no_memory:;
/* save temporary memory by calling simpler function */
ret= Xorriso_ls(xorriso, (flag&1)|4);
} else {
ret= Xorriso_expand_pattern(xorriso, nump, patterns, &filec, &filev,
ret= Xorriso_expand_pattern(xorriso, nump, patterns, 0, &filec, &filev,
&mem, 0);
if(ret<=0)
{ret= 0; goto ex;}
@ -4849,42 +5025,59 @@ int Xorriso_option_mvi(struct XorrisO *xorriso, int argc, char **argv,
char sfe[5*SfileadrL], sfe2[5*SfileadrL];
char eff_origin[SfileadrL], eff_dest[SfileadrL];
char dest_dir[SfileadrL], *leafname;
int optc= 0,destc= 0;
char **optv= NULL, **destv= NULL;
end_idx= Xorriso_end_idx(xorriso, argc, argv, *idx, 0);
end_idx= Xorriso_end_idx(xorriso, argc, argv, *idx,
xorriso->do_iso_rr_pattern==1);
if(end_idx - *idx < 2) {
sprintf(xorriso->info_text, "-mvi: not enough arguments");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
{ret= 0; goto ex;}
}
#ifdef NIX
optc= end_idx - *idx;
optv= argv + *idx;
#else
ret= Xorriso_opt_args(xorriso, argc, argv, *idx, &end_idx, &optc, &optv,
16); /* ignore last argument */
if(ret<=0)
goto ex;
ret= Xorriso_opt_args(xorriso, argc, argv, end_idx, &end_idx, &destc, &destv,
32|64); /* demand one match, or 0 with a constant */
if(ret<=0)
goto ex;
#endif /* ! NIX */
/* Check existence of old addresses */
for(i= *idx; i<end_idx-1; i++) {
ret= Xorriso_normalize_img_path(xorriso, argv[i], eff_origin, 0);
for(i= 0; i<optc; i++) {
ret= Xorriso_normalize_img_path(xorriso, optv[i], eff_origin, 0);
if(ret<=0)
{ret= 0; goto ex;}
}
/* Evaluate target address */
ret= Xorriso_normalize_img_path(xorriso, argv[end_idx-1], eff_dest, 1);
ret= Xorriso_normalize_img_path(xorriso, destv[0], eff_dest, 1);
if(ret<0)
{ret= 0; goto ex;}
if(ret==2) {
is_dir= 1;
strcpy(dest_dir, eff_dest);
} else if(end_idx - *idx > 2) {
} else if(optc > 2) {
sprintf(xorriso->info_text,
"-mvi: more than one origin given, destination is a non-directory: %s",
Text_shellsafe(argv[end_idx-1], sfe, 0));
Text_shellsafe(destv[0], sfe, 0));
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
{ret= 0; goto ex;}
}
if(ret==0) { /* compute complete eff_dest */
ret= Xorriso_normalize_img_path(xorriso, argv[end_idx-1], eff_dest, 2);
ret= Xorriso_normalize_img_path(xorriso, destv[0], eff_dest, 2);
if(ret<0)
{ret= 0; goto ex;}
}
/* Perform movements */
for(i= *idx; i<end_idx-1; i++) {
ret= Xorriso_normalize_img_path(xorriso, argv[i], eff_origin, 0);
for(i= 0; i<optc; i++) {
ret= Xorriso_normalize_img_path(xorriso, optv[i], eff_origin, 0);
if(ret<=0)
{ret= 0; goto ex;}
if(is_dir) {
@ -4916,6 +5109,8 @@ int Xorriso_option_mvi(struct XorrisO *xorriso, int argc, char **argv,
ret= !was_failure;
ex:;
(*idx)= end_idx;
Xorriso_opt_args(xorriso, argc, argv, *idx, &end_idx, &optc, &optv, 256);
Xorriso_opt_args(xorriso, argc, argv, *idx, &end_idx, &destc, &destv, 256);
return(ret);
}
@ -5241,13 +5436,16 @@ int Xorriso_option_report_about(struct XorrisO *xorriso, char *severity,
int Xorriso_option_rmi(struct XorrisO *xorriso, int argc, char **argv,
int *idx, int flag)
{
int i, end_idx, ret;
int i, ret, end_idx;
char path[SfileadrL], eff_path[SfileadrL];
int optc= 0;
char **optv= NULL;
end_idx= Xorriso_end_idx(xorriso, argc, argv, *idx, 0);
for(i= *idx; i<end_idx; i++) {
if(Sfile_str(path,argv[i],0)<=0)
ret= Xorriso_opt_args(xorriso, argc, argv, *idx, &end_idx, &optc, &optv, 0);
if(ret<=0)
goto ex;
for(i= 0; i<optc; i++) {
if(Sfile_str(path,optv[i],0)<=0)
{ret= -1; goto ex;}
if(path[0]!='/') {
ret= Sfile_prepend_path(xorriso->wdi, path, 0);
@ -5271,28 +5469,11 @@ int Xorriso_option_rmi(struct XorrisO *xorriso, int argc, char **argv,
ret= 1;
ex:;
(*idx)= end_idx;
Xorriso_opt_args(xorriso, argc, argv, *idx, &end_idx, &optc, &optv, 256);
return(ret);
}
/* Option -rmdir alias -rmdiri */
int Xorriso_option_rmdiri(struct XorrisO *xorriso, int argc, char **argv,
int *idx, int flag)
{
int i, end_idx;
end_idx= Xorriso_end_idx(xorriso, argc, argv, *idx, 0);
fprintf(stderr, ">>> LIBISOFS : -rmdiri ");
for(i= *idx; i<end_idx; i++)
fprintf(stderr, "%s ", argv[i]);
fprintf(stderr, "\n");
(*idx)= end_idx;
return(1);
}
/* Option -rollback */
int Xorriso_option_rollback(struct XorrisO *xorriso, int flag)
{
@ -5635,6 +5816,10 @@ next_command:;
return(ret);
{ret= 3; goto ex;}
} else if(strcmp(cmd,"-iso_rr_pattern")==0) {
(*idx)++;
ret= Xorriso_option_iso_rr_pattern(xorriso, arg1, 0);
} else if(strcmp(cmd,"-f")==0) {
ret= Xorriso_option_f(xorriso, 0);

View File

@ -190,6 +190,10 @@ int Xorriso_option_eject(struct XorrisO *xorriso, char *which, int flag);
/* Option -end */
int Xorriso_option_end(struct XorrisO *xorriso, int flag);
/* Option -iso_rr_pattern "on"|"ls"|"off" */
int Xorriso_option_iso_rr_pattern(struct XorrisO *xorriso, char *mode,
int flag);
/* Option -f */
int Xorriso_option_f(struct XorrisO *xorriso, int flag);

View File

@ -113,6 +113,7 @@ struct XorrisO { /* the global context of xorriso */
3= (eventually structured) shell parser expression
4= shell parser expression for leaf name
*/
int structured_search;
/* 0= flat text search
1= '/' is a significant separator that cannot be matched by wildcards
@ -121,6 +122,8 @@ struct XorrisO { /* the global context of xorriso */
4= actually not structured but unique find mode (with search_mode 4)
*/
int do_iso_rr_pattern; /* 0=off, 1=on, 2=ls */
int temp_mem_limit;
int use_stdin; /* use raw stdin even if readline support is compiled */

View File

@ -1 +1 @@
#define Xorriso_timestamP "2007.11.08.161215"
#define Xorriso_timestamP "2007.11.09.193142"

View File

@ -1874,6 +1874,7 @@ much_too_long:;
if(node==NULL)
continue;
size= iso_tree_node_get_size(node);
rpt[0]= 0;
if((flag&5)==1) { /* -ls_l */
if(LIBISO_ISDIR(node))
@ -1897,7 +1898,6 @@ much_too_long:;
(unsigned long) iso_tree_node_get_uid(node));
sprintf(rpt+strlen(rpt), "%-8lu ",
(unsigned long) iso_tree_node_get_gid(node));
size= iso_tree_node_get_size(node);
sprintf(rpt+strlen(rpt), "%8.f ",(double) size);
mtime= iso_tree_node_get_mtime(node);
tmpt= localtime_r(&mtime, &tms);
@ -2321,11 +2321,15 @@ out_of_memory:;
}
/* @param flag bit0= a match count !=1 is a SORRY event
bit1= with bit0 tolerate 0 matches if pattern is a constant
*/
int Xorriso_expand_pattern(struct XorrisO *xorriso,
int num_patterns, char **patterns,
int num_patterns, char **patterns, int extra_filec,
int *filec, char ***filev, off_t *mem, int flag)
{
int ret, count= 0, abs_adr= 0, i, l, was_count, was_filec;
int ret, count= 0, abs_adr= 0, i, l, was_count, was_filec, k;
int nonconst_mismatches= 0;
char mem_text[80], limit_text[80], sfe[5*SfileadrL];
struct iso_volume *volume;
struct iso_tree_node_dir *dir, *root_dir;
@ -2368,7 +2372,7 @@ cannot_compile:;
dir= root_dir;
abs_adr= 4;
} else {
/* This is done so late ito allow the following:
/* This is done so late to allow the following:
It is not an error if xorriso->wdi does not exist yet, but one may
not use it as base for relative address searches.
*/
@ -2396,8 +2400,19 @@ cannot_compile:;
1 | abs_adr);
if(ret<=0)
goto ex;
if(was_count==count && strcmp(patterns[i],"*")!=0) {
if(was_count==count && strcmp(patterns[i],"*")!=0 && (flag&3)!=1) {
count++;
/* Is this a constant pattern ? */
for(k= 0; k<xorriso->re_fill; k++) {
if(xorriso->re_constants[k]==NULL)
break;
if(xorriso->re_constants[k][0]==0)
break;
}
if(k<xorriso->re_fill)
nonconst_mismatches++; /* it is not */
l= strlen(patterns[i])+1;
(*mem)+= sizeof(char *)+l;
if(l % sizeof(char *))
@ -2405,13 +2420,30 @@ cannot_compile:;
}
}
if((flag&1) && (count!=1 || nonconst_mismatches)){
if(count-nonconst_mismatches>0)
sprintf(xorriso->info_text,
"Pattern match with more than one file object");
else
sprintf(xorriso->info_text, "No pattern match with any file object");
if(num_patterns==1)
sprintf(xorriso->info_text+strlen(xorriso->info_text), ": %s",
Text_shellsafe(patterns[0], sfe, 0));
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
ret= 0; goto ex;
}
count+= extra_filec;
mem+= extra_filec*sizeof(char *);
if(count<=0)
{ret= 0; goto ex;}
Sfile_scale((double) *mem, mem_text,5,1e4,0);
sprintf(xorriso->info_text,
"Temporary memory needed for pattern expansion : %s", mem_text);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0);
if(!(flag&1))
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0);
if(*mem > xorriso->temp_mem_limit) {
Sfile_scale((double) xorriso->temp_mem_limit, limit_text,5,1e4,1);
sprintf(xorriso->info_text,

View File

@ -91,8 +91,9 @@ int Xorriso_rename(struct XorrisO *xorriso, char *origin, char *dest,int flag);
*/
int Xorriso_mkdir(struct XorrisO *xorriso, char *img_path, int flag);
/* @param flag bit0= a match count !=1 is a SORRY event */
int Xorriso_expand_pattern(struct XorrisO *xorriso,
int num_patterns, char **patterns,
int num_patterns, char **patterns, int extra_filec,
int *filec, char ***filev, off_t *mem, int flag);
int Xorriso_set_st_mode(struct XorrisO *xorriso, char *path,