4
( cd .. ; libisoburn-develop/xorriso/compile_xorriso.sh -g )
8
cc -g -DXorriso_with_maiN -DXorriso_with_readlinE \
9
-DXorriso_build_timestamP='"'"$(date -u '+%Y.%m.%d.%H%M%S')"'"' \
10
-Wall -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE \
12
xorriso/xorriso.c xorriso/xorrisoburn.c \
13
-lz -lacl -lpthread -lreadline -lburn -lisofs -lisoburn
17
cc -g -DXorriso_with_readlinE \
18
-DXorriso_build_timestamP='"'"$(date -u '+%Y.%m.%d.%H%M%S')"'"' \
19
-Wall -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE \
21
xorriso/xorriso.c xorriso/xorrisoburn.c
25
/* Command line oriented batch and dialog tool which creates, loads,
26
manipulates and burns ISO 9660 filesystem images.
28
Copyright 2007-2010 Thomas Schmitt, <scdbackup@gmx.net>
30
Initial code of this program was derived from program src/askme.c out
31
of scdbackup-0.8.8, Copyright 2007 Thomas Schmitt, BSD-License.
33
Provided under GPL version 2 or later, with the announcement that this
34
might get changed in future. I would prefer BSD or LGPL as soon as the
35
license situation of the library code allows that.
36
(This announcement affects only future releases of xorriso and it will
37
always be possible to derive a GPLv2+ from the future license.)
39
There is a derived package "GNU xorriso" under GPLv3+ which combines the
40
libburnia libraries and program xorriso to a statically linked binary.
43
Overview of xorriso architecture:
45
libburn provides the ability to read and write data.
47
libisofs interprets and manipulates ISO 9660 directory trees. It generates
48
the output stream which is handed over to libburn.
50
libisoburn encapsulates the connectivity issues between libburn and
51
libisofs. It also enables multi-session emulation on overwritable media
52
and random access file objects.
53
xorriso is intended as reference application of libisoburn.
55
xorrisoburn.[ch] encapsulate any usage of the libraries by xorriso.
57
xorriso.h exposes the public functions of xorriso which are intended
58
to be used by programs which link with xorriso.o. These functions are
59
direct equivalents of the xorriso interpreter commands.
60
There is also the API for handling event messages.
62
xorriso_private.h is not to be included by other software. It encapsulates
63
the inner interfaces of xorriso.
65
xorriso.c provides the command interpreter as described in xorriso.1.
66
It performs any activity that does not demand a reference to a symbol
67
of the library APIs. This includes:
68
- Interpretation of user input from arguments, dialog, and scripting.
69
- Output of result text and event messages.
70
- POSIX filesystem operations.
71
- Public functions which perform the particular xorriso commands.
72
- The main() function, if enabled by #define Xorriso_with_maiN.
76
/* This may be changed to Xorriso_GNU_xorrisO in order to create GNU xorriso */
77
#define Xorriso_libburnia_xorrisO yes
80
#ifdef Xorriso_without_subS
85
#include <sys/types.h>
93
/* The official xorriso options API. "No shortcuts" */
98
#else /* Xorriso_without_subS */
103
#include <sys/types.h>
108
#include <sys/stat.h>
111
#include <sys/time.h>
112
#include <sys/resource.h>
113
#include <sys/wait.h>
120
#include <sys/utsname.h>
121
#include <sys/select.h>
125
#include <langinfo.h>
128
/* eventually, this is done in xorriso_private.h : #include <regex.h> */
130
#ifdef Xorriso_with_readlinE
131
#ifdef Xorriso_with_old_readlinE
132
#include <readline.h>
134
#else /* Xorriso_with_old_readlinE */
135
#include <readline/readline.h>
136
#include <readline/history.h>
137
#endif /* ! Xorriso_with_old_readlinE */
138
#endif /* Xorriso_with_readlinE */
140
#define TSOB_FELD(typ,anz) (typ *) calloc(1, (anz)*sizeof(typ));
143
/* Diet facility: exclude help texts from binaries */
144
/* This will eventually be redefined to eat up its content */
148
/* There is only one stage of diet: Xorriso_no_helP */
149
#ifdef Xorriso_no_helP
155
/* ------------------------------------------------------------------------ */
158
/* The official xorriso options API. "No shortcuts" */
161
/* The inner description of XorrisO */
162
#define Xorriso_is_xorriso_selF 1
163
#include "xorriso_private.h"
165
/* The inner isofs- and burn-library interface */
166
#include "xorrisoburn.h"
169
/* See Xorriso__preset_signal_behavior() */
170
static int Xorriso_signal_behavioR= 1;
173
/* ------------------------------------------------------------------------ */
176
#ifndef Xorriso_sfile_externaL
177
/* @param flag bit0= do not clip of carriage return at line end
179
char *Sfile_fgets_n(char *line, int maxl, FILE *fp, int flag)
184
ret= fgets(line,maxl,fp);
188
if(l > 0 && !(flag & 1)) if(line[l-1] == '\r') line[--l]= 0;
189
if(l > 0) if(line[l-1] == '\n') line[--l]= 0;
190
if(l > 0 && !(flag & 1)) if(line[l-1] == '\r') line[--l]= 0;
195
int Sfile_count_components(char *path, int flag)
197
bit0= do not ignore trailing slash
198
bit1= do not ignore empty components (other than the empty root name)
208
for(cpt= path+l-1;cpt>=path;cpt--) {
210
if(*(cpt+1)==0 && !(flag&1))
212
if(*(cpt+1)=='/' && !(flag&2))
221
int Sfile_component_pointer(char *path, char **sourcept, int idx, int flag)
223
bit0= do not ignore trailing slash
224
bit1= do not ignore empty components (other than the empty root name)
225
bit2= accept 0 as '/'
231
for(spt= path;*spt!=0 || (flag&4);spt++) {
236
if(*spt=='/' || *spt==0) {
237
if(*(spt+1)=='/' && !(flag&2))
239
if(*(spt+1)==0 && !(flag&1))
244
if((flag&1) && count>=idx)
250
int Sfile_leafname(char *path, char leafname[SfileadrL], int flag)
256
count= Sfile_count_components(path, 0);
259
ret= Sfile_component_pointer(path, &lpt, count-1, 0);
262
if(Sfile_str(leafname, lpt, 0)<=0)
264
lpt= strchr(leafname, '/');
271
int Sfile_add_to_path(char path[SfileadrL], char *addon, int flag)
281
} else if(path[l-1]!='/') {
285
if(l+strlen(addon)>=SfileadrL)
288
strcpy(path+l,addon+1);
290
strcpy(path+l,addon);
295
int Sfile_prepend_path(char *prefix, char path[SfileadrL], int flag)
299
l= strlen(path)+strlen(prefix)+1;
303
/* >>> ??? how to transport messages to xorriso ? */
304
sprintf(xorriso->info_text,
305
"Combination of wd and relative address too long (%d > %d)",
307
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
313
for(i= strlen(path)+1; i>=0; i--)
320
int Sfile_being_group_member(struct stat *stbuf, int flag)
325
if (getegid()==stbuf->st_gid)
327
suppl_groups= getgroups(0, NULL);
328
suppl_glist= (gid_t *) malloc((suppl_groups + 1) * sizeof(gid_t));
329
if (suppl_glist==NULL)
331
suppl_groups= getgroups(suppl_groups+1,suppl_glist);
332
for (i= 0; i<suppl_groups; i++) {
333
if (suppl_glist[i]==stbuf->st_gid) {
334
free((char *) suppl_glist);
338
free((char *) suppl_glist);
343
int Sfile_type(char *filename, int flag)
345
bit0= return -1 if file is missing
346
bit1= return a hardlink with siblings as type 5
347
bit2= evaluate eventual link target rather than the link object itself
348
bit3= return a socket or a char device as types 7 or 8 rather than 0
357
5=multiple hardlink (with bit1)
360
8=character device (with bit3)
365
if(stat(filename,&stbuf)==-1) {
366
if(flag&1) return(-1);
370
if(lstat(filename,&stbuf)==-1) {
371
if(flag&1) return(-1);
375
if(S_ISREG(stbuf.st_mode)) {
381
if(S_ISDIR(stbuf.st_mode))
383
if((stbuf.st_mode&S_IFMT)==S_IFLNK)
385
if(S_ISFIFO(stbuf.st_mode))
387
if(S_ISBLK(stbuf.st_mode))
390
if((stbuf.st_mode&S_IFMT)==S_IFSOCK)
393
if(S_ISCHR(stbuf.st_mode))
399
char *Sfile_datestr(time_t tim, short int flag)
401
bit0=with hours+minutes
404
bit8= local time rather than UTC
407
static char zeitcode[80]={"000000"};
412
azt = localtime(&tim);
417
sprintf(zeitcode,"%c%1.1d%2.2d%2.2d",
418
'A'+(azt->tm_year-100)/10,azt->tm_year%10,
419
azt->tm_mon+1,azt->tm_mday);
421
sprintf(zeitcode,"%2.2d%2.2d%2.2d",
422
azt->tm_year,azt->tm_mon+1,azt->tm_mday);
424
sprintf(puff,".%2.2d%2.2d",azt->tm_hour,azt->tm_min);
425
strcat(zeitcode,puff);
428
sprintf(puff,"%2.2d",azt->tm_sec);
429
strcat(zeitcode,puff);
436
int Sfile_scale(double value, char *result, int siz, double thresh, int flag)
438
bit0= eventually ommit 'b'
439
bit1= make text as short as possible
440
bit2= no fraction (if it would fit at all)
443
char scale_c,scales[7],form[80], *negpt= NULL, *cpt;
444
int i,dec_siz= 0,avail_siz= 1;
453
strcpy(scales,"bkmgtp");
455
for(i=1;scales[i]!=0;i++) {
461
if(scale_c!='b' && !(flag&4)) { /* is there room for fractional part ? */
463
sprintf(form,"%%.f");
464
sprintf(result,"%.f",value);
465
if(strlen(result)<=avail_siz-2)
466
dec_siz= 1; /* we are very modest */
468
if(scale_c=='b' && (flag&1)) {
470
sprintf(form,"%%.f");
472
sprintf(form,"%%%d.f",siz);
473
sprintf(result,form,value);
476
sprintf(form,"%%.f%%c");
478
sprintf(form,"%%%d.%df%%c",avail_siz,dec_siz);
480
sprintf(form,"%%%d.f%%c",siz-1);
481
sprintf(result,form,value,scale_c);
484
for(cpt= result; *cpt==' '; cpt++);
494
int Sfile_off_t_text(char text[80], off_t num, int flag)
497
off_t hnum, scale= 1;
506
if(hnum<0) { /* it can stay nastily persistent */
507
strcpy(text, "_overflow_");
510
for(i= 0; i<23; i++) { /* good for up to 70 bit = 10 exp 21.07... */
522
strcpy(text, "_overflow_");
529
tpt[digits-i]= '0'+d;
538
/* Converts backslash codes into single characters:
539
\a BEL 7 , \b BS 8 , \e ESC 27 , \f FF 12 , \n LF 10 , \r CR 13 ,
540
\t HT 9 , \v VT 11 , \\ \ 92
541
\[0-9][0-9][0-9] octal code , \x[0-9a-f][0-9a-f] hex code ,
542
\cX control-x (ascii(X)-64)
543
@param upto maximum number of characters to examine for backslash.
544
The scope of a backslash (0 to 3 characters) is not affected.
545
@param eaten returns the difference in length between input and output
546
@param flag bit0= only determine *eaten, do not convert
547
bit1= allow to convert \000 to binary 0
549
int Sfile_bsl_interpreter(char *text, int upto, int *eaten, int flag)
551
char *rpt, *wpt, num_text[8], wdummy[8];
556
for(rpt= text; *rpt != 0 && rpt - text < upto; rpt++) {
564
} else if(*rpt == 'b') {
566
} else if(*rpt == 'e') {
568
} else if(*rpt == 'f') {
570
} else if(*rpt == 'n') {
572
} else if(*rpt == 'r') {
574
} else if(*rpt == 't') {
576
} else if(*rpt == 'v') {
578
} else if(*rpt == '\\') {
580
} else if(rpt[0] >= '0' && rpt[0] <= '7' &&
581
rpt[1] >= '0' && rpt[1] <= '7' &&
582
rpt[2] >= '0' && rpt[2] <= '7') {
584
num_text[1]= *(rpt + 0);
585
num_text[2]= *(rpt + 1);
586
num_text[3]= *(rpt + 2);
588
sscanf(num_text, "%o", &num);
589
if((num > 0 || (flag & 2)) && num <= 255) {
595
} else if(rpt[0] == 'x' &&
596
((rpt[1] >= '0' && rpt[1] <= '9') ||
597
(rpt[1] >= 'A' && rpt[1] <= 'F') ||
598
(rpt[1] >= 'a' && rpt[1] <= 'f'))
600
((rpt[2] >= '0' && rpt[2] <= '9') ||
601
(rpt[2] >= 'A' && rpt[2] <= 'F') ||
602
(rpt[2] >= 'a' && rpt[2] <= 'f'))
604
num_text[0]= *(rpt + 1);
605
num_text[1]= *(rpt + 2);
607
sscanf(num_text, "%x", &num);
608
if(num > 0 && num <= 255) {
614
} else if(*rpt == 'c') {
615
if(rpt[1] > 64 && rpt[1] < 96) {
616
*(wpt++)= rpt[1] - 64;
635
int Sfile_argv_bsl(int argc, char ***argv, int flag)
638
char **new_argv= NULL;
642
new_argv= (char **) Smem_malloC(argc * sizeof(char *));
645
for(i= 0; i < argc; i++) {
646
new_argv[i]= strdup((*argv)[i]);
647
if(new_argv[i] == NULL)
649
ret= Sfile_bsl_interpreter(new_argv[i], strlen(new_argv[i]), &eaten, 0);
657
free((char *) new_argv);
664
/* @param flag bit0= only encode inside quotes
665
bit1= encode < 32 outside quotes except 7, 8, 9, 10, 12, 13
666
bit2= encode in any case above 126
667
bit3= encode in any case shellsafe and name-value-safe:
668
<=42 , 59, 60, 61, 62, 63, 92, 94, 96, >=123
670
int Sfile_bsl_encoder(char **result, char *text, size_t text_len, int flag)
673
int count, sq_open= 0, dq_open= 0;
676
for(rpt= text; rpt - text < text_len; rpt++) {
679
if(!(*rpt <= 42 || (*rpt >= 59 && *rpt <= 63) ||
680
*rpt == 92 || *rpt == 94 || *rpt == 96 || *rpt >= 123))
682
} else if(*rpt >= 32 && *rpt <= 126 && *rpt != '\\')
684
if(((*rpt >= 7 && *rpt <= 13) || *rpt == 27 || *rpt == '\\') && !(flag & 8))
689
(*result)= wpt= calloc(count + 1, 1);
692
for(rpt= text; rpt - text < text_len; rpt++) {
694
sq_open= !(sq_open || dq_open);
696
dq_open= !(sq_open || dq_open);
699
if(!(*rpt <= 42 || (*rpt >= 59 && *rpt <= 63) ||
700
*rpt == 92 || *rpt == 94 || *rpt == 96 || *rpt >= 123)) {
704
} else if(*rpt >= 32 && *rpt <= 126 && *rpt != '\\') {
707
} else if( ((flag & 1) && !(sq_open || dq_open)) &&
708
!((flag & 2) && (*rpt >= 1 && * rpt <= 31 &&
709
!(*rpt == 7 || *rpt == 8 || *rpt == 9 || *rpt == 10 ||
710
*rpt == 12 || *rpt == 13))) &&
711
!((flag & 4) && (*rpt > 126 || *rpt < 0)) &&
712
!((flag & 6) && *rpt == '\\')) {
717
if(((*rpt >= 7 && *rpt <= 13) || *rpt == 27 || *rpt == '\\') && !(flag&8)) {
724
else if(*rpt == 10) {
726
} else if(*rpt == 11)
734
else if(*rpt == '\\')
737
sprintf(wpt, "%-3.3o", (unsigned int) *((unsigned char *) rpt));
746
int Sfile_destroy_argv(int *argc, char ***argv, int flag)
750
if(*argc>0 && *argv!=NULL){
751
for(i=0;i<*argc;i++){
753
Smem_freE((*argv)[i]);
755
Smem_freE((char *) *argv);
763
int Sfile_make_argv(char *progname, char *line, int *argc, char ***argv,
766
bit0= read progname as first argument from line
767
bit1= just release argument list argv and return
768
bit2= abort with return(0) if incomplete quotes are found
769
bit3= eventually prepend missing '-' to first argument read from line
770
bit4= like bit2 but only check quote completeness, do not allocate memory
771
bit5+6= interpretation of backslashes:
772
0= no interpretation, leave unchanged
773
1= only inside double quotes
774
2= outside single quotes
776
bit7= append a NULL element to argv
779
int i,pass,maxl=0,l,argzaehl=0,bufl,line_start_argc, bsl_mode, ret= 0, eaten;
783
Sfile_destroy_argv(argc,argv,0);
789
bsl_mode= (flag >> 5) & 3;
791
buf= calloc(strlen(line) + SfileadrL, 1);
794
for(pass=0;pass<2;pass++) {
797
argzaehl= line_start_argc= 1;
799
maxl= strlen(progname);
801
strcpy((*argv)[0],progname);
803
argzaehl= line_start_argc= 0;
807
if(isspace(*cpt)) continue;
812
if(isspace(*cpt)) break;
814
l= cpt-start; bufl= strlen(buf);
816
strncpy(buf + bufl, start, l); buf[bufl + l]= 0;
818
ret= Sfile_bsl_interpreter(buf, l, &eaten, 0);
825
while(*(++cpt)!=0) if(*cpt=='"') break;
826
if((flag&4) && *cpt==0)
828
l= cpt-start; bufl= strlen(buf);
830
strncpy(buf + bufl, start, l);
833
ret= Sfile_bsl_interpreter(buf + bufl, l, &eaten, 0);
839
}else if(*cpt=='\''){
840
l= cpt-start; bufl= strlen(buf);
842
strncpy(buf + bufl, start, l); buf[bufl + l]= 0;
844
ret= Sfile_bsl_interpreter(buf, l, &eaten, 0);
851
while(*(++cpt)!=0) if(*cpt=='\'') break;
852
if((flag&4) && *cpt==0)
854
l= cpt-start; bufl= strlen(buf);
856
strncat(buf,start,l);buf[bufl+l]= 0;
858
ret= Sfile_bsl_interpreter(buf + bufl, l, &eaten, 0);
870
strncpy(buf + bufl, start, l); buf[bufl + l]= 0;
872
ret= Sfile_bsl_interpreter(buf, l, &eaten, 0);
879
if(argzaehl==line_start_argc && (flag&8))
880
if(buf[0]!='-' && buf[0]!=0 && buf[0]!='#')
884
strcpy((*argv)[argzaehl],buf);
885
if(argzaehl==line_start_argc && (flag&8))
886
if(buf[0]!='-' && buf[0]!=0 && buf[0]!='#')
887
sprintf((*argv)[argzaehl],"-%s", buf);
896
if(argzaehl>0 || (flag & 128)) {
897
*argv= (char **) Smem_malloC((argzaehl + !!(flag & 128))
902
for(i=0;i<*argc;i++) {
903
(*argv)[i]= (char *) Smem_malloC((maxl+1));
908
(*argv)[*argc]= NULL;
919
/* @param flag bit0= append */
920
int Sfile_str(char target[SfileadrL], char *source, int flag)
928
fprintf(stderr, "--- Path string overflow (%d > %d). Malicious input ?\n",
933
strcat(target, source);
935
strcpy(target, source);
940
/** Combine environment variable HOME with given filename
941
@param filename Address relative to $HOME
942
@param fileadr Resulting combined address
943
@param fa_size Size of array fileadr
944
@param flag Unused yet
945
@return 1=ok , 0=no HOME variable , -1=result address too long
947
int Sfile_home_adr_s(char *filename, char *fileadr, int fa_size, int flag)
951
strcpy(fileadr,filename);
952
home= getenv("HOME");
955
if(strlen(home)+strlen(filename)+1>=fa_size)
957
strcpy(fileadr,home);
960
strcat(fileadr,filename);
966
/** Return a double representing seconds and microseconds since 1 Jan 1970 */
967
double Sfile_microtime(int flag)
971
gettimeofday(&tv,&tz);
972
return((double) (tv.tv_sec+1.0e-6*tv.tv_usec));
976
int Sfile_decode_datestr(struct tm *reply, char *text, int flag)
977
/* YYMMDD[.hhmm[ss]] */
983
current_time= time(0);
984
now= localtime(¤t_time);
985
for(i=0;i<sizeof(struct tm);i++)
986
((char *) reply)[i]= ((char *) now)[i];
988
if(text[0]<'0'|| (text[0]>'9' && text[0]<'A') || text[0]>'Z')
992
if(text[i]<'0'||text[i]>'9')
998
if(text[i]!='.' || (l!=11 && l!=13))
1001
if(text[i]<'0'||text[i]>'9')
1012
reply->tm_year= 100+(text[i]-'A')*10+text[1]-'0';
1014
reply->tm_year= 10*(text[0]-'0')+text[1]-'0';
1015
reply->tm_mon= 10*(text[2]-'0')+text[3]-'0'-1;
1016
reply->tm_mday= 10*(text[4]-'0')+text[5]-'0';
1019
reply->tm_hour= 10*(text[7]-'0')+text[8]-'0';
1020
reply->tm_min= 10*(text[9]-'0')+text[10]-'0';
1023
reply->tm_sec= 10*(text[11]-'0')+text[12]-'0';
1027
#endif /* Xorriso_sfile_externaL */
1030
/* --------------------------------- misc --------------------------------- */
1033
int Strcmp(const void *pt1, const void *pt2)
1035
return(strcmp(*((char **) pt1), *((char **) pt2)));
1039
int Sort_argv(int argc, char **argv, int flag)
1043
qsort(argv,(size_t) argc,sizeof(char *),Strcmp);
1048
static int Text_to_argv(char *text, int *argc, char ***argv, int flag)
1055
for(pass= 0; pass < 2; pass++) {
1059
(*argv)= calloc(*argc, sizeof(char *));
1066
for(npt= cpt= text; npt != NULL; cpt= npt + 1) {
1067
npt= strchr(cpt, '\n');
1071
(*argv)[*argc]= cpt;
1080
static int Count_diffs(int argc1, char **argv1, int argc2, char **argv2,
1083
int count= 0, i1= 0, i2= 0, cmp, end_corr= 0;
1085
Sort_argv(argc1, argv1, 0);
1086
Sort_argv(argc2, argv2, 0);
1090
count+= argc2 - i2 - end_corr;
1094
count+= argc1 - i1 - end_corr;
1097
cmp= strcmp(argv1[i1], argv2[i2]);
1102
} else if(cmp > 0) {
1106
if(i2 < argc2 && i1 < argc1 - 1)
1107
if(strcmp(argv1[i1 + 1], argv2[i2]) == 0) {
1115
if(i1 < argc1 && i2 < argc2 - 1)
1116
if(strcmp(argv2[i2 + 1], argv1[i1]) == 0) {
1127
@flag bit0= do not initialize *diff_count
1128
@return <0 error , 0 = mismatch , 1 = match
1130
static int Compare_text_lines(char *text1, char *text2, int *diff_count,
1133
int ret, argc1= 0, argc2= 0;
1134
char **argv1= NULL, **argv2= NULL, *copy1= NULL, *copy2= NULL;
1138
if(text1 == NULL && text2 == NULL)
1141
copy1= strdup(text1);
1144
ret= Text_to_argv(copy1, &argc1, &argv1, 0);
1149
copy2= strdup(text2);
1152
ret= Text_to_argv(copy2, &argc2, &argv2, 0);
1156
ret= Count_diffs(argc1, argv1, argc2, argv2, 1);
1160
ret= (*diff_count == 0);
1174
/** Convert a text into a number of type double and multiply it by unit code
1175
[kmgtpe] (2^10 to 2^60) or [s] (2048). (Also accepts capital letters.)
1176
@param text Input like "42", "2k", "3.14m" or "-1g"
1177
@param flag Bitfield for control purposes:
1178
bit0= return -1 rathern than 0 on failure
1179
@return The derived double value
1181
double Scanf_io_size(char *text, int flag)
1183
bit0= default value -1 rather than 0
1193
sscanf(text,"%lf",&ret);
1194
c= text[strlen(text)-1];
1195
if(c=='k' || c=='K') ret*= 1024.0;
1196
if(c=='m' || c=='M') ret*= 1024.0*1024.0;
1197
if(c=='g' || c=='G') ret*= 1024.0*1024.0*1024.0;
1198
if(c=='t' || c=='T') ret*= 1024.0*1024.0*1024.0*1024.0;
1199
if(c=='p' || c=='P') ret*= 1024.0*1024.0*1024.0*1024.0*1024.0;
1200
if(c=='e' || c=='E') ret*= 1024.0*1024.0*1024.0*1024.0*1024.0*1024.0;
1201
if(c=='s' || c=='S') ret*= 2048.0;
1206
int Decode_date_input_format(struct tm *erg, char *text, int flag)
1207
/* MMDDhhmm[[CC]YY][.ss]] */
1210
time_t current_time;
1213
current_time= time(0);
1214
now= localtime(¤t_time);
1215
for(i=0;i<sizeof(struct tm);i++)
1216
((char *) erg)[i]= ((char *) now)[i];
1220
if(text[i]<'0'||text[i]>'9')
1222
if(i!=8 && i!=10 && i!=12)
1226
if(text[i]!='.' || l!=15)
1229
if(text[i]<'0'||text[i]>'9')
1232
if(text[i]<'0'||text[i]>'9')
1236
/* MMDDhhmm[[CC]YY][.ss]] */
1238
erg->tm_mon= 10*(text[0]-'0')+text[1]-'0'-1;
1239
erg->tm_mday= 10*(text[2]-'0')+text[3]-'0';
1240
erg->tm_hour= 10*(text[4]-'0')+text[5]-'0';
1241
erg->tm_min= 10*(text[6]-'0')+text[7]-'0';
1246
year= 1000*(text[8]-'0')+100*(text[9]-'0')+10*(text[10]-'0')+(text[11]-'0');
1248
year= 1900+10*(text[8]-'0')+(text[9]-'0');
1252
erg->tm_year= year-1900;
1255
erg->tm_sec= 10*(text[13]-'0')+text[14]-'0';
1260
int Decode_date_weekday(char *text, int flag)
1263
static char days[][4]= {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", ""};
1265
for(i= 0; days[i][0]!=0; i++)
1266
if(strncmp(text,days[i],3)==0)
1268
if((strlen(text)==3 || (strlen(text)==4 && text[3]==',')) &&
1269
isalpha(text[0]) && isalpha(text[1]) && isalpha(text[2]))
1275
int Decode_date_month(char *text, int flag)
1278
static char months[][4]= {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
1279
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec", ""};
1281
for(i= 0; months[i][0]!=0; i++)
1282
if(strncmp(text,months[i],3)==0)
1288
/* @return -1=not a number, -2=not a day , 1 to 31 day of month */
1289
int Decode_date_mday(char *text, int flag)
1293
for(i= 0; text[i]!=0; i++)
1294
if(!isdigit(text[i]))
1296
if(strlen(text)>2 || text[0]==0)
1298
sscanf(text, "%d", &ret);
1299
if(ret<=0 || ret>31)
1304
int Decode_date_hms(char *text, struct tm *erg, int flag)
1306
int i, hour= -1, minute= -1, second= 0;
1308
for(i= 0; i<9; i+= 3) {
1309
if(i==6&&text[i]==0)
1311
if(!isdigit(text[i]))
1313
if(!isdigit(text[i+1]))
1315
if(text[i+2]!=':' && !(text[i+2]==0 && i>=3))
1318
sscanf(text+i,"%d",&hour);
1320
sscanf(text+i,"%d",&minute);
1322
sscanf(text+i,"%d",&second);
1324
if(hour<0 || hour>23 || minute<0 || minute>59 || second>59)
1327
erg->tm_min= minute;
1328
erg->tm_sec= second;
1333
/* @return -1=not a number, -2=not a year , >=0 years AD */
1334
int Decode_date_year(char *text, int flag)
1338
for(i= 0; text[i]!=0; i++)
1339
if(!isdigit(text[i]))
1343
sscanf(text, "%d", &ret);
1344
if(ret<0 || ret>3000)
1350
int Decode_date_timezone(char *text, struct tm *erg, int flag)
1353
static char tzs[][5]= {"GMT", "CET", "CEST", "0000", ""};
1355
for(i= 0; tzs[i][0]!=0; i++)
1356
if(strcmp(text,tzs[i])==0) {
1358
/* ??? >>> what to do with timezone info ? Add to ->tm_hour ? */
1362
if(text[0]=='+' || text[0]=='-') {
1363
for(i= 1; text[i]!=0; i++)
1364
if(!isdigit(text[i]))
1369
/* ??? >>> what to do with timezone info ? Add to ->tm_hour ? */
1373
for(i= 0; text[i]!=0; i++)
1374
if(text[i]<'A' || text[i]>'Z')
1383
int Decode_date_output_format(struct tm *erg, char *text, int flag)
1384
/* Thu Nov 8 09:07:50 CET 2007 */
1385
/* Sat, 03 Nov 2007 08:58:30 +0100 */
1388
int ret, i, argc= 0, seen_year= 0, seen_month= 0, seen_day= 0, seen_time= 0;
1393
memset(erg, 0, sizeof(*erg));
1395
ret= Sfile_make_argv("xorriso", text, &argc, &argv, 0);
1398
for(i= 1; i<argc; i++) {
1400
ret= Decode_date_month(argv[i], 0);
1408
ret= Decode_date_mday(argv[i], 0);
1414
if(ret==-2) /* first pure number must be day of month */
1418
ret= Decode_date_hms(argv[i], erg, 0);
1425
ret= Decode_date_year(argv[i], 0);
1427
erg->tm_year= ret-1900;
1433
/* ignorants have to stay at the end of the loop */
1435
ret= Decode_date_timezone(argv[i], erg, 0);
1438
ret= Decode_date_weekday(argv[i], 0);
1440
continue; /* ignore weekdays */
1442
{ret= 0; goto ex;} /* unrecognizable component */
1445
if(!(seen_day && seen_month))
1447
if(!seen_year) { /* then use this year */
1449
now= localtime(&timep);
1450
erg->tm_year= now->tm_year;
1454
Sfile_make_argv("", "", &argc, &argv, 2); /* release storage */
1459
int Decode_ecma119_format(struct tm *erg, char *text, int flag)
1460
/* YYYYMMDDhhmmsscc */
1461
/* 2010040711405800 */
1465
memset(erg, 0, sizeof(*erg));
1470
for(i= 0; i < l; i++)
1471
if(text[i] < '0' || text[i] > '9')
1474
for(i= 0; i < 4; i++)
1475
num= num * 10 + text[i] - '0';
1476
if(num < 1970 || num > 3000)
1478
erg->tm_year = num - 1900;
1479
erg->tm_mon= 10*(text[4]-'0')+text[5]-'0'-1;
1480
if(erg->tm_mon > 12)
1482
erg->tm_mday= 10*(text[6]-'0')+text[7]-'0';
1483
if(erg->tm_mday > 31)
1485
erg->tm_hour= 10*(text[8]-'0')+text[9]-'0';
1486
if(erg->tm_hour > 23)
1488
erg->tm_min= 10*(text[10]-'0')+text[11]-'0';
1489
if(erg->tm_min > 59)
1491
erg->tm_sec= 10*(text[12]-'0')+text[13]-'0';
1492
if(erg->tm_sec > 59)
1498
int Decode_xorriso_timestamp(struct tm *erg, char *code, int flag)
1499
/* 2007.11.07.225624 */
1502
int year,month,day,hour= 0,minute= 0,second= 0, i, l, mem;
1504
memset(erg, 0, sizeof(*erg));
1511
for(i= 0; buf[i]!=0 && i<4; i++)
1512
if(!isdigit(buf[i]))
1517
sscanf(buf, "%d", &year);
1518
if(year<1900 || year>3000)
1520
if(!(isdigit(buf[5]) && isdigit(buf[6]) && buf[7]=='.'))
1523
sscanf(buf+5, "%d", &month);
1524
if(month<1 || month>12)
1526
if(!(isdigit(buf[8]) && isdigit(buf[9]) && (buf[10]=='.' || buf[10]==0)))
1529
sscanf(buf+8, "%d", &day);
1534
if(!(isdigit(buf[11]) && isdigit(buf[12]) &&
1535
(isdigit(buf[13]) || buf[13]==0)))
1539
sscanf(buf+11, "%d", &hour);
1541
if(hour<0 || hour>23)
1545
if(!(isdigit(buf[13]) && isdigit(buf[14]) &&
1546
(isdigit(buf[15]) || buf[15]==0)))
1550
sscanf(buf+13, "%d", &minute);
1552
if(minute<0 || minute>59)
1556
if(!(isdigit(buf[15]) && isdigit(buf[16]) && buf[17]==0))
1558
sscanf(buf+15, "%d", &second);
1559
if(second<0 || second>59)
1563
erg->tm_year= year-1900;
1564
erg->tm_mon= month-1;
1567
erg->tm_min= minute;
1568
erg->tm_sec= second;
1573
time_t Decode_timestring(char *code, time_t *date, int flag)
1575
char *cpt,scale_chr;
1576
double value,seconds;
1577
struct tm result_tm;
1578
int seconds_valid= 0;
1582
if(code[0]=='-' || code[0]=='+' || code[0]=='=' || code[0]=='@'){
1585
if(!isdigit(code[1]))
1588
if(code[0]=='=' || code[0]=='@') {
1590
sscanf(code+1,"%lf",&value);
1592
seconds= time(NULL);
1593
sscanf(code,"%lf",&value);
1595
scale_chr= code[strlen(code)-1];
1596
if(isalpha(scale_chr))
1597
scale_chr= tolower(scale_chr);
1598
if (scale_chr=='s') seconds+= 1.0*value;
1599
else if(scale_chr=='h') seconds+= 3600.0*value;
1600
else if(scale_chr=='d') seconds+= 86400.0*value;
1601
else if(scale_chr=='w') seconds+= 86400.0*7.0*value;
1602
else if(scale_chr=='m') seconds+= 86400.0*31.0*value;
1603
else if(scale_chr=='y') seconds+= 86400.0*(365.25*value+1.0);
1604
else seconds+= 1.0*value;
1607
} else if(Sfile_decode_datestr(&result_tm,code,0)>0) {
1608
/* YYMMDD[.hhmm[ss]] */
1609
result_tm.tm_isdst= -1;
1610
seconds= mktime(&result_tm);
1613
} else if(Decode_date_input_format(&result_tm,code,0)>0) {
1614
/* MMDDhhmm[[CC]YY][.ss]] */
1615
result_tm.tm_isdst= -1;
1616
seconds= mktime(&result_tm);
1619
} else if(Decode_xorriso_timestamp(&result_tm, code, 0)>0) {
1620
/* 2007.11.07.225624 */
1621
seconds= mktime(&result_tm);
1624
} else if(Decode_date_output_format(&result_tm, code, 0)>0) {
1625
/* Thu Nov 8 09:07:50 CET 2007 */;
1626
/* Sat, 03 Nov 2007 08:58:30 +0100 */;
1628
seconds= mktime(&result_tm);
1631
} else if(Decode_ecma119_format(&result_tm, code, 0)>0) {
1632
/* YYYYMMDDhhmmsscc */
1633
/* 2010040711405800 */
1634
seconds= mktime(&result_tm);
1647
/* @param flag bit0=with year and seconds
1650
1= timestamp format YYYY.MM.DD.hhmmss
1651
2= Wdy Mon Day hh:mm:ss Year
1652
3= Mon Day hh:mm:ss Year
1655
char *Ftimetxt(time_t t, char timetext[40], int flag)
1658
struct tm tms, *tmpt;
1659
static char months[12][4]= { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
1660
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
1661
static char days[7][4]= {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
1665
tmpt= localtime_r(&t, &tms);
1669
sprintf(rpt+strlen(rpt), "%12.f", (double) t);
1671
sprintf(rpt+strlen(rpt), "%4.4d.%2.2d.%2.2d.%2.2d%2.2d%2.2d",
1672
1900+tms.tm_year, tms.tm_mon+1, tms.tm_mday,
1673
tms.tm_hour, tms.tm_min, tms.tm_sec);
1675
sprintf(rpt+strlen(rpt), "%s %s %2.2d %2.2d:%2.2d:%2.2d %4.4d",
1676
days[tms.tm_wday], months[tms.tm_mon], tms.tm_mday,
1677
tms.tm_hour, tms.tm_min, tms.tm_sec, 1900+tms.tm_year);
1679
sprintf(rpt+strlen(rpt), "%s %2.2d %2.2d:%2.2d:%2.2d %4.4d",
1680
months[tms.tm_mon], tms.tm_mday,
1681
tms.tm_hour, tms.tm_min, tms.tm_sec, 1900+tms.tm_year);
1682
else if (form == 4) {
1684
sprintf(rpt+strlen(rpt), "%c", 'A' + (tms.tm_year - 100) / 10);
1686
sprintf(rpt+strlen(rpt), "%c", '0' + tms.tm_year / 10);
1687
sprintf(rpt+strlen(rpt), "%1.1d%2.2d%2.2d.%2.2d%2.2d%2.2d",
1688
tms.tm_year % 10, tms.tm_mon + 1, tms.tm_mday,
1689
tms.tm_hour, tms.tm_min, tms.tm_sec);
1691
sprintf(rpt+strlen(rpt), "%2d %3s %4.4d %2.2d:%2.2d:%2.2d",
1692
tms.tm_mday, months[tms.tm_mon], 1900+tms.tm_year,
1693
tms.tm_hour, tms.tm_min, tms.tm_sec);
1694
else if(time(NULL)-t < 180*86400 && time(NULL)-t >= 0)
1695
sprintf(rpt+strlen(rpt), "%3s %2d %2.2d:%2.2d",
1696
months[tms.tm_mon], tms.tm_mday, tms.tm_hour, tms.tm_min);
1698
sprintf(rpt+strlen(rpt), "%3s %2d %4.4d",
1699
months[tms.tm_mon], tms.tm_mday, 1900+tms.tm_year);
1704
/* @param flag bit0= single letters */
1705
char *Ftypetxt(mode_t st_mode, int flag)
1708
goto single_letters;
1709
if(S_ISDIR(st_mode))
1710
return("directory");
1711
else if(S_ISREG(st_mode))
1712
return("regular_file");
1713
else if(S_ISLNK(st_mode))
1714
return("symbolic_link");
1715
else if(S_ISBLK(st_mode))
1716
return("block_device");
1717
else if(S_ISCHR(st_mode))
1718
return("char_device");
1719
else if(S_ISFIFO(st_mode))
1720
return("name_pipe");
1721
else if(S_ISSOCK(st_mode))
1722
return("unix_socket");
1725
if(S_ISDIR(st_mode))
1727
else if(S_ISREG(st_mode))
1729
else if(S_ISLNK(st_mode))
1731
else if(S_ISBLK(st_mode))
1733
else if(S_ISCHR(st_mode))
1735
else if(S_ISFIFO(st_mode))
1737
else if(S_ISSOCK(st_mode))
1743
int Wait_for_input(int fd, int microsec, int flag)
1754
wt.tv_sec= microsec/1000000;
1755
wt.tv_usec= microsec%1000000;
1756
ready= select(fd+1,&rds,&wts,&exs,&wt);
1759
if(FD_ISSET(fd,&exs))
1761
if(FD_ISSET(fd,&rds))
1767
int System_uname(char **sysname, char **release, char **version,
1768
char **machine, int flag)
1771
static struct utsname uts;
1772
static int initialized= 0;
1774
if(initialized == 0) {
1779
if(initialized == -1)
1782
*sysname= uts.sysname;
1784
*release= uts.release;
1786
*version= uts.version;
1788
*machine= uts.machine;
1792
/* ------------------------------------------------------------------------ */
1795
#ifndef Xorriso_sregex_externaL
1798
#define Smem_malloC malloc
1801
#define Smem_freE free
1805
int Sregex_string_cut(char **handle, char *text, int len, int flag)
1807
bit0= append (text!=NULL)
1813
if((flag&1)&&*handle!=NULL)
1814
l+= strlen(*handle);
1815
old_handle= *handle;
1818
*handle= TSOB_FELD(char,l+1);
1820
*handle= old_handle;
1823
if((flag&1) && old_handle!=NULL)
1824
strcpy(*handle,old_handle);
1828
strncat(*handle,text,len);
1832
if(old_handle!=NULL)
1833
Smem_freE(old_handle);
1838
int Sregex_string(char **handle, char *text, int flag)
1840
bit0= append (text!=NULL)
1848
/* #define Sregex_looking_for_contenT 1 */
1849
#ifdef Sregex_looking_for_contenT
1850
/* a debugging point if a certain text content has to be caught */
1852
if(strcmp(text,"clear")==0)
1856
ret= Sregex_string_cut(handle,text,l,flag&1);
1862
vars[][0] points to the variable names, vars[][1] to their contents.
1863
start marks the begin of variable names. It must be non-empty. esc before
1864
start disables this meaning. start and esc may be equal but else they must
1865
have disjoint character sets.
1866
end marks the end of a variable name. It may be empty but if non-empty it
1867
must not appear in vars[][0].
1868
@param flag bit0= Substitute unknown variables by empty text
1869
(else copy start,name,end unaltered to result).
1870
Parameter end must be non-empty for that.
1872
int Sregex_resolve_var(char *form, char *vars[][2], int num_vars,
1873
char *start, char *end, char *esc,
1874
char *result, int result_size, int flag)
1876
int l_e, l_v, l_s, l_esc, i, start_equals_esc;
1877
char *rpt, *wpt, *spt, *npt, *ept;
1879
if(start[0] == 0) /* It is not allowed to have no start marker */
1884
start_equals_esc= !strcmp(start, esc);
1890
/* look for start mark */
1891
spt= strstr(rpt, start);
1893
if((wpt - result) + strlen(rpt) >= result_size)
1900
/* copy cleartext part up to next variable */
1901
if((wpt - result) + (spt - rpt) >= result_size)
1903
strncpy(wpt, rpt, spt - rpt);
1909
/* handle eventual escape */
1910
if(start_equals_esc) {
1911
if(strncmp(spt + l_s, esc, l_esc) == 0) {
1912
/* copy esc and start */
1913
if((wpt - result) + l_esc + l_s >= result_size)
1915
strncpy(wpt, spt, l_esc + l_s);
1922
/* escape would be already copied */
1923
if(l_esc > 0 && spt - form >= l_esc) {
1924
if(strncmp(spt - l_esc, esc, l_esc) == 0) {
1926
if((wpt - result) + l_s >= result_size)
1928
strncpy(wpt, spt, l_s);
1937
/* Memorize eventual end mark for default handling */;
1940
ept= strstr(npt, end);
1942
/* Look for defined variable name */
1943
for(i = 0; i < num_vars; i++) {
1944
if(strncmp(npt, vars[i][0], strlen(vars[i][0])) == 0
1945
&& (l_e == 0 || strncmp(npt + strlen(vars[i][0]), end, l_e) == 0))
1949
/* substitute found variable */
1950
l_v= strlen(vars[i][0]);
1951
if((wpt - result) + strlen(vars[i][1]) >= result_size)
1953
strcpy(wpt, vars[i][1]);
1954
rpt= npt + strlen(vars[i][0]) + l_e;
1955
} else if((flag & 1) && ept != NULL) {
1956
/* skip up to end mark */
1958
} else if(ept != NULL) {
1959
/* copy start,name,end */
1960
if((wpt - result) + (ept - rpt) + l_e >= result_size)
1962
strncpy(wpt, rpt, (ept - rpt) + l_e);
1965
/* copy start marker only */
1966
if((wpt - result) + l_s >= result_size)
1968
strncpy(wpt, rpt, l_s);
1978
/* @param flag bit0= only test expression whether compilable
1980
int Sregex_match(char *pattern, char *text, int flag)
1983
char re_text[2*SfileadrL];
1985
regmatch_t match[1];
1987
Xorriso__bourne_to_reg(pattern, re_text, 0);
1988
ret= regcomp(&re, re_text, 0);
1995
ret= regexec(&re, text, 1, match, 0);
2003
#endif /* Xorriso_sregex_externaL */
2007
/* @param flag bit0= append to out_text rather than overwrite it
2009
char *Text_shellsafe(char *in_text, char *out_text, int flag)
2014
ol= w= strlen(out_text);
2015
/* enclose everything by hard quotes */
2017
out_text[w++]= '\'';
2019
if(in_text[i]=='\''){
2020
if(w+7>5*SfileadrL+ol)
2022
/* escape hard quote within the text */
2023
out_text[w++]= '\'';
2025
out_text[w++]= '\'';
2027
out_text[w++]= '\'';
2029
if(w+3>5*SfileadrL) {
2031
strncpy(out_text, "'xorriso: TEXT MUCH TOO LONG ... ",33);
2034
out_text[w++]= in_text[i];
2037
out_text[w++]= '\'';
2043
int Hex_to_bin(char *hex,
2044
int bin_size, int *bin_count, unsigned char *bin_data, int flag)
2050
return(-1); /* malformed */
2052
for(i= 0; i < l; i+= 2) {
2053
if(hex[i] >= '0' && hex[i] <= '9')
2054
acc= (hex[i] - '0') << 4;
2055
else if(hex[i] >= 'A' && hex[i] <= 'F')
2056
acc= (hex[i] - 'A' + 10) << 4;
2057
else if(hex[i] >= 'a' && hex[i] <= 'f')
2058
acc= (hex[i] - 'a' + 10) << 4;
2061
if(hex[i + 1] >= '0' && hex[i + 1] <= '9')
2062
acc|= (hex[i + 1] - '0');
2063
else if(hex[i + 1] >= 'A' && hex[i + 1] <= 'F')
2064
acc|= (hex[i + 1] - 'A' + 10);
2065
else if(hex[i + 1] >= 'a' && hex[i + 1] <= 'f')
2066
acc|= (hex[i + 1] - 'a' + 10);
2069
if(*bin_count >= bin_size)
2070
return(0); /* overflow */
2071
bin_data[*bin_count]= acc;
2078
#ifndef Xorriso_fileliste_externaL
2080
/* ??? ts A71006 : Is this compatible with mkisofs pathspecs ?
2081
I dimly remember so */
2083
int Fileliste__target_source_limit(char *line, char sep, char **limit_pt,
2088
for(npt= line;*npt!=0;npt++) {
2103
#endif /* ! Xorriso_fileliste_externaL */
2106
/* ------------------------------------------------------------------------ */
2107
/* DirseQ : crawl along a directory's content list */
2109
static int Dirseq_buffer_sizE= 100;
2112
char adr[SfileadrL];
2120
struct DirseQ *next;
2123
int Dirseq_destroy(struct DirseQ **o, int flag);
2124
int Dirseq_next_adrblock(struct DirseQ *o, char *replies[], int *reply_count,
2125
int max_replies, int flag);
2128
int Dirseq_new(struct DirseQ **o, char *adr, int flag)
2130
bit0= with non-fatal errors do not complain about failed opendir()
2133
int ret,i,severe_error;
2136
m= *o= TSOB_FELD(struct DirseQ,1);
2147
if(Sfile_str(m->adr, adr, 0)<=0)
2148
{ret= 0; goto failed;}
2149
m->buffer= TSOB_FELD(char *,Dirseq_buffer_sizE);
2151
{ret= -1; goto failed;}
2152
m->buffer_size= Dirseq_buffer_sizE;
2153
for(i= 0;i<m->buffer_size;i++)
2156
m->dirpt= opendir(".");
2158
m->dirpt= opendir(adr);
2159
if(m->dirpt==NULL) {
2160
severe_error= (errno && errno!=ENOENT && errno!=EACCES && errno!=ENOTDIR);
2161
if(severe_error || !(flag&1))
2162
fprintf(stderr,"opendir(%s) failed : %s\n",adr,strerror(errno));
2168
Dirseq_destroy(o,0);
2173
int Dirseq_destroy(struct DirseQ **o, int flag)
2179
if((*o)->dirpt!=NULL)
2180
closedir((*o)->dirpt);
2181
if((*o)->buffer!=NULL) {
2182
for(i=0;i<(*o)->buffer_size;i++)
2183
if((*o)->buffer[i]!=NULL)
2184
free((*o)->buffer[i]);
2185
free((char *) (*o)->buffer);
2193
int Dirseq_set_next(struct DirseQ *o, struct DirseQ *next, int flag)
2200
int Dirseq_get_next(struct DirseQ *o, struct DirseQ **next, int flag)
2207
int Dirseq_get_adr(struct DirseQ *o, char **adrpt, int flag)
2214
int Dirseq_rewind(struct DirseQ *o, int flag)
2216
rewinddir(o->dirpt);
2221
int Dirseq_next_adr(struct DirseQ *o, char reply[SfileadrL], int flag)
2224
bit0= permission to use buffer
2225
bit1= do not increment counter
2226
bit2= ignore buffer in any case
2227
bit3= do not exclude '.' and '..'
2229
bit5= sort only incomplete last buffer
2232
0= no more entries available
2233
1= ok, reply is valid
2237
struct dirent *entry;
2240
static int override_flag_0= 0,override_flag_1= 32;
2241
flag= (flag&~override_flag_0)|override_flag_1;
2243
if((flag&1) && o->buffer_rpt>=o->buffer_fill) {
2244
/* permission to buffer and buffer empty : load a buffer */
2245
ret= Dirseq_next_adrblock(o,o->buffer,&(o->buffer_fill),
2246
o->buffer_size,2|4|(flag&16));
2250
if((flag&32) && o->buffer_fill<o->buffer_size && o->buffer_fill>0)
2251
Sort_argv(o->buffer_fill,o->buffer,0);
2253
if(o->buffer_rpt<o->buffer_fill && !(flag&4)) {
2254
ret= Sfile_str(reply,o->buffer[o->buffer_rpt],0);
2255
Sregex_string(&(o->buffer[o->buffer_rpt]),NULL,0);
2264
entry= readdir(o->dirpt);
2266
/* >>> how to distinguish error from EOF , do i need a (FILE *) ? */
2269
if(strlen(entry->d_name)>=SfileadrL) {
2270
fprintf(stderr,"--- oversized directory entry (number %d) :\n %s",
2271
o->count+1,entry->d_name);
2274
name= entry->d_name;
2277
/* skip "." and ".." */
2278
} while(name[0]=='.' && ((name[1]=='.' && name[2]==0) || name[1]==0));
2279
if(Sfile_str(reply,name,0)<=0)
2287
int Dirseq_next_adrblock(struct DirseQ *o, char *replies[], int *reply_count,
2288
int max_replies, int flag)
2289
/* @param replies A vector of Sregex_string pointers */
2292
bit0= permission to use buffer
2293
bit1= do not increment counter
2294
bit2= ignore buffer in any case
2298
0= no more entries available
2299
1= ok, reply is valid
2303
char reply[SfileadrL];
2306
for(i=0;i<max_replies;i++) {
2307
ret= Dirseq_next_adr(o,reply,flag&(1|2|4));
2312
if(Sregex_string(&(replies[i]),reply,0)<=0)
2316
if((*reply_count)==0)
2319
Sort_argv(*reply_count,replies,0);
2324
/* --------------------------------- Xorriso_lsT --------------------------- */
2328
@param flag Bitfield for control purposes
2329
bit0= insert before link rather than after it
2330
bit1= do not copy data (e.g. because *data is invalid)
2331
bit2= attach data directly by pointer rather than by copying
2333
int Xorriso_lst_new_binary(struct Xorriso_lsT **lstring, char *data,
2334
int data_len, struct Xorriso_lsT *link, int flag)
2337
struct Xorriso_lsT *s;
2339
s= TSOB_FELD(struct Xorriso_lsT,1);
2343
s->next= s->prev= NULL;
2349
{ret= -1; goto failed;}
2350
s->text= Smem_malloC(data_len);
2352
{ret= -1; goto failed;}
2354
memcpy(s->text,data,data_len);
2361
s->prev= link->prev;
2362
if(link->prev!=NULL)
2363
link->prev->next= s;
2367
s->next= link->next;
2368
if(link->next!=NULL)
2369
link->next->prev= s;
2376
Xorriso_lst_destroy(lstring,0);
2382
@param flag Bitfield for control purposes
2383
see Xorriso_lst_new_binary()
2385
int Xorriso_lst_new(struct Xorriso_lsT **lstring, char *text,
2386
struct Xorriso_lsT *link, int flag)
2390
ret= Xorriso_lst_new_binary(lstring,text,strlen(text)+1,link,flag);
2396
@param flag Bitfield for control purposes
2397
bit0= do not set *lstring to NULL
2399
int Xorriso_lst_destroy(struct Xorriso_lsT **lstring, int flag)
2401
struct Xorriso_lsT *s;
2407
s->prev->next= s->next;
2409
s->next->prev= s->prev;
2412
Smem_freE((char *) s);
2419
int Xorriso_lst_destroy_all(struct Xorriso_lsT **lstring, int flag)
2421
struct Xorriso_lsT *s,*next;
2425
if((*lstring)==NULL)
2427
for(s= *lstring; s->prev!=NULL; s= s->prev);
2428
for(;s!=NULL;s= next){
2430
Xorriso_lst_destroy(&s,0);
2437
int Xorriso_lst_append_binary(struct Xorriso_lsT **entry,
2438
char *data, int data_len, int flag)
2440
struct Xorriso_lsT *target= NULL,*newby;
2443
for(target= *entry; target->next!=NULL; target= target->next);
2444
if(Xorriso_lst_new_binary(&newby, data, data_len, target, flag & ~1)<=0)
2446
if(*entry==NULL || (flag & 1))
2452
struct Xorriso_lsT *Xorriso_lst_get_next(struct Xorriso_lsT *entry, int flag)
2454
return(entry->next);
2458
struct Xorriso_lsT *Xorriso_lst_get_prev(struct Xorriso_lsT *entry, int flag)
2460
return(entry->prev);
2464
char *Xorriso_lst_get_text(struct Xorriso_lsT *entry, int flag)
2466
return(entry->text);
2470
int Xorriso_lst_detach_text(struct Xorriso_lsT *entry, int flag)
2477
/* ------------------------------ LinkiteM -------------------------------- */
2484
struct LinkiteM *next;
2487
int Linkitem_destroy(struct LinkiteM **o, int flag);
2490
int Linkitem_new(struct LinkiteM **o, char *link_path, dev_t target_dev,
2491
ino_t target_ino, struct LinkiteM *next, int flag)
2495
m= *o= TSOB_FELD(struct LinkiteM,1);
2498
m->target_dev= target_dev;
2499
m->target_ino= target_ino;
2503
m->link_count= m->next->link_count+1;
2504
m->link_path= strdup(link_path);
2505
if(m->link_path==NULL)
2509
Linkitem_destroy(o, 0);
2514
int Linkitem_destroy(struct LinkiteM **o, int flag)
2518
if((*o)->link_path!=NULL)
2519
free((*o)->link_path);
2520
free((char *) (*o));
2526
int Linkitem_reset_stack(struct LinkiteM **o, struct LinkiteM *to, int flag)
2528
struct LinkiteM *m, *m_next= NULL;
2530
/* Prevent memory corruption */
2531
for(m= *o; m!=to; m= m->next)
2532
if(m==NULL) { /* this may actually not happen */
2537
for(m= *o; m!=to; m= m_next) {
2539
Linkitem_destroy(&m, 0);
2546
int Linkitem_find(struct LinkiteM *stack, dev_t target_dev, ino_t target_ino,
2547
struct LinkiteM **result, int flag)
2551
for(m= stack; m!=NULL; m= m->next) {
2552
if(target_dev == m->target_dev && target_ino == m->target_ino) {
2561
/* ----------------------- Exprtest ----------------------- */
2564
int Exprtest_new( struct ExprtesT **ftest, struct FindjoB *boss, int flag)
2568
*ftest= f= TSOB_FELD(struct ExprtesT,1);
2580
int Exprtest_destroy(struct ExprtesT **ftest, int flag)
2588
if(f->test_type == 1) {
2591
if(f->arg2 != NULL) {
2595
} else if(f->test_type == 9) {
2596
/* arg1 is not an allocated value */;
2609
/* ----------------------- Nttpfnode ----------------------- */
2612
int Exprnode_new(struct ExprnodE **fnode, struct FindjoB *job,
2613
struct ExprnodE *up, char *origin, int flag)
2615
bit0= set invert-property
2616
bit1= set use_shortcuts
2622
*fnode= n= TSOB_FELD(struct ExprnodE,1);
2625
for(i= 0; i < sizeof(n->origin); i++)
2627
strncpy(n->origin, origin, sizeof(n->origin) - 1);
2629
n->invert= (flag & 1);
2631
n->use_shortcuts= !!(flag & 2);
2637
n->is_if_then_else= 0;
2638
n->true_branch= NULL;
2639
n->false_branch= NULL;
2642
n->composed_value= -1;
2644
ret= Exprtest_new(&(n->test), job, 0);
2646
Exprnode_destroy(fnode, 0);
2653
int Exprnode_destroy(struct ExprnodE **fnode, int flag)
2657
Exprnode_destroy(&((*fnode)->right),0);
2658
Exprnode_destroy(&((*fnode)->sub),0);
2659
Exprnode_destroy(&((*fnode)->true_branch),0);
2660
Exprnode_destroy(&((*fnode)->false_branch),0);
2661
Exprtest_destroy(&((*fnode)->test),0);
2662
free((char *) *fnode);
2668
int Exprnode_set_is_if(struct ExprnodE *fnode, int value, int flag)
2670
fnode->is_if_then_else= value;
2675
int Exprnode_is_if(struct ExprnodE *fnode, int flag)
2677
return(fnode->is_if_then_else);
2681
int Exprnode_set_branch(struct ExprnodE *fnode, struct ExprnodE *target,
2684
bit0= false_branch (else true_branch)
2687
struct ExprnodE **branch;
2690
branch= &(fnode->false_branch);
2692
branch= &(fnode->true_branch);
2693
Exprnode_destroy(branch,0);
2699
int Exprnode_get_branch(struct ExprnodE *fnode, struct ExprnodE **branch,
2702
bit0= false_branch (else true_branch)
2706
(*branch)= fnode->false_branch;
2708
(*branch)= fnode->true_branch;
2713
int Exprnode_is_defined(struct ExprnodE *fnode, int flag)
2715
struct ExprtesT *ftest;
2719
if(fnode->sub!=NULL)
2724
if(ftest->test_type>=0)
2730
int Exprnode_own_value(struct XorrisO *xorriso, struct ExprnodE *fnode,
2731
void *node, char *name, char *path,
2732
struct stat *boss_stbuf, struct stat *stbuf, int flag)
2735
return: (also from Exprtest_match() and Exprnode_tree_value() )
2739
2 = immediate decision : does not match
2740
3 = immediate decision : does match
2747
if(fnode->sub!=NULL) {
2748
ret= Exprnode_tree_value(xorriso, fnode->sub, -1,
2749
node, name, path, boss_stbuf, stbuf, 0);
2751
ret= Exprtest_match(xorriso, fnode->test, node, name, path,
2752
boss_stbuf, stbuf, 0);
2764
int Exprnode_op(int value1, int value2, int op, int flag)
2769
ret= value1 || value2 ;
2771
ret= value1 && value2 ;
2776
int Exprnode_tree_value(struct XorrisO *xorriso, struct ExprnodE *fnode,
2777
int left_value, void *node, char *name, char *path,
2778
struct stat *boss_stbuf, struct stat *stbuf, int flag)
2780
bit0-7= testmode: 0=head , 1=filename
2781
return: (also from Nntpftest_match() and Nntpfnode_own_value() )
2785
2 = immediate decision : does not match
2786
3 = immediate decision : does match
2793
if(!Exprnode_is_defined(fnode,0))
2796
if(fnode->use_shortcuts && fnode->left!=NULL){
2797
fnode->composed_value= left_value;
2798
if(fnode->left_op==0) {/* OR */
2806
fnode->composed_value= fnode->own_value=
2807
Exprnode_own_value(xorriso, fnode, node, name, path, boss_stbuf, stbuf, 0);
2808
if(fnode->own_value < 0 || fnode->own_value > 1)
2809
return(fnode->own_value);
2811
if(fnode->assoc == 0){ /* left associative */
2812
if(fnode->left != NULL && left_value >= 0)
2813
fnode->composed_value=
2814
Exprnode_op(left_value, fnode->own_value, fnode->left_op, 0);
2815
/* compute right value */
2816
/* is the right value relevant ? */
2817
if(fnode->right!=NULL){
2818
if(fnode->use_shortcuts){
2819
if(fnode->right_op==0) {/* OR */
2820
if(fnode->composed_value!=0)
2823
if(fnode->composed_value==0)
2827
value= Exprnode_tree_value(xorriso, fnode->right,fnode->composed_value,
2828
node, name, path, boss_stbuf, stbuf, 0);
2829
if(value<0 || value>1)
2831
fnode->composed_value= value;
2833
}else{ /* right associative */
2834
if(fnode->right!=NULL){
2835
/* is the right value relevant ? */
2836
if(fnode->use_shortcuts){
2837
if(fnode->right_op==0) {/* OR */
2838
if(fnode->composed_value!=0)
2841
if(fnode->composed_value==0)
2845
value= Exprnode_tree_value(xorriso, fnode->right,fnode->own_value,
2846
node, name, path, boss_stbuf, stbuf, 0);
2847
if(value<0||value>1)
2850
value= fnode->own_value;
2851
fnode->composed_value= value;
2852
if(fnode->left!=NULL && left_value>=0)
2853
fnode->composed_value=
2854
Exprnode_op(left_value,fnode->composed_value,fnode->left_op,0);
2857
ret= fnode->composed_value;
2858
if(fnode->is_if_then_else) {
2859
/* The if-condition is evaluated. Now follow the chosen branch */
2860
struct ExprnodE *branch;
2862
branch= fnode->true_branch;
2864
branch= fnode->false_branch;
2866
ret= Exprnode_tree_value(xorriso, branch, -1,
2867
node, name, path, boss_stbuf, stbuf, 0);
2873
fnode->composed_value= ret;
2875
return(fnode->composed_value);
2879
/* --------------------- Findjob -------------------- */
2882
int Findjob_new(struct FindjoB **o, char *start_path, int flag)
2887
m= *o= TSOB_FELD(struct FindjoB,1);
2890
m->start_path= NULL;
2894
m->use_shortcuts= 1;
2895
m->action= 0; /* print */
2897
m->target= NULL; /* a mere pointer, not managed memory */
2898
m->text_2= NULL; /* a mere pointer, not managed memory */
2903
m->start_path= strdup(start_path);
2904
if(m->start_path==NULL)
2906
m->found_path= NULL;
2909
ret= Exprnode_new(&(m->test_tree), m, NULL, "-find", (m->use_shortcuts)<<1);
2912
m->cursor= m->test_tree;
2916
Findjob_destroy(o, 0);
2921
int Findjob_destroy(struct FindjoB **o, int flag)
2928
if(m->test_tree != NULL)
2929
Exprnode_destroy(&(m->test_tree), 0);
2930
if(m->start_path != NULL)
2931
free(m->start_path);
2938
int Findjob_set_start_path(struct FindjoB *o, char *start_path, int flag)
2940
if(o->start_path!=NULL)
2941
free(o->start_path);
2942
if(start_path!=NULL) {
2943
o->start_path= strdup(start_path);
2944
if(o->start_path==NULL)
2947
o->start_path= NULL;
2952
int Findjob_get_start_path(struct FindjoB *o, char **start_path, int flag)
2954
*start_path= o->start_path;
2959
int Findjob_cursor_complete( struct FindjoB *job, int flag)
2965
ret= Exprnode_is_defined(job->cursor,0);
2970
int Findjob_is_restrictive(struct FindjoB *job, int flag)
2974
if(job->test_tree == NULL)
2976
if(!Exprnode_is_defined(job->test_tree, 0))
2982
int Findjob_new_node(struct FindjoB *job, struct ExprnodE **fnode,
2983
char *origin, int flag)
2985
bit0= open new branch
2986
bit1= with bit1 : do not register as sub-node of job->cursor
2992
ret= Exprnode_new(fnode,job,NULL,origin,
2993
job->invert|((job->use_shortcuts)<<1));
2999
if(job->cursor!=NULL && !(flag&2)) {
3000
if(job->cursor->sub!=NULL) {
3001
/* This would become a memory leak */
3003
sprintf(job->errmsg,
3004
"Program error while parsing -job : sub branch overwrite");
3007
job->cursor->sub= f;
3010
f->up= job->cursor->up;
3011
f->left= job->cursor;
3012
if(job->cursor!=NULL)
3013
job->cursor->right= f;
3020
/* If an operator is expected : use -and
3021
@param flag bit0= prepare for a pseudo-test:
3022
if an operator is expected, do nothing and return 2
3024
int Findjob_default_and(struct FindjoB *o, int flag)
3028
if(Findjob_cursor_complete(o, 0)) {
3031
ret= Findjob_and(o, 0);
3039
int Findjob_open_bracket(struct FindjoB *job, int flag)
3042
struct ExprnodE *fnode;
3044
ret= Findjob_default_and(job, 0);
3047
ret= Findjob_new_node(job, &fnode, "-sub", 1);
3055
int Findjob_close_bracket(struct FindjoB *job, int flag)
3057
if(!Findjob_cursor_complete(job, 0)) {
3059
sprintf(job->errmsg,
3060
"Unary operator or expression expected, closing-bracket found");
3064
if(job->cursor->up==NULL){
3066
sprintf(job->errmsg,
3067
"No bracket open when encountering closing bracket.");
3070
job->cursor= job->cursor->up;
3075
int Findjob_not(struct FindjoB *job, int flag)
3079
ret= Findjob_default_and(job, 0);
3082
job->cursor->invert= !job->cursor->invert;
3087
int Findjob_and(struct FindjoB *job, int flag)
3090
struct ExprnodE *fnode;
3092
if(!Findjob_cursor_complete(job, 0)) {
3094
sprintf(job->errmsg,
3095
"Unary operator or expression expected, binary operator found");
3099
ret= Findjob_new_node(job, &fnode, "-and", 0);
3102
job->cursor->right_op= 1;
3103
job->cursor->assoc= 1; /* compute right side first */
3105
fnode->assoc= 0; /* compute left side first */
3111
int Findjob_or(struct FindjoB *job, int flag)
3114
struct ExprnodE *fnode;
3116
if(!Findjob_cursor_complete(job, 0)) {
3118
sprintf(job->errmsg,
3119
"Unary operator or expression expected, binary operator found");
3123
ret= Findjob_new_node(job, &fnode, "-or", 0);
3126
job->cursor->right= fnode;
3127
job->cursor->right_op= 0;
3128
/* if existing : compute left side first */
3129
job->cursor->assoc= (job->cursor->left == NULL);
3130
fnode->left= job->cursor;
3132
fnode->assoc= 0; /* no right side yet : compute left side first */
3138
int Findjob_if(struct FindjoB *job, int flag)
3141
struct ExprnodE *fnode;
3143
ret= Findjob_default_and(job, 0);
3146
ret= Findjob_new_node(job, &fnode, "-if", 1);
3149
Exprnode_set_is_if(fnode,1,0);
3155
int Findjob_then(struct FindjoB *job, int flag)
3158
struct ExprnodE *fnode,*branch= NULL;
3160
if(! Findjob_cursor_complete(job,0)) {
3162
sprintf(job->errmsg,
3163
"Unary operator or expression expected, -then-operator found");
3166
/* Finding the -if that matches this -then
3167
Do not go up one node but look for the leftmost one.
3168
If everything is right we are at level of the -if node */
3169
while(job->cursor->left!=NULL)
3170
job->cursor= job->cursor->left;
3171
Exprnode_get_branch(job->cursor, &branch, 0);
3172
if(!Exprnode_is_if(job->cursor, 0) || branch != NULL) {
3174
sprintf(job->errmsg, "-then-operator found outside its proper range.");
3177
ret= Findjob_new_node(job, &fnode, "-then", 1|2);
3180
Exprnode_set_branch(job->cursor, fnode, 0);
3186
int Findjob_else(struct FindjoB *job, int flag)
3189
struct ExprnodE *fnode, *true_branch, *false_branch;
3191
if(! Findjob_cursor_complete(job, 0)) {
3193
sprintf(job->errmsg,
3194
"Unary operator or expression expected, -else-operator found");
3197
if(job->cursor->up == NULL)
3198
goto improper_range;
3199
job->cursor= job->cursor->up;
3200
Exprnode_get_branch(job->cursor, &true_branch, 0);
3201
Exprnode_get_branch(job->cursor, &false_branch, 1);
3202
if(!Exprnode_is_if(job->cursor, 0) ||
3203
true_branch == NULL || false_branch != NULL) {
3206
sprintf(job->errmsg, "-else-operator found outside its proper range.");
3209
ret= Findjob_new_node(job, &fnode, "-else", 1 | 2);
3212
Exprnode_set_branch(job->cursor, fnode, 1);
3218
int Findjob_elseif(struct FindjoB *job, int flag)
3221
struct ExprnodE *true_branch, *false_branch;
3223
if(!Findjob_cursor_complete(job, 0)) {
3225
sprintf(job->errmsg,
3226
"Unary operator or expression expected, -elseif-operator found");
3229
if(job->cursor->up == NULL)
3230
goto improper_range;
3231
job->cursor= job->cursor->up;
3232
Exprnode_get_branch(job->cursor, &true_branch, 0);
3233
Exprnode_get_branch(job->cursor, &false_branch, 1);
3234
if(!Exprnode_is_if(job->cursor, 0) ||
3235
true_branch==NULL || false_branch!=NULL) {
3238
sprintf(job->errmsg,
3239
"-elseif-operator found outside its proper range.");
3242
job->cursor= job->cursor->up;
3243
/* -elseif is equivalent to the three-step sequence : -endif -or -if
3244
( -endif has already been performed by following job->cursor->up ) */
3245
ret= Findjob_or(job, 0);
3248
ret= Findjob_if(job, 0);
3255
int Findjob_endif(struct FindjoB *job, int flag)
3257
struct ExprnodE *true_branch;
3259
if(!Findjob_cursor_complete(job,0)) {
3261
sprintf(job->errmsg,
3262
"Unary operator or expression expected, -endif found");
3265
if(job->cursor->up==NULL)
3266
goto improper_range;
3267
/* test wether parent node is -if */
3268
job->cursor= job->cursor->up;
3269
Exprnode_get_branch(job->cursor, &true_branch, 0);
3270
if(!Exprnode_is_if(job->cursor,0) || true_branch == NULL) {
3273
sprintf(job->errmsg, "-endif-mark found outside its proper range.");
3276
/* go to grand parent node */
3277
job->cursor= job->cursor->up;
3282
/* @param flag bit0= -wholename rather than -name
3284
int Findjob_set_name_expr(struct FindjoB *o, char *name_expr, int flag)
3286
char regexpr[2*SfileadrL+2];
3291
if(strlen(name_expr)>=SfileadrL)
3294
ret= Findjob_default_and(o, 0);
3298
t->test_type= (flag & 1 ? 13 : 1);
3299
name_re= (regex_t *) calloc(1, sizeof(regex_t));
3302
t->arg1= strdup(name_expr);
3303
if(t->arg1 == NULL) {
3304
free((char *) name_re);
3307
Xorriso__bourne_to_reg(name_expr, regexpr, 0);
3308
if(regcomp(name_re, regexpr, 0) != 0)
3315
int Findjob_set_file_type(struct FindjoB *o, char file_type, int flag)
3317
static char known[]= {"bcdpf-lsmeX"};
3321
ret= Findjob_default_and(o, 0);
3326
if(strchr(known, file_type) == NULL)
3330
t->arg1= calloc(1, 1);
3333
*((char *) t->arg1)= file_type;
3338
/* @param value -1= only without property, 1= only with property
3339
@param flag bit0= pseudo-test:
3340
if no operator is open, do nothing and return 2
3342
int Findjob_set_prop_filter(struct FindjoB *o, int test_type, int value,
3348
ret= Findjob_default_and(o, flag & 1);
3349
if(ret <= 0 || ret == 2)
3353
t->test_type= test_type;
3355
t->invert= !t->invert;
3360
/* @param value -1= only undamaged files, 1= only damaged files
3362
int Findjob_set_damage_filter(struct FindjoB *o, int value, int flag)
3366
ret= Findjob_set_prop_filter(o, 3, value, 0);
3371
int Findjob_set_lba_range(struct FindjoB *o, int start_lba, int count,
3377
ret= Findjob_default_and(o, 0);
3383
t->arg1= calloc(sizeof(int), 1);
3384
t->arg2= calloc(sizeof(int), 1);
3385
if(t->arg1 == NULL || t->arg2 == NULL)
3387
*((int *) t->arg1)= start_lba;
3389
*((int *) t->arg2)= start_lba + count - 1;
3391
*((int *) t->arg2)= start_lba - count + 1;
3396
/* @param value -1= files without ACL, 1= only files with ACL
3398
int Findjob_set_acl_filter(struct FindjoB *o, int value, int flag)
3402
ret= Findjob_set_prop_filter(o, 5, value, 0);
3407
/* @param value -1= files without xattr, 1= only files with xattr
3408
@param flag bit0=-has_any_xattr rather than -has_xattr
3410
int Findjob_set_xattr_filter(struct FindjoB *o, int value, int flag)
3414
ret= Findjob_set_prop_filter(o, (flag & 1 ? 14 : 6), value, 0);
3419
/* @param value -1= files without aaip, 1= only files with aaip
3421
int Findjob_set_aaip_filter(struct FindjoB *o, int value, int flag)
3425
ret= Findjob_set_prop_filter(o, 7, value, 0);
3430
/* @param value -1= files without filter, 1= files with filter
3432
int Findjob_set_filter_filter(struct FindjoB *o, int value, int flag)
3436
ret= Findjob_set_prop_filter(o, 8, value, 0);
3441
int Findjob_set_wanted_node(struct FindjoB *o, void *wanted_node, int flag)
3446
ret= Findjob_default_and(o, 0);
3452
t->arg1= wanted_node;
3457
int Findjob_set_commit_filter_2(struct FindjoB *o, int flag)
3461
ret= Findjob_default_and(o, 0);
3465
o->cursor->test->test_type= 10;
3470
int Findjob_set_decision(struct FindjoB *o, char *decision, int flag)
3475
ret= Findjob_default_and(o, 0);
3481
t->arg1= strdup(decision);
3488
/* @param value -1= true, 1= false
3489
@param flag bit0= pseudo-test:
3490
if no operator is open, do nothing and return 2
3492
int Findjob_set_false(struct FindjoB *o, int value, int flag)
3496
ret= Findjob_set_prop_filter(o, 0, value, flag & 1);
3501
int Findjob_set_prune(struct FindjoB *o, int flag)
3505
ret= Findjob_set_prop_filter(o, 12, 0, 0);
3510
int Findjob_set_found_path(struct FindjoB *o, char *path, int flag)
3512
if(o->found_path != NULL)
3513
free(o->found_path);
3515
o->found_path= strdup(path);
3516
if(o->found_path == NULL)
3519
o->found_path= NULL;
3524
int Findjob_get_found_path(struct FindjoB *o, char **path, int flag)
3526
*path= o->found_path;
3531
int Findjob_get_action(struct FindjoB *o, int flag)
3537
/* @return <0 error, >=0 see above struct FindjoB.action
3539
int Findjob_get_action_parms(struct FindjoB *o, char **target, char **text_2,
3540
uid_t *user, gid_t *group,
3541
mode_t *mode_and, mode_t *mode_or,
3542
int *type, time_t *date, struct FindjoB **subjob,
3549
*mode_and= o->mode_and;
3550
*mode_or= o->mode_or;
3558
int Findjob_test_2(struct XorrisO *xorriso, struct FindjoB *o,
3559
void *node, char *name, char *path,
3560
struct stat *boss_stbuf, struct stat *stbuf, int flag)
3564
ret= Exprnode_tree_value(xorriso, o->test_tree, -1,
3565
node, name, path, boss_stbuf, stbuf, 0);
3574
int Findjob_set_action_target(struct FindjoB *o, int action, char *target,
3583
int Findjob_set_action_type(struct FindjoB *o, int action, int type,
3592
int Findjob_set_action_text_2(struct FindjoB *o, int action, char *target,
3593
char* text_2, int flag)
3602
/* @param flag bit0= recursive
3604
int Findjob_set_action_chown(struct FindjoB *o, uid_t user,int flag)
3610
Findjob_destroy(&(o->subjob), 0);
3611
ret= Findjob_new(&(o->subjob), "", 0);
3614
Findjob_set_action_chown(o->subjob, user, 0);
3624
/* @param flag bit0= recursive
3626
int Findjob_set_action_chgrp(struct FindjoB *o, gid_t group, int flag)
3632
Findjob_destroy(&(o->subjob), 0);
3633
ret= Findjob_new(&(o->subjob), "", 0);
3636
Findjob_set_action_chgrp(o->subjob, group, 0);
3646
/* @param flag bit0= recursive
3648
int Findjob_set_action_chmod(struct FindjoB *o,
3649
mode_t mode_and, mode_t mode_or, int flag)
3655
Findjob_destroy(&(o->subjob), 0);
3656
ret= Findjob_new(&(o->subjob), "", 0);
3659
Findjob_set_action_chmod(o->subjob, mode_and, mode_or, 0);
3663
o->mode_and= mode_and;
3664
o->mode_or= mode_or;
3670
/* @param flag bit0= recursive
3672
int Findjob_set_action_ad(struct FindjoB *o, int type, time_t date, int flag)
3678
Findjob_destroy(&(o->subjob), 0);
3679
ret= Findjob_new(&(o->subjob), "", 0);
3682
Findjob_set_action_ad(o->subjob, type, date, 0);
3693
int Findjob_set_action_subjob(struct FindjoB *o, int action,
3694
struct FindjoB *subjob, int flag)
3697
Findjob_destroy(&(o->subjob), 0);
3703
int Findjob_set_action_found_path(struct FindjoB *o, int flag)
3706
Findjob_set_found_path(o, NULL, 0);
3711
/* ---------------------------- SplitparT ------------------------- */
3723
static char Splitpart_wordS[][16]= {"part_", "_of_", "_at_", "_with_", "_of_"};
3726
int Splitparts_new(struct SplitparT **o, int count, int flag)
3730
(*o)= TSOB_FELD(struct SplitparT, count);
3733
for(i= 0; i<count; i++) {
3736
(*o)[i].total_parts= 0;
3739
(*o)[i].total_bytes= 0;
3745
int Splitparts_destroy(struct SplitparT **o, int count, int flag)
3751
for(i= 0; i<count; i++) {
3752
if((*o)[i].name!=NULL)
3761
int Splitparts_set(struct SplitparT *o, int idx,
3762
char *name, int partno, int total_parts,
3763
off_t offset, off_t bytes, off_t total_bytes, int flag)
3765
if(o[idx].name!=NULL)
3767
o[idx].name= strdup(name);
3768
if(o[idx].name==NULL)
3770
o[idx].partno= partno;
3771
o[idx].total_parts= total_parts;
3772
o[idx].offset= offset;
3773
o[idx].bytes= bytes;
3774
o[idx].total_bytes= total_bytes;
3779
int Splitparts_get(struct SplitparT *o, int idx, char **name, int *partno,
3780
int *total_parts, off_t *offset, off_t *bytes,
3781
off_t *total_bytes, int flag)
3784
*partno= o[idx].partno;
3785
*total_parts= o[idx].total_parts;
3786
*offset= o[idx].offset;
3787
*bytes= o[idx].bytes;
3788
*total_bytes= o[idx].total_bytes;
3793
int Splitpart__read_next_num(char *base_pt, char **next_pt, off_t *num,
3796
char *cpt, *ept, scale[4];
3800
for(cpt= base_pt; *cpt!=0 && !isdigit(*cpt); cpt++);
3803
for(ept= cpt; *ept!=0 && isdigit(*ept); ept++)
3804
*num= (*num)*10+(*ept)-'0';
3808
sfak= Scanf_io_size(scale, 0);
3809
*num *= (off_t) sfak;
3817
int Splitpart__parse(char *name, int *partno, int *total_parts,
3818
off_t *offset, off_t *bytes, off_t *total_bytes, int flag)
3826
if(strncmp(cpt, Splitpart_wordS[0], strlen(Splitpart_wordS[0])) != 0)
3828
ret= Splitpart__read_next_num(cpt, &ept, &num, 0);
3833
if(strncmp(cpt, Splitpart_wordS[1], strlen(Splitpart_wordS[1])) != 0)
3835
ret= Splitpart__read_next_num(cpt, &ept, &num, 0);
3840
if(strncmp(cpt, Splitpart_wordS[2], strlen(Splitpart_wordS[2])) != 0)
3842
ret= Splitpart__read_next_num(cpt, &ept, offset, 0);
3846
if(strncmp(cpt, Splitpart_wordS[3], strlen(Splitpart_wordS[3])) != 0)
3848
ret= Splitpart__read_next_num(cpt, &ept, bytes, 0);
3852
if(strncmp(cpt, Splitpart_wordS[4], strlen(Splitpart_wordS[4])) != 0)
3854
ret= Splitpart__read_next_num(cpt, &ept, total_bytes, 0);
3863
int Splitpart__is_part_path(char *path, int flag)
3865
int partno, total_parts, ret;
3866
off_t offset, bytes, total_bytes;
3869
name= strrchr(path, '/');
3874
ret= Splitpart__parse(name, &partno, &total_parts, &offset, &bytes,
3880
/* part_#_of_#_at_#_with_#_of_#
3882
int Splitpart__compose(char *adr, int partno, int total_parts,
3883
off_t offset, off_t bytes, off_t total_bytes, int flag)
3885
sprintf(adr, "%s%d%s%d%s", Splitpart_wordS[0], partno, Splitpart_wordS[1],
3886
total_parts, Splitpart_wordS[2]);
3887
if((offset % (1024*1024))==0 && offset>0) {
3888
Sfile_off_t_text(adr+strlen(adr), offset / (1024*1024), 0);
3891
Sfile_off_t_text(adr+strlen(adr), offset, 0);
3892
strcat(adr, Splitpart_wordS[3]);
3893
if((bytes % (1024*1024))==0) {
3894
Sfile_off_t_text(adr+strlen(adr), bytes / (1024*1024), 0);
3897
Sfile_off_t_text(adr+strlen(adr), bytes, 0);
3898
strcat(adr, Splitpart_wordS[4]);
3899
Sfile_off_t_text(adr+strlen(adr), total_bytes, 0);
3904
int Splitparts_cmp(const void *v1, const void *v2)
3906
struct SplitparT *p1, *p2;
3908
p1= (struct SplitparT *) v1;
3909
p2= (struct SplitparT *) v2;
3911
if(p1->partno>p2->partno)
3913
if(p1->partno<p2->partno)
3915
if(p1->offset>p2->offset)
3917
if(p1->offset<p2->offset)
3923
int Splitparts_sort(struct SplitparT *o, int count, int flag)
3925
qsort(o, (size_t) count, sizeof(struct SplitparT), Splitparts_cmp);
3930
/* ---------------------------- End SplitparT ------------------------- */
3932
/* ------------------------------ ExclusionS ------------------------------ */
3936
/* Absolute input patterns which lead to not_paths */
3937
struct Xorriso_lsT *not_paths_descr;
3939
/* Actually banned absolute paths */
3940
struct Xorriso_lsT *not_paths;
3942
/* Input patterns which lead to not_leafs */
3943
struct Xorriso_lsT *not_leafs_descr;
3945
/* Compiled not_leaf patterns. Caution: not char[] but regex_t */
3946
struct Xorriso_lsT *not_leafs;
3951
int Exclusions_new(struct ExclusionS **o, int flag)
3953
struct ExclusionS *m;
3955
m= *o= TSOB_FELD(struct ExclusionS, 1);
3958
m->not_paths_descr= NULL;
3960
m->not_leafs_descr= NULL;
3966
int Exclusions_destroy(struct ExclusionS **o, int flag)
3968
struct Xorriso_lsT *s,*next;
3972
Xorriso_lst_destroy_all(&((*o)->not_paths_descr), 0);
3973
Xorriso_lst_destroy_all(&((*o)->not_paths), 0);
3974
Xorriso_lst_destroy_all(&((*o)->not_leafs_descr), 0);
3975
for(s= (*o)->not_leafs; s!=NULL; s= next){
3977
regfree((regex_t *) s->text);
3978
Xorriso_lst_destroy(&s, 0);
3986
int Exclusions_add_not_paths(struct ExclusionS *o, int descrc, char **descrs,
3987
int pathc, char **paths, int flag)
3989
struct Xorriso_lsT *s, *new_s;
3993
if(o->not_paths_descr!=NULL)
3994
for(s= o->not_paths_descr; s->next!=NULL; s= s->next);
3995
for(i= 0; i<descrc; i++) {
3996
ret= Xorriso_lst_new(&new_s, descrs[i], s, 0);
3999
if(o->not_paths_descr==NULL)
4000
o->not_paths_descr= new_s;
4004
if(o->not_paths!=NULL)
4005
for(s= o->not_paths; s->next!=NULL; s= s->next);
4006
for(i= 0; i<pathc; i++) {
4007
ret= Xorriso_lst_new(&new_s, paths[i], s, 0);
4010
if(o->not_paths==NULL)
4011
o->not_paths= new_s;
4018
/* @return -1=cannot store , 0=cannot compile regex , 1=ok
4020
int Exclusions_add_not_leafs(struct ExclusionS *o, char *not_leafs_descr,
4021
regex_t *re, int flag)
4025
ret= Xorriso_lst_append_binary(&(o->not_leafs_descr),
4026
not_leafs_descr, strlen(not_leafs_descr)+1, 0);
4029
ret= Xorriso_lst_append_binary(&(o->not_leafs), (char *) re, sizeof(regex_t), 0);
4036
/* @param flag bit0= whole subtree is banned with -not_paths
4037
@return 0=no match , 1=not_paths , 2=not_leafs, <0=error
4039
int Exclusions_match(struct ExclusionS *o, char *abs_path, int flag)
4041
struct Xorriso_lsT *s;
4042
char leaf[SfileadrL], *leaf_pt;
4043
regmatch_t match[1];
4044
int ret, was_non_slash, l;
4046
/* test abs_paths */
4048
for(s= o->not_paths; s!=NULL; s= s->next) {
4050
if(strncmp(abs_path, s->text, l)==0)
4051
if(abs_path[l]=='/' || abs_path[l]==0)
4055
for(s= o->not_paths; s!=NULL; s= s->next)
4056
if(strcmp(abs_path, s->text)==0)
4060
/* determine leafname */
4062
for(leaf_pt= abs_path+strlen(abs_path); leaf_pt>abs_path; leaf_pt--) {
4068
} else if(*leaf_pt!=0)
4071
if(strlen(leaf_pt)>=SfileadrL)
4073
strcpy(leaf, leaf_pt);
4074
leaf_pt= strchr(leaf, '/');
4078
/* test with leaf expressions */
4079
for(s= o->not_leafs; s!=NULL; s= s->next) {
4080
ret= regexec((regex_t *) s->text, leaf, 1, match, 0);
4088
int Exclusions_get_descrs(struct ExclusionS *o,
4089
struct Xorriso_lsT **not_paths_descr,
4090
struct Xorriso_lsT **not_leafs_descr, int flag)
4092
*not_paths_descr= o->not_paths_descr;
4093
*not_leafs_descr= o->not_leafs_descr;
4098
/* ---------------------------- End ExclusionS ---------------------------- */
4100
/* ------------------------------ PermstacK ------------------------------- */
4106
struct PermiteM *next;
4110
int Permstack_push(struct PermiteM **o, char *disk_path, struct stat *stbuf,
4115
m= TSOB_FELD(struct PermiteM,1);
4119
memcpy(&(m->stbuf), stbuf, sizeof(struct stat));
4122
m->disk_path= strdup(disk_path);
4123
if(m->disk_path==NULL)
4129
if(m->disk_path!=NULL)
4136
/* @param flag bit0= minimal transfer: access permissions only
4137
bit1= do not set timestamps
4139
int Permstack_pop(struct PermiteM **o, struct PermiteM *stopper,
4140
struct XorrisO *xorriso, int flag)
4143
char sfe[5*SfileadrL];
4144
struct utimbuf utime_buffer;
4145
struct PermiteM *m, *m_next;
4149
for(m= *o; m!=NULL; m= m->next)
4150
if(m->next==stopper)
4153
sprintf(xorriso->info_text,
4154
"Program error: Permstack_pop() : cannot find stopper");
4155
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
4159
for(m= *o; m!=stopper; m= m_next) {
4160
ret= chmod(m->disk_path, m->stbuf.st_mode);
4163
sprintf(xorriso->info_text,
4164
"Cannot change access permissions of disk directory: chmod %o %s",
4165
(unsigned int) (m->stbuf.st_mode & 07777),
4166
Text_shellsafe(m->disk_path, sfe, 0));
4167
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE",
4172
chown(m->disk_path, m->stbuf.st_uid, m->stbuf.st_gid);
4173
/* don't complain if it fails */
4175
utime_buffer.actime= m->stbuf.st_atime;
4176
utime_buffer.modtime= m->stbuf.st_mtime;
4177
ret= utime(m->disk_path,&utime_buffer);
4178
if(ret==-1 && xorriso!=NULL) {
4179
sprintf(xorriso->info_text,
4180
"Cannot change timestamps of disk directory: %s",
4181
Text_shellsafe(m->disk_path, sfe, 0));
4182
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE",
4196
/* ---------------------------- End PermstacK ----------------------------- */
4198
/* ------------------------------ SpotlisT -------------------------------- */
4200
struct SpotlistiteM {
4204
struct SpotlistiteM *next;
4208
int Spotlistitem_new(struct SpotlistiteM **o, int start_lba, int blocks,
4209
int quality, int flag)
4211
struct SpotlistiteM *m;
4213
m= TSOB_FELD(struct SpotlistiteM,1);
4217
m->start_lba= start_lba;
4219
m->quality= quality;
4225
int Spotlistitem_destroy(struct SpotlistiteM **o, int flag)
4236
struct SpotlistiteM *list_start;
4237
struct SpotlistiteM *list_end;
4239
struct SpotlistiteM *current_item;
4244
int Spotlist_new(struct SpotlisT **o, int flag)
4248
m= TSOB_FELD(struct SpotlisT,1);
4252
m->list_start= NULL;
4255
m->current_item= NULL;
4261
int Spotlist_destroy(struct SpotlisT **o, int flag)
4264
struct SpotlistiteM *li, *next_li;
4269
for(li= m->list_start; li != NULL; li= next_li) {
4271
Spotlistitem_destroy(&li, 0);
4279
int Spotlist_add_item(struct SpotlisT *o, int start_lba, int blocks,
4280
int quality, int flag)
4283
struct SpotlistiteM *li;
4284
static int debug_verbous= 0;
4286
ret= Spotlistitem_new(&li, start_lba, blocks, quality, 0);
4289
if(o->list_end != NULL)
4290
o->list_end->next= li;
4292
if(o->list_start == NULL)
4296
if(debug_verbous) {char quality_name[80];
4297
fprintf(stderr, "debug: lba %10d , size %10d , quality '%s'\n",
4298
start_lba, blocks, Spotlist__quality_name(quality, quality_name,
4299
Xorriso_read_quality_invaliD, 0) + 2);
4306
int Spotlist_count(struct SpotlisT *o, int flag)
4308
return o->list_count;
4312
int Spotlist_block_count(struct SpotlisT *o, int flag)
4315
struct SpotlistiteM *li;
4317
for(li= o->list_start; li != NULL; li= li->next) {
4318
if(li->start_lba + li->blocks > list_blocks)
4319
list_blocks= li->start_lba + li->blocks;
4321
return(list_blocks);
4325
int Spotlist_sector_size(struct SpotlisT *o, int read_chunk, int flag)
4328
struct SpotlistiteM *li;
4330
sector_size= read_chunk * 2048;
4331
for(li= o->list_start; li != NULL; li= li->next) {
4332
if((li->start_lba % read_chunk) || (li->blocks % read_chunk)) {
4337
return(sector_size);
4341
int Spotlist_get_item(struct SpotlisT *o, int idx,
4342
int *start_lba, int *blocks, int *quality, int flag)
4345
struct SpotlistiteM *li;
4347
if(idx < 0 || idx > o->list_count)
4349
if(idx == o->current_idx && o->current_item != NULL)
4350
li= o->current_item;
4351
else if(idx == o->current_idx + 1 && o->current_item != NULL) {
4352
li= o->current_item->next;
4355
for(i= 0; i < idx; i++)
4358
o->current_item= li;
4359
o->current_idx= idx;
4360
*start_lba= li->start_lba;
4361
*blocks= li->blocks;
4362
*quality= li->quality;
4367
char *Spotlist__quality_name(int quality, char name[80], int bad_limit,
4370
if(quality == Xorriso_read_quality_untesteD ||
4371
quality == Xorriso_read_quality_tao_enD ||
4372
quality == Xorriso_read_quality_off_tracK)
4374
else if(quality <= bad_limit)
4378
if(quality == Xorriso_read_quality_gooD)
4379
strcat(name, "good");
4380
else if(quality == Xorriso_read_quality_md5_matcH)
4381
strcat(name, "md5_match");
4382
else if(quality == Xorriso_read_quality_sloW)
4383
strcat(name, "slow");
4384
else if(quality == Xorriso_read_quality_partiaL)
4385
strcat(name, "partial");
4386
else if(quality == Xorriso_read_quality_valiD)
4387
strcat(name, "valid");
4388
else if(quality == Xorriso_read_quality_untesteD)
4389
strcat(name, "untested");
4390
else if(quality == Xorriso_read_quality_invaliD)
4391
strcat(name, "invalid");
4392
else if(quality == Xorriso_read_quality_tao_enD)
4393
strcat(name, "tao_end");
4394
else if(quality == Xorriso_read_quality_off_tracK)
4395
strcat(name, "off_track");
4396
else if(quality == Xorriso_read_quality_md5_mismatcH)
4397
strcat(name, "md5_mismatch");
4398
else if(quality == Xorriso_read_quality_unreadablE)
4399
strcat(name, "unreadable");
4401
sprintf(name, "0 0x%8.8X", (unsigned int) quality);
4406
/* ---------------------------- End SpotlisT ------------------------------ */
4408
/* ---------------------------- SectorbitmaP ------------------------------ */
4410
struct SectorbitmaP {
4418
int Sectorbitmap_new(struct SectorbitmaP **o, int sectors, int sector_size,
4421
struct SectorbitmaP *m;
4423
m= TSOB_FELD(struct SectorbitmaP,1);
4427
m->sectors= sectors;
4428
m->sector_size= sector_size;
4430
m->map_size= sectors / 8 + 1;
4432
m->map= calloc(m->map_size, 1);
4437
Sectorbitmap_destroy(o, 0);
4442
int Sectorbitmap_destroy(struct SectorbitmaP **o, int flag)
4446
if((*o)->map != NULL)
4447
free((char *) (*o)->map);
4454
int Sectorbitmap_from_file(struct SectorbitmaP **o, char *path, char *msg,
4455
int *os_errno, int flag)
4457
int ret, fd= -1, sectors, sector_size, i, todo, map_size, skip;
4459
unsigned char buf[1024];
4464
fd= open(path, O_RDONLY);
4468
strcpy(msg, "Cannot open path ");
4469
Text_shellsafe(path, msg+strlen(msg), 0);
4473
ret= read(fd, buf, 32);
4479
strcpy(msg, "Not a sector bitmap file: ");
4480
Text_shellsafe(path, msg+strlen(msg), 0);
4484
if(strncmp((char *) buf, "xorriso sector bitmap v1 ", 32) == 0)
4486
else if(strncmp((char *) buf, "xorriso sector bitmap v2 ", 25) == 0) {
4488
sscanf(((char *) buf) + 25, "%d", &skip);
4490
{ret= 0; goto wrong_filetype;}
4491
for(i= 0; i < skip; i+= sizeof(buf)) {
4495
ret= read(fd, buf, todo);
4497
goto wrong_filetype;
4500
{ret= 0; goto wrong_filetype;}
4501
ret= read(fd, buf, 8);
4503
goto wrong_filetype;
4504
sectors= (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3];
4505
sector_size= (buf[4] << 24) | (buf[5] << 16) | (buf[6] << 8) | buf[7];
4506
if(sectors <= 0 || sector_size <= 0)
4507
goto wrong_filetype;
4508
ret= Sectorbitmap_new(o, sectors, sector_size, 0);
4511
sprintf(msg, "Cannot allocate bitmap memory for %d sectors", sectors);
4515
map_size= (*o)->map_size;
4516
for(i= 0; i < map_size; i+= sizeof(buf)) {
4518
if(i + todo > map_size)
4520
ret= read(fd, buf, todo);
4522
goto wrong_filetype;
4523
memcpy(map + i, buf, todo);
4530
Sectorbitmap_destroy(o, 0);
4535
int Sectorbitmap_to_file(struct SectorbitmaP *o, char *path, char *info,
4536
char *msg, int *os_errno, int flag)
4538
int ret, fd= -1, j, l;
4539
unsigned char buf[40];
4542
fd= open(path, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR);
4546
strcpy(msg, "Cannot open path ");
4547
Text_shellsafe(path, msg+strlen(msg), 0);
4556
strcpy(msg, "Info string is longer than 999999 bytes");
4559
sprintf((char *) buf, "xorriso sector bitmap v2 %-6d\n", l);
4561
ret= write(fd, buf, 32);
4566
strcpy(msg, "Cannot write to ");
4567
Text_shellsafe(path, msg+strlen(msg), 0);
4572
ret= write(fd, info, l);
4577
for(j= 0; j < 4; j++) {
4578
buf[j]= o->sectors >> (24 - j * 8);
4579
buf[j+4]= o->sector_size >> (24 - j * 8);
4581
ret= write(fd, buf, 8);
4584
ret= write(fd, o->map, o->map_size);
4585
if(ret != o->map_size)
4596
/* @param flag bit0= sector bit value
4598
int Sectorbitmap_set(struct SectorbitmaP *o, int sector, int flag)
4600
if(sector < 0 || sector >= o->sectors)
4603
o->map[sector / 8]|= 1 << (sector % 8);
4605
o->map[sector / 8]&= ~(1 << (sector % 8));
4610
/* @param flag bit0= sector bit value
4612
int Sectorbitmap_set_range(struct SectorbitmaP *o,
4613
int start_sector, int sectors, int flag)
4615
int start_i, end_i, i;
4616
unsigned char value;
4618
if(start_sector < 0 || start_sector + sectors > o->sectors || sectors < 1)
4624
start_i= start_sector / 8;
4625
end_i= (start_sector + sectors - 1) / 8;
4626
for(i= start_sector; i / 8 == start_i && i < start_sector + sectors; i++)
4627
Sectorbitmap_set(o, i, flag & 1);
4628
for(i= start_i + 1; i < end_i; i++)
4631
for(i= end_i * 8; i < start_sector + sectors; i++)
4632
Sectorbitmap_set(o, i, flag & 1);
4637
int Sectorbitmap_is_set(struct SectorbitmaP *o, int sector, int flag)
4639
if(sector < 0 || sector >= o->sectors)
4641
return(!! (o->map[sector / 8] & (1 << (sector % 8))));
4645
int Sectorbitmap_bytes_are_set(struct SectorbitmaP *o,
4646
off_t start_byte, off_t end_byte, int flag)
4650
end_sector= end_byte / o->sector_size;
4651
for(i= start_byte / o->sector_size; i <= end_sector; i++)
4652
if(!Sectorbitmap_is_set(o, i, 0))
4658
int Sectorbitmap_get_layout(struct SectorbitmaP *o,
4659
int *sectors, int *sector_size, int flag)
4661
*sectors= o->sectors;
4662
*sector_size= o->sector_size;
4667
int Sectorbitmap_copy(struct SectorbitmaP *from, struct SectorbitmaP *to,
4670
int i, run_start, run_value, start_sec, limit_sec, start_aligned;
4673
if(((off_t) from->sectors) * ((off_t) from->sector_size) >
4674
((off_t) to->sectors) * ((off_t) to->sector_size))
4676
if(from->sector_size == to->sector_size) {
4677
for(i= 0; i < from->map_size; i++)
4678
to->map[i]= from->map[i];
4682
run_value= Sectorbitmap_is_set(from, 0, 0);
4683
for(i= 1; i <= from->sectors; i++) {
4684
if(i < from->sectors)
4685
if(Sectorbitmap_is_set(from, i, 0) == run_value)
4687
start_sec= run_start * from->sector_size / to->sector_size;
4689
(start_sec * to->sector_size == run_start * from->sector_size);
4690
limit_sec= i * from->sector_size / to->sector_size;
4691
end_complete= (limit_sec * to->sector_size == i * from->sector_size);
4699
if(start_sec < limit_sec)
4700
Sectorbitmap_set_range(to, start_sec, limit_sec - 1 - start_sec,
4702
run_value= !run_value;
4709
int Sectorbitmap_clone(struct SectorbitmaP *from, struct SectorbitmaP **clone,
4714
ret= Sectorbitmap_new(clone, from->sectors, from->sector_size, 0);
4717
ret= Sectorbitmap_copy(from, *clone, 0);
4719
Sectorbitmap_destroy(clone, 0);
4724
/* -------------------------- End SectorbitmaP ---------------------------- */
4726
/* ---------------------------- CheckmediajoB ----------------------------- */
4728
int Checkmediajob_new(struct CheckmediajoB **o, int flag)
4730
struct CheckmediajoB *m;
4732
m= TSOB_FELD(struct CheckmediajoB,1);
4739
m->min_block_size= 0;
4741
m->start_time= time(NULL);
4742
m->time_limit= 28800;
4743
m->item_limit= 100000;
4744
strcpy(m->abort_file_path, "/var/opt/xorriso/do_abort_check_media");
4745
m->data_to_path[0]= 0;
4747
m->data_to_offset= 0;
4748
m->data_to_limit= -1;
4750
m->patch_lba0_msc1= -1;
4751
m->sector_map_path[0]= 0;
4752
m->sector_map= NULL;
4753
m->map_with_volid= 0;
4756
strcpy(m->event_severity, "ALL");
4757
m->slow_threshold_seq= 1.0;
4758
m->untested_valid= 0;
4763
int Checkmediajob_destroy(struct CheckmediajoB **o, int flag)
4767
if((*o)->data_to_fd != -1)
4768
close((*o)->data_to_fd);
4769
Sectorbitmap_destroy(&((*o)->sector_map), 0);
4776
int Checkmediajob_copy(struct CheckmediajoB *from, struct CheckmediajoB *to,
4779
to->use_dev= from->use_dev;
4780
to->min_lba= from->min_lba;
4781
to->max_lba= from->max_lba;
4782
to->min_block_size= from->min_block_size;
4783
to->mode= from->mode;
4784
to->time_limit= from->time_limit;
4785
to->item_limit= from->item_limit;
4786
strcpy(to->abort_file_path, from->abort_file_path);
4787
strcpy(to->data_to_path, from->data_to_path);
4788
/* not copied: data_to_fd */
4789
to->data_to_offset= from->data_to_offset;
4790
to->data_to_limit= from->data_to_limit;
4791
to->patch_lba0= from->patch_lba0;
4792
to->patch_lba0_msc1= from->patch_lba0_msc1;
4793
strcpy(to->sector_map_path, from->sector_map_path);
4794
/* not copied: sector_map */
4795
to->map_with_volid= from->map_with_volid;
4796
to->retry= from->retry;
4797
to->report_mode= from->report_mode;
4798
strcpy(to->event_severity, from->event_severity);
4799
to->slow_threshold_seq= from->slow_threshold_seq;
4800
to->untested_valid= from->untested_valid;
4805
/* -------------------------- End CheckmediajoB --------------------------- */
4807
/* ------------------------------- Xorriso -------------------------------- */
4810
/** The list of startup file names */
4811
#define Xorriso_rc_nuM 4
4813
static char Xorriso_sys_rc_nameS[Xorriso_rc_nuM][80]= {
4814
"/etc/default/xorriso",
4815
"/etc/opt/xorriso/rc",
4816
"/etc/xorriso/xorriso.conf",
4817
"placeholder for $HOME/.xorrisorc"
4821
int Xorriso_new(struct XorrisO ** xorriso,char *progname, int flag)
4825
char leafname[SfileadrL];
4827
*xorriso= m= TSOB_FELD(struct XorrisO,1);
4830
m->libs_are_started= 0;
4831
strncpy(m->progname,progname,sizeof(m->progname)-1);
4832
m->progname[sizeof(m->progname)-1]= 0;
4833
if(getcwd(m->initial_wdx,sizeof(m->initial_wdx)-1)==NULL)
4834
m->initial_wdx[0]= 0;
4836
m->argument_emulation= 0;
4838
m->rc_filename_count= Xorriso_rc_nuM;
4839
for(i=0;i<m->rc_filename_count-1;i++)
4840
strcpy(m->rc_filenames[i],Xorriso_sys_rc_nameS[i]);
4841
m->rc_filenames[m->rc_filename_count-1][0]= 0;
4844
strcpy(m->wdx, m->initial_wdx);
4845
m->did_something_useful= 0;
4848
strcpy(m->list_delimiter, "--");
4853
m->scdbackup_tag_name[0]= 0;
4854
m->scdbackup_tag_time[0]= 0;
4855
m->scdbackup_tag_written[0]= 0;
4856
m->scdbackup_tag_listname[0]= 0;
4857
m->relax_compliance= 0;
4858
m->do_follow_pattern= 1;
4859
m->do_follow_param= 0;
4860
m->do_follow_links= 0;
4861
m->follow_link_limit= 100;
4862
m->do_follow_mount= 1;
4863
m->do_global_uid= 0;
4865
strcpy(m->volid, "ISOIMAGE");
4866
m->volid_default= 1;
4867
m->loaded_volid[0]= 0;
4868
m->assert_volid[0]= 0;
4869
m->assert_volid_sev[0]= 0;
4871
m->application_id[0]= 0;
4874
m->session_logfile[0]= 0;
4876
m->session_blocks= 0;
4877
m->do_global_gid= 0;
4879
m->do_global_mode= 0;
4880
m->global_dir_mode= 0555;
4881
m->global_file_mode= 0444;
4883
m->filter_list_closed= 0;
4884
m->zlib_level_default= m->zlib_level= 6;
4885
m->zisofs_block_size= m->zisofs_block_size_default= (1 << 15);
4886
m->zisofs_by_magic= 0;
4889
m->drive_blacklist= NULL;
4890
m->drive_greylist= NULL;
4891
m->drive_whitelist= NULL;
4892
m->toc_emulation_flag= 0;
4893
m->image_start_mode= 0;
4894
m->image_start_value[0]= 0;
4895
m->drives_exclusive= 1;
4896
m->do_calm_drive= 1;
4898
m->in_drive_handle= NULL;
4899
m->in_volset_handle= NULL;
4900
m->in_charset= NULL;
4901
m->isofs_st_out= time(0) - 1;
4902
m->indev_is_exclusive= 1;
4904
m->volset_change_pending= 0;
4905
m->no_volset_present= 0;
4906
m->in_sector_map= NULL;
4907
m->check_media_default= NULL;
4908
m->check_media_bad_limit= Xorriso_read_quality_invaliD;
4910
m->out_drive_handle= NULL;
4911
m->out_charset= NULL;
4913
m->outdev_is_exclusive= 1;
4914
m->grow_blindly_msc2= -1;
4915
m->ban_stdio_write= 0;
4919
m->fs= 4*512; /* 4 MiB */
4920
m->padding= 300*1024;
4922
m->do_stream_recording= 0;
4925
m->keep_boot_image= 0;
4926
m->boot_image_cat_path[0]= 0;
4928
m->boot_platform_id= 0x00; /* El Torito Boot Catalog Platform ID: 0 = 80x86 */
4929
m->patch_isolinux_image= 0;
4930
m->boot_image_bin_path[0]= 0;
4931
m->boot_image_bin_form[0]= 0;
4932
m->boot_image_emul= 0;
4933
m->boot_image_load_size= 4 * 512; /* hearsay out of libisofs/demo/iso.c */
4934
memset(m->boot_id_string, 0, sizeof(m->boot_id_string));
4935
memset(m->boot_selection_crit, 0, sizeof(m->boot_selection_crit));
4937
#ifdef Xorriso_with_isohybriD
4938
m->boot_image_isohybrid= 1;
4940
m->boot_image_isohybrid= 0;
4943
m->boot_efi_default= 0;
4945
#ifndef Xorriso_multi_booT
4946
m->boot_image_efi_path[0]= 0;
4949
m->system_area_disk_path[0]= 0;
4950
m->system_area_options= 0;
4951
m->patch_system_area= 0;
4952
m->vol_creation_time= 0;
4953
m->vol_modification_time= 0;
4954
m->vol_expiration_time= 0;
4955
m->vol_effective_time= 0;
4957
m->loaded_boot_bin_lba= 0;
4958
m->loaded_boot_cat_path[0]= 0;
4959
m->allow_graft_points= 0;
4960
m->allow_restore= 0;
4961
m->do_concat_split= 1;
4962
m->do_auto_chmod= 0;
4963
m->do_restore_sort_lba= 0;
4965
m->bsl_interpretation= 0;
4967
m->structured_search= 1;
4968
m->do_iso_rr_pattern= 1;
4969
m->do_disk_pattern= 2;
4970
m->temp_mem_limit= 16*1024*1024;
4971
m->file_size_limit= Xorriso_default_file_size_limiT;
4972
m->disk_exclusions= NULL;
4973
m->disk_excl_mode= 1;
4975
m->result_page_length= 0;
4976
m->result_page_width= 80;
4978
m->packet_output= 0;
4979
for(i=0; i<4; i++) {
4980
m->logfile[i][0]= 0;
4981
m->logfile_fp[i]= NULL;
4984
for(i= 0; i < Xorriso_max_outlist_stacK; i++) {
4985
m->result_msglists[i]= NULL;
4986
m->info_msglists[i]= NULL;
4987
m->msglist_flags[i]= 0;
4989
m->msglist_stackfill= 0;
4990
m->status_history_max= Xorriso_status_history_maX;
4992
strcpy(m->report_about_text, "UPDATE");
4993
Xorriso__text_to_sev(m->report_about_text, &m->report_about_severity, 0);
4994
m->library_msg_direct_print= 0;
4995
strcpy(m->abort_on_text,"FATAL");
4996
Xorriso__text_to_sev(m->abort_on_text, &m->abort_on_severity, 0);
4997
m->problem_status= 0;
4998
m->problem_status_text[0]= 0;
4999
m->errfile_log[0]= 0;
5001
m->errfile_fp= NULL;
5003
m->img_read_error_mode= 2; /* abort faulty image reading with FATAL */
5004
m->extract_error_mode= 1; /* keep extracted files after read error */
5005
strcpy(m->return_with_text, "SORRY");
5006
Xorriso__text_to_sev(m->return_with_text, &m->return_with_severity, 0);
5007
m->return_with_value= 32;
5008
m->eternal_problem_status= 0;
5009
m->eternal_problem_status_text[0]= 0;
5011
/* >>> ??? how to initialize m->match[0] ? */
5012
m->re_constants= NULL;
5019
m->pending_option[0]= 0;
5020
m->request_to_abort= 0;
5021
m->request_not_to_ask= 0;
5023
m->re_failed_at= -1;
5028
m->pacifier_style= 0;
5029
m->pacifier_interval= 1.0;
5030
m->pacifier_count= 0;
5031
m->pacifier_total= 0;
5032
m->pacifier_byte_count= 0;
5033
m->pacifier_fifo= NULL;
5035
m->last_update_time= 0.0;
5036
m->find_compare_result= 1;
5037
m->find_check_md5_result= 0;
5040
m->node_array_size= 0;
5041
m->node_array= NULL;
5042
m->node_disk_prefixes= NULL;
5043
m->node_img_prefixes= NULL;
5047
m->hln_targets= NULL;
5048
m->hln_change_pending= 0;
5049
m->di_do_widen= NULL;
5050
m->di_disk_paths= NULL;
5051
m->di_iso_paths= NULL;
5053
m->node_targets_availmem= 0;
5058
m->perm_stack= NULL;
5060
m->result_line[0]= 0;
5061
m->result_line_counter= 0;
5062
m->result_page_counter= 0;
5063
m->result_open_line_len= 0;
5067
ret= Sfile_leafname(progname, leafname, 0);
5070
if(strcmp(leafname, "osirrox")==0) {
5071
m->allow_restore= 1;
5072
m->drives_exclusive= 0;
5073
} else if(strcmp(leafname, "xorrisofs")==0 || strcmp(leafname, "genisofs")==0 ||
5074
strcmp(leafname, "mkisofs")==0 || strcmp(leafname, "genisoimage")==0) {
5075
m->argument_emulation= 1;
5076
m->pacifier_style= 1;
5077
Xorriso_protect_stdout(*xorriso, 0);
5078
} else if(strcmp(leafname, "xorrecord")==0 || strcmp(leafname, "wodim")==0 ||
5079
strcmp(leafname, "cdrecord")==0 || strcmp(leafname, "cdrskin")==0) {
5080
m->argument_emulation= 2;
5081
m->pacifier_style= 2;
5083
ret= Exclusions_new(&(m->disk_exclusions), 0);
5086
Xorriso_relax_compliance(m, "default", 0);
5087
ret= Xorriso_lst_new(&(m->drive_greylist), "/dev", m->drive_greylist, 1);
5093
Xorriso_destroy(xorriso, 0);
5098
int Xorriso_destroy_re(struct XorrisO *m, int flag)
5103
for(i=0;i<m->re_fill;i++) {
5104
if(m->re_constants!=NULL)
5105
if(m->re_constants[i]!=NULL)
5106
continue; /* ,->re[i] was never subject to regcomp() */
5107
regfree(&(m->re[i]));
5109
free((char *) m->re);
5113
if(m->re_constants!=NULL) {
5114
for(i=0;i<m->re_fill;i++)
5115
if(m->re_constants[i]!=NULL)
5116
free(m->re_constants[i]);
5117
free((char *) m->re_constants);
5118
m->re_constants= NULL;
5126
/* @param flag bit0= global shutdown of libraries */
5127
int Xorriso_destroy(struct XorrisO **xorriso, int flag)
5134
if(m->in_charset!=NULL)
5135
free(m->in_charset);
5136
if(m->out_charset!=NULL)
5137
free(m->out_charset);
5138
Xorriso_destroy_re(m,0);
5139
Exclusions_destroy(&(m->disk_exclusions), 0);
5140
Xorriso_destroy_all_extf(m, 0);
5141
Xorriso_lst_destroy_all(&(m->drive_blacklist), 0);
5142
Xorriso_lst_destroy_all(&(m->drive_greylist), 0);
5143
Xorriso_lst_destroy_all(&(m->drive_whitelist), 0);
5144
Xorriso_destroy_node_array(m, 0);
5145
Xorriso_destroy_hln_array(m, 0);
5146
Xorriso_destroy_di_array(m, 0);
5148
Xorriso_detach_libraries(m, flag&1);
5156
int Xorriso__preset_signal_behavior(int behavior, int flag)
5158
if(behavior < 0 || behavior > 1)
5160
Xorriso_signal_behavioR= behavior;
5165
int Xorriso__get_signal_behavior(int flag)
5167
return(Xorriso_signal_behavioR);
5171
int Xorriso_dialog_input(struct XorrisO *xorriso, char line[], int linesize,
5174
bit0= do not write to history
5175
bit1= do not read input (but eventually write to history)
5176
bit2= do not write to history line which begin with "-history:" or "-history "
5179
char *cpt= NULL, **argv= NULL, *linept, *why_append= "";
5180
int ret, argc= 0, base_length= 0, l, append_line;
5181
#ifdef Xorriso_with_readlinE
5182
static char last_input[SfileadrL]= {""};
5183
#endif /* ! Xorriso_with_readlinE */
5188
gettimeofday(&tv,&tz);
5189
tdiff= tv.tv_sec+(1.e-6*(double) tv.tv_usec);
5195
#ifdef Xorriso_with_readlinE
5197
if(xorriso->use_stdin || xorriso->dev_fd_1>=0) {
5200
if(Sfile_fgets_n(linept,linesize - base_length - 1, stdin,
5201
(xorriso->dialog == 2)) == NULL) {
5202
/* need a very dramatic end */
5203
kill(getpid(),SIGHUP);
5206
goto process_single;
5213
/* need a very dramatic end */
5214
kill(getpid(),SIGHUP);
5218
if(l >= linesize - base_length - 1) {
5219
strncpy(linept, cpt, linesize - 1);
5220
line[sizeof(line)-1]= 0;
5221
sprintf(xorriso->info_text,"Input line too long !");
5222
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
5225
strcpy(linept, cpt);
5230
#else /* Xorriso_with_readlinE */
5234
if(Sfile_fgets_n(linept, linesize - base_length - 1, stdin,
5235
(xorriso->dialog == 2)) == NULL) {
5236
/* need a very dramatic end */
5237
kill(getpid(),SIGHUP);
5241
#endif /* ! Xorriso_with_readlinE */
5243
if(xorriso->dialog == 2) {
5245
if(linept != line && strcmp(linept, "@@@") == 0) {
5246
sprintf(xorriso->info_text, "Incomplete input line cleared by %s",
5248
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE",0);
5252
sprintf(xorriso->info_text, "-------------------------------------\n");
5253
Xorriso_info(xorriso,0);
5254
sprintf(xorriso->info_text, "Enter new text for empty input line :\n");
5255
Xorriso_info(xorriso,0);
5259
ret= Sfile_make_argv("", line, &argc, &argv, 16);
5262
if(ret == 0 && !append_line) {
5263
/* append a newline character */
5264
if(l >= linesize - 1) {
5265
sprintf(xorriso->info_text,"Input line too long !");
5266
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
5272
why_append= "Quoted newline char";
5274
if(l > 0 && !append_line)
5275
if(line[l - 1] == '\\') {
5278
why_append= "Trailing backslash ";
5281
base_length= strlen(line);
5282
linept= line + base_length;
5283
sprintf(xorriso->info_text,
5284
"---------------------------------------------------------------\n");
5285
Xorriso_info(xorriso,0);
5286
sprintf(xorriso->info_text,
5287
"%s : Enter rest of line (or @@@ to clear it) :\n", why_append);
5288
Xorriso_info(xorriso,0);
5293
#ifdef Xorriso_with_readlinE
5295
if(line[0]!=0 && strcmp(last_input,line)!=0 && !(flag&1))
5297
(strncmp(line,"-history:",9)==0 || strncmp(line,"-history ",9)==0))) {
5299
strncpy(last_input,line,sizeof(last_input)-1);
5300
last_input[sizeof(last_input)-1]= 0;
5303
#endif /* ! Xorriso_with_readlinE */
5309
gettimeofday(&tv,&tz);
5310
xorriso->idle_time+= tv.tv_sec+(1.e-6*(double) tv.tv_usec)-tdiff;
5315
int Xorriso_request_confirmation(struct XorrisO *xorriso, int flag)
5317
bit0= important operation going on:
5318
demand confirmation of abort, only abort on @@@
5319
bit1= mark '@' and '@@' by return 4
5320
bit2= accept: i|n= ignore | do not remove , r|y= retry | remove , q|x= abort
5321
bit3= @@@ = 'done reading' rather than 'abort'
5322
bit4= in non-dialog mode return 6 rather than 1
5324
/* return: <=0 error
5325
1= go on | do not remove existing file
5327
3= redo request for confirmation
5330
6= retry failed operation | remove existing file
5334
char line[SfileadrL],*cpt,previous_line[SfileadrL];
5335
char *abort_req_text,*abort_really_text;
5337
if(!xorriso->dialog) {
5343
abort_req_text= "request to end";
5344
abort_really_text= "done reading";
5346
abort_req_text= "request to abort";
5347
abort_really_text= "abort this command";
5349
ret= Xorriso_dialog_input(xorriso,line,sizeof(line),1);
5350
xorriso->result_line_counter= 0;
5351
xorriso->result_page_counter++;
5353
if(xorriso->result_page_length>0)
5354
xorriso->result_page_length= -xorriso->result_page_length;
5357
if(strcmp(cpt,"@@@")==0 ||
5358
strcmp(cpt,"x")==0 || strcmp(cpt,"X")==0 ||
5359
strcmp(cpt,"q")==0 || strcmp(cpt,"Q")==0) {
5361
strcpy(previous_line,cpt);
5362
sprintf(xorriso->info_text,
5363
"... [%s = %s registered. Really %s ? (y/n) ] ...\n",
5364
cpt,abort_req_text,abort_really_text);
5365
Xorriso_info(xorriso,0);
5366
ret= Xorriso_dialog_input(xorriso,line,sizeof(line),1);
5370
if(strcmp(cpt,previous_line)==0 ||
5371
((*cpt=='Y' || *cpt=='y' || *cpt=='j' || *cpt=='J' || *cpt=='1') &&
5373
xorriso->request_to_abort= 1;
5374
sprintf(xorriso->info_text,
5375
"------- ( %s confirmed )\n",abort_req_text);
5376
Xorriso_info(xorriso,0);
5379
sprintf(xorriso->info_text, "....... ( %s revoked )\n",abort_req_text);
5380
Xorriso_info(xorriso,0);
5383
xorriso->request_to_abort= 1;
5384
sprintf(xorriso->info_text,
5385
"----------- [%s = request to abort registered. Operation ends ] ------------\n",
5387
Xorriso_info(xorriso,0);
5389
} else if(*cpt=='@') {
5390
if(strcmp(cpt,"@@")==0) {
5393
} else if(strcmp(cpt,"@")==0) {
5395
if(xorriso->result_page_length>0)
5396
xorriso->result_page_length= -xorriso->result_page_length;
5398
sprintf(xorriso->info_text,
5399
"... [@ = prompt suppression registered. Prompting disabled temporarily ] ...\n");
5400
Xorriso_info(xorriso,0);
5404
Xorriso_dialog_input(xorriso,cpt,strlen(line)+1,2); /* write to history */
5405
sprintf(xorriso->info_text,
5406
"--- Unrecognized input beginning with @. Please enter someting else.\n");
5407
Xorriso_info(xorriso,0);
5417
if(strcmp(cpt,"i")==0 || strcmp(cpt,"I")==0 ||
5418
strcmp(cpt,"n")==0 || strcmp(cpt,"N")==0 ||
5421
} else if(strcmp(cpt,"r")==0 || strcmp(cpt,"R")==0 ||
5422
strcmp(cpt,"y")==0 || strcmp(cpt,"Y")==0) {
5425
/* >>> unknown input */
5426
sprintf(xorriso->info_text,
5427
"--- Please enter one of : empty line, i,n, r,y, q,x, @, @@@\n");
5428
Xorriso_info(xorriso,0);
5432
} else if(*cpt!=0 && !(flag&1)) {
5433
Xorriso_dialog_input(xorriso,cpt,strlen(line)+1,2); /* write to history */
5434
strcpy(xorriso->pending_option,cpt);
5435
xorriso->request_to_abort= 1;
5436
sprintf(xorriso->info_text,
5437
"-------------- [ Input of option registered. Operation ends ] ---------------\n");
5438
Xorriso_info(xorriso,0);
5441
} else if(*cpt!=0) {
5442
Xorriso_dialog_input(xorriso,cpt,strlen(line)+1,2); /* write to history */
5443
sprintf(xorriso->info_text,
5444
"--- Please enter one of : empty line, @, @@@\n");
5445
Xorriso_info(xorriso,0);
5452
/* @param flag bit0= quoted multiline mode
5453
bit1= release allocated memory and return 1
5454
bit2= with bit0: warn of empty text arguments
5455
bit3= deliver as single quoted text including all whitespace
5456
and without any backslash interpretation
5457
@return -1=out of memory , 0=line format error , 1=ok, go on , 2=done
5459
int Xorriso_read_lines(struct XorrisO *xorriso, FILE *fp, int *linecount,
5460
int *argc, char ***argv, int flag)
5462
char line[5 * SfileadrL + 2], *linept, *fgot;
5463
int l, base_length, append_line, ret, mem_linecount, i;
5465
Sfile_make_argv("", line, argc, argv, 2);
5469
mem_linecount= *linecount;
5473
fgot= Sfile_fgets_n(linept, SfileadrL - base_length + 1, fp,
5474
!!(flag & (1 | 8)));
5478
if(linept != line) {
5479
sprintf(xorriso->info_text,"Open quotation mark at end of input");
5480
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
5488
if(flag & 1) { /* check whether the line is incomplete yet */
5489
ret= Sfile_make_argv("", line, argc, argv, 16);
5492
if(ret == 0 && !append_line) {
5497
if(l > 0 && !append_line)
5498
if(line[l - 1] == '\\') {
5503
if(l >= SfileadrL) {
5504
sprintf(xorriso->info_text,"Input line too long !");
5505
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
5510
base_length= strlen(line);
5511
linept= line + base_length;
5513
if((flag & 1) && !(flag & 8)) {
5514
ret= Sfile_make_argv("", line, argc, argv,
5515
1 | ((xorriso->bsl_interpretation & 3) << 5));
5519
for(i= 0; i < *argc; i++) {
5520
if((*argv)[i][0] == 0) {
5521
sprintf(xorriso->info_text, "Empty text as quoted argument in ");
5522
} else if(strlen((*argv)[i]) >= SfileadrL) {
5523
(*argv)[i][SfileadrL - 1]= 0;
5524
sprintf(xorriso->info_text,
5525
"Input text too long and now truncated in");
5528
if(mem_linecount + 1 < *linecount)
5529
sprintf(xorriso->info_text + strlen(xorriso->info_text),
5530
"lines %d to %d", mem_linecount + 1, *linecount);
5532
sprintf(xorriso->info_text + strlen(xorriso->info_text),
5533
"line %d", mem_linecount + 1);
5534
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0);
5537
(*argv)= Smem_malloC(sizeof(char *));
5540
(*argv)[0]= strdup(line);
5541
if((*argv)[0] == NULL)
5549
int Xorriso_predict_linecount(struct XorrisO *xorriso, char *line,
5550
int *linecount, int flag)
5557
width= xorriso->result_page_width;
5559
ept= strchr(spt,'\n');
5564
l+= xorriso->result_open_line_len;
5565
if(ept!=NULL && l==0)
5568
(*linecount)+= l/width;
5570
xorriso->result_open_line_len= l%width;
5573
(*linecount)+= !!(l%width);
5575
xorriso->result_open_line_len= 0;
5582
int Xorriso_pager(struct XorrisO *xorriso, char *line, int flag)
5584
bit1= mark '@' by return 4
5586
/* return: <=0 error , 1=go on , 2=abort , 4=see flag bit1*/
5589
char info_text[10*SfileadrL];
5591
if(xorriso->result_page_length<=0 || xorriso->request_not_to_ask ||
5592
xorriso->dialog == 0)
5594
Xorriso_predict_linecount(xorriso,line,&linecount,0);
5595
if(xorriso->result_line_counter+linecount>xorriso->result_page_length) {
5597
strcpy(info_text,xorriso->info_text);
5598
sprintf(xorriso->info_text,"\n");
5599
Xorriso_info(xorriso,0);
5600
sprintf(xorriso->info_text,
5601
".... [Press Enter to continue. @,Enter avoids further stops. @@@ aborts] ....\n");
5602
Xorriso_info(xorriso,0);
5603
ret= Xorriso_request_confirmation(xorriso,flag&2);
5604
strcpy(xorriso->info_text,info_text);
5612
xorriso->result_line_counter+= linecount;
5617
int Xorriso_write_to_channel(struct XorrisO *xorriso,
5618
char *in_text, int channel_no, int flag)
5620
bit0= eventually backslash encode linefeeds
5621
bit1= text is the name of the log file for the given channel
5622
bit2= text is the name of the consolidated packet log file for all channels
5623
bit15= with bit1 or bit2: close depicted log file
5626
char *rpt, *npt, *text;
5627
int ret= 1, info_redirected= 0, result_redirected= 0;
5629
FILE *logfile_fp, *pktlog_fp;
5630
struct Xorriso_lsT *msglist;
5631
static int num_channels= 4;
5632
static char channel_prefixes[4][4]= {".","R","I","M"};
5634
if(channel_no<0 || channel_no>=num_channels)
5637
text= in_text; /* might change due to backslash encoding */
5640
logfile_fp= xorriso->logfile_fp[channel_no];
5641
pktlog_fp= xorriso->pktlog_fp;
5642
if((flag&2) && logfile_fp!=NULL) {
5644
"! end ! end ! end ! end ! end ! end ! end ! end xorriso log : %s : %s\n",
5645
channel_prefixes[channel_no],Sfile_datestr(time(0),1|2|256));
5647
xorriso->logfile_fp[channel_no]= logfile_fp= NULL;
5649
if((flag&4) && pktlog_fp!=NULL) {
5651
"I:1:! end ! end ! end ! end ! end ! end ! end ! end xorriso log : %s : %s\n",
5652
channel_prefixes[channel_no],Sfile_datestr(time(0),1|2|256));
5654
xorriso->pktlog_fp= pktlog_fp= NULL;
5659
xorriso->logfile_fp[channel_no]= logfile_fp= fopen(text,"a");
5660
if(logfile_fp==NULL)
5663
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! xorriso log : %s : %s\n",
5664
channel_prefixes[channel_no],Sfile_datestr(time(0),1|2|256));
5668
xorriso->pktlog_fp= pktlog_fp= fopen(text,"a");
5672
"I:1:!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! xorriso log : . : %s\n",
5673
Sfile_datestr(time(0),1|2|256));
5679
/* Eventually perform backslash encoding of non-printable characters */
5680
if(((xorriso->bsl_interpretation & 32) && channel_no == 1) ||
5681
((xorriso->bsl_interpretation & 64) && channel_no == 2)) {
5682
ret= Sfile_bsl_encoder(&text, text, strlen(text), 1 | 2 | 4);
5687
/* Eventually perform messag redirection */
5688
if(xorriso->msglist_stackfill > 0) {
5689
if(xorriso->msglist_flags[xorriso->msglist_stackfill - 1] & 1)
5690
result_redirected= 1;
5691
if(xorriso->msglist_flags[xorriso->msglist_stackfill - 1] & 2)
5694
if(result_redirected) {
5695
if(channel_no==1 || channel_no==3) {
5696
msglist= xorriso->result_msglists[xorriso->msglist_stackfill - 1];
5697
ret= Xorriso_lst_append_binary(&msglist, text, strlen(text) + 1, 0);
5700
if(xorriso->result_msglists[xorriso->msglist_stackfill - 1] == NULL)
5701
xorriso->result_msglists[xorriso->msglist_stackfill - 1]= msglist;
5704
if(info_redirected) {
5705
if(channel_no==2 || channel_no==3) {
5706
msglist= xorriso->info_msglists[xorriso->msglist_stackfill - 1];
5707
ret= Xorriso_lst_append_binary(&msglist, text, strlen(text) + 1, 0);
5710
if(xorriso->info_msglists[xorriso->msglist_stackfill - 1] == NULL)
5711
xorriso->info_msglists[xorriso->msglist_stackfill - 1]= msglist;
5714
if((channel_no == 1 && result_redirected) ||
5715
(channel_no == 2 && info_redirected) ||
5716
(result_redirected && info_redirected))
5719
/* Non-redirected output */
5720
if(!xorriso->packet_output) {
5721
if(channel_no==1 || channel_no==3) {
5725
if(channel_no==2 || channel_no==3)
5726
fprintf(stderr,"%s",text);
5727
if(logfile_fp!=NULL) {
5728
fprintf(logfile_fp,"%s",text);
5735
sprintf(prefix,"%s:x: ",channel_prefixes[channel_no]);
5737
npt= strchr(rpt,'\n');
5742
if(xorriso->packet_output) {
5743
ret= fwrite(prefix,5,1,stdout);
5747
if(pktlog_fp!=NULL) {
5748
ret= fwrite(prefix,5,1,pktlog_fp);
5753
if(xorriso->packet_output) {
5754
ret= fwrite(rpt,strlen(rpt),1,stdout);
5757
ret= fwrite("\n",1,1,stdout);
5761
if(pktlog_fp!=NULL) {
5762
ret= fwrite(rpt,strlen(rpt),1,pktlog_fp);
5765
ret= fwrite("\n",1,1,pktlog_fp);
5771
if(xorriso->packet_output) {
5772
ret= fwrite(rpt,npt+1-rpt,1,stdout);
5776
if(pktlog_fp!=NULL) {
5777
ret= fwrite(rpt,npt+1-rpt,1,pktlog_fp);
5784
if(xorriso->packet_output)
5790
if(text != in_text && text != NULL)
5796
int Xorriso_push_outlists(struct XorrisO *xorriso, int *stack_handle,
5799
if(xorriso->msglist_stackfill + 1 >= Xorriso_max_outlist_stacK) {
5800
Xorriso_msgs_submit(xorriso, 0,
5801
"Overflow of message output redirection stack", 0, "FATAL", 0);
5806
xorriso->msglist_stackfill++;
5807
xorriso->result_msglists[xorriso->msglist_stackfill - 1]= NULL;
5808
xorriso->info_msglists[xorriso->msglist_stackfill - 1]= NULL;
5809
xorriso->msglist_flags[xorriso->msglist_stackfill - 1]= flag & 3;
5810
*stack_handle= xorriso->msglist_stackfill - 1;
5815
int Xorriso_pull_outlists(struct XorrisO *xorriso, int stack_handle,
5816
struct Xorriso_lsT **result_list,
5817
struct Xorriso_lsT **info_list, int flag)
5821
if(stack_handle < 0 || stack_handle >= xorriso->msglist_stackfill) {
5822
Xorriso_msgs_submit(xorriso, 0,
5823
"Program error: Wrong message output redirection stack handle",
5827
*result_list= xorriso->result_msglists[stack_handle];
5828
*info_list= xorriso->info_msglists[stack_handle];
5829
for(i = stack_handle + 1; i < xorriso->msglist_stackfill - 1; i++) {
5830
xorriso->result_msglists[i - 1]= xorriso->result_msglists[i];
5831
xorriso->info_msglists[i - 1]= xorriso->info_msglists[i];
5833
xorriso->msglist_stackfill--;
5838
int Xorriso_result(struct XorrisO *xorriso, int flag)
5840
bit0= no considerations or computations or dialog. Just put out.
5843
int ret, redirected= 0;
5847
if(xorriso->request_to_abort)
5849
if(xorriso->msglist_stackfill > 0)
5850
if(xorriso->msglist_flags[xorriso->msglist_stackfill - 1] & 1)
5852
if(xorriso->result_page_length>0 && !redirected) {
5853
ret= Xorriso_pager(xorriso,xorriso->result_line,2);
5858
if(xorriso->request_to_abort)
5862
xorriso->bar_is_fresh= 0;
5863
ret= Xorriso_write_to_channel(xorriso, xorriso->result_line, 1,0);
5868
int Xorriso_info(struct XorrisO *xorriso, int flag)
5870
bit0= use pager (as with result)
5871
bit1= permission to suppress output
5872
bit2= insist in showing output
5876
static int note_sev= 0;
5879
if(xorriso->request_to_abort)
5883
Xorriso__text_to_sev("NOTE", ¬e_sev, 0);
5884
if(note_sev<xorriso->report_about_severity &&
5885
note_sev<xorriso->abort_on_severity && !(flag&4))
5889
ret= Xorriso_pager(xorriso,xorriso->info_text,2);
5895
if(xorriso->request_to_abort)
5898
xorriso->bar_is_fresh= 0;
5899
ret=Xorriso_write_to_channel(xorriso, xorriso->info_text, 2, 0);
5904
int Xorriso_mark(struct XorrisO *xorriso, int flag)
5906
int ret= 1,r_ret,i_ret;
5908
if(xorriso->mark_text[0]==0)
5910
if(xorriso->packet_output)
5911
ret=Xorriso_write_to_channel(xorriso, xorriso->mark_text, 3, 0);
5913
sprintf(xorriso->result_line,"%s\n",xorriso->mark_text);
5914
r_ret= Xorriso_result(xorriso,1);
5915
strcpy(xorriso->info_text,xorriso->result_line);
5916
i_ret= Xorriso_info(xorriso,0);
5917
if(r_ret==0 || i_ret==0)
5924
int Xorriso_restxt(struct XorrisO *xorriso, char *text)
5928
strncpy(xorriso->result_line,text,sizeof(xorriso->result_line)-1);
5929
xorriso->result_line[sizeof(xorriso->result_line)-1]= 0;
5930
ret= Xorriso_result(xorriso,0);
5935
int Xorriso_pacifier_reset(struct XorrisO *xorriso, int flag)
5937
xorriso->start_time= Sfile_microtime(0);
5938
xorriso->last_update_time= xorriso->start_time;
5939
xorriso->pacifier_count= 0;
5940
xorriso->pacifier_total= 0;
5941
xorriso->pacifier_byte_count= 0;
5946
/* This call is to be issued by long running workers in short intervals.
5947
It will check whether enough time has elapsed since the last pacifier
5948
message and eventually issue an update message.
5949
@param what_done A sparse description of the action, preferrably in past
5950
tense. E.g. "done" , "files added".
5951
@param count The number of objects processed so far.
5953
@param todo The number of objects to be done in total.
5955
@param current_object A string telling the object currently processed.
5957
@param flag bit0= report unconditionally, no time check
5958
bit1= report count <=0 (no thank you for being patient then)
5959
bit2= report xorriso->pacifier_byte_count
5960
bit6= report with carriage return rather than line feed
5962
int Xorriso_pacifier_callback(struct XorrisO *xorriso, char *what_done,
5963
off_t count, off_t todo, char *current_object,
5966
double current_time, since;
5967
char count_text[80], byte_text[80];
5969
current_time= Sfile_microtime(0);
5970
if(current_time - xorriso->last_update_time < xorriso->pacifier_interval
5973
xorriso->last_update_time= Sfile_microtime(0);
5974
since= current_time - xorriso->start_time;
5975
if((flag&1)&&since<1.0)
5979
strcat(byte_text, " (");
5980
Sfile_scale((double) xorriso->pacifier_byte_count,
5981
byte_text+strlen(byte_text), 7, 1e5, 0);
5982
strcat(byte_text, ")");
5984
if(count<=0.0 && !(flag&2)) {
5985
sprintf(xorriso->info_text,
5986
"Thank you for being patient for %.f seconds", since);
5987
} else if(todo<=0.0) {
5989
sprintf(count_text, "%.f", (double) count);
5991
Sfile_scale((double) count, count_text, 7, 1e5, 1);
5992
sprintf(xorriso->info_text, "%s %s%s in %.f %s",
5993
count_text, what_done, byte_text, since, (flag&64) ? "s" : "seconds");
5995
sprintf(xorriso->info_text, "%.f of %.f %s%s in %.f seconds",
5996
(double) count, (double) todo, what_done, byte_text, since);
5998
if(current_object[0]!=0)
5999
sprintf(xorriso->info_text+strlen(xorriso->info_text),
6000
", now at %s", current_object);
6001
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "UPDATE", (flag&64));
6006
int Xorriso_reset_counters(struct XorrisO *xorriso, int flag)
6008
xorriso->error_count= 0;
6009
xorriso->insert_count= 0;
6010
xorriso->insert_bytes= 0;
6011
Xorriso_pacifier_reset(xorriso, 0);
6016
int Xorriso__bourne_to_reg(char bourne_expr[], char reg_expr[], int flag)
6017
/* reg_expr should be twice as large as bourne_expr ( + 2 to be exact) */
6018
/* return: 2= bourne_expr is surely a constant */
6021
int backslash= 0,is_constant= 1,in_square_brackets= 0;
6022
int first_in_square_brackets=0;
6030
if(first_in_square_brackets>0)
6031
first_in_square_brackets--;
6049
first_in_square_brackets= 2;
6050
in_square_brackets= 1;
6054
in_square_brackets= 0;
6056
if(first_in_square_brackets)
6058
else if(in_square_brackets)
6065
if(in_square_brackets)
6088
return(1+(is_constant>0));
6092
/* @param flag bit0= do not augment relative structured search by xorriso->wdi
6093
bit1= return 2 if bonked at start point by ..
6094
(caller then aborts or retries without bit0)
6095
bit2= eventually prepend wdx rather than wdi
6096
@return <=0 error, 1= ok, 2= with bit1: relative pattern exceeds start point
6098
int Xorriso_prepare_regex(struct XorrisO *xorriso, char *adr, int flag)
6100
int l,ret,i,count,bonked= 0,is_constant,is_still_relative= 0;
6101
char *cpt,*npt,adr_part[2*SfileadrL],absolute_adr[2*SfileadrL],*adr_start,*wd;
6108
if(xorriso->search_mode>=2 && xorriso->search_mode<=4) {
6109
if(xorriso->search_mode==3 || xorriso->search_mode==4) {
6110
l= strlen(adr)+strlen(wd)+1;
6111
if(l*2+2>sizeof(xorriso->reg_expr) || l*2+2>sizeof(adr_part)) {
6112
sprintf(xorriso->info_text,"Search pattern too long");
6113
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
6117
Xorriso_destroy_re(xorriso,0);
6118
if(xorriso->structured_search && xorriso->search_mode==3) {
6120
is_still_relative= 1;
6121
if(is_still_relative && !(flag&1)) {
6122
/* relative expression : prepend working directory */
6123
sprintf(absolute_adr,"%s/%s",wd,adr);
6124
adr_start= absolute_adr;
6125
xorriso->prepended_wd= 1;
6126
is_still_relative= 0;
6129
/* count slashes */;
6134
cpt= strchr(cpt,'/');
6141
xorriso->re= TSOB_FELD(regex_t,count);
6142
if(xorriso->re==NULL)
6144
xorriso->re_constants= TSOB_FELD(char *,count);
6145
if(xorriso->re_constants==NULL)
6147
for(i= 0;i<count;i++)
6148
xorriso->re_constants[i]= NULL;
6149
xorriso->re_count= count;
6150
xorriso->re_fill= 0;
6152
/* loop over slash chunks*/;
6154
xorriso->re_fill= 0;
6157
for(i= 0;i<count;i++) {
6158
npt= strchr(cpt,'/');
6160
if(strlen(cpt)>=sizeof(adr_part))
6162
strcpy(adr_part,cpt);
6164
if(npt-cpt>=sizeof(adr_part))
6166
strncpy(adr_part,cpt,npt-cpt);
6167
adr_part[npt-cpt]= 0;
6172
if(adr_part[0]=='.' && adr_part[1]==0 &&
6173
(xorriso->re_fill>0 || i<count-1))
6175
if(adr_part[0]=='.' && adr_part[1]=='.' && adr_part[2]==0) {
6176
/* delete previous part */
6177
if(xorriso->re_fill <= 0) {
6181
if(xorriso->re_constants[xorriso->re_fill-1]!=NULL) {
6182
free(xorriso->re_constants[xorriso->re_fill-1]);
6183
xorriso->re_constants[xorriso->re_fill-1]= NULL;
6185
regfree(&(xorriso->re[xorriso->re_fill-1]));
6186
(xorriso->re_fill)--;
6189
if(strcmp(adr_part,"*")==0) {
6193
ret= Xorriso__bourne_to_reg(adr_part,xorriso->reg_expr,0);
6195
if(Sregex_string(&(xorriso->re_constants[xorriso->re_fill]),adr_part,0)
6199
if(regcomp(&(xorriso->re[xorriso->re_fill]),xorriso->reg_expr,0)!=0)
6200
goto cannot_compile;
6213
sprintf(xorriso->info_text, "Your '..' bonked at the %s directory.",
6214
is_still_relative ? "working" : "root");
6215
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE",0);
6219
Xorriso__bourne_to_reg(adr_start,xorriso->reg_expr,0); /* just for show */
6223
if(strcmp(adr,"*")==0 || adr[0]==0) {
6225
} else if(xorriso->search_mode==3 || xorriso->search_mode==4) {
6226
ret= Xorriso__bourne_to_reg(adr,xorriso->reg_expr,0);
6227
is_constant= (ret==2);
6229
if(strlen(adr)>=sizeof(xorriso->reg_expr))
6231
strcpy(xorriso->reg_expr,adr);
6233
xorriso->re_count= 0; /* tells matcher that this is not structured */
6234
xorriso->re_constants= TSOB_FELD(char *,1);
6235
if(xorriso->re_constants==NULL)
6237
xorriso->re_constants[0]= NULL;
6239
if(strcmp(adr,"*")==0) {
6240
if(Sregex_string(&(xorriso->re_constants[0]),"",0)<=0)
6243
if(Sregex_string(&(xorriso->re_constants[0]),adr,0)<=0)
6246
xorriso->re_fill= 1;
6248
xorriso->re= TSOB_FELD(regex_t,1);
6249
if(xorriso->re==NULL)
6251
if(regcomp(&(xorriso->re[0]),xorriso->reg_expr,0)!=0) {
6253
sprintf(xorriso->info_text, "Cannot compile regular expression : %s",
6255
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE",0);
6266
/* @param flag bit0= do not shortcut last component of to_match
6267
bit1= consider match if regex matches parent of path
6268
bit2= retry beginning at failed last component
6270
@return 0=match , else no match
6272
int Xorriso_regexec(struct XorrisO *xorriso, char *to_match, int *failed_at,
6275
int ret,i,re_start= 0,reg_nomatch= -1;
6276
char *cpt,*npt,adr_part[SfileadrL],*mpt;
6278
reg_nomatch= REG_NOMATCH;
6281
if(!(xorriso->structured_search && xorriso->re_count>0)) {
6282
if(xorriso->re_constants!=NULL)
6283
if(xorriso->re_constants[0]!=NULL) {
6284
if(xorriso->re_constants[0][0]==0)
6286
if(strcmp(xorriso->re_constants[0],to_match)!=0)
6287
return(reg_nomatch);
6290
ret= regexec(&(xorriso->re[0]),to_match,1,xorriso->match,0);
6298
re_start= xorriso->re_failed_at;
6301
for(i= re_start;i<xorriso->re_fill;i++) {
6303
npt= strchr(cpt,'/');
6305
if(i<xorriso->re_fill-1 && !(flag&1))
6306
return(reg_nomatch); /* this must be the last expression part */
6309
strncpy(adr_part,cpt,npt-cpt);
6310
adr_part[npt-cpt]= 0;
6313
if(xorriso->re_constants[i]!=NULL) {
6314
if(xorriso->re_constants[i][0]!=0) /* empty constant matches anything */
6315
if(strcmp(xorriso->re_constants[i],mpt)!=0)
6316
return(reg_nomatch);
6318
ret= regexec(&(xorriso->re[i]),mpt,1,xorriso->match,0);
6323
if(i>=xorriso->re_fill-1)
6324
return(0); /* MATCH */
6326
return(reg_nomatch);
6332
*failed_at= xorriso->re_fill;
6334
return(0); /* MATCH */
6335
return(reg_nomatch);
6339
int Xorriso_is_in_patternlist(struct XorrisO *xorriso,
6340
struct Xorriso_lsT *patternlist, char *path,
6343
int ret, failed_at, i= 0;
6344
struct Xorriso_lsT *s;
6346
xorriso->search_mode= 3;
6347
xorriso->structured_search= 1;
6349
for(s= patternlist; s != NULL; s= Xorriso_lst_get_next(s, 0)) {
6350
ret= Xorriso_prepare_regex(xorriso, Xorriso_lst_get_text(s, 0), 0);
6353
/* Match path or parent of path */
6354
ret= Xorriso_regexec(xorriso, path, &failed_at, 2);
6363
char *Xorriso_get_pattern(struct XorrisO *xorriso,
6364
struct Xorriso_lsT *patternlist, int index, int flag)
6367
struct Xorriso_lsT *s;
6369
for(s= patternlist; s != NULL; s= Xorriso_lst_get_next(s, 0)) {
6371
return(Xorriso_lst_get_text(s, 0));
6378
/* @param flag bit0= simple readlink(): no normalization, no multi-hop
6380
int Xorriso_resolve_link(struct XorrisO *xorriso,
6381
char *link_path, char result_path[SfileadrL], int flag)
6385
int link_count= 0, ret, show_errno= 0;
6386
char buf[SfileadrL], dirbuf[SfileadrL], *lpt, *spt, sfe[5*SfileadrL];
6387
static int link_limit= 100;
6390
if(stat(link_path, &stbuf)==-1)
6397
l= readlink(lpt, buf, SfileadrL-1);
6400
Xorriso_msgs_submit(xorriso, 0, link_path, 0, "ERRFILE", 0);
6401
sprintf(xorriso->info_text, "Cannot obtain link target of : %s",
6402
Text_shellsafe(link_path, sfe, 0));
6403
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE",0);
6405
if(strcmp(lpt, link_path)!=0) {
6406
sprintf(xorriso->info_text,
6407
"Problem occured with intermediate path : %s",
6408
Text_shellsafe(lpt, sfe, 0));
6409
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE",0);
6415
Xorriso_msgs_submit(xorriso, 0, link_path, 0, "ERRFILE", 0);
6416
sprintf(xorriso->info_text, "Empty link target with : %s",
6417
Text_shellsafe(link_path, sfe, 0));
6418
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE",0);
6423
strcpy(result_path, buf);
6427
/* normalize relative to disk_path */
6428
if(Sfile_str(dirbuf, lpt, 0)<=0)
6431
spt= strrchr(dirbuf,'/');
6439
ret= Xorriso_normalize_img_path(xorriso, dirbuf, buf, result_path, 2|4);
6443
if(lstat(result_path, &stbuf)==-1) {
6447
if(!S_ISLNK(stbuf.st_mode))
6452
if(link_count>link_limit) {
6454
Xorriso_msgs_submit(xorriso, 0, link_path, 0, "ERRFILE", 0);
6455
sprintf(xorriso->info_text, "Too many link hops with : %s",
6456
Text_shellsafe(link_path, sfe, 0));
6457
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, show_errno,
6466
int Xorriso_status_filter(struct XorrisO *xorriso, char *filter, char *line,
6471
if(strncmp(filter, line, strlen(filter))!=0)
6477
int Xorriso_status_result(struct XorrisO *xorriso, char *filter, FILE *fp,
6480
bit1= do only report to fp
6485
ret= Xorriso_status_filter(xorriso, filter, xorriso->result_line, 0);
6489
Xorriso_result(xorriso,0);
6491
ret= fwrite(xorriso->result_line,strlen(xorriso->result_line),1,fp);
6499
int Xorriso_check_media_setup_job(struct XorrisO *xorriso,
6500
struct CheckmediajoB *job,
6501
char **argv, int old_idx, int end_idx, int flag)
6505
struct CheckmediajoB *default_job;
6508
if(xorriso->check_media_default != NULL)
6509
Checkmediajob_copy(xorriso->check_media_default, job, 0);
6510
for(i= old_idx; i < end_idx; i++) {
6511
if(strncmp(argv[i], "abort_file=", 11) == 0) {
6512
ret= Sfile_str(job->abort_file_path, argv[i] + 11, 0);
6515
} else if(strncmp(argv[i], "bad_limit=", 10) == 0) {
6516
if(strcmp(argv[i] + 10, "good") == 0)
6517
xorriso->check_media_bad_limit= Xorriso_read_quality_gooD;
6518
else if(strcmp(argv[i] + 10, "md5_match") == 0)
6519
xorriso->check_media_bad_limit= Xorriso_read_quality_md5_matcH;
6520
else if(strcmp(argv[i] + 10, "slow") == 0)
6521
xorriso->check_media_bad_limit= Xorriso_read_quality_sloW;
6522
else if(strcmp(argv[i] + 10, "partial") == 0)
6523
xorriso->check_media_bad_limit= Xorriso_read_quality_partiaL;
6524
else if(strcmp(argv[i] + 10, "valid") == 0)
6525
xorriso->check_media_bad_limit= Xorriso_read_quality_valiD;
6526
else if(strcmp(argv[i] + 10, "untested") == 0)
6527
xorriso->check_media_bad_limit= Xorriso_read_quality_untesteD;
6528
else if(strcmp(argv[i] + 10, "invalid") == 0)
6529
xorriso->check_media_bad_limit= Xorriso_read_quality_invaliD;
6530
else if(strcmp(argv[i] + 10, "tao_end") == 0)
6531
xorriso->check_media_bad_limit= Xorriso_read_quality_tao_enD;
6532
else if(strcmp(argv[i] + 10, "off_track") == 0)
6533
xorriso->check_media_bad_limit= Xorriso_read_quality_off_tracK;
6534
else if(strcmp(argv[i] + 10, "md5_mismatch") == 0)
6535
xorriso->check_media_bad_limit= Xorriso_read_quality_md5_mismatcH;
6536
else if(strcmp(argv[i] + 10, "unreadable") == 0)
6537
xorriso->check_media_bad_limit= Xorriso_read_quality_unreadablE;
6540
} else if(strncmp(argv[i], "data_to=", 8) == 0) {
6541
ret= Sfile_str(job->data_to_path, argv[i] + 8, 0);
6544
} else if(strncmp(argv[i], "chunk_size=", 11) == 0) {
6545
num= Scanf_io_size(argv[i] + 11, 1);
6546
if(num >= 2048 || num == 0)
6547
job->min_block_size= num / 2048;
6550
} else if(strncmp(argv[i], "event=", 6) == 0) {
6551
strncpy(sev_text, argv[i] + 6, 19);
6553
ret= Xorriso__text_to_sev(sev_text, &sev, 0);
6555
strcpy(xorriso->info_text, "-check_media event=");
6556
Text_shellsafe(sev_text, xorriso->info_text, 1);
6557
strcat(xorriso->info_text, " : Not a known severity name");
6558
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
6561
strcpy(job->event_severity, sev_text);
6562
} else if(strncmp(argv[i], "map_with_volid=", 15) == 0) {
6563
if(strcmp(argv[i] + 15, "on") == 0)
6564
job->map_with_volid= 1;
6565
else if(strcmp(argv[i] + 15, "off") == 0)
6566
job->map_with_volid= 0;
6569
} else if(strncmp(argv[i], "max_lba=", 8) == 0 ||
6570
strncmp(argv[i], "min_lba=", 8) == 0) {
6572
sscanf(argv[i] + 8, "%lf", &num);
6573
if(num > 0x7fffffff || num < 0)
6575
if(strncmp(argv[i], "max_lba=", 8) == 0)
6579
} else if(strncmp(argv[i], "patch_lba0=", 11) == 0) {
6580
job->patch_lba0_msc1= -1;
6581
if(strcmp(argv[i] + 11, "on") == 0)
6583
else if(strcmp(argv[i] + 11, "off") == 0)
6585
else if(strcmp(argv[i] + 11, "force") == 0)
6587
else if(argv[i][11] >= '1' && argv[i][11] <= '9') {
6589
sscanf(argv[i] + 11, "%lf", &num);
6590
if(num > 0x7fffffff || num < 0)
6592
job->patch_lba0_msc1= num;
6593
job->patch_lba0= (num >= 32) + (strstr(argv[i] + 11, ":force") != NULL);
6596
} else if(strncmp(argv[i], "report=", 7) == 0) {
6597
if(strcmp(argv[i] + 7, "blocks") == 0)
6598
job->report_mode= 0;
6599
else if(strcmp(argv[i] + 7, "files") == 0)
6600
job->report_mode= 1;
6601
else if(strcmp(argv[i] + 7, "blocks_files") == 0)
6602
job->report_mode= 2;
6605
} else if(strcmp(argv[i], "reset=now") == 0) {
6606
ret= Checkmediajob_new(&default_job, 0);
6608
sprintf(xorriso->info_text,
6609
"-check_media: Cannot reset options due to lack of resources");
6610
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
6613
Checkmediajob_copy(default_job, job, 0);
6614
Checkmediajob_destroy(&default_job, 0);
6615
xorriso->check_media_bad_limit= Xorriso_read_quality_invaliD;
6616
} else if(strncmp(argv[i], "retry=", 6) == 0) {
6617
if(strcmp(argv[i] + 6, "on") == 0)
6619
else if(strcmp(argv[i] + 6, "off") == 0)
6621
else if(strcmp(argv[i] + 6, "default") == 0)
6625
} else if(strncmp(argv[i], "sector_map=", 11) == 0) {
6626
ret= Sfile_str(job->sector_map_path, argv[i] + 11, 0);
6629
} else if(strncmp(argv[i], "slow_limit=", 11) == 0) {
6630
sscanf(argv[i] + 11, "%lf", &(job->slow_threshold_seq));
6631
} else if(strncmp(argv[i], "time_limit=", 11) == 0 ||
6632
strncmp(argv[i], "item_limit=", 11) == 0 ) {
6634
sscanf(argv[i] + 11, "%lf", &num);
6635
if(num > 0x7fffffff || num < 0)
6637
if(strncmp(argv[i], "time_limit=", 11) == 0)
6638
job->time_limit= num;
6640
job->item_limit= num;
6643
} else if(strncmp(argv[i], "untested=", 9) == 0) {
6644
if(strcmp(argv[i] + 9, "damaged") == 0)
6645
job->untested_valid= 0;
6646
if(strcmp(argv[i] + 9, "undamaged") == 0 ||
6647
strcmp(argv[i] + 9, "ok") == 0)
6648
job->untested_valid= 1;
6653
} else if(strncmp(argv[i], "use=", 4) == 0) {
6654
if(strcmp(argv[i] + 4, "outdev") == 0)
6656
else if(strcmp(argv[i] + 4, "indev") == 0)
6658
else if(strcmp(argv[i] + 4, "sector_map") == 0)
6662
} else if(strncmp(argv[i], "what=", 5) == 0) {
6663
if(strcmp(argv[i]+5, "tracks") == 0)
6665
else if(strcmp(argv[i]+5, "disc")== 0)
6669
sprintf(xorriso->info_text,
6670
"-check_media: Unknown value with option %s", argv[i]);
6671
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
6675
sprintf(xorriso->info_text, "-check_media: Unknown option '%s'", argv[i]);
6676
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
6686
/* @param report Buffer of at least 10*SfileadrL
6687
@param flag bit0= only report non-default settings
6688
@return <=0 error , 1 ok , 2 with bit0: every option is on default setting
6690
int Xorriso_check_media_list_job(struct XorrisO *xorriso,
6691
struct CheckmediajoB *job,
6692
char *report, int flag)
6695
char default_report[161], quality_name[80];
6696
struct CheckmediajoB *dflt= NULL;
6700
ret= Checkmediajob_new(&dflt, 0);
6703
sprintf(report, "-check_media_defaults");
6705
strcat(report, " reset=now");
6706
if(all || job->use_dev != dflt->use_dev)
6707
sprintf(report + strlen(report), " use=%s",
6708
job->use_dev == 1 ? "outdev" :
6709
job->use_dev == 2 ? "sector_map" : "indev");
6710
if(all || job->mode != dflt->mode)
6711
sprintf(report + strlen(report), " what=%s",
6712
job->mode == 1 ? "disc" : "tracks");
6713
if(all || job->min_lba != dflt->min_lba)
6714
sprintf(report + strlen(report), " min_lba=%d", job->min_lba);
6715
if(all || job->max_lba != dflt->max_lba)
6716
sprintf(report + strlen(report), " max_lba=%d", job->max_lba);
6717
if(all || job->retry != dflt->retry)
6718
sprintf(report + strlen(report), " retry=%s",
6719
job->retry == 1 ? "on" : job->retry == -1 ? "off" : "default");
6720
if(all || job->time_limit != dflt->time_limit)
6721
sprintf(report + strlen(report), " time_limit=%d", job->time_limit);
6722
if(all || job->item_limit != dflt->item_limit)
6723
sprintf(report + strlen(report), " item_limit=%d", job->item_limit);
6724
if(all || strcmp(job->abort_file_path, dflt->abort_file_path)) {
6725
strcat(report, " abort_file=");
6726
Text_shellsafe(job->abort_file_path, report + strlen(report), 0);
6728
if(strlen(report) > 4 * SfileadrL)
6730
if(all || strcmp(job->data_to_path, dflt->data_to_path)) {
6731
strcat(report, " data_to=");
6732
Text_shellsafe(job->data_to_path, report + strlen(report), 0);
6734
if(strlen(report) > 4 * SfileadrL)
6736
if(all || strcmp(job->sector_map_path, dflt->sector_map_path)) {
6737
strcat(report, " sector_map=");
6738
Text_shellsafe(job->sector_map_path, report + strlen(report), 0);
6740
if(all || job->map_with_volid != dflt->map_with_volid)
6741
sprintf(report + strlen(report), " map_with_volid=%s",
6742
job->map_with_volid == 1 ? "on" : "off");
6743
if(all || job->patch_lba0 != dflt->patch_lba0) {
6744
sprintf(report + strlen(report), " patch_lba0=");
6745
if(job->patch_lba0 == 0)
6746
sprintf(report + strlen(report), "off");
6747
else if(job->patch_lba0_msc1 >= 0)
6748
sprintf(report + strlen(report), "%d%s",
6749
job->patch_lba0_msc1, job->patch_lba0 == 2 ? ":force" : "");
6751
sprintf(report + strlen(report), "%s",
6752
job->patch_lba0 == 2 ? "force" : "on");
6754
if(all || job->report_mode != dflt->report_mode)
6755
sprintf(report + strlen(report), " report=%s",
6756
job->report_mode == 0 ? "blocks" :
6757
job->report_mode == 1 ? "files" : "blocks_files");
6758
if(all || job->slow_threshold_seq != dflt->slow_threshold_seq)
6759
sprintf(report + strlen(report), " slow_limit=%f", job->slow_threshold_seq);
6760
if(all || xorriso->check_media_bad_limit != Xorriso_read_quality_invaliD)
6761
sprintf(report + strlen(report), " bad_limit=%s",
6762
Spotlist__quality_name(xorriso->check_media_bad_limit, quality_name,
6763
Xorriso_read_quality_invaliD, 0) + 2);
6764
if(all || job->min_block_size != dflt->min_block_size)
6765
sprintf(report + strlen(report), " chunk_size=%ds", job->min_block_size);
6766
if(all || strcmp(job->event_severity, "ALL") != 0)
6767
sprintf(report + strlen(report), " event=%s", job->event_severity);
6768
if(strlen(report) > 4 * SfileadrL)
6772
strcat(report, " ");
6773
strcat(report, xorriso->list_delimiter);
6774
Checkmediajob_destroy(&dflt, 0);
6775
sprintf(default_report, "-check_media_defaults reset=now %s",
6776
xorriso->list_delimiter);
6777
if(ret > 0 && strcmp(report, default_report) == 0)
6783
int Xorriso_status(struct XorrisO *xorriso, char *filter, FILE *fp, int flag)
6785
bit0= do only report non-default settings
6786
bit1= do only report to fp
6787
bit2= report current -resume status even if bit0 is set, but only if valid
6788
bit3= report readline history
6789
bit4= report -resume options indirectly as
6790
-options_from_file:${resume_state_file}_pos
6793
int is_default, no_defaults, i, ret, adr_mode, do_single;
6794
int show_indev= 1, show_outdev= 1, show_dev= 0;
6795
int part_table_implicit= 0;
6796
char *line, sfe[5 * SfileadrL + 80], mode[80], *form, *treatment;
6797
char *in_pt, *out_pt, *nl_charset, *local_charset, *mode_pt;
6798
char *dev_filter= NULL;
6799
static char channel_prefixes[4][4]= {".","R","I","M"};
6800
static char load_names[][20]= {"auto", "session", "track", "lba", "volid"};
6801
static int max_load_mode= 4;
6802
struct Xorriso_lsT *paths, *leafs, *s;
6804
#ifndef Xorriso_multi_booT
6806
int patch_is_implicit= 0, efi_path_in_use= 0, bin_path_in_use= 0;
6809
no_defaults= flag&1;
6810
line= xorriso->result_line;
6812
if(xorriso->no_rc) {
6813
sprintf(line,"-no_rc\n");
6814
Xorriso_status_result(xorriso,filter,fp,flag&2);
6817
is_default= strcmp(xorriso->list_delimiter, "--") == 0;
6818
sprintf(line,"-list_delimiter %s\n", xorriso->list_delimiter);
6819
if(!(is_default && no_defaults))
6820
Xorriso_status_result(xorriso,filter,fp,flag&2);
6823
if(xorriso->dialog == 2)
6824
sprintf(line,"-dialog on\n");
6825
else if(xorriso->dialog == 1)
6826
sprintf(line,"-dialog single_line\n");
6828
sprintf(line,"-dialog off\n");
6831
if(!(is_default && no_defaults))
6832
Xorriso_status_result(xorriso,filter,fp,flag&2);
6834
is_default= (xorriso->result_page_length==0 && xorriso->result_page_width==80);
6835
sprintf(line,"-page %d %d\n",
6836
(xorriso->result_page_length>=0?xorriso->result_page_length
6837
:-xorriso->result_page_length),
6838
xorriso->result_page_width);
6839
if(!(is_default && no_defaults))
6840
Xorriso_status_result(xorriso,filter,fp,flag&2);
6842
is_default= (xorriso->use_stdin==0);
6843
sprintf(line,"-use_readline %s\n", (xorriso->use_stdin?"off":"on"));
6844
if(!(is_default && no_defaults))
6845
Xorriso_status_result(xorriso,filter,fp,flag&2);
6847
is_default= (xorriso->bsl_interpretation == 0);
6848
strcpy(line, "-backslash_codes ");
6849
if(xorriso->bsl_interpretation == 0)
6850
strcat(line, "off");
6851
else if(xorriso->bsl_interpretation == (3 | 16 | 32 | 64))
6854
if((xorriso->bsl_interpretation & 3) == 1)
6855
strcat(line, "in_double_quotes");
6856
else if((xorriso->bsl_interpretation & 3) == 2)
6857
strcat(line, "in_quotes");
6858
else if((xorriso->bsl_interpretation & 3) == 3)
6859
strcat(line, "with_quoted_input");
6860
if(xorriso->bsl_interpretation & 16) {
6861
if(strlen(line) > 17)
6863
strcat(line, "with_program_arguments");
6865
if((xorriso->bsl_interpretation & (32 | 64)) == (32 | 64)) {
6866
if(strlen(line) > 17)
6868
strcat(line, "encode_output");
6870
if(xorriso->bsl_interpretation & 32) {
6871
if(strlen(line) > 17)
6873
strcat(line, "encode_results");
6875
if(xorriso->bsl_interpretation & 64) {
6876
if(strlen(line) > 17)
6878
strcat(line, "encode_infos");
6883
if(!(is_default && no_defaults))
6884
Xorriso_status_result(xorriso,filter,fp,flag&2);
6886
is_default= !xorriso->packet_output;
6887
sprintf(line,"-pkt_output %s\n",(xorriso->packet_output?"on":"off"));
6888
if(!(is_default && no_defaults))
6889
Xorriso_status_result(xorriso,filter,fp,flag&2);
6892
is_default= (xorriso->logfile[i]!=0);
6893
sprintf(line,"-logfile %s %s\n",
6894
channel_prefixes[i],Text_shellsafe(xorriso->logfile[i],sfe,0));
6895
if(!(is_default && no_defaults))
6896
Xorriso_status_result(xorriso,filter,fp,flag&2);
6899
is_default= (xorriso->errfile_log[0]==0);
6900
sprintf(line,"-errfile_log %s\n",Text_shellsafe(xorriso->errfile_log,sfe,0));
6901
if(!(is_default && no_defaults))
6902
Xorriso_status_result(xorriso,filter,fp,flag&2);
6904
if(xorriso->check_media_default == NULL) {
6906
sprintf(line, "-check_media_defaults reset=now %s\n",
6907
xorriso->list_delimiter);
6909
ret= Xorriso_check_media_list_job(xorriso, xorriso->check_media_default,
6911
is_default= (ret == 2);
6914
if(!(is_default && no_defaults))
6915
Xorriso_status_result(xorriso,filter,fp,flag&2);
6917
is_default= (xorriso->img_read_error_mode==2);
6918
treatment= "best_effort";
6919
if(xorriso->img_read_error_mode==1)
6920
treatment= "failure";
6921
else if(xorriso->img_read_error_mode==2)
6923
sprintf(line,"-error_behavior image_loading %s\n", treatment);
6924
if(!(is_default && no_defaults))
6925
Xorriso_status_result(xorriso,filter,fp,flag&2);
6926
is_default= (xorriso->extract_error_mode == 1);
6928
if(xorriso->extract_error_mode == 0)
6929
treatment= "best_effort";
6930
else if(xorriso->extract_error_mode == 2)
6931
treatment= "delete";
6932
sprintf(line,"-error_behavior file_extraction %s\n", treatment);
6933
if(!(is_default && no_defaults))
6934
Xorriso_status_result(xorriso,filter,fp,flag&2);
6936
is_default= (xorriso->mark_text[0]==0);
6937
sprintf(line,"-mark %s\n",Text_shellsafe(xorriso->mark_text,sfe,0));
6938
if(!(is_default && no_defaults))
6939
Xorriso_status_result(xorriso,filter,fp,flag&2);
6941
is_default= (xorriso->temp_mem_limit==16*1024*1024);
6942
if((xorriso->temp_mem_limit/1024/1024)*1024*1024==xorriso->temp_mem_limit)
6943
sprintf(line,"-temp_mem_limit %dm\n", xorriso->temp_mem_limit/1024/1024);
6945
sprintf(line,"-temp_mem_limit %dk\n", xorriso->temp_mem_limit/1024);
6946
if(!(is_default && no_defaults))
6947
Xorriso_status_result(xorriso,filter,fp,flag&2);
6950
sprintf(line,"-prog %s\n",Text_shellsafe(xorriso->progname,sfe,0));
6951
Xorriso_status_result(xorriso,filter,fp,flag&2);
6953
if(xorriso->ban_stdio_write) {
6954
sprintf(line,"-ban_stdio_write\n");
6955
Xorriso_status_result(xorriso,filter,fp,flag&2);
6958
is_default= (xorriso->allow_restore==0 && xorriso->do_concat_split==1 &&
6959
xorriso->do_auto_chmod==0 && xorriso->drives_exclusive == 1);
6961
if(xorriso->allow_restore == -1)
6963
else if(xorriso->allow_restore == 1)
6965
else if(xorriso->allow_restore == 2)
6966
mode_pt= "device_files";
6967
if(xorriso->allow_restore == -1)
6968
sprintf(line,"-osirrox %s\n", mode_pt);
6970
sprintf(line,"-osirrox %s:%s:%s:%s:%s\n", mode_pt,
6971
xorriso->do_concat_split ? "concat_split_on" : "concat_split_off",
6972
xorriso->do_auto_chmod ? "auto_chmod_on" : "auto_chmod_off",
6973
xorriso->do_restore_sort_lba ? "sort_lba_on" : "sort_lba_off",
6974
xorriso->drives_exclusive ? "o_excl_on" : "o_excl_off"
6976
if(!(is_default && no_defaults))
6977
Xorriso_status_result(xorriso,filter,fp,flag&2);
6979
is_default= (xorriso->mount_opts_flag == 0);
6980
sprintf(line,"-mount_opts %s\n",
6981
xorriso->mount_opts_flag & 1 ? "shared" : "exclusive");
6982
if(!(is_default && no_defaults))
6983
Xorriso_status_result(xorriso,filter,fp,flag&2);
6985
#ifdef Xorriso_multi_booT
6987
Xorriso_boot_image_status(xorriso, filter, fp, flag & 3);
6989
#else /* Xorriso_multi_booT */
6991
is_default= (xorriso->keep_boot_image == 0
6992
&& xorriso->patch_isolinux_image == 0
6993
&& xorriso->boot_image_bin_path[0] == 0);
6994
bin_form= form= "any";
6995
treatment= "discard";
6996
if(xorriso->boot_image_bin_path[0]) {
6997
if(xorriso->boot_image_bin_form[0])
6998
bin_form= form= xorriso->boot_image_bin_form;
6999
if(strcmp(form, "isolinux") == 0) {
7000
patch_is_implicit= 1;
7001
if(strcmp(xorriso->boot_image_bin_path, "/isolinux.bin") == 0 &&
7002
strcmp(xorriso->boot_image_cat_path, "/boot.cat") == 0)
7003
strcpy(sfe, "dir=/");
7004
else if(strcmp(xorriso->boot_image_bin_path, "/isolinux/isolinux.bin") == 0
7005
&& strcmp(xorriso->boot_image_cat_path, "/isolinux/boot.cat") == 0)
7006
strcpy(sfe, "dir=/isolinux");
7007
else if(strcmp(xorriso->boot_image_bin_path,
7008
"/boot/isolinux/isolinux.bin") == 0
7009
&& strcmp(xorriso->boot_image_cat_path,
7010
"/boot/isolinux/boot.cat") == 0)
7011
strcpy(sfe, "dir=/boot/isolinux");
7016
} else if(strcmp(form, "grub") == 0) {
7017
patch_is_implicit= 1;
7024
strcpy(sfe, "bin_path=");
7025
Text_shellsafe(xorriso->boot_image_bin_path, sfe + strlen(sfe), 0);
7030
} else if(xorriso->boot_image_efi_path[0]) {
7032
strcpy(sfe, "efi_path=");
7033
Text_shellsafe(xorriso->boot_image_efi_path, sfe + strlen(sfe), 0);
7037
} else if(xorriso->patch_isolinux_image & 1) {
7039
if(xorriso->patch_system_area & 1)
7041
else if(xorriso->patch_system_area & 2)
7043
if(xorriso->patch_system_area)
7044
part_table_implicit= 1;
7045
} else if(xorriso->keep_boot_image) {
7048
sprintf(line,"-boot_image %s %s\n", form, treatment);
7049
if(!(is_default && no_defaults))
7050
Xorriso_status_result(xorriso,filter,fp,flag&2);
7051
if((xorriso->patch_isolinux_image & 1) && xorriso->boot_image_bin_path[0] &&
7052
!patch_is_implicit) {
7053
sprintf(line,"-boot_image any boot_info_table=on\n");
7054
if(!(is_default && no_defaults))
7055
Xorriso_status_result(xorriso,filter,fp,flag&2);
7057
if(bin_path_in_use) {
7058
is_default= xorriso->boot_image_load_size == 4 * 512;
7059
sprintf(line,"-boot_image %s load_size=%.f\n",
7060
bin_form, (double) xorriso->boot_image_load_size);
7061
if(!(is_default && no_defaults))
7062
Xorriso_status_result(xorriso,filter,fp,flag&2);
7064
if(bin_path_in_use) {
7065
is_default= (xorriso->boot_platform_id == 0x00);
7066
sprintf(line,"-boot_image any platform_id=0x%-2.2x\n",
7067
(unsigned int) xorriso->boot_platform_id);
7068
if(!(is_default && no_defaults))
7069
Xorriso_status_result(xorriso,filter,fp,flag&2);
7072
if(xorriso->boot_image_efi_path[0] && xorriso->boot_image_bin_path[0]) {
7073
strcpy(line,"-boot_image grub efi_path=");
7074
Text_shellsafe(xorriso->boot_image_efi_path, line + strlen(line), 0);
7076
Xorriso_status_result(xorriso,filter,fp,flag&2);
7080
if(xorriso->boot_image_cat_path[0] && (bin_path_in_use || efi_path_in_use)) {
7082
sprintf(line,"-boot_image %s cat_path=%s\n",
7083
bin_form, Text_shellsafe(xorriso->boot_image_cat_path, sfe, 0));
7084
if(!(is_default && no_defaults))
7085
Xorriso_status_result(xorriso,filter,fp,flag&2);
7088
#endif /* Xorriso_multi_booT */
7090
is_default= (xorriso->system_area_disk_path[0] == 0);
7091
sprintf(line,"-boot_image %s system_area=%s\n",
7092
xorriso->system_area_disk_path[0] && (xorriso->system_area_options & 2)
7093
? "isolinux" : "any",
7094
Text_shellsafe(xorriso->system_area_disk_path, sfe, 0));
7095
if(!(is_default && no_defaults))
7096
Xorriso_status_result(xorriso,filter,fp,flag&2);
7097
if(xorriso->system_area_disk_path[0] || !part_table_implicit) {
7098
is_default= ((xorriso->system_area_options & 3) == 0);
7099
sprintf(line,"-boot_image %s partition_table=%s\n",
7100
xorriso->system_area_options & 2 ? "isolinux" : "grub",
7101
xorriso->system_area_options & 3 ? "on" : "off");
7102
if(!(is_default && no_defaults))
7103
Xorriso_status_result(xorriso,filter,fp,flag&2);
7106
#ifdef Xorriso_with_isohybriD
7107
if(strcmp(form, "isolinux") == 0) {
7108
static char modes[4][6]= {"off", "auto", "on", "force"};
7109
is_default= (xorriso->boot_image_isohybrid == 1);
7110
sprintf(line,"-boot_image isolinux isohybrid=%s\n",
7111
modes[xorriso->boot_image_isohybrid & 3]);
7112
if(!(is_default && no_defaults))
7113
Xorriso_status_result(xorriso,filter,fp,flag&2);
7115
#endif /* Xorriso_with_isohybriD */
7117
sprintf(line,"-cd %s\n",
7118
(xorriso->wdi[0] ? Text_shellsafe(xorriso->wdi,sfe,0) : "'/'"));
7119
Xorriso_status_result(xorriso,filter,fp,flag&2);
7120
sprintf(line,"-cdx %s\n",
7121
(xorriso->wdx[0] ? Text_shellsafe(xorriso->wdx,sfe,0) : "'/'"));
7122
Xorriso_status_result(xorriso,filter,fp,flag&2);
7124
is_default= (xorriso->split_size==0);
7125
strcpy(line,"-split_size ");
7126
if(xorriso->split_size % (1024*1024) || xorriso->split_size==0) {
7127
Sfile_off_t_text(line+strlen(line), xorriso->split_size, 0);
7129
Sfile_off_t_text(line+strlen(line), xorriso->split_size / (1024*1024), 0);
7133
if(!(is_default && no_defaults))
7134
Xorriso_status_result(xorriso,filter,fp,flag&2);
7136
is_default= (xorriso->add_plainly==0);
7137
sprintf(line,"-add_plainly %s\n",
7138
(xorriso->add_plainly == 1 ? "unknown" :
7139
xorriso->add_plainly == 2 ? "dashed" :
7140
xorriso->add_plainly == 3 ? "any" : "none"));
7141
if(!(is_default && no_defaults))
7142
Xorriso_status_result(xorriso,filter,fp,flag&2);
7144
ret= Exclusions_get_descrs(xorriso->disk_exclusions, &paths, &leafs, 0);
7146
for(; paths!=NULL; paths= paths->next) {
7147
sprintf(line, "-not_paths %s %s\n",
7148
Text_shellsafe(paths->text, sfe, 0), xorriso->list_delimiter);
7149
Xorriso_status_result(xorriso,filter,fp,flag&2);
7151
for(; leafs!=NULL; leafs= leafs->next) {
7152
sprintf(line,"-not_leaf %s\n", Text_shellsafe(leafs->text, sfe, 0));
7153
Xorriso_status_result(xorriso,filter,fp,flag&2);
7157
is_default= (xorriso->file_size_limit ==
7158
Xorriso_default_file_size_limiT);
7159
if(xorriso->file_size_limit <= 0)
7160
sprintf(line, "-file_size_limit off %s\n", xorriso->list_delimiter);
7162
sprintf(line, "-file_size_limit %.f %s\n",
7163
(double) xorriso->file_size_limit, xorriso->list_delimiter);
7164
if(!(is_default && no_defaults))
7165
Xorriso_status_result(xorriso,filter,fp,flag&2);
7167
is_default= (xorriso->disk_excl_mode==1);
7168
sprintf(line, "-not_mgt %s:%s:%s:%s\n",
7169
(xorriso->disk_excl_mode&1 ? "on" : "off"),
7170
(xorriso->disk_excl_mode&2 ? "param_on" : "param_off"),
7171
(xorriso->disk_excl_mode&4 ? "subtree_on" : "subtree_off"),
7172
(xorriso->disk_excl_mode&8 ? "ignore_on" : "ignore_off"));
7173
if(!(is_default && no_defaults))
7174
Xorriso_status_result(xorriso,filter,fp,flag&2);
7176
is_default= (xorriso->do_iso_rr_pattern==1);
7177
sprintf(line,"-iso_rr_pattern %s\n",
7178
(xorriso->do_iso_rr_pattern == 1 ? "on" :
7179
(xorriso->do_iso_rr_pattern == 2 ? "ls" : "off")));
7180
if(!(is_default && no_defaults))
7181
Xorriso_status_result(xorriso,filter,fp,flag&2);
7183
is_default= (xorriso->do_disk_pattern==2);
7184
sprintf(line,"-disk_pattern %s\n",
7185
(xorriso->do_disk_pattern == 1 ? "on" :
7186
(xorriso->do_disk_pattern == 2 ? "ls" : "off")));
7187
if(!(is_default && no_defaults))
7188
Xorriso_status_result(xorriso,filter,fp,flag&2);
7190
is_default= xorriso->volid_default;
7191
sprintf(line,"-volid %s\n",Text_shellsafe(xorriso->volid,sfe,0));
7192
if(!(is_default && no_defaults))
7193
Xorriso_status_result(xorriso,filter,fp,flag&2);
7194
if(is_default && xorriso->loaded_volid[0] &&
7195
strcmp(xorriso->loaded_volid, xorriso->volid)!=0 && !no_defaults) {
7196
sprintf(line,"# loaded image effective -volid %s\n",
7197
Text_shellsafe(xorriso->loaded_volid,sfe,0));
7198
Xorriso_status_result(xorriso,filter,fp,flag&2);
7201
is_default= (xorriso->publisher[0]==0);
7202
sprintf(line,"-publisher %s\n",Text_shellsafe(xorriso->publisher,sfe,0));
7203
if(!(is_default && no_defaults))
7204
Xorriso_status_result(xorriso,filter,fp,flag&2);
7206
is_default= (xorriso->application_id[0]==0);
7207
sprintf(line,"-application_id %s\n",
7208
Text_shellsafe(xorriso->application_id,sfe,0));
7209
if(!(is_default && no_defaults))
7210
Xorriso_status_result(xorriso,filter,fp,flag&2);
7212
is_default= (xorriso->system_id[0]==0);
7213
sprintf(line,"-system_id %s\n", Text_shellsafe(xorriso->system_id,sfe,0));
7214
if(!(is_default && no_defaults))
7215
Xorriso_status_result(xorriso,filter,fp,flag&2);
7217
is_default= (xorriso->volset_id[0]==0);
7218
sprintf(line,"-volset_id %s\n", Text_shellsafe(xorriso->volset_id,sfe,0));
7219
if(!(is_default && no_defaults))
7220
Xorriso_status_result(xorriso,filter,fp,flag&2);
7222
is_default= (xorriso->vol_creation_time == 0);
7223
sprintf(line,"-volume_date c %s\n",
7224
is_default ? "default" :
7225
Ftimetxt(xorriso->vol_creation_time, sfe, 2));
7226
if(!(is_default && no_defaults))
7227
Xorriso_status_result(xorriso,filter,fp,flag&2);
7229
is_default= (xorriso->vol_modification_time == 0);
7230
sprintf(line,"-volume_date m %s\n",
7231
xorriso->vol_uuid[0] ? "overridden" :
7232
is_default ? "default" :
7233
Ftimetxt(xorriso->vol_modification_time, sfe, 2));
7234
if(!(is_default && no_defaults))
7235
Xorriso_status_result(xorriso,filter,fp,flag&2);
7237
is_default= (xorriso->vol_expiration_time == 0);
7238
sprintf(line,"-volume_date x %s\n",
7239
is_default ? "default" :
7240
Ftimetxt(xorriso->vol_expiration_time, sfe, 2));
7241
if(!(is_default && no_defaults))
7242
Xorriso_status_result(xorriso,filter,fp,flag&2);
7244
is_default= (xorriso->vol_effective_time == 0);
7245
sprintf(line,"-volume_date f %s\n",
7246
is_default ? "default" :
7247
Ftimetxt(xorriso->vol_effective_time, sfe, 2));
7248
if(!(is_default && no_defaults))
7249
Xorriso_status_result(xorriso,filter,fp,flag&2);
7251
is_default= (xorriso->vol_uuid[0] == 0);
7252
sprintf(line,"-volume_date uuid %s\n",
7253
Text_shellsafe(xorriso->vol_uuid,sfe,0));
7254
if(!(is_default && no_defaults))
7255
Xorriso_status_result(xorriso,filter,fp,flag&2);
7257
is_default= (xorriso->do_joliet==0);
7258
sprintf(line,"-joliet %s\n", (xorriso->do_joliet == 1 ? "on" : "off"));
7259
if(!(is_default && no_defaults))
7260
Xorriso_status_result(xorriso,filter,fp,flag&2);
7262
if(xorriso->do_global_uid) {
7263
sprintf(line,"-uid %lu\n", (unsigned long) xorriso->global_uid);
7264
Xorriso_status_result(xorriso,filter,fp,flag&2);
7267
if(xorriso->do_global_gid) {
7268
sprintf(line,"-gid %lu\n", (unsigned long) xorriso->global_gid);
7269
Xorriso_status_result(xorriso,filter,fp,flag&2);
7272
Xorriso_status_extf(xorriso, filter, fp, flag & 2);
7273
Xorriso_status_zisofs(xorriso, filter, fp, flag & 3);
7275
is_default= !xorriso->allow_graft_points;
7276
sprintf(line,"-pathspecs %s\n", xorriso->allow_graft_points ? "on" : "off");
7277
if(!(is_default && no_defaults))
7278
Xorriso_status_result(xorriso,filter,fp,flag&2);
7280
is_default= (xorriso->do_follow_pattern && (!xorriso->do_follow_param)
7281
&& xorriso->do_follow_mount && (!xorriso->do_follow_links)
7282
&& xorriso->follow_link_limit==100);
7284
if(xorriso->do_follow_pattern &&
7285
!(xorriso->do_follow_links && xorriso->do_follow_mount))
7286
strcat(mode,":pattern");
7287
if(xorriso->do_follow_param && !(xorriso->do_follow_links))
7288
strcat(mode,":param");
7289
if(xorriso->do_follow_links)
7290
strcat(mode,":link");
7291
if(xorriso->do_follow_mount)
7292
strcat(mode,":mount");
7294
strcpy(mode, ":off");
7295
sprintf(mode+strlen(mode), ":limit=%d", xorriso->follow_link_limit);
7296
sprintf(line,"-follow %s\n", mode+1);
7297
if(!(is_default && no_defaults))
7298
Xorriso_status_result(xorriso,filter,fp,flag&2);
7300
is_default= (xorriso->do_overwrite==2);
7301
sprintf(line,"-overwrite %s\n",(xorriso->do_overwrite == 1 ? "on" :
7302
(xorriso->do_overwrite == 2 ? "nondir" : "off")));
7303
if(!(is_default && no_defaults))
7304
Xorriso_status_result(xorriso,filter,fp,flag&2);
7306
is_default= !xorriso->do_reassure;
7307
sprintf(line,"-reassure %s\n",(xorriso->do_reassure == 1 ? "on" :
7308
(xorriso->do_reassure == 2 ? "tree" : "off")));
7309
if(!(is_default && no_defaults))
7310
Xorriso_status_result(xorriso,filter,fp,flag&2);
7312
is_default= !xorriso->do_close;
7313
sprintf(line,"-close %s\n",(xorriso->do_close ? "on" : "off"));
7314
if(!(is_default && no_defaults))
7315
Xorriso_status_result(xorriso,filter,fp,flag&2);
7317
is_default= !xorriso->do_dummy;
7318
sprintf(line,"-dummy %s\n",(xorriso->do_dummy ? "on" : "off"));
7319
if(!(is_default && no_defaults))
7320
Xorriso_status_result(xorriso,filter,fp,flag&2);
7322
is_default= (xorriso->speed==0);
7323
sprintf(line,"-speed %dkB/s\n", xorriso->speed);
7324
if(!(is_default && no_defaults))
7325
Xorriso_status_result(xorriso,filter,fp,flag&2);
7327
is_default= (xorriso->do_stream_recording==0);
7328
strcpy(mode, "off");
7329
if(xorriso->do_stream_recording == 1)
7330
strcpy(mode, "full");
7331
if(xorriso->do_stream_recording == 2)
7332
strcpy(mode, "data");
7333
else if(xorriso->do_stream_recording == 32)
7335
else if(xorriso->do_stream_recording >= 16)
7336
sprintf(mode, "%ds", xorriso->do_stream_recording);
7337
sprintf(line,"-stream_recording %s\n", mode);
7338
if(!(is_default && no_defaults))
7339
Xorriso_status_result(xorriso,filter,fp,flag&2);
7341
is_default= (xorriso->dvd_obs == 0);
7342
strcpy(mode, "default");
7343
if(xorriso->dvd_obs == 32768 || xorriso->dvd_obs == 65536)
7344
sprintf(mode, "%dk", xorriso->dvd_obs / 1024);
7345
sprintf(line,"-dvd_obs %s\n", mode);
7346
if(!(is_default && no_defaults))
7347
Xorriso_status_result(xorriso,filter,fp,flag&2);
7349
is_default= (xorriso->stdio_sync == 0);
7350
strcpy(line, "-stdio_sync ");
7351
if(xorriso->stdio_sync == -1)
7352
strcat(line, "off");
7353
else if(xorriso->stdio_sync == 0)
7355
else if(xorriso->stdio_sync % 512) {
7356
Sfile_off_t_text(line+strlen(line), (off_t) (xorriso->stdio_sync * 2048),
7359
Sfile_off_t_text(line+strlen(line), (off_t) (xorriso->stdio_sync / 512), 0);
7363
if(!(is_default && no_defaults))
7364
Xorriso_status_result(xorriso,filter,fp,flag&2);
7366
is_default= (xorriso->fs==4*512);
7367
if((xorriso->fs/512)*512==xorriso->fs)
7368
sprintf(line,"-fs %dm\n", xorriso->fs/512);
7370
sprintf(line,"-fs %dk\n", xorriso->fs*2);
7371
if(!(is_default && no_defaults))
7372
Xorriso_status_result(xorriso,filter,fp,flag&2);
7374
is_default= (xorriso->padding==300*1024);
7375
sprintf(line,"-padding %dk\n", xorriso->padding/1024);
7376
if(!(is_default && no_defaults))
7377
Xorriso_status_result(xorriso,filter,fp,flag&2);
7379
is_default= (strcmp(xorriso->report_about_text,"UPDATE")==0);
7380
sprintf(line,"-report_about %s\n",xorriso->report_about_text);
7381
if(!(is_default && no_defaults))
7382
Xorriso_status_result(xorriso,filter,fp,flag&2);
7384
is_default= (xorriso->scsi_log == 0);
7385
sprintf(line,"-scsi_log %s\n", xorriso->scsi_log ? "on" : "off");
7386
if(!(is_default && no_defaults))
7387
Xorriso_status_result(xorriso,filter,fp,flag&2);
7389
is_default= (xorriso->session_logfile[0]==0);
7390
sprintf(line,"-session_log %s\n",
7391
Text_shellsafe(xorriso->session_logfile,sfe,0));
7392
if(!(is_default && no_defaults))
7393
Xorriso_status_result(xorriso,filter,fp,flag&2);
7395
is_default= (xorriso->pacifier_style==0);
7396
sprintf(line,"-pacifier '%s'\n",
7397
xorriso->pacifier_style==1 ? "mkisofs" :
7398
xorriso->pacifier_style==2 ? "cdrecord" : "xorriso");
7399
if(!(is_default && no_defaults))
7400
Xorriso_status_result(xorriso,filter,fp,flag&2);
7402
is_default= (strcmp(xorriso->return_with_text,"SORRY")==0 &&
7403
xorriso->return_with_value==32);
7404
sprintf(line,"-return_with %s %d\n",
7405
xorriso->return_with_text, xorriso->return_with_value);
7406
if(!(is_default && no_defaults))
7407
Xorriso_status_result(xorriso,filter,fp,flag&2);
7409
is_default= (strcmp(xorriso->abort_on_text,"FATAL")==0);
7410
sprintf(line,"-abort_on %s\n",xorriso->abort_on_text);
7411
if(!(is_default && no_defaults))
7412
Xorriso_status_result(xorriso,filter,fp,flag&2);
7414
if(xorriso->status_history_max!=Xorriso_status_history_maX || !no_defaults) {
7415
sprintf(line,"-status_history_max %d\n",xorriso->status_history_max);
7416
Xorriso_status_result(xorriso,filter,fp,flag&2);
7419
#ifdef Xorriso_with_readlinE
7421
if((flag&8) && xorriso->status_history_max>0) {
7427
for(hc= 0;hl[hc]!=NULL;hc++);
7429
if(strcmp(hl[hc-1]->line,"-end")==0)
7431
if(hc>=xorriso->status_history_max)
7432
i= hc-xorriso->status_history_max;
7436
sprintf(line,"-history %s\n",Text_shellsafe(hl[i]->line,sfe,0));
7437
Xorriso_status_result(xorriso,filter,fp,flag&2);
7442
#endif /* Xorriso_with_readlinE */
7444
is_default= (xorriso->toc_emulation_flag == 0);
7445
sprintf(line,"-rom_toc_scan %s%s\n",
7446
xorriso->toc_emulation_flag & 4 ? "force" :
7447
xorriso->toc_emulation_flag & 1 ? "on" : "off",
7448
xorriso->toc_emulation_flag & 2 ? ":emul_off" : "");
7449
if(!(is_default && no_defaults))
7450
Xorriso_status_result(xorriso, filter, fp, flag & 2);
7452
adr_mode= xorriso->image_start_mode & 0xffff;
7453
if(adr_mode>=0 && adr_mode<=max_load_mode) {
7454
is_default= (adr_mode==0);
7455
sprintf(line,"-load %s ", load_names[adr_mode]);
7457
sprintf(line+strlen(line),"''\n");
7458
else if(adr_mode>=1 && adr_mode<=3)
7459
sprintf(line+strlen(line),"%s\n", xorriso->image_start_value);
7461
sprintf(line+strlen(line),"%s\n",
7462
Text_shellsafe(xorriso->image_start_value, sfe, 0));
7463
if(!(is_default && no_defaults))
7464
Xorriso_status_result(xorriso,filter,fp,flag&2);
7467
is_default= (xorriso->do_calm_drive & 1);
7468
sprintf(line,"-calm_drive %s\n", xorriso->do_calm_drive & 1 ? "on" : "off");
7469
if(!(is_default && no_defaults))
7470
Xorriso_status_result(xorriso,filter,fp,flag&2);
7472
is_default= (xorriso->grow_blindly_msc2<0);
7473
sprintf(sfe, "%d", xorriso->grow_blindly_msc2);
7474
sprintf(line,"-grow_blindly %s\n",
7475
xorriso->grow_blindly_msc2 < 0 ? "off" : sfe);
7476
if(!(is_default && no_defaults))
7477
Xorriso_status_result(xorriso,filter,fp,flag&2);
7479
Xorriso_get_local_charset(xorriso, &local_charset, 0);
7480
nl_charset= nl_langinfo(CODESET);
7481
is_default= (strcmp(local_charset, nl_charset) == 0);
7482
sprintf(line, "-local_charset %s\n", Text_shellsafe(local_charset, sfe, 0));
7483
if(!(is_default && no_defaults))
7484
Xorriso_status_result(xorriso, filter, fp, flag & 2);
7486
is_default= (xorriso->out_charset == NULL && xorriso->in_charset == NULL);
7488
if(xorriso->in_charset != NULL)
7489
in_pt= xorriso->in_charset;
7491
if(xorriso->out_charset != NULL)
7492
out_pt= xorriso->out_charset;
7494
ret= Xorriso_status_filter(xorriso, filter, "-in_charset", 0);
7496
ret= Xorriso_status_filter(xorriso, filter, "-out_charset", 0);
7499
if(strcmp(in_pt, out_pt) == 0 && !do_single) {
7500
sprintf(line, "-charset %s\n", Text_shellsafe(in_pt, sfe, 0));
7501
if(!(is_default && no_defaults))
7502
Xorriso_status_result(xorriso, filter, fp, flag & 2);
7504
sprintf(line, "-in_charset %s\n", Text_shellsafe(in_pt, sfe, 0));
7505
if(!(is_default && no_defaults))
7506
Xorriso_status_result(xorriso, filter, fp, flag & 2);
7507
sprintf(line, "-out_charset %s\n", Text_shellsafe(out_pt, sfe, 0));
7508
if(!(is_default && no_defaults))
7509
Xorriso_status_result(xorriso, filter, fp, flag & 2);
7511
is_default= ((xorriso->do_aaip & (256 | 512)) == 0);
7512
sprintf(line,"-auto_charset %s\n", (xorriso->do_aaip & 256 ? "on" : "off"));
7513
if(!(is_default && no_defaults))
7514
Xorriso_status_result(xorriso,filter,fp,flag&2);
7516
is_default= ((xorriso->ino_behavior & 31) == 7);
7517
switch (xorriso->ino_behavior & 15) {
7519
break; case 8: form= "without_update";
7520
break; default: form= "off";
7522
sprintf(line,"-hardlinks %s:%s\n", form,
7523
xorriso->ino_behavior & 16 ?
7524
"cheap_sorted_extract" : "normal_extract");
7525
if(!(is_default && no_defaults))
7526
Xorriso_status_result(xorriso,filter,fp,flag&2);
7528
is_default= ((xorriso->do_aaip & (1 | 4)) == 0);
7529
sprintf(line,"-acl %s\n", (xorriso->do_aaip & 1 ? "on" : "off"));
7530
if(!(is_default && no_defaults))
7531
Xorriso_status_result(xorriso,filter,fp,flag&2);
7532
is_default= ((xorriso->do_aaip & (2 | 8)) == 0);
7533
sprintf(line,"-xattr %s\n", (xorriso->do_aaip & 4 ? "on" : "off"));
7534
if(!(is_default && no_defaults))
7535
Xorriso_status_result(xorriso,filter,fp,flag&2);
7536
is_default= ((xorriso->do_aaip & (16 | 32 | 64)) == 0);
7537
sprintf(line,"-disk_dev_ino %s\n",
7538
(xorriso->do_aaip & 16 ? (xorriso->do_aaip & 128 ? "ino_only" : "on" )
7540
if(!(is_default && no_defaults))
7541
Xorriso_status_result(xorriso,filter,fp,flag&2);
7543
is_default= ((xorriso->do_md5 & 31) == 0);
7544
sprintf(line, "-md5 ");
7545
if(xorriso->do_md5 & 1) {
7546
if((xorriso->do_md5 & (8)) == (8)) {
7547
strcat(line, "all\n");
7550
if(xorriso->do_md5 & 8)
7551
strcat(line, ":stability_check_on");
7555
strcat(line, "off\n");
7556
if(!(is_default && no_defaults))
7557
Xorriso_status_result(xorriso,filter,fp,flag&2);
7559
is_default= (xorriso->scdbackup_tag_name[0] == 0 &&
7560
xorriso->scdbackup_tag_listname[0] == 0);
7561
sprintf(line, "-scdbackup_tag ");
7562
Text_shellsafe(xorriso->scdbackup_tag_listname, line, 1);
7564
Text_shellsafe(xorriso->scdbackup_tag_name, line, 1);
7566
if(!(is_default && no_defaults))
7567
Xorriso_status_result(xorriso,filter,fp,flag&2);
7569
is_default= (Xorriso_get_relax_text(xorriso, sfe, 0) == 2);
7570
sprintf(line,"-compliance %s\n", sfe);
7571
if(!(is_default && no_defaults))
7572
Xorriso_status_result(xorriso,filter,fp,flag&2);
7574
is_default= (xorriso->assert_volid[0] == 0);
7575
sprintf(line, "-assert_volid ");
7576
Text_shellsafe(xorriso->assert_volid, line, 1);
7578
Text_shellsafe(xorriso->assert_volid_sev, line, 1);
7580
if(!(is_default && no_defaults))
7581
Xorriso_status_result(xorriso,filter,fp,flag&2);
7584
if(xorriso->drive_blacklist != NULL || xorriso->drive_whitelist != NULL ||
7585
xorriso->drive_greylist == NULL)
7587
if(xorriso->drive_greylist != NULL) {
7588
if(strcmp(Xorriso_get_pattern(xorriso, xorriso->drive_greylist, 0, 0),
7591
if(Xorriso_get_pattern(xorriso, xorriso->drive_greylist, 1, 0) != NULL)
7594
if(!(is_default && no_defaults)) {
7595
for(s= xorriso->drive_blacklist; s != NULL; s= Xorriso_lst_get_next(s, 0)) {
7596
sprintf(line, "-drive_class 'banned' %s\n",
7597
Text_shellsafe(Xorriso_lst_get_text(s, 0), sfe, 0));
7598
Xorriso_status_result(xorriso,filter,fp,flag&2);
7600
for(s= xorriso->drive_greylist; s != NULL; s= Xorriso_lst_get_next(s, 0)) {
7601
sprintf(line, "-drive_class 'caution' %s\n",
7602
Text_shellsafe(Xorriso_lst_get_text(s, 0), sfe, 0));
7603
Xorriso_status_result(xorriso,filter,fp,flag&2);
7605
for(s= xorriso->drive_whitelist; s != NULL; s= Xorriso_lst_get_next(s, 0)) {
7606
sprintf(line, "-drive_class 'harmless' %s\n",
7607
Text_shellsafe(Xorriso_lst_get_text(s, 0), sfe, 0));
7608
Xorriso_status_result(xorriso,filter,fp,flag&2);
7614
if(dev_filter != NULL) {
7615
show_dev= Xorriso_status_filter(xorriso, filter, "-dev", 0);
7619
if(dev_filter != NULL) {
7620
show_indev= Xorriso_status_filter(xorriso, filter, "-indev", 0);
7621
show_outdev= Xorriso_status_filter(xorriso, filter, "-outdev", 0);
7622
if(show_outdev > 0 || show_indev > 0)
7625
if(xorriso->drives_exclusive != xorriso->indev_is_exclusive &&
7628
else if(xorriso->drives_exclusive != xorriso->outdev_is_exclusive &&
7631
if(strcmp(xorriso->indev, xorriso->outdev) == 0 && !do_single) {
7632
sprintf(line,"-dev %s\n", Text_shellsafe(xorriso->indev,sfe,0));
7633
Xorriso_status_result(xorriso, dev_filter, fp, flag & 2);
7635
if(xorriso->drives_exclusive != xorriso->indev_is_exclusive &&
7636
xorriso->indev[0] && show_indev) {
7637
sprintf(line,"-osirrox o_excl_%s\n",
7638
xorriso->indev_is_exclusive ? "on" : "off");
7639
Xorriso_status_result(xorriso, NULL, fp, flag & 2);
7641
sprintf(line,"-indev %s\n", Text_shellsafe(xorriso->indev,sfe,0));
7642
Xorriso_status_result(xorriso, dev_filter, fp, flag & 2);
7643
if(xorriso->drives_exclusive != xorriso->indev_is_exclusive &&
7644
xorriso->indev[0] && show_indev) {
7645
sprintf(line,"-osirrox o_excl_%s\n",
7646
xorriso->drives_exclusive ? "on" : "off");
7647
Xorriso_status_result(xorriso, NULL, fp, flag & 2);
7650
if(xorriso->drives_exclusive != xorriso->outdev_is_exclusive &&
7651
xorriso->outdev[0] && show_outdev) {
7652
sprintf(line,"-osirrox o_excl_%s\n",
7653
xorriso->outdev_is_exclusive ? "on" : "off");
7654
Xorriso_status_result(xorriso, NULL, fp, flag & 2);
7656
sprintf(line,"-outdev %s\n", Text_shellsafe(xorriso->outdev,sfe,0));
7657
Xorriso_status_result(xorriso, dev_filter, fp, flag & 2);
7658
if(xorriso->drives_exclusive != xorriso->outdev_is_exclusive &&
7659
xorriso->outdev[0] && show_outdev) {
7660
sprintf(line,"-osirrox o_excl_%s\n",
7661
xorriso->drives_exclusive ? "on" : "off");
7662
Xorriso_status_result(xorriso, NULL, fp, flag & 2);
7670
/* @param flag bit2= this is a disk_pattern
7671
@return <=0 failure , 1 pattern ok , 2 pattern needed prepended wd */
7672
int Xorriso_prepare_expansion_pattern(struct XorrisO *xorriso, char *pattern,
7677
ret= Xorriso_prepare_regex(xorriso, pattern, 1|2|(flag&4));
7679
ret= Xorriso_prepare_regex(xorriso, pattern, flag&4);
7683
sprintf(xorriso->info_text,
7684
"Cannot compile pattern to regular expression: %s", pattern);
7685
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
7692
/* @param flag bit0= count results rather than storing them
7693
bit1= unexpected change of number is a FATAL event
7694
@return <=0 error , 1 is root (end processing) ,
7695
2 is not root (go on processing)
7697
int Xorriso_check_for_root_pattern(struct XorrisO *xorriso,
7698
int *filec, char **filev, int count_limit, off_t *mem, int flag)
7700
if(xorriso->re_fill!=0)
7702
/* This is the empty pattern representing root */
7707
if(*filec >= count_limit) {
7708
sprintf(xorriso->info_text,
7709
"Number of matching files changed unexpectedly (> %d)",
7711
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0,
7712
(flag&2 ? "FATAL" : "WARNING"), 0);
7713
return(flag&2 ? -1 : 0);
7715
filev[*filec]= strdup("/");
7716
if(filev[*filec]==NULL) {
7717
Xorriso_no_pattern_memory(xorriso, (off_t) 2, 0);
7726
/* @param flag bit0= prepend wd only if name does not begin by '/'
7727
bit1= normalize image path
7728
bit2= prepend wd (automatically done if wd[0]!=0)
7729
bit3= (with bit1) this is an address in the disk world
7731
int Xorriso_make_abs_adr(struct XorrisO *xorriso, char *wd, char *name,
7732
char adr[], int flag)
7734
char norm_adr[SfileadrL];
7737
if((wd[0]!=0 || (flag&4)) && !((flag&1) && name[0]=='/')) {
7738
if(strlen(wd)+1>=SfileadrL)
7742
if(Sfile_add_to_path(adr, name, 0)<=0) {
7744
Xorriso_much_too_long(xorriso, (int) (strlen(adr)+strlen(name)+1), 2);
7748
if(strlen(name)+1>=SfileadrL)
7753
ret= Xorriso_normalize_img_path(xorriso, "", adr, norm_adr,
7758
strcpy(norm_adr, "/");
7759
strcpy(adr, norm_adr);
7766
@param result Bitfield indicationg type of mismatch
7767
bit11= cannot open regular disk file
7768
bit12= cannot open iso file
7769
bit13= early eof of disk file
7770
bit14= early eof of iso file
7771
bit15= content bytes differ
7772
@param flag bit0= mtimes of both file objects are equal
7773
bit29= do not issue pacifier messages
7774
bit31= do not issue result messages
7775
@return >0 ok , <=0 error
7777
int Xorriso_compare_2_contents(struct XorrisO *xorriso, char *common_adr,
7778
char *disk_adr, off_t disk_size,
7779
off_t offset, off_t bytes,
7780
char *iso_adr, off_t iso_size,
7781
int *result, int flag)
7783
int fd1= -1, ret, r1, r2, done, wanted, i, was_error= 0, use_md5= 0;
7784
void *stream2= NULL;
7785
off_t r1count= 0, r2count= 0, diffcount= 0, first_diff= -1;
7786
char *respt, buf1[32*1024], buf2[32*1024], offset_text[80];
7787
char disk_md5[16], iso_md5[16];
7790
respt= xorriso->result_line;
7792
fd1= open(disk_adr, O_RDONLY);
7794
sprintf(respt, "- %s (DISK) : cannot open() : %s\n",
7795
disk_adr, strerror(errno));
7798
Xorriso_result(xorriso,0);
7803
if(lseek(fd1, offset, SEEK_SET)==-1) {
7804
sprintf(respt, "- %s (DISK) : cannot lseek(%.f) : %s\n",
7805
disk_adr, (double) offset, strerror(errno));
7807
goto cannot_address;
7810
if(xorriso->do_md5 & 16) {
7812
ret= Xorriso_is_plain_image_file(xorriso, NULL, iso_adr, 0);
7814
ret= 0; /* (reverse) filtered files are likely not to match their MD5 */
7816
ret= Xorriso_get_md5(xorriso, NULL, iso_adr, iso_md5, 1);
7820
ret= Xorriso_md5_start(xorriso, &ctx, 0);
7826
ret= Xorriso_iso_file_open(xorriso, iso_adr, NULL, &stream2, 0);
7828
sprintf(respt, "- %s (ISO) : cannot open() file in ISO image\n",iso_adr);
7830
Xorriso_result(xorriso,0);
7840
wanted= sizeof(buf1);
7841
if(r1count+offset+wanted>disk_size)
7842
wanted= disk_size-r1count-offset;
7843
if(r1count+wanted>bytes)
7844
wanted= bytes-r1count;
7847
ret= read(fd1, buf1, wanted);
7854
wanted= sizeof(buf2);
7855
if(r2count+wanted>iso_size)
7856
wanted= iso_size-r2count;
7858
if(r2count+wanted>bytes)
7859
wanted= bytes-r2count;
7864
r2= Xorriso_iso_file_read(xorriso, stream2, buf2, wanted, 0);
7876
if(disk_size > r1count + r1 + offset) {
7877
sprintf(respt, "- %s (DISK) : early EOF after %.f bytes\n",
7878
disk_adr, (double) r1count);
7880
Xorriso_result(xorriso,0);
7883
(*result)|= (1<<15);
7886
if(r2<=0 || r2<r1) {
7889
if(iso_size > r2count + r2) {
7890
sprintf(respt, "- %s (ISO) : early EOF after %.f bytes\n",
7891
iso_adr, (double) r2count);
7893
Xorriso_result(xorriso,0);
7894
(*result)|= (1<<14);
7896
(*result)|= (1<<15);
7900
if(disk_size > r1count + r1 + offset) {
7901
sprintf(respt, "- %s (DISK) : early EOF after %.f bytes\n",
7902
disk_adr, (double) r1count);
7904
Xorriso_result(xorriso,0);
7907
(*result)|= (1<<15);
7915
Xorriso_md5_compute(xorriso, ctx, buf1, r1, 0);
7917
for(i= 0; i<r1; i++) {
7918
if(buf1[i]!=buf2[i]) {
7920
first_diff= r1count - r1 + i;
7925
if(!(flag&(1<<29))) {
7926
xorriso->pacifier_count+= r1;
7927
xorriso->pacifier_byte_count+= r1;
7929
Xorriso_pacifier_callback(xorriso, "content bytes read",
7930
xorriso->pacifier_count, 0, "", 0);
7932
Xorriso_pacifier_callback(xorriso, "bytes", xorriso->pacifier_count, 0,
7938
ret= Xorriso_md5_end(xorriso, &ctx, disk_md5, 0);
7940
*result |= (1 << 15);
7943
for(i= 0; i < 16; i++)
7944
if(iso_md5[i] != disk_md5[i])
7949
sprintf(offset_text, "%.f+", (double) offset);
7950
sprintf(respt, "%s %s : differs by MD5 sums.\n",
7951
common_adr, (flag&1 ? "CONTENT": "content"));
7953
Xorriso_result(xorriso,0);
7954
(*result)|= (1<<15);
7956
} else if(diffcount>0 || r1count!=r2count) {
7958
first_diff= (r1count>r2count ? r2count : r1count);
7961
sprintf(offset_text, "%.f+", (double) offset);
7962
sprintf(respt, "%s %s : differs by at least %.f bytes. First at %s%.f\n",
7963
common_adr, (flag&1 ? "CONTENT": "content"),
7964
(double) (diffcount + abs(r1count-r2count)),
7965
offset_text, (double) first_diff);
7967
Xorriso_result(xorriso,0);
7968
(*result)|= (1<<15);
7973
Xorriso_iso_file_close(xorriso, &stream2, 0);
7979
Xorriso_md5_end(xorriso, &ctx, disk_md5, 0);
7985
@param result Bitfield indicationg type of mismatch
7986
bit0= disk_adr not existing
7987
bit1= iso_adr not existing
7988
bit2= access permissions
7992
bit6= minor, major with device file
7997
bit11= cannot open regular disk file
7998
bit12= cannot open iso file
7999
bit13= early eof of disk file
8000
bit14= early eof of iso file
8001
bit15= content bytes differ
8002
bit16= symbolic link on disk pointing to dir, dir in iso
8003
bit17= file chunks detected and compared
8004
bit18= incomplete chunk collection encountered
8005
bit19= ACL differs (this condition sets also bit2)
8007
bit21= mismatch of recorded dev,inode
8008
bit22= no recorded dev,inode found in node
8009
bit23= timestamps younger than xorriso->isofs_st_in
8010
bit24= hardlink split
8011
bit25= hardlink fusion
8012
@param flag bit0= compare atime
8014
bit2= check only existence of both file objects
8015
count one or both missing as "difference"
8016
bit27= for Xorriso_path_is_excluded(): bit0
8017
bit28= examine eventual disk_path link target rather than link
8018
bit29= do not issue pacifier messages
8019
bit30= omit adr_common_tail in report messages
8020
bit31= do not issue result messages
8021
@return 1=files match properly , 0=difference detected , -1=error
8023
int Xorriso_compare_2_files(struct XorrisO *xorriso, char *disk_adr,
8024
char *iso_adr, char *adr_common_tail,
8025
int *result, int flag)
8027
struct stat s1, s2, stbuf;
8028
int ret, missing= 0, is_split= 0, i, was_error= 0, diff_count= 0;
8029
int content_shortcut= 0;
8031
char a[5*SfileadrL], sfe[5*SfileadrL];
8032
char ttx1[40], ttx2[40];
8033
char *a1_acl= NULL, *a2_acl= NULL, *d1_acl= NULL, *d2_acl= NULL;
8034
char *attrlist1= NULL, *attrlist2= NULL;
8035
struct SplitparT *split_parts= NULL;
8039
char part_path[SfileadrL], *part_name;
8040
int partno, total_parts= 0;
8041
off_t offset, bytes, total_bytes;
8044
respt= xorriso->result_line;
8046
if(!(xorriso->disk_excl_mode&8)) {
8047
ret= Xorriso_path_is_excluded(xorriso, disk_adr, 2 | !!(flag&(1<<27)));
8049
sprintf(respt , "? %s (DISK) : exluded by %s\n",
8050
Text_shellsafe(disk_adr, sfe, 0),
8051
(ret==1 ? "-not_paths" : "-not_leaf"));
8053
Xorriso_result(xorriso,0);
8060
ret= stat(disk_adr, &s1);
8062
ret= lstat(disk_adr, &s1);
8064
sprintf(respt , "? %s (DISK) : cannot lstat() : %s\n",
8065
Text_shellsafe(disk_adr, sfe, 0), strerror(errno));
8067
Xorriso_result(xorriso,0);
8075
strcpy(a, Ftypetxt(s1.st_mode, 1));
8077
if(adr_common_tail[0])
8078
strcat(a, Text_shellsafe(adr_common_tail, sfe, 0));
8080
Text_shellsafe(disk_adr, a+strlen(a), 0);
8081
strcat(a, " (DISK)");
8090
ret= Xorriso_iso_lstat(xorriso, iso_adr, &s2, 0);
8092
sprintf(respt, "? %s (ISO) : cannot find this file in ISO image\n",
8093
Text_shellsafe(iso_adr, sfe, 0));
8095
Xorriso_result(xorriso,0);
8100
if((flag&4)||missing)
8101
{ret= !missing; goto ex;}
8104
/* Splitfile parts */
8105
if((S_ISREG(s1.st_mode) || S_ISBLK(s1.st_mode)) && S_ISDIR(s2.st_mode)) {
8106
is_split= Xorriso_identify_split(xorriso, iso_adr, NULL, &split_parts,
8107
&split_count, &s2, 0);
8109
(*result)|= (1<<17);
8115
if(s1.st_mode != s2.st_mode) {
8116
if((s1.st_mode&~S_IFMT)!=(s2.st_mode&~S_IFMT)) {
8117
sprintf(respt, "%s st_mode : %7.7o <> %7.7o\n",
8118
a, (unsigned int) (s1.st_mode & ~S_IFMT),
8119
(unsigned int) (s2.st_mode & ~S_IFMT));
8121
Xorriso_result(xorriso,0);
8125
if((s1.st_mode&S_IFMT)!=(s2.st_mode&S_IFMT)) {
8126
sprintf(respt, "%s type : %s <> %s\n",
8127
a, Ftypetxt(s1.st_mode, 0), Ftypetxt(s2.st_mode, 0));
8129
Xorriso_result(xorriso,0);
8131
if((s1.st_mode&S_IFMT) == S_IFLNK) {
8132
/* check whether link target type matches */
8133
ret= stat(disk_adr, &stbuf);
8135
if(S_ISDIR(stbuf.st_mode) && S_ISDIR(s2.st_mode))
8136
(*result)|= (1<<16);
8142
if(xorriso->do_aaip & 3) {
8143
Xorriso_local_getfacl(xorriso, disk_adr, &a1_acl,
8144
16 | ((flag & (1 << 28)) >> 23));
8145
if(S_ISDIR(s1.st_mode))
8146
Xorriso_local_getfacl(xorriso, disk_adr, &d1_acl, 1);
8147
ret= Xorriso_getfacl(xorriso, NULL, iso_adr, &a2_acl, 1 | 4 | 16);
8150
if(S_ISDIR(s1.st_mode)) {
8151
ret= Xorriso_getfacl(xorriso, NULL, iso_adr, &d2_acl, 1 | 8);
8155
ret= Compare_text_lines(a1_acl, a2_acl, &diff_count, 0);
8159
(*result)|= 4 | (1 << 19);
8160
ret= Compare_text_lines(d1_acl, d2_acl, &diff_count, 1);
8164
(*result)|= 4 | (1 << 19);
8165
if((*result) & (1 << 19)) {
8166
sprintf(respt, "%s ACL : %d difference%s\n",
8167
a, diff_count, diff_count == 1 ? "" : "s");
8169
Xorriso_result(xorriso,0);
8174
if(xorriso->do_aaip & 12) {
8175
ret= Xorriso_getfattr(xorriso, NULL, disk_adr, &attrlist1,
8176
1 | 2 | ((flag & (1 << 28)) >> 23));
8179
ret= Xorriso_getfattr(xorriso, NULL, iso_adr, &attrlist2, 1);
8182
ret= Compare_text_lines(attrlist1, attrlist2, &diff_count, 0);
8186
(*result)|= (1 << 20);
8187
sprintf(respt, "%s xattr : %d difference%s\n",
8188
a, diff_count, diff_count == 1 ? "" : "s");
8190
Xorriso_result(xorriso,0);
8194
if(s1.st_uid != s2.st_uid) {
8195
sprintf(respt, "%s st_uid : %lu <> %lu\n", a,
8196
(unsigned long) s1.st_uid, (unsigned long) s2.st_uid);
8198
Xorriso_result(xorriso,0);
8201
if(s1.st_gid != s2.st_gid) {
8202
sprintf(respt, "%s st_gid : %lu <> %lu\n", a,
8203
(unsigned long) s1.st_gid, (unsigned long) s2.st_gid);
8205
Xorriso_result(xorriso,0);
8208
if((S_ISCHR(s1.st_mode) && S_ISCHR(s2.st_mode)) ||
8209
(S_ISBLK(s1.st_mode) && S_ISBLK(s2.st_mode))) {
8210
if(s1.st_rdev != s2.st_rdev) {
8211
sprintf(respt, "%s %s st_rdev : %lu <> %lu\n", a,
8212
(S_ISCHR(s1.st_mode) ? "S_IFCHR" : "S_IFBLK"),
8213
(unsigned long) s1.st_rdev, (unsigned long) s1.st_rdev);
8215
Xorriso_result(xorriso,0);
8219
if((!(xorriso->do_aaip & 32)) &&
8220
S_ISREG(s2.st_mode) && s1.st_size != s2.st_size) {
8221
sprintf(respt, "%s st_size : %.f <> %.f diff= %.f\n",
8222
a, (double) s1.st_size, (double) s2.st_size,
8223
((double) s1.st_size) - (double) s2.st_size);
8225
Xorriso_result(xorriso,0);
8228
if(s1.st_mtime != s2.st_mtime) {
8229
sprintf(respt, "%s st_mtime : %s <> %s diff= %.f s\n",
8230
a, Ftimetxt(s1.st_mtime, ttx1, 0),
8231
Ftimetxt(s2.st_mtime, ttx2, 0),
8232
((double) s1.st_mtime) - (double) s2.st_mtime);
8234
Xorriso_result(xorriso,0);
8238
if(s1.st_atime != s2.st_atime) {
8239
sprintf(respt, "%s st_atime : %s <> %s diff= %.f s\n",
8240
a, Ftimetxt(s1.st_atime, ttx1, 0),
8241
Ftimetxt(s2.st_atime, ttx2, 0),
8242
((double) s1.st_atime) - (double) s2.st_atime);
8244
Xorriso_result(xorriso,0);
8249
if(s1.st_ctime != s2.st_ctime) {
8250
sprintf(respt, "%s st_ctime : %s <> %s diff= %.f s\n",
8251
a, Ftimetxt(s1.st_ctime, ttx1, 0),
8252
Ftimetxt(s2.st_ctime, ttx2, 0),
8253
((double) s1.st_ctime) - (double) s2.st_ctime);
8255
Xorriso_result(xorriso,0);
8259
if(xorriso->isofs_st_in > 0 &&
8260
(xorriso->isofs_st_in <= s2.st_mtime ||
8261
((flag & 1) && xorriso->isofs_st_in <= s2.st_atime) ||
8262
((flag & 2) && xorriso->isofs_st_in <= s2.st_ctime)))
8263
(*result)|= 1 << 23;
8265
if((xorriso->do_aaip & 32) || !(xorriso->ino_behavior & 2)) {
8266
/* dev,inode comparison.
8267
For skipping content comparison or for hardlink detection.
8269
ret= Xorriso_record_dev_inode(xorriso, "", s1.st_dev, s1.st_ino, NULL,
8270
iso_adr, 1 | 2 | ((flag & (1 << 28)) >> 23) | (xorriso->do_aaip & 128));
8273
} else if(ret == 0) { /* match */
8274
if((xorriso->do_aaip & 64) && S_ISREG(s1.st_mode) && S_ISREG(s2.st_mode)){
8275
if(xorriso->do_aaip & 32)
8276
content_shortcut= 1;
8277
if((*result) & (8 | 128 | 256 | 512 | 1024 | (1 << 23))) {
8278
(*result)|= (1 << 15); /* content bytes differ */
8279
if(((*result) & (1 << 23)) &&
8280
!((*result) & (8 | 128 | 256 | 512 | 1024))) {
8282
"%s content : node timestamp younger than image timestamp\n", a);
8283
if((xorriso->do_aaip & 32) && !(flag&(1<<31)))
8284
Xorriso_result(xorriso,0);
8286
if((flag & 1) && s2.st_atime >= stamp)
8288
if((flag & 2) && s2.st_ctime >= stamp)
8290
sprintf(respt, "%s content : %s > %s diff= %.f s\n",
8291
a, Ftimetxt(stamp, ttx1, 3 << 1),
8292
Ftimetxt(xorriso->isofs_st_in, ttx2, 3 << 1),
8293
((double) stamp) - (double) xorriso->isofs_st_in);
8294
if((xorriso->do_aaip & 32) && !(flag&(1<<31)))
8295
Xorriso_result(xorriso,0);
8298
"%s content : assuming inequality due to size or timestamps\n", a);
8299
if((xorriso->do_aaip & 32) && !(flag&(1<<31)))
8300
Xorriso_result(xorriso,0);
8303
} else if(ret == 1) { /* mismatch */
8304
(*result)|= (1 << 21);
8305
sprintf(respt, "%s dev_ino : differing\n", a);
8306
if((xorriso->do_aaip & 32) && !(flag&(1<<31)))
8307
Xorriso_result(xorriso,0);
8309
if((xorriso->do_aaip & 64) && S_ISREG(s1.st_mode) && S_ISREG(s2.st_mode)){
8310
if(xorriso->do_aaip & 32)
8311
content_shortcut= 1;
8312
(*result)|= (1 << 15); /* content bytes differ */
8314
"%s content : assuming inequality after dev_ino mismatch\n", a);
8315
if((xorriso->do_aaip & 32) && !(flag&(1<<31)))
8316
Xorriso_result(xorriso,0);
8319
sprintf(respt, "%s dev_ino : no dev_ino stored with image node\n", a);
8320
if((xorriso->do_aaip & 32) && !(flag&(1<<31)))
8321
Xorriso_result(xorriso,0);
8322
(*result)|= (1 << 22);
8326
if(S_ISREG(s1.st_mode) && S_ISREG(s2.st_mode) && !content_shortcut) {
8329
for(i= 0; i<split_count; i++) {
8330
Splitparts_get(split_parts, i, &part_name, &partno, &total_parts,
8331
&offset, &bytes, &total_bytes, 0);
8332
strcpy(part_path, iso_adr);
8333
if(Sfile_add_to_path(part_path, part_name, 0)<=0) {
8334
Xorriso_much_too_long(xorriso, strlen(iso_adr)+strlen(part_name)+1,
8338
ret= Xorriso_iso_lstat(xorriso, part_path, &stbuf, 0);
8341
ret= Xorriso_compare_2_contents(xorriso, a, disk_adr, s1.st_size,
8343
part_path, stbuf.st_size, result,
8344
(s1.st_mtime==s2.st_mtime) | (flag&((1<<29)|(1<<31))));
8348
if(total_parts>0 && split_count!=total_parts) {
8349
sprintf(xorriso->info_text,
8350
"- %s/* (ISO) : Not all split parts present (%d of %d)\n",
8351
iso_adr, split_count, total_parts);
8353
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 1);
8357
ret= Xorriso_compare_2_contents(xorriso, a, disk_adr, s1.st_size,
8358
(off_t) 0, s1.st_size,
8359
iso_adr, s2.st_size, result,
8360
(s1.st_mtime==s2.st_mtime) | (flag&((1<<29)|(1<<31))));
8369
ret= (((*result) & ~((1 << 17) | (1 << 18) | (1 << 23)))==0);
8371
if(split_parts!=NULL)
8372
Splitparts_destroy(&split_parts, split_count, 0);
8373
Xorriso_local_getfacl(xorriso, disk_adr, &a1_acl, 1 << 15);
8374
Xorriso_local_getfacl(xorriso, disk_adr, &d1_acl, 1 << 15);
8383
int Xorriso_pfx_disk_path(struct XorrisO *xorriso, char *iso_path,
8384
char *iso_prefix, char *disk_prefix,
8385
char disk_path[SfileadrL], int flag)
8388
char adrc[SfileadrL];
8390
if(strncmp(iso_path, iso_prefix, strlen(iso_prefix))!=0)
8392
if(strlen(disk_prefix) + strlen(iso_path) - strlen(iso_prefix)+1 >= SfileadrL)
8394
if(iso_path[strlen(iso_prefix)] == '/')
8395
strcpy(adrc, iso_path + strlen(iso_prefix) + 1);
8397
strcpy(adrc, iso_path + strlen(iso_prefix));
8398
ret= Xorriso_make_abs_adr(xorriso, disk_prefix, adrc, disk_path, 4 | 8);
8405
/* @param boss_iter Opaque handle to be forwarded to actions in ISO image
8406
Set to NULL if calling this function from outside ISO world
8407
@param flag bit0= update rather than compare
8408
bit1= find[ix] is in recursion
8409
@return <=0 error, 1= ok , 2= iso_path was deleted
8410
3=ok, do not dive into directory (e.g. because it is a split file)
8412
int Xorriso_find_compare(struct XorrisO *xorriso, void *boss_iter,
8413
char *iso_path, char *iso_prefix, char *disk_prefix,
8416
int ret, result, uret, follow_links, deleted= 0;
8417
char disk_path[SfileadrL];
8419
ret= Xorriso_pfx_disk_path(xorriso, iso_path, iso_prefix, disk_prefix,
8424
/* compare exclusions against disk_path resp. leaf name */
8425
if(xorriso->disk_excl_mode&8)
8426
ret= Xorriso_path_is_excluded(xorriso, disk_path, !(flag&2));
8434
follow_links= (xorriso->do_follow_links ||
8435
(xorriso->do_follow_param && !(flag&2))) <<28;
8436
ret= Xorriso_compare_2_files(xorriso, disk_path, iso_path, "", &result,
8437
2 | follow_links | ((!(flag&2))<<27) | ((flag&1)<<31));
8438
/* was once: | ((!(flag&1))<<29) */
8439
if(ret<xorriso->find_compare_result)
8440
xorriso->find_compare_result= ret;
8444
if(Xorriso_eval_problem_status(xorriso, ret, 1|2)<0)
8446
uret= Xorriso_update_interpreter(xorriso, boss_iter, result,
8447
disk_path, iso_path, (flag&2)<<1);
8464
/* @param flag bit0= count result rather than storing it
8465
bit1= unexpected change of number is a FATAL event
8467
int Xorriso_register_matched_adr(struct XorrisO *xorriso,
8468
char *adr, int count_limit,
8469
int *filec, char **filev, off_t *mem, int flag)
8476
(*mem)+= sizeof(char *)+l;
8477
if(l % sizeof(char *))
8478
(*mem)+= sizeof(char *)-(l % sizeof(char *));
8480
if(*filec >= count_limit) {
8481
sprintf(xorriso->info_text,
8482
"Number of matching files changed unexpectedly (> %d)",
8484
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0,
8485
(flag&2 ? "FATAL" : "WARNING"), 0);
8486
return(flag&2 ? -1 : 0);
8488
filev[*filec]= strdup(adr);
8489
if(filev[*filec]==NULL) {
8490
Xorriso_no_pattern_memory(xorriso, (off_t) (strlen(adr)+1), 0);
8499
/* @param flag bit0= count results rather than storing them
8500
bit1= this is a recursion
8501
bit2= prepend wd (automatically done if wd[0]!=0)
8502
@return <=0 error , 1 ok , 2 could not open directory
8504
int Xorriso_obtain_pattern_files_x(
8505
struct XorrisO *xorriso, char *wd, char *dir_adr,
8506
int *filec, char **filev, int count_limit, off_t *mem,
8507
int *dive_count, int flag)
8509
int ret, failed_at, follow_mount, follow_links;
8510
struct DirseQ *dirseq= NULL;
8514
char *adr= NULL, *name= NULL, *path_data= NULL;
8516
adr= malloc(SfileadrL);
8517
name= malloc(SfileadrL);
8518
path_data= malloc(SfileadrL);
8519
if(adr==NULL || name==NULL || path_data==NULL) {
8520
Xorriso_no_malloc_memory(xorriso, &adr, 0);
8523
follow_mount= (xorriso->do_follow_mount || xorriso->do_follow_pattern);
8524
follow_links= (xorriso->do_follow_links || xorriso->do_follow_pattern);
8530
ret= Xorriso_check_for_root_pattern(xorriso, filec, filev, count_limit,
8535
if(lstat(dir_adr, &stbuf)==-1)
8537
dir_dev= stbuf.st_dev;
8538
if(S_ISLNK(stbuf.st_mode)) {
8539
if(stat(dir_adr, &stbuf)==-1)
8541
if(dir_dev != stbuf.st_dev && !follow_mount)
8544
ret= Dirseq_new(&dirseq, dir_adr, 1);
8546
sprintf(xorriso->info_text, "Cannot obtain disk directory iterator");
8547
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
8554
ret= Dirseq_next_adr(dirseq,name,0);
8558
sprintf(xorriso->info_text,"Failed to obtain next directory entry");
8559
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
8563
ret= Xorriso_make_abs_adr(xorriso, wd, name, adr, flag&4);
8567
ret= Xorriso_regexec(xorriso, adr, &failed_at, 1);
8568
if(ret>0) { /* no match */
8569
if(failed_at <= *dive_count) /* no hope for a match */
8574
ret= Xorriso_make_abs_adr(xorriso, xorriso->wdx, adr, path, 1|4);
8580
ret= stat(path,&stbuf);
8582
ret= lstat(path,&stbuf);
8585
if(!S_ISDIR(stbuf.st_mode))
8587
if(dir_dev != stbuf.st_dev && !follow_mount)
8591
ret= Xorriso_obtain_pattern_files_x(xorriso, adr, path,
8592
filec, filev, count_limit, mem, dive_count, flag|2);
8596
ret= Xorriso_register_matched_adr(xorriso, adr, count_limit,
8597
filec, filev, mem, flag&1);
8612
Dirseq_destroy(&dirseq,0);
8619
int Xorriso_eval_nonmatch(struct XorrisO *xorriso, char *pattern,
8620
int *nonconst_mismatches, off_t *mem, int flag)
8624
/* Is this a constant pattern ? */
8625
for(k= 0; k<xorriso->re_fill; k++) {
8626
if(xorriso->re_constants[k]==NULL)
8628
if(xorriso->re_constants[k][0]==0)
8631
if(k<xorriso->re_fill)
8632
(*nonconst_mismatches)++; /* it is not */
8634
l= strlen(pattern)+1;
8635
(*mem)+= sizeof(char *)+l;
8636
if(l % sizeof(char *))
8637
(*mem)+= sizeof(char *)-(l % sizeof(char *));
8642
/* @param flag bit0= a match count !=1 is a SORRY event
8643
bit1= a match count !=1 is a FAILURE event
8645
int Xorriso_check_matchcount(struct XorrisO *xorriso,
8646
int count, int nonconst_mismatches, int num_patterns,
8647
char **patterns, int flag)
8649
char sfe[5*SfileadrL];
8651
if((flag&1) && (count!=1 || nonconst_mismatches)){
8652
if(count-nonconst_mismatches>0)
8653
sprintf(xorriso->info_text,
8654
"Pattern match with more than one file object");
8656
sprintf(xorriso->info_text, "No pattern match with any file object");
8658
sprintf(xorriso->info_text+strlen(xorriso->info_text), ": %s",
8659
Text_shellsafe(patterns[0], sfe, 0));
8660
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0,
8661
(flag&2 ? "FAILURE" : "SORRY"), 0);
8668
int Xorriso_no_pattern_memory(struct XorrisO *xorriso, off_t mem, int flag)
8672
Sfile_scale((double) mem, mem_text,5,1e4,1);
8673
sprintf(xorriso->info_text,
8674
"Cannot allocate enough memory (%s) for pattern expansion",
8676
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
8681
int Xorriso_no_malloc_memory(struct XorrisO *xorriso, char **to_free, int flag)
8684
if(*to_free!=NULL) {
8685
/* Eventual memory sacrifice to get on going */
8689
sprintf(xorriso->info_text, "Out of virtual memory");
8690
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "ABORT", 0);
8695
int Xorriso_alloc_pattern_mem(struct XorrisO *xorriso, off_t mem,
8696
int count, char ***filev, int flag)
8698
char mem_text[80], limit_text[80];
8700
Sfile_scale((double) mem, mem_text,5,1e4,0);
8701
sprintf(xorriso->info_text,
8702
"Temporary memory needed for pattern expansion : %s", mem_text);
8704
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0);
8705
if(mem > xorriso->temp_mem_limit) {
8706
Sfile_scale((double) xorriso->temp_mem_limit, limit_text,5,1e4,1);
8707
sprintf(xorriso->info_text,
8708
"List of matching file addresses exceeds -temp_mem_limit (%s > %s)",
8709
mem_text, limit_text);
8710
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
8714
(*filev)= (char **) calloc(count, sizeof(char *));
8716
Xorriso_no_pattern_memory(xorriso, mem, 0);
8723
/* @param flag bit0= a match count !=1 is a FAILURE event
8724
bit1= with bit0 tolerate 0 matches if pattern is a constant
8726
int Xorriso_expand_disk_pattern(struct XorrisO *xorriso,
8727
int num_patterns, char **patterns, int extra_filec,
8728
int *filec, char ***filev, off_t *mem, int flag)
8730
int ret, count= 0, abs_adr= 0, i, was_count, was_filec;
8731
int nonconst_mismatches= 0, dive_count= 0;
8732
char sfe[5*SfileadrL], dir_adr[SfileadrL];
8737
xorriso->search_mode= 3;
8738
xorriso->structured_search= 1;
8740
for(i= 0; i<num_patterns; i++) {
8742
ret= Xorriso_prepare_expansion_pattern(xorriso, patterns[i], 4);
8748
if(patterns[i][0]=='/' || abs_adr) {
8749
strcpy(dir_adr, "/");
8752
strcpy(dir_adr, xorriso->wdx);
8754
strcpy(dir_adr, "/");
8755
ret= Sfile_type(dir_adr, 1|4);
8757
Xorriso_msgs_submit(xorriso, 0, dir_adr, 0, "ERRFILE", 0);
8758
sprintf(xorriso->info_text,
8759
"Address set by -cdx is not a directory: %s",
8760
Text_shellsafe(dir_adr, sfe, 0));
8761
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
8766
/* count the matches */
8768
ret= Xorriso_obtain_pattern_files_x(xorriso, "", dir_adr, &count, NULL, 0,
8769
mem, &dive_count, 1 | abs_adr);
8772
if(was_count==count && strcmp(patterns[i],"*")!=0 && (flag&3)!=1) {
8774
ret= Xorriso_eval_nonmatch(xorriso, patterns[i],
8775
&nonconst_mismatches, mem, 0);
8781
ret= Xorriso_check_matchcount(xorriso, count, nonconst_mismatches,
8782
num_patterns, patterns, (flag&1)|2);
8786
count+= extra_filec;
8787
mem+= extra_filec*sizeof(char *);
8792
ret= Xorriso_alloc_pattern_mem(xorriso, *mem, count, filev, 0);
8796
/* now store addresses */
8797
for(i= 0; i<num_patterns; i++) {
8799
ret= Xorriso_prepare_expansion_pattern(xorriso, patterns[i], 4);
8803
if(patterns[i][0]=='/' || abs_adr) {
8804
strcpy(dir_adr, "/");
8807
strcpy(dir_adr, xorriso->wdx);
8809
strcpy(dir_adr, "/");
8813
ret= Xorriso_obtain_pattern_files_x(xorriso, "", dir_adr, filec, *filev,
8814
count, mem, &dive_count, abs_adr);
8818
if(was_filec == *filec && strcmp(patterns[i],"*")!=0) {
8819
(*filev)[*filec]= strdup(patterns[i]);
8820
if((*filev)[*filec]==NULL) {
8821
(*mem)= strlen(patterns[i])+1;
8822
Xorriso_no_pattern_memory(xorriso, *mem, 0);
8833
Sfile_destroy_argv(&count, filev, 0);
8840
/* @param flag bit0= command without pattern capability
8841
bit1= disk_pattern rather than iso_rr_pattern
8843
int Xorriso_warn_of_wildcards(struct XorrisO *xorriso, char *path, int flag)
8845
if(strchr(path,'*')!=NULL || strchr(path,'?')!=NULL ||
8846
strchr(path,'[')!=NULL) {
8848
sprintf(xorriso->info_text,
8849
"Pattern expansion of wildcards \"*?[\" does not apply to this command");
8851
sprintf(xorriso->info_text,
8852
"Pattern expansion of wildcards \"*?[\" is disabled by command %s",
8853
(flag&2) ? "-disk_pattern or -pathspecs" : "-iso_rr_pattern");
8855
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0);
8856
sprintf(xorriso->info_text,"Pattern seen: %s\n", path);
8857
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0);
8864
/* @param flag bit0= do not warn of wildcards
8865
bit1= these are disk_paths
8867
int Xorriso_end_idx(struct XorrisO *xorriso,
8868
int argc, char **argv, int idx, int flag)
8872
for(i= idx; i<argc; i++) {
8873
if(strcmp(argv[i], xorriso->list_delimiter)==0)
8875
if(!((flag&1) || warned))
8876
warned= Xorriso_warn_of_wildcards(xorriso, argv[i], flag&2);
8882
/* Returns a vector of strings which belong to an open ended arg list.
8883
If expansion is enabled, the vector might be allocated, else it is
8884
a pointer into the argv input vector.
8885
Thus the release of that memory is an expert task to be done by this
8886
function only. Use bit8 for that. With bit8 parameter argc MUST be the
8887
same value as with the call which might have allocated memory.
8888
@param xorriso The environment object
8889
@param argc Length of argv
8890
@param argv The vector with arguments, eventual list_delimiter ("--")
8891
and then eventual unrelated words
8892
@param idx Start index in argv of the argument list
8893
@param optc Length of the effective possibly expanded option vector
8894
@param optv The option vector. Maybe a pointer into argv or maybe
8895
an own allocated vector.
8896
@param flag bit0= do not warn of wildcards
8897
bit1= these are disk_paths
8898
bit2= never expand wildcards
8899
bit3= do not expand last argument
8900
bit4= ignore last argument
8901
bit5= demand exactly one match
8902
bit6= with bit5 allow 0 matches if pattern is a constant
8903
bit7= silently tolerate empty argument list
8904
bit8= free the eventually allocated sub_vector
8906
int Xorriso_opt_args(struct XorrisO *xorriso, char *cmd,
8907
int argc, char **argv, int idx,
8908
int *end_idx, int *optc, char ***optv, int flag)
8910
int i, do_expand, nump, was_empty= 0, filec= 0, ret;
8911
char **filev= NULL, **patterns= NULL;
8915
do_expand= xorriso->do_disk_pattern==1 && !(flag&4);
8917
do_expand= xorriso->do_iso_rr_pattern==1 && !(flag&4);
8919
if(*optv<argv || *optv>=argv+argc)
8920
Sfile_destroy_argv(optc, optv, 0);
8927
sprintf(xorriso->info_text, "%s : Not enough arguments given", cmd);
8930
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
8933
*end_idx= Xorriso_end_idx(xorriso, argc, argv, idx,
8934
((flag&1) || do_expand) | (flag&2));
8937
if((flag&16) && (*end_idx)>idx)
8939
*optc= *end_idx - idx;
8941
if(*optc<=0 || !do_expand)
8943
patterns= calloc(*optc, sizeof(char *));
8944
if(patterns==NULL) {
8946
sprintf(xorriso->info_text,
8947
"%s : Cannot allocate enough memory for pattern expansion", cmd);
8948
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
8954
mem+= strlen(argv[idx + *optc - 1])+1+sizeof(char *);
8956
for(i= 0; i<*optc-!!(flag&8); i++) {
8957
if(argv[i + idx][0]==0) {
8959
mem+= sizeof(char *); /* as upper limit for size of an empty string */
8962
patterns[nump++]= argv[i + idx];
8964
if(nump<=0) { /* Only empty texts. May the caller get happy with them. */
8969
ret= Xorriso_expand_disk_pattern(xorriso, nump, patterns, was_empty,
8970
&filec, &filev, &mem, (flag>>5)&3);
8972
ret= Xorriso_expand_pattern(xorriso, nump, patterns, was_empty,
8973
&filec, &filev, &mem, (flag>>5)&3);
8976
for(i= 0; i<was_empty; i++) {
8977
if(i==was_empty-1 && (flag&8))
8978
filev[filec++]= strdup(argv[idx + *optc - 1]);
8980
filev[filec++]= strdup("");
8981
if(filev[filec-1]==NULL)
8985
#ifdef Xorriso_verbous_pattern_expansioN
8987
sprintf(xorriso->info_text, "Pattern expansion yields %d items:", filec);
8988
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0);
8990
xorriso->info_text[0]= 0;
8991
for(i= 0; i<filec; i++) {
8992
l= strlen(xorriso->info_text);
8993
if(l>0 && l+1+strlen(filev[i])>60) {
8994
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0);
8995
xorriso->info_text[0]= 0;
8998
sprintf(xorriso->info_text+l, " %s", filev[i]);
9000
l= strlen(xorriso->info_text);
9002
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0);
9004
#endif /* Xorriso_verbous_pattern_expansioN */
9010
free((char *) patterns);
9011
Sfile_destroy_argv(&filec, &filev, 0);
9020
int Xorriso_get_problem_status(struct XorrisO *xorriso, char severity[80],
9023
strcpy(severity, xorriso->problem_status_text);
9024
return(xorriso->problem_status);
9028
int Xorriso_set_problem_status(struct XorrisO *xorriso, char *severity,
9031
char *sev_text= "ALL";
9036
ret= Xorriso__text_to_sev(sev_text, &sev, 0);
9039
xorriso->problem_status= sev;
9040
strcpy(xorriso->problem_status_text, sev_text);
9041
if(sev > xorriso->eternal_problem_status) {
9042
xorriso->eternal_problem_status= sev;
9043
strcpy(xorriso->eternal_problem_status_text, sev_text);
9049
/* @param flag bit0-7= purpose
9051
1= mark line (only to be put out if enabled)
9053
int Xorriso_process_errfile(struct XorrisO *xorriso,
9054
int error_code, char msg_text[], int os_errno,
9060
if(strlen(msg_text)>SfileadrL)
9064
if(purpose==1 && !(xorriso->errfile_mode&1))
9066
if(xorriso->errfile_fp!=NULL) {
9068
fprintf(xorriso->errfile_fp, "----------------- %s %s\n",
9069
msg_text, Ftimetxt(time(0), ttx, 1));
9071
fprintf(xorriso->errfile_fp, "%s\n", msg_text);
9072
fflush(xorriso->errfile_fp);
9075
if(xorriso->errfile_log[0]==0)
9077
if(strcmp(xorriso->errfile_log, "-")==0 ||
9078
strcmp(xorriso->errfile_log, "-R")==0) {
9080
sprintf(xorriso->result_line, "----------------- %s %s\n",
9081
msg_text, Ftimetxt(time(0), ttx, 1));
9083
sprintf(xorriso->result_line, "%s\n", msg_text);
9084
Xorriso_result(xorriso, 1);
9087
if(strcmp(xorriso->errfile_log, "-I")==0) {
9089
sprintf(xorriso->info_text, "ERRFILE_MARK=%s %s\n",
9090
msg_text, Ftimetxt(time(0), ttx, 1));
9092
sprintf(xorriso->info_text, "ERRFILE=%s", msg_text);
9093
Xorriso_info(xorriso, 0);
9100
/* Note: It is ok to submit xorriso->info_text as msg_text here. */
9102
bit0= for Xorriso_info() : use pager (as with result)
9103
bit1= for Xorriso_info() : permission to suppress output
9104
bit2..5= name prefix
9110
bit6= append carriage return rather than line feed (if not os_errno)
9111
bit7= perform Xorriso_process_msg_queues() first
9113
int Xorriso_msgs_submit(struct XorrisO *xorriso,
9114
int error_code, char msg_text[], int os_errno,
9115
char severity[], int flag)
9117
int ret, lt, li, sev, i;
9118
char *sev_text= "FATAL", prefix[80];
9119
static char pfx_list[20][16]= {
9120
"xorriso : ", "libisofs: ", "libburn : ", "libisoburn: ",
9121
"", "", "", "", "", "", "", "", "", "", "", "" };
9124
Xorriso_process_msg_queues(xorriso, 0);
9126
if(strcmp(severity, "ERRFILE")==0)
9127
Xorriso_process_errfile(xorriso, error_code, msg_text, os_errno, 0);
9129
/* Set problem status */
9130
ret= Xorriso__text_to_sev(severity, &sev, 0);
9132
Xorriso__text_to_sev(sev_text, &sev, 0);
9135
if(xorriso->problem_status<sev) {
9136
xorriso->problem_status= sev;
9137
strcpy(xorriso->problem_status_text, sev_text);
9139
if(xorriso->eternal_problem_status<sev) {
9140
xorriso->eternal_problem_status= sev;
9141
strcpy(xorriso->eternal_problem_status_text, sev_text);
9144
/* Report problem event */
9145
if(sev<xorriso->report_about_severity && sev<xorriso->abort_on_severity)
9147
sprintf(prefix,"%s%s : ", pfx_list[(flag>>2)&15], sev_text);
9149
lt= strlen(msg_text);
9150
if(lt>sizeof(xorriso->info_text)-li-2)
9151
lt= sizeof(xorriso->info_text)-li-2;
9152
if(msg_text==xorriso->info_text) {
9153
for(i= lt; i>=0; i--)
9154
msg_text[i+li]= msg_text[i];
9156
msg_text[i]= prefix[i];
9158
strcpy(xorriso->info_text, prefix);
9159
strncpy(xorriso->info_text+li, msg_text, lt);
9161
if((flag&64) && os_errno<=0)
9162
xorriso->info_text[li+lt]= '\r';
9164
xorriso->info_text[li+lt]= '\n';
9165
xorriso->info_text[li+lt+1]= 0;
9166
Xorriso_info(xorriso,4|(flag&3));
9168
sprintf(xorriso->info_text, "%ssys : %s\n",
9169
pfx_list[(flag>>2)&15], strerror(os_errno));
9170
Xorriso_info(xorriso,4|(flag&3));
9176
/* To be used with isoburn_set_msgs_submit()
9178
int Xorriso_msgs_submit_void(void *xorriso,
9179
int error_code, char msg_text[], int os_errno,
9180
char severity[], int flag)
9184
ret= Xorriso_msgs_submit((struct XorrisO *) xorriso, error_code, msg_text,
9185
os_errno, severity, flag);
9191
@param flag bit0= do not issue own event messages
9192
bit1= take xorriso->request_to_abort as reason for abort
9193
@return Gives the advice:
9194
2= pardon was given, go on
9195
1= no problem, go on
9196
0= function failed but xorriso would not abort, go on
9198
-1 = due to problem_status
9199
-2 = due to xorriso->request_to_abort
9201
int Xorriso_eval_problem_status(struct XorrisO *xorriso, int ret, int flag)
9205
Xorriso__text_to_sev("SORRY", &sev, 0);
9207
if((flag&2) && xorriso->request_to_abort)
9210
Xorriso_process_msg_queues(xorriso, 0);
9211
if(ret>0 && xorriso->problem_status <= 0)
9214
if(xorriso->problem_status < xorriso->abort_on_severity &&
9215
xorriso->problem_status > 0) {
9216
if(xorriso->problem_status >= sev && !(flag&1)) {
9217
sprintf(xorriso->info_text,
9218
"xorriso : NOTE : Tolerated problem event of severity '%s'\n",
9219
xorriso->problem_status_text);
9220
Xorriso_info(xorriso, 0);/* submit not as problem event */
9223
} else if(xorriso->problem_status > 0) {
9224
sprintf(xorriso->info_text,
9225
"xorriso : aborting : -abort_on '%s' encountered '%s'\n",
9226
xorriso->abort_on_text, xorriso->problem_status_text);
9228
Xorriso_info(xorriso, 0);/* submit not as problem event */
9238
int Xorriso_convert_uidstring(struct XorrisO *xorriso, char *uid_string,
9239
uid_t *uid, int flag)
9245
sscanf(uid_string, "%lf", &num);
9246
sprintf(text,"%.f",num);
9247
if(strcmp(text,uid_string)==0) {
9251
pwd= getpwnam(uid_string);
9253
sprintf(xorriso->info_text, "-uid: Not a known user: '%s'", uid_string);
9254
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
9262
int Xorriso_convert_gidstring(struct XorrisO *xorriso, char *gid_string,
9263
gid_t *gid, int flag)
9269
sscanf(gid_string, "%lf", &num);
9270
sprintf(text,"%.f",num);
9271
if(strcmp(text,gid_string)==0) {
9275
grp= getgrnam(gid_string);
9277
sprintf(xorriso->info_text, "-gid: Not a known group: '%s'", gid_string);
9278
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
9286
int Xorriso_convert_modstring(struct XorrisO *xorriso, char *cmd, char *mode,
9287
mode_t *mode_and, mode_t *mode_or, int flag)
9290
char sfe[5*SfileadrL], *mpt, *vpt, *opt;
9291
unsigned int num= 0;
9292
mode_t mode_val,mask;
9298
sscanf(mode,"%o",&num);
9300
} else if(strchr(mode,'+')!=NULL || strchr(mode,'-')!=NULL
9301
|| strchr(mode,'=')!=NULL) {
9302
/* [ugoa][+-][rwxst] */;
9303
for(mpt= mode; mpt!=NULL; mpt= strchr(mpt, ',')) {
9307
goto unrecognizable;
9309
for(vpt= mpt; *vpt!='+' && *vpt!='-' && *vpt!='='; vpt++) {
9319
goto unrecognizable;
9323
for(vpt= opt+1; *vpt!=0 && *vpt!=','; vpt++) {
9331
} else if(*vpt=='w') {
9338
} else if(*vpt=='x') {
9345
} else if(*vpt=='s') {
9350
} else if(*vpt=='t') {
9354
goto unrecognizable;
9357
(*mode_or)|= mode_val;
9358
} else if(*opt=='=') {
9361
mask|= S_IRWXO|S_ISVTX;
9363
mask|= S_IRWXG|S_ISGID;
9365
mask|= S_IRWXU|S_ISUID;
9366
(*mode_and)&= ~(mask);
9367
(*mode_or)= ((*mode_or) & ~mask) | mode_val;
9368
} else if(*opt=='-') {
9369
(*mode_or)&= ~mode_val;
9370
(*mode_and)&= ~mode_val;
9375
sprintf(xorriso->info_text,
9376
"%s: Unrecognizable or faulty permission mode %s\n", cmd,
9377
Text_shellsafe(mode, sfe, 0));
9378
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
9385
/* @param flag bit0= do not complain in case of error, but set info_text */
9386
int Xorriso_convert_datestring(struct XorrisO *xorriso, char *cmd,
9387
char *time_type, char *timestring,
9388
int *t_type, time_t *t, int flag)
9392
if(strcmp(time_type, "a")==0)
9394
else if(strcmp(time_type, "m")==0)
9396
else if(strcmp(time_type, "b")==0)
9399
sprintf(xorriso->info_text, "%s: Unrecognized type '%s'", cmd, time_type);
9401
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
9404
ret= Decode_timestring(timestring, t, 0);
9406
sprintf(xorriso->info_text, "%s: Cannot decode timestring '%s'", cmd,
9409
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
9412
sprintf(xorriso->info_text, "Understanding timestring '%s' as: %s",
9413
timestring, ctime(t));
9414
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0);
9419
/* @param flag bit0=path is in source filesystem , bit1= unconditionally */
9420
int Xorriso_much_too_long(struct XorrisO *xorriso, int len, int flag)
9422
if(len>=SfileadrL || (flag&2)) {
9423
sprintf(xorriso->info_text,
9424
"Path given for %s is much too long (%d)",
9425
((flag&1) ? "local filesystem" : "ISO image"), len);
9426
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
9433
int Xorriso_no_findjob(struct XorrisO *xorriso, char *cmd, int flag)
9435
sprintf(xorriso->info_text, "%s: cannot create find job object", cmd);
9436
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
9441
/* @param flag bit1= do not report memory usage as DEBUG
9443
int Xorriso_check_temp_mem_limit(struct XorrisO *xorriso, off_t mem, int flag)
9445
char mem_text[80], limit_text[80];
9447
Sfile_scale((double) mem, mem_text,5,1e4,0);
9449
sprintf(xorriso->info_text,
9450
"Temporary memory needed for result sorting : %s", mem_text);
9451
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0);
9453
if(mem > xorriso->temp_mem_limit) {
9454
Sfile_scale((double) xorriso->temp_mem_limit,limit_text,5,1e4,1);
9455
sprintf(xorriso->info_text,
9456
"Cannot sort. List of matching files exceeds -temp_mem_limit (%s > %s)",
9457
mem_text, limit_text);
9458
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0);
9465
/* @param flag bit0= for Xorriso_msgs_submit: use pager
9466
bit1= do not issue warnings
9468
int Xorriso_hop_link(struct XorrisO *xorriso, char *link_path,
9469
struct LinkiteM **link_stack, struct stat *stbuf, int flag)
9472
struct LinkiteM *litm;
9473
char sfe[5*SfileadrL];
9475
if(*link_stack != NULL) {
9476
if((*link_stack)->link_count>=xorriso->follow_link_limit) {
9477
sprintf(xorriso->info_text,
9478
"Too many symbolic links in single tree branch at : %s",
9479
Text_shellsafe(link_path, sfe, 0));
9481
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0,"WARNING",flag&1);
9485
ret= stat(link_path, stbuf);
9488
ret= Linkitem_find(*link_stack, stbuf->st_dev, stbuf->st_ino, &litm, 0);
9490
sprintf(xorriso->info_text,
9491
"Detected symbolic link loop around : %s",
9492
Text_shellsafe(link_path, sfe, 0));
9494
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", flag&1);
9497
ret= Linkitem_new(&litm, link_path, stbuf->st_dev, stbuf->st_ino,
9500
sprintf(xorriso->info_text,
9501
"Cannot add new item to link loop prevention stack");
9502
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", flag&1);
9510
/* @param flag bit0= do not only sum up sizes but also print subdirs
9511
bit1= this is a recursion
9512
@return <=0 error , 1 ok , 2 could not open directory
9514
int Xorriso_show_dux_subs(struct XorrisO *xorriso,
9515
char *abs_path, char *rel_path, off_t *size,
9517
struct LinkiteM *link_stack,
9520
int i, ret, no_sort= 0, filec= 0, l, j, fc, no_dive, is_link;
9521
char **filev= NULL, *namept;
9522
off_t sub_size, report_size, mem= 0;
9523
struct DirseQ *dirseq= NULL;
9526
struct LinkiteM *own_link_stack;
9527
char *path= NULL, *show_path= NULL, *name= NULL, *sfe= NULL;
9529
sfe= malloc(5*SfileadrL);
9530
path= malloc(SfileadrL);
9531
show_path= malloc(SfileadrL);
9532
name= malloc(SfileadrL);
9533
if(path==NULL || show_path==NULL || name==NULL || sfe==NULL) {
9534
Xorriso_no_malloc_memory(xorriso, &sfe, 0);
9537
own_link_stack= link_stack;
9541
if(lstat(abs_path, &stbuf)==-1)
9543
dir_dev= stbuf.st_dev;
9544
if(S_ISLNK(stbuf.st_mode)) {
9545
if(!(xorriso->do_follow_links || (xorriso->do_follow_param && !(flag&2))))
9547
if(stat(abs_path, &stbuf)==-1)
9549
if(dir_dev != stbuf.st_dev &&
9550
!(xorriso->do_follow_mount || (xorriso->do_follow_param && !(flag&2))))
9553
ret= Dirseq_new(&dirseq, abs_path, 1);
9555
sprintf(xorriso->info_text, "Cannot obtain disk directory iterator");
9556
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
9563
Linkitem_reset_stack(&own_link_stack, link_stack, 0);
9564
ret= Dirseq_next_adr(dirseq,name,0);
9571
strcpy(show_path, rel_path);
9572
if(Sfile_add_to_path(show_path, name, 0)<=0)
9575
strcpy(path, abs_path);
9576
if(Sfile_add_to_path(path, name, 0)<=0) {
9578
Xorriso_much_too_long(xorriso, strlen(path)+strlen(name)+1, 2);
9583
ret= lstat(path, &stbuf);
9586
is_link= S_ISLNK(stbuf.st_mode);
9587
if(is_link && xorriso->do_follow_links) {
9588
ret= Xorriso_hop_link(xorriso, path, &own_link_stack, &stbuf, 1);
9594
if(!S_ISDIR(stbuf.st_mode))
9596
if(dir_dev != stbuf.st_dev && !xorriso->do_follow_mount)
9600
l= strlen(rel_path)+1;
9602
if(l % sizeof(char *))
9603
mem+= sizeof(char *)-(l % sizeof(char *));
9604
if(flag&1) /* diving and counting is done further below */
9606
ret= Xorriso_show_dux_subs(xorriso, path, show_path, &sub_size, boss_mem,
9615
sub_size+= stbuf.st_size+strlen(name)+1;
9617
sub_size+= stbuf.st_size+2048;
9622
if(filec<=0 || !(flag&1))
9625
/* Try to get a sorted list of directory names */
9626
mem+= (filec+1)*sizeof(char *);
9627
ret= Xorriso_check_temp_mem_limit(xorriso, mem+boss_mem, 2);
9630
Dirseq_rewind(dirseq, 0);
9635
filev= (char **) calloc(filec+1, sizeof(char *));
9637
goto no_sort_possible;
9639
for(i= 0; i<filec; i++)
9643
ret= Dirseq_next_adr(dirseq,name,0);
9648
strcpy(path, abs_path);
9649
if(Sfile_add_to_path(path, name, 0)<=0)
9652
ret= lstat(path,&stbuf);
9655
is_link= S_ISLNK(stbuf.st_mode);
9656
if(is_link && xorriso->do_follow_links) {
9657
ret= stat(path,&stbuf);
9661
if(!S_ISDIR(stbuf.st_mode))
9663
if(dir_dev != stbuf.st_dev && !xorriso->do_follow_mount)
9666
if(fc>=filec) { /* Number of files changed (or programming error) */
9669
free((char *) filev[j]);
9670
free((char *) filev);
9672
goto no_sort_possible;
9675
filev[fc]= strdup(name);
9677
goto revoke_sorting;
9682
Sort_argv(filec, filev, 0);
9686
for(i= 0; (no_sort || i<filec) && !(xorriso->request_to_abort); i++) {
9687
Linkitem_reset_stack(&own_link_stack, link_stack, 0);
9689
ret= Dirseq_next_adr(dirseq,name,0);
9698
strcpy(show_path, rel_path);
9699
if(Sfile_add_to_path(show_path, namept, 0)<=0)
9701
strcpy(path, abs_path);
9702
if(Sfile_add_to_path(path, namept, 0)<=0)
9706
ret= lstat(path,&stbuf);
9709
is_link= S_ISLNK(stbuf.st_mode);
9710
if(is_link && xorriso->do_follow_links) {
9711
ret= Xorriso_hop_link(xorriso, path, &own_link_stack, &stbuf, 1);
9717
if(!S_ISDIR(stbuf.st_mode))
9719
if(dir_dev == stbuf.st_dev || xorriso->do_follow_mount) {
9720
ret= Xorriso_show_dux_subs(xorriso, path, show_path, &sub_size,
9721
boss_mem+mem, own_link_stack, 2|(flag&1));
9727
sub_size+= stbuf.st_size+strlen(namept)+1;
9729
sub_size+= stbuf.st_size+2048;
9732
report_size= sub_size/1024;
9733
if(report_size*1024<sub_size)
9735
sprintf(xorriso->result_line, "%7.f ",(double) (report_size));
9736
sprintf(xorriso->result_line+strlen(xorriso->result_line), "%s\n",
9737
Text_shellsafe(show_path, sfe, 0));
9738
Xorriso_result(xorriso, 0);
9751
Linkitem_reset_stack(&own_link_stack, link_stack, 0);
9752
Dirseq_destroy(&dirseq, 0);
9754
for(i=0; i<filec; i++)
9756
free((char *) filev[i]);
9757
free((char *) filev);
9763
/* @param flag bit1= add '+' to perms
9765
int Xorriso__mode_to_perms(mode_t st_mode, char perms[11], int flag)
9767
strcpy(perms,"--------- ");
9768
if(st_mode&S_IRUSR) perms[0]= 'r';
9769
if(st_mode&S_IWUSR) perms[1]= 'w';
9770
if(st_mode&S_IXUSR) perms[2]= 'x';
9771
if(st_mode&S_ISUID) {
9777
if(st_mode&S_IRGRP) perms[3]= 'r';
9778
if(st_mode&S_IWGRP) perms[4]= 'w';
9779
if(st_mode&S_IXGRP) perms[5]= 'x';
9780
if(st_mode&S_ISGID) {
9786
if(st_mode&S_IROTH) perms[6]= 'r';
9787
if(st_mode&S_IWOTH) perms[7]= 'w';
9788
if(st_mode&S_IXOTH) perms[8]= 'x';
9789
if(st_mode&S_ISVTX) {
9801
/* @param flag bit0= recognize Xorriso_IFBOOT as file type
9802
bit1= add '+' to perms
9804
int Xorriso_format_ls_l(struct XorrisO *xorriso, struct stat *stbuf, int flag)
9806
int show_major_minor= 0, high_shift= 0, high_mask= 0;
9807
char *rpt, perms[11], mm_text[80];
9809
dev_t dev, major, minor;
9811
rpt= xorriso->result_line;
9813
st_mode= stbuf->st_mode;
9815
if(S_ISDIR(st_mode))
9817
else if(S_ISREG(st_mode))
9819
else if(S_ISLNK(st_mode))
9821
else if(S_ISBLK(st_mode)) {
9823
show_major_minor= 1;
9824
} else if(S_ISCHR(st_mode)) {
9826
show_major_minor= 1;
9827
} else if(S_ISFIFO(st_mode))
9829
else if(S_ISSOCK(st_mode))
9831
else if((flag & 1) && (st_mode & S_IFMT) == Xorriso_IFBOOT)
9836
Xorriso__mode_to_perms(st_mode, perms, flag & 2);
9839
sprintf(rpt+strlen(rpt)," %3u ",(unsigned int) stbuf->st_nlink);
9841
sprintf(rpt+strlen(rpt), "%-8lu ", (unsigned long) stbuf->st_uid);
9842
sprintf(rpt+strlen(rpt), "%-8lu ", (unsigned long) stbuf->st_gid);
9843
if(show_major_minor) {
9844
dev= stbuf->st_rdev;
9846
/* according to /usr/include/sys/sysmacros.h : gnu_dev_major(),_minor()
9847
>>> but this looks as if it should go to some system dependency
9848
>>> in FreeBSD dev_t is 32 bit
9850
if(sizeof(dev_t) > 4) {
9854
major= (((dev >> 8) & 0xfff) |
9855
((unsigned int) (dev >> high_shift) & high_mask))
9857
minor= (((dev & 0xff) | ((unsigned int) (dev >> 12) & ~0xff))) & 0xffffffff;
9859
sprintf(mm_text, "%u,%u", (unsigned int) major, (unsigned int) minor);
9860
sprintf(rpt+strlen(rpt), "%8s ", mm_text);
9862
sprintf(rpt+strlen(rpt), "%8.f ", (double) stbuf->st_size);
9864
Ftimetxt(stbuf->st_mtime, rpt+strlen(rpt), 0);
9873
struct DirentrY *next;
9877
int Xorriso_sorted_dir_x(struct XorrisO *xorriso, char *dir_path,
9878
int *filec, char ***filev, off_t boss_mem, int flag)
9881
char name[SfileadrL];
9882
struct DirseQ *dirseq= NULL;
9884
struct DirentrY *last= NULL, *current= NULL;
9889
ret= Dirseq_new(&dirseq, dir_path, 1);
9892
while(1) { /* loop over directory content */
9893
ret= Dirseq_next_adr(dirseq,name,0);
9898
mem+= strlen(name)+8+sizeof(struct DirentrY)+sizeof(char *);
9899
if(mem>xorriso->temp_mem_limit)
9902
current= (struct DirentrY *) calloc(1, sizeof(struct DirentrY));
9906
current->next= last;
9908
last->adr= strdup(name);
9916
(*filev)= (char **) calloc(count, sizeof(char *));
9918
{ret= -1; goto ex; }
9920
for(current= last; current!=NULL; current= last) {
9921
last= current->next;
9922
(*filev)[count++]= current->adr;
9923
free((char *) current);
9925
Sort_argv(*filec, *filev, 0);
9928
for(current= last; current!=NULL; current= last) {
9929
last= current->next;
9931
free((char *) current);
9937
/* @param flag bit0= long format
9938
bit1= do not print count of nodes
9940
bit3= print directories as themselves (ls -d)
9942
int Xorriso_lsx_filev(struct XorrisO *xorriso, char *wd,
9943
int filec, char **filev, off_t boss_mem, int flag)
9945
int i, ret, was_error= 0, dfilec= 0, pass, passes;
9946
char sfe[5*SfileadrL], sfe2[5*SfileadrL], path[SfileadrL], *acl_text= NULL;
9947
char *rpt, link_target[SfileadrL], **dfilev= NULL;
9951
rpt= xorriso->result_line;
9953
Sort_argv(filec, filev, 0);
9955
/* Count valid nodes, warn of invalid ones */
9956
for(i= 0; i<filec; i++) {
9957
ret= Xorriso_make_abs_adr(xorriso, wd, filev[i], path, 1|2|4);
9962
ret= lstat(path, &stbuf);
9964
sprintf(xorriso->info_text, "Not found in local filesystem: %s",
9965
Text_shellsafe(path, sfe, 0));
9966
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 1);
9972
if((flag&8) && !(flag&(2|4))) {
9973
sprintf(xorriso->info_text,"Valid local files found: %d\n",filec-was_error);
9974
Xorriso_info(xorriso,1);
9975
if(filec-was_error<=0)
9979
passes= 1+!(flag&(4|8));
9980
for(pass= 0; pass<passes; pass++)
9981
for(i= 0; i<filec && !(xorriso->request_to_abort); i++) {
9982
ret= Xorriso_make_abs_adr(xorriso, wd, filev[i], path, 1|2|4);
9985
ret= lstat(path, &stbuf);
9988
if(S_ISLNK(stbuf.st_mode) &&
9989
(xorriso->do_follow_links || xorriso->do_follow_param)) {
9990
ret= stat(path, &stbuf);
9992
ret= lstat(path, &stbuf);
9996
if(S_ISDIR(stbuf.st_mode) && !(flag&(4|8))) {
10000
strcpy(xorriso->result_line, "\n");
10001
Xorriso_result(xorriso,0);
10002
sprintf(xorriso->result_line, "%s:\n", Text_shellsafe(filev[i], sfe,0));
10003
Xorriso_result(xorriso,0);
10005
ret= Xorriso_sorted_dir_x(xorriso, path, &dfilec, &dfilev, boss_mem, 0);
10008
/* >>> DirseQ loop and single item Xorriso_lsx_filev() */;
10012
sprintf(xorriso->result_line, "total %d\n", dfilec);
10013
Xorriso_result(xorriso,0);
10015
Xorriso_lsx_filev(xorriso, path,
10016
dfilec, dfilev, boss_mem, (flag&1)|2|8);
10019
Sfile_destroy_argv(&dfilec, &dfilev, 0);
10027
Xorriso_local_getfacl(xorriso, path, &acl_text, 16);
10028
ret= Xorriso_format_ls_l(xorriso, &stbuf, (acl_text != NULL) << 1);
10029
Xorriso_local_getfacl(xorriso, path, &acl_text, 1 << 15);
10032
if(S_ISLNK(stbuf.st_mode)) {
10033
ret= Xorriso_resolve_link(xorriso, path, link_target, 1);
10037
} else if(flag&4) { /* -du or -dus */
10038
size= stbuf.st_size;
10039
if(S_ISDIR(stbuf.st_mode)) {
10040
ret= Xorriso_show_dux_subs(xorriso, path, filev[i], &size, boss_mem,
10047
sprintf(rpt, "%7.f ",(double) (size/1024));
10050
sprintf(xorriso->result_line+strlen(xorriso->result_line), "%s -> %s\n",
10051
Text_shellsafe(filev[i], sfe, 0),
10052
Text_shellsafe(link_target, sfe2, 0));
10054
sprintf(xorriso->result_line+strlen(xorriso->result_line), "%s\n",
10055
Text_shellsafe(filev[i], sfe, 0));
10056
Xorriso_result(xorriso, 0);
10058
return(!was_error);
10062
/* @param flag bit0= path is a directory
10063
bit2= recursion: do not reassure in mode 2 "tree"
10064
bit3= this is for overwriting and not for plain removal
10066
int Xorriso_reassure_restore(struct XorrisO *xorriso, char *path, int flag)
10069
char sfe[5*SfileadrL];
10071
while((xorriso->do_reassure==1 || (xorriso->do_reassure==2 && !(flag&4)))
10072
&& !xorriso->request_not_to_ask) {
10074
Xorriso_lsx_filev(xorriso, xorriso->wdx, 1, &path, (off_t) 0, 1|2|8);
10075
if(flag&1) /* du -s */
10076
Xorriso_lsx_filev(xorriso, xorriso->wdx, 1, &path, (off_t) 0, 2|4);
10078
sprintf(xorriso->info_text,
10079
"File exists. Remove ? n= keep old, y= remove, x= abort, @= stop asking\n");
10081
sprintf(xorriso->info_text,
10082
"Remove above file ? n= keep it, y= remove it, x= abort, @= stop asking\n");
10083
Xorriso_info(xorriso, 4);
10084
ret= Xorriso_request_confirmation(xorriso, 1|2|4|16);
10087
if(xorriso->request_to_abort) {
10088
sprintf(xorriso->info_text,
10089
"Removal operation aborted by user before file: %s",
10090
Text_shellsafe(path, sfe, 0));
10091
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
10096
if(ret==6) /* yes */
10098
if(ret==4) { /* yes, do not ask again */
10099
xorriso->request_not_to_ask= 1;
10102
if(ret==1) { /* no */
10103
sprintf(xorriso->info_text, "Kept in existing state: %s",
10104
Text_shellsafe(path, sfe, 0));
10105
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
10116
@param flag >>> bit0= remove whole sub tree: rm -r
10117
bit1= remove empty directory: rmdir
10118
bit2= recursion: do not reassure in mode 2 "tree"
10119
bit3= this is for overwriting and not for plain removal
10120
bit4= count deleted files in xorriso->pacifier_count
10121
bit5= with bit0 only remove directory content, not the directory
10122
bit6= permission to call Xorriso_make_accessible()
10123
@return <=0 = error
10124
1 = removed leaf file object
10125
2 = removed directory or tree
10126
3 = did not remove on user revocation
10128
int Xorriso_rmx(struct XorrisO *xorriso, off_t boss_mem, char *path, int flag)
10130
int ret, is_dir= 0, made_accessible= 0;
10131
struct stat victim_stbuf, *victim_node= NULL;
10132
struct DirseQ *dirseq= NULL;
10133
char *sfe= NULL, *sub_path= NULL;
10134
struct PermiteM *perm_stack_mem;
10136
perm_stack_mem= xorriso->perm_stack;
10138
/* Avoiding large local memory objects in order to save stack space */
10139
sfe= malloc(5*SfileadrL);
10140
sub_path= malloc(2*SfileadrL);
10141
if(sfe==NULL || sub_path==NULL) {
10142
Xorriso_no_malloc_memory(xorriso, &sfe, 0);
10143
{ret= -1; goto ex;}
10146
if(Xorriso_much_too_long(xorriso, strlen(path), 0)<=0)
10149
ret= lstat(path, &victim_stbuf);
10151
if((flag & 64) && errno == EACCES) {
10152
ret= Xorriso_make_accessible(xorriso, path, 0);
10155
made_accessible= 1;
10156
ret= lstat(path, &victim_stbuf);
10159
sprintf(xorriso->info_text, "Cannot lstat(%s)",
10160
Text_shellsafe(path, sfe, 0));
10161
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE", 0);
10165
if(strcmp(path, "/")==0) {
10166
sprintf(xorriso->info_text, "May not delete root directory");
10167
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
10170
victim_node= &victim_stbuf;
10171
if(S_ISDIR(victim_stbuf.st_mode))
10174
if(flag&2) { /* rmdir */
10175
sprintf(xorriso->info_text, "%s in disk filesystem is not a directory",
10176
Text_shellsafe(path, sfe, 0));
10177
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
10181
if(flag&1) { /* rm -r */
10183
#ifdef Osirrox_not_yeT
10186
if((xorriso->do_reassure==1 && !xorriso->request_not_to_ask) ||
10188
/* Iterate over subordinates and delete them */
10191
ret= Xorriso_findi_iter(xorriso, (IsoDir *) victim_node, &mem,
10192
&iter, &node_array, &node_count, &node_idx,
10195
cannot_create_iter:;
10196
Xorriso_cannot_create_iter(xorriso, ret, 0);
10200
strcpy(sub_path, path);
10201
if(pl==0 || sub_path[pl-1]!='/') {
10202
sub_path[pl++]= '/';
10205
sub_name= sub_path+pl;
10207
ret= Xorriso_findi_iter(xorriso, (IsoDir *) victim_node, &mem, &iter,
10208
&node_array, &node_count, &node_idx, &node, 0);
10211
if(ret==0 || xorriso->request_to_abort)
10213
name= (char *) iso_node_get_name(node);
10214
if(Xorriso_much_too_long(xorriso, pl+1+strlen(name), 0)<=0)
10215
{ret= 0; goto rm_r_problem_handler;}
10216
strcpy(sub_name, name);
10217
ret= Xorriso_rmi(xorriso, iter, mem, sub_path, (flag&(1|2|8|16))|4);
10218
if(ret==3 || ret<=0 || xorriso->request_to_abort) {
10219
rm_r_problem_handler:;
10221
fret= Xorriso_eval_problem_status(xorriso, ret, 1|2);
10223
goto dir_not_removed;
10231
sprintf(xorriso->info_text, "Directory not removed: %s",
10232
Text_shellsafe(path, sfe, 0));
10233
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
10240
#else /* Osirrox_not_yeT */
10242
sprintf(xorriso->info_text, "-rm_rx is not implemented yet");
10243
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
10246
#endif /* !Osirrox_not_yeT */
10249
if(!(flag&2)) { /* not rmdir */
10250
sprintf(xorriso->info_text, "%s in disk filesystem is a directory",
10251
Text_shellsafe(path, sfe, 0));
10252
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
10255
ret= Dirseq_new(&dirseq, path, 1);
10257
ret= Dirseq_next_adr(dirseq, sfe, 0);
10259
sprintf(xorriso->info_text,
10260
"Directory not empty on attempt to delete: %s",
10261
Text_shellsafe(path, sfe, 0));
10262
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
10268
if(xorriso->request_to_abort)
10270
ret= Xorriso_reassure_restore(xorriso, path, (flag&(4|8)) | !!is_dir);
10271
if(ret<=0 || ret==3)
10278
if((flag & 64) && errno == EACCES && !made_accessible) {
10279
ret= Xorriso_make_accessible(xorriso, path, 0);
10282
made_accessible= 1;
10289
sprintf(xorriso->info_text, "Cannot delete from disk filesystem %s",
10290
Text_shellsafe(path, sfe, 0));
10291
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE", 0);
10296
xorriso->pacifier_count++;
10299
if(made_accessible)
10300
Permstack_pop(&(xorriso->perm_stack), perm_stack_mem, xorriso, 0);
10305
Dirseq_destroy(&dirseq, 0);
10310
/* @param flag bit0= recursion
10312
int Xorriso_findx_action(struct XorrisO *xorriso, struct FindjoB *job,
10313
char *abs_path, char *show_path, int depth, int flag)
10315
int ret= 0, type, action= 0, dpl= 0, compare_result, uret;
10319
mode_t mode_or= 0, mode_and= ~1;
10320
char *target, *text_2, sfe[5*SfileadrL], *disk_prefix, iso_path[SfileadrL];
10321
struct FindjoB *subjob;
10324
action= Findjob_get_action_parms(job, &target, &text_2, &user, &group,
10325
&mode_and, &mode_or, &type, &date, &subjob, 0);
10330
if(action==15 || action==16 || action==18 || action==19 || action==20) {
10331
/* in_iso , not_in_iso, add_missing , empty_iso_dir , is_full_in_iso */
10332
Findjob_get_start_path(job, &disk_prefix, 0);
10333
if(strncmp(abs_path, disk_prefix, strlen(disk_prefix))!=0)
10334
{ret= -1; goto ex;}
10335
dpl= strlen(disk_prefix);
10336
if(strlen(target)+strlen(abs_path)-dpl >= SfileadrL)
10337
{ret= -1; goto ex;}
10338
if(abs_path[dpl]=='/')
10340
ret= Xorriso_make_abs_adr(xorriso, target, abs_path+dpl, iso_path, 4);
10345
if(action==15) { /* in_iso */
10346
ret= Xorriso_iso_lstat(xorriso, iso_path, &stbuf, 0);
10349
sprintf(xorriso->result_line, "%s\n", Text_shellsafe(show_path, sfe, 0));
10350
Xorriso_result(xorriso, 0);
10352
} else if(action==16) { /* not_in_iso */
10353
ret= Xorriso_compare_2_files(xorriso, abs_path, iso_path, abs_path+dpl,
10354
&compare_result, 4);
10355
if(ret<xorriso->find_compare_result)
10356
xorriso->find_compare_result= ret;
10359
} else if(action==18) { /* add_missing */
10360
ret= Xorriso_compare_2_files(xorriso, abs_path, iso_path, abs_path+dpl,
10361
&compare_result, 4|(1<<31));
10362
if(ret<xorriso->find_compare_result)
10363
xorriso->find_compare_result= ret;
10365
uret= Xorriso_update_interpreter(xorriso, NULL, compare_result,
10366
abs_path, iso_path, (flag&1)<<2);
10372
} else if(action==19) { /* empty_iso_dir */
10373
ret= Xorriso_iso_lstat(xorriso, iso_path, &stbuf, 0);
10376
if(!S_ISDIR(stbuf.st_mode))
10378
ret= Xorriso_rmi(xorriso, NULL, (off_t) 0, iso_path, 1|32);
10380
sprintf(xorriso->info_text, "Emptied directory %s",
10381
Text_shellsafe(iso_path, sfe, 0));
10382
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "UPDATE", 0);
10384
} else if(action==20) { /* is_full_in_iso */
10385
ret= Xorriso_iso_lstat(xorriso, iso_path, &stbuf, 0);
10388
if(!S_ISDIR(stbuf.st_mode))
10390
strcpy(sfe, xorriso->wdi);
10391
strcpy(xorriso->wdi, iso_path);
10392
ret= Xorriso_ls(xorriso, 4|8);
10393
strcpy(xorriso->wdi, sfe);
10395
sprintf(xorriso->result_line,
10396
"d %s (ISO) : non-empty directory (would not match mount point)\n",
10397
Text_shellsafe(iso_path, sfe, 0));
10398
Xorriso_result(xorriso,0);
10402
sprintf(xorriso->result_line, "%s\n", Text_shellsafe(show_path, sfe, 0));
10403
Xorriso_result(xorriso, 0);
10407
if(action==15 || action==16 || action==18 || action==19 || action==20)
10408
if(xorriso->no_volset_present)
10409
xorriso->request_to_abort= 1; /* Need an image. No use to try again. */
10414
/* @param flag bit0=recursion
10416
int Xorriso_findx(struct XorrisO *xorriso, struct FindjoB *job,
10417
char *abs_dir_parm, char *dir_path,
10418
struct stat *dir_stbuf, int depth,
10419
struct LinkiteM *link_stack, int flag)
10421
int ret,is_link, no_dive;
10422
struct DirseQ *dirseq= NULL;
10424
struct LinkiteM *own_link_stack;
10425
char *abs_dir_path, *namept;
10426
char *name= NULL, *path= NULL, *sfe= NULL;
10427
char *abs_dir_path_data= NULL, *abs_path= NULL;
10429
if(xorriso->request_to_abort)
10432
sfe= malloc(5*SfileadrL);
10433
name= malloc(SfileadrL);
10434
path= malloc(SfileadrL);
10435
abs_dir_path_data= malloc(SfileadrL);
10436
abs_path= malloc(SfileadrL);
10437
if(name==NULL || sfe==NULL || path==NULL ||
10438
abs_dir_path_data==NULL || abs_path==NULL) {
10439
Xorriso_no_malloc_memory(xorriso, &sfe, 0);
10440
{ret= -1; goto ex;}
10442
own_link_stack= link_stack;
10443
abs_dir_path= abs_dir_parm;
10444
if(abs_dir_path[0]==0) {
10445
ret= Xorriso_make_abs_adr(xorriso, xorriso->wdx, dir_path,
10446
abs_dir_path_data, 1|2|8);
10449
abs_dir_path= abs_dir_path_data;
10450
ret= Xorriso_path_is_excluded(xorriso, abs_dir_path, !(flag&1));
10455
ret= lstat(abs_dir_path, dir_stbuf);
10458
if(S_ISLNK(dir_stbuf->st_mode) &&
10459
(xorriso->do_follow_links || (xorriso->do_follow_param && !(flag&1))))
10460
if(stat(abs_dir_path, &stbuf)!=-1)
10461
if(dir_stbuf->st_dev == stbuf.st_dev ||
10462
(xorriso->do_follow_mount || (xorriso->do_follow_param && !(flag&1))))
10463
memcpy(dir_stbuf, &stbuf, sizeof(struct stat));
10465
namept= strrchr(dir_path, '/');
10471
ret= Findjob_test_2(xorriso, job, NULL, namept, dir_path, NULL, dir_stbuf,
10476
ret= Xorriso_findx_action(xorriso, job, abs_dir_path, dir_path, depth,
10478
if(xorriso->request_to_abort)
10481
if(Xorriso_eval_problem_status(xorriso, ret, 1|2)<0)
10486
if(xorriso->request_to_abort)
10488
if(!S_ISDIR(dir_stbuf->st_mode))
10491
ret= Dirseq_new(&dirseq, abs_dir_path, 1);
10493
sprintf(xorriso->info_text, "Cannot obtain disk directory iterator");
10494
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
10495
{ret= -1; goto ex;}
10500
while(!xorriso->request_to_abort) {
10501
Linkitem_reset_stack(&own_link_stack, link_stack, 0);
10502
ret= Dirseq_next_adr(dirseq,name,0);
10506
sprintf(xorriso->info_text,"Failed to obtain next directory entry");
10507
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
10508
{ret= -1; goto ex;}
10510
ret= Xorriso_make_abs_adr(xorriso, abs_dir_path, name, abs_path, 1);
10513
ret= Xorriso_make_abs_adr(xorriso, dir_path, name, path, 4);
10516
ret= Xorriso_path_is_excluded(xorriso, abs_path, 0); /* (is never param) */
10521
ret= lstat(abs_path, &stbuf);
10526
is_link= S_ISLNK(stbuf.st_mode);
10527
if(is_link && xorriso->do_follow_links) {
10528
ret= Xorriso_hop_link(xorriso, abs_path, &own_link_stack, &stbuf, 2);
10530
{ret= -1; goto ex;}
10535
ret= Findjob_test_2(xorriso, job, NULL, name, path, dir_stbuf, &stbuf, 0);
10539
ret= Xorriso_findx_action(xorriso, job, abs_path, path, depth, flag&1);
10540
if(xorriso->request_to_abort)
10543
if(Xorriso_eval_problem_status(xorriso, ret, 1|2)<0)
10547
if(!S_ISDIR(stbuf.st_mode))
10549
if(dir_stbuf->st_dev != stbuf.st_dev && !xorriso->do_follow_mount)
10552
ret= Xorriso_findx(xorriso, job, abs_path, path, &stbuf, depth+1,
10553
own_link_stack, flag|1);
10567
if(abs_dir_path_data!=NULL)
10568
free(abs_dir_path_data);
10571
Dirseq_destroy(&dirseq, 0);
10576
/* @param flag bit0= a non-existing target of multiple sources is a directory
10577
bit1= all paths except the last one are disk_paths
10578
bit2= the last path is a disk_path
10579
@return <=0 is error, 1= leaf file object, 2= directory
10581
int Xorriso_cpmv_args(struct XorrisO *xorriso, char *cmd,
10582
int argc, char **argv, int *idx,
10583
int *optc, char ***optv, char eff_dest[SfileadrL],
10586
int destc= 0, is_dir=0, end_idx, ret, i;
10587
char **destv= NULL;
10588
char sfe[5*SfileadrL];
10590
end_idx= Xorriso_end_idx(xorriso, argc, argv, *idx,
10591
(xorriso->do_iso_rr_pattern==1)|(flag&2));
10592
if(end_idx - *idx < 2) {
10593
sprintf(xorriso->info_text, "%s: not enough arguments", cmd);
10594
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
10598
ret= Xorriso_opt_args(xorriso, cmd, argc, argv, *idx, &end_idx, optc, optv,
10599
(flag&2)|16); /* ignore last argument */
10602
/* demand one match, or 0 with a constant */
10603
ret= Xorriso_opt_args(xorriso, cmd, argc, argv, end_idx, &end_idx, &destc,
10604
&destv, ((flag&4)>>1) | 32 | 64);
10608
/* Evaluate target address */
10610
ret= Xorriso_normalize_img_path(xorriso, xorriso->wdx, destv[0], eff_dest,
10613
ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, destv[0], eff_dest,
10617
if(ret==2 || ((flag&1) && *optc > 1 && ret==0)) {
10619
} else if(*optc > 1) {
10620
for(i= 0; i<*optc; i++)
10621
Xorriso_msgs_submit(xorriso, 0, (*optv)[i], 0, "ERRFILE", 0);
10622
sprintf(xorriso->info_text,
10623
"%s: more than one origin given, destination is a non-directory: %s",
10624
cmd, Text_shellsafe(destv[0], sfe, 0));
10625
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
10628
if(ret==0) { /* compute complete eff_dest */
10629
ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, destv[0], eff_dest,
10637
Xorriso_opt_args(xorriso, cmd, argc, argv, *idx, &end_idx, &destc, &destv,
10644
/** @return -1= abort , 0= no , 1= yes
10646
int Xorriso_reassure(struct XorrisO *xorriso, char *cmd, char *which_will,
10651
if(!xorriso->do_reassure)
10653
sprintf(xorriso->info_text, "Really perform %s which will %s ? (y/n)\n",
10655
Xorriso_info(xorriso, 4);
10657
ret= Xorriso_request_confirmation(xorriso, 2|4|16);
10659
if(ret==6 || ret==4) {
10660
sprintf(xorriso->info_text, "%s confirmed", cmd);
10661
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
10665
sprintf(xorriso->info_text, "%s aborted", cmd);
10666
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
10669
sprintf(xorriso->info_text, "%s revoked", cmd);
10670
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
10675
/* @param flag bit0+1= what to aquire after giving up outdev
10676
0=none, 1=indev, 2=outdev, 3=both
10678
int Xorriso_reaquire_outdev(struct XorrisO *xorriso, int flag)
10681
char drive_name[SfileadrL], sfe[5*SfileadrL];
10684
strcpy(drive_name, xorriso->outdev);
10685
Xorriso_give_up_drive(xorriso, aq_flag);
10687
sprintf(xorriso->info_text,"Gave up -outdev %s",
10688
Text_shellsafe(xorriso->outdev, sfe, 0));
10689
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
10692
sprintf(xorriso->info_text,"Re-aquiring -outdev %s",
10693
Text_shellsafe(drive_name, sfe, 0));
10694
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
10695
ret= Xorriso_aquire_drive(xorriso, drive_name, aq_flag);
10697
sprintf(xorriso->info_text,"Could not re-aquire -outdev %s",
10698
Text_shellsafe(xorriso->outdev, sfe, 0));
10699
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
10706
int Xorriso_set_system_area_path(struct XorrisO *xorriso, char *path, int flag)
10709
char eff_src[SfileadrL];
10712
xorriso->system_area_disk_path[0]= 0;
10715
ret= Xorriso_normalize_img_path(xorriso, xorriso->wdx, path, eff_src, 2|4|16);
10719
sprintf(xorriso->info_text,
10720
"Given path does not exist on disk: -boot_image system_area=");
10721
Text_shellsafe(eff_src, xorriso->info_text, 1);
10722
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
10725
sprintf(xorriso->info_text,
10726
"Given path leads to a directory: -boot_image system_area=");
10727
Text_shellsafe(eff_src, xorriso->info_text, 1);
10728
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
10731
ret= Sfile_str(xorriso->system_area_disk_path, eff_src, 0);
10738
int Xorriso_cdrskin_help(struct XorrisO *xorriso, int flag)
10740
static char helptext[][80]= {
10741
"Usage: xorriso -as cdrecord [options|source_addresses]",
10742
"Note: This is not cdrecord. See xorriso -help, xorriso -version, man xorriso",
10744
"\t-version\tprint version information and exit emulation",
10745
"\t--devices\tprint list of available MMC drives and exit emulation",
10746
"\tdev=target\tpseudo-SCSI target to use as CD-Recorder",
10747
"\t-v\t\tincrement verbose level by one",
10748
"\t-checkdrive\tcheck if a driver for the drive is present",
10749
"\t-inq\t\tdo an inquiry for the drive and exit emulation",
10750
"\tspeed=#\t\tset speed of drive",
10751
"\tblank=type\tblank a CD-RW disc (see blank=help)",
10752
"\tfs=#\t\tSet fifo size to # (0 to disable, default is 4 MB)",
10753
"\t-eject\t\teject the disk after doing the work",
10754
"\t-dummy\t\tdo everything with laser turned off",
10755
"\t-msinfo\t\tretrieve multi-session info for mkisofs >= 1.10",
10756
"\t-toc\t\tretrieve and print TOC/PMA data",
10757
"\t-atip\t\tretrieve media state, print \"Is *erasable\"",
10758
"\t-multi\t\tgenerate a TOC that allows multi session",
10759
"\t-waiti\t\twait until input is available before opening SCSI",
10760
"\ttsize=#\t\tannounces exact size of source data",
10761
"\tpadsize=#\tAmount of padding",
10762
"\t-data\t\tSubsequent tracks are CD-ROM data mode 1 (default)",
10763
"\t-isosize\tUse iso9660 file system size for next data track",
10764
"\t-pad\t\tpadsize=30k",
10765
"\t-nopad\t\tDo not pad",
10766
"\t--grow_overwriteable_iso\temulate multi-session on DVD+RW, BD-RE",
10767
"\twrite_start_address=#\t\twrite to byte address on DVD+RW, BD-RE",
10768
"\tstream_recording=on|number\ttry to get full speed on DVD-RAM, BD",
10769
"\tdvd_obs=default|32k|64k\t\tbytes per DVD/BD write operation",
10770
"\tstdio_sync=on|off|number\twhether to fsync output to \"stdio:\"",
10771
"\t-help\t\tprint this text to stderr and exit emulation",
10772
"Actually this is the integrated ISO RockRidge filesystem manipulator xorriso",
10773
"lending its libburn capabilities to a very limited cdrecord emulation. Only",
10774
"a single data track can be burnt to blank, appendable or overwriteable media.",
10775
"A much more elaborate cdrecord emulator is cdrskin from the same project.",
10776
"@End_of_helptexT@"
10780
for(i= 0; strcmp(helptext[i], "@End_of_helptexT@")!=0; i++) {
10781
sprintf(xorriso->info_text, "%s\n", helptext[i]);
10782
Xorriso_info(xorriso,0);
10788
/* micro version of cdrskin */
10789
int Xorriso_cdrskin(struct XorrisO *xorriso, char *whom, int argc, char **argv,
10792
int ret, i, k, mem_do_close, aq_ret, eject_ret, msc1, msc2, hflag;
10793
int do_atip= 0, do_checkdrive= 0, do_eject= 0, do_scanbus= 0;
10794
int do_toc= 0, do_verbous= 0, do_version= 0, do_help= 0, do_waiti= 0;
10795
int do_multi= 0, do_msinfo= 0, do_grow= 0, do_isosize= 0, do_xa1= 0;
10796
double write_start_address= -1.0, tsize= -1.0;
10797
char track_source[SfileadrL], sfe[5*SfileadrL], dev_adr[SfileadrL], *cpt;
10798
char mem_report_about_text[80], *report_about= "SORRY", blank_mode[80];
10801
/* cdrecord 2.01 options which are not scheduled for implementation, yet */
10802
static char ignored_partial_options[][41]= {
10803
"timeout=", "debug=", "kdebug=", "kd=", "driver=", "ts=",
10804
"pregap=", "defpregap=", "mcn=", "isrc=", "index=", "textfile=",
10805
"pktsize=", "cuefile=",
10806
"gracetime=", "minbuf=",
10808
"assert_write_lba=", "fifo_start_at=", "dev_translation=",
10809
"drive_scsi_dev_family=", "fallback_program=", "modesty_on_drive=",
10810
"tao_to_sao_tsize=",
10812
"direct_write_amount=", "msifile=",
10816
static char ignored_full_options[][41]= {
10817
"-d", "-Verbose", "-V", "-silent", "-s", "-setdropts", "-prcap",
10818
"-reset", "-abort", "-overburn", "-ignsize", "-useinfo",
10820
"-raw", "-raw96p", "-raw16",
10822
"-cdi", "-preemp", "-nopreemp", "-copy", "-nocopy",
10823
"-scms", "-shorttrack", "-noshorttrack", "-packet", "-noclose",
10824
"-media-info", "-minfo",
10825
"-load", "-lock", "-raw96r", "-sao", "-dao", "-swab",
10826
"-tao", "-force", "-format",
10828
"--adjust_speed_to_drive", "--allow_emulated_drives", "--allow_setuid",
10829
"--allow_untested_media", "--any_track", "--demand_a_drive",
10830
"--fifo_disable", "--fifo_start_empty", "--fill_up_media",
10831
"--list_ignored_options", "--no_rc", "--no_convert_fs_adr",
10832
"--prodvd_cli_compatible", "--single_track",
10833
"--tell_media_space",
10838
static char blank_help[][80]= {
10839
"Blanking options:",
10840
"\tall\t\tblank the entire disk",
10841
"\tdisc\t\tblank the entire disk",
10842
"\tdisk\t\tblank the entire disk",
10843
"\tfast\t\tminimally blank the entire disk",
10844
"\tminimal\t\tminimally blank the entire disk",
10845
"\tas_needed\tblank or format media to make it ready for (re-)use",
10846
"\tdeformat\t\tblank a formatted DVD-RW",
10847
"\tdeformat_quickest\tminimally blank a formatted DVD-RW to DAO only",
10848
"\tformat_overwrite\tformat a DVD-RW to \"Restricted Overwrite\"",
10849
"@End_of_helptexT@"
10852
strcpy(mem_report_about_text, xorriso->report_about_text);
10853
mem_do_close= xorriso->do_close;
10855
track_source[0]= 0;
10860
if(xorriso->in_drive_handle != NULL) {
10861
ret= Xorriso_option_dev(xorriso, "", 1|32); /* give up indev */
10867
/* Assess plan, make settings */
10868
for(i= 0; i<argc; i++) {
10869
sprintf(xorriso->info_text, "-as %s: %s",
10870
whom, Text_shellsafe(argv[i], sfe, 0));
10871
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0);
10873
for(k=0;ignored_partial_options[k][0]!=0;k++) {
10874
if(argv[i][0]=='-')
10875
if(strncmp(argv[i]+1,ignored_partial_options[k],
10876
strlen(ignored_partial_options[k]))==0)
10878
if(strncmp(argv[i],ignored_partial_options[k],
10879
strlen(ignored_partial_options[k]))==0)
10882
for(k=0;ignored_full_options[k][0]!=0;k++)
10883
if(strcmp(argv[i],ignored_full_options[k])==0)
10887
sprintf(xorriso->info_text, "-as %s: Ignored option %s",
10888
whom, Text_shellsafe(argv[i], sfe, 0));
10889
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
10893
if(strcmp(argv[i], "-atip")==0) {
10895
} else if(strcmp(argv[i], "-audio")==0) {
10896
sprintf(xorriso->info_text, "-as %s: Option -audio not supported.", whom);
10897
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
10899
} else if(strncmp(argv[i], "-blank=", 7)==0 ||
10900
strncmp(argv[i], "blank=", 6)==0) {
10901
cpt= strchr(argv[i], '=')+1;
10902
if(strcmp(cpt,"all")==0 || strcmp(cpt,"disc")==0
10903
|| strcmp(cpt,"disk")==0) {
10904
strcpy(blank_mode, "all");
10905
} else if(strcmp(cpt,"fast")==0 || strcmp(cpt,"minimal")==0) {
10906
strcpy(blank_mode, "fast");
10907
} else if(strcmp(cpt,"help")==0) {
10908
strcpy(blank_mode, "help");
10909
} else if(strcmp(cpt,"deformat")==0 ||
10910
strcmp(cpt,"deformat_sequential")==0 ||
10911
strcmp(cpt,"deformat_quickest")==0 ||
10912
strcmp(cpt,"deformat_sequential_quickest")==0) {
10913
strcpy(blank_mode, cpt);
10914
} else if(strcmp(cpt,"format_overwrite")==0) {
10915
strcpy(blank_mode, "format_overwrite");
10916
} else if(strcmp(cpt,"as_needed")==0) {
10917
strcpy(blank_mode, "as_needed");
10919
sprintf(xorriso->info_text,
10920
"-as %s: blank=%s not supported. See blank=help .",
10921
whom, Text_shellsafe(argv[i], sfe, 0));
10922
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
10925
} else if(strcmp(argv[i], "-checkdrive")==0) {
10927
} else if(strcmp(argv[i], "-data")==0) {
10929
} else if(strncmp(argv[i], "-dev=", 5)==0 ||
10930
strncmp(argv[i], "dev=", 4)==0) {
10931
cpt= strchr(argv[i], '=')+1;
10932
strcpy(dev_adr, cpt);
10933
} else if(strcmp(argv[i], "--devices")==0) {
10935
} else if(strncmp(argv[i],"driveropts=", 11)==0 ||
10936
strncmp(argv[i],"-driveropts=", 12)==0) {
10937
if(strcmp(argv[i]+11, "help")==0) {
10938
fprintf(stderr,"Driver options:\n");
10940
"burnfree\tPrepare writer to use BURN-Free technology\n");
10942
} else if(strcmp(argv[i], "-dummy")==0) {
10943
xorriso->do_dummy= 1;
10944
} else if(strcmp(argv[i], "-eject")==0) {
10946
} else if(strncmp(argv[i], "-fs=", 4)==0 || strncmp(argv[i], "fs=", 3)==0) {
10947
cpt= strchr(argv[i], '=')+1;
10948
ret= Xorriso_option_fs(xorriso, cpt, 0);
10951
} else if(strcmp(argv[i], "--grow_overwriteable_iso")==0) {
10953
} else if(strcmp(argv[i], "-help")==0) {
10955
} else if(strcmp(argv[i], "-isosize")==0) {
10957
} else if(strcmp(argv[i], "-inq")==0) {
10959
} else if(strcmp(argv[i], "-mode2")==0) {
10960
Xorriso_msgs_submit(xorriso, 0,
10961
"Defaulting option -mode2 to option -data", 0, "NOTE", 0);
10962
} else if(strcmp(argv[i], "-msinfo")==0) {
10964
} else if(strcmp(argv[i], "-multi")==0) {
10966
} else if(strcmp(argv[i], "-nopad")==0) {
10967
xorriso->padding= 0;
10968
} else if(strcmp(argv[i], "-pad")==0) {
10969
xorriso->padding= 15*2048;
10970
} else if(strncmp(argv[i], "-padsize=", 9)==0 ||
10971
strncmp(argv[i], "padsize=", 8)==0) {
10972
cpt= strchr(argv[i], '=')+1;
10973
ret= Xorriso_option_padding(xorriso, cpt, 0);
10976
} else if(strcmp(argv[i], "-scanbus")==0) {
10977
sprintf(xorriso->info_text, "-as %s: Option -scanbus not supported.",
10979
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
10982
/* do_scanbus= 1; */
10983
} else if(strncmp(argv[i], "-speed=", 7)==0 ||
10984
strncmp(argv[i], "speed=", 6)==0) {
10985
cpt= strchr(argv[i], '=')+1;
10986
strncpy(speed, cpt, 79);
10989
} else if(strncmp(argv[i], "-stream_recording=", 18)==0 ||
10990
strncmp(argv[i], "stream_recording=", 17)==0) {
10991
cpt= strchr(argv[i], '=')+1;
10992
Xorriso_option_stream_recording(xorriso, cpt, 0);
10994
} else if(strncmp(argv[i], "-dvd_obs=", 9)==0 ||
10995
strncmp(argv[i], "dvd_obs=", 8)==0) {
10996
cpt= strchr(argv[i], '=') + 1;
10997
Xorriso_option_dvd_obs(xorriso, cpt, 0);
10999
} else if(strncmp(argv[i], "-stdio_sync=", 12)==0 ||
11000
strncmp(argv[i], "stdio_sync=", 11)==0) {
11001
cpt= strchr(argv[i], '=') + 1;
11002
Xorriso_option_stdio_sync(xorriso, cpt, 0);
11004
} else if(strcmp(argv[i], "-toc")==0 || strcmp(argv[i], "--long_toc")==0) {
11006
} else if(strncmp(argv[i], "-tsize=", 7)==0 ||
11007
strncmp(argv[i], "tsize=", 6)==0) {
11008
cpt= strchr(argv[i], '=')+1;
11009
tsize= Scanf_io_size(cpt, 1);
11010
if(tsize > 1024.0*1024.0*1024.0*1024.0*1024.0) {
11011
sprintf(xorriso->info_text, "-as %s: much too large: %s",whom, argv[i]);
11012
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
11015
} else if(strcmp(argv[i], "-v")==0 || strcmp(argv[i],"-verbose")==0) {
11017
} else if(strcmp(argv[i], "-vv")==0) {
11019
} else if(strcmp(argv[i], "-vvv")==0) {
11021
} else if(strcmp(argv[i], "-version")==0) {
11023
} else if(strcmp(argv[i], "-waiti")==0) {
11025
} else if(strncmp(argv[i], "write_start_address=", 20)==0) {
11026
write_start_address= Scanf_io_size(argv[i]+20,0);
11027
} else if(strcmp(argv[i], "-xa")==0) {
11028
Xorriso_msgs_submit(xorriso, 0,
11029
"Defaulting option -xa to option -data", 0, "NOTE", 0);
11030
} else if(strcmp(argv[i], "-xa1")==0) {
11033
} else if(strcmp(argv[i], "--xa1-ignore")==0) {
11035
} else if(strcmp(argv[i], "-xa2")==0) {
11036
Xorriso_msgs_submit(xorriso, 0,
11037
"Defaulting option -xa2 to option -data", 0, "NOTE", 0);
11038
} else if(strcmp(argv[i], "-xamix")==0) {
11039
Xorriso_msgs_submit(xorriso, 0,
11040
"Option -xamix not implemented and data not yet convertible to other modes",
11043
} else if(argv[i][0]=='-' && argv[i][1]!=0) {
11044
sprintf(xorriso->info_text, "-as %s: Unknown option %s",
11045
whom, Text_shellsafe(argv[i], sfe, 0));
11046
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
11049
if(track_source[0]) {
11050
sprintf(xorriso->info_text, "-as %s: Surplus track source %s",
11051
whom, Text_shellsafe(argv[i], sfe, 0));
11052
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
11053
sprintf(xorriso->info_text, "First and only track source is %s",
11054
Text_shellsafe(track_source, sfe, 0));
11055
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
11058
if(Sfile_str(track_source, argv[i], 0)<=0)
11059
{ret= -1; goto ex;}
11063
/* Perform actions */
11064
Xorriso_option_report_about(xorriso, "NOTE", 0);
11066
sprintf(xorriso->result_line, "Cdrecord 2.01-Emulation Copyright (C) 2010 see libburnia-project.org xorriso\n");
11067
Xorriso_result(xorriso, 1);
11068
Xorriso_option_version(xorriso, 0);
11072
sprintf(xorriso->info_text,
11073
"xorriso: Option -waiti pauses program until input appears at stdin\n");
11074
Xorriso_info(xorriso,0);
11075
sprintf(xorriso->result_line, "Waiting for data on stdin...\n");
11076
Xorriso_result(xorriso, 1);
11077
for(ret= 0; ret==0; )
11078
ret= Wait_for_input(0,1000000,0);
11079
if(ret<0 || feof(stdin)) {
11080
Xorriso_msgs_submit(xorriso, 0,
11081
"stdin produces exception rather than data", 0, "NOTE", 0);
11083
sprintf(xorriso->info_text, "xorriso: Option -waiti pausing is done.\n");
11086
hflag= 2 | 32 | 64;
11088
hflag|= 8; /* consider overwriteables as blank */
11089
ret= Xorriso_option_dev(xorriso, dev_adr, hflag);
11095
Xorriso_cdrskin_help(xorriso, 0);
11100
/* >>> would need -scanbus compatible output and input format */;
11102
Xorriso_option_devices(xorriso, 0);
11105
if(strcmp(blank_mode, "help")==0) {
11106
for(i= 0; strcmp(blank_help[i], "@End_of_helptexT@")!=0; i++) {
11107
sprintf(xorriso->info_text, "%s\n", blank_help[i]);
11108
Xorriso_info(xorriso,0);
11113
if(!(do_checkdrive || do_atip || do_toc || blank_mode[0] || track_source[0] ||
11114
do_eject || do_msinfo))
11117
if(xorriso->out_drive_handle==NULL) {
11118
sprintf(xorriso->info_text, "-as %s: No output drive selected", whom);
11119
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
11124
ret= Xorriso_msinfo(xorriso, &msc1, &msc2, 2 | !!do_grow);
11127
sprintf(xorriso->result_line, "%d,%d\n", msc1, msc2);
11128
Xorriso_result(xorriso, 1);
11132
ret= Xorriso_option_speed(xorriso, speed, 0);
11138
report_about= "SORRY";
11139
else if(do_verbous<=2)
11140
report_about= "UPDATE";
11141
else if(do_verbous==3)
11142
report_about= "DEBUG";
11144
report_about= "ALL";
11145
Xorriso_option_report_about(xorriso, report_about, 0);
11147
if(do_checkdrive) {
11148
ret= Xorriso_atip(xorriso, 2-(do_checkdrive==2));
11153
ret= Xorriso_atip(xorriso, 0);
11158
ret= Xorriso_option_toc(xorriso, 0);
11162
if(strcmp(blank_mode, "format_overwrite")==0) {
11163
ret= Xorriso_option_blank(xorriso, "fast", 1);
11166
} else if(blank_mode[0]) {
11167
ret= Xorriso_option_blank(xorriso, blank_mode, 0);
11171
if(track_source[0]) {
11172
xorriso->do_close= !do_multi;
11173
ret= Xorriso_burn_track(xorriso, (off_t) write_start_address,
11174
track_source, (off_t) tsize,
11175
(!!do_grow) | ((!!do_isosize) << 1) | ((do_xa1 == 1) << 2));
11176
aq_ret= Xorriso_reaquire_outdev(xorriso, 2*(ret>0));
11177
if(ret<=0 && ret<aq_ret)
11180
{ret= aq_ret; goto ex;}
11185
if(do_eject && ret>=0) {
11186
eject_ret= Xorriso_option_eject(xorriso, "out", 0);
11191
sprintf(xorriso->info_text, "-as %s: Job could not be performed properly.",
11193
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
11195
Xorriso_option_report_about(xorriso, mem_report_about_text, 0);
11196
xorriso->do_close= mem_do_close;
11201
/* @param flag bit0= do not report eventual ignore decision
11203
int Xorriso_genisofs_ignore(struct XorrisO *xorriso, char *whom,
11204
char **argv, int *i, int flag)
11206
/* mkisofs 2.01 options which are not scheduled for implementation, yet */
11207
static char ignored_arg0_options[][41]= {
11208
"-allow-leading-dots", "-ldots", "-allow-lowercase", "-allow-multidot",
11209
"-cache-inodes", "-no-cache-inodes", "-check-oldnames", "-d", "-D",
11210
"-joliet-long", "-l", "-L", "-max-iso9660-filenames", "-N", "-nobak",
11211
"-no-bak", "-force-rr", "-relaxed-filenames", "-T", "-U",
11212
"-no-iso-translate",
11215
static char ignored_arg1_options[][41]= {
11216
"-biblio", "-check-session", "-p", "-root",
11217
"-old-root", "-table-name", "-volset-seqno", "-volset-size",
11220
int k, idx_offset= 0;
11221
char sfe[5*SfileadrL];
11223
for(k=0;ignored_arg0_options[k][0]!=0;k++)
11224
if(strcmp(argv[*i],ignored_arg0_options[k])==0)
11226
for(k=0;ignored_arg1_options[k][0]!=0;k++)
11227
if(strcmp(argv[*i],ignored_arg1_options[k])==0) {
11234
sprintf(xorriso->info_text, "-as %s: Ignored option %s",
11235
whom, Text_shellsafe(argv[(*i)+idx_offset], sfe, 0));
11237
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
11242
int Xorriso_genisofs_add_boot(struct XorrisO *xorriso, char *whom,
11243
int *option_b, int *no_emul_boot, int flag)
11247
if(*option_b && !*no_emul_boot) {
11248
xorriso->boot_image_bin_path[0]= 0;
11249
sprintf(xorriso->info_text,
11250
"-as %s: Option -b is supported only if option -no-emul-boot is given",
11252
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
11255
ret= Xorriso_attach_boot_image(xorriso, 0);
11257
xorriso->boot_image_bin_path[0]= 0;
11264
int Xorriso_genisofs_help(struct XorrisO *xorriso, int flag)
11266
static char helptext[][160]= {
11267
"Usage: xorriso -as mkisofs [options] file...",
11268
"Note: This is not mkisofs. See xorriso -help, xorriso -version, man xorriso",
11270
" -f, -follow-links Follow symbolic links",
11271
" -graft-points Allow to use graft points for filenames",
11272
" -help Print option help",
11273
" -input-charset CHARSET Local input charset for file name conversion",
11274
" -output-charset CHARSET Output charset for file name conversion",
11275
" -iso-level LEVEL Set ISO9660 conformance level (1..3)",
11276
" -J, -joliet Generate Joliet directory information",
11277
" -o FILE, -output FILE Set output file name",
11278
" -m GLOBFILE, -exclude GLOBFILE",
11279
" Exclude file name",
11280
" -exclude-list FILE File with list of file names to exclude",
11281
" -pad Pad output by 300k (default)",
11282
" -no-pad Do not pad output",
11283
" -M FILE, -prev-session FILE Set path to previous session to merge",
11284
" -C PARAMS, -cdrecord-params PARAMS",
11285
" Magic paramters from cdrecord",
11286
" -path-list FILE File with list of pathnames to process",
11287
" --quoted_path_list FILE File with list of quoted pathnames to process",
11288
" -print-size Print estimated filesystem size and exit",
11289
" -quiet Run quietly",
11290
" -R, -rock Generate Rock Ridge directory information",
11291
" -r, -rational-rock Generate rationalized Rock Ridge directory information",
11292
" --hardlinks Record eventual hard link relations of files",
11293
" --acl Record eventual ACLs of files",
11294
" --xattr Record eventual user space xattr of files",
11295
" --md5 Compute and record MD5 checksums of data files",
11296
" --scdbackup_tag PATH NAME With --md5 record a scdbackup checksum tag",
11297
" --for_backup Use all options which improve backup fidelity",
11298
" -V ID, -volid ID Set Volume ID",
11299
" -volset ID Set Volume set ID",
11300
" -publisher PUB Set Volume publisher",
11301
" -A ID, -appid ID Set Application ID",
11302
" -sysid ID Set System ID",
11303
" -b FILE, -eltorito-boot FILE",
11304
" Set El Torito boot image name",
11305
" -eltorito-alt-boot Start specifying alternative El Torito boot parameters",
11306
" --efi-boot FILE Set El Torito EFI boot image name and type",
11307
" -c FILE, -eltorito-catalog FILE",
11308
" Set El Torito boot catalog name",
11309
" -boot-load-size # Set numbers of load sectors",
11310
" -no-emul-boot Boot image is 'no emulation' image",
11311
" -boot-info-table Patch boot image with info table",
11312
" -G FILE, -generic-boot FILE Set generic boot image name",
11313
" --protective-msdos-label Patch System Area by partition table",
11314
" --modification-date=YYYYMMDDhhmmsscc",
11315
" Override date of creation and modification",
11316
" -isohybrid-mbr FILE Set SYSLINUX mbr/isohdp[fp]x*.bin for isohybrid",
11317
#ifdef Xorriso_with_isohybriD
11318
" isolinux_mbr=on|auto|off Control eventual isohybrid MBR generation",
11320
" --sort-weight NUMBER FILE Set LBA weight number to file or file tree",
11321
" --stdio_sync on|off|number Control forced output to disk files",
11322
" -z, -transparent-compression",
11323
" Enable transparent compression of files",
11324
" -v, -verbose Verbose",
11325
" -version Print the current version",
11326
"@End_of_helptexT@"
11331
strcpy(ra_text, xorriso->report_about_text);
11333
Xorriso_option_report_about(xorriso, "NOTE", 0);
11334
for(i= 0; strcmp(helptext[i], "@End_of_helptexT@")!=0; i++) {
11335
sprintf(xorriso->info_text, "%s\n", helptext[i]);
11336
Xorriso_info(xorriso, 1);
11338
Xorriso_option_report_about(xorriso, ra_text, 0);
11343
/* micro emulation of mkisofs */
11344
int Xorriso_genisofs(struct XorrisO *xorriso, char *whom,
11345
int argc, char **argv, int flag)
11347
int ret, i, j, was_path= 0, was_other_option= 0, mem_graft_points, mem;
11348
int do_print_size= 0, fd, idx, iso_level= 0, no_emul_boot= 0;
11349
int option_b= 0, was_failure= 0, fret, lower_r= 0, zero= 0;
11350
int *weight_list= NULL, weight_count= 0;
11351
int *boot_opt_list= NULL, boot_opt_count= 0;
11352
char sfe[5*SfileadrL], adr[SfileadrL+8], ra_text[80], pathspec[2*SfileadrL];
11353
char *ept, *add_pt, eff_path[SfileadrL], indev[SfileadrL+8], msc[80], *cpt;
11355
static char *lower_r_args[3]= {"/", "-exec", "mkisofs_r"};
11356
static char *sort_weight_args[4]= {"", "-exec", "sort_weight", ""};
11358
strcpy(ra_text, xorriso->report_about_text);
11360
weight_list= TSOB_FELD(int, (argc / 3) + 1);
11361
if(weight_list == NULL) {
11362
Xorriso_no_malloc_memory(xorriso, NULL, 0);
11365
boot_opt_list= TSOB_FELD(int, argc + 1);
11366
if(boot_opt_list == NULL) {
11367
cpt= (char *) weight_list;
11368
Xorriso_no_malloc_memory(xorriso, &cpt, 0);
11372
adr[0]= indev[0]= msc[0]= 0;
11373
for(i= 0; i<argc; i++) {
11374
ret= Xorriso_genisofs_ignore(xorriso, whom, argv, &i, 1);
11377
if(strcmp(argv[i], "-version")==0) {
11378
sprintf(xorriso->result_line,
11379
"mkisofs 2.01-Emulation Copyright (C) 2010 see libburnia-project.org xorriso\n"
11381
fd= xorriso->dev_fd_1;
11384
write(fd, xorriso->result_line, strlen(xorriso->result_line));
11386
Xorriso_option_version(xorriso, 0);
11388
} else if(strcmp(argv[i], "-o")==0 || strcmp(argv[i], "-output")==0) {
11390
goto not_enough_args;
11393
if(strcmp(argv[i],"-")!=0 && strncmp(argv[i], "stdio:", 6)!=0)
11394
strcpy(adr, "stdio:");
11395
if(Sfile_str(adr+strlen(adr), argv[i], 0)<=0)
11396
{ret= -1; goto ex;}
11397
} else if(strcmp(argv[i], "-M")==0 || strcmp(argv[i], "-dev")==0 ||
11398
strcmp(argv[i], "-prev-session")==0) {
11400
goto not_enough_args;
11402
if(strncmp(argv[i], "stdio:", 6)!=0)
11403
strcpy(indev, "stdio:");
11404
if(Sfile_str(indev+strlen(indev), argv[i], 0)<=0)
11405
{ret= -1; goto ex;}
11406
} else if(strcmp(argv[i], "-C")==0 ||
11407
strcmp(argv[i], "-cdrecord-params")==0) {
11409
goto not_enough_args;
11411
strncpy(msc, argv[i], sizeof(msc)-1);
11412
msc[sizeof(msc)-1]= 0;
11413
} else if(strcmp(argv[i], "-help")==0) {
11414
Xorriso_genisofs_help(xorriso, 0);
11415
} else if(strcmp(argv[i], "-v")==0 || strcmp(argv[i], "-verbose")==0) {
11416
strcpy(ra_text, "UPDATE");
11417
} else if(strcmp(argv[i], "-quiet")==0) {
11418
strcpy(ra_text, "SORRY");
11419
} else if(strcmp(argv[i], "-f")==0 || strcmp(argv[i], "-follow-links")==0) {
11420
ret= Xorriso_option_follow(xorriso, "on", 0);
11422
goto problem_handler_1;
11423
} else if(strcmp(argv[i], "-iso-level")==0) {
11425
goto not_enough_args;
11427
sscanf(argv[i], "%d", &iso_level);
11428
if(iso_level < 1 || iso_level > 3) {
11429
sprintf(xorriso->info_text,
11430
"-as %s: unsupported -iso-level '%s' (use one of: 1,2,3)",
11432
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
11433
ret= 0; goto problem_handler_1;
11436
xorriso->file_size_limit=
11437
((off_t) 4) * ((off_t) 1024*1024*1024) - ((off_t) 1);
11439
xorriso->file_size_limit= 0;
11441
#ifndef Xorriso_multi_booT
11443
} else if(strcmp(argv[i], "-no-emul-boot")==0) {
11445
} else if(strcmp(argv[i], "-boot-info-table")==0) {
11446
xorriso->patch_isolinux_image= 1;
11447
} else if(strcmp(argv[i], "-b") == 0 ||
11448
strcmp(argv[i], "-eltorito-boot") == 0 ||
11449
strcmp(argv[i], "--efi-boot") == 0) {
11451
goto not_enough_args;
11453
/* >>> provisory: ts B00421
11454
Only one BIOS boot image and one EFI boot image are possible.
11456
Several boot images shall be kept in a list. One is the Default.
11457
They can have type BIOS or EFI.
11459
if(strcmp(argv[i - 1], "--efi-boot") == 0) {
11460
boot_path= xorriso->boot_image_efi_path;
11461
xorriso->boot_efi_default= 1;
11463
boot_path= xorriso->boot_image_bin_path;
11464
xorriso->boot_platform_id= 0x00;
11465
xorriso->boot_efi_default= 0;
11469
if(argv[i][0] != '/')
11470
strcat(boot_path, "/");
11471
ret= Sfile_str(boot_path + strlen(boot_path), argv[i], 0);
11474
xorriso->keep_boot_image= 0;
11476
} else if(strcmp(argv[i], "-c") == 0 ||
11477
strcmp(argv[i], "-eltorito-catalog") == 0) {
11479
goto not_enough_args;
11481
xorriso->boot_image_cat_path[0]= 0;
11482
if(argv[i][0] != '/')
11483
strcat(xorriso->boot_image_cat_path, "/");
11484
ret= Sfile_str(xorriso->boot_image_cat_path
11485
+ strlen(xorriso->boot_image_cat_path), argv[i], 0);
11488
} else if(strcmp(argv[i], "-boot-load-size") == 0) {
11490
goto not_enough_args;
11492
sscanf(argv[i], "%d", &ret);
11493
xorriso->boot_image_load_size= ret * 512;
11494
} else if(strncmp(argv[i], "isolinux_mbr=", 13)==0) {
11495
sprintf(sfe, "isohybrid=%s", argv[i] + 13);
11496
ret= Xorriso_option_boot_image(xorriso, "isolinux", sfe, 0);
11498
goto problem_handler_1;
11500
#endif /* ! Xorriso_multi_booT */
11502
} else if(strcmp(argv[i], "-input-charset")==0) {
11504
goto not_enough_args;
11506
/* -local_charset */
11507
if(strcmp(argv[i], "default") == 0)
11508
ret= Xorriso_option_charset(xorriso, "ISO-8859-1", 4);
11510
ret= Xorriso_option_charset(xorriso, argv[i], 4);
11512
goto problem_handler_1;
11513
} else if(strcmp(argv[i], "-output-charset")==0) {
11515
goto not_enough_args;
11518
if(strcmp(argv[i], "default") == 0)
11519
ret= Xorriso_option_charset(xorriso, "ISO-8859-1", 3);
11521
ret= Xorriso_option_charset(xorriso, argv[i], 3);
11523
goto problem_handler_1;
11524
} else if(strcmp(argv[i], "--hardlinks")==0) {
11525
Xorriso_option_hardlinks(xorriso, "on", 0);
11526
} else if(strcmp(argv[i], "--acl")==0) {
11527
Xorriso_option_acl(xorriso, "on", 0);
11528
} else if(strcmp(argv[i], "--xattr")==0) {
11529
Xorriso_option_xattr(xorriso, "on", 0);
11530
} else if(strcmp(argv[i], "--md5")==0) {
11531
Xorriso_option_md5(xorriso, "on", 0);
11532
} else if(strcmp(argv[i], "--scdbackup_tag")==0) {
11534
goto not_enough_args;
11536
ret= Xorriso_option_scdbackup_tag(xorriso, argv[i-1], argv[i], 0);
11538
goto problem_handler_1;
11539
} else if(strcmp(argv[i], "--for_backup")==0) {
11540
Xorriso_option_hardlinks(xorriso, "on", 0);
11541
Xorriso_option_acl(xorriso, "on", 0);
11542
Xorriso_option_xattr(xorriso, "on", 0);
11543
Xorriso_option_md5(xorriso, "on", 0);
11544
} else if(strcmp(argv[i], "-z")==0 ||
11545
strcmp(argv[i], "-transparent-compression")==0) {
11546
Xorriso_option_zisofs(xorriso, "by_magic=on", 0);
11547
} else if(strcmp(argv[i], "--stdio_sync")==0) {
11549
goto not_enough_args;
11551
Xorriso_option_stdio_sync(xorriso, argv[i], 0);
11553
was_other_option= 1;
11555
continue; /* regular bottom of loop */
11556
problem_handler_1:;
11558
fret= Xorriso_eval_problem_status(xorriso, ret, 1|2);
11563
Xorriso_option_report_about(xorriso, ra_text, 0);
11565
if(strncmp(adr, "stdio:", 6)==0 && strncmp(adr, "stdio:/dev/fd/", 14)!=0) {
11566
ret= Sfile_type(adr+6, 1);
11569
} else if(ret==2 || ret==3) {
11570
sprintf(xorriso->info_text,
11571
"-as %s: Cannot accept %s as target: -o %s",
11572
whom, (ret==3 ? "symbolic link" : "directory"),
11573
Text_shellsafe(adr+6, sfe, 0));
11574
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
11578
/* Regard overwriteable as blank, truncate regular files on write start */
11579
ret= Xorriso_option_dev(xorriso, adr, 2|8|16);
11584
#ifndef Xorriso_multi_booT
11586
if(option_b && !no_emul_boot) {
11587
xorriso->boot_image_bin_path[0]= 0;
11588
sprintf(xorriso->info_text,
11589
"-as %s: Option -b is supported only if option -no-emul-boot is given",
11591
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
11595
#endif /* ! Xorriso_multi_booT */
11597
if(was_other_option && xorriso->out_drive_handle==NULL) {
11598
ret= Xorriso_option_dev(xorriso, "-", 2|4); /* set outdev to stdout */
11604
cpt= strchr(msc, ',');
11607
sprintf(xorriso->info_text,
11608
"-as %s: unusable parameter with option -C: %s",
11609
whom, Text_shellsafe(msc, sfe, 0));
11610
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
11612
} else if(cpt==msc || msc[1]==0)
11614
strncpy(sfe, msc, cpt-msc);
11616
if(xorriso->in_drive_handle!=NULL && indev[0]) {
11617
/* give up indev before setting the load address */
11618
ret= Xorriso_option_dev(xorriso, "", 1);
11622
/* growisofs submits msc1+16 to avoid a theoretical bug in mkisofs.
11623
Therefore this bug has to be emulated here. Sigh.
11625
ret= Xorriso_option_load(xorriso, "sbsector", sfe, 1);
11628
ret= Xorriso_option_grow_blindly(xorriso, cpt+1, 0);
11633
ret= Xorriso_option_dev(xorriso, indev, 1);
11638
if(!was_other_option)
11641
xorriso->padding= 300*1024;
11643
for(i= 0; i<argc; i++) {
11644
sprintf(xorriso->info_text, "-as %s: %s",
11645
whom, Text_shellsafe(argv[i], sfe, 0));
11646
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0);
11647
ret= Xorriso_genisofs_ignore(xorriso, whom, argv, &i, 0);
11650
if(strcmp(argv[i], "-version")==0) {
11651
/* was already handled in first argument scan */;
11653
} else if(strcmp(argv[i], "-R")==0 || strcmp(argv[i], "-rock")==0) {
11655
} else if(strcmp(argv[i], "-r")==0 || strcmp(argv[i], "-rational-rock")==0){
11657
} else if(strcmp(argv[i], "-J")==0 || strcmp(argv[i], "-joliet")==0) {
11658
xorriso->do_joliet= 1;
11659
} else if(strcmp(argv[i], "-graft-points")==0) {
11660
xorriso->allow_graft_points= 1;
11661
} else if(strcmp(argv[i], "-path-list")==0 ||
11662
strcmp(argv[i], "--quoted_path_list")==0) {
11665
sprintf(xorriso->info_text, "-as %s: Not enough arguments to option %s",
11667
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
11672
xorriso->pacifier_style= 1;
11673
ret= Xorriso_option_path_list(xorriso, argv[i],
11674
(strcmp(argv[i-1], "--quoted_path_list")==0));
11676
goto problem_handler_2;
11677
} else if(strcmp(argv[i], "-f")==0 || strcmp(argv[i], "-follow-links")==0) {
11678
/* was already handled in first argument scan */;
11679
} else if(strcmp(argv[i], "-pad")==0) {
11680
xorriso->padding= 300*1024;
11681
} else if(strcmp(argv[i], "-no-pad")==0) {
11682
xorriso->padding= 0;
11683
} else if(strcmp(argv[i], "-print-size")==0) {
11685
} else if(strcmp(argv[i], "-o")==0) {
11687
/* was already handled in first argument scan */;
11688
} else if(strcmp(argv[i], "-M")==0 || strcmp(argv[i], "-dev")==0) {
11690
/* was already handled in first argument scan */;
11691
} else if(strcmp(argv[i], "-C")==0) {
11693
/* was already handled in first argument scan */;
11694
} else if(strcmp(argv[i], "-help")==0) {
11695
/* was already handled in first argument scan */;
11696
} else if(strcmp(argv[i], "-V")==0 || strcmp(argv[i], "-volid")==0) {
11698
goto not_enough_args;
11700
ret= Xorriso_option_volid(xorriso, argv[i], 0);
11702
goto problem_handler_2;
11703
} else if(strcmp(argv[i], "-volset")==0) {
11705
goto not_enough_args;
11707
ret= Xorriso_option_volid(xorriso, argv[i], 0);
11709
goto problem_handler_2;
11710
} else if(strcmp(argv[i], "-P")==0 || strcmp(argv[i], "-publisher")==0) {
11712
goto not_enough_args;
11714
ret= Xorriso_option_publisher(xorriso, argv[i], 0);
11716
goto problem_handler_2;
11717
} else if(strcmp(argv[i], "-A")==0 || strcmp(argv[i], "-appid")==0) {
11719
goto not_enough_args;
11721
ret= Xorriso_option_application_id(xorriso, argv[i], 0);
11723
goto problem_handler_2;
11724
} else if(strcmp(argv[i], "-sysid")==0) {
11726
goto not_enough_args;
11728
ret= Xorriso_option_system_id(xorriso, argv[i], 0);
11730
goto problem_handler_2;
11731
} else if(strcmp(argv[i], "-m")==0 || strcmp(argv[i], "-exclude")==0 ||
11732
strcmp(argv[i], "-x")==0 || strcmp(argv[i], "-old-exclude")==0) {
11734
goto not_enough_args;
11736
mem= xorriso->do_disk_pattern;
11737
xorriso->do_disk_pattern= 1;
11738
if(strchr(argv[i], '/')!=NULL) {
11740
ret= Xorriso_option_not_paths(xorriso, i+1, argv, &idx, 0);
11742
ret= Xorriso_option_not_leaf(xorriso, argv[i], 0);
11743
xorriso->do_disk_pattern= mem;
11745
goto problem_handler_2;
11746
} else if(strcmp(argv[i], "-exclude-list")==0) {
11748
goto not_enough_args;
11750
mem= xorriso->do_disk_pattern;
11751
xorriso->do_disk_pattern= 1;
11752
ret= Xorriso_option_not_list(xorriso, argv[i], 0);
11753
xorriso->do_disk_pattern= mem;
11755
goto problem_handler_2;
11756
} else if(strcmp(argv[i], "-v")==0 || strcmp(argv[i], "-quiet")==0) {
11757
/* was already handled in first argument scan */;
11759
} else if(strcmp(argv[i], "-iso-level")==0) {
11761
/* was already handled in first argument scan */;
11763
#ifdef Xorriso_multi_booT
11765
} else if(strcmp(argv[i], "-no-emul-boot")==0 ||
11766
strcmp(argv[i], "-boot-info-table")==0 ||
11767
strncmp(argv[i], "isolinux_mbr=", 13)==0 ||
11768
strncmp(argv[i], "isolinux_mbr=", 13)==0 ||
11769
strcmp(argv[i], "-eltorito-alt-boot")==0 ||
11770
strcmp(argv[i], "--protective-msdos-label")==0) {
11771
boot_opt_list[boot_opt_count++]= i;
11772
} else if(strcmp(argv[i], "-b") == 0 ||
11773
strcmp(argv[i], "-eltorito-boot") == 0 ||
11774
strcmp(argv[i], "--efi-boot") == 0 ||
11775
strcmp(argv[i], "-c") == 0 ||
11776
strcmp(argv[i], "-eltorito-catalog") == 0 ||
11777
strcmp(argv[i], "-boot-load-size") == 0 ||
11778
strcmp(argv[i], "--embedded-boot")==0 ||
11779
strcmp(argv[i], "-generic-boot")==0 ||
11780
strcmp(argv[i], "-G") == 0 ||
11781
strcmp(argv[i], "-isohybrid-mbr")==0) {
11783
goto not_enough_args;
11784
boot_opt_list[boot_opt_count++]= i;
11787
#else /* Xorriso_multi_booT */
11789
} else if(strcmp(argv[i], "-no-emul-boot")==0) {
11790
/* was already handled in first argument scan */;
11791
} else if(strcmp(argv[i], "-b") == 0 ||
11792
strcmp(argv[i], "-eltorito-boot") == 0 ||
11793
strcmp(argv[i], "--efi-boot") == 0) {
11795
} else if(strcmp(argv[i], "-c") == 0 ||
11796
strcmp(argv[i], "-eltorito-catalog") == 0) {
11798
/* was already handled in first argument scan */;
11799
} else if(strncmp(argv[i], "isolinux_mbr=", 13)==0) {
11800
/* was already handled in first argument scan */;
11801
} else if(strcmp(argv[i], "--embedded-boot")==0 ||
11802
strcmp(argv[i], "-generic-boot")==0 ||
11803
strcmp(argv[i], "-G") == 0 ||
11804
strcmp(argv[i], "-isohybrid-mbr")==0) {
11806
goto not_enough_args;
11808
ret= Xorriso_set_system_area_path(xorriso, argv[i], 0);
11811
if(strcmp(argv[i - 1], "-isohybrid-mbr")==0)
11812
xorriso->system_area_options= (xorriso->system_area_options & ~3) | 2;
11813
} else if(strcmp(argv[i], "-boot-load-size") == 0) {
11815
/* was already handled in first argument scan */;
11816
} else if(strcmp(argv[i], "-boot-info-table")==0) {
11818
} else if(strcmp(argv[i], "--protective-msdos-label")==0) {
11819
xorriso->system_area_options= (xorriso->system_area_options & ~3) | 1;
11821
#endif /* ! Xorriso_multi_booT */
11823
} else if(strncmp(argv[i], "--modification-date=", 20)==0) {
11824
ret= Xorriso_option_volume_date(xorriso, "uuid", argv[i] + 20, 0);
11826
goto problem_handler_1;
11828
} else if(strcmp(argv[i], "-input-charset")==0) {
11830
/* was already handled in first argument scan */;
11831
} else if(strcmp(argv[i], "-output-charset")==0) {
11833
/* was already handled in first argument scan */;
11834
} else if(strcmp(argv[i], "--hardlinks")==0 ||
11835
strcmp(argv[i], "--acl")==0 ||
11836
strcmp(argv[i], "--xattr")==0 ||
11837
strcmp(argv[i], "--md5")==0 ||
11838
strcmp(argv[i], "--for_backup")==0) {
11839
/* was already handled in first argument scan */;
11840
} else if(strcmp(argv[i], "--scdbackup_tag")==0) {
11841
/* was already handled in first argument scan */;
11843
} else if(strcmp(argv[i], "--sort-weight")==0) {
11845
goto not_enough_args;
11847
/* memorize for find runs after pathspecs have been added */
11848
weight_list[weight_count++]= i - 2;
11849
} else if(strcmp(argv[i], "-z")==0 ||
11850
strcmp(argv[i], "-transparent-compression")==0) {
11851
/* was already handled in first argument scan */;
11852
} else if(argv[i][0]=='-' && argv[i][1]!=0) {
11853
sprintf(xorriso->info_text, "-as %s: Unknown option %s",
11854
whom, Text_shellsafe(argv[i], sfe, 0));
11855
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
11859
/* implementing mkisofs tendency to map single-path pathspecs to / */
11860
if((!xorriso->allow_graft_points) ||
11861
Fileliste__target_source_limit(argv[i], '=', &ept, 0)<=0) {
11862
ret= Xorriso_normalize_img_path(xorriso, xorriso->wdx, argv[i],
11865
goto problem_handler_2;
11866
ret= Sfile_type(eff_path,
11867
1|((xorriso->do_follow_param||xorriso->do_follow_links)<<2));
11869
strcpy(pathspec, "/=");
11873
ret= Sfile_leafname(eff_path, pathspec+1, 0);
11875
strcat(pathspec, "=");
11879
strcat(pathspec, eff_path);
11883
mem_graft_points= xorriso->allow_graft_points;
11884
xorriso->allow_graft_points= 1;
11885
ret= Xorriso_option_add(xorriso, 1, &add_pt, &zero, was_path<<1);
11886
xorriso->allow_graft_points= mem_graft_points;
11888
goto problem_handler_2;
11890
xorriso->pacifier_style= 1;
11892
continue; /* regular bottom of loop */
11893
problem_handler_2:;
11895
fret= Xorriso_eval_problem_status(xorriso, ret, 1|2);
11900
if(do_print_size) {
11901
ret= Xorriso_option_print_size(xorriso, 1);
11907
ret= Xorriso_option_find(xorriso, 3, lower_r_args, &zero, 2);
11912
for(j= 0; j < weight_count; j++) {
11914
/* find argv[i+2] -exec sort_weight argv[i+1] */
11916
sort_weight_args[0]= argv[i + 2];
11917
sort_weight_args[3]= argv[i + 1];
11918
ret= Xorriso_option_find(xorriso, 4, sort_weight_args, &zero, 2);
11921
/* Problem handler */
11923
fret= Xorriso_eval_problem_status(xorriso, ret, 1|2);
11929
#ifdef Xorriso_multi_booT
11931
/* After all pathspecs are added: perform boot related options */
11932
for(j= 0; j < boot_opt_count; j++) {
11933
i= boot_opt_list[j];
11934
if(strcmp(argv[i], "-no-emul-boot")==0) {
11936
} else if(strcmp(argv[i], "-boot-info-table")==0) {
11937
xorriso->patch_isolinux_image= 1;
11938
} else if(strcmp(argv[i], "-b") == 0 ||
11939
strcmp(argv[i], "-eltorito-boot") == 0 ||
11940
strcmp(argv[i], "--efi-boot") == 0) {
11942
if(strcmp(argv[i - 1], "--efi-boot") == 0) {
11943
if(xorriso->boot_image_bin_path[0]) {
11944
ret= Xorriso_genisofs_add_boot(xorriso, whom,
11945
&option_b, &no_emul_boot, 0);
11947
goto problem_handler_boot;
11949
boot_path= xorriso->boot_image_bin_path;
11950
xorriso->boot_efi_default= 1;
11952
boot_path= xorriso->boot_image_bin_path;
11953
xorriso->boot_platform_id= 0x00;
11954
xorriso->boot_efi_default= 0;
11958
if(argv[i][0] != '/')
11959
strcat(boot_path, "/");
11960
ret= Sfile_str(boot_path + strlen(boot_path), argv[i], 0);
11963
if(xorriso->boot_efi_default && xorriso->boot_image_bin_path[0]) {
11965
ret= Xorriso_genisofs_add_boot(xorriso, whom,
11966
&option_b, &no_emul_boot, 0);
11968
goto problem_handler_boot;
11970
xorriso->keep_boot_image= 0;
11971
} else if(strcmp(argv[i], "-c") == 0 ||
11972
strcmp(argv[i], "-eltorito-catalog") == 0) {
11974
goto not_enough_args;
11976
xorriso->boot_image_cat_path[0]= 0;
11977
if(argv[i][0] != '/')
11978
strcat(xorriso->boot_image_cat_path, "/");
11979
ret= Sfile_str(xorriso->boot_image_cat_path
11980
+ strlen(xorriso->boot_image_cat_path), argv[i], 0);
11983
} else if(strcmp(argv[i], "-boot-load-size") == 0) {
11985
goto not_enough_args;
11987
sscanf(argv[i], "%d", &ret);
11988
xorriso->boot_image_load_size= ret * 512;
11989
} else if(strncmp(argv[i], "isolinux_mbr=", 13)==0) {
11990
sprintf(sfe, "isohybrid=%s", argv[i] + 13);
11991
ret= Xorriso_option_boot_image(xorriso, "isolinux", sfe, 0);
11993
goto problem_handler_boot;
11994
} else if(strcmp(argv[i], "-eltorito-alt-boot")==0) {
11995
ret= Xorriso_genisofs_add_boot(xorriso, whom,
11996
&option_b, &no_emul_boot, 0);
11998
goto problem_handler_boot;
11999
} else if(strcmp(argv[i], "--embedded-boot")==0 ||
12000
strcmp(argv[i], "-generic-boot")==0 ||
12001
strcmp(argv[i], "-G") == 0 ||
12002
strcmp(argv[i], "-isohybrid-mbr")==0) {
12004
goto not_enough_args;
12006
ret= Xorriso_set_system_area_path(xorriso, argv[i], 0);
12008
goto problem_handler_boot;
12009
if(strcmp(argv[i - 1], "-isohybrid-mbr")==0)
12010
xorriso->system_area_options= (xorriso->system_area_options & ~3) | 2;
12011
} else if(strcmp(argv[i], "--protective-msdos-label")==0) {
12012
xorriso->system_area_options= (xorriso->system_area_options & ~3) | 1;
12014
continue; /* regular bottom of loop */
12015
problem_handler_boot:;
12016
/* Problem handler */
12018
fret= Xorriso_eval_problem_status(xorriso, ret, 1|2);
12023
if(xorriso->boot_image_bin_path[0]) {
12024
ret= Xorriso_genisofs_add_boot(xorriso, whom, &option_b, &no_emul_boot, 0);
12029
#endif /* Xorriso_multi_booT */
12033
if(was_path && !do_print_size)
12034
Xorriso_pacifier_callback(xorriso, "files added", xorriso->pacifier_count,
12035
xorriso->pacifier_total, "", 1);
12036
if(do_print_size && xorriso->volset_change_pending)
12037
Xorriso_option_rollback(xorriso, 0);
12038
if(weight_list != NULL)
12040
if(boot_opt_list != NULL)
12041
free(boot_opt_list);
12046
int Xorriso_as_genisofs(struct XorrisO *xorriso, int argc, char **argv,
12047
int *idx, int flag)
12049
int end_idx, ret, idx_count, old_idx;
12052
end_idx= Xorriso_end_idx(xorriso, argc, argv, *idx, 1);
12054
idx_count= end_idx-old_idx;
12055
if(end_idx<=0 || old_idx>=argc)
12057
ret= Xorriso_genisofs(xorriso, "genisofs", end_idx-old_idx, argv+old_idx, 0);
12062
int Xorriso_as_cdrskin(struct XorrisO *xorriso, int argc, char **argv,
12063
int *idx, int flag)
12065
int end_idx, ret, idx_count, old_idx;
12068
end_idx= Xorriso_end_idx(xorriso, argc, argv, *idx, 1);
12070
idx_count= end_idx-old_idx;
12071
if(end_idx<=0 || old_idx>=argc)
12073
ret= Xorriso_cdrskin(xorriso, "cdrskin", end_idx-old_idx, argv+old_idx, 0);
12078
/* @param boss_iter Opaque handle to be forwarded to actions in ISO image
12079
Set to NULL if calling this function from outside ISO world
12080
@param flag bit0= widen hardlink sibling:
12081
Do not call Xorriso_hardlink_update()
12082
Overwrite exactly if normal mode would not,
12084
bit2= -follow: this is not a command parameter
12085
@return <=0 error, 1= ok , 2= iso_rr_path node object has been deleted ,
12088
int Xorriso_update_interpreter(struct XorrisO *xorriso, void *boss_iter,
12089
int compare_result, char *disk_path,
12090
char *iso_rr_path, int flag)
12092
int ret, deleted= 0, is_split= 0, i, loop_count, late_hardlink_update= 0;
12093
char sfe[5*SfileadrL];
12095
struct SplitparT *split_parts= NULL;
12096
int split_count= 0;
12097
char part_path[SfileadrL], *part_name;
12098
int partno, total_parts, new_total_parts;
12099
off_t offset, bytes, total_bytes, disk_size, first_bytes;
12101
if((compare_result&3)==3) {
12102
sprintf(xorriso->info_text, "Missing on disk and in ISO: disk_path %s",
12103
Text_shellsafe(disk_path, sfe, 0));
12104
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 1);
12105
xorriso->find_compare_result= -1;
12109
if(compare_result&((1<<11)|(1<<13))) {
12112
/* cannot open regular disk file, early eof of disk file */
12113
sprintf(xorriso->info_text, "Problems with reading disk file %s",
12114
Text_shellsafe(disk_path, sfe, 0));
12115
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 1);
12116
xorriso->find_compare_result= -1;
12119
xorriso->info_text[0]= 0;
12120
is_split= !!(compare_result & (1<<17));
12122
if((!(xorriso->ino_behavior & 2)) && (compare_result & (2 | (3 << 21))) &&
12124
if(compare_result & 2) {
12125
/* File is not yet in image */
12126
late_hardlink_update= 1;
12128
/* Hard link relation has changed resp. was not recorded. */
12129
ret= Xorriso_hardlink_update(xorriso, &compare_result,
12130
disk_path, iso_rr_path, flag & 4);
12138
if(compare_result&(8|64)) {
12139
/* file type, minor+major with device file */
12142
ret= Xorriso_rmi(xorriso, boss_iter, (off_t) 0, iso_rr_path, 1); /* rm_r */
12145
ret= Xorriso_graft_in(xorriso, boss_iter, disk_path, iso_rr_path,
12146
(off_t) 0, (off_t) 0, 2|(flag&4));
12148
sprintf(xorriso->info_text, "Deleted and re-added ");
12150
} else if(compare_result&(1)) {
12152
/* disk_adr not existing */
12153
ret= Xorriso_rmi(xorriso, boss_iter, (off_t) 0, iso_rr_path, 1);
12155
sprintf(xorriso->info_text, "Deleted ");
12157
} else if(compare_result&(2|128|(1<<12)|(1<<14)|(1<<15))) {
12158
/* iso_adr not existing, size, cannot open iso file, early eof of iso file
12159
content bytes differ */
12165
ret= Xorriso_identify_split(xorriso, iso_rr_path, NULL,
12166
&split_parts, &split_count, &stbuf, 0);
12168
{ret= -1; goto ex;} /* (should not happen) */
12169
ret= lstat(disk_path, &stbuf);
12172
disk_size= stbuf.st_size;
12173
Splitparts_get(split_parts, 0, &part_name, &partno, &total_parts,
12174
&offset, &first_bytes, &total_bytes, 0);
12175
new_total_parts= disk_size/first_bytes;
12176
if(disk_size % first_bytes)
12179
loop_count= split_count;
12180
/* If disk file grew over part limit and all parts are present:
12182
if(new_total_parts > total_parts && split_count == total_parts)
12183
loop_count= new_total_parts;
12185
for(i= 0; i<loop_count; i++) {
12186
if(i<split_count) {
12187
/* Delete old part */
12188
Splitparts_get(split_parts, i, &part_name, &partno, &total_parts,
12189
&offset, &bytes, &total_bytes, 0);
12190
strcpy(part_path, iso_rr_path);
12191
if(Sfile_add_to_path(part_path, part_name, 0)<=0) {
12192
Xorriso_much_too_long(xorriso,
12193
strlen(iso_rr_path)+strlen(part_path)+1, 2);
12194
{ret= -1; goto ex;}
12196
ret= Xorriso_rmi(xorriso, NULL, (off_t) 0, part_path, 1);
12202
offset= i*first_bytes;
12203
bytes= first_bytes;
12205
if(disk_size<=offset)
12207
/* Insert new part */
12208
if(strlen(part_path)+160>SfileadrL) {
12209
Xorriso_much_too_long(xorriso, strlen(part_path)+160, 2);
12212
Splitpart__compose(part_path+strlen(iso_rr_path)+1, partno,
12213
new_total_parts, offset, first_bytes, disk_size, 0);
12214
ret= Xorriso_graft_in(xorriso, boss_iter, disk_path, part_path,
12215
offset, bytes, 2|(flag&4)|8|128);
12219
/* Copy file attributes to iso_rr_path, augment r-perms by x-perms */
12220
ret= Xorriso_copy_properties(xorriso, disk_path, iso_rr_path, 2 | 4);
12224
ret= Xorriso_graft_in(xorriso, boss_iter, disk_path, iso_rr_path,
12225
(off_t) 0, (off_t) 0, 2|(flag&4));
12226
if(ret>0 && !(compare_result&2))
12229
if(late_hardlink_update) {
12230
/* Handle eventual hardlink siblings of newly created file */
12231
ret= Xorriso_hardlink_update(xorriso, &compare_result,
12232
disk_path, iso_rr_path, 1 | (flag & 4));
12237
sprintf(xorriso->info_text, "Widened hard link ");
12239
sprintf(xorriso->info_text, "Added/overwrote ");
12241
} else if(compare_result&(4|16|32|256|512|1024|(1<<19)|(1<<20)|(1<<22))) {
12242
/* access permissions, user id, group id, mtime, atime, ctime, ACL, xattr,
12249
ret= Xorriso_identify_split(xorriso, iso_rr_path, NULL,
12250
&split_parts, &split_count, &stbuf, 0);
12252
{ret= -1; goto ex;} /* (should not happen) */
12253
for(i= 0; i<split_count; i++) {
12254
Splitparts_get(split_parts, i, &part_name, &partno, &total_parts,
12255
&offset, &bytes, &total_bytes, 0);
12256
strcpy(part_path, iso_rr_path);
12257
if(Sfile_add_to_path(part_path, part_name, 0)<=0) {
12258
Xorriso_much_too_long(xorriso,
12259
strlen(iso_rr_path)+strlen(part_path)+1, 2);
12260
{ret= -1; goto ex;}
12262
ret= Xorriso_copy_properties(xorriso, disk_path, part_path,
12263
4 * !(compare_result & (1<<21)));
12264
/* do not update eventually mismatching dev_ino */
12268
/* Copy file attributes to iso_rr_path, augment r-perms by x-perms */
12269
ret= Xorriso_copy_properties(xorriso, disk_path, iso_rr_path, 2 | 4);
12273
ret= Xorriso_copy_properties(xorriso, disk_path, iso_rr_path, 4);
12274
sprintf(xorriso->info_text, "Adjusted attributes of ");
12276
} else if(flag & 1) {
12280
if(ret>0 && xorriso->info_text[0]) {
12281
strcat(xorriso->info_text, Text_shellsafe(iso_rr_path, sfe, 0));
12282
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "UPDATE", 0);
12286
if(split_parts!=NULL)
12287
Splitparts_destroy(&split_parts, split_count, 0);
12296
int Xorriso_write_session_log(struct XorrisO *xorriso, int flag)
12299
char sfe[5*SfileadrL], timetext[40], *rpt, *wpt;
12301
if(xorriso->session_logfile[0]==0)
12303
fp= fopen(xorriso->session_logfile, "a");
12305
sprintf(xorriso->info_text, "-session_log: Cannot open file %s",
12306
Text_shellsafe(xorriso->session_logfile, sfe, 0));
12307
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
12311
for(rpt= xorriso->volid; *rpt!=0; rpt++) {
12319
fprintf(fp, "%s %d %d %s\n",
12320
Ftimetxt(time(0), timetext, 2), xorriso->session_lba,
12321
xorriso->session_blocks, sfe);
12327
/* @param flag bit0= path is a command parameter
12329
int Xorriso_path_is_excluded(struct XorrisO *xorriso, char *path, int flag)
12332
char sfe[5*SfileadrL];
12334
if(!(xorriso->disk_excl_mode&1)) /* exclusion is off */
12336
if((flag&1) && !(xorriso->disk_excl_mode&2)) /* params are exempted */
12338
ret= Exclusions_match(xorriso->disk_exclusions, path,
12339
!!(xorriso->disk_excl_mode&4));
12341
sprintf(xorriso->info_text,
12342
"Error during disk file exclusion decision");
12343
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
12345
if(ret>0 && (flag&1)) {
12346
sprintf(xorriso->info_text, "Disk path parameter excluded by %s : %s",
12347
(ret==1 ? "-not_paths" : "-not_leaf"), Text_shellsafe(path, sfe, 0));
12348
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
12354
/* @param flag bit7= return 4 if restore fails from denied permission
12355
do not issue error message
12356
@return <=0 failure , 1 success ,
12357
4 with bit7: permission to create file was denied
12359
int Xorriso_make_tmp_path(struct XorrisO *xorriso, char *orig_path,
12360
char *tmp_path, int *fd, int flag)
12364
cpt= strrchr(orig_path, '/');
12368
strncpy(tmp_path, orig_path, cpt+1-orig_path);
12369
tmp_path[cpt+1-orig_path]= 0;
12371
strcat(tmp_path, "_tmp_xorriso_restore_XXXXXX");
12372
*fd= mkstemp(tmp_path);
12374
if(errno == EACCES && (flag & 128))
12376
strcpy(xorriso->info_text, "Cannot create temporary file : ");
12377
Text_shellsafe(tmp_path, xorriso->info_text, 1);
12378
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE", 0);
12381
fchmod(*fd, S_IRUSR|S_IWUSR);
12386
/* @param flag bit0= change regardless of xorriso->do_auto_chmod
12387
bit1= desired is only rx
12388
@return -1=severe error , -2= cannot chmod, 0= nothing to do, 1 = chmoded
12390
int Xorriso_auto_chmod(struct XorrisO *xorriso, char *disk_path, int flag)
12392
int ret, is_link= 0;
12393
char *path_pt, sfe[5*SfileadrL], link_target[SfileadrL];
12394
mode_t mode, desired= S_IRUSR | S_IWUSR | S_IXUSR;
12397
if(!(xorriso->do_auto_chmod || (flag & 1)))
12401
desired &= ~S_IWUSR;
12402
path_pt= disk_path;
12403
ret= lstat(path_pt, &stbuf);
12406
if(S_ISLNK(stbuf.st_mode)) {
12408
ret= stat(path_pt, &stbuf);
12412
if(!S_ISDIR(stbuf.st_mode))
12415
ret= Xorriso_resolve_link(xorriso, path_pt, link_target, 0);
12418
path_pt= link_target;
12420
if((stbuf.st_mode & desired) == desired)
12422
if(stbuf.st_uid!=geteuid())
12425
mode= (stbuf.st_mode | desired) & 07777;
12426
ret= chmod(path_pt, mode);
12428
sprintf(xorriso->info_text,
12429
"Cannot change access permissions of disk directory: chmod %o %s",
12430
(unsigned int) (mode & 07777), Text_shellsafe(path_pt, sfe, 0));
12431
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "SORRY", 0);
12434
ret= Permstack_push(&(xorriso->perm_stack), path_pt, &stbuf, 0);
12441
int Xorriso_make_accessible(struct XorrisO *xorriso, char *disk_path, int flag)
12443
int done= 0, ret, just_rx= 2;
12444
char *npt, *apt, path[SfileadrL], *wpt;
12448
for(npt= apt; !done; apt= npt + 1) {
12449
npt= strchr(apt, '/');
12452
if(strchr(npt + 1, '/') == NULL)
12454
strncpy(wpt, apt, npt + 1 - apt);
12455
wpt+= npt + 1 - apt;
12457
ret= Xorriso_auto_chmod(xorriso, path, just_rx);
12467
/* @param flag bit0= prefer to find a match after *img_prefixes
12468
(but deliver img_prefixes if no other can be found)
12470
int Xorriso_make_restore_path(struct XorrisO *xorriso,
12471
struct Xorriso_lsT **img_prefixes, struct Xorriso_lsT **disk_prefixes,
12472
char img_path[SfileadrL], char disk_path[SfileadrL], int flag)
12475
struct Xorriso_lsT *s, *d, *found_s= NULL, *found_d= NULL;
12478
/* Obtain disk_path by replacing start piece of img_path */
12481
for(s= *img_prefixes; s != NULL;
12482
s= Xorriso_lst_get_next(s, 0), d= Xorriso_lst_get_next(d, 0)) {
12484
ipfx= Xorriso_lst_get_text(s, 0);
12486
dpfx= Xorriso_lst_get_text(d, 0);
12487
if(strncmp(img_path, ipfx, li) != 0)
12489
if(img_path[li] != 0 && img_path[li] != '/')
12491
if(strlen(dpfx) + strlen(img_path) - li + 1 >= SfileadrL)
12493
if(img_path[li]=='/')
12494
sprintf(disk_path, "%s/%s", dpfx, img_path + strlen(ipfx) + 1);
12496
strcpy(disk_path, dpfx);
12499
if(s != *img_prefixes || !(flag & 1))
12502
*img_prefixes= found_s;
12503
*disk_prefixes= found_d;
12504
return(found_s != NULL);
12508
/* @param flag bit0=permission to run Xorriso_make_accessible
12510
int Xorriso_restore_make_hl(struct XorrisO *xorriso,
12511
char *old_path, char *new_path, int flag)
12514
struct PermiteM *perm_stack_mem;
12516
ret= link(old_path, new_path);
12519
if(errno == EACCES && (flag & 1)) {
12520
perm_stack_mem= xorriso->perm_stack;
12521
ret= Xorriso_make_accessible(xorriso, new_path, 0);
12523
ret= link(old_path, new_path);
12525
Permstack_pop(&(xorriso->perm_stack), perm_stack_mem, xorriso, 0);
12529
Permstack_pop(&(xorriso->perm_stack), perm_stack_mem, xorriso, 0);
12532
sprintf(xorriso->info_text, "Hardlinking failed: ");
12533
Text_shellsafe(new_path, xorriso->info_text, 1);
12534
strcat(xorriso->info_text, " -> ");
12535
Text_shellsafe(old_path, xorriso->info_text, 1);
12536
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "WARNING", 0);
12541
/* @param flag bit0= mark untested areas as valid
12543
int Xorriso_spotlist_to_sectormap(struct XorrisO *xorriso,
12544
struct SpotlisT *spotlist,
12546
struct SectorbitmaP **map,
12549
struct SectorbitmaP *m;
12550
int map_sectors= -1, map_sector_size= -1, valid;
12551
int list_sectors, list_blocks, sector_size, sector_blocks;
12552
int replace_map= 0, count, i, lba, blocks, quality, ret, pass;
12554
sector_size= Spotlist_sector_size(spotlist, read_chunk, 0);
12555
sector_blocks= sector_size / 2048;
12557
Sectorbitmap_get_layout(*map, &map_sectors, &map_sector_size, 0);
12559
count= Spotlist_count(spotlist, 0);
12560
list_blocks= Spotlist_block_count(spotlist, 0);
12562
/* >>> ??? insist in list_blocks % sector_blocks == 0 */
12564
list_sectors= list_blocks / sector_blocks;
12565
if(list_sectors * sector_blocks < list_blocks)
12567
if(*map != NULL && map_sectors * (map_sector_size / 2048) >= list_blocks &&
12568
map_sector_size == sector_size)
12572
if(((off_t) (*map)->sectors) * ((off_t) (*map)->sector_size) >
12573
((off_t) list_sectors) * ((off_t) sector_size))
12574
list_sectors= (((off_t) (*map)->sectors) *
12575
((off_t) (*map)->sector_size)) / ((off_t) sector_size)
12578
ret= Sectorbitmap_new(&m, list_sectors, sector_size, 0);
12583
ret= Sectorbitmap_copy(*map, m, 0);
12585
Sectorbitmap_destroy(&m, 0);
12591
count= Spotlist_count(spotlist, 0);
12592
/* first set good bits, then eventually override by bad bits */
12593
for(pass= 0; pass < 2; pass++) {
12594
for(i= 0; i < count; i++) {
12595
ret= Spotlist_get_item(spotlist, i, &lba, &blocks, &quality, 0);
12598
valid= quality > xorriso->check_media_bad_limit;
12599
if(quality == Xorriso_read_quality_untesteD && (flag & 1))
12601
else if(pass == 0 && !valid)
12603
else if(pass == 1 && valid)
12605
Sectorbitmap_set_range(m, lba / sector_blocks, blocks / sector_blocks,
12610
Sectorbitmap_destroy(map, 0);
12617
int Xorriso_sectormap_to_spotlist(struct XorrisO *xorriso,
12618
struct CheckmediajoB *job,
12619
struct SpotlisT **spotlist,
12622
struct SectorbitmaP *map;
12623
int ret, i, sectors, sector_size, value, old_value= -1, old_start= -1;
12625
map= job->sector_map;
12628
ret= Spotlist_new(spotlist, 0);
12630
{ret= -1; goto ex;}
12631
Sectorbitmap_get_layout(map, §ors, §or_size, 0);
12632
sector_size/= 2048;
12633
if(job->max_lba >= 0)
12634
sectors= (job->max_lba + 1) / sector_size;
12636
if(job->min_lba >= 0)
12637
i= job->min_lba / sector_size;
12638
for(; i < sectors; i++) {
12639
value= Sectorbitmap_is_set(map, i, 0);
12640
if(value == old_value)
12642
if(old_value >= 0) {
12643
ret= Spotlist_add_item(*spotlist, old_start, i * sector_size - old_start,
12644
(old_value ? Xorriso_read_quality_valiD :
12645
Xorriso_read_quality_invaliD), 0);
12648
if(job->item_limit > 0 &&
12649
Spotlist_count(*spotlist, 0) + 1 >= job->item_limit) {
12650
sprintf(xorriso->info_text, "-check_media: Reached item_limit=%d",
12652
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
12653
if(sectors - i > 1) {
12654
ret= Spotlist_add_item(*spotlist, i * sector_size,
12655
(sectors - i - 1) * sector_size,
12656
Xorriso_read_quality_untesteD, 0);
12664
old_start= i * sector_size;
12666
if(old_value >= 0) {
12667
ret= Spotlist_add_item(*spotlist, old_start, i * sector_size - old_start,
12668
(old_value ? Xorriso_read_quality_valiD :
12669
Xorriso_read_quality_invaliD), 0);
12676
Spotlist_destroy(spotlist, 0);
12681
int Xorriso_afile_fopen(struct XorrisO *xorriso,
12682
char *filename, char *mode, FILE **ret_fp, int flag)
12684
bit0= do not print error message on failure
12685
bit1= do not open stdin
12691
if(strcmp(filename,"-")==0) {
12692
if(mode[0]=='a' || mode[0]=='w' ||
12693
(mode[0]=='r' && mode[1]=='+') ||
12694
(mode[0]=='r' && mode[1]=='b' && mode[2]=='+'))
12696
else if(flag & 2) {
12697
Xorriso_msgs_submit(xorriso, 0, "Not allowed as input path: '-'", 0,
12701
Xorriso_msgs_submit(xorriso, 0, "Ready for data at standard input", 0,
12705
} else if(strncmp(filename,"tcp:",4)==0){
12706
Xorriso_msgs_submit(xorriso, 0, "TCP/IP service isn't implemented yet.", 0,
12708
} else if(strncmp(filename,"file:",5)==0){
12709
fp= fopen(filename+5,mode);
12711
fp= fopen(filename,mode);
12715
sprintf(xorriso->info_text,
12716
"Failed to open file '%s' in %s mode\n", filename, mode);
12717
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE", 0);
12726
/* @param flag bit2=do not try to read ISO heads
12728
int Xorriso_toc_to_string(struct XorrisO *xorriso, char **toc_text, int flag)
12730
int ret, stack_handle, toc_ret, l;
12731
struct Xorriso_lsT *results= NULL, *infos= NULL, *lpt;
12734
ret= Xorriso_push_outlists(xorriso, &stack_handle, 1);
12737
toc_ret= Xorriso_toc(xorriso, flag & 4);
12738
ret= Xorriso_pull_outlists(xorriso, stack_handle, &results, &infos, 0);
12742
{ret= toc_ret; goto ex;}
12744
for(lpt= results; lpt != NULL; lpt= Xorriso_lst_get_next(lpt, 0))
12745
l+= strlen(Xorriso_lst_get_text(lpt, 0));
12746
*toc_text= calloc(l + 1, 1);
12748
for(lpt= results; lpt != NULL; lpt= Xorriso_lst_get_next(lpt, 0)) {
12749
strcpy((*toc_text) + l, Xorriso_lst_get_text(lpt, 0));
12750
l+= strlen(Xorriso_lst_get_text(lpt, 0));
12753
Xorriso_lst_destroy_all(&results, 0);
12754
Xorriso_lst_destroy_all(&infos, 0);
12759
int Xorriso_open_job_data_to(struct XorrisO *xorriso,
12760
struct CheckmediajoB *job, int flag)
12762
char sfe[5*SfileadrL];
12764
if(job->data_to_path[0] == 0)
12766
job->data_to_fd= open(job->data_to_path, O_RDWR | O_CREAT,
12767
S_IRUSR | S_IWUSR);
12768
if(job->data_to_fd == -1) {
12769
sprintf(xorriso->info_text, "Cannot open path %s",
12770
Text_shellsafe(job->data_to_path, sfe, 0));
12771
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE", 0);
12778
@param flag bit0= make absolute command paths with known systems
12779
bit1= do not allow prefixes with cmd
12780
bit2= interpret unprefixed cmd as shell:
12782
int Xorriso_make_mount_cmd(struct XorrisO *xorriso, char *cmd,
12783
int lba, int track, int session, char *volid,
12784
char *devadr, char result[SfileadrL], int flag)
12786
int ret, reg_file= 0, is_safe= 0, sys_code= 0;
12787
char form[6*SfileadrL], session_text[12], track_text[12], lba_text[12];
12788
char *vars[5][2], sfe[5*SfileadrL], volid_sfe[5*80+1], *cpt, *sysname;
12791
if(strlen(cmd) > SfileadrL) {
12795
Xorriso_msgs_submit(xorriso, 0, "Argument much too long", 0, "FAILURE", 0);
12798
ret= stat(devadr, &stbuf);
12800
if(S_ISREG(stbuf.st_mode))
12802
if(strncmp(cmd, "linux:", 6) == 0 && !(flag & 2)) {
12805
} else if(strncmp(cmd, "freebsd:", 8) == 0 && !(flag & 2)) {
12808
} else if(strncmp(cmd, "string:", 7) == 0 && !(flag & 2)) {
12811
} else if(flag & 4) {
12816
ret= System_uname(&sysname, NULL, NULL, NULL, 0);
12818
Xorriso_msgs_submit(xorriso, 0,
12819
"-mount*: Cannot determine current system type",
12822
} else if(strcmp(sysname, "FreeBSD") == 0 ||
12823
strcmp(sysname, "GNU/kFreeBSD") == 0) {
12824
/* "GNU/kFreeBSD" = Debian kfreebsd */
12826
} else if(strcmp(sysname, "Linux") == 0) {
12829
sprintf(xorriso->info_text, "-mount*: Unsupported system type %s",
12830
Text_shellsafe(sysname, sfe, 0));
12831
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
12836
if(sys_code == 1) { /* GNU/Linux */
12838
"%smount -t iso9660 -o %snodev,noexec,nosuid,ro,sbsector=%%sbsector%% %%device%% %s",
12839
(flag & 1 ? "/bin/" : ""),
12840
(reg_file || (xorriso->mount_opts_flag & 1) ? "loop," : ""),
12841
Text_shellsafe(cpt, sfe, 0));
12843
} else if(sys_code == 2) { /* FreeBSD */
12846
/* <<< Considered to create vnode as of
12847
J.R. Oldroyd <fbsd@opal.com>, 20 Nov 2008
12848
but for now refraining from creating that persistent file object
12850
strcpy(form, "n=$(mdconfig -a -t vnode -f %device%)");
12851
sprintf(form + strlen(form),
12852
" && mount -t cd9660 -o noexec,nosuid -s %%sbsector%% /dev/\"$n\" %s",
12853
Text_shellsafe(cmd+8, sfe, 0));
12856
Xorriso_msgs_submit(xorriso, 0,
12857
"Detected regular file as mount device with FreeBSD style command.",
12859
Xorriso_msgs_submit(xorriso, 0,
12860
"Command mdconfig -a -t vnode -f can create a device node which uses the file",
12865
"%smount_cd9660 -o noexec,nosuid -s %%sbsector%% %%device%% %s",
12866
(flag & 1 ? "/sbin/" : ""), Text_shellsafe(cmd+8, sfe, 0));
12868
Not working on FreeBSD 7.2 according to Zsolt Kuti, 11 Oct 2009:
12869
"%smount -t cd9660 -o noexec,nosuid -o -s %%sbsector%% %%device%% %s",
12874
sprintf(session_text, "%d", session);
12875
sprintf(track_text, "%d", track);
12876
sprintf(lba_text, "%d", lba);
12877
vars[0][0]= "sbsector";
12878
vars[0][1]= lba_text;
12879
vars[1][0]= "track";
12880
vars[1][1]= track_text;
12881
vars[2][0]= "session";
12882
vars[2][1]= session_text;
12883
vars[3][0]= "volid";
12884
vars[3][1]= Text_shellsafe(volid, volid_sfe, 0);
12885
vars[4][0]= "device";
12886
vars[4][1]= Text_shellsafe(devadr, sfe, 0);
12887
ret= Sregex_resolve_var(form, vars, 5, "%", "%", "%", result, SfileadrL, 0);
12890
return(1 + is_safe);
12894
/* @param flag bit0= with adr_mode sbsector: adr_value is possibly 16 too high
12896
int Xorriso_decode_load_adr(struct XorrisO *xorriso, char *cmd,
12897
char *adr_mode, char *adr_value,
12898
int *entity_code, char entity_id[81],
12904
if(strcmp(adr_mode, "auto")==0)
12906
else if(strcmp(adr_mode, "session")==0)
12908
else if(strcmp(adr_mode, "track")==0)
12910
else if(strcmp(adr_mode, "lba")==0 || strcmp(adr_mode, "sbsector")==0)
12911
*entity_code= 3 | ((flag&1) << 16);
12912
else if(strcmp(adr_mode, "volid")==0)
12915
sprintf(xorriso->info_text, "%s: unknown address mode '%s'", cmd, adr_mode);
12916
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
12919
l= strlen(adr_value);
12923
if(*entity_code>=1 && *entity_code<= 3) {
12924
num= Scanf_io_size(adr_value, 0);
12925
if(*entity_code==3 &&
12926
(adr_value[l-1]<'0' || adr_value[l-1]>'9'))
12928
sprintf(entity_id, "%.f", num);
12930
if(strlen(adr_value)>80) {
12931
sprintf(xorriso->info_text, "%s: address value too long (80 < %d)",
12932
cmd, (int) strlen(adr_value));
12933
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
12936
strcpy(entity_id, adr_value);
12943
@param flag bit0= use env_path to find the desired program
12948
int Xorriso_execv(struct XorrisO *xorriso, char *cmd, char *env_path,
12949
int *status, int flag)
12952
char **argv= NULL, *pathlist= NULL, *cpt, *npt, prog[SfileadrL];
12953
char sfe[5*SfileadrL];
12957
wait3(NULL,WNOHANG,NULL); /* just to remove any old dead child */
12959
ret= Sfile_make_argv("", cmd, &argc, &argv, 1|4|128);
12965
strcpy(prog, argv[0]);
12966
if((flag & 1) && strchr(argv[0], '/') == NULL) {
12967
if(env_path == NULL)
12968
env_path= "/bin:/sbin";
12969
else if(env_path[0] == 0)
12970
env_path= "/bin:/sbin";
12971
if(Sregex_string(&pathlist, env_path, 0) <= 0)
12972
{ret= -1; goto ex;}
12973
for(cpt= npt= pathlist; npt != NULL; cpt= npt + 1) {
12974
npt= strchr(cpt, ':');
12977
if(strlen(cpt) + strlen(argv[0]) + 1 >= SfileadrL)
12978
{ret= -1; goto ex;}
12979
sprintf(prog, "%s/%s", cpt, argv[0]);
12980
ret= stat(prog, &stbuf);
12986
sprintf(xorriso->info_text, "Cannot find external program %s",
12987
Text_shellsafe(argv[0], sfe, 0));
12988
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
12998
/* this is the child process */
13000
sprintf(xorriso->info_text, "Executing external program %s",
13001
Text_shellsafe(prog, sfe, 0));
13002
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0);
13004
execv(prog, argv); /* should never come back */
13005
fprintf(stderr,"--- execution of shell command failed:\n");
13006
fprintf(stderr," %s\n",cmd);
13011
/* this is the original process waiting for child to exit */
13013
/* try to read and print the reply */;
13014
ret= waitpid(child_pid,status,WNOHANG);
13018
} else if(ret==0) {
13022
/* >>> An interrupt key would be nice. */
13025
ret= Asqueue_event_is_pending(agent->queue,0,0);
13027
Asagent_stderr(agent,"--- shell command interrupted",1);
13028
kill(child_pid,SIGTERM);
13041
Sfile_make_argv("", "", &argc, &argv, 2);
13042
Sregex_string(&pathlist, NULL, 0);
13047
/* Normalize ACL and sort apart "access" ACL from "default" ACL.
13049
int Xorriso_normalize_acl_text(struct XorrisO *xorriso, char *in_text,
13050
char **access_acl_text, char **default_acl_text, int flag)
13052
int ret, access_count= 0, default_count= 0, pass, is_default, line_len;
13053
int was_error= 0, line_count= 0, perms;
13054
char *acl_text= NULL, *cpt, *npt, *access_wpt= NULL, *default_wpt= NULL;
13055
char *dpt= NULL, *ddpt= NULL, **wpt, *ppt;
13057
if(in_text[0] == 0 || strcmp(in_text, "clear") == 0 ||
13058
strcmp(in_text, "--remove-all") == 0) {
13059
*access_acl_text= *default_acl_text= NULL;
13061
} else if (strcmp(in_text, "--remove-default") == 0) {
13063
/* >>> protect Access-ACL and delete Default-ACL */;
13070
acl_text= strdup(in_text);
13071
if(acl_text == NULL) {
13072
Xorriso_no_malloc_memory(xorriso, NULL, 0);
13073
{ret= -1; goto ex;}
13076
/* From comma to newline */
13077
for(cpt= strchr(acl_text, ','); cpt != NULL; cpt= strchr(cpt + 1, ','))
13080
/* Normalize to long text form
13081
and sort apart "access" ACL from "default" ACL */;
13082
for(pass= 0; pass < 2; pass++) {
13084
for(cpt= acl_text; cpt != NULL; cpt= npt) {
13086
npt= strchr(cpt, '\n');
13089
if(*cpt == '#' || *cpt == '\n' || *cpt == 0)
13098
cpt= strchr(cpt, ':');
13100
was_error= line_count;
13107
dpt= strchr(cpt, ':');
13109
ddpt= strchr(dpt + 1, ':');
13110
if(dpt == NULL || ddpt == NULL) {
13111
was_error= line_count;
13117
line_len+= ddpt - dpt;
13119
strcpy(*wpt, "user:");
13120
strncpy(*wpt + 5, dpt + 1, ddpt - dpt);
13121
(*wpt)+= 5 + (ddpt - dpt);
13123
} else if(*cpt == 'g') {
13125
line_len+= 6 + (ddpt - dpt);
13127
strcpy(*wpt, "group:");
13128
strncpy(*wpt + 6, dpt + 1, ddpt - dpt);
13129
(*wpt)+= 6 + (ddpt - dpt);
13131
} else if(*cpt == 'o') {
13133
if(ddpt - dpt > 1) {
13134
was_error= line_count;
13137
line_len+= 6 + (ddpt - dpt);
13139
strcpy(*wpt, "other:");
13140
strncpy(*wpt + 6, dpt + 1, ddpt - dpt);
13141
(*wpt)+= 6 + (ddpt - dpt);
13143
} else if(*cpt == 'm') {
13145
if(ddpt - dpt > 1) {
13146
was_error= line_count;
13149
line_len+= 5 + (ddpt - dpt);
13151
strcpy(*wpt, "mask:");
13152
strncpy(*wpt + 5, dpt + 1, ddpt - dpt);
13153
(*wpt)+= 5 + (ddpt - dpt);
13157
/* Unknown tag type */
13158
was_error= line_count;
13162
/* Examine permissions at ddpt + 1 */;
13164
for(ppt= ddpt + 1; *ppt != 0 && *ppt != '\n'; ppt++) {
13167
else if(*ppt == 'w')
13169
else if(*ppt == 'x')
13171
else if(*ppt == '-' || *ppt == ' ' || *ppt == '\t')
13173
else if(*ppt == '#')
13176
was_error= line_count;
13183
sprintf(*wpt, "%c%c%c\n",
13184
perms & 4 ? 'r' : '-', perms & 2 ? 'w' : '-', perms & 1 ? 'x' : '-');
13190
default_count+= line_len;
13192
access_count+= line_len;
13197
*access_acl_text= calloc(access_count + 1, 1);
13198
*default_acl_text= calloc(default_count + 1, 1);
13199
if(access_acl_text == NULL || *default_acl_text == NULL) {
13200
Xorriso_no_malloc_memory(xorriso, access_acl_text, 0);
13201
{ret= -1; goto ex;}
13203
access_wpt= *access_acl_text;
13204
default_wpt= *default_acl_text;
13213
if(acl_text != NULL)
13216
sprintf(xorriso->info_text,
13217
"Malformed ACL entries encountered. Last one in line number %d.",
13219
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
13226
int Xorriso_perform_acl_from_list(struct XorrisO *xorriso, char *file_path,
13227
char *uid, char *gid, char *acl, int flag)
13233
/* Set group and owner */
13235
ret= Xorriso_convert_gidstring(xorriso, gid, &gid_number, 0);
13238
ret= Xorriso_set_gid(xorriso, file_path, gid_number, 0);
13243
ret= Xorriso_convert_uidstring(xorriso, uid, &uid_number, 0);
13246
ret= Xorriso_set_uid(xorriso, file_path, uid_number, 0);
13250
ret= Xorriso_option_setfacli(xorriso, acl, 1, &file_path, &zero, 0);
13258
@param flag bit0= do not perform setfattr but only check input
13260
int Xorriso_path_setfattr(struct XorrisO *xorriso, void *in_node, char *path,
13261
char *name, size_t value_length, char *value, int flag)
13264
size_t num_attrs= 1;
13270
sprintf(xorriso->info_text,
13271
"-setfattr: Empty attribute name is not allowed");
13272
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
13274
} else if(strcmp(name, "--remove-all") == 0) {
13276
sprintf(xorriso->info_text,
13277
"-setfattr: Value is not empty with pseudo name --remove-all");
13278
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
13283
} else if(name[0] == '-') {
13286
} else if(name[0] == '=' || name[0] == '+') {
13291
ret= Xorriso_setfattr(xorriso, in_node, path,
13292
num_attrs, &name_pt, &value_length, &value, hflag);
13297
/* Warning: The text content of lst gets mangled by 0s and unescaping.
13299
int Xorriso_perform_attr_from_list(struct XorrisO *xorriso, char *path,
13300
struct Xorriso_lsT *lst_start, int flag)
13303
char *valuept, *ept, *line, **names= NULL, **values= NULL;
13304
size_t num_attr= 0, *value_lengths= NULL, v_len;
13305
struct Xorriso_lsT *lst;
13307
for(lst= lst_start; lst != NULL; lst= Xorriso_lst_get_next(lst, 0))
13309
if(num_attr == 0) {
13310
ret= Xorriso_setfattr(xorriso, NULL, path, num_attr, NULL, NULL, NULL, 0);
13314
names= calloc(num_attr, sizeof(char *));
13315
if(names == NULL) {
13316
Xorriso_no_malloc_memory(xorriso, NULL, 0);
13319
value_lengths= calloc(num_attr, sizeof(size_t));
13320
if(value_lengths== NULL) {
13322
Xorriso_no_malloc_memory(xorriso, NULL, 0);
13325
values= calloc(num_attr, sizeof(char *));
13326
if(values== NULL) {
13328
free(value_lengths);
13329
Xorriso_no_malloc_memory(xorriso, NULL, 0);
13334
for(lst= lst_start; lst != NULL; lst= Xorriso_lst_get_next(lst, 0)) {
13335
line= Xorriso_lst_get_text(lst, 0);
13336
ept= strchr(line, '=');
13339
/* Split into name and content */;
13343
/* Strip quotes from value */
13344
v_len= strlen(valuept);
13345
if(v_len < 2 || *valuept != '"' || *(valuept + v_len - 1) != '"')
13348
*(valuept + v_len - 1)= 0;
13352
/* Unescape backslashes , values eventually with 0-bytes */
13353
ret= Sfile_bsl_interpreter(line, strlen(line), &eaten, 0);
13356
ret= Sfile_bsl_interpreter(valuept, (int) v_len, &eaten, 2);
13360
names[num_attr]= line;
13361
values[num_attr]= valuept;
13362
value_lengths[num_attr]= v_len - eaten;
13365
ret= Xorriso_setfattr(xorriso, NULL, path, num_attr, names,
13366
value_lengths, values, 0);
13370
if(value_lengths != NULL)
13371
free(value_lengths);
13378
/* @param flag bit0= no hardlink reconstruction
13379
bit1= do not set xorriso->node_*_prefixes
13380
bit5= -extract_single: eventually do not insert directory tree
13382
int Xorriso_restore_sorted(struct XorrisO *xorriso, int count,
13383
char **src_array, char **tgt_array, int flag)
13385
int i, ret, with_node_array= 0, hflag= 0, hret;
13387
if(!(((xorriso->ino_behavior & 16) && xorriso->do_restore_sort_lba) ||
13388
(xorriso->ino_behavior & 4) || (flag & 1))) {
13389
ret= Xorriso_make_hln_array(xorriso, 0);
13393
if(xorriso->do_restore_sort_lba) {
13394
/* Count affected nodes */
13395
Xorriso_destroy_node_array(xorriso, 0);
13396
for(i= 0; i < count; i++) {
13397
if(src_array[i] == NULL || tgt_array[i] == NULL)
13399
/* sort_lba : Make directories plus node_array and then
13400
run array extractor (with eventual hardlink detection)
13402
hflag= (1 << 7) | ((!!(flag & 2)) << 9);
13403
ret= Xorriso_restore(xorriso, src_array[i], tgt_array[i],
13404
(off_t) 0, (off_t) 0, hflag);
13406
hret= Xorriso_eval_problem_status(xorriso, ret, 0);
13410
with_node_array= 1;
13414
if(with_node_array) {
13415
/* Allocate and fill node array */
13416
if(xorriso->node_counter <= 0)
13418
ret= Xorriso_new_node_array(xorriso, xorriso->temp_mem_limit, 0,
13419
!xorriso->do_restore_sort_lba);
13422
for(i= 0; i < count; i++) {
13423
if(src_array[i] == NULL || tgt_array[i] == NULL)
13425
ret= Xorriso_restore(xorriso, src_array[i], tgt_array[i],
13426
(off_t) 0, (off_t) 0, 2 << 7);
13428
hret= Xorriso_eval_problem_status(xorriso, ret, 0);
13435
/* Perform restore operations */
13436
if(xorriso->do_restore_sort_lba) {
13437
ret= Xorriso_restore_node_array(xorriso, 0);
13441
for(i= 0; i < count; i++) {
13442
if(src_array[i] == NULL || tgt_array[i] == NULL)
13444
ret= Xorriso_restore(xorriso, src_array[i], tgt_array[i],
13445
(off_t) 0, (off_t) 0, 0);
13447
hret= Xorriso_eval_problem_status(xorriso, ret, flag & 32);
13460
int Xorriso_report_md5_outcome(struct XorrisO *xorriso, char *severity,
13465
has_md5= Xorriso_image_has_md5(xorriso, 0);
13466
if(xorriso->find_check_md5_result & 1) {
13467
sprintf(xorriso->result_line,
13468
"Mismatch detected between file contents and MD5 checksums.\n");
13469
} else if(xorriso->find_check_md5_result & 8) {
13470
sprintf(xorriso->result_line,
13471
"File contents and their MD5 checksums match.\n");
13473
sprintf(xorriso->result_line,
13474
"Not a single file with MD5 checksum was found.");
13476
strcat(xorriso->result_line,
13477
" (There is no MD5 checksum array loaded.)\n");
13479
strcat(xorriso->result_line, "\n");
13481
Xorriso_result(xorriso,0);
13482
if(xorriso->find_check_md5_result & 2) {
13483
sprintf(xorriso->result_line,
13484
"Encountered errors other than non-match during MD5 checking.\n");
13485
Xorriso_result(xorriso,0);
13487
if((xorriso->find_check_md5_result & 4) && has_md5) {
13488
sprintf(xorriso->result_line,
13489
"There were data files which have no MD5 and thus could not be checked.\n");
13490
Xorriso_result(xorriso,0);
13492
if((xorriso->find_check_md5_result & 3) && strcmp(severity, "ALL") != 0) {
13493
sprintf(xorriso->info_text, "Event triggered by MD5 comparison mismatch");
13494
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, severity, 0);
13500
int Xorriso_append_scdbackup_record(struct XorrisO *xorriso, int flag)
13503
char dummy[81], name[81], timestamp[81], size[81], md5[81];
13505
if(xorriso->scdbackup_tag_written[0] == 0)
13508
name[0]= timestamp[0]= size[0]= md5[0]= 0;
13509
sscanf(xorriso->scdbackup_tag_written, "%s %s %s %s %s %s %s",
13510
dummy, dummy, dummy, name, timestamp, size, md5);
13511
sprintf(xorriso->info_text, "scdbackup tag written : %s %s %s %s\n",
13512
name, timestamp, size, md5);
13513
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
13515
if(xorriso->scdbackup_tag_listname[0]) {
13516
fp= fopen(xorriso->scdbackup_tag_listname, "a");
13518
strcpy(xorriso->info_text, "-scdbackup_tag: Cannot open file ");
13519
Text_shellsafe(xorriso->scdbackup_tag_listname, xorriso->info_text, 1);
13520
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
13523
fprintf(fp, "%s %s %s %s\n", name, timestamp, size, md5);
13530
int Xorriso_may_burn(struct XorrisO *xorriso, int flag)
13533
if(xorriso->outdev_is_exclusive)
13535
sprintf(xorriso->info_text, "The output drive was not aquired exclusively.");
13536
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
13537
sprintf(xorriso->info_text, "A possible remedy is: -osirrox 'o_excl_on'");
13538
if(xorriso->outdev[0]) {
13539
strcat(xorriso->info_text," -outdev ");
13540
Text_shellsafe(xorriso->outdev, xorriso->info_text, 1);
13542
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "HINT", 0);
13547
int Xorriso_check_name_len(struct XorrisO *xorriso, char *name, int size,
13548
char *cmd, int flag)
13550
if(strlen(name) >= size) {
13551
sprintf(xorriso->info_text,
13552
"Name too long with option %s (%d > %d)", cmd,
13553
(int) strlen(name), size - 1);
13554
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
13561
/* ---------------------------- Options API ------------------------ */
13564
/* Option -abort_on */
13565
int Xorriso_option_abort_on(struct XorrisO *xorriso, char *severity, int flag)
13568
char sfe[5*SfileadrL];
13570
ret= Xorriso__text_to_sev(severity, &sev, 0);
13572
sprintf(xorriso->info_text,
13573
"-abort_on: Not a known severity name : %s",
13574
Text_shellsafe(severity, sfe, 0));
13575
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
13578
if(Sfile_str(xorriso->abort_on_text,severity,0)<=0)
13580
xorriso->abort_on_severity= sev;
13581
Xorriso_set_abort_severity(xorriso, 0);
13586
/* Option -acl "on"|"off" */
13587
int Xorriso_option_acl(struct XorrisO *xorriso, char *mode, int flag)
13591
if(strcmp(mode, "off")==0)
13592
xorriso->do_aaip&= ~3;
13593
else if(strcmp(mode, "on")==0)
13594
xorriso->do_aaip|= (1 | 2);
13596
sprintf(xorriso->info_text, "-acl: unknown mode '%s'", mode);
13597
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
13600
ret= Xorriso_set_ignore_aclea(xorriso, 0);
13608
/* @param flag bit0=do not report the added item
13609
bit1=do not reset pacifier, no final pacifier message
13611
int Xorriso_option_add(struct XorrisO *xorriso, int argc, char **argv,
13612
int *idx, int flag)
13614
int i, end_idx, ret, was_failure= 0, fret, optc= 0, split;
13615
char target[SfileadrL], source[SfileadrL], *ept, eff_path[SfileadrL];
13616
char **optv= NULL, *rpt, *wpt;
13618
ret= Xorriso_opt_args(xorriso, "-add", argc, argv, *idx, &end_idx,
13619
&optc, &optv, ((!!xorriso->allow_graft_points)<<2)|2);
13624
Xorriso_pacifier_reset(xorriso, 0);
13625
for(i= 0; i<optc; i++) {
13626
if(Sfile_str(target,optv[i],0)<=0)
13627
{ret= -1; goto ex;}
13628
strcpy(source, optv[i]);
13630
if(xorriso->allow_graft_points) {
13631
ret= Fileliste__target_source_limit(target, '=', &ept, 0);
13634
strcpy(source, ept+1);
13642
for(; *rpt!=0; rpt++) {
13651
strcpy(target, source);
13652
} else if(target[0]!='/') {
13653
ret= Sfile_prepend_path(xorriso->wdi, target, 0);
13655
goto problem_handler;
13658
ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, target, eff_path, 2);
13660
goto problem_handler;
13661
strcpy(target, eff_path);
13662
ret= Xorriso_normalize_img_path(xorriso, xorriso->wdx, source,eff_path,2|4);
13664
goto problem_handler;
13665
strcpy(source, eff_path);
13667
ret= Xorriso_graft_in(xorriso, NULL, source, target, (off_t)0, (off_t)0, 0);
13668
if(ret<=0 || xorriso->request_to_abort)
13669
goto problem_handler;
13670
sprintf(xorriso->info_text, "Added to ISO image: %s '%s'='%s'\n",
13671
(ret>1 ? "directory" : "file"), (target[0] ? target : "/"), source);
13673
Xorriso_info(xorriso, 0);
13675
continue; /* regular bottom of loop */
13678
fret= Xorriso_eval_problem_status(xorriso, ret, 1|2);
13684
Xorriso_pacifier_callback(xorriso, "files added", xorriso->pacifier_count,
13685
xorriso->pacifier_total, "", 1);
13689
Xorriso_opt_args(xorriso, "-add", argc, argv, *idx, &end_idx, &optc, &optv,
13693
return(!was_failure);
13697
/* Option -add_plainly "none"|"unknown" */
13698
int Xorriso_option_add_plainly(struct XorrisO *xorriso, char *mode,int flag)
13700
if(strcmp(mode, "none")==0)
13701
xorriso->add_plainly= 0;
13702
if(strcmp(mode, "unknown")==0)
13703
xorriso->add_plainly= 1;
13704
else if(strcmp(mode, "dashed")==0)
13705
xorriso->add_plainly= 2;
13706
else if(strcmp(mode, "any")==0)
13707
xorriso->add_plainly= 3;
13709
sprintf(xorriso->info_text, "-add_plainly: unknown mode '%s'", mode);
13710
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
13717
/* Option -alter_date , -alter_date_r */
13718
/* @param flag bit0=recursive (-alter_date_r)
13720
int Xorriso_option_alter_date(struct XorrisO *xorriso,
13721
char *time_type, char *timestring,
13722
int argc, char **argv, int *idx, int flag)
13724
int i, ret, was_failure= 0, t_type= 0, end_idx, fret;
13728
struct FindjoB *job= NULL;
13729
struct stat dir_stbuf;
13731
ret= Xorriso_opt_args(xorriso, "-alter_date", argc, argv, *idx, &end_idx,
13735
ret= Xorriso_convert_datestring(xorriso, "-alter_date", time_type, timestring,
13739
for(i= 0; i<optc; i++) {
13741
ret= Findjob_new(&job, optv[i], 0);
13743
Xorriso_no_findjob(xorriso, "-alter_date", 0);
13744
{ret= -1; goto ex;}
13746
Findjob_set_action_ad(job, t_type, t, 0);
13747
ret= Xorriso_findi(xorriso, job, NULL, (off_t) 0,
13748
NULL, optv[i], &dir_stbuf, 0, 0);
13749
Findjob_destroy(&job, 0);
13751
ret= Xorriso_set_time(xorriso, optv[i], t, t_type);
13752
if(ret>0 && !xorriso->request_to_abort)
13753
continue; /* regular bottom of loop */
13755
fret= Xorriso_eval_problem_status(xorriso, ret, 1|2);
13763
Xorriso_opt_args(xorriso, "-alter_date", argc, argv, *idx, &end_idx, &optc,
13765
Findjob_destroy(&job, 0);
13768
return(!was_failure);
13772
/* Option -application_id */
13773
int Xorriso_option_application_id(struct XorrisO *xorriso, char *name,
13776
if(Xorriso_check_name_len(xorriso, name,
13777
(int) sizeof(xorriso->application_id),
13778
"-application_id", 0) <= 0)
13780
strcpy(xorriso->application_id,name);
13781
Xorriso_set_change_pending(xorriso, 1);
13787
/* @param flag bit0=do not report the added item
13788
bit1=do not reset pacifier, no final pacifier message
13790
int Xorriso_option_as(struct XorrisO *xorriso, int argc, char **argv,
13791
int *idx, int flag)
13793
int end_idx, ret, idx_count;
13795
end_idx= Xorriso_end_idx(xorriso, argc, argv, *idx, 1);
13796
idx_count= end_idx-(*idx);
13797
if(end_idx<=0 || (*idx)>=argc) {
13799
sprintf(xorriso->info_text,
13800
"-as : Not enough arguments given. Needed: whom do_what %s",
13801
xorriso->list_delimiter);
13803
sprintf(xorriso->info_text,
13804
"-as %s : Not enough arguments given. Needed: do_what %s",
13805
argv[*idx], xorriso->list_delimiter);
13806
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
13809
if(strcmp(argv[*idx], "cdrecord")==0 || strcmp(argv[*idx], "wodim")==0 ||
13810
strcmp(argv[*idx], "cdrskin")==0 || strcmp(argv[*idx], "xorrecord")==0) {
13811
ret= Xorriso_cdrskin(xorriso, argv[*idx], end_idx-(*idx)-1, argv+(*idx)+1,
13815
} else if(strcmp(argv[*idx], "mkisofs")==0 ||
13816
strcmp(argv[*idx], "genisoimage")==0 ||
13817
strcmp(argv[*idx], "genisofs")==0 ||
13818
strcmp(argv[*idx], "xorrisofs")==0) {
13819
ret= Xorriso_genisofs(xorriso, argv[*idx], end_idx-(*idx)-1, argv+(*idx)+1,
13824
sprintf(xorriso->info_text,
13825
"-as : Not a known emulation personality: '%s'", argv[*idx]);
13826
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
13837
/* Option -assert_volid */
13838
int Xorriso_option_assert_volid(struct XorrisO *xorriso, char *pattern,
13839
char *severity, int flag)
13842
char *sev_text= "";
13844
if(strlen(pattern)>=sizeof(xorriso->assert_volid)) {
13845
sprintf(xorriso->info_text,
13846
"Name too long with option -application_id (%d > %d)",
13847
(int) strlen(pattern), (int) sizeof(xorriso->assert_volid)-1);
13848
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
13852
ret= Sregex_match(pattern, "", 1);
13854
sprintf(xorriso->info_text, "-assert_volid: Cannot use given pattern.");
13855
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
13859
if(severity[0] != 0 || pattern[0] != 0) {
13860
if(severity[0] == 0)
13861
sev_text= xorriso->abort_on_text;
13863
sev_text= severity;
13864
if(strcmp(sev_text, "NEVER") == 0)
13866
ret= Xorriso__text_to_sev(sev_text, &sev, 0);
13868
sprintf(xorriso->info_text, "-assert_volid: Not a known severity name : ");
13869
Text_shellsafe(severity, xorriso->info_text, 1);
13870
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
13874
if(Sfile_str(xorriso->assert_volid, pattern,0) <= 0)
13876
strcpy(xorriso->assert_volid_sev, sev_text);
13881
/* Option -auto_charset "on"|"off" */
13882
int Xorriso_option_auto_charset(struct XorrisO *xorriso, char *mode, int flag)
13884
if(strcmp(mode, "off")==0)
13885
xorriso->do_aaip&= ~(256 | 512);
13886
else if(strcmp(mode, "on")==0)
13887
xorriso->do_aaip|= (256 | 512);
13889
sprintf(xorriso->info_text, "-auto_charset: unknown mode '%s'", mode);
13890
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
13897
/* Option -backslash_codes */
13898
int Xorriso_option_backslash_codes(struct XorrisO *xorriso, char *mode,
13904
was= xorriso->bsl_interpretation;
13905
xorriso->bsl_interpretation= 0;
13907
for(; npt!=NULL; cpt= npt+1) {
13908
npt= strchr(cpt,':');
13915
if(l == 3 && strncmp(cpt, "off", l)==0) {
13916
xorriso->bsl_interpretation= 0;
13917
} else if(l == 16 && strncmp(cpt, "in_double_quotes", l)==0) {
13918
xorriso->bsl_interpretation= (xorriso->bsl_interpretation & ~3) | 1;
13919
} else if(l == 9 && strncmp(cpt, "in_quotes", l)==0) {
13920
xorriso->bsl_interpretation= (xorriso->bsl_interpretation & ~3) | 2;
13921
} else if(l == 17 && strncmp(cpt, "with_quoted_input", l)==0) {
13922
xorriso->bsl_interpretation= (xorriso->bsl_interpretation & ~3) | 3;
13923
} else if(l == 22 && strncmp(cpt, "with_program_arguments", l)==0) {
13924
xorriso->bsl_interpretation= xorriso->bsl_interpretation | 16;
13925
} else if(l == 13 && strncmp(cpt, "encode_output", l)==0) {
13926
xorriso->bsl_interpretation= xorriso->bsl_interpretation | 32 | 64;
13927
} else if(l == 14 && strncmp(cpt, "encode_results", l)==0) {
13928
xorriso->bsl_interpretation= xorriso->bsl_interpretation | 32;
13929
} else if(l == 12 && strncmp(cpt, "encode_infos", l)==0) {
13930
xorriso->bsl_interpretation= xorriso->bsl_interpretation | 64;
13931
} else if(l == 2 && strncmp(cpt, "on", l)==0) {
13932
xorriso->bsl_interpretation= 3 | 16 | 32 | 64;
13935
sprintf(xorriso->info_text, "-backslash_codes: unknown mode '%s'", cpt);
13937
sprintf(xorriso->info_text,
13938
"-backslash_codes: oversized mode parameter (%d)", l);
13939
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
13940
xorriso->bsl_interpretation= was;
13948
/* Option -ban_stdio_write */
13949
int Xorriso_option_ban_stdio_write(struct XorrisO *xorriso, int flag)
13951
xorriso->ban_stdio_write= 1;
13956
/* Option -blank and -format */
13957
/* @param flag bit0= format rather than blank
13958
@return <=0 error , 1 success, 2 revoked by -reassure
13960
int Xorriso_option_blank(struct XorrisO *xorriso, char *mode, int flag)
13962
char drive_name[SfileadrL], *cmd= "-blank";
13963
int aq_ret, ret, aq_flag= 2, mode_flag= 0, as_needed= 0, idx;
13968
if(xorriso->out_drive_handle == NULL) {
13969
sprintf(xorriso->info_text,
13970
"%s: No output drive set by -dev -or -outdev", cmd);
13971
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
13974
if(xorriso->in_drive_handle == xorriso->out_drive_handle) {
13975
if(xorriso->volset_change_pending) {
13976
sprintf(xorriso->info_text,
13977
"%s: Image changes pending. -commit or -rollback first.", cmd);
13978
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
13983
ret= Xorriso_reassure(xorriso, cmd,
13984
"possibly make unreadable data on outdev", 0);
13988
if(strcmp(mode, "as_needed")==0 || mode[0]==0)
13990
else if(strcmp(mode, "all")==0 || strcmp(mode, "full")==0)
13992
else if((strcmp(mode, "deformat")==0 ||
13993
strcmp(mode, "deformat_sequential")==0) && !(flag&1))
13995
else if((strcmp(mode, "deformat_quickest")==0 ||
13996
strcmp(mode, "deformat_sequential_quickest")==0) && !(flag&1))
13998
else if(strcmp(mode, "fast")==0)
14000
else if(strncmp(mode, "by_index_", 9)==0 && (flag&1)) {
14004
sscanf(mode+9, "%d", &idx);
14005
if(idx<0 || idx>255) {
14007
sprintf(xorriso->info_text,
14008
"-format: mode '%s' provides unusable index number", mode);
14009
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
14012
mode_flag|= (idx<<8);
14013
} else if(strncmp(mode, "fast_by_index_", 14)==0 && (flag&1)) {
14014
mode_flag= 1 | 128;
14016
if(strlen(mode)>14)
14017
sscanf(mode+14, "%d", &idx);
14018
if(idx<0 || idx>255)
14019
goto unusable_index;
14020
mode_flag|= (idx<<8);
14021
} else if(strncmp(mode, "by_size_", 8) == 0 && (flag & 1)) {
14022
size= (off_t) Scanf_io_size(mode + 8, 0);
14025
sprintf(xorriso->info_text,
14026
"-format: mode '%s' provides unusable size value", mode);
14027
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
14031
} else if(strncmp(mode, "fast_by_size_", 13) == 0 && (flag & 1)) {
14032
size= (off_t) Scanf_io_size(mode + 13, 0);
14034
goto unusable_size;
14037
sprintf(xorriso->info_text,
14038
"%s: Unknown %s mode '%s'",
14039
cmd, ((flag&1) ? "-format" : "-blank"), mode);
14040
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
14044
ret= Xorriso_blank_as_needed(xorriso, (flag&1)<<2);
14046
ret= Xorriso_format_media(xorriso, size, mode_flag & 0xff83);
14048
ret= Xorriso_blank_media(xorriso, mode_flag&3);
14051
strcpy(drive_name, xorriso->outdev);
14052
if(ret <= 0) { /* in case of success, above functions will have re-aquired */
14053
aq_ret= Xorriso_reaquire_outdev(xorriso, 0); /* actually give up drive */
14063
/* Option -boot_image */
14064
int Xorriso_option_boot_image(struct XorrisO *xorriso, char *form,
14065
char *treatment, int flag)
14067
int was_ok= 1, ret, isolinux_grub= 0, count;
14069
char *formpt, *treatpt;
14075
treatpt= treatment;
14076
if(treatpt[0]=='-')
14079
if(strcmp(formpt, "isolinux")==0 || strcmp(formpt, "grub") == 0)
14081
if(strcmp(treatpt, "keep")==0) {
14082
if(xorriso->boot_count > 0) {
14083
cannot_keep_or_patch:;
14084
sprintf(xorriso->info_text,
14085
"Loaded boot image has already been replaced. Cannot keep or patch it.");
14086
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
14090
goto treatment_patch;
14091
xorriso->keep_boot_image= 1;
14092
xorriso->patch_isolinux_image= 0;
14093
xorriso->boot_image_bin_path[0]= 0;
14094
xorriso->patch_system_area= 0;
14096
} else if(strcmp(treatpt, "patch")==0) {
14098
if(xorriso->boot_count > 0)
14099
goto cannot_keep_or_patch;
14100
xorriso->keep_boot_image= 0;
14101
xorriso->patch_isolinux_image= 1;
14102
xorriso->boot_image_bin_path[0]= 0;
14103
if(strcmp(formpt, "grub") == 0) {
14104
xorriso->patch_isolinux_image|= 2;
14105
xorriso->patch_system_area= 1;
14106
} else if(strcmp(formpt, "isolinux") == 0)
14107
xorriso->patch_system_area= 2;
14109
xorriso->patch_system_area= 0;
14111
} else if(strcmp(treatpt, "discard")==0) {
14112
xorriso->keep_boot_image= 0;
14113
xorriso->patch_isolinux_image= 0;
14114
xorriso->boot_image_bin_path[0]= 0;
14115
xorriso->patch_system_area= 0;
14116
if(xorriso->boot_count > 0) {
14117
ret= Xorriso_attach_boot_image(xorriso, 2); /* dispose boot images */
14122
} else if(strcmp(treatpt, "next") == 0) {
14123
ret= Xorriso_attach_boot_image(xorriso, 0);
14127
} else if(strcmp(treatpt, "show_status")==0) {
14128
sprintf(xorriso->result_line, "------------------------------------\n");
14129
Xorriso_result(xorriso, 0);
14130
sprintf(xorriso->result_line, "Status of loaded boot image :\n");
14131
Xorriso_result(xorriso, 0);
14132
sprintf(xorriso->result_line, "------------------------------------\n");
14133
Xorriso_result(xorriso, 0);
14134
Xorriso_show_boot_info(xorriso, 0);
14135
sprintf(xorriso->result_line, "------------------------------------\n");
14136
Xorriso_result(xorriso, 0);
14137
sprintf(xorriso->result_line, "Boot image settings for next commit:\n");
14138
Xorriso_result(xorriso, 0);
14139
sprintf(xorriso->result_line, "------------------------------------\n");
14140
Xorriso_result(xorriso, 0);
14141
Xorriso_status(xorriso, "-boot_image", NULL, 0);
14142
sprintf(xorriso->result_line, "------------------------------------\n");
14143
Xorriso_result(xorriso, 0);
14145
} else if(strcmp(treatpt, "cat_path=") == 0) {
14146
xorriso->boot_image_cat_path[0] = 0;
14147
} else if(strncmp(treatpt, "cat_path=", 9) == 0) {
14148
ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, treatpt + 9,
14149
xorriso->boot_image_cat_path, 2);
14153
} else if(strncmp(treatpt, "dir=", 4) == 0) {
14154
if(strcmp(formpt, "isolinux")==0) {
14156
/* The three locations mentioned in http://syslinux.zytor.com/iso.php */
14157
if(strcmp(treatpt + 4, "/") == 0)
14158
strcpy(xorriso->boot_image_bin_path, "/");
14159
else if(strcmp(treatpt + 4, "isolinux") == 0
14160
|| strcmp(treatpt + 4, "/isolinux") == 0)
14161
strcpy(xorriso->boot_image_bin_path, "/isolinux/");
14162
else if(strcmp(treatpt + 4, "boot/isolinux") == 0
14163
|| strcmp(treatpt + 4, "/boot/isolinux") == 0
14164
|| strcmp(treatpt + 4, "boot") == 0
14165
|| strcmp(treatpt + 4, "/boot") == 0)
14166
strcpy(xorriso->boot_image_bin_path, "/boot/isolinux/");
14168
sprintf(xorriso->info_text,
14169
"Unrecognized keyword with -boot_image %s %s",
14171
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
14172
sprintf(xorriso->info_text,
14173
"Allowed with dir= are / , /isolinux . /boot/isolinux");
14174
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "HINT", 0);
14177
strcpy(xorriso->boot_image_cat_path, xorriso->boot_image_bin_path);
14178
strcat(xorriso->boot_image_bin_path, "isolinux.bin");
14179
strcat(xorriso->boot_image_cat_path, "boot.cat");
14180
xorriso->boot_image_load_size= 4 * 512;
14181
xorriso->keep_boot_image= 0;
14182
xorriso->patch_isolinux_image= 1;
14183
strcpy(xorriso->boot_image_bin_form, formpt);
14186
} else if(strcmp(formpt, "grub") == 0) {
14191
strcpy(xorriso->boot_image_bin_form, formpt);
14196
} else if(strcmp(treatpt, "bin_path=") == 0) {
14197
xorriso->boot_image_bin_path[0] = 0;
14198
xorriso->boot_efi_default= 0;
14199
} else if(strncmp(treatpt, "bin_path=", 9) == 0) {
14200
ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, treatpt + 9,
14201
xorriso->boot_image_bin_path, 2);
14204
xorriso->keep_boot_image= 0;
14205
if(isolinux_grub) {
14206
xorriso->patch_isolinux_image= 1;
14207
if(xorriso->boot_image_bin_path[0])
14208
xorriso->boot_image_load_size= 4 * 512;
14209
strcpy(xorriso->boot_image_bin_form, formpt);
14211
strcpy(xorriso->boot_image_bin_form, "any");
14212
xorriso->boot_efi_default= 0;
14214
#ifdef Xorriso_multi_booT
14216
} else if(strcmp(treatpt, "efi_path=") == 0) {
14217
xorriso->boot_image_bin_path[0] = 0;
14218
xorriso->boot_efi_default= 0;
14219
} else if(strncmp(treatpt, "efi_path=", 9) == 0) {
14220
ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, treatpt + 9,
14221
xorriso->boot_image_bin_path, 2);
14225
} else if(strcmp(treatpt, "efi_path=") == 0) {
14226
xorriso->boot_image_efi_path[0] = 0;
14227
} else if(strncmp(treatpt, "efi_path=", 9) == 0) {
14228
ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, treatpt + 9,
14229
xorriso->boot_image_efi_path, 2);
14231
#endif /* ! Xorriso_multi_booT */
14235
xorriso->keep_boot_image= 0;
14236
xorriso->boot_efi_default= 1;
14238
} else if(strncmp(treatpt, "boot_info_table=", 16)==0) {
14239
if(strcmp(treatpt + 16, "off") == 0)
14240
xorriso->patch_isolinux_image= 0;
14241
else if(strcmp(treatpt + 16, "on") == 0)
14242
xorriso->patch_isolinux_image= 1 | (2 * (strcmp(treatpt, "grub") == 0));
14246
} else if(strncmp(treatpt, "load_size=", 10) == 0) {
14247
num= Scanf_io_size(treatpt + 10, 0);
14248
if(num < 512 && isolinux_grub) {
14249
sprintf(xorriso->info_text,
14250
"-boot_image %s : load_size too small (%s < 512)",
14251
formpt, treatpt + 10);
14252
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
14255
xorriso->boot_image_load_size= num;
14257
} else if(strncmp(treatpt, "id_string=", 10) == 0) {
14258
memset(xorriso->boot_id_string, 0, 29);
14259
if(strlen(treatpt + 10) == 56) {
14260
ret= Hex_to_bin(treatpt + 10, 28, &count, xorriso->boot_id_string, 0);
14264
strncpy((char *) xorriso->boot_id_string, treatpt + 10, 28);
14266
} else if(strncmp(treatpt, "sel_crit=", 9) == 0) {
14267
memset(xorriso->boot_selection_crit, 0, 21);
14269
ret= Hex_to_bin(treatpt + 9, 20, &count, xorriso->boot_selection_crit, 0);
14271
sprintf(xorriso->info_text,
14272
"-boot_image %s sel_crit= : Wrong form. Need even number of hex digits.",
14274
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
14278
} else if(strncmp(treatpt, "system_area=", 12) == 0) {
14279
ret= Xorriso_set_system_area_path(xorriso, treatpt + 12, 0);
14282
if(strcmp(formpt, "isolinux")==0)
14283
xorriso->system_area_options= (xorriso->system_area_options & ~3) | 2;
14285
} else if(strncmp(treatpt, "partition_table=", 16)==0) {
14286
if(strcmp(treatpt + 16, "off") == 0) {
14287
xorriso->system_area_options&= ~3;
14288
xorriso->patch_system_area= xorriso->system_area_options;
14289
} else if(strcmp(treatpt + 16, "on") == 0) {
14290
xorriso->system_area_options&= ~3;
14291
if(strcmp(formpt, "isolinux")==0)
14292
xorriso->system_area_options|= 2;
14294
xorriso->system_area_options|= 1;
14295
xorriso->patch_system_area= xorriso->system_area_options;
14299
} else if(strncmp(treatpt, "platform_id=", 12)==0) {
14300
if(strncmp(treatpt + 12, "0x", 2) == 0)
14301
sscanf(treatpt + 14, "%x", &u);
14303
sscanf(treatpt + 12, "%u", &u);
14305
sprintf(xorriso->info_text,
14306
"-boot_image %s : platform_id too large (%s > 0xff)",
14307
formpt, treatpt + 12);
14308
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
14311
xorriso->boot_platform_id= u;
14313
} else if(strncmp(treatpt, "isohybrid=", 10) == 0 &&
14314
strcmp(formpt, "isolinux")==0) {
14316
#ifdef Xorriso_with_isohybriD
14318
if(strcmp(treatpt + 10, "off") == 0)
14319
xorriso->boot_image_isohybrid= 0;
14320
else if(strcmp(treatpt + 10, "auto") == 0)
14321
xorriso->boot_image_isohybrid= 1;
14322
else if(strcmp(treatpt + 10, "on") == 0)
14323
xorriso->boot_image_isohybrid= 2;
14324
else if(strcmp(treatpt + 10, "force") == 0)
14325
xorriso->boot_image_isohybrid= 3;
14327
sprintf(xorriso->info_text,
14328
"Unrecognized keyword with -boot_image %s %s",
14330
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
14331
sprintf(xorriso->info_text,
14332
"Allowed with isohybrid= are: off , auto , on , force");
14333
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "HINT", 0);
14339
if(strcmp(treatpt + 10, "off") == 0) {
14340
xorriso->boot_image_isohybrid= 0;
14342
sprintf(xorriso->info_text,
14343
"isohybrid MBR generation has been disabled on request of its inventor H. Peter Anvin on 31 Mar 2010");
14344
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
14345
sprintf(xorriso->info_text,
14346
"It has been replaced by -boot_image isolinux system_area=External-File");
14347
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "HINT", 0);
14350
#endif /* ! Xorriso_with_isohybriD */
14356
sprintf(xorriso->info_text, "Unrecognized options with -boot_image: %s %s",
14358
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
14365
/* Option -calm_drive */
14366
int Xorriso_option_calm_drive(struct XorrisO *xorriso, char *which, int flag)
14368
int gu_flag= 0, ret;
14370
if(strcmp(which,"in")==0)
14372
else if(strcmp(which,"out")==0)
14374
else if(strcmp(which,"on")==0) {
14375
xorriso->do_calm_drive|= 1;
14376
} else if(strcmp(which,"off")==0) {
14377
xorriso->do_calm_drive&= ~1;
14378
} else if(strcmp(which,"revoke")==0) {
14382
ret= Xorriso_drive_snooze(xorriso, gu_flag);
14387
/* Option -cd alias -cdi */
14388
int Xorriso_option_cdi(struct XorrisO *xorriso, char *iso_rr_path, int flag)
14390
char sfe[5*SfileadrL], path[SfileadrL], eff_path[SfileadrL];
14393
if (strlen(iso_rr_path)>sizeof(xorriso->wdi)) {
14394
sprintf(xorriso->info_text,"-cdi: iso_rr_path too long (%d > %d)",
14395
(int) strlen(iso_rr_path), (int) sizeof(xorriso->wdi)-1);
14396
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
14399
Xorriso_warn_of_wildcards(xorriso, iso_rr_path, 1);
14400
sprintf(xorriso->info_text,"previous working directory:\n");
14401
Xorriso_info(xorriso,0);
14402
sprintf(xorriso->result_line,"%s/\n",Text_shellsafe(xorriso->wdi, sfe, 0));
14403
Xorriso_result(xorriso,0);
14404
if(strcmp(iso_rr_path,"/")==0 || iso_rr_path[0]==0) {
14405
strcpy(xorriso->wdi,"");
14406
Xorriso_option_pwdi(xorriso, 0);
14408
} else if(iso_rr_path[0]!='/') {
14409
strcpy(path, xorriso->wdi);
14410
if(Sfile_add_to_path(path,iso_rr_path,0)<=0)
14413
if(Sfile_str(path,iso_rr_path,0)<=0)
14417
ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, path, eff_path, 1);
14421
sprintf(xorriso->info_text, "-cdi: not existing yet in ISO image : %s",
14422
Text_shellsafe(path, sfe, 0));
14423
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0);
14424
ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, path, eff_path, 2);
14427
} else if(ret!=2) {
14428
sprintf(xorriso->info_text, "-cdi: not a directory : %s",
14429
Text_shellsafe(eff_path, sfe, 0));
14430
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
14433
strcpy(xorriso->wdi, eff_path);
14435
Xorriso_option_pwdi(xorriso, 0);
14441
int Xorriso_option_cdx(struct XorrisO *xorriso, char *disk_path, int flag)
14443
char sfe[5*SfileadrL], path[SfileadrL], eff_path[SfileadrL];
14446
if (strlen(disk_path)>sizeof(xorriso->wdx)) {
14447
sprintf(xorriso->info_text,"-cdx: disk_path too long (%d > %d)",
14448
(int) strlen(disk_path), (int) sizeof(xorriso->wdx)-1);
14449
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
14452
Xorriso_warn_of_wildcards(xorriso, disk_path, 1|2);
14453
sprintf(xorriso->info_text,"previous working directory on hard disk:\n");
14454
Xorriso_info(xorriso,0);
14455
sprintf(xorriso->result_line,"%s/\n",Text_shellsafe(xorriso->wdx, sfe, 0));
14456
Xorriso_result(xorriso,0);
14457
if(strcmp(disk_path,"/")==0) {
14458
strcpy(xorriso->wdx,"");
14459
Xorriso_option_pwdx(xorriso, 0);
14461
} else if(disk_path[0]!='/') {
14462
strcpy(path, xorriso->wdx);
14463
if(Sfile_add_to_path(path,disk_path,0)<=0)
14466
if(Sfile_str(path,disk_path,0)<=0)
14470
ret= Xorriso_normalize_img_path(xorriso, xorriso->wdx, path, eff_path, 2|4);
14474
ret= Sfile_type(eff_path,1|4|8);
14476
Xorriso_msgs_submit(xorriso, 0, eff_path, 0, "ERRFILE", 0);
14477
sprintf(xorriso->info_text,"-cdx: file not found : %s",
14478
Text_shellsafe(eff_path, sfe, 0));
14479
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
14483
Xorriso_msgs_submit(xorriso, 0, eff_path, 0, "ERRFILE", 0);
14484
sprintf(xorriso->info_text,
14485
"-cdx: not a directory : %s",
14486
Text_shellsafe(eff_path, sfe, 0));
14487
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
14491
if(Sfile_str(xorriso->wdx,eff_path,0)<=0)
14493
Xorriso_option_pwdx(xorriso, 0);
14498
/* Option -charset */
14499
/* @param flag bit0= set in_charset
14500
bit1= set out_charset
14501
bit2= set local_charset
14503
int Xorriso_option_charset(struct XorrisO *xorriso, char *name, int flag)
14506
char *name_pt= NULL, sfe[5 * SfileadrL], *local_charset;
14507
iconv_t iconv_ret= (iconv_t) -1;
14513
ret= Xorriso_set_local_charset(xorriso, name_pt, 0);
14518
if(name_pt != NULL) {
14519
Xorriso_get_local_charset(xorriso, &local_charset, 0);
14520
iconv_ret= iconv_open(local_charset, name_pt);
14521
if(iconv_ret == (iconv_t) -1) {
14522
sprintf(xorriso->info_text,
14523
"-%scharset: Cannot convert from character set %s",
14524
flag & 2 ? "" : "in_", Text_shellsafe(name_pt, sfe, 0));
14525
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE",
14529
iconv_close(iconv_ret);
14531
if(Sregex_string(&(xorriso->in_charset), name_pt, 0) <= 0) {
14532
Xorriso_no_malloc_memory(xorriso, NULL, 0);
14537
if(name_pt != NULL) {
14538
Xorriso_get_local_charset(xorriso, &local_charset, 0);
14539
iconv_ret= iconv_open(local_charset, name_pt);
14540
if(iconv_ret == (iconv_t) -1) {
14541
sprintf(xorriso->info_text, "-%scharset: Cannot convert to charset %s",
14542
flag & 1 ? "" : "out_", Text_shellsafe(name_pt, sfe, 0));
14543
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE",
14547
iconv_close(iconv_ret);
14549
if(Sregex_string(&(xorriso->out_charset), name_pt, 0) <= 0) {
14550
Xorriso_no_malloc_memory(xorriso, NULL, 0);
14555
if(name_pt == NULL)
14556
Xorriso_get_local_charset(xorriso, &name_pt, 0);
14557
sprintf(xorriso->info_text, "Character set for %sconversion is now: %s",
14558
(flag & 3) == 1 ? "input " : (flag & 3) == 2 ? "output " : "",
14559
Text_shellsafe(name_pt, sfe, 0));
14560
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
14566
/* Options -check_md5 and -check_md5_r
14567
@param flag bit0= issue summary message
14568
bit1= do not reset pacifier, no final pacifier message
14569
>>> bit2= do not issue pacifier messages at all
14570
bit3= recursive: -check_md5_r
14572
int Xorriso_option_check_md5(struct XorrisO *xorriso,
14573
int argc, char **argv, int *idx, int flag)
14575
int ret, i, mem_pci, end_idx, fret, sev, do_report= 0;
14577
char **optv= NULL, *cpt, *severity= "ALL";
14578
struct FindjoB *job= NULL;
14579
double mem_lut= 0.0;
14581
mem_pci= xorriso->pacifier_interval;
14583
ret= Xorriso_opt_args(xorriso, "-check_md5", argc, argv, *idx + 1,
14584
&end_idx, &optc, &optv, 128);
14588
/* Interpret argv[*idx] as severity */
14590
sprintf(xorriso->info_text,
14591
"-check_md5: No event severity given for case of mismatch");
14592
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
14595
severity= argv[*idx];
14596
ret= Xorriso__text_to_sev(severity, &sev, 0);
14598
sprintf(xorriso->info_text, "-check_md5: Not a known severity name : ");
14599
Text_shellsafe(severity, xorriso->info_text, 1);
14600
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
14604
if(!(flag & (2 | 4))) {
14605
Xorriso_pacifier_reset(xorriso, 0);
14606
mem_lut= xorriso->last_update_time;
14608
xorriso->pacifier_interval= 5.0;
14610
xorriso->find_check_md5_result= 0;
14613
ret= Xorriso_check_session_md5(xorriso, severity, 0);
14618
for(i= 0; i < optc; i++) {
14620
ret= Findjob_new(&job, optv[i], 0);
14622
Xorriso_no_findjob(xorriso, "-check_md5_r", 0);
14623
{ret= -1; goto ex;}
14625
Findjob_set_action_target(job, 35, severity, 0);
14627
ret= Xorriso_findi_sorted(xorriso, job, (off_t) 0, 1, &cpt, 0);
14628
Findjob_destroy(&job, 0);
14630
ret= xorriso->find_compare_result;
14633
xorriso->find_check_md5_result|= 2;
14636
ret= Xorriso_check_md5(xorriso, NULL, optv[i], 4);
14638
xorriso->find_check_md5_result|= 2;
14640
xorriso->find_check_md5_result|= 1;
14642
xorriso->find_check_md5_result|= 8;
14644
xorriso->find_check_md5_result|= 4;
14646
if(ret>0 && !xorriso->request_to_abort)
14647
continue; /* regular bottom of loop */
14648
fret= Xorriso_eval_problem_status(xorriso, ret, 1|2);
14651
ret= 0; goto report_outcome;
14659
if(!(flag & (2 | 4))) {
14660
xorriso->pacifier_interval= mem_pci;
14661
if(mem_lut!=xorriso->last_update_time && !(flag&2))
14662
Xorriso_pacifier_callback(xorriso, "content bytes read",
14663
xorriso->pacifier_count, 0, "", 1);
14668
sprintf(xorriso->result_line,
14669
"MD5 MISMATCH WITH DATA OF LOADED SESSION !\n");
14670
Xorriso_result(xorriso,0);
14671
if(strcmp(severity, "ALL") != 0) {
14672
sprintf(xorriso->info_text,
14673
"Event triggered by MD5 comparison mismatch");
14674
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, severity, 0);
14677
sprintf(xorriso->result_line, "Ok, session data match recorded md5.\n");
14678
Xorriso_result(xorriso,0);
14681
Xorriso_report_md5_outcome(xorriso, severity, 0);
14685
Xorriso_opt_args(xorriso, "-getfacl", argc, argv, *idx, &end_idx,
14686
&optc, &optv, 256);
14687
Findjob_destroy(&job, 0);
14690
return((xorriso->find_check_md5_result & 3) == 0);
14694
/* Option -check_media */
14695
int Xorriso_option_check_media(struct XorrisO *xorriso,
14696
int argc, char **argv, int *idx, int flag)
14698
int ret, i, count, lba, blocks, quality, pass, was_md5= 0, was_event= 0;
14699
int end_idx, old_idx, os_errno;
14700
char quality_name[80], head_buffer[64*1024];
14701
struct SpotlisT *spotlist= NULL;
14702
struct CheckmediajoB *job= NULL;
14703
struct FindjoB *findjob= NULL;
14704
struct stat dir_stbuf;
14707
end_idx= Xorriso_end_idx(xorriso, argc, argv, *idx, 1);
14710
ret= Checkmediajob_new(&job, 0);
14713
ret= Xorriso_check_media_setup_job(xorriso, job, argv, old_idx, end_idx, 0);
14717
if((job->report_mode == 1 || job->report_mode == 2) && job->use_dev == 1) {
14718
sprintf(xorriso->info_text,
14719
"-check_media: cannot report=*files while use=outdef");
14720
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
14723
if(job->patch_lba0 && job->data_to_path[0] == 0) {
14724
sprintf(xorriso->info_text,
14725
"-check_media: cannot apply patch_lba0= while data_to= has empty value");
14726
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
14730
if(job->use_dev == 2) {
14731
if(job->sector_map_path[0] == 0) {
14732
sprintf(xorriso->info_text,
14733
"-check_media: option use=sector_map but sector_map=''");
14734
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
14737
ret= Sectorbitmap_from_file(&(job->sector_map), job->sector_map_path,
14738
xorriso->info_text, &os_errno, 0);
14740
if(xorriso->info_text[0])
14741
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, os_errno,
14745
ret= Xorriso_sectormap_to_spotlist(xorriso, job, &spotlist, 0);
14748
Sectorbitmap_destroy(&(xorriso->in_sector_map), 0);
14749
ret= Sectorbitmap_clone(job->sector_map, &(xorriso->in_sector_map), 0);
14753
ret= Xorriso_check_media(xorriso, &spotlist, job, 0);
14758
if(job->patch_lba0) {
14759
ret= Xorriso_open_job_data_to(xorriso, job, 0);
14763
ret= Xorriso_update_iso_lba0(xorriso, job->patch_lba0_msc1, 0,
14765
(8 * (job->patch_lba0 == 1)) |
14766
4 | (job->patch_lba0_msc1 < 0));
14772
if(job->report_mode == 0 || job->report_mode == 2) { /* report blocks */
14773
for(pass= 0; pass < 2; pass++) {
14775
sprintf(xorriso->result_line,
14776
"Media checks : lba , size , quality\n");
14780
sprintf(xorriso->result_line,
14781
"MD5 checks : lba , size , result\n");
14783
Xorriso_result(xorriso,0);
14784
count= Spotlist_count(spotlist, 0);
14785
for(i= 0; i < count; i++) {
14786
ret= Spotlist_get_item(spotlist, i, &lba, &blocks, &quality, 0);
14790
if(quality == Xorriso_read_quality_md5_mismatcH ||
14791
quality == Xorriso_read_quality_unreadablE) {
14794
if(quality == Xorriso_read_quality_md5_matcH ||
14795
quality == Xorriso_read_quality_md5_mismatcH) {
14800
else if(pass == 1 && !(quality == Xorriso_read_quality_md5_matcH ||
14801
quality == Xorriso_read_quality_md5_mismatcH))
14803
sprintf(xorriso->result_line, "%s: %10d , %10d , %s\n",
14804
pass == 0 ? "Media region " : "MD5 tag range",
14805
lba, blocks, Spotlist__quality_name(quality, quality_name,
14806
xorriso->check_media_bad_limit, 0));
14807
Xorriso_result(xorriso,0);
14811
if(job->report_mode == 1 || job->report_mode == 2) { /* report files */
14812
ret= Findjob_new(&findjob, "/", 0);
14814
Xorriso_no_findjob(xorriso, "-check_media report=files", 0);
14815
{ret= -1; goto ex;}
14817
Findjob_set_damage_filter(findjob, 1, 0);
14818
Findjob_set_action_target(findjob, 21, NULL, 0);
14819
ret= Xorriso_findi(xorriso, findjob, NULL, (off_t) 0,
14820
NULL, "/", &dir_stbuf, 0, 0);
14821
Findjob_destroy(&findjob, 0);
14827
if(was_event && strcmp(job->event_severity, "ALL") != 0) {
14828
sprintf(xorriso->info_text,
14829
"Event triggered by media read error or MD5 comparison mismatch");
14830
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, job->event_severity,
14833
Spotlist_destroy(&spotlist, 0);
14834
Checkmediajob_destroy(&job, 0);
14839
/* Option -check_media_defaults */
14840
int Xorriso_option_check_media_defaults(struct XorrisO *xorriso,
14841
int argc, char **argv, int *idx, int flag)
14843
int ret, old_idx, end_idx;
14844
struct CheckmediajoB *job= NULL;
14847
end_idx= Xorriso_end_idx(xorriso, argc, argv, *idx, 1);
14850
ret= Checkmediajob_new(&job, 0);
14853
ret= Xorriso_check_media_setup_job(xorriso, job, argv, old_idx, end_idx, 0);
14856
Checkmediajob_destroy(&(xorriso->check_media_default), 0);
14857
xorriso->check_media_default= job;
14861
Checkmediajob_destroy(&job, 0);
14866
/* Option -chgrp alias -chgrpi , chgrp_r alias chgrpi */
14867
/* @param flag bit0=recursive (-chgrp_r)
14869
int Xorriso_option_chgrpi(struct XorrisO *xorriso, char *gid,
14870
int argc, char **argv, int *idx, int flag)
14872
int i, ret, was_failure= 0, end_idx, fret;
14876
struct FindjoB *job= NULL;
14877
struct stat dir_stbuf;
14879
ret= Xorriso_opt_args(xorriso, "-chgrpi", argc, argv, *idx, &end_idx, &optc,
14883
ret= Xorriso_convert_gidstring(xorriso, gid, &gid_number, 0);
14886
for(i= 0; i<optc; i++) {
14888
ret= Findjob_new(&job, optv[i], 0);
14890
Xorriso_no_findjob(xorriso, "-chgrp_r", 0);
14891
{ret= -1; goto ex;}
14893
Findjob_set_action_chgrp(job, gid_number, 0);
14894
ret= Xorriso_findi(xorriso, job, NULL, (off_t) 0,
14895
NULL, optv[i], &dir_stbuf, 0, 0);
14896
Findjob_destroy(&job, 0);
14898
ret= Xorriso_set_gid(xorriso, optv[i], gid_number, 0);
14899
if(ret>0 && !xorriso->request_to_abort)
14900
continue; /* regular bottom of loop */
14902
fret= Xorriso_eval_problem_status(xorriso, ret, 1|2);
14910
Xorriso_opt_args(xorriso, "-chgrpi", argc, argv, *idx, &end_idx, &optc, &optv,
14911
256); /* clean up */
14914
Findjob_destroy(&job, 0);
14915
return(!was_failure);
14919
/* Option -chmod alias -chmodi , -chmod_r alias chmod_ri */
14920
/* @param flag bit0=recursive (-chmod_r)
14922
int Xorriso_option_chmodi(struct XorrisO *xorriso, char *mode,
14923
int argc, char **argv, int *idx, int flag)
14925
int i, ret, was_failure= 0, end_idx, fret;
14926
mode_t mode_and= ~0, mode_or= 0;
14929
struct FindjoB *job= NULL;
14930
struct stat dir_stbuf;
14932
ret= Xorriso_opt_args(xorriso, "-chmodi", argc, argv, *idx, &end_idx, &optc,
14936
ret= Xorriso_convert_modstring(xorriso, "-chmodi",
14937
mode, &mode_and, &mode_or, 0);
14940
for(i= 0; i<optc; i++) {
14942
ret= Findjob_new(&job, optv[i], 0);
14944
Xorriso_no_findjob(xorriso, "-chmod_r", 0);
14945
{ret= -1; goto ex;}
14947
Findjob_set_action_chmod(job, mode_and, mode_or, 0);
14948
ret= Xorriso_findi(xorriso, job, NULL, (off_t) 0,
14949
NULL, optv[i], &dir_stbuf, 0, 0);
14950
Findjob_destroy(&job, 0);
14952
ret= Xorriso_set_st_mode(xorriso, optv[i], mode_and, mode_or, 0);
14954
if(ret>0 && !xorriso->request_to_abort)
14955
continue; /* regular bottom of loop */
14957
fret= Xorriso_eval_problem_status(xorriso, ret, 1|2);
14965
Xorriso_opt_args(xorriso, "-chmodi", argc, argv, *idx, &end_idx, &optc, &optv,
14967
Findjob_destroy(&job, 0);
14970
return(!was_failure);
14974
/* Option -chown alias -chowni , chown_r alias chown_ri */
14975
/* @param flag bit0=recursive (-chown_r)
14977
int Xorriso_option_chowni(struct XorrisO *xorriso, char *uid,
14978
int argc, char **argv, int *idx, int flag)
14980
int i, ret, was_failure= 0, end_idx, fret;
14984
struct FindjoB *job= NULL;
14985
struct stat dir_stbuf;
14987
ret= Xorriso_opt_args(xorriso, "-chowni", argc, argv, *idx, &end_idx,
14991
ret= Xorriso_convert_uidstring(xorriso, uid, &uid_number, 0);
14994
for(i= 0; i<optc; i++) {
14996
ret= Findjob_new(&job, optv[i], 0);
14998
Xorriso_no_findjob(xorriso, "-chown_r", 0);
14999
{ret= -1; goto ex;}
15001
Findjob_set_action_chown(job, uid_number, 0);
15002
ret= Xorriso_findi(xorriso, job, NULL, (off_t) 0,
15003
NULL, optv[i], &dir_stbuf, 0, 0);
15004
Findjob_destroy(&job, 0);
15006
ret= Xorriso_set_uid(xorriso, optv[i], uid_number, 0);
15007
if(ret>0 && !xorriso->request_to_abort)
15008
continue; /* regular bottom of loop */
15010
fret= Xorriso_eval_problem_status(xorriso, ret, 1|2);
15018
Xorriso_opt_args(xorriso, "-chowni", argc, argv, *idx, &end_idx,
15019
&optc, &optv, 256);
15020
Findjob_destroy(&job, 0);
15023
return(!was_failure);
15027
/* Option -close "on"|"off" */
15028
int Xorriso_option_close(struct XorrisO *xorriso, char *mode, int flag)
15030
xorriso->do_close= !!strcmp(mode, "off");
15035
/* Option -close_filter_list */
15036
int Xorriso_option_close_filter_list(struct XorrisO *xorriso, int flag)
15038
xorriso->filter_list_closed= 1;
15043
/* Option -commit */
15044
/* @param flag bit0= leave indrive and outdrive aquired as they were,
15045
i.e. do not aquire outdrive as new in-out-drive
15046
bit1= do not perform eventual -reassure
15047
@return <=0 error , 1 success, 2 revoked by -reassure , 3 no change pending
15049
int Xorriso_option_commit(struct XorrisO *xorriso, int flag)
15052
char newdev[SfileadrL];
15054
if(!xorriso->volset_change_pending) {
15055
sprintf(xorriso->info_text, "-commit: No image modifications pending");
15056
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0);
15060
ret= Xorriso_reassure(xorriso, "-commit",
15061
"write the pending image changes to media", 0);
15065
Xorriso_process_errfile(xorriso, 0, "burn session start", 0, 1);
15066
ret= Xorriso_write_session(xorriso, 0);
15067
Xorriso_process_errfile(xorriso, 0, "burn session end", 0, 1);
15070
Xorriso_write_session_log(xorriso, 0);
15071
xorriso->volset_change_pending= 0;
15072
xorriso->no_volset_present= 0;
15075
if(Sregex_string(&(xorriso->in_charset), xorriso->out_charset, 0) <= 0)
15077
strcpy(newdev, xorriso->outdev);
15078
if(xorriso->grow_blindly_msc2>=0)
15079
ret= Xorriso_option_dev(xorriso, "", 3|4);
15081
ret= Xorriso_option_dev(xorriso, newdev, 3|4);
15086
/* Option -commit_eject */
15087
/* @return <=0 error , 1 success, 2 revoked by -reassure
15089
int Xorriso_option_commit_eject(struct XorrisO *xorriso, char *which, int flag)
15093
ret= Xorriso_option_commit(xorriso, 1);
15094
if(ret<=0 || ret==2 || ret==3)
15096
if(strcmp(which, "none")==0)
15099
eret= Xorriso_option_eject(xorriso, which, 1);
15100
ret= Xorriso_option_dev(xorriso, "", 3|4);
15107
/* Options -compare and -compare_r
15108
@param flag bit0= issue summary message
15109
bit1= do not reset pacifier, no final pacifier message
15110
bit2= do not issue pacifier messages at all
15111
bit3= recursive: -compare_r
15113
int Xorriso_option_compare(struct XorrisO *xorriso, char *disk_path,
15114
char *iso_path, int flag)
15116
int ret, mem_pci, zero= 0, result, follow_links;
15117
double mem_lut= 0.0;
15118
char *ipth, *argv[6], eff_origin[SfileadrL], eff_dest[SfileadrL];
15123
if(disk_path[0]==0) {
15124
sprintf(xorriso->info_text, "-compare: Empty disk_path given");
15125
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 1);
15128
ret= Xorriso_normalize_img_path(xorriso, xorriso->wdx, disk_path, eff_origin,
15132
ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, ipth, eff_dest, 2|8);
15136
if(xorriso->disk_excl_mode&8)
15137
ret= Xorriso_path_is_excluded(xorriso, eff_origin, 1);
15141
goto report_outcome;
15143
Xorriso_pacifier_reset(xorriso, 0);
15144
mem_lut= xorriso->last_update_time;
15146
mem_pci= xorriso->pacifier_interval;
15147
xorriso->pacifier_interval= 5.0;
15150
xorriso->find_compare_result= 1;
15153
argv[2]= "compare";
15154
argv[3]= eff_origin;
15156
ret= Xorriso_option_find(xorriso, 4, argv, &zero, 2); /* -findi */
15158
argv[0]= eff_origin;
15160
argv[2]= "not_in_iso";
15163
ret= Xorriso_option_find(xorriso, 4, argv, &zero, 1|2); /* -findx */
15164
if(ret>0 && !xorriso->do_follow_mount) {
15165
argv[0]= eff_origin;
15169
argv[4]= "is_full_in_iso";
15172
ret= Xorriso_option_find(xorriso, 6, argv, &zero, 1|2); /* -findx */
15175
ret= xorriso->find_compare_result;
15181
follow_links= (xorriso->do_follow_links || xorriso->do_follow_param) << 28;
15182
ret= Xorriso_compare_2_files(xorriso, eff_origin, eff_dest, "", &result,
15183
2 | follow_links | ((flag&4)<<27) | (1<<30));
15186
xorriso->pacifier_interval= mem_pci;
15187
if(mem_lut!=xorriso->last_update_time && !(flag&2))
15188
Xorriso_pacifier_callback(xorriso, "content bytes read",
15189
xorriso->pacifier_count, 0, "", 1);
15192
sprintf(xorriso->result_line,
15193
"Both file objects match as far as expectable.\n");
15194
} else if(ret==0) {
15195
sprintf(xorriso->result_line, "Differences detected.\n");
15197
sprintf(xorriso->result_line, "Comparison failed due to error.\n");
15200
Xorriso_result(xorriso,0);
15207
/* Option -compliance */
15208
int Xorriso_option_compliance(struct XorrisO *xorriso, char *mode,
15211
return(Xorriso_relax_compliance(xorriso, mode, 0));
15215
/* Option -cpr alias -cpri */
15216
int Xorriso_option_cpri(struct XorrisO *xorriso, int argc, char **argv,
15217
int *idx, int flag)
15219
int i, ret, is_dir= 0, was_failure= 0, fret, end_idx_dummy;
15220
char eff_origin[SfileadrL], eff_dest[SfileadrL];
15221
char dest_dir[SfileadrL], leafname[SfileadrL];
15225
ret= Xorriso_cpmv_args(xorriso, "-cpri", argc, argv, idx,
15226
&optc, &optv, eff_dest, 1|2);
15231
strcpy(dest_dir, eff_dest);
15234
/* Perform graft-ins */
15235
Xorriso_pacifier_reset(xorriso, 0);
15236
for(i= 0; i<optc && !xorriso->request_to_abort; i++) {
15237
ret= Xorriso_normalize_img_path(xorriso, xorriso->wdx, optv[i], eff_origin,
15239
if(ret<=0 || xorriso->request_to_abort)
15240
goto problem_handler;
15242
ret= Sfile_leafname(eff_origin, leafname, 0);
15244
goto problem_handler;
15245
strcpy(eff_dest, dest_dir);
15246
ret= Sfile_add_to_path(eff_dest, leafname, 0);
15248
sprintf(xorriso->info_text, "Effective path gets much too long (%d)",
15249
(int) (strlen(eff_dest)+ strlen(leafname)+1));
15250
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
15251
goto problem_handler;
15254
ret= Xorriso_graft_in(xorriso, NULL, eff_origin, eff_dest,
15255
(off_t) 0, (off_t) 0, 0);
15256
if(ret<=0 || xorriso->request_to_abort)
15257
goto problem_handler;
15258
sprintf(xorriso->info_text, "Added to ISO image: %s '%s'='%s'\n",
15259
(ret>1 ? "directory" : "file"), (eff_dest[0] ? eff_dest : "/"),
15262
Xorriso_info(xorriso, 0);
15263
continue; /* regular bottom of loop */
15266
fret= Xorriso_eval_problem_status(xorriso, ret, 1|2);
15271
Xorriso_pacifier_callback(xorriso, "files added", xorriso->pacifier_count,
15272
xorriso->pacifier_total, "", 1);
15275
Xorriso_opt_args(xorriso, "-cpri",
15276
argc, argv, *idx, &end_idx_dummy, &optc, &optv, 256);
15281
/* Options -cpx , -cpax, -cp_rx , -cp_rax */
15282
/* @param flag bit0= recursive (-cp_rx, -cp_rax)
15283
bit1= full property restore (-cpax, -cp_rax)
15285
int Xorriso_option_cpx(struct XorrisO *xorriso, int argc, char **argv,
15286
int *idx, int flag)
15288
int i, ret, is_dir= 0, was_failure= 0, fret, end_idx_dummy;
15289
char eff_origin[SfileadrL], eff_dest[SfileadrL];
15290
char dest_dir[SfileadrL], leafname[SfileadrL], sfe[5*SfileadrL];
15291
char **eff_src_array= NULL, **eff_tgt_array= NULL;
15297
ret= Xorriso_cpmv_args(xorriso, "-cp*x", argc, argv, idx,
15298
&optc, &optv, eff_dest, 1|4);
15303
strcpy(dest_dir, eff_dest);
15305
if(xorriso->allow_restore <= 0) {
15306
sprintf(xorriso->info_text,
15307
"-cpx: image-to-disk copies are not enabled by option -osirrox");
15308
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
15312
if(xorriso->do_restore_sort_lba || !(xorriso->ino_behavior & 4)) {
15313
eff_src_array= calloc(optc, sizeof(char *));
15314
eff_tgt_array= calloc(optc, sizeof(char *));
15315
if(eff_src_array == NULL || eff_tgt_array == NULL) {
15316
Xorriso_no_malloc_memory(xorriso, NULL, 0);
15319
for(i= 0; i < optc; i++)
15320
eff_src_array[i]= eff_tgt_array[i]= NULL;
15323
/* Perform copying */
15324
Xorriso_pacifier_reset(xorriso, 0);
15325
for(i= 0; i<optc && !xorriso->request_to_abort; i++) {
15326
ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, optv[i], eff_origin,
15328
if(ret<=0 || xorriso->request_to_abort)
15329
goto problem_handler;
15331
ret= Xorriso_iso_lstat(xorriso, eff_origin, &stbuf, 2|4);
15333
goto problem_handler;
15334
if(S_ISDIR(stbuf.st_mode) && !(flag&1)) {
15335
/* only allow directories if they actually represent split data files */
15337
if(xorriso->do_concat_split)
15338
ret= Xorriso_is_split(xorriso, eff_origin, NULL, 0);
15340
goto problem_handler;
15342
sprintf(xorriso->info_text, "-cpx: May not copy directory %s",
15343
Text_shellsafe(eff_origin, sfe, 0));
15344
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
15345
ret= 0; goto problem_handler;
15349
if(is_dir && strcmp(eff_origin, "/")!=0) {
15350
ret= Sfile_leafname(eff_origin, leafname, 0);
15352
goto problem_handler;
15353
strcpy(eff_dest, dest_dir);
15354
ret= Sfile_add_to_path(eff_dest, leafname, 0);
15356
sprintf(xorriso->info_text, "Effective path gets much too long (%d)",
15357
(int) (strlen(eff_dest)+strlen(leafname)+1));
15358
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
15359
goto problem_handler;
15362
if(eff_src_array != NULL) {
15363
eff_src_array[i]= strdup(eff_origin);
15364
eff_tgt_array[i]= strdup(eff_dest);
15365
if(eff_src_array[i] == NULL || eff_tgt_array[i] == NULL) {
15366
Xorriso_no_malloc_memory(xorriso, &(eff_src_array[i]), 0);
15370
ret= Xorriso_restore(xorriso, eff_origin, eff_dest, (off_t) 0, (off_t) 0,
15371
16 | ((!(flag&2))<<6));
15372
if(ret<=0 || xorriso->request_to_abort)
15373
goto problem_handler;
15374
if(ret==3 || (flag&1))
15376
sprintf(xorriso->info_text,
15377
"Copied from ISO image to disk: %s '%s' = '%s'\n",
15378
(ret>1 ? "directory" : "file"), eff_origin, eff_dest);
15379
Xorriso_info(xorriso, 0);
15381
continue; /* regular bottom of loop */
15384
fret= Xorriso_eval_problem_status(xorriso, ret, 1|2);
15390
if(eff_src_array != NULL) {
15391
ret= Xorriso_restore_sorted(xorriso, optc, eff_src_array, eff_tgt_array, 0);
15395
if(xorriso->pacifier_count>0)
15396
Xorriso_pacifier_callback(xorriso, "files restored",xorriso->pacifier_count,
15397
xorriso->pacifier_total, "", 1|4);
15401
Sfile_destroy_argv(&i, &eff_src_array, 0);
15403
Sfile_destroy_argv(&i, &eff_tgt_array, 0);
15404
Xorriso_opt_args(xorriso, "-cp*x",
15405
argc, argv, *idx, &end_idx_dummy, &optc, &optv, 256);
15410
/* Option -cut_out */
15411
int Xorriso_option_cut_out(struct XorrisO *xorriso, char *disk_path,
15412
char *start, char *count, char *iso_rr_path, int flag)
15416
off_t startbyte, bytecount;
15418
num= Scanf_io_size(start, 0);
15419
if(num<0 || num > 1.0e18) { /* 10^18 = 10^3 ^ 6 < 2^10 ^ 6 = 2^60 */
15420
sprintf(xorriso->info_text,
15421
"-cut_out: startbyte address negative or much too large (%s)", start);
15422
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
15426
num= Scanf_io_size(count, 0);
15427
if(num<=0 || num > 1.0e18) {
15428
sprintf(xorriso->info_text,
15429
"-cut_out: bytecount zero, negative or much too large (%s)", count);
15430
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
15434
sprintf(xorriso->info_text,
15435
"-cut_out from %s , byte %.f to %.f, and graft as %s",
15436
disk_path, (double) startbyte, (double) (startbyte+bytecount),
15438
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0);
15440
ret= Xorriso_cut_out(xorriso, disk_path, startbyte, bytecount,
15446
/* Options -dev , -indev, -outdev */
15447
/** @param flag bit0= use as indev
15448
bit1= use as outdev
15449
bit2= do not -reassure
15450
bit3= regard overwriteable media as blank
15451
bit4= if the drive is a regular disk file: truncate it to
15452
the write start address
15453
bit5= do not print toc of aquired drive
15454
bit6= do not calm down drive after aquiring it
15455
@return <=0 error , 1 success, 2 revoked by -reassure
15457
int Xorriso_option_dev(struct XorrisO *xorriso, char *in_adr, int flag)
15460
char sfe[5*SfileadrL], *adr;
15463
if(strcmp(in_adr, "-")==0)
15464
adr= "stdio:/dev/fd/1";
15465
if(strncmp(adr, "stdio:", 6)==0) {
15466
if(strlen(adr)==6 || strcmp(adr, "stdio:/")==0 ||
15467
strcmp(adr, "stdio:.")==0 || strcmp(adr, "stdio:..")==0 ||
15468
strcmp(adr, "stdio:-")==0) {
15469
sprintf(xorriso->info_text,
15470
"No suitable path given by device address '%s'", adr);
15471
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
15476
if(xorriso->volset_change_pending && (flag&1)) {
15477
sprintf(xorriso->info_text,
15478
"%s: Image changes pending. -commit or -rollback first",
15479
(flag&2) ? "-dev" : "-indev");
15480
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
15483
if((flag&1) && (xorriso->in_drive_handle != NULL || adr[0]) && !(flag&4)) {
15484
ret= Xorriso_reassure(xorriso, (flag&2) ? "-dev" : "-indev",
15485
"eventually discard the current image", 0);
15491
if((flag&1) && xorriso->in_drive_handle != NULL) {
15492
if(xorriso->in_drive_handle == xorriso->out_drive_handle)
15493
sprintf(xorriso->info_text,"Giving up -dev %s",
15494
Text_shellsafe(xorriso->indev, sfe, 0));
15496
sprintf(xorriso->info_text,"Giving up -indev %s",
15497
Text_shellsafe(xorriso->indev, sfe, 0));
15498
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
15500
if((flag&2) && xorriso->out_drive_handle != NULL &&
15501
xorriso->in_drive_handle != xorriso->out_drive_handle) {
15502
sprintf(xorriso->info_text,"Giving up -outdev %s",
15503
Text_shellsafe(xorriso->outdev, sfe, 0));
15504
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
15506
ret= Xorriso_give_up_drive(xorriso, (flag&3)|((flag&32)>>2));
15508
ret= Xorriso_aquire_drive(xorriso, adr,
15509
(flag & (3 | 32 | 64)) | (((flag & (8 | 16)) >> 1)));
15512
if(xorriso->in_drive_handle == NULL)
15513
xorriso->image_start_mode= 0; /* session setting is invalid by now */
15518
/* Option -devices */
15519
/* @return <=0 error , 1 success, 2 revoked by -reassure
15521
int Xorriso_option_devices(struct XorrisO *xorriso, int flag)
15524
char sfe[5*SfileadrL];
15526
if(xorriso->volset_change_pending) {
15527
sprintf(xorriso->info_text,
15528
"-devices: Image changes pending. -commit or -rollback first");
15529
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
15532
ret= Xorriso_reassure(xorriso, "-devices",
15533
"eventually discard the current image", 0);
15536
xorriso->info_text[0]= 0;
15537
if(xorriso->in_drive_handle!=NULL || xorriso->out_drive_handle!=NULL) {
15538
if(xorriso->in_drive_handle == xorriso->out_drive_handle) {
15539
sprintf(xorriso->info_text, "Gave up -dev %s",
15540
Text_shellsafe(xorriso->indev, sfe, 0));
15541
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
15543
if(xorriso->in_drive_handle!=NULL) {
15544
sprintf(xorriso->info_text, "Gave up -indev %s",
15545
Text_shellsafe(xorriso->indev, sfe, 0));
15546
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
15548
if(xorriso->out_drive_handle!=NULL) {
15549
sprintf(xorriso->info_text, "Gave up -outdev %s",
15550
Text_shellsafe(xorriso->outdev, sfe, 0));
15551
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
15554
Xorriso_give_up_drive(xorriso, 3);
15556
ret= Xorriso_show_devices(xorriso, 0);
15561
/* Option -dialog "on"|"single_line"|"off" */
15562
int Xorriso_option_dialog(struct XorrisO *xorriso, char *mode, int flag)
15564
if(strcmp(mode, "on") == 0 || strcmp(mode, "multi_line") == 0)
15565
xorriso->dialog= 2;
15566
else if(strcmp(mode, "single_line") == 0)
15567
xorriso->dialog= 2;
15568
else if(strcmp(mode, "off") == 0)
15569
xorriso->dialog= 0;
15571
sprintf(xorriso->info_text, "-dialog: unknown mode '%s'", mode);
15572
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
15579
/* Option -disk_dev_ino "on"|"ino_only"|"off" */
15580
int Xorriso_option_disk_dev_ino(struct XorrisO *xorriso, char *mode, int flag)
15582
if(strcmp(mode, "on") == 0)
15583
xorriso->do_aaip= (xorriso->do_aaip & ~128) | 16 | 32 | 64;
15584
else if(strcmp(mode, "ino_only") == 0)
15585
xorriso->do_aaip|= 16 | 32 | 64 | 128;
15586
else if(strcmp(mode, "off") == 0)
15587
xorriso->do_aaip &= ~(16 | 32 | 64 | 128);
15589
sprintf(xorriso->info_text, "-disk_dev_ino: unknown mode '%s'", mode);
15590
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
15597
/* Option -disk_pattern "on"|"ls"|"off" */
15598
int Xorriso_option_disk_pattern(struct XorrisO *xorriso, char *mode, int flag)
15600
if(strcmp(mode, "off")==0)
15601
xorriso->do_disk_pattern= 0;
15602
else if(strcmp(mode, "on")==0)
15603
xorriso->do_disk_pattern= 1;
15604
else if(strcmp(mode, "ls")==0)
15605
xorriso->do_disk_pattern= 2;
15607
sprintf(xorriso->info_text, "-disk_pattern: unknown mode '%s'", mode);
15608
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
15615
/* Option -drive_class */
15616
int Xorriso_option_drive_class(struct XorrisO *xorriso,
15617
char *d_class, char *pattern, int flag)
15621
if(strcmp(d_class, "banned") == 0) {
15622
ret= Xorriso_lst_new(&(xorriso->drive_blacklist), pattern,
15623
xorriso->drive_blacklist, 1);
15624
} else if(strcmp(d_class, "caution") == 0) {
15625
ret= Xorriso_lst_new(&(xorriso->drive_greylist), pattern,
15626
xorriso->drive_greylist, 1);
15627
} else if (strcmp(d_class, "harmless") == 0) {
15628
ret= Xorriso_lst_new(&(xorriso->drive_whitelist), pattern,
15629
xorriso->drive_whitelist, 1);
15630
} else if (strcmp(d_class, "clear_list") == 0) {
15631
if(strcmp(pattern, "banned") == 0)
15632
Xorriso_lst_destroy_all(&(xorriso->drive_blacklist), 0);
15633
else if(strcmp(pattern, "caution") == 0)
15634
Xorriso_lst_destroy_all(&(xorriso->drive_greylist), 0);
15635
else if(strcmp(pattern, "harmless") == 0)
15636
Xorriso_lst_destroy_all(&(xorriso->drive_whitelist), 0);
15637
else if(strcmp(pattern, "all") == 0) {
15638
Xorriso_lst_destroy_all(&(xorriso->drive_blacklist), 0);
15639
Xorriso_lst_destroy_all(&(xorriso->drive_greylist), 0);
15640
Xorriso_lst_destroy_all(&(xorriso->drive_whitelist), 0);
15642
sprintf(xorriso->info_text, "-drive_class clear : unknown class '%s'",
15644
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
15649
sprintf(xorriso->info_text, "-drive_class: unknown class '%s'", d_class);
15650
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
15657
/* Option -dummy "on"|"off" */
15658
int Xorriso_option_dummy(struct XorrisO *xorriso, char *mode, int flag)
15660
xorriso->do_dummy= !!strcmp(mode, "off");
15665
/* Option -dvd_obs "default"|"32k"|"64k" */
15666
int Xorriso_option_dvd_obs(struct XorrisO *xorriso, char *obs, int flag)
15670
if(strcmp(obs, "default") == 0)
15673
num = Scanf_io_size(obs,0);
15674
if(num != 0 && num != 32768 && num != 65536) {
15675
sprintf(xorriso->info_text,
15676
"-dvd_obs : Bad size. Acceptable are 0, 32k, 64k");
15677
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
15680
xorriso->dvd_obs= num;
15685
/* Option -eject */
15686
/* @param flag bit0=do not report toc of eventually remaining drives
15688
int Xorriso_option_eject(struct XorrisO *xorriso, char *which, int flag)
15690
int gu_flag= 4, ret;
15692
if(strncmp(which,"in",2)==0)
15694
else if(strncmp(which,"out",3)==0)
15698
if((gu_flag&1) && xorriso->volset_change_pending) {
15699
sprintf(xorriso->info_text,
15700
"-eject: Image changes pending. -commit or -rollback first");
15701
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
15706
ret= Xorriso_give_up_drive(xorriso, gu_flag);
15711
/* Options -end , and -rollback_end */
15712
/* @param flag bit0= discard pending changes
15713
bit1= do not -reassure
15714
@return <=0 error , 1 success, 2 revoked by -reassure
15716
int Xorriso_option_end(struct XorrisO *xorriso, int flag)
15719
char *cmd, *which_will;
15722
cmd= "-rollback_end";
15725
if(xorriso->volset_change_pending) {
15727
which_will= "end the program discarding image changes";
15729
which_will= "commit image changes and then end the program";
15731
which_will= "end the program";
15734
ret= Xorriso_reassure(xorriso, cmd, which_will, 0);
15739
if(xorriso->volset_change_pending) {
15741
xorriso->volset_change_pending= 0;
15743
ret= Xorriso_option_commit(xorriso, 1);
15744
xorriso->volset_change_pending= 0; /* no further tries to commit */
15749
ret= Xorriso_give_up_drive(xorriso, 3);
15756
/* Option -errfile_log marked|plain path|-|"" */
15757
int Xorriso_option_errfile_log(struct XorrisO *xorriso,
15758
char *mode, char *path, int flag)
15760
int ret, mode_word;
15762
char sfe[5*SfileadrL];
15764
if(path[0]==0 || path[0]=='-') {
15767
fp= fopen(path, "a");
15769
sprintf(xorriso->info_text, "-errfile_log: Cannot open file %s",
15770
Text_shellsafe(path, sfe, 0));
15771
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
15775
mode_word= xorriso->errfile_mode;
15776
if(strcmp(mode, "marked")==0)
15778
else if(strcmp(mode, "plain")==0)
15781
sprintf(xorriso->info_text, "-errfile_log: Unknown mode %s",
15782
Text_shellsafe(mode, sfe, 0));
15783
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
15787
Xorriso_process_errfile(xorriso, 0, "log end", 0, 1);
15788
if(xorriso->errfile_fp!=NULL)
15789
fclose(xorriso->errfile_fp);
15790
xorriso->errfile_fp= fp;
15791
xorriso->errfile_mode= mode_word;
15792
ret= Sfile_str(xorriso->errfile_log, path, 0);
15794
ret= Xorriso_process_errfile(xorriso, 0, "log start", 0, 1);
15801
/* Option -error_behavior */
15802
int Xorriso_option_error_behavior(struct XorrisO *xorriso,
15803
char *occasion, char *behavior, int flag)
15805
if(strcmp(occasion, "image_loading")==0) {
15806
if(strcmp(behavior, "best_effort")==0)
15807
xorriso->img_read_error_mode= 0;
15808
else if(strcmp(behavior, "failure")==0 || strcmp(behavior, "FAILURE")==0)
15809
xorriso->img_read_error_mode= 1;
15810
else if(strcmp(behavior, "fatal")==0 || strcmp(behavior, "FATAL")==0)
15811
xorriso->img_read_error_mode= 2;
15814
sprintf(xorriso->info_text,
15815
"-error_behavior: with '%s': unknown behavior '%s'",
15816
occasion, behavior);
15817
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
15820
} else if(strcmp(occasion, "file_extraction")==0) {
15821
if(strcmp(behavior, "best_effort")==0)
15822
xorriso->extract_error_mode= 0;
15823
else if(strcmp(behavior, "keep")==0)
15824
xorriso->extract_error_mode= 1;
15825
else if(strcmp(behavior, "delete")==0)
15826
xorriso->extract_error_mode= 2;
15828
goto unknown_behavior;
15830
sprintf(xorriso->info_text, "-error_behavior: unknown occasion '%s'",
15832
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
15839
/* Option -external_filter */
15840
int Xorriso_option_external_filter(struct XorrisO *xorriso,
15841
int argc, char **argv, int *idx, int flag)
15843
int ret, start_idx, end_idx;
15846
end_idx= Xorriso_end_idx(xorriso, argc, argv, start_idx, 1);
15848
if(end_idx - start_idx < 3) {
15849
sprintf(xorriso->info_text,
15850
"-external_filter : Not enough arguments given. Needed: name options path %s",
15851
xorriso->list_delimiter);
15852
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
15855
ret= Xorriso_external_filter(xorriso, argv[start_idx],
15856
argv[start_idx + 1], argv[start_idx + 2],
15857
end_idx - start_idx - 3, argv + start_idx + 3, 0);
15862
/* Options -extract , -extract_single */
15863
/* @param flag bit0=do not report the restored item
15864
bit1=do not reset pacifier, no final pacifier message
15865
bit2= do not make lba-sorted node array for hardlink detection
15866
bit5= -extract_single: eventually do not insert directory tree
15868
int Xorriso_option_extract(struct XorrisO *xorriso, char *iso_path,
15869
char *disk_path, int flag)
15872
char eff_origin[SfileadrL], eff_dest[SfileadrL], *ipth, *eopt[1], *edpt[1];
15874
if(xorriso->allow_restore <= 0) {
15875
sprintf(xorriso->info_text,
15876
"-extract: image-to-disk copies are not enabled by option -osirrox");
15877
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
15881
Xorriso_pacifier_reset(xorriso, 0);
15886
if(disk_path[0]==0) {
15887
sprintf(xorriso->info_text, "-extract: Empty disk_path given");
15888
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 1);
15891
ret= Xorriso_normalize_img_path(xorriso, xorriso->wdx, disk_path, eff_dest,
15895
ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, ipth, eff_origin, 2|8);
15899
eopt[0]= eff_origin;
15901
ret= Xorriso_restore_sorted(xorriso, 1, eopt, edpt, (flag & 32 ? 33 : 0));
15904
Xorriso_pacifier_callback(xorriso, "files restored",xorriso->pacifier_count,
15905
xorriso->pacifier_total, "", 1|4);
15910
sprintf(xorriso->info_text, "Extracted from ISO image: %s '%s'='%s'\n",
15911
(ret>1 ? "directory" : "file"), eff_origin, eff_dest);
15912
Xorriso_info(xorriso,0);
15916
if(!(flag & (4 | 32)))
15917
Xorriso_destroy_node_array(xorriso, 0);
15922
/* Option -extract_cut */
15923
int Xorriso_option_extract_cut(struct XorrisO *xorriso, char *iso_rr_path,
15924
char *start, char *count, char *disk_path, int flag)
15928
off_t startbyte, bytecount;
15930
num= Scanf_io_size(start, 0);
15931
if(num<0 || num > 1.0e18) { /* 10^18 = 10^3 ^ 6 < 2^10 ^ 6 = 2^60 */
15932
sprintf(xorriso->info_text,
15933
"-extract_cut: startbyte address negative or much too large (%s)",
15935
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
15939
num= Scanf_io_size(count, 0);
15940
if(num<=0 || num > 1.0e18) {
15941
sprintf(xorriso->info_text,
15942
"-extract_cut: bytecount zero, negative or much too large (%s)",
15944
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
15948
sprintf(xorriso->info_text,
15949
"-extract_cut from %s , byte %.f to %.f, and store as %s",
15950
iso_rr_path, (double) startbyte, (double) (startbyte+bytecount),
15952
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0);
15954
ret= Xorriso_extract_cut(xorriso, iso_rr_path, disk_path,
15955
startbyte, bytecount, 0);
15960
/* Option -file_size_limit */
15961
int Xorriso_option_file_size_limit(struct XorrisO *xorriso,
15962
int argc, char **argv, int *idx, int flag)
15964
int ret, i, end_idx;
15965
off_t new_limit= 0;
15967
end_idx= Xorriso_end_idx(xorriso, argc, argv, *idx, 1);
15968
if(*idx >= end_idx)
15970
if(*idx + 1 == end_idx && strcmp(argv[*idx], "off") == 0) {
15971
xorriso->file_size_limit= 0;
15974
for(i= *idx; i < end_idx; i++)
15975
new_limit+= Scanf_io_size(argv[i], 0);
15976
if(new_limit <= 0) {
15977
sprintf(xorriso->info_text, "-file_size_limit: values sum up to %.f",
15978
(double) new_limit);
15979
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 1);
15982
xorriso->file_size_limit= new_limit;
15987
if(xorriso->file_size_limit > 0)
15988
sprintf(xorriso->info_text, "-file_size_limit now at %.f\n",
15989
(double) xorriso->file_size_limit);
15991
sprintf(xorriso->info_text, "-file_size_limit now off\n");
15992
Xorriso_info(xorriso,0);
15998
/* Option -find alias -findi, and -findx */
15999
/* @param flag bit0= -findx rather than -findi
16000
bit1= do not reset pacifier, no final pacifier message
16001
do not reset find_compare_result
16002
bit2= do not count deleted files with rm and rm_r
16003
bit3= use Xorriso_findi_sorted() rather than Xorriso_findi()
16004
(this can also be ordered by test -sort_lba)
16006
int Xorriso_option_find(struct XorrisO *xorriso, int argc, char **argv,
16007
int *idx, int flag)
16009
int ret, i, end_idx, type= 0, action, deleter= 0, start_lba, count;
16010
struct FindjoB *job, *first_job= NULL, *new_job;
16011
char *start_path, sfe[5*SfileadrL], *cpt, other_path_start[SfileadrL];
16012
char *access_acl_text= NULL, *default_acl_text= NULL;
16014
struct stat dir_stbuf;
16018
mode_t mode_or= 0, mode_and= ~1;
16019
double mem_lut= 0.0;
16021
end_idx= Xorriso_end_idx(xorriso, argc, argv, *idx, 1);
16023
if(end_idx > *idx && start_path[0]!=0)
16024
start_path= argv[*idx];
16025
ret= Findjob_new(&first_job, start_path, 0);
16027
Xorriso_no_findjob(xorriso, "-find[ix]", 0);
16028
{ret= -1; goto ex;}
16032
xorriso->find_compare_result= 1;
16033
for(i= *idx+1; i<end_idx; i++) {
16034
if(strcmp(argv[i], "-name")==0) {
16036
not_enough_arguments:;
16037
sprintf(xorriso->info_text,
16038
"-find[ix]: not enough arguments with test %s",
16039
Text_shellsafe(argv[i], sfe, 0));
16043
ret= Findjob_set_name_expr(job, argv[i], 0);
16045
sprintf(xorriso->info_text, "-find[ix]: cannot set -name expression %s",
16046
Text_shellsafe(argv[i], sfe, 0));
16049
} else if(strcmp(argv[i], "-wholename")==0) {
16051
goto not_enough_arguments;
16053
ret= Findjob_set_name_expr(job, argv[i], 1);
16055
sprintf(xorriso->info_text,
16056
"-find[ix]: cannot set -wholename expression %s",
16057
Text_shellsafe(argv[i], sfe, 0));
16060
} else if(strcmp(argv[i], "-type")==0) {
16062
goto not_enough_arguments;
16064
ret= Findjob_set_file_type(job, argv[i][0], 0);
16066
sprintf(xorriso->info_text, "-find[ix]: unknown -type '%c'",argv[i][0]);
16069
} else if(strcmp(argv[i], "-damaged")==0) {
16070
Findjob_set_damage_filter(job, 1, 0);
16071
} else if(strcmp(argv[i], "-undamaged")==0) {
16072
Findjob_set_damage_filter(job, -1, 0);
16073
} else if(strcmp(argv[i], "-lba_range")==0) {
16075
goto not_enough_arguments;
16077
sscanf(argv[i-1], "%d", &start_lba);
16078
sscanf(argv[i], "%d", &count);
16079
Findjob_set_lba_range(job, start_lba, count, 0);
16080
} else if(strcmp(argv[i], "-pending_data")==0) {
16081
Findjob_set_commit_filter_2(job, 0);
16082
} else if(strcmp(argv[i], "-has_acl")==0) {
16083
Findjob_set_acl_filter(job, 1, 0);
16084
} else if(strcmp(argv[i], "-has_no_acl")==0) {
16085
Findjob_set_acl_filter(job, -1, 0);
16086
} else if(strcmp(argv[i], "-has_xattr")==0) {
16087
Findjob_set_xattr_filter(job, 1, 0);
16088
} else if(strcmp(argv[i], "-has_any_xattr")==0) {
16089
Findjob_set_xattr_filter(job, 1, 1);
16090
} else if(strcmp(argv[i], "-has_no_xattr")==0) {
16091
Findjob_set_xattr_filter(job, -1, 0);
16092
} else if(strcmp(argv[i], "-has_aaip")==0) {
16093
Findjob_set_aaip_filter(job, 1, 0);
16094
} else if(strcmp(argv[i], "-has_no_aaip")==0) {
16095
Findjob_set_aaip_filter(job, -1, 0);
16096
} else if(strcmp(argv[i], "-has_filter")==0) {
16097
Findjob_set_filter_filter(job, 1, 0);
16098
} else if(strcmp(argv[i], "-has_no_filter")==0) {
16099
Findjob_set_filter_filter(job, -1, 0);
16100
} else if(strcmp(argv[i], "-has_md5")==0) {
16101
Findjob_set_prop_filter(job, 15, 1, 0);
16102
} else if(strcmp(argv[i], "-true") == 0) {
16103
ret= Findjob_set_false(job, -1, 0);
16104
} else if(strcmp(argv[i], "-false") == 0) {
16105
ret= Findjob_set_false(job, 1, 0);
16106
} else if(strcmp(argv[i], "-decision") == 0) {
16108
goto not_enough_arguments;
16110
ret= Findjob_set_decision(job, argv[i], 0);
16111
} else if(strcmp(argv[i], "-prune") == 0) {
16112
ret= Findjob_set_prune(job, 0);
16113
} else if(strcmp(argv[i], "-sub") == 0 || strcmp(argv[i], "(") == 0) {
16114
ret= Findjob_open_bracket(job, 0);
16115
} else if(strcmp(argv[i], "-subend") == 0 || strcmp(argv[i], ")") == 0) {
16116
ret= Findjob_close_bracket(job, 0);
16117
} else if(strcmp(argv[i], "-not") == 0 || strcmp(argv[i], "!") == 0) {
16118
ret= Findjob_not(job, 0);
16119
} else if(strcmp(argv[i], "-and") == 0 || strcmp(argv[i], "-a") == 0) {
16120
ret= Findjob_and(job, 0);
16121
} else if(strcmp(argv[i], "-or") == 0 || strcmp(argv[i], "-o") == 0) {
16122
ret= Findjob_or(job, 0);
16123
} else if(strcmp(argv[i], "-if") == 0) {
16124
ret= Findjob_if(job, 0);
16125
} else if(strcmp(argv[i], "-then") == 0) {
16126
ret= Findjob_then(job, 0);
16127
} else if(strcmp(argv[i], "-else") == 0) {
16128
ret= Findjob_else(job, 0);
16129
} else if(strcmp(argv[i], "-elseif") == 0) {
16130
ret= Findjob_elseif(job, 0);
16131
} else if(strcmp(argv[i], "-endif") == 0) {
16132
ret= Findjob_endif(job, 0);
16133
} else if(strcmp(argv[i], "-sort_lba") == 0) {
16135
/* If an operator is open: insert a -true test, else do nothing */
16136
ret= Findjob_set_false(job, -1, 1);
16139
} else if(strcmp(argv[i], "-exec")==0) {
16141
not_enough_exec_arguments:;
16142
sprintf(xorriso->info_text,
16143
"-find[ix]: not enough arguments with -exec %s",
16144
Text_shellsafe(argv[i], sfe, 0));
16151
if(strcmp(cpt, "echo")==0) {
16152
Findjob_set_action_target(job, 0, NULL, 0);
16153
} else if(strcmp(cpt, "rm")==0) {
16154
Findjob_set_action_target(job, 1, NULL, 0);
16156
} else if(strcmp(cpt, "rm_r")==0) {
16157
Findjob_set_action_target(job, 2, NULL, 0);
16161
/* >>> not implemented yet */;
16162
} else if(strcmp(cpt, "mv")==0) {
16164
goto not_enough_exec_arguments;
16166
Findjob_set_action_target(job, 3, argv[i], 0);
16169
} else if(strcmp(cpt, "chown")==0 || strcmp(cpt, "chown_r")==0) {
16171
goto not_enough_exec_arguments;
16173
ret= Xorriso_convert_uidstring(xorriso, argv[i], &user, 0);
16176
ret= Findjob_set_action_chown(job, user, strlen(cpt)>5);
16178
Xorriso_no_findjob(xorriso, "-find -exec chown_r", 0);
16181
} else if(strcmp(cpt, "chgrp")==0 || strcmp(cpt, "chgrp_r")==0) {
16183
goto not_enough_exec_arguments;
16185
ret= Xorriso_convert_gidstring(xorriso, argv[i], &group, 0);
16188
ret= Findjob_set_action_chgrp(job, group, strlen(cpt)>5);
16190
Xorriso_no_findjob(xorriso, "-find -exec chgrp_r", 0);
16193
} else if(strcmp(cpt, "chmod")==0 || strcmp(cpt, "chmod_r")==0) {
16195
goto not_enough_exec_arguments;
16197
ret= Xorriso_convert_modstring(xorriso, "-find -exec chmod",
16198
argv[i], &mode_and, &mode_or, 0);
16201
ret= Findjob_set_action_chmod(job, mode_and, mode_or, strlen(cpt)>5);
16203
Xorriso_no_findjob(xorriso, "-find -exec chmod_r", 0);
16206
} else if(strcmp(cpt, "alter_date")==0 || strcmp(cpt, "alter_date_r")==0){
16208
goto not_enough_exec_arguments;
16210
ret= Xorriso_convert_datestring(xorriso, "-find -exec alter_date",
16211
argv[i-1], argv[i], &type, &date, 0);
16214
ret= Findjob_set_action_ad(job, type, date, strlen(cpt)>10);
16216
Xorriso_no_findjob(xorriso, "-find -exec alter_date_r", 0);
16219
} else if(strcmp(cpt, "lsdl")==0) {
16220
Findjob_set_action_target(job, 8, NULL, 0);
16222
} else if(strcmp(cpt, "find")==0) {
16223
ret= Findjob_new(&new_job, "", 0);
16225
Xorriso_no_findjob(xorriso, "-find[ix]", 0);
16226
{ret= -1; goto ex;}
16228
Findjob_set_action_subjob(job, 13, new_job, 0);
16231
} else if(strcmp(cpt, "compare")==0 || strcmp(cpt, "update")==0 ||
16232
strcmp(cpt, "widen_hardlinks")==0) {
16234
goto not_enough_exec_arguments;
16237
if(strcmp(cpt, "update")==0)
16239
if(strcmp(cpt, "widen_hardlinks")==0)
16241
ret= Xorriso_make_abs_adr(xorriso, xorriso->wdx, argv[i],
16242
other_path_start, 1|2|4|8);
16245
Findjob_set_action_target(job, action, other_path_start, 0);
16246
ret= Xorriso_make_abs_adr(xorriso, xorriso->wdi, start_path,sfe, 1|2|4);
16249
Findjob_set_start_path(job, sfe, 0);
16251
Xorriso_pacifier_reset(xorriso, 0);
16252
mem_lut= xorriso->last_update_time;
16254
} else if(strcmp(cpt, "in_iso")==0 ||
16255
strcmp(cpt, "not_in_iso")==0 ||
16256
strcmp(cpt, "add_missing")==0 ||
16257
strcmp(cpt, "empty_iso_dir")==0 ||
16258
strcmp(cpt, "is_full_in_iso")==0) {
16260
goto not_enough_exec_arguments;
16262
ret= Xorriso_make_abs_adr(xorriso, xorriso->wdi, argv[i],
16263
other_path_start, 1|2|4);
16266
if(strcmp(cpt, "in_iso")==0)
16268
else if(strcmp(cpt, "add_missing")==0)
16270
else if(strcmp(cpt, "empty_iso_dir")==0)
16272
else if(strcmp(cpt, "is_full_in_iso")==0)
16276
Findjob_set_action_target(job, action, other_path_start, 0);
16277
ret= Xorriso_make_abs_adr(xorriso, xorriso->wdx, start_path, sfe,
16281
Findjob_set_start_path(job, sfe, 0);
16283
} else if(strcmp(cpt, "report_damage")==0) {
16284
Findjob_set_action_target(job, 21, NULL, 0);
16285
} else if(strcmp(cpt, "report_lba")==0) {
16286
Findjob_set_action_target(job, 22, NULL, 0);
16287
} else if(strcmp(cpt, "getfacl")==0) {
16288
Findjob_set_action_target(job, 24, NULL, 0);
16289
} else if(strcmp(cpt, "setfacl")==0) {
16291
goto not_enough_exec_arguments;
16293
ret= Xorriso_normalize_acl_text(xorriso, argv[i],
16294
&access_acl_text, &default_acl_text, 0);
16297
Findjob_set_action_text_2(job, 25, access_acl_text, default_acl_text,
16299
} else if(strcmp(cpt, "getfattr")==0) {
16300
Findjob_set_action_target(job, 26, NULL, 0);
16301
} else if(strcmp(cpt, "setfattr")==0) {
16302
if(i + 2 >= end_idx)
16303
goto not_enough_exec_arguments;
16306
ret= Xorriso_path_setfattr(xorriso, NULL, "", argv[i - 1],
16307
strlen(argv[i]), argv[i], 1);
16310
Findjob_set_action_text_2(job, 27, argv[i - 1], argv[i], 0);
16311
} else if(strcmp(cpt, "set_filter")==0) {
16312
if(i + 1 >= end_idx)
16313
goto not_enough_exec_arguments;
16315
Findjob_set_action_target(job, 28, argv[i], 0);
16317
Xorriso_pacifier_reset(xorriso, 0);
16318
mem_lut= xorriso->last_update_time;
16320
} else if(strcmp(cpt, "show_stream")==0) {
16321
Findjob_set_action_target(job, 29, NULL, 0);
16322
} else if(strcmp(cpt, "get_any_xattr")==0) {
16323
Findjob_set_action_target(job, 33, NULL, 0);
16324
} else if(strcmp(cpt, "get_md5")==0) {
16325
Findjob_set_action_target(job, 34, NULL, 0);
16326
} else if(strcmp(cpt, "check_md5")==0) {
16327
if(i + 1 >= end_idx)
16328
goto not_enough_exec_arguments;
16330
Findjob_set_action_target(job, 35, argv[i], 0);
16333
Xorriso_pacifier_reset(xorriso, 0);
16334
mem_lut= xorriso->last_update_time;
16337
xorriso->find_check_md5_result= 0;
16338
} else if(strcmp(cpt, "make_md5")==0) {
16339
Findjob_set_action_target(job, 36, NULL, 0);
16342
Xorriso_pacifier_reset(xorriso, 0);
16343
mem_lut= xorriso->last_update_time;
16345
} else if(strcmp(cpt, "mkisofs_r")==0) {
16346
Findjob_set_action_target(job, 37, NULL, 0);
16347
} else if(strcmp(cpt, "sort_weight")==0) {
16348
if(i + 1 >= end_idx)
16349
goto not_enough_exec_arguments;
16351
sscanf(argv[i], "%d", &type);
16352
Findjob_set_action_type(job, 38, type, 0);
16354
sprintf(xorriso->info_text, "-find -exec: unknown action %s",
16355
Text_shellsafe(argv[i], sfe, 0));
16359
sprintf(xorriso->info_text, "-find[ix]: unknown option %s",
16360
Text_shellsafe(argv[i], sfe, 0));
16362
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
16367
ret= Xorriso_findx(xorriso, first_job, "", start_path, &dir_stbuf, 0, NULL,
16369
else if(flag & 8) {
16371
ret= Xorriso_findi_sorted(xorriso, first_job, (off_t) 0, 1, &cpt, 0);
16373
ret= Xorriso_findi(xorriso, first_job, NULL, (off_t) 0, NULL,
16374
start_path, &dir_stbuf, 0, (flag&4)>>1);
16376
if(deleter && !(flag&2))
16377
Xorriso_pacifier_callback(xorriso, "iso_rr_paths deleted",
16378
xorriso->pacifier_count, 0, "", 1|2);
16379
else if(first_job->action == 28 && !(flag&2))
16380
Xorriso_pacifier_callback(xorriso, "file filters processed",
16381
xorriso->pacifier_count, 0, "", 1 | 2);
16382
else if(mem_lut!=xorriso->last_update_time && mem_lut!=0.0 && !(flag&2))
16383
Xorriso_pacifier_callback(xorriso, "content bytes read",
16384
xorriso->pacifier_count, 0, "", 1);
16385
if(first_job->action == 35 && !(flag & 1))
16386
Xorriso_report_md5_outcome(xorriso, first_job->target, 0);
16387
if(access_acl_text != NULL)
16388
free(access_acl_text);
16389
if(default_acl_text != NULL)
16390
free(default_acl_text);
16391
Findjob_destroy(&first_job, 0);
16397
/* Option -follow */
16398
int Xorriso_option_follow(struct XorrisO *xorriso, char *mode, int flag)
16400
int was_fl, was_fm, was_fpr, was_fpt, l;
16404
was_fpt= xorriso->do_follow_pattern;
16405
was_fpr= xorriso->do_follow_param;
16406
was_fl= xorriso->do_follow_links;
16407
was_fm= xorriso->do_follow_mount;
16408
xorriso->do_follow_pattern= 0;
16409
xorriso->do_follow_param= 0;
16410
xorriso->do_follow_links= 0;
16411
xorriso->do_follow_mount= 0;
16413
for(cpt= mode; npt!=NULL; cpt= npt+1) {
16414
npt= strchr(cpt,':');
16421
if(strncmp(cpt, "off", l)==0) {
16422
xorriso->do_follow_pattern= 0;
16423
xorriso->do_follow_param= 0;
16424
xorriso->do_follow_links= 0;
16425
xorriso->do_follow_mount= 0;
16426
} else if(strncmp(cpt, "on", l)==0) {
16427
xorriso->do_follow_pattern= 1;
16428
xorriso->do_follow_param= 1;
16429
xorriso->do_follow_links= 1;
16430
xorriso->do_follow_mount= 1;
16431
} else if(strncmp(cpt, "default", l)==0) {
16432
xorriso->do_follow_pattern= 1;
16433
xorriso->do_follow_param= 0;
16434
xorriso->do_follow_links= 0;
16435
xorriso->do_follow_mount= 1;
16436
xorriso->follow_link_limit= 100;
16437
} else if(strncmp(cpt, "link", l)==0 || strncmp(cpt,"links", l)==0) {
16438
xorriso->do_follow_links= 1;
16439
} else if(strncmp(cpt, "mount", l)==0) {
16440
xorriso->do_follow_mount= 1;
16441
} else if(strncmp(cpt,"param", l)==0) {
16442
xorriso->do_follow_param= 1;
16443
} else if(strncmp(cpt, "pattern", l)==0) {
16444
xorriso->do_follow_pattern= 1;
16445
} else if(strncmp(cpt, "limit=", 6)==0) {
16446
sscanf(cpt+6, "%lf", &num);
16447
if(num<=0 || num>1.0e6) {
16448
sprintf(xorriso->info_text, "-follow: Value too %s with '%s'",
16449
num<=0 ? "small" : "large", cpt+6);
16452
xorriso->follow_link_limit= num;
16456
sprintf(xorriso->info_text, "-follow: unknown mode '%s'", cpt);
16458
sprintf(xorriso->info_text, "-follow: oversized mode parameter (%d)",l);
16460
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
16461
xorriso->do_follow_pattern= was_fpt;
16462
xorriso->do_follow_param= was_fpr;
16463
xorriso->do_follow_links= was_fl;
16464
xorriso->do_follow_mount= was_fm;
16473
int Xorriso_option_fs(struct XorrisO *xorriso, char *size, int flag)
16477
num= Scanf_io_size(size, 0);
16478
if(num < 64*1024 || num > 1024.0 * 1024.0 * 1024.0) {
16479
sprintf(xorriso->info_text, "-fs: wrong size %.f (allowed: %.f - %.f)",
16480
num, 64.0 * 1024.0, 1024.0 * 1024.0 * 1024.0);
16481
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
16484
xorriso->fs= num / 2048.0;
16485
if(xorriso->fs * 2048 < num)
16491
/* Optionis -getfacl alias -getfacli, -getfacl_r alias -getfacl_ri
16492
-getfattr alias getfattri
16494
/* @param flag bit0= recursive -getfacl_r
16495
bit1= getfattr rather than getfacl
16496
bit3= with bit1: do not ignore eventual non-user attributes
16498
int Xorriso_option_getfacli(struct XorrisO *xorriso,
16499
int argc, char **argv, int *idx, int flag)
16501
int i, ret, was_failure= 0, end_idx, fret;
16504
struct FindjoB *job= NULL;
16505
struct stat dir_stbuf;
16507
ret= Xorriso_opt_args(xorriso, "-getfacl", argc, argv, *idx, &end_idx, &optc,
16511
for(i= 0; i<optc; i++) {
16513
ret= Findjob_new(&job, optv[i], 0);
16515
Xorriso_no_findjob(xorriso, "-getfacl_r", 0);
16516
{ret= -1; goto ex;}
16519
Findjob_set_action_target(job, 26, NULL, 0);
16521
Findjob_set_action_target(job, 24, NULL, 0);
16522
ret= Xorriso_findi(xorriso, job, NULL, (off_t) 0,
16523
NULL, optv[i], &dir_stbuf, 0, 0);
16524
Findjob_destroy(&job, 0);
16527
ret= Xorriso_getfattr(xorriso, NULL, optv[i], NULL, flag & 8);
16529
ret= Xorriso_getfacl(xorriso, NULL, optv[i], NULL, 0);
16531
if(ret>0 && !xorriso->request_to_abort)
16532
continue; /* regular bottom of loop */
16534
fret= Xorriso_eval_problem_status(xorriso, ret, 1|2);
16542
Xorriso_opt_args(xorriso, "-getfacl", argc, argv, *idx, &end_idx,
16543
&optc, &optv, 256);
16544
Findjob_destroy(&job, 0);
16547
return(!was_failure);
16552
int Xorriso_option_gid(struct XorrisO *xorriso, char *gid, int flag)
16556
xorriso->do_global_gid= 0;
16557
if(gid[0]==0 || strcmp(gid,"-")==0)
16559
ret= Xorriso_convert_gidstring(xorriso, gid, &(xorriso->global_gid), 0);
16561
xorriso->do_global_gid= 1;
16566
/* Option -grow_blindly */
16567
int Xorriso_option_grow_blindly(struct XorrisO *xorriso, char *msc2, int flag)
16572
if(msc2[0]==0 || msc2[0]=='-' || strcmp(msc2, "off")==0) {
16573
xorriso->grow_blindly_msc2= -1;
16576
num= Scanf_io_size(msc2, 0);
16578
if(msc2[l-1]<'0' || msc2[l-1]>'9')
16580
xorriso->grow_blindly_msc2= num;
16585
/* Option -hardlinks "on"|"off" */
16586
int Xorriso_option_hardlinks(struct XorrisO *xorriso, char *mode, int flag)
16589
char what_data[SfileadrL], *what, *what_next;
16591
if(Sfile_str(what_data, mode, 0)<=0) {
16592
sprintf(xorriso->info_text,
16593
"-hardlinks: mode string is much too long (%d)",
16594
(int) strlen(mode));
16595
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
16598
for(what= what_data; what != NULL; what= what_next) {
16599
what_next= strchr(what, ':');
16600
if(what_next != NULL) {
16604
if(strcmp(what, "off") == 0) {
16605
Xorriso_finish_hl_update(xorriso, 0);
16606
xorriso->ino_behavior|= 1 | 2 | 4;
16607
xorriso->ino_behavior&= ~8;
16608
} else if(strcmp(what, "on") == 0) {
16609
xorriso->ino_behavior&= ~(1 | 2 | 4 | 8);
16610
} else if(strcmp(what, "without_update") == 0) {
16611
Xorriso_finish_hl_update(xorriso, 0);
16612
xorriso->ino_behavior&= ~(1 | 2 | 4);
16613
xorriso->ino_behavior|= 8;
16614
} else if(strcmp(what, "start_update") == 0) {
16615
xorriso->ino_behavior&= ~(1 | 2 | 4 | 8);
16616
ret= Xorriso_make_di_array(xorriso, 1);
16619
} else if(strcmp(what, "end_update") == 0) {
16620
Xorriso_finish_hl_update(xorriso, 0);
16621
} else if(strcmp(what, "perform_update") == 0) {
16622
Xorriso_finish_hl_update(xorriso, 0);
16623
} else if(strcmp(what, "start_extract") == 0) {
16624
xorriso->ino_behavior&= ~(1 | 2 | 4);
16625
ret= Xorriso_make_hln_array(xorriso, 1);
16628
} else if(strcmp(what, "end_extract") == 0) {
16629
Xorriso_destroy_hln_array(xorriso, 0);
16630
} else if(strcmp(what, "discard_extract") == 0) {
16631
Xorriso_destroy_hln_array(xorriso, 0);
16632
} else if(strcmp(what, "normal_extract") == 0) {
16633
xorriso->ino_behavior&= ~16;
16634
} else if(strcmp(what, "cheap_sorted_extract") == 0) {
16635
xorriso->ino_behavior|= 16;
16637
sprintf(xorriso->info_text, "-hardlinks: unknown mode '%s' in '%s'",
16639
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
16643
if(xorriso->ino_behavior & 2)
16644
Xorriso_option_compliance(xorriso, "new_rr", 0);
16650
/* Option -help and part of -prog_help */
16651
int Xorriso_option_help(struct XorrisO *xorriso, int flag)
16653
static char text[][80]={
16655
#ifdef Xorriso_no_helP
16657
"This binary program does not contain a help text.",
16658
"If available, read: man 1 xorriso",
16662
"This program creates, loads, manipulates and writes ISO 9660 filesystem",
16663
"images with Rock Ridge extensions. Write targets can be drives with optical",
16664
"media or local filesystem objects.",
16666
"Preparation options:",
16667
"Drive addresses are either /dev/... as listed with option -devices or",
16668
"disk files, eventually with prefix \"stdio:\" if non-CD-drive in /dev tree.",
16669
"E.g. /dev/sr0 , /tmp/pseudo_drive , stdio:/dev/sdc",
16670
" -dev address Set input and output drive and load eventual ISO image.",
16671
" Set the image expansion method to growing.",
16672
" -indev address Set input drive and load eventual ISO image. Use expansion",
16673
" methods modifying or blind growing.",
16674
" -outdev address",
16675
" Set output drive and use modifying or blind growing.",
16676
" -drive_class \"harmless\"|\"banned\"|\"risky\"|\"clear_list\" disk_pattern",
16677
" Add a drive path pattern to one of the safety lists or make",
16678
" those lists empty. Defaulty entry in \"risky\" is \"/dev\".",
16679
" -grow_blindly \"off\"|predicted_nwa",
16680
" Switch between modifying and blind growing.",
16681
" -load \"session\"|\"track\"|\"lba\"|\"sbsector\"|\"volid\"|\"auto\" id",
16682
" Load a particular (outdated) ISO image from a -dev or",
16683
" -indev which hosts more than one session.",
16684
" -rom_toc_scan \"on\"|\"force\"|\"off\"[:\"emul_on\"|\"emul_off\"]",
16685
" Enable scanning for ISO sessions on read-only drives/media",
16686
" resp. on overwriteable media with emulated TOC.",
16687
" -calm_drive \"in\"|\"out\"|\"all\"|\"on\"|\"off\"",
16688
" Reduce drive noise until it gets actually used again.",
16689
" -assert_volid pattern severity",
16690
" Accept input image only if its volume id matches pattern.",
16691
" -charset name Set the character set name to be used for file name",
16692
" conversion from and to media.",
16693
" -in_charset name",
16694
" Like -charset but only for conversion from media.",
16695
" -auto_charset \"on\"|\"off\"",
16696
" Enable writing and reading of character set name in image.",
16697
" -out_charset name",
16698
" Like -charset but only for conversion to media.",
16699
" -local_charset name",
16700
" Override system assumption of the local character set name.",
16701
" -hardlinks mode[:mode ...]",
16702
" Enable resp. disable recording and restoring of hard links.",
16703
" Modes are \"on\", \"off\", \"perform_update\",",
16704
" \"without_update\", \"discard_extract\",",
16705
" \"cheap_sorted_extract\", \"normal_extract\"",
16706
" -acl \"on\"|\"off\"",
16707
" Enable resp. disable reading and writing of ACLs.",
16708
" -xattr \"on\"|\"off\"",
16709
" Enable resp. disable reading and writing of xattr.",
16711
" Shortcut for: -hardlinks on -acl on -xattr on -md5 on",
16712
" -disk_dev_ino \"on\"|\"ino_only\"|\"off\"",
16713
" Enable resp. disable recording of disk file dev_t and ino_t",
16714
" and their use in file comparison.",
16715
" -md5 \"on\"|\"all\"|\"off\"",
16716
" Enable resp. disable processing of MD5 checksums.",
16717
" -scdbackup_tag list_path record_name",
16718
" Enable production of scdbackup tag with -md5 on",
16719
" -ban_stdio_write",
16720
" Allow for writing only the usage of optical drives.",
16721
" -blank \"fast\"|\"all\"|\"deformat\"|\"deformat_quickest\"",
16722
" Blank media resp. invalidate ISO image on media.",
16723
" -format \"as_needed\"|\"full\"|\"fast\"|\"by_index_#\"|\"by_size_#\"",
16724
" Format BD-RE, BD-R, DVD-RAM, DVD-RW, DVD+RW.",
16725
" -volid volume_id",
16726
" Specifies the volume ID text. (32 chars out of [A-Z0-9_])",
16727
" -volset_id name",
16728
" Specifies the volume set id. (128 chars)",
16729
" -publisher name",
16730
" Specifies the publisher name. (128 chars)",
16731
" -application_id name",
16732
" Specifies the application id. (128 chars)",
16733
" -system_id name",
16734
" Specifies the system id for the System Area. (32 chars)",
16735
" -volume_date type timestring",
16736
" Specifies volume timestamps. [\"c\",\"m\",\"x\",\"f\",\"uuid\"]",
16737
" -joliet \"on\"|\"off\"",
16738
" Generate Joliet info additional to Rock Ridge info.",
16739
" -compliance rule[:rule...]",
16740
" Allow more or less harmless deviations from strict standards",
16742
" -boot_image \"any\"|\"isolinux\"|\"grub\"",
16743
" \"discard\"|\"keep\"|\"patch\"|\"dir=\"|\"bin_path=\"|\"cat_path=\"",
16744
" |\"load_size=\"|\"system_area=\"|\"partition_table=on|off\"",
16745
" Whether to discard or keep an exiting El Torito boot image.",
16746
" ISOLINUX can be made bootable by dir=/ or dir=/isolinux",
16747
" or dir=/boot/isolinux. Others, like GRUB, by bin_path=...",
16748
" and cat_path=...",
16749
" The boot image and its helper files need to be added to the",
16750
" ISO image by the usual commands like -map or -add.",
16751
" system_area= and partition_table= are for MBR based booting",
16752
" from USB stick. The system_area= file needs not to be added.",
16754
" -uid uid User id to be used for the whole multi-session ISO image.",
16755
" -gid gid Group id for the same purpose.",
16757
" -devices Show list of available optical drives and their addresses.",
16759
" -toc Show media specific table of content (sessions).",
16761
" -mount_cmd drive entity id path",
16762
" Print to result channel a command suitable to mount the",
16763
" depicted entity (see -load) at the given directory path.",
16764
" -mount_opts \"exclusive\"|\"shared\"",
16765
" Set options for -mount and -mount_cmd.",
16766
" -session_string drive entity id \"linux:\"path|\"freebsd:\"path|form",
16767
" Print foreign OS command or custom line.",
16769
" -list_formats Show media specific list of format descriptors.",
16771
" -list_profiles \"in\"|\"out\"|\"all\"",
16772
" Show list of media types supported by indev resp. outdev.",
16773
" -print_size Print the foreseeable consumption by next -commit.",
16775
" -tell_media_space",
16776
" Print foreseeable available space on output media",
16777
" -pvd_info Print various id strings of the loaded ISO image."
16779
"Options with variable length path list [...] need the list delimiter text",
16780
"as end mark if they are followed by another option. By default this delimiter",
16781
"is \"--\". In dialog and with options read from files, the line end serves",
16782
"as such a mark. With program arguments this mark can be omitted only with",
16783
"the last option in the list of arguments.",
16784
"For brevity the list delimiter is referred as \"--\" throughout this text.",
16786
" -list_delimiter text Set the list delimiter to be used instead of \"--\"",
16787
" It has to be a single word, must not be empty, not longer",
16788
" than 80 characters, may mot contain quotation marks.",
16790
"Manipulation options:",
16791
"disk_path is a path to an object in the local filesystem tree.",
16792
"iso_rr_path is the Rock Ridge name of a file object in the ISO image.",
16793
"pathspec is either a disk_path or (if allowed) a pair: iso_rr_path=disk_path",
16794
"Options marked by [***] have variable argument length and perform pattern",
16795
"expansion if enabled by -iso_rr_pattern resp. -disk_pattern.",
16797
" -pathspecs \"on\"|\"off\" Allow or disallow pathspecs of form ",
16798
" iso_rr_path=disk_path . Only \"off\" allows eventual",
16799
" -disk_pattern expansion.",
16800
" -add pathspec [...] | disk_path [***]",
16801
" Insert the given files or directory trees from",
16802
" filesystem into the ISO image. Much like mkisofs.",
16803
" -add_plainly \"none\"|\"unknown\"|\"dashed\"|\"any\"",
16804
" Whether to add lonely arguments as pathspec resp. disk_path.",
16805
" -path_list disk_path",
16806
" Like -add but read the pathspecs from file disk_path.",
16807
" -quoted_path_list disk_path",
16808
" Like -path_list but with line rules as -dialog \"on\".",
16810
" -map disk_path iso_rr_path",
16811
" Insert disk file object at the given iso_rr_path.",
16812
" -map_single disk_path iso_rr_path",
16813
" Like -map but with directory do not insert its sub tree.",
16814
" -map_l disk_prefix iso_rr_prefix disk_path [***]",
16815
" Performs -map with each disk_path.",
16816
" -update disk_path iso_rr_path",
16817
" Compare both file objects and do what is necessary to make",
16818
" iso_rr_path a matching copy of disk_path.",
16819
" -update_r disk_path iso_rr_path",
16820
" Like -update but affecting all files below directories.",
16821
" -update_l disk_prefix iso_rr_prefix disk_path [***]",
16822
" Performs -update_r with each disk_path.",
16823
" -cut_out disk_path byte_offset byte_count iso_rr_path",
16824
" Map a byte interval of a regular disk file into a regular",
16825
" file in the ISO image.",
16827
" -cpr disk_path [***] iso_rr_path",
16828
" Insert the given files or directory trees from filesystem",
16829
" into the ISO image, according to the rules of cp -r.",
16831
" -rm iso_rr_path [***]",
16832
" Delete the given files from the ISO image.",
16833
" -rm_r iso_rr_path [***]",
16834
" Delete the given directory trees from ISO image.",
16835
" -mv iso_rr_path [***] iso_rr_path",
16836
" Rename the given file objects in the ISO tree to the last",
16837
" argument in the list.",
16838
" -chown uid iso_rr_path [***]",
16839
" Equivalent to chown in the ISO image.",
16840
" -chown_r uid iso_rr_path [***]",
16841
" Like -chown but affecting all files below directories.",
16842
" -chgrp gid iso_rr_path [***]",
16843
" Equivalent to chgrp in the ISO image.",
16844
" -chgrp_r gid iso_rr_path [***]",
16845
" Like -chgrp but affecting all files below directories.",
16846
" -chmod mode iso_rr_path [***]",
16847
" Equivalent to chmod in the ISO image.",
16848
" -chmod_r mode iso_rr_path [***]",
16849
" Like -chmod but affecting all files below directories.",
16850
" -setfacl acl_text iso_rr_path [***]",
16851
" Replace the permissions and eventual ACL of the given files",
16852
" in the ISO image by the ACL which is defined by acl_text.",
16853
" -setfacl_r acl_text iso_rr_path [***]",
16854
" Like -setfacl but affecting all files below directories.",
16855
" -setfacl_list disk_path",
16856
" Read output of getfacl from file disk_path. Set owner,",
16857
" group and ACL of the iso_rr_path given by line \"# file:\".",
16858
" -setfattr [-]name value iso_rr_path [***]",
16859
" Set xattr pair with the given name to the given value, or",
16860
" delete pair if name is prefixed with \"-\" and value is",
16862
" -setfattr_r [-]name value iso_rr_path [***]",
16863
" Like -setfattr but affecting all files below directories.",
16864
" -setfattr_list disk_path",
16865
" Read output of getfattr from file disk_path. Replace the",
16866
" xattr of the iso_rr_path given by line \"# file:\".",
16867
" -alter_date type timestring iso_rr_path [***]",
16868
" Alter the date entries of a file in the ISO image. type is",
16869
" one of \"a\", \"m\", \"b\" for:",
16870
" access time, modification time, both times.",
16871
" -alter_date_r type timestring iso_rr_path [***]",
16872
" Like -alter_date but affecting all files below directories.",
16873
" -find iso_rr_path [test [op] [test ...]] [-exec action [params]]",
16874
" performs an action on files below the given directory in",
16875
" the ISO image. Tests:",
16876
" -name pattern, -wholename pattern, -type b|c|d|p|f|l|s|e,",
16877
" -pending_data, -lba_range start count, -damaged,",
16878
" -has_acl, -has_xattr, -has_aaip, -has_filter, -has_md5",
16879
" -has_any_xattr, -prune, -decision yes|no, -true, -false",
16880
" Operators: -not, -or, -and, -sub, (, -subend, ),",
16881
" -if, -then, -elseif, -else, -endif",
16882
" Action may be one of: echo, chown, chown_r, chgrp, chgrp_r",
16883
" chmod, chmod_r, alter_date, alter_date_r, lsdl, compare,",
16884
" rm, rm_r, compare, update, report_damage, report_lba,",
16885
" getfacl, setfacl, getfattr, setfattr, get_any_xattr,",
16886
" get_md5, check_md5, make_md5, set_filter, show_stream,",
16887
" mkisofs_r, find.",
16888
" params are their arguments except iso_rr_path.",
16889
" -mkdir iso_rr_path [...]",
16890
" Create empty directories if they do not exist yet.",
16891
" -rmdir iso_rr_path [***]",
16892
" Delete empty directories.",
16893
" -- Default list delimiter marking the end of action argument",
16894
" list. It may be changed by option -list_delimiter.",
16896
" -not_paths disk_path [***]",
16897
" Add the given paths to the list of excluded absolute paths.",
16898
" -not_leaf pattern",
16899
" Add the given pattern to the list of leafname exclusions.",
16900
" -not_list disk_path",
16901
" Read lines from disk_path and use as -not_paths (with \"/\")",
16902
" or as -not_leaf (without \"/\").",
16903
" -quoted_not_list disk_path",
16904
" Like -not_list but with line rules as -dialog \"on\".",
16905
" -not_mgt \"reset\"|\"on\"|\"off\"|\"param_on\"|\"subtree_on\"|\"ignore_on\"",
16906
" Control effect of exclusion lists.",
16907
" -follow \"on\"|\"pattern:param:link:mount:limit=#\"|\"default\"|\"off\"",
16908
" Follow symbolic links and mount points within disk_path.",
16909
" -overwrite \"on\"|\"nondir\"|\"off\"",
16910
" Allow or disallow to overwrite existing files in ISO image.",
16911
" -split_size number[\"k\"|\"m\"]",
16912
" Set the threshold for automatic splitting of regular files.",
16913
" -reassure \"on\"|\"tree\"|\"off\"",
16914
" If \"on\" then ask the user for \"y\" or \"n\" with any",
16915
" file before deleting or overwriting it in the ISO image.",
16918
"External filter processes may produce synthetic file content by reading the",
16919
"original content from stdin and writing to stdout whatever they want.",
16921
#ifdef Xorriso_allow_external_filterS
16923
" -external_filter name option[:option] program_path [arguments] --",
16924
" Define an external filter. Options are: suffix=...: ",
16925
" remove_suffix:if_nonempty:if_reduction:if_block_reduction.",
16926
" -unregister_filter name",
16927
" Undefine an external filter.",
16928
" -close_filter_list",
16929
" Irrevocably ban -external_filter and -unregister_filter.",
16933
"Sorry: The use of external filters was not enabled at compile time.",
16934
" E.g. by ./configure option --enable-external-filters",
16936
#endif /* ! Xorriso_allow_external_filterS */
16938
" -set_filter name iso_rr_path [***]",
16939
" Apply a defined filter to the given data files.",
16940
" Special name \"--remove-all-filters\" revokes filtering.",
16941
" Builtin filters are --gzip , --gunzip, --zisofs .",
16942
" -set_filter_r name iso_rr_path [***]",
16943
" Like -set_filter but affecting all files below directories.",
16945
"zisofs is a compression format which is recognized by some Linux kernels.",
16946
"xorriso supports it by builtin filter \"--zisofs\" which is to be applied by",
16947
"the user, and by \"--zisofs-decode\" which is applied automatically when",
16948
"compressed content is detected with a file in the ISO image.",
16949
" -zisofs option[:options]",
16950
" Set global zisofs parameters:",
16951
" level=0|...|9 , block_size=32k|64k|128k , by_magic=on|off",
16953
"Write-to-media options:",
16954
" -rollback Discard the manipulated ISO image and reload it.",
16956
" -commit Perform the write operation and then perform -dev outdrive.",
16957
" Hint: To perform a final write operation with no new -dev",
16958
" and no new loading of image, execute option -end.",
16959
" -commit_eject \"in\"|\"out\"|\"all\"|\"none\"",
16960
" Like -commit but rather eject than load image from outdrive.",
16961
" Give up any unejected drive afterwards.",
16962
" -close \"on\"|\"off\"",
16963
" If \"on\" then mark the written media as not appendable.",
16964
" -padding number[\"k\"|\"m\"]",
16965
" Append extra bytes to image stream. (Default is 300k)",
16966
" -dummy \"on\"|\"off\"",
16967
" If \"on\" simulate burning. Refuse if media cannot simulate.",
16968
" -speed number[\"k/s\"|\"m/s\"|\"[x]CD\"|\"[x]DVD\"|\"[x]BD\"]",
16969
" Set the burn speed. Default is 0 = maximum speed.",
16970
" -stream_recording \"on\"|\"off\"",
16971
" Try to circumvent slow checkread on DVD-RAM, BD-RE, BD-R.",
16972
" -dvd_obs \"default\"|\"32k\"|\"64k\"",
16973
" Set number of bytes per DVD/BD write operation.",
16974
" -stdio_sync \"on\"|\"off\"|number",
16975
" Set number of bytes after which to force output to stdio",
16976
" pseudo drives. \"on\" is the same as 16m.",
16977
" -fs number[\"k\"|\"m\"]",
16978
" Set the size of the fifo buffer. (Default is 4m)",
16979
" -eject \"in\"|\"out\"|\"all\"",
16980
" Immediately eject the media in -indev, resp. -outdev,",
16983
"Navigation options:",
16985
" -cd iso_rr_path Change working directory in the ISO image. iso_rr_paths",
16986
" which do not begin with '/' will be inserted beginning at",
16987
" the path given with -cd. -ls patterns will eventually",
16988
" looked up at this path.",
16989
" -cdi disk_path Same as -cd disk_path",
16990
" -cdx disk_path Change the current working directory in the local",
16991
" filesystem. disk_paths which do not begin with '/'",
16992
" will be looked up beginning at the path given with -cdx.",
16993
" -lsx patterns will eventually be looked up at this path.",
16994
" -pwd tells the current working directory in the ISO image.",
16995
" -pwdi same as -pwd.",
16996
" -pwdx tells the current working directory in the local filesystem.",
16998
" -iso_rr_pattern \"on\"|\"ls\"|\"off\"",
16999
" Enable or disable pattern expansions for ISO image commands",
17000
" marked by [***]. \"ls\" restricts it to -ls and -du.",
17001
" -disk_pattern \"on\"|\"ls\"|\"off\"",
17002
" Enable or disable pattern expansions for local filesystem",
17003
" commands marked by [***]. \"ls\" restricts to -ls*x and -du*x.",
17005
" -ls pattern [***] lists files of the ISO image which match one of the",
17006
" given shell parser patterns. (I.e. wildcards '*' '?').",
17007
" Directories are listed by their content.",
17008
" -lsd pattern [***] like -ls but listing directories as single items.",
17009
" -lsl pattern [***] like -ls but also telling some file attributes.",
17010
" -lsdl pattern [***] like -lsd but also telling some file attributes.",
17012
" -lsx pattern [***] lists files of the local filesystem which match one",
17013
" of the patterns. Directories are listed by their content.",
17014
" -lsdx pattern [***] like -lsx but listing directories as single items.",
17015
" -lslx pattern [***] like -lsx but also telling some file attributes.",
17016
" -lsdlx pattern [***] like -lsdx but also telling some file attributes.",
17017
" -getfacl pattern [***] list eventual ACLs of the given files.",
17018
" -getfacl_r pattern [***] like -getfacl but listing whole file trees.",
17019
" -getfattr pattern [***] list eventual xattr of the given files.",
17020
" -getfxattr_r pattern [***] like -getfxattr but listing whole file trees.",
17022
" -du pattern [***] recursively lists sizes of files or directories in the",
17023
" ISO image which match one of the shell parser patterns.",
17024
" -dux pattern [***] recursively lists sizes of files or directories in the",
17025
" local filesystem which match one of the shell parser",
17027
" -dus pattern [***] like -du but summing up subdirectories without",
17028
" listing them explicitely.",
17029
" -dusx pattern [***] like -dux but summing up subdirectories without",
17030
" listing them explicitely.",
17032
" -findx disk_path [-name pattern] [-type t] [-exec action [params]]",
17033
" Like -find but operating on local filesystem. Most -exec",
17034
" actions are defaulted to action echo. Supported actions are:",
17035
" in_iso, not_in_iso, is_full_in_iso, add_missing,",
17038
" -compare disk_path iso_rr_path",
17039
" compare attributes and in case of regular data files the",
17040
" content of filesystem object and ISO object.",
17041
" -compare_r disk_path iso_rr_path",
17042
" Like -compare but affecting all files below directories.",
17043
" -compare_l disk_prefix iso_rr_prefix disk_path [***]",
17044
" Performs -compare_r with each disk_path.",
17046
" -show_stream iso_rr_path [***]",
17047
" Show content stream chain of data files in the ISO image.",
17048
" -show_stream_r iso_rr_path [***]",
17049
" Like -show_stream but affecting all files below directories.",
17051
"Restore options which copy file objects from ISO image to disk filesystem:",
17052
" -osirrox \"on\"|\"device_files\"|\"off\"|\"banned\"",
17053
" [:\"concat_split_on\"|\"concat_split_off\"]",
17054
" [:\"auto_chmod_on\"|\"auto_chmod_off\"]",
17055
" [:\"sort_lba_on\"|\"sort_lba_off\"]",
17056
" By default \"off\" the inverse operation of xorriso from ISO",
17057
" image to disk filesystem is disabled. \"on\" allows xorriso",
17058
" to create, overwrite, delete files in the disk filesystem.",
17059
" \"banned\" is irrevocably \"off\".",
17060
" -extract iso_rr_path disk_path",
17061
" Copy tree under iso_rr_path onto disk address disk_path.",
17062
" This avoids the pitfalls of cp -r addressing rules.",
17063
" -extract_l iso_rr_prefix disk_prefix iso_rr_path [***]",
17064
" Perform -extract with each iso_rr_path.",
17065
" -extract_single iso_rr_path disk_path",
17066
" Like -extract but with directory do not restore sub tree.",
17067
" -extract_cut iso_rr_path byte_offset byte_count disk_path",
17068
" Copy a byte interval from iso_rr_path to disk_path.",
17069
" This is governed in part by -check_media_defaults.",
17070
" -cpx iso_rr_path [***] disk_path",
17071
" Copy leaf file objects from ISO image to disk filesystem.",
17072
" -cpax iso_rr_path [***] disk_path",
17073
" Like -cpx but trying to restore timestamps and ownership.",
17074
" -cp_rx iso_rr_path [***] disk_path",
17075
" Copy directory trees from ISO image to disk filesystem.",
17076
" -cp_rax iso_rr_path [***] disk_path",
17077
" Like -cp_rx but trying to restore timestamps and ownership.",
17078
" -paste_in iso_rr_path disk_path byte_offset byte_count",
17079
" Copy ISO file content into a byte interval of a disk file.",
17080
" -mount drive entity id path",
17081
" Like -mount_cmd but actually performing that command if",
17082
" not setuid or setgid is active.",
17084
"Evaluation of readability:",
17085
" -check_media [options] --",
17086
" Try to read data blocks from media and report about the",
17087
" outcome. Several options modify the behavior:",
17088
" use=indev|outdev , what=track|session ,",
17089
" min_lba=blockadr , max_lba=blockadr ,",
17090
" abort_file=path , time_limit=seconds , item_limit=number ,",
17091
" retry=on|off|default , data_to=filepath ,",
17092
" sector_map=filepath , map_with_volid=on|off ,",
17093
" patch_lba0=on|off|force|blockadr[:force] ,",
17094
" report=blocks|files|blocks_files event=severity ,",
17095
" bad_limit=quality , slow_limit=seconds , chunk_size=bytes",
17096
" -check_media_defaults [options] --",
17097
" Preset options for runs of -check_media and -extract_cut.",
17099
"Compatibility emulation (argument list may be ended by list delimiter --):",
17100
" -as mkisofs [-help|-version|-o|-R|-r|-J|-V|-P|-f|-m|-exclude-list|",
17101
" -no-pad|-M|-C|-graft-points|-path-list|pathspecs|-z|",
17102
" -no-emul-boot|-b|-c|-boot-info-table|-boot-load-size|-G]",
17103
" Perform some mkisofs gestures, understand pathspecs as mkisofs",
17104
" does. Commit happens outside emulation at usual occasions.",
17105
" -as cdrecord [-help|-v|dev=|speed=|blank=|fs=|-eject|-atip|padsize=|-multi]",
17107
" Perform some cdrecord gestures, eventually write at most one",
17108
" data track to blank, appendable or overwriteable media.",
17109
" -pacifier \"xorriso\"|\"cdrecord\"|\"mkisofs\"",
17110
" Choose format of UPDATE pacifier during write operations.",
17112
"General options:",
17113
" -help Print this text",
17114
" -abort_on severity Set the threshhold for events to abort the program.",
17115
" Useful severities: NEVER, ABORT, FATAL, FAILURE, SORRY, WARNING",
17116
" -return_with severity exit_value Set the threshhold for events to return",
17117
" at program end the given exit_value even if not aborted.",
17118
" exit_value may be 0 or 32 to 63.",
17119
" -report_about severity Set the threshhold for events to be reported.",
17120
" Use -abort_on severities or: HINT, NOTE, UPDATE, DEBUG, ALL",
17121
" -error_behavior \"image_loading\"|\"file_extraction\" behavior",
17122
" Behavior \"best_effort\" is most endurant but may produce",
17123
" results which are correct only on the first glimpse.",
17124
" -dialog \"on\"|\"off\"|\"single_line\"",
17125
" After all arguments are processed, enter dialog mode.",
17126
" \"single_line\" does not support newline characters within",
17127
" open quotation marks and no line continuation by trailing \\.",
17128
" -page len width Prompt user after len output lines (0=no prompt).",
17129
" width (default 80) can adjust line number computation",
17130
" to the output terminal's line width.",
17131
#ifdef Xorriso_with_readlinE
17132
" -use_stdin Use raw standard input even if libreadline is available",
17133
" -use_readline Use libreadline for dialog if available",
17134
" -history text Copy text into libreadline history. This command",
17135
" itself is not copied to the history list.",
17136
#endif /* Xorriso_with_readlinE */
17137
" -backslash_codes \"on\"|\"off\"|",
17138
" \"in_double_quotes\"|\"in_quotes\"|\"with_quoted_input\"",
17139
" [:\"with_program_arguments\"][:\"encode_output\"]",
17140
" Disable or enable interpretation of \\a \\b \\e \\f \\n \\r \\t \\v",
17141
" \\\\ \\NNN \\xNN \\cC in input or program arguments.",
17142
" -pkt_output \"on\"|\"off\" Direct output to stdout and prefix each line",
17143
" by a short header which tells channel id and a mode number.",
17144
" Each such output packet is finalized by a newline.",
17145
" Channel ids are 'R:' for result lines, 'I:' for notes",
17146
" and error messages, 'M:' for -mark texts. Bit 0 of the",
17147
" mode number tells whether the newline is also part of the",
17148
" packet payload. Example of a info message with newline:",
17149
" I:1: enter option text :",
17150
" -pkt_output:on is intended for use by frontend programs.",
17151
" -logfile channel fileaddress Copy output of a channel to the given file.",
17152
" channel may be 'R','I','M' as with -pkt_output or '.'",
17153
" for the consolidated -pkt_output stream.",
17154
" -mark text If text is not empty it will get put out each time an",
17155
" option is completed.",
17156
" -temp_mem_limit number[\"k\"|\"m\"]",
17157
" Set the maximum size for pattern expansion. (Default is 16m)",
17158
" -prog text Use text as this program's name in subsequent messages",
17159
" -prog_help text Use text as this program's name and perform -help",
17160
" -status mode|filter Report the current settings of persistent options.",
17162
" short... print only important or altered options",
17163
" long ... print options even if they have default settings",
17164
" long_history like long plus -history: lines",
17165
" Filters begin with '-' and are compared literally against the",
17166
" output lines of -status long_history. A line is put out only",
17167
" if its start matches the filter.",
17168
" -status_history_max number Maximum number of history lines to be reported",
17169
" with -status:long_history",
17170
" -options_from_file fileaddress",
17171
" Reads lines from the given file and executes them as program",
17173
" -no_rc Only if used as first command line argument this option",
17174
" prevents reading and interpretation of startup files.",
17176
" Print a text to result channel.",
17178
" Wait for Enter key resp. for a line of input at stdin.",
17179
" -errfile_log mode path|channel",
17180
" Log disk paths of files involved in problem events.",
17181
" -session_log path",
17182
" Set path of a file where a log record gets appended after",
17183
" each session. Form: timestamp start_lba size volume-id",
17184
" -scsi_log \"on\"|\"off\"",
17185
" Enable or disable logging of SCSI commands to stderr.",
17186
" # any text Is ignored. In dialog mode the input line will be stored in",
17187
" the eventual readline history, nevertheless.",
17188
" -version Tell program and version number",
17189
" -end End program. Commit eventual pending changes.",
17191
" End program. Discard pending changes.",
17194
"Option -page causes a user prompt after the given number of result lines.",
17195
"Empty input resumes output until the next prompt. Other input may be:",
17196
" @ suppresses paging until the current action is done",
17197
" @@ suppresses further result output but continues the action",
17198
" @@@ aborts the current action",
17199
" other aborts the current action and executes input as new",
17203
#endif /* ! Xorriso_no_helP */
17205
"@ENDE_OF_HELPTEXT_(HOPEFULLY_UNIQUELY_SILLY_TEXT)@"
17211
Xorriso_restxt(xorriso,"\n");
17212
sprintf(xorriso->result_line,"usage: %s [settings|actions]\n",
17213
xorriso->progname);
17214
Xorriso_result(xorriso,0);
17215
Xorriso_restxt(xorriso,"\n");
17216
for(pass=0;pass<1;pass++) {
17221
if(strcmp(tpt,"@ENDE_OF_HELPTEXT_(HOPEFULLY_UNIQUELY_SILLY_TEXT)@")==0)
17223
sprintf(xorriso->result_line,"%s\n",tpt);
17224
Xorriso_result(xorriso,0);
17225
if(xorriso->request_to_abort)
17229
Xorriso_restxt(xorriso,"\n");
17234
/* Option -history */
17235
int Xorriso_option_history(struct XorrisO *xorriso, char *line, int flag)
17237
Xorriso_dialog_input(xorriso,line,strlen(line)+1,2);
17242
/* Option -iso_rr_pattern "on"|"ls"|"off" */
17243
int Xorriso_option_iso_rr_pattern(struct XorrisO *xorriso, char *mode,int flag)
17245
if(strcmp(mode, "off")==0)
17246
xorriso->do_iso_rr_pattern= 0;
17247
else if(strcmp(mode, "on")==0)
17248
xorriso->do_iso_rr_pattern= 1;
17249
else if(strcmp(mode, "ls")==0)
17250
xorriso->do_iso_rr_pattern= 2;
17252
sprintf(xorriso->info_text, "-iso_rr_pattern: unknown mode '%s'", mode);
17253
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
17260
/* Option -joliet "on"|"off" */
17261
int Xorriso_option_joliet(struct XorrisO *xorriso, char *mode, int flag)
17263
if(strcmp(mode, "off")==0)
17264
xorriso->do_joliet= 0;
17265
else if(strcmp(mode, "on")==0)
17266
xorriso->do_joliet= 1;
17268
sprintf(xorriso->info_text, "-joliet: unknown mode '%s'", mode);
17269
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
17276
/* Option -list_delimiter */
17277
int Xorriso_option_list_delimiter(struct XorrisO *xorriso, char *text,
17284
sprintf(xorriso->info_text,
17285
"-list_delimiter: New delimiter text is empty");
17286
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
17289
if(strlen(text) > 80) {
17290
sprintf(xorriso->info_text,
17291
"-list_delimiter: New delimiter text is too long");
17292
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
17295
ret= Sfile_make_argv(xorriso->progname, text, &argc, &argv, 4);
17298
sprintf(xorriso->info_text,
17299
"-list_delimiter: New delimiter text contains more than one word");
17300
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
17302
Sfile_make_argv(xorriso->progname, text, &argc, &argv, 2);
17306
if(strchr(text, '"') != NULL || strchr(text, '\'') != NULL) {
17307
sprintf(xorriso->info_text,
17308
"-list_delimiter: New delimiter text contains quotation marks");
17309
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
17312
strcpy(xorriso->list_delimiter, text);
17317
/* Option -list_formats */
17318
int Xorriso_option_list_formats(struct XorrisO *xorriso, int flag)
17322
ret= Xorriso_list_formats(xorriso, 0);
17327
/* Option -list_profiles */
17328
int Xorriso_option_list_profiles(struct XorrisO *xorriso, char *which,
17334
if(strncmp(which,"in",2)==0)
17336
else if(strncmp(which,"out",3)==0)
17341
ret= Xorriso_toc(xorriso, 1 | 16 | 32);
17343
Xorriso_list_profiles(xorriso, 0);
17345
if((mode & 2) && xorriso->in_drive_handle != xorriso->out_drive_handle) {
17346
ret= Xorriso_toc(xorriso, 1 | 2 | 16 | 32);
17348
Xorriso_list_profiles(xorriso, 2);
17354
/* Option -load session|track|sbsector value */
17355
/* @param flag bit0= with adr_mode sbsector: adr_value is possibly 16 too high
17356
@return <=0 error , 1 success, 2 revoked by -reassure
17358
int Xorriso_option_load(struct XorrisO *xorriso, char *adr_mode,
17359
char *adr_value, int flag)
17363
if(xorriso->volset_change_pending) {
17364
sprintf(xorriso->info_text,
17365
"-load: Image changes pending. -commit or -rollback first");
17366
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
17369
ret= Xorriso_reassure(xorriso, "-load", "loads an alternative image", 0);
17372
ret= Xorriso_decode_load_adr(xorriso, "-load", adr_mode, adr_value,
17373
&(xorriso->image_start_mode),
17374
xorriso->image_start_value, flag & 1);
17377
xorriso->image_start_mode|= (1<<30); /* enable non-default msc1 processing */
17378
if(strlen(xorriso->indev)>0) {
17379
ret= Xorriso_option_rollback(xorriso, 1); /* Load image, no -reassure */
17387
/* Option -logfile */
17388
int Xorriso_option_logfile(struct XorrisO *xorriso, char *channel,
17389
char *fileadr, int flag)
17391
int hflag,channel_no= 0, ret;
17393
if(channel[0]==0) {
17394
logfile_wrong_form:;
17395
sprintf(xorriso->info_text,"Wrong form. Correct would be: -logfile \".\"|\"R\"|\"I\"|\"M\" file_address");
17396
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
17400
if(channel[0]=='R')
17402
else if(channel[0]=='I')
17404
else if(channel[0]=='M')
17406
else if(channel[0]=='.')
17409
goto logfile_wrong_form;
17410
if(strcmp(fileadr,"-")==0 || fileadr[0]==0)
17412
xorriso->logfile[channel_no][0]= 0;
17413
ret= Xorriso_write_to_channel(xorriso, fileadr, channel_no, hflag);
17415
sprintf(xorriso->info_text, "Cannot open logfile: %s", fileadr);
17416
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
17417
} else if(!(hflag&(1<<15)))
17418
if(Sfile_str(xorriso->logfile[channel_no], fileadr, 0)<=0)
17424
/* Options -ls alias -lsi and -lsl alias -lsli
17425
and -lsd alias -lsdi and -lsdl alias -lsdli
17426
and -du alias -dui and -dus alias -dusi
17427
@param flag bit0= long format (-lsl , -du)
17428
bit1= do not expand patterns but use literally
17429
bit2= du rather than ls
17430
bit3= list directories as themselves (ls -d)
17432
int Xorriso_option_lsi(struct XorrisO *xorriso, int argc, char **argv,
17433
int *idx, int flag)
17435
int ret, end_idx, filec= 0, nump, i;
17436
char **filev= NULL, **patterns= NULL;
17440
end_idx= Xorriso_end_idx(xorriso, argc, argv, *idx, 1);
17441
if(xorriso->do_iso_rr_pattern==0)
17444
nump= end_idx - *idx;
17445
if((flag&2) && nump>0 ) {
17447
} else if(nump <= 0) {
17448
if(Xorriso_iso_lstat(xorriso, xorriso->wdi, &stbuf, 0)<0) {
17449
sprintf(xorriso->info_text,
17450
"Current -cd path does not yet exist in the ISO image");
17451
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
17454
if(!S_ISDIR(stbuf.st_mode)) {
17455
sprintf(xorriso->info_text,
17456
"Current -cd meanwhile points to a non-directory in ISO image");
17457
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
17460
patterns= calloc(1, sizeof(char *));
17461
if(patterns == NULL) {
17463
sprintf(xorriso->info_text,
17464
"Cannot allocate enough memory for pattern expansion");
17465
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
17466
{ret= -1; goto ex;}
17475
patterns= calloc(nump, sizeof(char *));
17478
for(i= 0; i<nump; i++) {
17479
if(argv[i + *idx][0]==0)
17482
patterns[i]= argv[i + *idx];
17486
if((flag & 1) && !(xorriso->ino_behavior & 1)) {
17487
ret= Xorriso_make_hln_array(xorriso, 0); /* for stbuf.st_nlink */
17492
ret= Xorriso_ls_filev(xorriso, xorriso->wdi, nump, argv + (*idx), mem,
17494
} else if(nump==1 && strcmp(patterns[0],"*")==0 && !(flag&4)){
17495
/* save temporary memory by calling simpler function */
17496
ret= Xorriso_ls(xorriso, (flag&1)|4);
17498
ret= Xorriso_expand_pattern(xorriso, nump, patterns, 0, &filec, &filev,
17502
ret= Xorriso_ls_filev(xorriso, xorriso->wdi, filec, filev, mem,
17511
free((char *) patterns);
17512
Sfile_destroy_argv(&filec, &filev, 0);
17518
/* Options -lsx, -lslx, -lsdx , -lsdlx , -dux , -dusx
17519
@param flag bit0= long format (-lslx , -dux)
17520
bit1= do not expand patterns but use literally
17521
bit2= du rather than ls
17522
bit3= list directories as themselves (ls -d)
17524
int Xorriso_option_lsx(struct XorrisO *xorriso, int argc, char **argv,
17525
int *idx, int flag)
17527
int ret, end_idx, filec= 0, nump, i;
17528
char **filev= NULL, **patterns= NULL;
17531
end_idx= Xorriso_end_idx(xorriso, argc, argv, *idx, 1|2);
17532
if(xorriso->do_disk_pattern==0)
17535
nump= end_idx - *idx;
17536
if((flag&2) && nump>0) {
17538
} else if(nump <= 0) {
17539
patterns= calloc(1, sizeof(char *));
17540
if(patterns == NULL) {
17542
sprintf(xorriso->info_text,
17543
"Cannot allocate enough memory for pattern expansion");
17544
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
17545
{ret= -1; goto ex;}
17554
patterns= calloc(nump, sizeof(char *));
17557
for(i= 0; i<nump; i++) {
17558
if(argv[i + *idx][0]==0)
17561
patterns[i]= argv[i + *idx];
17565
ret= Xorriso_lsx_filev(xorriso, xorriso->wdx,
17566
nump, argv + (*idx), mem, flag&(1|4|8));
17569
} else if(nump==1 && strcmp(patterns[0],"*")==0 && !(flag&4)){
17570
/* save temporary memory by calling simpler function */
17571
ret= Xorriso_ls(xorriso, (flag&1)|4);
17575
ret= Xorriso_expand_disk_pattern(xorriso, nump, patterns, 0, &filec, &filev,
17579
ret= Xorriso_lsx_filev(xorriso, xorriso->wdx, filec, filev, mem,
17588
free((char *) patterns);
17589
Sfile_destroy_argv(&filec, &filev, 0);
17595
/* Option -map , -map_single */
17596
/* @param flag bit0=do not report the added item
17597
bit1=do not reset pacifier, no final pacifier message
17598
bit5=eventually do not insert directory tree
17600
int Xorriso_option_map(struct XorrisO *xorriso, char *disk_path,
17601
char *iso_path, int flag)
17604
char eff_origin[SfileadrL], eff_dest[SfileadrL], *ipth;
17607
Xorriso_pacifier_reset(xorriso, 0);
17612
if(disk_path[0]==0) {
17613
sprintf(xorriso->info_text, "-map: Empty disk_path given");
17614
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 1);
17617
ret= Xorriso_normalize_img_path(xorriso, xorriso->wdx, disk_path, eff_origin,
17621
ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, ipth, eff_dest, 2);
17624
ret= Xorriso_graft_in(xorriso, NULL, eff_origin, eff_dest,
17625
(off_t) 0, (off_t) 0, 2|(flag&32));
17627
Xorriso_pacifier_callback(xorriso, "files added", xorriso->pacifier_count,
17628
xorriso->pacifier_total, "", 1);
17633
sprintf(xorriso->info_text, "Added to ISO image: %s '%s'='%s'\n",
17634
(ret>1 ? "directory" : "file"), (eff_dest[0] ? eff_dest : "/"),
17636
Xorriso_info(xorriso,0);
17642
/* Options -map_l , -compare_l , -update_l , -extract_l */
17643
/* @param flag bit4= do not establish and dispose xorriso->di_array
17645
bit8-11= mode 0= -map_l
17650
int Xorriso_option_map_l(struct XorrisO *xorriso, int argc, char **argv,
17651
int *idx, int flag)
17653
int ret, end_idx, optc= 0, was_failure= 1, i, fret, mode;
17654
int ns_flag= 2|4, nt_flag= 2, opt_args_flag= 2, made_di_array= 0;
17655
char source_prefix[SfileadrL], target_prefix[SfileadrL], *cmd, **optv= NULL;
17656
char eff_source[SfileadrL], eff_target[SfileadrL], *source_pt, *s_wd, *t_wd;
17657
char sfe[5*SfileadrL], **eff_src_array= NULL, **eff_tgt_array= NULL;
17660
s_wd= xorriso->wdx;
17661
t_wd= xorriso->wdi;
17662
Xorriso_pacifier_reset(xorriso, 0);
17663
mode= (flag>>8) & 15;
17672
s_wd= xorriso->wdi;
17674
t_wd= xorriso->wdx;
17678
end_idx= Xorriso_end_idx(xorriso, argc, argv, *idx, 1|2);
17679
if(end_idx - (*idx) < 3) {
17680
sprintf(xorriso->info_text, "%s: Not enough arguments given (%d < 3)", cmd,
17682
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 1);
17685
ret= Xorriso_normalize_img_path(xorriso, s_wd, argv[*idx],
17686
source_prefix, ns_flag | 64);
17689
ret= Xorriso_normalize_img_path(xorriso, t_wd, argv[(*idx)+1],
17690
target_prefix, nt_flag);
17693
ret= Xorriso_opt_args(xorriso, cmd, argc, argv, (*idx)+2, &end_idx,
17694
&optc, &optv, opt_args_flag);
17700
(xorriso->do_restore_sort_lba || !(xorriso->ino_behavior & 4))) {
17701
eff_src_array= calloc(optc, sizeof(char *));
17702
eff_tgt_array= calloc(optc, sizeof(char *));
17703
if(eff_src_array == NULL || eff_tgt_array == NULL) {
17704
Xorriso_no_malloc_memory(xorriso, NULL, 0);
17707
for(i= 0; i < optc; i++)
17708
eff_src_array[i]= eff_tgt_array[i]= NULL;
17710
if(mode == 2 && !((xorriso->ino_behavior & 2) || (flag & 16) ||
17711
xorriso->di_array != NULL)) {
17712
/* Create all-image node array sorted by isofs.di */
17713
ret= Xorriso_make_di_array(xorriso, 0);
17719
for(i= 0; i<optc; i++) {
17720
ret= Xorriso_normalize_img_path(xorriso, s_wd, optv[i],
17721
eff_source, ns_flag);
17724
strcpy(eff_target, target_prefix);
17725
source_pt= eff_source;
17726
if(source_prefix[0]) {
17727
if(strncmp(source_prefix, eff_source, strlen(source_prefix))!=0) {
17728
sprintf(xorriso->info_text,
17729
"%s: disk_path %s does not begin with disk_prefix ", cmd,
17730
Text_shellsafe(eff_source, sfe, 0));
17731
Text_shellsafe(source_prefix,
17732
xorriso->info_text+strlen(xorriso->info_text), 0);
17733
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 1);
17736
source_pt+= strlen(source_prefix);
17738
strcat(eff_target, source_pt);
17741
ret= Xorriso_option_map(xorriso, eff_source, eff_target, 2);
17743
ret= Xorriso_option_compare(xorriso, eff_source, eff_target, 2|8);
17745
ret= Xorriso_option_update(xorriso, eff_source, eff_target, 2 | 8 | 16);
17747
if(eff_src_array != NULL) {
17748
eff_src_array[i]= strdup(eff_source);
17749
eff_tgt_array[i]= strdup(eff_target);
17750
if(eff_src_array[i] == NULL || eff_tgt_array[i] == NULL) {
17751
Xorriso_no_malloc_memory(xorriso, &(eff_src_array[i]), 0);
17755
ret= Xorriso_option_extract(xorriso, eff_source, eff_target, 2 | 4);
17759
if(ret>0 && !xorriso->request_to_abort)
17760
continue; /* regular bottom of loop */
17762
fret= Xorriso_eval_problem_status(xorriso, ret, 2);
17769
if(mode == 3 && eff_src_array != NULL) {
17770
ret= Xorriso_lst_append_binary(&(xorriso->node_disk_prefixes),
17771
target_prefix, strlen(target_prefix) + 1, 0);
17774
ret= Xorriso_lst_append_binary(&(xorriso->node_img_prefixes),
17775
source_prefix, strlen(source_prefix) + 1, 0);
17778
ret= Xorriso_restore_sorted(xorriso, optc, eff_src_array, eff_tgt_array, 0);
17781
Xorriso_pacifier_callback(xorriso, "files added", xorriso->pacifier_count,
17782
xorriso->pacifier_total, "", 1);
17783
else if(mode==1 || mode==2)
17784
Xorriso_pacifier_callback(xorriso, "content bytes read",
17785
xorriso->pacifier_count, 0, "", 1);
17787
Xorriso_pacifier_callback(xorriso, "files restored",xorriso->pacifier_count,
17788
xorriso->pacifier_total, "", 1|4);
17790
Xorriso_destroy_node_array(xorriso, 0);
17792
Sfile_destroy_argv(&i, &eff_src_array, 0);
17794
Sfile_destroy_argv(&i, &eff_tgt_array, 0);
17796
Xorriso_opt_args(xorriso, cmd, argc, argv, *idx, &end_idx, &optc, &optv, 256);
17799
return(!was_failure);
17804
int Xorriso_option_mark(struct XorrisO *xorriso, char *mark, int flag)
17807
xorriso->mark_text[0]= 0;
17809
strncpy(xorriso->mark_text,mark,sizeof(xorriso->mark_text)-1);
17810
xorriso->mark_text[sizeof(xorriso->mark_text)-1]= 0;
17815
/* Option -md5 "on"|"all"|"off" */
17816
int Xorriso_option_md5(struct XorrisO *xorriso, char *mode, int flag)
17822
for(; npt!=NULL; cpt= npt+1) {
17823
npt= strchr(cpt,':');
17830
if(l == 3 && strncmp(cpt, "off", l) == 0)
17831
xorriso->do_md5&= ~31;
17832
else if(l == 2 && strncmp(cpt, "on", l) == 0)
17833
xorriso->do_md5= (xorriso->do_md5 & ~31) | 7 | 16;
17834
else if(l == 3 && strncmp(cpt, "all", l) == 0)
17835
xorriso->do_md5|= 31;
17836
else if(l == 18 && strncmp(cpt, "stability_check_on", l) == 0)
17837
xorriso->do_md5|= 8;
17838
else if(l == 19 && strncmp(cpt, "stability_check_off", l) == 0)
17839
xorriso->do_md5&= ~8;
17841
sprintf(xorriso->info_text, "-md5: unknown mode ");
17842
Text_shellsafe(cpt, xorriso->info_text, 1);
17843
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
17851
/* Option -mkdir alias -mkdiri */
17852
int Xorriso_option_mkdiri(struct XorrisO *xorriso, int argc, char **argv,
17853
int *idx, int flag)
17855
int i, end_idx, ret, was_failure= 0, fret;
17857
end_idx= Xorriso_end_idx(xorriso, argc, argv, *idx, 0);
17859
for(i= *idx; i<end_idx; i++) {
17860
ret= Xorriso_mkdir(xorriso, argv[i], 0);
17861
if(ret>0 && !xorriso->request_to_abort)
17862
continue; /* regular bottom of loop */
17864
fret= Xorriso_eval_problem_status(xorriso, ret, 1|2);
17874
return(!was_failure);
17878
/* Options -mount , -mount_cmd , -session_string */
17879
/* @param bit0= -mount_cmd: print mount command to result channel rather
17881
bit1= perform -session_string rather than -mount_cmd
17883
int Xorriso_option_mount(struct XorrisO *xorriso, char *dev, char *adr_mode,
17884
char *adr, char *cmd, int flag)
17886
int ret, entity_code= 0, m_flag;
17887
char entity_id[81], *mnt;
17892
mnt= "-session_string";
17895
if(xorriso->allow_restore <= 0) {
17896
sprintf(xorriso->info_text,
17897
"-mount: image-to-disk features are not enabled by option -osirrox");
17898
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
17901
if(xorriso->volset_change_pending) {
17902
sprintf(xorriso->info_text,
17903
"%s: Image changes pending. -commit or -rollback first", mnt);
17904
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
17908
ret= Xorriso_decode_load_adr(xorriso, mnt, adr_mode, adr,
17909
&entity_code, entity_id, 0);
17915
m_flag= (flag & 1) | 2;
17916
ret= Xorriso_mount(xorriso, dev, entity_code, entity_id, cmd, m_flag);
17921
/* Option -mount_opts option[:...] */
17922
int Xorriso_option_mount_opts(struct XorrisO *xorriso, char *mode, int flag)
17927
was= xorriso->mount_opts_flag;
17929
for(cpt= mode; npt!=NULL; cpt= npt+1) {
17930
npt= strchr(cpt,':');
17937
if(strncmp(cpt, "shared", l)==0) {
17938
xorriso->mount_opts_flag|= 1;
17939
} else if(strncmp(cpt, "exclusive", l)==0) {
17940
xorriso->mount_opts_flag&= ~1;
17944
sprintf(xorriso->info_text, "-mount_opts: unknown option '%s'", cpt);
17946
sprintf(xorriso->info_text, "-mount_opts: oversized parameter (%d)",l);
17947
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
17948
xorriso->mount_opts_flag= was;
17956
/* Option -mv alias -mvi */
17957
int Xorriso_option_mvi(struct XorrisO *xorriso, int argc, char **argv,
17958
int *idx, int flag)
17960
int i, end_idx_dummy, ret, is_dir= 0, was_failure= 0, fret;
17961
char sfe[5*SfileadrL], sfe2[5*SfileadrL];
17962
char eff_origin[SfileadrL], eff_dest[SfileadrL], dest_dir[SfileadrL];
17963
char leafname[SfileadrL];
17967
ret= Xorriso_cpmv_args(xorriso, "-mvi", argc, argv, idx,
17968
&optc, &optv, eff_dest, 0);
17973
strcpy(dest_dir, eff_dest);
17975
/* Perform movements */
17976
for(i= 0; i<optc; i++) {
17977
ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi,optv[i],eff_origin,0);
17978
if(ret<=0 || xorriso->request_to_abort)
17979
goto problem_handler;
17981
ret= Sfile_leafname(eff_origin, leafname, 0);
17983
goto problem_handler;
17984
strcpy(eff_dest, dest_dir);
17985
ret= Sfile_add_to_path(eff_dest, leafname, 0);
17987
sprintf(xorriso->info_text, "Effective path gets much too long (%d)",
17988
(int) (strlen(eff_dest)+strlen(leafname)+1));
17989
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
17990
goto problem_handler;
17993
ret= Xorriso_rename(xorriso, NULL, eff_origin, eff_dest, 0);
17994
if(ret<=0 || xorriso->request_to_abort)
17995
goto problem_handler;
17996
sprintf(xorriso->info_text, "Renamed in ISO image: %s to %s\n",
17997
Text_shellsafe(eff_origin,sfe,0),Text_shellsafe(eff_dest,sfe2,0));
17998
Xorriso_info(xorriso, 0);
18000
continue; /* regular bottom of loop */
18003
fret= Xorriso_eval_problem_status(xorriso, ret, 1|2);
18010
Xorriso_opt_args(xorriso, "-mvi",
18011
argc, argv, *idx, &end_idx_dummy, &optc, &optv, 256);
18016
/* Option -no_rc */
18017
int Xorriso_option_no_rc(struct XorrisO *xorriso, int flag)
18024
/* Option -not_leaf */
18025
int Xorriso_option_not_leaf(struct XorrisO *xorriso, char *pattern, int flag)
18028
char regexpr[2*SfileadrL+2], sfe[5*SfileadrL];
18032
{ret= 0; goto cannot_add;}
18033
Xorriso__bourne_to_reg(pattern, regexpr, 0);
18034
if(regcomp(&re, regexpr, 0)!=0)
18035
{ret= 0; goto cannot_add;}
18036
ret= Exclusions_add_not_leafs(xorriso->disk_exclusions, pattern, &re, 0);
18039
sprintf(xorriso->info_text,"Cannot add pattern: -not_leaf %s",
18040
Text_shellsafe(pattern, sfe, 0));
18041
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
18048
/* Option -not_list , -quoted_not_list */
18049
/* @param flag bit0= -quoted_not_list */
18050
int Xorriso_option_not_list(struct XorrisO *xorriso, char *adr, int flag)
18052
int ret, linecount= 0, insertcount= 0, null= 0, argc= 0, i;
18054
char sfe[5*SfileadrL], **argv= NULL;
18056
Xorriso_pacifier_reset(xorriso, 0);
18058
sprintf(xorriso->info_text, "Empty file name given with %s",
18059
(flag & 1) ? "-quoted_not_list" : "-not_list");
18060
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
18063
ret= Xorriso_afile_fopen(xorriso, adr, "rb", &fp, 0);
18067
ret= Xorriso_read_lines(xorriso, fp, &linecount, &argc, &argv,
18073
for(i= 0; i < argc; i++) {
18074
if(argv[i][0] == 0)
18076
if(strchr(argv[i], '/')!=NULL) {
18078
ret= Xorriso_option_not_paths(xorriso, 1, argv + i, &null, 0);
18080
ret= Xorriso_option_not_leaf(xorriso, argv[i], 0);
18088
if(fp != NULL && fp != stdin)
18090
Xorriso_read_lines(xorriso, fp, &linecount, &argc, &argv, 2);
18092
sprintf(xorriso->info_text, "Aborted reading of file %s in line number %d",
18093
Text_shellsafe(adr, sfe, 0), linecount);
18094
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
18096
sprintf(xorriso->info_text, "Added %d exclusion list items from file %s\n",
18097
insertcount, Text_shellsafe(adr, sfe, 0));
18098
Xorriso_info(xorriso,0);
18103
/* Option -not_mgt */
18104
int Xorriso_option_not_mgt(struct XorrisO *xorriso, char *setting, int flag)
18107
char what_data[SfileadrL], *what, *what_next;
18109
if(Sfile_str(what_data, setting, 0)<=0) {
18110
sprintf(xorriso->info_text,
18111
"-not_mgt: setting string is much too long (%d)",
18112
(int) strlen(setting));
18113
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
18116
for(what= what_data; what!=NULL; what= what_next) {
18117
what_next= strchr(what, ':');
18118
if(what_next!=NULL) {
18123
if(strcmp(what, "reset")==0 || strcmp(what, "erase")==0) {
18124
if(strcmp(what, "reset")==0)
18125
xorriso->disk_excl_mode= 1;
18126
Exclusions_destroy(&(xorriso->disk_exclusions), 0);
18127
ret= Exclusions_new(&(xorriso->disk_exclusions), 0);
18129
Xorriso_no_malloc_memory(xorriso, NULL, 0);
18132
} else if(strcmp(what, "on")==0) {
18133
xorriso->disk_excl_mode|= 1;
18134
} else if(strcmp(what, "off")==0) {
18135
xorriso->disk_excl_mode&= ~1;
18136
} else if(strcmp(what, "param_on")==0) {
18137
xorriso->disk_excl_mode|= 2;
18138
} else if(strcmp(what, "param_off")==0) {
18139
xorriso->disk_excl_mode&= ~2;
18140
} else if(strcmp(what, "subtree_on")==0) {
18141
xorriso->disk_excl_mode|= 4;
18142
} else if(strcmp(what, "subtree_off")==0) {
18143
xorriso->disk_excl_mode&= ~4;
18144
} else if(strcmp(what, "ignore_on")==0) {
18145
xorriso->disk_excl_mode|= 8;
18146
} else if(strcmp(what, "ignore_off")==0) {
18147
xorriso->disk_excl_mode&= ~8;
18149
sprintf(xorriso->info_text, "-not_mgt: unknown setting '%s'", what);
18150
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
18158
/* Option -not_paths */
18159
int Xorriso_option_not_paths(struct XorrisO *xorriso, int argc, char **argv,
18160
int *idx, int flag)
18162
int ret, end_idx, num_descr, dummy, optc= 0, i;
18163
char **descr= NULL, **optv= NULL, sfe[5*SfileadrL], eff_path[SfileadrL];
18166
end_idx= Xorriso_end_idx(xorriso, argc, argv, *idx,
18167
(xorriso->do_disk_pattern==1) | 2);
18170
num_descr= end_idx - *idx;
18174
/* produce absolute patterns */
18175
descr= TSOB_FELD(char *, num_descr);
18178
Xorriso_no_pattern_memory(xorriso, sizeof(char *) * (off_t) num_descr, 0);
18181
for(i= 0; i<num_descr; i++)
18183
for(i= 0; i<num_descr; i++) {
18184
ret= Xorriso_normalize_img_path(xorriso, xorriso->wdx, argv[i+*idx],
18188
descr[i]= strdup(eff_path);
18193
ret= Xorriso_opt_args(xorriso, "-not_paths",
18194
num_descr, descr, 0, &dummy, &optc, &optv, 2);
18197
ret= Exclusions_add_not_paths(xorriso->disk_exclusions,
18198
num_descr, descr, optc, optv, 0);
18200
sprintf(xorriso->info_text,"Cannot add path list: -not_paths %s%s %s",
18201
Text_shellsafe(argv[*idx], sfe, 0), (num_descr>1 ? " ..." : ""),
18202
xorriso->list_delimiter);
18203
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
18207
Xorriso_opt_args(xorriso, "-not_paths",
18208
num_descr, descr, 0, &dummy, &optc, &optv, 256);
18210
for(i= 0; i<num_descr; i++)
18213
free((char *) descr);
18220
/* Option -options_from_file */
18221
int Xorriso_option_options_from_file(struct XorrisO *xorriso, char *adr,
18224
bit0= called from Xorriso_prescan_args,
18225
therefore execute via that same function
18229
<=0 error , 1 = success , 3 = end program run
18232
int ret,linecount= 0, argc= 0, was_failure= 0, fret;
18234
char shellsafe[5*SfileadrL];
18237
char *line= NULL, **linev= NULL;
18240
sprintf(xorriso->info_text,"Empty file name given with -options_from_file");
18241
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
18244
Text_shellsafe(adr,shellsafe,0);
18245
if(xorriso->is_dialog) {
18246
sprintf(xorriso->info_text,"+ performing command lines from file %s :\n",
18248
Xorriso_info(xorriso,1);
18250
ret= Xorriso_afile_fopen(xorriso, adr, "rb", &fp, 0);
18254
ret= Xorriso_read_lines(xorriso, fp, &linecount, &linec, &linev, 1 | 8);
18256
goto ex; /* no problem_handler because there is no sense in going on */
18260
if(line[0]==0 || line[0]=='#')
18264
ret= Sfile_make_argv(xorriso->progname, line, &argc, &argv,
18265
4 | 8 | ((xorriso->bsl_interpretation & 3) << 5));
18267
goto problem_handler;
18268
ret= Xorriso_prescan_args(xorriso,argc,argv,1);
18272
goto problem_handler;
18274
if(xorriso->is_dialog) {
18275
sprintf(xorriso->info_text,"+ %d: %s\n",linecount,line);
18276
Xorriso_info(xorriso,1);
18278
ret= Xorriso_execute_option(xorriso,line,1|(1<<16));
18282
goto problem_handler;
18285
continue; /* regular bottom of loop */
18288
fret= Xorriso_eval_problem_status(xorriso, ret, 1);
18295
Sfile_make_argv("", "", &argc, &argv, 2); /* release memory */
18296
Xorriso_read_lines(xorriso, fp, &linecount, &linec, &linev, 2);
18297
Xorriso_reset_counters(xorriso,0);
18298
if(fp != NULL && fp != stdin)
18301
sprintf(xorriso->info_text,
18302
"error triggered by line %d of file:\n %s\n",
18303
linecount,shellsafe);
18304
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 1);
18308
return(!was_failure);
18312
/* Option -osirrox "on"|"off" */
18313
int Xorriso_option_osirrox(struct XorrisO *xorriso, char *mode, int flag)
18315
int l, allow_restore;
18318
allow_restore= xorriso->allow_restore;
18321
for(cpt= mode; npt!=NULL; cpt= npt+1) {
18322
npt= strchr(cpt,':');
18327
if(l==0 && mode[0]!=0)
18329
if(strncmp(cpt, "off", l)==0)
18331
else if(strncmp(cpt, "banned", l)==0)
18333
else if(strncmp(cpt, "device_files", l)==0)
18335
else if(strncmp(cpt, "on", l)==0 || mode[0]==0)
18337
else if(strncmp(cpt, "concat_split_on", l)==0)
18338
xorriso->do_concat_split= 1;
18339
else if(strncmp(cpt, "concat_split_off", l)==0)
18340
xorriso->do_concat_split= 0;
18341
else if(strncmp(cpt, "auto_chmod_on", l)==0)
18342
xorriso->do_auto_chmod= 1;
18343
else if(strncmp(cpt, "auto_chmod_off", l)==0)
18344
xorriso->do_auto_chmod= 0;
18345
else if(strncmp(cpt, "sort_lba_on", l)==0)
18346
xorriso->do_restore_sort_lba= 1;
18347
else if(strncmp(cpt, "sort_lba_off", l)==0)
18348
xorriso->do_restore_sort_lba= 0;
18349
else if(strncmp(cpt, "o_excl_off", l)==0)
18350
xorriso->drives_exclusive= 0;
18351
else if(strncmp(cpt, "o_excl_on", l)==0)
18352
xorriso->drives_exclusive= 1;
18355
sprintf(xorriso->info_text, "-osirrox: unknown mode '%s'", cpt);
18356
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
18360
if(allow_restore > 0 && xorriso->allow_restore == -1) {
18361
sprintf(xorriso->info_text,
18362
"-osirrox: was already permanently disabled by setting 'banned'");
18363
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
18366
if(xorriso->allow_restore != -1)
18367
xorriso->allow_restore= allow_restore;
18368
sprintf(xorriso->info_text,
18369
"Copying of file objects from ISO image to disk filesystem is: %s\n",
18370
xorriso->allow_restore > 0 ? "Enabled" : "Disabled");
18371
Xorriso_info(xorriso, 0);
18376
/* Option -overwrite "on"|"nondir"|"off" */
18377
int Xorriso_option_overwrite(struct XorrisO *xorriso, char *mode, int flag)
18379
if(strcmp(mode, "off")==0)
18380
xorriso->do_overwrite= 0;
18381
else if(strcmp(mode, "on")==0)
18382
xorriso->do_overwrite= 1;
18383
else if(strcmp(mode, "nondir")==0)
18384
xorriso->do_overwrite= 2;
18386
sprintf(xorriso->info_text, "-overwrite: unknown mode '%s'", mode);
18387
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
18394
/* Option -pacifier */
18395
int Xorriso_option_pacifier(struct XorrisO *xorriso, char *style, int flag)
18397
if(strcmp(style, "xorriso")==0 || strcmp(style, "default")==0)
18398
xorriso->pacifier_style= 0;
18399
else if(strcmp(style, "mkisofs")==0 || strcmp(style, "genisofs")==0 ||
18400
strcmp(style, "genisoimage")==0 || strcmp(style, "xorrisofs")==0)
18401
xorriso->pacifier_style= 1;
18402
else if(strcmp(style, "cdrecord")==0 || strcmp(style, "cdrskin")==0 ||
18403
strcmp(style, "wodim")==0 || strcmp(style, "xorrecord")==0)
18404
xorriso->pacifier_style= 2;
18406
sprintf(xorriso->info_text, "-pacifier: unknown behavior code '%s'", style);
18407
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
18414
/* Option -padding */
18415
int Xorriso_option_padding(struct XorrisO *xorriso, char *size, int flag)
18419
num= Scanf_io_size(size, 0);
18420
if(num < 0 || num > 1024.0 * 1024.0 * 1024.0) {
18421
sprintf(xorriso->info_text, "-padding: wrong size %.f (allowed: %.f - %.f)",
18422
num, 0.0, 1024.0 * 1024.0 * 1024.0);
18423
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
18426
xorriso->padding= num;
18427
if(xorriso->padding/2048 != num/2048.0)
18428
xorriso->padding++;
18434
int Xorriso_option_page(struct XorrisO *xorriso, int len, int width, int flag)
18436
if(len<0 || width<=0) {
18437
sprintf(xorriso->info_text,
18438
"Improper numeric value of arguments of -page: %d %d",
18440
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
18443
xorriso->result_page_length= len;
18444
xorriso->result_page_width= width;
18449
/* Option -paste_in */
18450
int Xorriso_option_paste_in(struct XorrisO *xorriso, char *iso_rr_path,
18451
char *disk_path, char *start, char *count, int flag)
18455
off_t startbyte, bytecount;
18457
num= Scanf_io_size(start, 0);
18458
if(num<0 || num > 1.0e18) { /* 10^18 = 10^3 ^ 6 < 2^10 ^ 6 = 2^60 */
18459
sprintf(xorriso->info_text,
18460
"-paste_in: startbyte address negative or much too large (%s)", start);
18461
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
18465
num= Scanf_io_size(count, 0);
18466
if(num<=0 || num > 1.0e18) {
18467
sprintf(xorriso->info_text,
18468
"-paste_in : bytecount zero, negative or much too large (%s)", count);
18469
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
18473
sprintf(xorriso->info_text, "-paste_in from %s to %s, byte %.f to %.f",
18474
disk_path, iso_rr_path,
18475
(double) startbyte, (double) (startbyte+bytecount));
18476
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0);
18478
ret= Xorriso_paste_in(xorriso, disk_path, startbyte, bytecount,
18484
/* Option -path_list , -quoted_path_list */
18485
/* @param flag bit0= -quoted_path_list */
18486
int Xorriso_option_path_list(struct XorrisO *xorriso, char *adr, int flag)
18488
int ret,linecount= 0, insertcount= 0, null= 0, was_failure= 0, fret= 0;
18489
int was_ferror= 0, argc= 0, i;
18491
char sfe[5*SfileadrL], **argv= NULL;
18493
Xorriso_pacifier_reset(xorriso, 0);
18495
sprintf(xorriso->info_text,"Empty file name given with %s",
18496
flag & 1 ? "-quoted_path_list" : "-path_list");
18497
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0);
18500
ret= Xorriso_afile_fopen(xorriso, adr, "rb", &fp, 0);
18504
ret= Xorriso_read_lines(xorriso, fp, &linecount, &argc, &argv,
18510
for(i= 0; i < argc; i++) {
18511
if(argv[i][0] == 0)
18514
ret= Xorriso_option_add(xorriso, 1, argv + i, &null, 1|2);
18515
if(ret<=0 || xorriso->request_to_abort)
18516
goto problem_handler;
18520
continue; /* regular bottom of loop */
18523
fret= Xorriso_eval_problem_status(xorriso, ret, 1|2);
18531
Xorriso_read_lines(xorriso, fp, &linecount, &argc, &argv, 2);
18533
if(fp != NULL && fp != stdin)
18535
Xorriso_pacifier_callback(xorriso, "files added", xorriso->pacifier_count,
18536
xorriso->pacifier_total, "", 1);
18538
sprintf(xorriso->info_text, "Aborted reading of file %s in line number %d",
18539
Text_shellsafe(adr, sfe, 0), linecount);
18540
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0,
18541
(fret==-2 ? "NOTE" : "FAILURE"), 0);
18544
sprintf(xorriso->info_text, "Added %d items from file %s\n",
18545
insertcount, Text_shellsafe(adr, sfe, 0));
18546
Xorriso_info(xorriso,0);
18549
return(!was_failure);
18553
/* Option -pathspecs */
18554
int Xorriso_option_pathspecs(struct XorrisO *xorriso, char *mode, int flag)
18556
if(strcmp(mode, "off")==0)
18557
xorriso->allow_graft_points= 0;
18558
else if(strcmp(mode, "on")==0)
18559
xorriso->allow_graft_points= 1;
18561
sprintf(xorriso->info_text, "-pathspecs: unknown mode '%s'", mode);
18562
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
18569
/* Option -pkt_output */
18570
int Xorriso_option_pkt_output(struct XorrisO *xorriso, char *mode, int flag)
18572
if(strcmp(mode,"off")==0)
18573
xorriso->packet_output= 0;
18575
xorriso->packet_output= 1;
18580
/* Option -print */
18581
int Xorriso_option_print(struct XorrisO *xorriso, char *text, int flag)
18583
sprintf(xorriso->result_line,"%s\n",text);
18584
Xorriso_result(xorriso,1);
18589
/* Option -print_size
18590
@param flag bit0= report in mkisofs compatible form on real stdout
18592
int Xorriso_option_print_size(struct XorrisO *xorriso, int flag)
18596
if(!xorriso->volset_change_pending) {
18597
sprintf(xorriso->info_text,"-print_size: No image modifications pending");
18598
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0);
18599
sprintf(xorriso->result_line,"Image size : 0s\n");
18600
Xorriso_result(xorriso,0);
18603
ret= Xorriso_write_session(xorriso, 1);
18605
sprintf(xorriso->info_text,"-print_size: Failed to set up virtual -commit");
18606
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
18610
sprintf(xorriso->result_line,"%d\n", ret);
18611
fd= xorriso->dev_fd_1;
18614
write(fd, xorriso->result_line, strlen(xorriso->result_line));
18617
sprintf(xorriso->result_line,"Image size : %ds\n", ret);
18618
Xorriso_result(xorriso,0);
18625
int Xorriso_option_prog(struct XorrisO *xorriso, char *name, int flag)
18627
if(strlen(name)>=sizeof(xorriso->progname)) {
18628
sprintf(xorriso->info_text,
18629
"Name too long with option -prog (%d > %d)",
18630
(int) strlen(name), (int) sizeof(xorriso->progname)-1);
18631
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
18634
if(Sfile_str(xorriso->progname,name,0)<=0)
18640
/* Option -prog_help */
18641
int Xorriso_option_prog_help(struct XorrisO *xorriso, char *name, int flag)
18645
ret= Xorriso_option_prog(xorriso, name, 0);
18648
ret= Xorriso_option_help(xorriso, 0);
18653
/* Option -prompt */
18654
int Xorriso_option_prompt(struct XorrisO *xorriso, char *text, int flag)
18659
strncpy(xorriso->result_line,text,sizeof(xorriso->result_line)-1);
18660
xorriso->result_line[sizeof(xorriso->result_line)-1]= 0;
18661
Xorriso_result(xorriso,0);
18662
ret= Xorriso_dialog_input(xorriso, line, sizeof(line),1);
18667
/* Option -publisher */
18668
int Xorriso_option_publisher(struct XorrisO *xorriso, char *name, int flag)
18670
if(Xorriso_check_name_len(xorriso, name, (int) sizeof(xorriso->publisher),
18671
"-publisher", 0) <= 0)
18673
strcpy(xorriso->publisher,name);
18674
Xorriso_set_change_pending(xorriso, 1);
18679
/* Option -pvd_info */
18680
int Xorriso_option_pvd_info(struct XorrisO *xorriso, int flag)
18682
return(Xorriso_pvd_info(xorriso, 0));
18686
/* Option -pwd alias -pwdi */
18687
int Xorriso_option_pwdi(struct XorrisO *xorriso, int flag)
18689
char sfe[5 * SfileadrL];
18691
sprintf(xorriso->info_text,"current working directory in ISO image:\n");
18692
Xorriso_info(xorriso,0);
18693
sprintf(xorriso->result_line,"%s/\n", Text_shellsafe(xorriso->wdi, sfe, 0));
18694
Xorriso_result(xorriso,0);
18700
int Xorriso_option_pwdx(struct XorrisO *xorriso, int flag)
18702
sprintf(xorriso->info_text,"current working directory on hard disk:\n");
18703
Xorriso_info(xorriso,0);
18704
sprintf(xorriso->result_line,"%s/\n",xorriso->wdx);
18705
Xorriso_result(xorriso,0);
18710
/* Option -reassure "on"|"tree"|"off" */
18711
int Xorriso_option_reassure(struct XorrisO *xorriso, char *mode, int flag)
18713
if(strcmp(mode, "off")==0)
18714
xorriso->do_reassure= 0;
18715
else if(strcmp(mode, "on")==0)
18716
xorriso->do_reassure= 1;
18717
else if(strcmp(mode, "tree")==0)
18718
xorriso->do_reassure= 2;
18720
sprintf(xorriso->info_text, "-reassure: unknown mode '%s'", mode);
18721
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
18728
/* Option -unregister_filter */
18729
int Xorriso_option_unregister_filter(struct XorrisO *xorriso, char *name,
18734
ret= Xorriso_external_filter(xorriso, name, "", "", 0, NULL, 1);
18739
/* Option -report_about */
18740
int Xorriso_option_report_about(struct XorrisO *xorriso, char *severity,
18744
char sfe[5*SfileadrL];
18746
ret= Xorriso__text_to_sev(severity, &sev, 0);
18748
sprintf(xorriso->info_text,
18749
"-report_about: Not a known severity name : %s",
18750
Text_shellsafe(severity, sfe, 0));
18751
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0);
18754
if(Sfile_str(xorriso->report_about_text,severity,0)<=0)
18756
xorriso->report_about_severity= sev;
18761
/* Option -return_with */
18762
int Xorriso_option_return_with(struct XorrisO *xorriso, char *severity,
18763
int exit_value, int flag)
18766
char sfe[5*SfileadrL];
18768
ret= Xorriso__text_to_sev(severity, &sev, 0);
18770
sprintf(xorriso->info_text,
18771
"-return_with: Not a known severity name : %s",
18772
Text_shellsafe(severity, sfe, 0));
18773
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
18776
if(exit_value && (exit_value < 32 || exit_value > 63)) {
18777
sprintf(xorriso->info_text,
18778
"-return_with: Not an allowed exit_value. Use 0, or 32 to 63.");
18779
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
18782
if(Sfile_str(xorriso->return_with_text,severity,0)<=0)
18784
xorriso->return_with_severity= sev;
18785
xorriso->return_with_value= exit_value;
18790
/* Options -rm alias -rmi , -rm_r alias -rm_ri , -rmdir alias -rmdiri */
18791
/* @param flag bit0=recursive , bit1= remove empty directory: rmdir */
18792
int Xorriso_option_rmi(struct XorrisO *xorriso, int argc, char **argv,
18793
int *idx, int flag)
18795
int i, ret, end_idx, was_failure= 0, fret;
18796
char path[SfileadrL], eff_path[SfileadrL], sfe[5*SfileadrL];
18800
ret= Xorriso_opt_args(xorriso, "-rm*i",
18801
argc, argv, *idx, &end_idx, &optc, &optv, 0);
18804
for(i= 0; i<optc; i++) {
18805
if(Sfile_str(path,optv[i],0)<=0)
18806
{ret= -1; goto problem_handler;}
18808
ret= Sfile_prepend_path(xorriso->wdi, path, 0);
18810
goto problem_handler;
18812
ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, path, eff_path, 1);
18814
goto problem_handler;
18816
sprintf(xorriso->info_text,
18817
"Cannot find path %s in loaded ISO image for removal",
18818
Text_shellsafe(path, sfe, 0));
18819
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
18820
goto problem_handler;
18822
strcpy(path, eff_path);
18824
ret= Xorriso_rmi(xorriso, NULL, (off_t) 0, path, flag&(1|2));
18825
if(ret<=0 || xorriso->request_to_abort)
18826
goto problem_handler;
18828
sprintf(xorriso->info_text, "Removed from ISO image: %s '%s'\n",
18829
((flag&2) ? "directory" : (ret>1 ? "subtree" : "file")), path);
18830
Xorriso_info(xorriso, 0);
18833
continue; /* regular bottom of loop */
18836
fret= Xorriso_eval_problem_status(xorriso, ret, 1|2);
18844
Xorriso_opt_args(xorriso, "-rm*i",
18845
argc, argv, *idx, &end_idx, &optc, &optv, 256);
18848
return(!was_failure);
18852
/* Option -rollback */
18853
/* @param flag bit0= do not -reassure
18854
@return <=0 error , 1 success, 2 revoked by -reassure
18856
int Xorriso_option_rollback(struct XorrisO *xorriso, int flag)
18859
char indev[SfileadrL], *which_will;
18861
if(xorriso->volset_change_pending)
18862
which_will= "revoke the pending image changes";
18864
which_will= "reload the image";
18866
ret= Xorriso_reassure(xorriso, "-rollback", which_will, 0);
18871
if(Sfile_str(indev, xorriso->indev, 0)<=0)
18873
ret= Xorriso_give_up_drive(xorriso, 1|8);
18876
xorriso->image_start_mode&= ~(1<<31); /* reactivate eventual -load address */
18877
ret= Xorriso_option_dev(xorriso, indev, 1|4);
18882
/* Option -rom_toc_scan */
18883
int Xorriso_option_rom_toc_scan(struct XorrisO *xorriso, char *mode, int flag)
18888
xorriso->toc_emulation_flag= 0;
18890
for(cpt= mode; npt != NULL; cpt= npt + 1) {
18891
npt= strchr(cpt,':');
18898
xorriso->toc_emulation_flag&= ~4;
18899
if(strncmp(cpt, "off", l) == 0)
18900
xorriso->toc_emulation_flag&= ~1;
18901
else if(strncmp(cpt, "on", l) == 0)
18902
xorriso->toc_emulation_flag|= 1;
18903
else if(strncmp(cpt, "force", l) == 0)
18904
xorriso->toc_emulation_flag|= 4;
18905
else if(strncmp(cpt, "emul_off", l) == 0)
18906
xorriso->toc_emulation_flag|= 2;
18907
else if(strncmp(cpt, "emul_on", l) == 0)
18908
xorriso->toc_emulation_flag&= ~2;
18911
sprintf(xorriso->info_text, "-rom_toc_scan: unknown mode in '%s'", mode);
18912
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
18920
/* Option -scdbackup_tag list_path record_name */
18921
int Xorriso_option_scdbackup_tag(struct XorrisO *xorriso, char *listname,
18922
char *recname, int flag)
18924
if(strlen(recname) > 80) {
18925
sprintf(xorriso->info_text,
18926
"Unsuitable record name given with -scdbackup_tag");
18927
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
18930
strcpy(xorriso->scdbackup_tag_name, recname);
18931
xorriso->scdbackup_tag_time[0]= 0;
18932
if(Sfile_str(xorriso->scdbackup_tag_listname, listname, 0) <= 0)
18938
/* Option -scsi_log */
18939
int Xorriso_option_scsi_log(struct XorrisO *xorriso, char *mode, int flag)
18941
if(strcmp(mode, "on") == 0)
18942
xorriso->scsi_log= 1;
18943
else if(strcmp(mode, "off") == 0)
18944
xorriso->scsi_log= 0;
18946
sprintf(xorriso->info_text, "-scsi_log: unknown mode '%s'", mode);
18947
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
18950
Xorriso_scsi_log(xorriso, !!xorriso->scsi_log);
18955
/* Option -session_log */
18956
int Xorriso_option_session_log(struct XorrisO *xorriso, char *path, int flag)
18958
if(Sfile_str(xorriso->session_logfile, path, 0)<=0)
18965
/* Option -setfacl_list alias -setfacl_listi */
18966
int Xorriso_option_setfacl_listi(struct XorrisO *xorriso, char *path, int flag)
18969
size_t buf_size= 0, buf_add= 64 * 1024, l, linecount= 0;
18970
char line[SfileadrL * 4], *buf= NULL, *wpt, *new_buf, limit_text[80];
18971
char file_path[SfileadrL], uid[161], gid[161];
18974
Xorriso_pacifier_reset(xorriso, 0);
18976
sprintf(xorriso->info_text, "Empty file name given with -setfacl_list");
18977
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
18980
ret= Xorriso_afile_fopen(xorriso, path, "rb", &fp, 0);
18985
buf= calloc(buf_size, 1);
18993
if(Sfile_fgets_n(line, sizeof(line), fp, 0) == NULL)
18996
if(strncmp(line, "# file: ", 8) ==0) {
18997
if(wpt != buf && file_path[0]) {
18998
/* Commit previous list */
18999
ret= Xorriso_perform_acl_from_list(xorriso, file_path,
19005
file_path[0]= uid[0]= gid[0]= 0;
19007
/* Unescape line and register as file path */
19008
Sfile_bsl_interpreter(line + 8, strlen(line + 8), &eaten, 0);
19009
if(strlen(line + 8) >= SfileadrL) {
19010
sprintf(xorriso->info_text, "-setfacl_list: Oversized file path");
19011
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
19014
strcpy(file_path, line + 8);
19016
} else if(strncmp(line, "# owner: ", 9) == 0) {
19017
if(strlen(line + 9) > 160) {
19018
sprintf(xorriso->info_text, "-setfacl_list: Oversized owner id");
19019
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
19022
strcpy(uid, line + 9);
19024
} else if(strncmp(line, "# group: ", 9) == 0) {
19025
if(strlen(line + 9) > 160) {
19026
sprintf(xorriso->info_text, "-setfacl_list: Oversized group id");
19027
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
19030
strcpy(gid, line + 9);
19032
} else if(line[0] == '#' || line[0] == 0) {
19034
} else if(strcmp(line, "@") == 0) {
19035
Xorriso_msgs_submit(xorriso, 0,
19036
"-setfacl_list input ended by '@'", 0, "NOTE", 0);
19038
} else if(strcmp(line, "@@@") == 0) {
19039
Xorriso_msgs_submit(xorriso, 0,
19040
"-setfacl_list aborted by input line '@@@'", 0, "WARNING", 0);
19044
/* Register ACL entry */
19046
if(wpt + l + 2 - buf > buf_size) {
19047
if(buf_size + buf_add > xorriso->temp_mem_limit) {
19048
Sfile_scale((double) xorriso->temp_mem_limit, limit_text,5,1e4,1);
19049
sprintf(xorriso->info_text,
19050
"-setfacl_list: List entry for a single file exceeds -temp_mem_limit %s",
19052
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
19055
buf_size+= buf_add;
19056
new_buf= realloc(buf, buf_size);
19057
if(new_buf == NULL)
19061
memcpy(wpt, line, l);
19066
if(wpt != buf && file_path[0]) {
19067
/* Commit last list */
19068
ret= Xorriso_perform_acl_from_list(xorriso, file_path, uid, gid, buf, 0);
19072
sprintf(xorriso->info_text, "-setfacl_list: Unexpected end of file ");
19073
Text_shellsafe(path, xorriso->info_text, 1);
19074
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0);
19080
if(fp != NULL && fp != stdin)
19083
sprintf(xorriso->info_text, "-setfacl_list ");
19084
Text_shellsafe(path, xorriso->info_text, 1);
19085
sprintf(xorriso->info_text + strlen(xorriso->info_text),
19086
" aborted in line %.f\n", (double) linecount);
19087
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
19091
Xorriso_no_malloc_memory(xorriso, &buf, 0);
19097
/* Options -setfacl alias -setfacli, -setfacl_r alias -setfacl_ri */
19098
/* @param flag bit0=recursive -setfacl_r
19100
int Xorriso_option_setfacli(struct XorrisO *xorriso, char *acl_text,
19101
int argc, char **argv, int *idx, int flag)
19103
int i, ret, was_failure= 0, end_idx, fret;
19105
char **optv= NULL, *access_acl_text= NULL, *default_acl_text= NULL;
19106
struct FindjoB *job= NULL;
19107
struct stat dir_stbuf;
19109
ret= Xorriso_opt_args(xorriso, "-setfacl", argc, argv, *idx, &end_idx, &optc,
19114
ret= Xorriso_normalize_acl_text(xorriso, acl_text,
19115
&access_acl_text, &default_acl_text, 0);
19116
if(access_acl_text != NULL && default_acl_text != NULL) {
19117
sprintf(xorriso->info_text, "Access-ACL :\n%s", access_acl_text);
19118
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0);
19119
sprintf(xorriso->info_text, "Default-ACL :\n%s", default_acl_text);
19120
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0);
19121
} else if(access_acl_text == NULL && default_acl_text == NULL) {
19122
sprintf(xorriso->info_text, "Will delete Access-ACL and Default-ACL");
19123
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0);
19128
for(i= 0; i<optc; i++) {
19130
ret= Findjob_new(&job, optv[i], 0);
19132
Xorriso_no_findjob(xorriso, "-setfacl_r", 0);
19133
{ret= -1; goto ex;}
19135
Findjob_set_action_text_2(job, 25, access_acl_text, default_acl_text, 0);
19136
ret= Xorriso_findi(xorriso, job, NULL, (off_t) 0,
19137
NULL, optv[i], &dir_stbuf, 0, 0);
19138
Findjob_destroy(&job, 0);
19141
if(access_acl_text == NULL || access_acl_text[0] ||
19142
default_acl_text == NULL || default_acl_text[0])
19143
ret= Xorriso_setfacl(xorriso, NULL, optv[i],
19144
access_acl_text, default_acl_text, 0);
19146
if(ret>0 && !xorriso->request_to_abort)
19147
continue; /* regular bottom of loop */
19149
fret= Xorriso_eval_problem_status(xorriso, ret, 1|2);
19157
Xorriso_opt_args(xorriso, "-setfacl", argc, argv, *idx, &end_idx,
19158
&optc, &optv, 256);
19159
Findjob_destroy(&job, 0);
19160
if(access_acl_text != NULL)
19161
free(access_acl_text);
19162
if(default_acl_text != NULL)
19163
free(default_acl_text);
19166
return(!was_failure);
19170
/* Options -setfattr alias -setfattri, -setfattr_r alias -setfattr_ri */
19171
/* @param flag bit0=recursive -setfattr_r
19173
int Xorriso_option_setfattri(struct XorrisO *xorriso, char *name, char *value,
19174
int argc, char **argv, int *idx, int flag)
19176
int i, ret, was_failure= 0, end_idx, fret;
19179
struct FindjoB *job= NULL;
19180
struct stat dir_stbuf;
19182
ret= Xorriso_opt_args(xorriso, "-setfattr", argc, argv, *idx, &end_idx, &optc,
19188
ret= Xorriso_path_setfattr(xorriso, NULL, "", name, strlen(value), value, 1);
19192
for(i= 0; i<optc; i++) {
19194
ret= Findjob_new(&job, optv[i], 0);
19196
Xorriso_no_findjob(xorriso, "-setfattr_r", 0);
19197
{ret= -1; goto ex;}
19199
Findjob_set_action_text_2(job, 27, name, value, 0);
19200
ret= Xorriso_findi(xorriso, job, NULL, (off_t) 0,
19201
NULL, optv[i], &dir_stbuf, 0, 0);
19202
Findjob_destroy(&job, 0);
19205
ret= Xorriso_path_setfattr(xorriso, NULL, optv[i],
19206
name, strlen(value), value, 0);
19208
if(ret>0 && !xorriso->request_to_abort)
19209
continue; /* regular bottom of loop */
19211
fret= Xorriso_eval_problem_status(xorriso, ret, 1|2);
19219
Xorriso_opt_args(xorriso, "-setfattr", argc, argv, *idx, &end_idx,
19220
&optc, &optv, 256);
19221
Findjob_destroy(&job, 0);
19224
return(!was_failure);
19228
/* Option -setfattr_list alias -setfattr_listi */
19229
int Xorriso_option_setfattr_listi(struct XorrisO *xorriso, char *path,
19233
size_t linecount= 0, mem_used= 0, num_attr= 0, v_len;
19234
char line[SfileadrL * 4], limit_text[80], *ept, *valuept;
19235
char file_path[SfileadrL];
19237
struct Xorriso_lsT *lst_curr= NULL, *lst_start= NULL;
19239
Xorriso_pacifier_reset(xorriso, 0);
19241
sprintf(xorriso->info_text, "Empty file name given with -setfattr_list");
19242
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
19245
ret= Xorriso_afile_fopen(xorriso, path, "rb", &fp, 0);
19250
if(Sfile_fgets_n(line, sizeof(line), fp, 0) == NULL)
19253
if(strncmp(line, "# file: ", 8) ==0) {
19254
if(num_attr > 0 && file_path[0]) {
19255
/* Commit previous list */
19256
ret= Xorriso_perform_attr_from_list(xorriso, file_path, lst_start, 0);
19261
Xorriso_lst_destroy_all(&lst_start, 0);
19264
/* Unescape line and register as file path */
19265
Sfile_bsl_interpreter(line + 8, strlen(line + 8), &eaten, 0);
19266
if(strlen(line + 8) >= SfileadrL) {
19267
sprintf(xorriso->info_text, "-setfattr_list: Oversized file path");
19268
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
19271
strcpy(file_path, line + 8);
19273
} else if(line[0] == '#' || line[0] == 0) {
19275
} else if(strcmp(line, "@") == 0) {
19276
Xorriso_msgs_submit(xorriso, 0,
19277
"-setfattr_list input ended by '@'", 0, "NOTE", 0);
19279
} else if(strcmp(line, "@@@") == 0) {
19280
Xorriso_msgs_submit(xorriso, 0,
19281
"-setfattr_list aborted by input line '@@@'", 0, "WARNING", 0);
19284
mem_used+= strlen(line) + 1;
19285
if(mem_used > xorriso->temp_mem_limit) {
19286
Sfile_scale((double) xorriso->temp_mem_limit, limit_text,5,1e4,1);
19287
sprintf(xorriso->info_text,
19288
"-setfattr_list: List entry for a single file exceeds -temp_mem_limit %s",
19290
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
19294
/* Register attr pair */
19296
ept= strchr(line, '=');
19298
sprintf(xorriso->info_text, "-setfattr_list: ");
19299
Text_shellsafe(path, xorriso->info_text, 1);
19300
sprintf(xorriso->info_text + strlen(xorriso->info_text),
19301
" : Line %.f : No separator '=' found",
19302
(double) linecount);
19303
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0);
19307
v_len= strlen(valuept);
19308
for(ept= valuept + v_len - 1; ept > valuept; ept--)
19313
v_len= strlen(valuept);
19314
if(v_len < 2 || *valuept != '"' || *(valuept + v_len -1) != '"') {
19315
sprintf(xorriso->info_text, "-setfattr_list: ");
19316
Text_shellsafe(path, xorriso->info_text, 1);
19317
sprintf(xorriso->info_text + strlen(xorriso->info_text),
19318
" : Line %.f : Value not enclosed in quotes",
19319
(double) linecount);
19320
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0);
19325
ret= Xorriso_lst_new(&lst_curr, line, lst_curr, 0);
19328
if(lst_start == NULL)
19329
lst_start= lst_curr;
19334
/* Commit last list */
19335
ret= Xorriso_perform_attr_from_list(xorriso, file_path, lst_start, 0);
19339
sprintf(xorriso->info_text, "-setfattr_list: Unexpected end of file ");
19340
Text_shellsafe(path, xorriso->info_text, 1);
19341
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0);
19345
if(fp != NULL && fp != stdin)
19347
Xorriso_lst_destroy_all(&lst_start, 0);
19349
sprintf(xorriso->info_text, "-setfattr_list ");
19350
Text_shellsafe(path, xorriso->info_text, 1);
19351
sprintf(xorriso->info_text + strlen(xorriso->info_text),
19352
" aborted in line %.f\n", (double) linecount);
19353
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
19357
Xorriso_no_malloc_memory(xorriso, NULL, 0);
19363
/* Options -set_filter , -set_filter_r , -show_stream , -show_stream_r */
19364
/* @param flag bit0=recursive -set_filter_r
19365
bit1= do not reset pacifier, no final pacifier message
19366
bit2= -show_stream rather than -set_filter
19368
int Xorriso_option_set_filter(struct XorrisO *xorriso, char *name,
19369
int argc, char **argv, int *idx, int flag)
19371
int i, ret, was_failure= 0, end_idx, fret;
19374
struct FindjoB *job= NULL;
19375
struct stat dir_stbuf;
19376
char *cmd= "-set_filter";
19379
case 0: cmd= "-set_filter";
19380
break; case 1: cmd= "-set_filter_r";
19381
break; case 4: cmd= "-show_stream";
19382
break; case 5: cmd= "-show_stream_r";
19385
ret= Xorriso_opt_args(xorriso, cmd,
19386
argc, argv, *idx, &end_idx, &optc, &optv, 0);
19390
Xorriso_pacifier_reset(xorriso, 0);
19392
for(i= 0; i<optc; i++) {
19394
ret= Findjob_new(&job, optv[i], 0);
19396
Xorriso_no_findjob(xorriso, cmd, 0);
19397
{ret= -1; goto ex;}
19399
Findjob_set_action_target(job, ((flag & 4) ? 29 : 28), name, 0);
19400
Findjob_set_file_type(job, 'f', 0);
19401
ret= Xorriso_findi(xorriso, job, NULL, (off_t) 0,
19402
NULL, optv[i], &dir_stbuf, 0, 0);
19403
Findjob_destroy(&job, 0);
19407
ret= Xorriso_show_stream(xorriso, NULL, optv[i], 0);
19409
ret= Xorriso_set_filter(xorriso, NULL, optv[i], name, 0);
19411
if(ret>0 && !xorriso->request_to_abort)
19412
continue; /* regular bottom of loop */
19414
fret= Xorriso_eval_problem_status(xorriso, ret, 1|2);
19420
Xorriso_pacifier_callback(xorriso, "file filters processed",
19421
xorriso->pacifier_count, 0, "", 1);
19425
Xorriso_opt_args(xorriso, cmd, argc, argv, *idx, &end_idx,
19426
&optc, &optv, 256);
19427
Findjob_destroy(&job, 0);
19430
return(!was_failure);
19434
/* Option -speed */
19435
int Xorriso_option_speed(struct XorrisO *xorriso, char *speed, int flag)
19437
int is_cd= 1, unit_found= 0, ret, profile_number;
19439
char *cpt, profile_name[80];
19441
if(speed[0]==0 || strcmp(speed, "any")==0) {
19442
xorriso->speed= 0; /* full speed */
19446
sscanf(speed,"%lf",&num);
19447
for(cpt= speed+strlen(speed)-1; cpt>=speed; cpt--)
19448
if(isdigit(*cpt) || *cpt=='.')
19452
if(*cpt=='k' || *cpt=='K') {
19453
/* is merchand kilobyte, stays merchand kilobyte */
19455
} else if(*cpt=='m' || *cpt=='M') {
19458
} else if(*cpt=='x' || *cpt=='X')
19463
} else if(*cpt=='c' || *cpt=='C') {
19466
} else if(*cpt=='d' || *cpt=='D') {
19469
} else if(*cpt=='b' || *cpt=='B') {
19473
ret= Xorriso_get_profile(xorriso, &profile_number, profile_name, 2);
19484
sprintf(xorriso->info_text,
19485
"-speed: Value too large or not recognizable: '%s'", speed);
19486
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
19489
xorriso->speed= num;
19490
if(xorriso->speed<num)
19496
/* Option -split_size */
19497
int Xorriso_option_split_size(struct XorrisO *xorriso, char *size, int flag)
19501
num= Scanf_io_size(size, 0);
19502
if(num > xorriso->file_size_limit && xorriso->file_size_limit > 0) {
19503
sprintf(xorriso->info_text, "-split_size: too large %.f (allowed: %.f)",
19504
num, (double) xorriso->file_size_limit);
19505
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
19509
xorriso->split_size= num;
19514
/* Option -status */
19515
int Xorriso_option_status(struct XorrisO *xorriso, char *mode, int flag)
19517
if(strcmp(mode,"short")==0)
19518
Xorriso_status(xorriso,NULL,NULL,1);
19519
else if(strcmp(mode,"long")==0)
19520
Xorriso_status(xorriso,NULL,NULL,0);
19521
else if(strcmp(mode,"long_history")==0)
19522
Xorriso_status(xorriso,NULL,NULL,8);
19523
else if(mode[0]=='-')
19524
Xorriso_status(xorriso,mode,NULL,8);
19526
Xorriso_status(xorriso,NULL,NULL,1);
19531
/* Option -status_history_max */
19532
int Xorriso_option_status_history_max(struct XorrisO *xorriso, int num,
19535
if(num>=0 && num<1000000)
19536
xorriso->status_history_max= num;
19541
/* Option -stdio_sync "on"|"off"|size */
19542
int Xorriso_option_stdio_sync(struct XorrisO *xorriso, char *rythm, int flag)
19546
if(strcmp(rythm, "default") == 0 || strcmp(rythm, "on") == 0)
19548
if(strcmp(rythm, "off") == 0)
19551
num = Scanf_io_size(rythm, 0);
19554
if(num != -1 && num != 0 && (num < 32 || num > 512 * 1024)) {
19555
sprintf(xorriso->info_text,
19556
"-stdio_sync : Bad size. Acceptable are -1, 0, 32k ... 1g");
19557
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
19560
xorriso->stdio_sync= num;
19565
/* Option -stream_recording */
19566
int Xorriso_option_stream_recording(struct XorrisO *xorriso, char *mode,
19571
if(strcmp(mode,"on")==0 || mode[0]==0)
19572
xorriso->do_stream_recording= 32;
19573
else if(strcmp(mode,"full")==0)
19574
xorriso->do_stream_recording= 1;
19575
else if(strcmp(mode,"data")==0)
19576
xorriso->do_stream_recording= 2;
19577
else if(mode[0] >= '0' && mode[0] <= '9') {
19578
num= Scanf_io_size(mode, 0);
19580
if(num >= 16 && num <= 0x7FFFFFFF)
19581
xorriso->do_stream_recording= num;
19583
xorriso->do_stream_recording= 0;
19585
xorriso->do_stream_recording= 0;
19590
/* Option -system_id */
19591
int Xorriso_option_system_id(struct XorrisO *xorriso, char *name, int flag)
19593
if(Xorriso_check_name_len(xorriso, name, (int) sizeof(xorriso->system_id),
19594
"-system_id", 0) <= 0)
19596
strcpy(xorriso->system_id, name);
19597
Xorriso_set_change_pending(xorriso, 1);
19602
/* Option -tell_media_space */
19603
int Xorriso_option_tell_media_space(struct XorrisO *xorriso, int flag)
19605
int ret, free_space= 0, media_space= 0;
19607
ret= Xorriso_tell_media_space(xorriso, &media_space, &free_space, 0);
19609
sprintf(xorriso->info_text, "Cannot -tell_media_space");
19610
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
19614
sprintf(xorriso->info_text,
19615
"Pending image size larger than free space on media");
19616
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0);
19618
sprintf(xorriso->result_line, "Media space : %ds\n", media_space);
19619
Xorriso_result(xorriso, 0);
19620
sprintf(xorriso->result_line, "After commit : %ds\n", free_space);
19621
Xorriso_result(xorriso, 0);
19626
/* Option -temp_mem_limit */
19627
int Xorriso_option_temp_mem_limit(struct XorrisO *xorriso, char *size,
19632
num= Scanf_io_size(size, 0);
19633
if(num < 64.0 * 1024.0 || num > 1024.0 * 1024.0 * 1024.0) {
19634
sprintf(xorriso->info_text,
19635
"-temp_mem_limit: wrong size %.f (allowed: %.f - %.f)",
19636
num, 64.0 * 1024.0, 1024.0 * 1024.0 * 1024.0);
19637
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
19640
xorriso->temp_mem_limit= num;
19646
int Xorriso_option_toc(struct XorrisO *xorriso, int flag)
19648
int ret, in_ret= 1000;
19650
if(strcmp(xorriso->indev,xorriso->outdev)==0)
19651
ret= Xorriso_toc(xorriso, 0);
19653
if(xorriso->indev[0]!=0)
19654
in_ret= Xorriso_toc(xorriso, 0);
19655
if(xorriso->indev[0]!=0 && xorriso->outdev[0]!=0) {
19656
strcpy(xorriso->result_line, "-------------: ---------------------------------------------------------------\n");
19657
Xorriso_result(xorriso,0);
19660
if(xorriso->outdev[0]!=0)
19661
ret= Xorriso_toc(xorriso, 2);
19670
int Xorriso_option_uid(struct XorrisO *xorriso, char *uid, int flag)
19674
xorriso->do_global_uid= 0;
19675
if(uid[0]==0 || strcmp(uid,"-")==0)
19677
ret= Xorriso_convert_uidstring(xorriso, uid, &(xorriso->global_uid), 0);
19679
xorriso->do_global_uid= 1;
19684
/* Options -update and -update_r
19685
@param flag bit0= issue start and summary message
19686
bit1= do not reset pacifier, no final pacifier message
19687
bit2= do not issue pacifier messages at all
19688
bit3= recursive: -update_r
19689
bit4= do not establish and dispose xorriso->di_array
19691
int Xorriso_option_update(struct XorrisO *xorriso, char *disk_path,
19692
char *iso_path, int flag)
19694
int ret, mem_pci, zero= 0, result, uret, follow_links, do_register= 1;
19695
int not_in_iso= 0, not_on_disk= 0, made_di_array= 0;
19696
double mem_lut= 0.0, start_time;
19697
char *ipth, *argv[6], sfe[5*SfileadrL];
19698
char eff_origin[SfileadrL], eff_dest[SfileadrL];
19701
start_time= Sfile_microtime(0);
19706
if(disk_path[0]==0) {
19707
sprintf(xorriso->info_text, "-update: Empty disk_path given");
19708
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 1);
19712
ret= Xorriso_normalize_img_path(xorriso, xorriso->wdx, disk_path, eff_origin,
19716
ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, ipth, eff_dest, 2|8);
19721
Xorriso_pacifier_reset(xorriso, 0);
19722
mem_lut= xorriso->last_update_time;
19724
mem_pci= xorriso->pacifier_interval;
19725
xorriso->pacifier_interval= 5.0;
19728
sprintf(xorriso->info_text, "Updating %s to",
19729
Text_shellsafe(eff_origin, sfe, 0));
19730
sprintf(xorriso->info_text+strlen(xorriso->info_text), " %s\n",
19731
Text_shellsafe(eff_dest, sfe, 0));
19732
Xorriso_info(xorriso,0);
19734
if(xorriso->disk_excl_mode&8)
19735
ret= Xorriso_path_is_excluded(xorriso, eff_origin, 1);
19739
goto report_outcome;
19741
if(!(xorriso->ino_behavior & 2)) {
19742
if(!(xorriso->di_array != NULL || (flag & 16))) {
19743
/* Create all-image node array sorted by isofs.di */
19745
ret= Xorriso_make_di_array(xorriso, 0);
19749
if(xorriso->di_array != NULL) {
19751
/* If directory with -update : do not register di_*_paths */
19752
ret= lstat(eff_origin, &stbuf);
19754
if(S_ISDIR(stbuf.st_mode))
19758
ret= Xorriso_lst_new(&(xorriso->di_disk_paths), eff_origin,
19759
xorriso->di_disk_paths, 1);
19762
ret= Xorriso_lst_new(&(xorriso->di_iso_paths), eff_dest,
19763
xorriso->di_iso_paths, 1);
19771
xorriso->find_compare_result= 1;
19772
ret= Xorriso_iso_lstat(xorriso, eff_dest, &stbuf, 0);
19777
argv[3]= eff_origin;
19779
ret= Xorriso_option_find(xorriso, 4, argv, &zero,
19780
2 | (8 * !((xorriso->do_aaip & 96) == 96))); /* -findi */
19781
} else if(ret==-2) { /* severe error (e.g. lack of image) */
19783
goto report_outcome;
19789
ret= lstat(eff_origin, &stbuf);
19791
argv[0]= eff_origin;
19793
argv[2]= "add_missing";
19796
ret= Xorriso_option_find(xorriso, 4, argv, &zero, 1|2); /* -findx */
19797
if(ret>0 && !xorriso->do_follow_mount) {
19798
argv[0]= eff_origin;
19802
argv[4]= "empty_iso_dir";
19805
ret= Xorriso_option_find(xorriso, 6, argv, &zero, 1|2); /* -findx */
19808
ret= xorriso->find_compare_result;
19812
ret= xorriso->find_compare_result;
19817
if(not_on_disk && not_in_iso) {
19818
sprintf(xorriso->info_text, "Missing on disk and in ISO: disk_path %s",
19819
Text_shellsafe(disk_path, sfe, 0));
19820
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 1);
19824
/* compare ctime too, no filename reporting, eventually silent */
19825
follow_links= (xorriso->do_follow_links || xorriso->do_follow_param) <<28;
19826
ret= Xorriso_compare_2_files(xorriso, eff_origin, eff_dest, "", &result,
19827
2 | follow_links | ((flag&4)<<27) | (3<<30));
19829
uret= Xorriso_update_interpreter(xorriso, NULL, result, eff_origin,
19837
xorriso->pacifier_interval= mem_pci;
19838
if(mem_lut!=xorriso->last_update_time && !(flag&2))
19839
Xorriso_pacifier_callback(xorriso, "content bytes read",
19840
xorriso->pacifier_count, 0, "", 1);
19843
sprintf(xorriso->info_text,
19844
"No file object needed update.");
19845
} else if(ret==0) {
19846
sprintf(xorriso->info_text, "Differences detected and updated.");
19848
sprintf(xorriso->info_text,
19849
"Not ok. Comparison or update failed due to error.");
19851
sprintf(xorriso->info_text+strlen(xorriso->info_text),
19852
" (runtime %.1f s)\n", Sfile_microtime(0)-start_time);
19854
Xorriso_info(xorriso,0);
19863
/* Option -use_readline */
19864
int Xorriso_option_use_readline(struct XorrisO *xorriso, char *mode, int flag)
19866
if(strcmp(mode,"off")==0)
19867
xorriso->use_stdin= 1;
19869
xorriso->use_stdin= 0;
19874
/* Option -version */
19875
int Xorriso_option_version(struct XorrisO *xorriso, int flag)
19877
#ifdef Xorriso_GNU_xorrisO
19878
sprintf(xorriso->result_line, "GNU xorriso %s%s\n",
19879
Xorriso_program_versioN, Xorriso_program_patch_leveL);
19881
sprintf(xorriso->result_line, "xorriso %s%s\n",
19882
Xorriso_program_versioN, Xorriso_program_patch_leveL);
19883
#endif /* ! Xorriso_GNU_xorrisO */
19884
Xorriso_result(xorriso, 0);
19885
sprintf(xorriso->result_line,
19886
"ISO 9660 Rock Ridge filesystem manipulator and CD/DVD/BD burn program\n");
19887
sprintf(xorriso->result_line+strlen(xorriso->result_line),
19888
"Copyright (C) 2010, Thomas Schmitt <scdbackup@gmx.net>, libburnia project.\n");
19889
Xorriso_result(xorriso, 0);
19890
sprintf(xorriso->result_line,
19891
"xorriso version : %s%s\n",
19892
Xorriso_program_versioN, Xorriso_program_patch_leveL);
19893
sprintf(xorriso->result_line+strlen(xorriso->result_line),
19894
"Version timestamp : %s\n",Xorriso_timestamP);
19895
sprintf(xorriso->result_line+strlen(xorriso->result_line),
19896
"Build timestamp : %s\n",Xorriso_build_timestamP);
19897
Xorriso_result(xorriso, 0);
19898
Xorriso_report_lib_versions(xorriso, 0);
19900
#ifdef Xorriso_GNU_xorrisO
19901
sprintf(xorriso->result_line,
19902
"License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.\n");
19903
Xorriso_result(xorriso, 0);
19904
sprintf(xorriso->result_line,
19905
"This is free software: you are free to change and redistribute it.\n");
19906
Xorriso_result(xorriso, 0);
19908
sprintf(xorriso->result_line, "Provided under GNU GPL version 2 or later.\n");
19909
Xorriso_result(xorriso, 0);
19910
#endif /* ! Xorriso_GNU_xorrisO */
19912
sprintf(xorriso->result_line,
19913
"There is NO WARRANTY, to the extent permitted by law.\n");
19914
Xorriso_result(xorriso, 0);
19919
/* Option -volid */
19920
int Xorriso_option_volid(struct XorrisO *xorriso, char *volid, int flag)
19922
int warn_shell= 0, warn_ecma= 0, i, ret;
19923
static char shell_chars[]= {
19924
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-+=:.,~@"};
19925
static char ecma_chars[]= {"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_"};
19927
for(i=0; volid[i]!=0; i++) {
19928
if(strchr(shell_chars, volid[i])==NULL)
19930
if(strchr(ecma_chars, volid[i])==NULL)
19934
sprintf(xorriso->info_text, "-volid: Text too long (%d > 32)", i);
19935
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
19939
sprintf(xorriso->info_text,
19940
"-volid text problematic as automatic mount point name");
19941
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0);
19943
if(xorriso->do_joliet && strlen(volid)>16) {
19944
sprintf(xorriso->info_text,
19945
"-volid text is too long for Joliet (%d > 16)",(int) strlen(volid));
19946
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0);
19949
sprintf(xorriso->info_text,
19950
"-volid text does not comply to ISO 9660 / ECMA 119 rules");
19951
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0);
19953
strcpy(xorriso->volid, volid);
19954
ret= Xorriso_set_volid(xorriso, volid, 0);
19957
xorriso->volid_default= (strcmp(xorriso->volid, "ISOIMAGE")==0 ||
19958
xorriso->volid[0]==0);
19963
/* Option -volset_id */
19964
int Xorriso_option_volset_id(struct XorrisO *xorriso, char *name, int flag)
19966
if(Xorriso_check_name_len(xorriso, name, (int) sizeof(xorriso->volset_id),
19967
"-volset_id", 0) <= 0)
19969
strcpy(xorriso->volset_id, name);
19970
Xorriso_set_change_pending(xorriso, 1);
19975
/* Option -volume_date */
19976
int Xorriso_option_volume_date(struct XorrisO *xorriso,
19977
char *time_type, char *timestring, int flag)
19979
int ret, t_type= 0;
19983
if(timestring[0] == 0 || strcmp(timestring, "default") == 0 ||
19984
strcmp(timestring, "overridden") == 0 ){
19986
} else if(strcmp(time_type, "uuid") == 0) {
19987
t= time(NULL); /* Just to have some that is not 0 */
19989
ret= Xorriso_convert_datestring(xorriso, "-volume_date",
19990
"m", timestring, &t_type, &t, 0);
19994
if(strcmp(time_type, "uuid") == 0) {
19996
xorriso->vol_uuid[0]= 0;
19999
ret= Decode_ecma119_format(&erg, timestring, 0);
20001
sprintf(xorriso->info_text, "-volume_date uuid : Not an ECMA-119 time string. (16 decimal digits, range 1970... to 2999...)");
20002
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
20005
strcpy(xorriso->vol_uuid, timestring);
20006
if(erg.tm_year < 138) {
20007
sprintf(xorriso->info_text,
20008
"Understanding ECMA-119 timestring '%s' as: %s",
20009
timestring, asctime(&erg));
20010
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0);
20013
} else if(strcmp(time_type, "c") == 0) {
20014
xorriso->vol_creation_time= t;
20015
} else if(strcmp(time_type, "m") == 0) {
20016
xorriso->vol_modification_time= t;
20017
} else if(strcmp(time_type, "x") == 0) {
20018
xorriso->vol_expiration_time= t;
20019
} else if(strcmp(time_type, "f") == 0) {
20020
xorriso->vol_effective_time= t;
20023
/* >>> unknown time type */;
20033
/* Option -xattr "on"|"off" */
20034
int Xorriso_option_xattr(struct XorrisO *xorriso, char *mode, int flag)
20038
if(strcmp(mode, "off")==0)
20039
xorriso->do_aaip&= ~12;
20040
else if(strcmp(mode, "on")==0)
20041
xorriso->do_aaip|= (4 | 8);
20043
sprintf(xorriso->info_text, "-xattr: unknown mode '%s'", mode);
20044
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
20047
ret= Xorriso_set_ignore_aclea(xorriso, 0);
20054
/* Option -zisofs */
20055
int Xorriso_option_zisofs(struct XorrisO *xorriso, char *mode, int flag)
20057
int was_level, was_blocksize, ret, l;
20059
char *cpt, *npt, text[16];
20061
was_level= xorriso->zlib_level;
20062
was_blocksize= xorriso->zisofs_block_size;
20064
for(cpt= mode; npt!=NULL; cpt= npt+1) {
20065
npt= strchr(cpt,':');
20073
if(strncmp(cpt, "level=", 6) == 0) {
20074
sscanf(cpt + 6, "%lf", &num);
20075
if(num < 0 || num > 9) {
20076
sprintf(xorriso->info_text,
20077
"-zisofs: Wrong zlib compression level '%s' (allowed 0...9)",
20081
xorriso->zlib_level= num;
20083
} else if(strncmp(cpt, "ziso_used=", 10) == 0 ||
20084
strncmp(cpt, "osiz_used=", 10) == 0) {
20085
/* (ignored info from -status) */;
20087
} else if(strncmp(cpt, "block_size=", 11)==0) {
20089
if(l > 11 && l < 27) {
20090
strncpy(text, cpt + 11, l - 11);
20092
num= Scanf_io_size(text, 0);
20094
if (num != (1 << 15) && num != (1 << 16) && num != (1 << 17)) {
20095
sprintf(xorriso->info_text,
20096
"-zisofs: Unsupported block size (allowed 32k, 64k, 128k)");
20099
xorriso->zisofs_block_size= num;
20101
} else if(strncmp(cpt, "by_magic=", 8)==0) {
20102
if(strncmp(cpt + 9, "on", l - 9) == 0)
20103
xorriso->zisofs_by_magic= 1;
20105
xorriso->zisofs_by_magic= 0;
20107
} else if(strncmp(cpt, "default", l)==0) {
20108
xorriso->zlib_level= xorriso->zlib_level_default;
20109
xorriso->zisofs_block_size= xorriso->zisofs_block_size_default;
20110
xorriso->zisofs_by_magic= 0;
20115
sprintf(xorriso->info_text, "-zisofs: unknown mode '%s'", cpt);
20117
sprintf(xorriso->info_text, "-zisofs: oversized mode parameter (%d)",l);
20119
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
20120
xorriso->zlib_level= was_level;
20121
xorriso->zisofs_block_size= was_blocksize;
20125
ret= Xorriso_set_zisofs_params(xorriso, 0);
20130
/* ---------------------------- End Options API ------------------------ */
20133
/* @return <0 error , >=0 number of skipped dashes
20135
int Xorriso_normalize_command(struct XorrisO *xorriso, char *original_cmd,
20136
int argno, char *cmd_data, int sizeof_cmd_data,
20137
char **cmd, int flag)
20142
if(strlen(original_cmd)>= sizeof_cmd_data) {
20144
sprintf(xorriso->info_text, "Oversized argument #%d (length %d)\n",
20145
argno, (int) strlen(original_cmd));
20147
sprintf(xorriso->info_text, "Oversized option (length %d)\n",
20148
(int) strlen(original_cmd));
20151
strcpy(cmd_data, original_cmd);
20153
if(strcmp(*cmd, xorriso->list_delimiter)==0)
20155
while((*cmd)[0]=='-') {
20161
for(dash_pt= *cmd; *dash_pt!=0; dash_pt++)
20164
return(was_dashed);
20168
/* @param flag bit0= do not warn of unknown option
20170
1=count is valid, 2=dashed unknown, 3=undashed unknown
20172
int Xorriso_count_args(struct XorrisO *xorriso, int argc, char **argv,
20173
int *count, int flag)
20175
int ret, was_dashed= 0, i;
20176
char *cmd, cmd_data[2*SfileadrL];
20177
static char arg0_commands[][40]= {
20178
"ban_stdio_write","close_filter_list","commit","devices","end",
20179
"for_backup", "help",
20180
"list_formats","no_rc","print_size","pvd_info","pwd","pwdi","pwdx",
20181
"rollback","rollback_end","tell_media_space","toc","version",
20184
static char arg1_commands[][40]= {
20185
"abort_on","acl","add_plainly","application_id","auto_charset",
20186
"backslash_codes","blank",
20187
"calm_drive","cd","cdi","cdx","charset","close",
20188
"commit_eject","compliance",
20189
"dev","dialog","disk_dev_ino","disk_pattern","dummy","dvd_obs","eject",
20190
"iso_rr_pattern","follow","format","fs","gid","grow_blindly","hardlinks",
20191
"history","indev","in_charset","joliet",
20192
"list_delimiter","list_profiles","local_charset",
20193
"mark","md5","mount_opts","not_leaf","not_list","not_mgt",
20194
"options_from_file","osirrox","outdev","out_charset","overwrite",
20195
"pacifier","padding","path_list","pathspecs","pkt_output","print","prompt",
20196
"prog","prog_help","publisher","quoted_not_list","quoted_path_list",
20197
"reassure","report_about","rom_toc_scan","scsi_log",
20198
"session_log","speed","split_size","status","status_history_max",
20199
"stdio_sync","stream_recording","system_id","temp_mem_limit",
20200
"uid","unregister_filter","use_readline","volid","volset_id",
20204
static char arg2_commands[][40]= {
20205
"assert_volid","boot_image","compare","compare_r","drive_class",
20206
"errfile_log","error_behavior","extract","extract_single",
20208
"map","map_single","page","return_with",
20209
"scdbackup_tag","update","update_r","volume_date",
20212
static char arg4_commands[][40]= {
20213
"cut_out","extract_cut","mount","mount_cmd","paste_in","session_string",
20216
static char argn_commands[][40]= {
20217
"add","alter_date","alter_date_r","as",
20218
"check_md5","check_md5_r","check_media","check_media_defaults",
20219
"chgrp","chgrpi","chgrp_r","chgrp_ri","chmod","chmodi",
20220
"chmod_r","chmod_ri","chown","chowni","chown_r","chown_ri",
20221
"compare_l","cpr","cpri","cp_rax","cp_rx","cpax","cpx",
20222
"du","dui","dus","dusi","dux","dusx","external_filter","extract_l",
20223
"file_size_limit","find","findi","finds","findx",
20224
"getfacl","getfacli","getfacl_r","getfacl_ri",
20225
"getfattr","getfattri","getfattr_r","getfattr_ri",
20226
"ls","lsi","lsl","lsli","lsd","lsdi","lsdl","lsdli",
20227
"lsx","lslx","lsdx","lsdlx","map_l","mv","mvi","mkdir","mkdiri",
20228
"not_paths","rm","rmi","rm_r","rm_ri","rmdir","rmdiri","update_l",
20229
"setfacl","setfacli","setfacl_list","setfacl_listi",
20230
"setfacl_r","setfacl_ri","setfattr","setfattri",
20231
"setfattr_list","setfattr_listi","setfattr_r","setfattr_ri",
20232
"set_filter","set_filter_r","show_stream","show_stream_r",
20239
ret= Xorriso_normalize_command(xorriso, argv[0], -1,
20240
cmd_data, sizeof(cmd_data), &cmd, 0);
20243
was_dashed= (ret>0);
20244
if(cmd[0]=='#' || cmd[0]==0 || strcmp(cmd, xorriso->list_delimiter) == 0) {
20245
/* ignore: comment line , empty option , orphaned list delimiter */
20248
for(i=0; arg0_commands[i][0]!=0; i++)
20249
if(strcmp(arg0_commands[i], cmd)==0)
20252
for(i=0; arg1_commands[i][0]!=0; i++)
20253
if(strcmp(arg1_commands[i], cmd)==0)
20256
for(i=0; arg2_commands[i][0]!=0; i++)
20257
if(strcmp(arg2_commands[i], cmd)==0)
20260
for(i=0; arg4_commands[i][0]!=0; i++)
20261
if(strcmp(arg4_commands[i], cmd)==0)
20264
for(i=0; argn_commands[i][0]!=0; i++)
20265
if(strcmp(argn_commands[i], cmd)==0) {
20266
ret= Xorriso_end_idx(xorriso, argc, argv, 1, 1);
20274
sprintf(xorriso->info_text, "Unknown option : '%s'", argv[0]);
20275
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0);
20278
return(2+!was_dashed);
20282
/* @param flag bit0= recursion
20283
bit1= these are command line arguments
20284
(for xorriso->argument_emulation)
20286
int Xorriso_interpreter(struct XorrisO *xorriso,
20287
int argc, char **argv, int *idx, int flag)
20290
<=0 error , 1 = success , 2 = problem event ignored , 3 = end program run
20293
int ret, was_dashed, end_ret, num1, num2;
20294
char *cmd, *original_cmd, cmd_data[2*SfileadrL], *arg1, *arg2;
20298
if(xorriso->is_dialog) {
20299
xorriso->result_line_counter= xorriso->result_page_counter= 0;
20300
if(xorriso->result_page_length<0)
20301
xorriso->result_page_length= -xorriso->result_page_length;
20307
if(xorriso->argument_emulation==1)
20308
ret= Xorriso_as_genisofs(xorriso, argc, argv, idx, 0);
20309
else if(xorriso->argument_emulation==2)
20310
ret= Xorriso_as_cdrskin(xorriso, argc, argv, idx, 0);
20311
if(xorriso->argument_emulation>0) {
20312
xorriso->argument_emulation= 0;
20314
goto eval_any_problems;
20320
xorriso->prepended_wd= 0;
20321
xorriso->request_to_abort= xorriso->request_not_to_ask= 0;
20322
Xorriso_set_problem_status(xorriso, "", 0);
20324
original_cmd= cmd= argv[*idx];
20326
original_cmd= cmd= "";
20327
if(xorriso->add_plainly==3 && cmd[0] && !xorriso->is_dialog) {
20329
goto add_plain_argument;
20333
ret= Xorriso_normalize_command(xorriso, original_cmd, -1,
20334
cmd_data, sizeof(cmd_data), &cmd, 0);
20336
goto eval_any_problems;
20341
arg1= argv[(*idx)];
20345
arg2= argv[(*idx)+1];
20350
if(cmd[0]=='#' || cmd[0]==0) {
20351
/* ignore comment line and empty option */;
20353
} else if(strcmp(cmd,"abort_on")==0) {
20355
ret= Xorriso_option_abort_on(xorriso, arg1, 0);
20357
} else if(strcmp(cmd,"acl")==0) {
20359
ret= Xorriso_option_acl(xorriso, arg1, 0);
20361
} else if(strcmp(cmd,"add")==0) {
20362
ret= Xorriso_option_add(xorriso, argc, argv, idx, 0);
20364
} else if(strcmp(cmd,"add_plainly")==0) {
20366
ret= Xorriso_option_add_plainly(xorriso, arg1, 0);
20368
} else if(strcmp(cmd,"alter_date")==0 || strcmp(cmd,"alter_date_r")==0) {
20370
ret= Xorriso_option_alter_date(xorriso, arg1, arg2, argc, argv, idx,
20373
} else if(strcmp(cmd,"application_id")==0) {
20375
ret= Xorriso_option_application_id(xorriso, arg1, 0);
20377
} else if(strcmp(cmd,"as")==0) {
20378
ret= Xorriso_option_as(xorriso, argc, argv, idx, 0);
20380
} else if(strcmp(cmd,"assert_volid")==0) {
20382
ret= Xorriso_option_assert_volid(xorriso, arg1, arg2, 0);
20384
} else if(strcmp(cmd,"auto_charset")==0) {
20386
ret= Xorriso_option_auto_charset(xorriso, arg1, 0);
20388
} else if(strcmp(cmd,"backslash_codes")==0) {
20390
ret= Xorriso_option_backslash_codes(xorriso, arg1, 0);
20392
} else if(strcmp(cmd,"ban_stdio_write")==0) {
20393
ret= Xorriso_option_ban_stdio_write(xorriso, 0);
20395
} else if(strcmp(cmd,"blank")==0) {
20397
ret= Xorriso_option_blank(xorriso, arg1, 0);
20399
} else if(strcmp(cmd,"boot_image")==0) {
20401
ret= Xorriso_option_boot_image(xorriso, arg1, arg2, 0);
20403
} else if(strcmp(cmd,"calm_drive")==0) {
20405
ret= Xorriso_option_calm_drive(xorriso, arg1, 0);
20407
} else if(strcmp(cmd,"cd")==0 || strcmp(cmd,"cdi")==0) {
20409
ret= Xorriso_option_cdi(xorriso, arg1, 0);
20411
} else if(strcmp(cmd,"cdx")==0) {
20413
ret= Xorriso_option_cdx(xorriso, arg1, 0);
20415
} else if(strcmp(cmd,"charset")==0) {
20417
ret= Xorriso_option_charset(xorriso, arg1, 3);
20419
} else if(strcmp(cmd,"check_md5")==0) {
20420
ret= Xorriso_option_check_md5(xorriso, argc, argv, idx, 0);
20422
} else if(strcmp(cmd,"check_md5_r")==0) {
20423
ret= Xorriso_option_check_md5(xorriso, argc, argv, idx, 8);
20425
} else if(strcmp(cmd,"check_media")==0) {
20426
ret= Xorriso_option_check_media(xorriso, argc, argv, idx, 0);
20428
} else if(strcmp(cmd,"check_media_defaults")==0) {
20429
ret= Xorriso_option_check_media_defaults(xorriso, argc, argv, idx, 0);
20431
} else if(strcmp(cmd,"chgrp")==0 || strcmp(cmd,"chgrpi")==0) {
20433
ret= Xorriso_option_chgrpi(xorriso, arg1, argc, argv, idx, 0);
20435
} else if(strcmp(cmd,"chgrp_r")==0 || strcmp(cmd,"chgrp_ri")==0) {
20437
ret= Xorriso_option_chgrpi(xorriso, arg1, argc, argv, idx, 1);
20439
} else if(strcmp(cmd,"chmod")==0 || strcmp(cmd,"chmodi")==0) {
20441
ret= Xorriso_option_chmodi(xorriso, arg1, argc, argv, idx, 0);
20443
} else if(strcmp(cmd,"chmod_r")==0 || strcmp(cmd,"chmod_ri")==0) {
20445
ret= Xorriso_option_chmodi(xorriso, arg1, argc, argv, idx, 1);
20447
} else if(strcmp(cmd,"chown_r")==0 || strcmp(cmd,"chown_ri")==0) {
20449
ret= Xorriso_option_chowni(xorriso, arg1, argc, argv, idx, 1);
20451
} else if(strcmp(cmd,"chown")==0 || strcmp(cmd,"chowni")==0) {
20453
ret= Xorriso_option_chowni(xorriso, arg1, argc, argv, idx, 0);
20455
} else if(strcmp(cmd,"close")==0) {
20457
ret= Xorriso_option_close(xorriso, arg1, 0);
20459
} else if(strcmp(cmd,"close_filter_list")==0) {
20460
ret= Xorriso_option_close_filter_list(xorriso, 0);
20462
} else if(strcmp(cmd,"commit")==0) {
20463
ret= Xorriso_option_commit(xorriso, 0);
20465
} else if(strcmp(cmd,"commit_eject")==0) {
20467
ret= Xorriso_option_commit_eject(xorriso, arg1, 0);
20469
} else if(strcmp(cmd,"compare")==0) {
20471
ret= Xorriso_option_compare(xorriso, arg1, arg2, 1);
20473
} else if(strcmp(cmd,"compare_l")==0) {
20474
ret= Xorriso_option_map_l(xorriso, argc, argv, idx, 1<<8);
20476
} else if(strcmp(cmd,"compare_r")==0) {
20478
ret= Xorriso_option_compare(xorriso, arg1, arg2, 1|8);
20480
} else if(strcmp(cmd,"compliance")==0) {
20482
Xorriso_option_compliance(xorriso, arg1, 0);
20484
} else if(strcmp(cmd,"cpr")==0 || strcmp(cmd,"cpri")==0) {
20485
ret= Xorriso_option_cpri(xorriso, argc, argv, idx, 0);
20487
} else if(strcmp(cmd,"cp_rx")==0 || strcmp(cmd,"cp_rax")==0) {
20488
ret= Xorriso_option_cpx(xorriso, argc, argv, idx,
20489
1|((strcmp(cmd,"cp_rax")==0)<<1));
20491
} else if(strcmp(cmd,"cpx")==0 || strcmp(cmd,"cpax")==0) {
20492
ret= Xorriso_option_cpx(xorriso, argc, argv, idx,
20493
(strcmp(cmd,"cpax")==0)<<1);
20495
} else if(strcmp(cmd,"cut_out")==0) {
20498
sprintf(xorriso->info_text,
20499
"-cut_out: Not enough arguments. Needed are: disk_path start count so_rr_path");
20500
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
20503
ret= Xorriso_option_cut_out(xorriso, arg1, arg2,
20504
argv[(*idx)-2], argv[(*idx)-1], 0);
20506
} else if(strcmp(cmd,"dev")==0) {
20508
ret= Xorriso_option_dev(xorriso, arg1, 3);
20510
} else if(strcmp(cmd,"devices")==0) {
20511
ret= Xorriso_option_devices(xorriso, 0);
20513
} else if(strcmp(cmd,"dialog")==0) {
20515
ret= Xorriso_option_dialog(xorriso, arg1, 0);
20517
} else if(strcmp(cmd,"disk_dev_ino")==0) {
20519
ret= Xorriso_option_disk_dev_ino(xorriso, arg1, 0);
20521
} else if(strcmp(cmd,"disk_pattern")==0) {
20523
ret= Xorriso_option_disk_pattern(xorriso, arg1, 0);
20525
} else if(strcmp(cmd,"drive_class")==0) {
20527
ret= Xorriso_option_drive_class(xorriso, arg1, arg2, 0);
20529
} else if(strcmp(cmd,"du")==0 || strcmp(cmd,"dui")==0 ||
20530
strcmp(cmd,"dus")==0 || strcmp(cmd,"dusi")==0) {
20531
ret= Xorriso_option_lsi(xorriso, argc, argv, idx, (cmd[2]!='s')|4);
20533
} else if(strcmp(cmd,"dummy")==0) {
20535
ret= Xorriso_option_dummy(xorriso, arg1, 0);
20537
} else if(strcmp(cmd,"dvd_obs")==0) {
20539
ret= Xorriso_option_dvd_obs(xorriso, arg1, 0);
20541
} else if(strcmp(cmd,"dux")==0 || strcmp(cmd,"dusx")==0) {
20542
ret= Xorriso_option_lsx(xorriso, argc, argv, idx, (cmd[2]!='s')|4);
20544
} else if(strcmp(cmd,"eject")==0) {
20546
ret= Xorriso_option_eject(xorriso, arg1, 0);
20548
} else if(strcmp(cmd,"end")==0) {
20549
end_ret= Xorriso_option_end(xorriso, 0);
20550
ret= Xorriso_eval_problem_status(xorriso, ret, 0);
20556
} else if(strcmp(cmd,"errfile_log")==0) {
20558
ret= Xorriso_option_errfile_log(xorriso, arg1, arg2, 0);
20560
} else if(strcmp(cmd,"error_behavior")==0) {
20562
ret= Xorriso_option_error_behavior(xorriso, arg1, arg2, 0);
20564
} else if(strcmp(cmd,"external_filter")==0) {
20565
ret= Xorriso_option_external_filter(xorriso, argc, argv, idx, 0);
20567
} else if(strcmp(cmd,"extract")==0) {
20569
ret= Xorriso_option_extract(xorriso, arg1, arg2, 0);
20571
} else if(strcmp(cmd,"extract_cut")==0) {
20574
sprintf(xorriso->info_text,
20575
"-extract_cut: Not enough arguments. Needed are: disk_path start count so_rr_path");
20576
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
20579
ret= Xorriso_option_extract_cut(xorriso, arg1, arg2,
20580
argv[(*idx)-2], argv[(*idx)-1], 0);
20582
} else if(strcmp(cmd,"extract_l")==0) {
20583
ret= Xorriso_option_map_l(xorriso, argc, argv, idx, 3<<8);
20585
} else if(strcmp(cmd,"extract_single")==0) {
20587
ret= Xorriso_option_extract(xorriso, arg1, arg2, 32);
20589
} else if(strcmp(cmd,"file_size_limit")==0) {
20590
ret= Xorriso_option_file_size_limit(xorriso, argc, argv, idx, 0);
20592
} else if(strcmp(cmd,"find")==0 || strcmp(cmd,"findi")==0) {
20593
ret= Xorriso_option_find(xorriso, argc, argv, idx, 0);
20595
} else if(strcmp(cmd,"findx")==0) {
20596
ret= Xorriso_option_find(xorriso, argc, argv, idx, 1);
20598
} else if(strcmp(cmd,"follow")==0) {
20600
ret= Xorriso_option_follow(xorriso, arg1, 0);
20602
} else if(strcmp(cmd,"for_backup")==0) {
20603
Xorriso_option_hardlinks(xorriso, "on", 0);
20604
Xorriso_option_acl(xorriso, "on", 0);
20605
Xorriso_option_xattr(xorriso, "on", 0);
20606
Xorriso_option_md5(xorriso, "on", 0);
20609
} else if(strcmp(cmd,"format")==0) {
20611
ret= Xorriso_option_blank(xorriso, arg1, 1);
20613
} else if(strcmp(cmd,"fs")==0) {
20615
ret= Xorriso_option_fs(xorriso, arg1, 0);
20617
} else if(strcmp(cmd,"getfacl")==0 || strcmp(cmd,"getfacli")==0) {
20618
ret= Xorriso_option_getfacli(xorriso, argc, argv, idx, 0);
20620
} else if(strcmp(cmd,"getfacl_r")==0 || strcmp(cmd,"getfacl_ri")==0) {
20621
ret= Xorriso_option_getfacli(xorriso, argc, argv, idx, 1);
20623
} else if(strcmp(cmd,"getfattr")==0 || strcmp(cmd,"getfattri")==0) {
20624
ret= Xorriso_option_getfacli(xorriso, argc, argv, idx, 2);
20626
} else if(strcmp(cmd,"getfattr_r")==0 || strcmp(cmd,"getfattr_ri")==0) {
20627
ret= Xorriso_option_getfacli(xorriso, argc, argv, idx, 1 | 2);
20629
} else if(strcmp(cmd,"gid")==0) {
20631
ret= Xorriso_option_gid(xorriso,arg1,0);
20633
} else if(strcmp(cmd,"grow_blindly")==0) {
20635
ret= Xorriso_option_grow_blindly(xorriso,arg1,0);
20637
} else if(strcmp(cmd,"hardlinks")==0) {
20639
ret= Xorriso_option_hardlinks(xorriso, arg1, 0);
20641
} else if(strcmp(cmd,"help")==0) {
20642
Xorriso_option_help(xorriso,0);
20644
} else if(strcmp(cmd,"history")==0) {
20645
/* add to readline history */
20647
ret= Xorriso_option_history(xorriso, arg1, 0);
20649
} else if(strcmp(cmd,"indev")==0) {
20651
ret= Xorriso_option_dev(xorriso, arg1, 1);
20653
} else if(strcmp(cmd,"in_charset")==0) {
20655
ret= Xorriso_option_charset(xorriso, arg1, 1);
20657
} else if(strcmp(cmd,"iso_rr_pattern")==0) {
20659
ret= Xorriso_option_iso_rr_pattern(xorriso, arg1, 0);
20661
} else if(strcmp(cmd,"joliet")==0) {
20663
ret= Xorriso_option_joliet(xorriso, arg1, 0);
20665
} else if(strcmp(cmd, "list_delimiter") == 0) {
20667
ret= Xorriso_option_list_delimiter(xorriso, arg1, 0);
20669
} else if(strcmp(cmd,"list_formats")==0) {
20670
ret= Xorriso_option_list_formats(xorriso, 0);
20672
} else if(strcmp(cmd,"list_profiles")==0) {
20674
ret= Xorriso_option_list_profiles(xorriso, arg1, 0);
20676
} else if(strcmp(cmd,"load")==0) {
20678
ret= Xorriso_option_load(xorriso, arg1, arg2, 0);
20680
} else if(strcmp(cmd,"local_charset")==0) {
20682
ret= Xorriso_option_charset(xorriso, arg1, 4);
20684
} else if(strcmp(cmd,"logfile")==0) {
20686
ret= Xorriso_option_logfile(xorriso, arg1, arg2, 0);
20688
} else if(strcmp(cmd,"ls")==0 || strcmp(cmd,"lsi")==0 ||
20689
strcmp(cmd,"lsl")==0 || strcmp(cmd,"lsli")==0) {
20690
ret= Xorriso_option_lsi(xorriso, argc, argv, idx, (cmd[2]=='l'));
20692
} else if(strcmp(cmd,"lsd")==0 || strcmp(cmd,"lsdi")==0 ||
20693
strcmp(cmd,"lsdl")==0 || strcmp(cmd,"lsdli")==0) {
20694
ret= Xorriso_option_lsi(xorriso, argc, argv, idx, (cmd[3]=='l')|8);
20696
} else if(strcmp(cmd,"lsdx")==0 || strcmp(cmd,"lsdlx")==0) {
20697
ret= Xorriso_option_lsx(xorriso, argc, argv, idx, (cmd[3]=='l')|8);
20699
} else if(strcmp(cmd,"lsx")==0 || strcmp(cmd,"lslx")==0) {
20700
ret= Xorriso_option_lsx(xorriso, argc, argv, idx, (cmd[2]=='l'));
20702
} else if(strcmp(cmd,"map")==0) {
20704
ret= Xorriso_option_map(xorriso, arg1, arg2, 0);
20706
} else if(strcmp(cmd,"map_l")==0) {
20707
ret= Xorriso_option_map_l(xorriso, argc, argv, idx, 0);
20709
} else if(strcmp(cmd,"map_single")==0) {
20711
ret= Xorriso_option_map(xorriso, arg1, arg2, 32);
20713
} else if(strcmp(cmd,"mark")==0) {
20715
ret= Xorriso_option_mark(xorriso, arg1, 0);
20717
} else if(strcmp(cmd, "md5")==0) {
20719
ret= Xorriso_option_md5(xorriso, arg1, 0);
20721
} else if(strcmp(cmd, "mount") == 0 || strcmp(cmd, "mount_cmd") == 0) {
20724
sprintf(xorriso->info_text,
20725
"-%s: Not enough arguments. Needed are: device entity id command",
20727
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
20730
ret= Xorriso_option_mount(xorriso, arg1, arg2,
20731
argv[(*idx)-2], argv[(*idx)-1],
20732
(strcmp(cmd, "mount_cmd") == 0));
20734
} else if(strcmp(cmd, "mount_opts")==0) {
20736
ret= Xorriso_option_mount_opts(xorriso, arg1, 0);
20738
} else if(strcmp(cmd,"mv")==0 || strcmp(cmd,"mvi")==0) {
20739
ret= Xorriso_option_mvi(xorriso, argc, argv, idx, 0);
20741
} else if(strcmp(cmd,"mkdir")==0 || strcmp(cmd,"mkdiri")==0) {
20742
ret= Xorriso_option_mkdiri(xorriso, argc, argv, idx, 0);
20744
} else if(strcmp(cmd,"no_rc")==0) {
20745
ret= Xorriso_option_no_rc(xorriso, 0);
20747
} else if(strcmp(cmd,"not_leaf")==0) {
20749
ret= Xorriso_option_not_leaf(xorriso, arg1, 0);
20751
} else if(strcmp(cmd,"not_list")==0) {
20753
ret= Xorriso_option_not_list(xorriso, arg1, 0);
20755
} else if(strcmp(cmd,"not_mgt")==0) {
20757
ret= Xorriso_option_not_mgt(xorriso, arg1, 0);
20759
} else if(strcmp(cmd,"not_paths")==0) {
20760
ret= Xorriso_option_not_paths(xorriso, argc, argv, idx, 0);
20762
} else if(strcmp(cmd,"options_from_file")==0) {
20764
ret= Xorriso_option_options_from_file(xorriso,arg1,0);
20768
} else if(strcmp(cmd,"osirrox")==0) {
20770
ret= Xorriso_option_osirrox(xorriso,arg1,0);
20772
} else if(strcmp(cmd,"outdev")==0) {
20774
ret= Xorriso_option_dev(xorriso, arg1, 2);
20776
} else if(strcmp(cmd,"out_charset")==0) {
20778
ret= Xorriso_option_charset(xorriso, arg1, 2);
20780
} else if(strcmp(cmd,"overwrite")==0) {
20782
ret= Xorriso_option_overwrite(xorriso,arg1,0);
20784
} else if(strcmp(cmd,"pacifier")==0) {
20786
ret= Xorriso_option_pacifier(xorriso, arg1, 0);
20788
} else if(strcmp(cmd,"padding")==0) {
20790
ret= Xorriso_option_padding(xorriso, arg1, 0);
20792
} else if(strcmp(cmd,"page")==0) {
20795
sscanf(arg1,"%d",&num1);
20796
sscanf(arg2,"%d",&num2);
20803
ret= Xorriso_option_page(xorriso, num1, num2, 0);
20805
} else if(strcmp(cmd,"paste_in")==0) {
20808
sprintf(xorriso->info_text,
20809
"-paste_in: Not enough arguments. Needed are: disk_path start count so_rr_path");
20810
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
20813
ret= Xorriso_option_paste_in(xorriso, arg1, arg2,
20814
argv[(*idx)-2], argv[(*idx)-1], 0);
20816
} else if(strcmp(cmd,"path-list")==0 || strcmp(cmd,"path_list")==0) {
20818
ret= Xorriso_option_path_list(xorriso, arg1, 0);
20820
} else if(strcmp(cmd,"pathspecs")==0) {
20822
ret= Xorriso_option_pathspecs(xorriso, arg1, 0);
20824
} else if(strcmp(cmd,"pkt_output")==0) {
20826
ret= Xorriso_option_pkt_output(xorriso, arg1, 0);
20828
} else if(strcmp(cmd,"print")==0) {
20830
ret= Xorriso_option_print(xorriso, arg1, 0);
20832
} else if(strcmp(cmd,"print_size")==0) {
20833
Xorriso_option_print_size(xorriso, 0);
20835
} else if(strcmp(cmd,"prompt")==0) {
20837
ret= Xorriso_option_prompt(xorriso, arg1, 0);
20839
} else if(strcmp(cmd,"prog")==0) {
20841
ret= Xorriso_option_prog(xorriso, arg1, 0);
20843
} else if(strcmp(cmd,"publisher")==0) {
20845
Xorriso_option_publisher(xorriso, arg1, 0);
20847
} else if(strcmp(cmd,"pvd_info")==0) {
20848
Xorriso_option_pvd_info(xorriso, 0);
20850
} else if(strcmp(cmd,"pwd")==0 || strcmp(cmd,"pwdi")==0) {
20851
Xorriso_option_pwdi(xorriso, 0);
20853
} else if(strcmp(cmd,"pwdx")==0) {
20854
Xorriso_option_pwdx(xorriso, 0);
20856
} else if(strcmp(cmd,"quoted_not_list")==0) {
20858
ret= Xorriso_option_not_list(xorriso, arg1, 1);
20860
} else if(strcmp(cmd,"quoted_path_list")==0) {
20862
ret= Xorriso_option_path_list(xorriso, arg1, 1);
20864
} else if(strcmp(cmd,"reassure")==0) {
20866
ret= Xorriso_option_reassure(xorriso, arg1, 0);
20868
} else if(strcmp(cmd,"report_about")==0) {
20870
ret= Xorriso_option_report_about(xorriso, arg1, 0);
20872
} else if(strcmp(cmd,"return_with")==0) {
20875
sscanf(arg2,"%d",&num2);
20876
ret= Xorriso_option_return_with(xorriso, arg1, num2, 0);
20878
} else if(strcmp(cmd,"rm")==0 || strcmp(cmd,"rmi")==0) {
20879
ret= Xorriso_option_rmi(xorriso, argc, argv, idx, 0);
20881
} else if(strcmp(cmd,"rm_r")==0 || strcmp(cmd,"rm_ri")==0) {
20882
ret= Xorriso_option_rmi(xorriso, argc, argv, idx, 1);
20884
} else if(strcmp(cmd,"rmdir")==0 || strcmp(cmd,"rmdiri")==0) {
20885
ret= Xorriso_option_rmi(xorriso, argc, argv, idx, 2);
20887
} else if(strcmp(cmd,"rollback")==0) {
20888
ret= Xorriso_option_rollback(xorriso, 0);
20890
} else if(strcmp(cmd,"rollback_end")==0) {
20891
end_ret= Xorriso_option_end(xorriso, 1);
20892
ret= Xorriso_eval_problem_status(xorriso, ret, 0);
20898
} else if(strcmp(cmd,"rom_toc_scan")==0) {
20900
Xorriso_option_rom_toc_scan(xorriso, arg1, 0);
20902
} else if(strcmp(cmd,"scdbackup_tag")==0) {
20904
ret= Xorriso_option_scdbackup_tag(xorriso, arg1, arg2, 0);
20906
} else if(strcmp(cmd, "scsi_log") == 0) {
20908
ret= Xorriso_option_scsi_log(xorriso, arg1, 0);
20910
} else if(strcmp(cmd,"session_log")==0) {
20912
ret= Xorriso_option_session_log(xorriso, arg1, 0);
20914
} else if(strcmp(cmd, "session_string") == 0) {
20917
sprintf(xorriso->info_text,
20918
"-%s: Not enough arguments. Needed are: device entity id command",
20920
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
20923
ret= Xorriso_option_mount(xorriso, arg1, arg2,
20924
argv[(*idx)-2], argv[(*idx)-1], 2);
20926
} else if(strcmp(cmd,"setfacl")==0 || strcmp(cmd,"setfacli")==0) {
20928
ret= Xorriso_option_setfacli(xorriso, arg1, argc, argv, idx, 0);
20930
} else if(strcmp(cmd,"setfacl_list")==0 || strcmp(cmd,"setfacl_listi")==0) {
20932
ret= Xorriso_option_setfacl_listi(xorriso, arg1, 0);
20934
} else if(strcmp(cmd,"setfacl_r")==0 || strcmp(cmd,"setfacl_ri")==0) {
20936
ret= Xorriso_option_setfacli(xorriso, arg1, argc, argv, idx, 1);
20938
} else if(strcmp(cmd,"setfattr")==0 || strcmp(cmd,"setfattri")==0) {
20940
ret= Xorriso_option_setfattri(xorriso, arg1, arg2, argc, argv, idx, 0);
20942
} else if(strcmp(cmd,"setfattr_list")==0 || strcmp(cmd,"setfattr_listi")==0) {
20944
ret= Xorriso_option_setfattr_listi(xorriso, arg1, 0);
20946
} else if(strcmp(cmd,"setfattr_r")==0 || strcmp(cmd,"setfattr_ri")==0) {
20948
ret= Xorriso_option_setfattri(xorriso, arg1, arg2, argc, argv, idx, 1);
20950
} else if(strcmp(cmd,"set_filter")==0 || strcmp(cmd,"set_filter_r")==0) {
20952
ret= Xorriso_option_set_filter(xorriso, arg1, argc, argv, idx,
20953
strcmp(cmd,"set_filter_r")==0);
20955
} else if(strcmp(cmd,"show_stream")==0 || strcmp(cmd,"show_stream_r")==0) {
20956
ret= Xorriso_option_set_filter(xorriso, "", argc, argv, idx,
20957
(strcmp(cmd,"show_stream_r")==0) | 2 | 4);
20959
} else if(strcmp(cmd,"speed")==0) {
20961
ret= Xorriso_option_speed(xorriso, arg1, 0);
20963
} else if(strcmp(cmd,"split_size")==0) {
20965
ret= Xorriso_option_split_size(xorriso, arg1, 0);
20967
} else if(strcmp(cmd,"status")==0) {
20969
ret= Xorriso_option_status(xorriso, arg1, 0);
20971
} else if(strcmp(cmd,"status_history_max")==0) {
20973
sscanf(arg1,"%d",&num1);
20974
ret= Xorriso_option_status_history_max(xorriso, num1, 0);
20976
} else if(strcmp(cmd,"stdio_sync")==0) {
20978
ret= Xorriso_option_stdio_sync(xorriso, arg1, 0);
20980
} else if(strcmp(cmd,"stream_recording")==0) {
20982
ret= Xorriso_option_stream_recording(xorriso, arg1, 0);
20984
} else if(strcmp(cmd,"system_id")==0) {
20986
ret= Xorriso_option_system_id(xorriso, arg1, 0);
20988
} else if(strcmp(cmd,"tell_media_space")==0) {
20989
Xorriso_option_tell_media_space(xorriso, 0);
20991
} else if(strcmp(cmd,"temp_mem_limit")==0) {
20993
ret= Xorriso_option_temp_mem_limit(xorriso, arg1, 0);
20995
} else if(strcmp(cmd,"test")==0) { /* This option does not exist. */
20997
/* install temporary test code here */;
20999
} else if(strcmp(cmd,"toc")==0) {
21000
Xorriso_option_toc(xorriso, 0);
21002
} else if(strcmp(cmd,"uid")==0) {
21004
ret= Xorriso_option_uid(xorriso,arg1,0);
21006
} else if(strcmp(cmd,"unregister_filter")==0) {
21008
ret= Xorriso_option_unregister_filter(xorriso, arg1, 0);
21010
} else if(strcmp(cmd,"update")==0) {
21012
ret= Xorriso_option_update(xorriso, arg1, arg2, 1);
21014
} else if(strcmp(cmd,"update_l")==0) {
21015
ret= Xorriso_option_map_l(xorriso, argc, argv, idx, 2<<8);
21017
} else if(strcmp(cmd,"update_r")==0) {
21019
ret= Xorriso_option_update(xorriso, arg1, arg2, 1|8);
21021
} else if(strcmp(cmd,"use_readline")==0) {
21023
ret= Xorriso_option_use_readline(xorriso, arg1, 0);
21025
} else if(strcmp(cmd,"version")==0){
21026
ret= Xorriso_option_version(xorriso, 0);
21028
} else if(strcmp(cmd,"volset_id")==0) {
21030
ret= Xorriso_option_volset_id(xorriso, arg1, 0);
21032
} else if(strcmp(cmd,"volid")==0) {
21034
ret= Xorriso_option_volid(xorriso,arg1,0);
21036
} else if(strcmp(cmd,"volume_date")==0) {
21038
ret= Xorriso_option_volume_date(xorriso, arg1, arg2, 0);
21040
} else if(strcmp(cmd,"xattr")==0) {
21042
ret= Xorriso_option_xattr(xorriso, arg1, 0);
21044
} else if(strcmp(cmd,"zisofs")==0) {
21046
ret= Xorriso_option_zisofs(xorriso, arg1, 0);
21048
} else if(strcmp(cmd, xorriso->list_delimiter)==0){
21051
} else if(was_dashed) {
21052
if(xorriso->add_plainly>1)
21053
goto add_plain_argument;
21055
sprintf(xorriso->info_text, "Not a known option: '%s'\n",
21057
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
21058
{ret= 0; goto eval_any_problems;}
21061
if(xorriso->add_plainly<=0)
21062
goto unknown_option;
21063
add_plain_argument:;
21065
ret= Xorriso_option_add(xorriso, (*idx)+1, argv, idx, 0);
21071
ret= Xorriso_eval_problem_status(xorriso, ret, 0);
21079
if((!xorriso->is_dialog) && !(flag&1))
21080
Xorriso_mark(xorriso,0);
21086
int Xorriso_execute_option(struct XorrisO *xorriso, char *line, int flag)
21088
bit0-bit15 are forwarded to Xorriso_interpreter
21090
bit16= no pageing of info lines
21091
bit17= print === bar even if xorriso->found<0
21094
int ret,argc= 0, idx= 1;
21098
struct timezone tz;
21100
gettimeofday(&tv,&tz);
21101
Xorriso_reset_counters(xorriso,0);
21102
xorriso->idle_time= 0.0;
21103
tdiff= tv.tv_sec+(1.e-6*(double) tv.tv_usec);
21105
/* parse line into args */
21106
ret= Sfile_make_argv(xorriso->progname, line, &argc, &argv,
21107
4 | ((xorriso->bsl_interpretation & 3) << 5));
21109
Xorriso_msgs_submit(xorriso, 0,
21110
"Severe lack of resources during command line parsing", 0, "FATAL", 0);
21114
sprintf(xorriso->info_text, "Incomplete quotation in command line: %s",
21116
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
21121
if(argv[1][0]=='#')
21124
ret= Xorriso_interpreter(xorriso, argc, argv, &idx, flag&0xffff);
21127
gettimeofday(&tv,&tz);
21128
tdiff= tv.tv_sec+(1.e-6*(double) tv.tv_usec)-tdiff-xorriso->idle_time;
21131
if(xorriso->error_count>0) {
21132
sprintf(xorriso->info_text,
21133
"----------------------------- %7.f errors encountered\n",
21134
xorriso->error_count);
21135
Xorriso_info(xorriso,!(flag&(1<<16)));
21138
/* ??? >>> print elapsed time tdiff ? */;
21140
if((flag&(1<<17)) && !xorriso->bar_is_fresh) {
21141
sprintf(xorriso->info_text,"============================\n");
21142
Xorriso_info(xorriso,0);
21143
xorriso->bar_is_fresh= 1;
21145
Xorriso_reset_counters(xorriso,0);
21147
Sfile_make_argv("", "", &argc, &argv, 2); /* release memory */
21152
int Xorriso_dialog(struct XorrisO *xorriso, int flag)
21154
int ret,first_round;
21155
char line[2*SfileadrL];
21157
if(!xorriso->dialog)
21159
xorriso->is_dialog= 1;
21160
for(first_round= 1;1;first_round= 0) {
21161
if(xorriso->pending_option[0]!=0) {
21162
Xorriso_mark(xorriso,0);
21163
strcpy(line,xorriso->pending_option);
21164
xorriso->pending_option[0]= 0;
21166
if(!xorriso->bar_is_fresh) {
21167
sprintf(xorriso->info_text,"============================\n");
21168
Xorriso_info(xorriso,0);
21169
xorriso->bar_is_fresh= 1;
21171
sprintf(xorriso->info_text,"enter option and arguments :\n");
21172
Xorriso_info(xorriso,0);
21173
Xorriso_mark(xorriso,0);
21174
ret= Xorriso_dialog_input(xorriso,line,sizeof(line),4);
21178
sprintf(xorriso->info_text,
21179
"==============================================================\n");
21180
Xorriso_info(xorriso,0);
21182
ret= Xorriso_execute_option(xorriso,line,1<<17);
21187
xorriso->did_something_useful= 1;
21188
xorriso->no_volset_present= 0; /* Re-enable "No ISO image present." */
21192
xorriso->is_dialog= 0;
21197
int Xorriso_change_is_pending(struct XorrisO *xorriso, int flag)
21199
return(!!xorriso->volset_change_pending);
21203
int Xorriso_protect_stdout(struct XorrisO *xorriso, int flag)
21205
if(xorriso->dev_fd_1>=0)
21207
xorriso->dev_fd_1= dup(1);
21214
int Xorriso_prescan_args(struct XorrisO *xorriso, int argc, char **argv,
21217
bit0= do not interpret argv[1]
21226
int i, ret, was_dashed, num2, arg_count;
21227
int was_report_about= 0, was_abort_on= 0, was_return_with= 0;
21228
char *cmd, *original_cmd, cmd_data[5*SfileadrL], *arg1, *arg2;
21229
char mem_list_delimiter[81];
21231
strcpy(mem_list_delimiter, xorriso->list_delimiter);
21232
for(i=1+(flag&1);i<argc;i++) {
21233
original_cmd= cmd= argv[i];
21236
was_dashed= Xorriso_normalize_command(xorriso, original_cmd, i,
21237
cmd_data, sizeof(cmd_data), &cmd, 0);
21239
{ret= -1; goto ex;}
21248
xorriso->did_something_useful= 1;
21249
if(i==1 && argc==2) {
21250
if(strcmp(cmd,"prog_help")==0) {
21252
Xorriso_option_prog_help(xorriso,arg1,0);
21253
xorriso->did_something_useful= 1;
21255
} else if(strcmp(cmd,"help")==0) {
21256
if(xorriso->argument_emulation == 1) {
21257
Xorriso_genisofs_help(xorriso, 0);
21258
} else if(xorriso->argument_emulation == 2) {
21259
Xorriso_cdrskin_help(xorriso, 0);
21261
Xorriso_option_help(xorriso,0);
21263
xorriso->did_something_useful= 1;
21266
} else if(i==1 && strcmp(cmd,"no_rc")==0) {
21267
ret= Xorriso_option_no_rc(xorriso, 0);
21271
} else if((strcmp(cmd,"dev")==0 || strcmp(cmd,"outdev")==0 ||
21272
strcmp(cmd,"indev")==0) &&
21273
(strcmp(arg1,"stdio:/dev/fd/1")==0 || strcmp(arg1,"-")==0) &&
21274
xorriso->dev_fd_1<0) {
21275
/* Detach fd 1 from externally perceived stdout and attach it to stderr.
21276
Keep dev_fd_1 connected to external stdout. dev_fd_1 is to be used when
21277
"stdio:/dev/fd/1" is interpreted as drive address.
21280
Xorriso_protect_stdout(xorriso, 0);
21281
sprintf(xorriso->info_text,
21282
"Encountered - or stdio:/dev/fd/1 as possible write target.");
21283
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0);
21284
sprintf(xorriso->info_text,
21285
"Redirecting nearly all text message output to stderr.");
21286
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0);
21287
sprintf(xorriso->info_text, "Disabling use of libreadline.");
21288
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0);
21290
} else if(strcmp(cmd,"abort_on")==0 && was_dashed == 1) {
21293
Xorriso_option_abort_on(xorriso, arg1, 0);
21296
} else if(strcmp(cmd,"report_about")==0 && was_dashed == 1) {
21298
if(!was_report_about)
21299
Xorriso_option_report_about(xorriso, arg1, 0);
21300
was_report_about= 1;
21302
} else if(strcmp(cmd,"return_with")==0 && was_dashed == 1) {
21305
sscanf(arg2,"%d",&num2);
21306
if(!was_return_with)
21307
Xorriso_option_return_with(xorriso, arg1, num2, 0);
21308
was_return_with= 1;
21310
} else if(strcmp(cmd,"as")==0 && was_dashed == 1) {
21311
if(strcmp(arg1, "mkisofs")==0 || strcmp(arg1, "genisoimage")==0 ||
21312
strcmp(arg1, "genisofs")==0 || strcmp(arg1, "xorrisofs")==0)
21313
goto protect_stdout;
21315
} else if(strcmp(cmd, "list_delimiter") == 0) {
21316
/* Needed for interpreting other args. Gets reset after prescan. */
21318
ret= Xorriso_option_list_delimiter(xorriso, arg1, 0);
21322
} else if(strcmp(cmd, "scsi_log") == 0 && was_dashed == 1) {
21324
Xorriso_option_scsi_log(xorriso, arg1, 0);
21327
ret= Xorriso_count_args(xorriso, argc-i, argv+i, &arg_count, 1);
21334
strcpy(xorriso->list_delimiter, mem_list_delimiter);
21339
int Xorriso_read_rc(struct XorrisO *xorriso, int flag)
21341
int ret,i,was_failure= 0,fret;
21345
i= xorriso->rc_filename_count-1;
21346
Sfile_home_adr_s(".xorrisorc", xorriso->rc_filenames[i],
21347
sizeof(xorriso->rc_filenames[i]),0);
21348
for(i=0;i<xorriso->rc_filename_count;i++) {
21349
ret= Sfile_type(xorriso->rc_filenames[i],1|8);
21352
ret= Xorriso_option_options_from_file(xorriso,xorriso->rc_filenames[i],0);
21356
continue; /* regular bottom of loop */
21358
fret= Xorriso_eval_problem_status(xorriso, ret, 1);
21363
return(!was_failure);
21367
int Xorriso_make_return_value(struct XorrisO *xorriso, int flag)
21371
if(xorriso->eternal_problem_status >= xorriso->return_with_severity)
21372
exit_value= xorriso->return_with_value;
21374
sprintf(xorriso->info_text,
21375
"-return_with %s %d triggered by problem severity %s",
21376
xorriso->return_with_text, exit_value,
21377
xorriso->eternal_problem_status_text);
21378
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
21380
return(exit_value);
21384
int Xorriso_program_arg_bsl(struct XorrisO *xorriso, int argc, char ***argv,
21389
if(!(xorriso->bsl_interpretation & 16))
21391
ret= Sfile_argv_bsl(argc, argv, 0);
21396
char *Xorriso__get_version_text(int flag)
21398
return(Xorriso_program_versioN);
21402
char *Xorriso__get_patch_level_text(int flag)
21404
return(Xorriso_program_patch_leveL);
21409
#endif /* ! Xorriso_without_subS */
21413
#ifdef Xorriso_with_maiN
21416
#ifdef Xorriso_without_subS
21418
/* xorriso consists only of a main() stub which has an own version to match
21419
the version of libxorriso header and runtime code.
21421
#define Xorriso_main_program_versioN "0.5.6"
21423
#else /* Xorriso_without_subS */
21425
/* Make sure that both version tests always match. */
21426
#define Xorriso_main_program_versioN Xorriso_program_versioN
21428
#endif /* ! Xorriso_without_subS */
21431
static void yell_xorriso()
21434
"%sxorriso %s%s : RockRidge filesystem manipulator, libburnia project.\n\n",
21435
#ifdef Xorriso_GNU_xorrisO
21440
Xorriso_main_program_versioN, Xorriso_program_patch_leveL);
21444
int main(int argc, char **argv)
21447
struct XorrisO *xorriso= NULL;
21448
char **orig_argv= NULL;
21450
if(strcmp(Xorriso_main_program_versioN, Xorriso_program_versioN)) {
21453
"xorriso : FATAL : libxorriso compile time version mismatch. Found %s\n\n",
21454
Xorriso_program_versioN);
21457
if(strcmp(Xorriso_program_versioN, Xorriso__get_version_text(0))) {
21460
"xorriso : FATAL : libxorriso runtime version mismatch. Found %s\n\n",
21461
Xorriso__get_version_text(0));
21467
fprintf(stderr,"usage : %s [options]\n", argv[0]);
21468
fprintf(stderr, " More is told by option -help\n");
21471
setlocale(LC_CTYPE, "");
21472
ret= Xorriso_new(&xorriso, argv[0], 0);
21474
fprintf(stderr,"Creation of XorrisO object failed. (not enough memory ?)\n");
21478
/* The prescan of arguments performs actions which have to happen before
21479
the normal processing of startup files and arguments.
21481
ret= Xorriso_prescan_args(xorriso,argc,argv,0);
21483
goto end_sucessfully;
21489
/* The following functions are allowed only after this initialization */
21490
ret= Xorriso_startup_libraries(xorriso, 0);
21492
{ret= 4; goto emergency_exit;}
21493
Xorriso_process_msg_queues(xorriso, 0);
21495
/* Interpret startup files */
21496
ret= Xorriso_read_rc(xorriso, 0);
21498
goto end_sucessfully;
21500
{ret= 5; goto emergency_exit;}
21502
/* Interpret program arguments */
21504
ret= Xorriso_program_arg_bsl(xorriso, argc, &argv, 0);
21506
{ret= 5; goto emergency_exit;}
21508
ret= Xorriso_interpreter(xorriso, argc, argv, &i, 2);
21510
goto end_sucessfully;
21512
{ret= 5; goto emergency_exit;}
21514
/* Enter dialog mode if it has been activated meanwhile */
21515
ret= Xorriso_dialog(xorriso, 0);
21517
{ret= 6; goto emergency_exit;}
21519
end_sucessfully:; /* normal shutdown, including eventual -commit */
21520
Xorriso_process_msg_queues(xorriso, 0);
21521
if(Xorriso_change_is_pending(xorriso, 0))
21522
Xorriso_option_end(xorriso, 2);
21523
Xorriso_process_msg_queues(xorriso, 0);
21524
ret= Xorriso_make_return_value(xorriso, 0);
21525
Xorriso_process_errfile(xorriso, 0, "xorriso end", 0, 1);
21526
Xorriso_destroy(&xorriso, 1);
21527
if(orig_argv != argv && orig_argv != NULL) {
21528
for(i= 0; i < argc; i++)
21529
if(argv[i] != NULL)
21536
if(xorriso != NULL) { /* minimal shutdown */
21537
Xorriso_process_msg_queues(xorriso, 0);
21538
Xorriso_destroy(&xorriso, 1);
21543
#endif /* Xorriso_with_maiN */