Implemented -disk_pattern, -lsx, ls_lx, -dux, -du_lx

master
Thomas Schmitt 15 years ago
parent 05f1080036
commit cbb35d28ef
  1. 100
      test/xorriso.1
  2. 1100
      test/xorriso.c
  3. 13
      test/xorriso.h
  4. 14
      test/xorriso_private.h
  5. 2
      test/xorriso_timestamp.h
  6. 113
      test/xorrisoburn.c

@ -2,7 +2,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 "November 14, 2007"
.TH XORRISO 1 "December 4, 2007"
.\" Please adjust this date whenever revising the manpage.
.\"
.\" Some roff macros, for reference:
@ -244,9 +244,9 @@ 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 "[...]".
feature. It gets controlled by commands -iso_rr_pattern and -disk_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
@ -352,18 +352,44 @@ Pattern matching supports the usual shell parser wildcards '*' '?' '[xyz]'
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 [***]".
man page by "iso_rr_path [***]" or "iso_rr_pattern [***]".
.br
Setting "on" enables it for all those commands.
Setting "ls" enables it only for those which are marked by "pattern [***]".
.br
Setting "ls" enables it only for those which are marked by
"iso_rr_pattern [***]".
.br
Default is "on".
.TP
\fB\-add\fR path [...]
\fB\-disk_pattern\fR "on"|"ls"|"off"
Set the pattern expansion mode for the disk_path arguments of several
commands which support this feature.
.br
Setting "off" disables this feature for all commands which are marked in this
man page by "disk_path [***]" or "disk_pattern [***]".
.br
Setting "on" enables it for all those commands.
.br
Setting "ls" enables it only for those which are marked by
"disk_pattern [***]".
.TP
\fB\-add\fR pathspec [...] | disk_path [***]
Insert the given files or directory trees from filesystem
into the ISO image.
.br
Use the same paths on ISO unless -graft-points is set and
the paths have the form iso_rr_path=disk_path .
If -graft-points is set then pattern expansion is always disabled and
character '=' has a special meaning. It eventually divides the ISO image path
from the disk path: iso_rr_path=disk_path . '=' can be escaped by '\\'.
If iso_rr_path does not begin with '/' then -cd is prepended.
If disk_path does not begin with '/' then -cdx is prepended.
.br
If no '=' is given then the word is used as both, iso_rr_path and disk path.
If in this case the word does not begin with '/' then -cdx is prepended,
not -cd.
.br
If -graft-points-off is set then eventual -disk_pattern expansion applies.
The resulting words are used as both, iso_rr_path and disk path. Eventually
-cdx gets prepended.
.TP
\fB\-path-list\fR disk_path
Like -add but read the pathspecs from file disk_path.
@ -547,7 +573,12 @@ Follow symbolic links.
\fB\-graft-points\fR
For xorriso action -add this enables pathspecs of the form
.B target=source
like with program mkisofs.
like with program mkisofs. It also disables pattern expansion for
command -add.
.TP
\fB\-graft-points-off\fR
For xorriso action -add this disables pathspecs of the form target=source
and eventually enables -disk_pattern expansion for command -add.
.TP
.B Settings for result writing:
.TP
@ -596,8 +627,8 @@ which means unit is kiB (= 1024) or MiB (= 1024 kiB).
If "on" then mark the written media as not appendable
any more (if possible at all with the given type of target media).
.br
This is the contrary of cdrecord, wodim, cdrskin -multi,
and is one aspect of growisofs -dvd-compat.
This is the contrary of cdrecord, wodim, cdrskin option -multi,
and is one aspect of growisofs option -dvd-compat.
.TP
.B Exception processing:
.TP
@ -711,29 +742,43 @@ 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 [***]
List files from the current working directory in the ISO
image which match shell patterns (i.e. with wildcards '*' '?' '[a-z]').
\fB\-ls\fR iso_rr_pattern [***]
List files in the ISO image which match shell patterns (i.e. with wildcards '*'
'?' '[a-z]').
If a pattern does not begin with '/' then it is compared with addresses
relative to -cd, the current working directory in the ISO image.
Note that this resembles rather shell command ls -d than command ls.
.TP
> \fB\-lsx\fR pattern [...]
List files from the current working directory on local filesystem
which match shell patterns.
\fB\-lsx\fR disk_pattern [***]
List files on local filesystem which match shell patterns. Patterns which do
not begin with '/' are used relative to -cdx, the current working directory in
the local filesystem.
.TP
\fB\-ls_l\fR pattern [***]
\fB\-ls_l\fR iso_rr_pattern [***]
Like -ls but also list some of the file attributes.
Output format resembles shell command ls -ldn.
.TP
> \fB\-ls_lx\fR pattern [...]
\fB\-ls_lx\fR disk_pattern [***]
Like -lsx but also list some of the file attributes.
.TP
\fB\-du\fR pattern [***]
Recursively list size of directories and files matching one of the patterns,
\fB\-du\fR iso_rr_pattern [***]
Recursively list size of directories and files in the ISO image
which match one of the patterns.
similar to shell command du -k.
.TP
\fB\-du_s\fR pattern [***]
List size of directories and files matching one of the patterns,
similar to shell command du -sk.
\fB\-dux\fR disk_pattern [***]
Recursively list size of directories and files in the local filesystem
which match one of the patterns, similar to shell command du -k.
.TP
\fB\-du_s\fR iso_rr_pattern [***]
List size of directories and files in the ISO image
which match one of the patterns.
Similar to shell command du -sk.
.TP
\fB\-du_sx\fR disk_pattern [***]
List size of directories and files in the local filesystem
which match one of the patterns.
Similar to shell command du -sk.
.TP
> \fB\-find\fR pattern
Equivalent to shell command find . -name pattern in the ISO image.
@ -864,7 +909,7 @@ with addresses from the hard disk.
.B A dialog session doing about the same
.br
-graft-points is already given as start argument. The other activities
are done as dialog input. The pager gets set to 20 lines of 80 chracters.
are done as dialog input. The pager gets set to 20 lines of 80 characters.
.br
The drive is aquired by option -dev rather than -outdev in order to see
the message about its current content. By option -blank this content is
@ -909,8 +954,7 @@ Load image from drive.
Remove (i.e. hide) directory /sounds and its subordinates.
Rename directory /pictures/confidential to /pictures/restricted.
Change access permissions of directory /pictures/restricted.
Add dummy as replacement of /pictures/confidential.
Add new directory tree /movies. Burn to the same DVD and eject.
Add new directory trees /sounds and /movies. Burn to the same DVD and eject.
.br
\fB$\fR xorriso -dev /dev/sr2 \\
-rm_r /sounds -- \\

File diff suppressed because it is too large Load Diff

@ -185,6 +185,9 @@ int Xorriso_option_devices(struct XorrisO *xorriso, int flag);
/* Option -dialog "on"|"off" */
int Xorriso_option_dialog(struct XorrisO *xorriso, char *mode, int flag);
/* Option -disk_pattern "on"|"ls"|"off" */
int Xorriso_option_disk_pattern(struct XorrisO *xorriso, char *mode, int flag);
/* Option -dummy "on"|"off" */
int Xorriso_option_dummy(struct XorrisO *xorriso, char *mode, int flag);
@ -214,6 +217,7 @@ int Xorriso_option_fs(struct XorrisO *xorriso, char *size, int flag);
int Xorriso_option_gid(struct XorrisO *xorriso, char *gid, int flag);
/* Option -graft-points */
/* @param flag bit0= disable graft points */
int Xorriso_option_graft_points(struct XorrisO *xorriso, int flag);
/* Option -help and part of -prog_help */
@ -238,6 +242,15 @@ int Xorriso_option_lsi(struct XorrisO *xorriso, int argc, char **argv,
int Xorriso_option_logfile(struct XorrisO *xorriso, char *channel,
char *fileadr, int flag);
/* Options -lsx , -ls_lx ,
-dux , -du_sx
@param flag bit0= long format (-ls_lx , -dux)
bit1= do not expand patterns but use literally
bit2= du rather than ls
*/
int Xorriso_option_lsx(struct XorrisO *xorriso, int argc, char **argv,
int *idx, int flag);
/* Option -mark */
int Xorriso_option_mark(struct XorrisO *xorriso, char *mark, int flag);

@ -123,6 +123,7 @@ struct XorrisO { /* the global context of xorriso */
*/
int do_iso_rr_pattern; /* 0=off, 1=on, 2=ls */
int do_disk_pattern; /* 0=off, 1=on, 2=ls */
int temp_mem_limit;
@ -196,6 +197,17 @@ int Xorriso_execute_option(struct XorrisO *xorriso, char *line, int flag);
int Xorriso_regexec(struct XorrisO *xorriso, char *to_match, int *failed_at,
int flag);
int Xorriso_prepare_expansion_pattern(struct XorrisO *xorriso, char *pattern,
int flag);
int Xorriso__mode_to_perms(mode_t st_mode, char perms[10], int flag);
int Xorriso_much_too_long(struct XorrisO *xorriso, int len, int flag);
int Xorriso_check_temp_mem_limit(struct XorrisO *xorriso, off_t mem, int flag);
int Sfile_str(char target[SfileadrL], char *source, int flag);
double Sfile_microtime(int flag);
@ -212,7 +224,7 @@ int Sort_argv(int argc, char **argv, int flag);
struct DirseQ;
int Dirseq_new(struct DirseQ **o, char *dir, int flag);
int Dirseq_new(struct DirseQ **o, char *adr, int flag);
int Dirseq_destroy(struct DirseQ **o, int flag);

@ -1 +1 @@
#define Xorriso_timestamP "2007.11.26.192113"
#define Xorriso_timestamP "2007.12.04.074340"

@ -101,20 +101,6 @@ int Xorriso_startup_libraries(struct XorrisO *xorriso, int flag)
}
/* @param flag bit0=path is in source filesystem , bit1= unconditionally */
int Xorriso_much_too_long(struct XorrisO *xorriso, int len, int flag)
{
if(len>=SfileadrL || (flag&2)) {
sprintf(xorriso->info_text,
"Path given for %s is much too long (%d)",
((flag&1) ? "local filesystem" : "ISO image"), len);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
return(0);
}
return(1);
}
/* @param flag bit1= obtain outdrive, else indrive */
int Xorriso_get_drive_handles(struct XorrisO *xorriso,
struct burn_drive_info **dinfo,
@ -852,6 +838,7 @@ int Xorriso_add_tree(struct XorrisO *xorriso, struct iso_tree_node_dir *dir,
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
ret=0; goto was_problem;
}
xorriso->volset_change_pending= 1;
/* name always equal to disk. Obsolete: iso_tree_node_set_name(node,name);*/
if(source_is_dir) {
ret= Xorriso_add_tree(xorriso, (struct iso_tree_node_dir *) node,
@ -891,8 +878,10 @@ int Xorriso_graft_in(struct XorrisO *xorriso, char *disk_path, char *img_path,
struct stat stbuf;
for(cpt= img_path; 1; cpt++) {
/*
if(cpt[0]!='/')
break;
*/
cpt= strstr(cpt,"/.");
if(cpt==NULL)
break;
@ -943,6 +932,7 @@ int Xorriso_graft_in(struct XorrisO *xorriso, char *disk_path, char *img_path,
"Source '%s' is not a directory. Target '%s' would be.",
disk_path, img_path);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
return(0);
}
}
}
@ -1011,6 +1001,7 @@ handle_path_node:;
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
return(0);
}
xorriso->volset_change_pending= 1;
iso_tree_node_set_ctime((struct iso_tree_node *) dir, time(NULL));
/* >>> copy properties from correspondent directory in disk_path
@ -1048,13 +1039,13 @@ attach_source:;
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
return(0);
}
xorriso->volset_change_pending= 1;
iso_tree_node_set_name(node, apt);
}
} else
*npt= '/';
}
Xorriso_process_msg_queues(xorriso,0);
xorriso->volset_change_pending= 1;
return(1+!!is_dir);
}
@ -1720,26 +1711,15 @@ int Xorriso_sorted_node_array(struct XorrisO *xorriso,
off_t boss_mem, int flag)
{
int i, ret, failed_at;
char *npt, mem_text[80], limit_text[80];
char *npt;
struct iso_tree_iter *iter= NULL;
struct iso_tree_node *node;
off_t mem;
mem= ((*nodec)+1)*sizeof(struct iso_tree_node *);
Sfile_scale((double) mem, mem_text,5,1e4,0);
if(!(flag&2)) {
sprintf(xorriso->info_text,
"Temporary memory needed for result sorting : %s", mem_text);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0);
}
if(mem > xorriso->temp_mem_limit - boss_mem) {
Sfile_scale((double) xorriso->temp_mem_limit - boss_mem,limit_text,5,1e4,1);
sprintf(xorriso->info_text,
"Cannot sort. List of matching files exceeds -temp_mem_limit (%s > %s)",
mem_text, limit_text);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0);
return(0);
}
ret= Xorriso_check_temp_mem_limit(xorriso, mem+boss_mem, flag&2);
if(ret<=0)
return(ret);
*node_array= calloc(sizeof(struct iso_tree_node *), (*nodec)+1);
if(*node_array==NULL) {
@ -1839,7 +1819,7 @@ much_too_long:;
iter= iso_tree_node_children(dir_node);
}
for(i= 0; i<filec && !(xorriso->request_to_abort); i++) {
for(i= 0; (no_sort || i<filec) && !(xorriso->request_to_abort); i++) {
if(no_sort) {
node= iso_tree_iter_next(iter);
if(node==NULL)
@ -1880,40 +1860,6 @@ ex:;
}
int Xorriso__mode_to_perms(mode_t st_mode, char perms[10], int flag)
{
strcpy(perms,"---------");
if(st_mode&S_IRUSR) perms[0]= 'r';
if(st_mode&S_IWUSR) perms[1]= 'w';
if(st_mode&S_IXUSR) perms[2]= 'x';
if(st_mode&S_ISUID) {
if(st_mode&S_IXUSR)
perms[2]= 's';
else
perms[2]= 'S';
}
if(st_mode&S_IRGRP) perms[3]= 'r';
if(st_mode&S_IWGRP) perms[4]= 'w';
if(st_mode&S_IXGRP) perms[5]= 'x';
if(st_mode&S_ISGID) {
if(st_mode&S_IXGRP)
perms[5]= 's';
else
perms[5]= 'S';
}
if(st_mode&S_IROTH) perms[6]= 'r';
if(st_mode&S_IWOTH) perms[7]= 'w';
if(st_mode&S_IXOTH) perms[8]= 'x';
if(st_mode&S_ISVTX) {
if(st_mode&S_IXOTH)
perms[8]= 't';
else
perms[8]= 'T';
}
return(1);
}
/* @param flag bit0= long format
bit1= do not print count of nodes
bit2= du format
@ -2004,7 +1950,7 @@ much_too_long:;
/* >>> With directories this should be : number of subdirs + 2 */
/* >>> ??? How to obtain RR hardlink number for other types ? */
strcat(rpt," 1 ");
strcat(rpt," 1 ");
sprintf(rpt+strlen(rpt), "%-8lu ",
(unsigned long) iso_tree_node_get_uid(node));
@ -2337,13 +2283,13 @@ int Xorriso_mkdir(struct XorrisO *xorriso, char *path, int flag)
/* @param flag bit0= count results rather than storing them
bit1= this is a recursion
bit2= prepend /
bit2= prepend wd (automatically done if wd[0]!=0)
*/
int Xorriso_obtain_pattern_files(
struct XorrisO *xorriso, char *wd, struct iso_tree_node_dir *dir,
int *filec, char **filev, int count_limit, off_t *mem, int flag)
{
int i, ret, failed_at, l;
int ret, failed_at, l;
struct iso_tree_iter *iter= NULL;
struct iso_tree_node *node;
char adr[SfileadrL], *name;
@ -2370,7 +2316,7 @@ int Xorriso_obtain_pattern_files(
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
return(-1);
}
for(i= 0; (node= iso_tree_iter_next(iter)) != NULL; ) {
while((node= iso_tree_iter_next(iter)) != NULL) {
name= (char *) iso_tree_node_get_name(node);
if(wd[0]!=0 || (flag&4)) {
if(strlen(wd)+1>=SfileadrL)
@ -2465,21 +2411,11 @@ int Xorriso_expand_pattern(struct XorrisO *xorriso,
}
for(i= 0; i<num_patterns; i++) {
ret= Xorriso_prepare_regex(xorriso, patterns[i], 1|2);
if(ret==2) {
ret= Xorriso_prepare_regex(xorriso, patterns[i], 0);
ret= Xorriso_prepare_expansion_pattern(xorriso, patterns[i], 0);
if(ret<=0)
return(ret);
if(ret==2)
abs_adr= 4;
}
if(ret<=0) {
cannot_compile:;
sprintf(xorriso->info_text,
"Cannot compile pattern to regular expression: %s", patterns[i]);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
return(0);
}
if(patterns[i][0]=='/' || abs_adr) {
dir= root_dir;
abs_adr= 4;
@ -2578,13 +2514,12 @@ no_memory:;
/* now store addresses */
for(i= 0; i<num_patterns; i++) {
ret= Xorriso_prepare_regex(xorriso, patterns[i], 1|2);
if(ret==2) {
ret= Xorriso_prepare_regex(xorriso, patterns[i], 0);
ret= Xorriso_prepare_expansion_pattern(xorriso, patterns[i], 0);
if(ret<=0)
return(ret);
if(ret==2)
abs_adr= 4;
}
if(ret<=0)
goto cannot_compile;
was_filec= *filec;
ret= Xorriso_obtain_pattern_files(xorriso, "", dir, filec, *filev, count,
mem, abs_adr);

Loading…
Cancel
Save