2
/* xorriso - creates, loads, manipulates and burns ISO 9660 filesystem images.
4
Copyright 2007-2010 Thomas Schmitt, <scdbackup@gmx.net>
6
Provided under GPL version 2 or later.
8
This file contains the implementation of actions on onjects of disk
13
#include "../config.h"
17
#include <sys/types.h>
32
#include "xorriso_private.h"
33
#include "xorrisoburn.h"
37
/* @param flag bit0= simple readlink(): no normalization, no multi-hop
39
int Xorriso_resolve_link(struct XorrisO *xorriso,
40
char *link_path, char result_path[SfileadrL], int flag)
44
int link_count= 0, ret, show_errno= 0;
45
char buf[SfileadrL], dirbuf[SfileadrL], *lpt, *spt, sfe[5*SfileadrL];
46
static int link_limit= 100;
49
if(stat(link_path, &stbuf)==-1)
56
l= readlink(lpt, buf, SfileadrL-1);
59
Xorriso_msgs_submit(xorriso, 0, link_path, 0, "ERRFILE", 0);
60
sprintf(xorriso->info_text, "Cannot obtain link target of : %s",
61
Text_shellsafe(link_path, sfe, 0));
62
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE",0);
64
if(strcmp(lpt, link_path)!=0) {
65
sprintf(xorriso->info_text,
66
"Problem occured with intermediate path : %s",
67
Text_shellsafe(lpt, sfe, 0));
68
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE",0);
74
Xorriso_msgs_submit(xorriso, 0, link_path, 0, "ERRFILE", 0);
75
sprintf(xorriso->info_text, "Empty link target with : %s",
76
Text_shellsafe(link_path, sfe, 0));
77
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE",0);
82
strcpy(result_path, buf);
86
/* normalize relative to disk_path */
87
if(Sfile_str(dirbuf, lpt, 0)<=0)
90
spt= strrchr(dirbuf,'/');
98
ret= Xorriso_normalize_img_path(xorriso, dirbuf, buf, result_path, 2|4);
102
if(lstat(result_path, &stbuf)==-1) {
106
if(!S_ISLNK(stbuf.st_mode))
111
if(link_count>link_limit) {
113
Xorriso_msgs_submit(xorriso, 0, link_path, 0, "ERRFILE", 0);
114
sprintf(xorriso->info_text, "Too many link hops with : %s",
115
Text_shellsafe(link_path, sfe, 0));
116
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, show_errno,
125
int Xorriso_convert_uidstring(struct XorrisO *xorriso, char *uid_string,
126
uid_t *uid, int flag)
132
sscanf(uid_string, "%lf", &num);
133
sprintf(text,"%.f",num);
134
if(strcmp(text,uid_string)==0) {
138
pwd= getpwnam(uid_string);
140
sprintf(xorriso->info_text, "-uid: Not a known user: '%s'", uid_string);
141
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
149
int Xorriso_convert_gidstring(struct XorrisO *xorriso, char *gid_string,
150
gid_t *gid, int flag)
156
sscanf(gid_string, "%lf", &num);
157
sprintf(text,"%.f",num);
158
if(strcmp(text,gid_string)==0) {
162
grp= getgrnam(gid_string);
164
sprintf(xorriso->info_text, "-gid: Not a known group: '%s'", gid_string);
165
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
173
int Xorriso_convert_modstring(struct XorrisO *xorriso, char *cmd, char *mode,
174
mode_t *mode_and, mode_t *mode_or, int flag)
177
char sfe[5*SfileadrL], *mpt, *vpt, *opt;
179
mode_t mode_val,mask;
185
sscanf(mode,"%o",&num);
187
} else if(strchr(mode,'+')!=NULL || strchr(mode,'-')!=NULL
188
|| strchr(mode,'=')!=NULL) {
189
/* [ugoa][+-][rwxst] */;
190
for(mpt= mode; mpt!=NULL; mpt= strchr(mpt, ',')) {
196
for(vpt= mpt; *vpt!='+' && *vpt!='-' && *vpt!='='; vpt++) {
210
for(vpt= opt+1; *vpt!=0 && *vpt!=','; vpt++) {
218
} else if(*vpt=='w') {
225
} else if(*vpt=='x') {
232
} else if(*vpt=='s') {
237
} else if(*vpt=='t') {
244
(*mode_or)|= mode_val;
245
} else if(*opt=='=') {
248
mask|= S_IRWXO|S_ISVTX;
250
mask|= S_IRWXG|S_ISGID;
252
mask|= S_IRWXU|S_ISUID;
253
(*mode_and)&= ~(mask);
254
(*mode_or)= ((*mode_or) & ~mask) | mode_val;
255
} else if(*opt=='-') {
256
(*mode_or)&= ~mode_val;
257
(*mode_and)&= ~mode_val;
262
sprintf(xorriso->info_text,
263
"%s: Unrecognizable or faulty permission mode %s\n", cmd,
264
Text_shellsafe(mode, sfe, 0));
265
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
272
/* @param flag bit0= for Xorriso_msgs_submit: use pager
273
bit1= do not issue warnings
275
int Xorriso_hop_link(struct XorrisO *xorriso, char *link_path,
276
struct LinkiteM **link_stack, struct stat *stbuf, int flag)
279
struct LinkiteM *litm;
280
char sfe[5*SfileadrL];
282
if(*link_stack != NULL) {
283
if(Linkitem_get_link_count(*link_stack, 0) >= xorriso->follow_link_limit) {
284
sprintf(xorriso->info_text,
285
"Too many symbolic links in single tree branch at : %s",
286
Text_shellsafe(link_path, sfe, 0));
288
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0,"WARNING",flag&1);
292
ret= stat(link_path, stbuf);
295
ret= Linkitem_find(*link_stack, stbuf->st_dev, stbuf->st_ino, &litm, 0);
297
sprintf(xorriso->info_text,
298
"Detected symbolic link loop around : %s",
299
Text_shellsafe(link_path, sfe, 0));
301
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", flag&1);
304
ret= Linkitem_new(&litm, link_path, stbuf->st_dev, stbuf->st_ino,
307
sprintf(xorriso->info_text,
308
"Cannot add new item to link loop prevention stack");
309
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", flag&1);
317
/* @param flag bit0= do not only sum up sizes but also print subdirs
318
bit1= this is a recursion
319
@return <=0 error , 1 ok , 2 could not open directory
321
int Xorriso_show_dux_subs(struct XorrisO *xorriso,
322
char *abs_path, char *rel_path, off_t *size,
324
struct LinkiteM *link_stack,
327
int i, ret, no_sort= 0, filec= 0, l, j, fc, no_dive, is_link;
328
char **filev= NULL, *namept;
329
off_t sub_size, report_size, mem= 0;
330
struct DirseQ *dirseq= NULL;
333
struct LinkiteM *own_link_stack;
334
char *path= NULL, *show_path= NULL, *name= NULL, *sfe= NULL;
336
sfe= malloc(5*SfileadrL);
337
path= malloc(SfileadrL);
338
show_path= malloc(SfileadrL);
339
name= malloc(SfileadrL);
340
if(path==NULL || show_path==NULL || name==NULL || sfe==NULL) {
341
Xorriso_no_malloc_memory(xorriso, &sfe, 0);
344
own_link_stack= link_stack;
348
if(lstat(abs_path, &stbuf)==-1)
350
dir_dev= stbuf.st_dev;
351
if(S_ISLNK(stbuf.st_mode)) {
352
if(!(xorriso->do_follow_links || (xorriso->do_follow_param && !(flag&2))))
354
if(stat(abs_path, &stbuf)==-1)
356
if(dir_dev != stbuf.st_dev &&
357
!(xorriso->do_follow_mount || (xorriso->do_follow_param && !(flag&2))))
360
ret= Dirseq_new(&dirseq, abs_path, 1);
362
sprintf(xorriso->info_text, "Cannot obtain disk directory iterator");
363
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
370
Linkitem_reset_stack(&own_link_stack, link_stack, 0);
371
ret= Dirseq_next_adr(dirseq,name,0);
378
strcpy(show_path, rel_path);
379
if(Sfile_add_to_path(show_path, name, 0)<=0)
382
strcpy(path, abs_path);
383
if(Sfile_add_to_path(path, name, 0)<=0) {
385
Xorriso_much_too_long(xorriso, strlen(path)+strlen(name)+1, 2);
390
ret= lstat(path, &stbuf);
393
is_link= S_ISLNK(stbuf.st_mode);
394
if(is_link && xorriso->do_follow_links) {
395
ret= Xorriso_hop_link(xorriso, path, &own_link_stack, &stbuf, 1);
401
if(!S_ISDIR(stbuf.st_mode))
403
if(dir_dev != stbuf.st_dev && !xorriso->do_follow_mount)
407
l= strlen(rel_path)+1;
409
if(l % sizeof(char *))
410
mem+= sizeof(char *)-(l % sizeof(char *));
411
if(flag&1) /* diving and counting is done further below */
413
ret= Xorriso_show_dux_subs(xorriso, path, show_path, &sub_size, boss_mem,
422
sub_size+= stbuf.st_size+strlen(name)+1;
424
sub_size+= stbuf.st_size+2048;
429
if(filec<=0 || !(flag&1))
432
/* Try to get a sorted list of directory names */
433
mem+= (filec+1)*sizeof(char *);
434
ret= Xorriso_check_temp_mem_limit(xorriso, mem+boss_mem, 2);
437
Dirseq_rewind(dirseq, 0);
442
filev= (char **) calloc(filec+1, sizeof(char *));
444
goto no_sort_possible;
446
for(i= 0; i<filec; i++)
450
ret= Dirseq_next_adr(dirseq,name,0);
455
strcpy(path, abs_path);
456
if(Sfile_add_to_path(path, name, 0)<=0)
459
ret= lstat(path,&stbuf);
462
is_link= S_ISLNK(stbuf.st_mode);
463
if(is_link && xorriso->do_follow_links) {
464
ret= stat(path,&stbuf);
468
if(!S_ISDIR(stbuf.st_mode))
470
if(dir_dev != stbuf.st_dev && !xorriso->do_follow_mount)
473
if(fc>=filec) { /* Number of files changed (or programming error) */
476
free((char *) filev[j]);
477
free((char *) filev);
479
goto no_sort_possible;
482
filev[fc]= strdup(name);
489
Sort_argv(filec, filev, 0);
493
for(i= 0; (no_sort || i<filec) && !(xorriso->request_to_abort); i++) {
494
Linkitem_reset_stack(&own_link_stack, link_stack, 0);
496
ret= Dirseq_next_adr(dirseq,name,0);
505
strcpy(show_path, rel_path);
506
if(Sfile_add_to_path(show_path, namept, 0)<=0)
508
strcpy(path, abs_path);
509
if(Sfile_add_to_path(path, namept, 0)<=0)
513
ret= lstat(path,&stbuf);
516
is_link= S_ISLNK(stbuf.st_mode);
517
if(is_link && xorriso->do_follow_links) {
518
ret= Xorriso_hop_link(xorriso, path, &own_link_stack, &stbuf, 1);
524
if(!S_ISDIR(stbuf.st_mode))
526
if(dir_dev == stbuf.st_dev || xorriso->do_follow_mount) {
527
ret= Xorriso_show_dux_subs(xorriso, path, show_path, &sub_size,
528
boss_mem+mem, own_link_stack, 2|(flag&1));
534
sub_size+= stbuf.st_size+strlen(namept)+1;
536
sub_size+= stbuf.st_size+2048;
539
report_size= sub_size/1024;
540
if(report_size*1024<sub_size)
542
sprintf(xorriso->result_line, "%7.f ",(double) (report_size));
543
sprintf(xorriso->result_line+strlen(xorriso->result_line), "%s\n",
544
Text_shellsafe(show_path, sfe, 0));
545
Xorriso_result(xorriso, 0);
558
Linkitem_reset_stack(&own_link_stack, link_stack, 0);
559
Dirseq_destroy(&dirseq, 0);
561
for(i=0; i<filec; i++)
563
free((char *) filev[i]);
564
free((char *) filev);
570
/* @param flag bit1= add '+' to perms
571
bit2-3: hidden_state : 0=off, 1=iso_rr, 2=joliet= 3=on
573
int Xorriso__mode_to_perms(mode_t st_mode, char perms[11], int flag)
577
strcpy(perms,"--------- ");
578
if(st_mode&S_IRUSR) perms[0]= 'r';
579
if(st_mode&S_IWUSR) perms[1]= 'w';
580
if(st_mode&S_IXUSR) perms[2]= 'x';
581
if(st_mode&S_ISUID) {
587
if(st_mode&S_IRGRP) perms[3]= 'r';
588
if(st_mode&S_IWGRP) perms[4]= 'w';
589
if(st_mode&S_IXGRP) perms[5]= 'x';
590
if(st_mode&S_ISGID) {
596
if(st_mode&S_IROTH) perms[6]= 'r';
597
if(st_mode&S_IWOTH) perms[7]= 'w';
598
if(st_mode&S_IXOTH) perms[8]= 'x';
599
if(st_mode&S_ISVTX) {
605
hidden_state= (flag >> 2) & 3;
606
if(hidden_state == 1)
608
else if(hidden_state == 2)
610
else if(hidden_state == 3)
614
perms[9]= tolower(perms[9]);
622
/* @param flag bit0= recognize Xorriso_IFBOOT as file type
623
bit1= add '+' to perms
624
bit2-3: hidden_state : 0=off, 1=iso_rr, 2=joliet= 3=on
626
int Xorriso_format_ls_l(struct XorrisO *xorriso, struct stat *stbuf, int flag)
628
int show_major_minor= 0, high_shift= 0, high_mask= 0;
629
char *rpt, perms[11], mm_text[80];
631
dev_t dev, major, minor;
633
rpt= xorriso->result_line;
635
st_mode= stbuf->st_mode;
639
else if(S_ISREG(st_mode)) {
641
} else if(S_ISLNK(st_mode))
643
else if(S_ISBLK(st_mode)) {
646
} else if(S_ISCHR(st_mode)) {
649
} else if(S_ISFIFO(st_mode))
651
else if(S_ISSOCK(st_mode))
653
else if((flag & 1) && (st_mode & S_IFMT) == Xorriso_IFBOOT)
658
Xorriso__mode_to_perms(st_mode, perms, flag & (2 | 12));
661
sprintf(rpt+strlen(rpt)," %3u ",(unsigned int) stbuf->st_nlink);
663
sprintf(rpt+strlen(rpt), "%-8lu ", (unsigned long) stbuf->st_uid);
664
sprintf(rpt+strlen(rpt), "%-8lu ", (unsigned long) stbuf->st_gid);
665
if(show_major_minor) {
668
/* according to /usr/include/sys/sysmacros.h : gnu_dev_major(),_minor()
669
>>> but this looks as if it should go to some system dependency
670
>>> in FreeBSD dev_t is 32 bit
672
if(sizeof(dev_t) > 4) {
676
major= (((dev >> 8) & 0xfff) |
677
((unsigned int) (dev >> high_shift) & high_mask))
679
minor= (((dev & 0xff) | ((unsigned int) (dev >> 12) & ~0xff))) & 0xffffffff;
681
sprintf(mm_text, "%u,%u", (unsigned int) major, (unsigned int) minor);
682
sprintf(rpt+strlen(rpt), "%8s ", mm_text);
684
sprintf(rpt+strlen(rpt), "%8.f ", (double) stbuf->st_size);
686
Ftimetxt(stbuf->st_mtime, rpt+strlen(rpt), 0);
695
struct DirentrY *next;
699
int Xorriso_sorted_dir_x(struct XorrisO *xorriso, char *dir_path,
700
int *filec, char ***filev, off_t boss_mem, int flag)
703
char name[SfileadrL];
704
struct DirseQ *dirseq= NULL;
706
struct DirentrY *last= NULL, *current= NULL;
711
ret= Dirseq_new(&dirseq, dir_path, 1);
714
while(1) { /* loop over directory content */
715
ret= Dirseq_next_adr(dirseq,name,0);
720
mem+= strlen(name)+8+sizeof(struct DirentrY)+sizeof(char *);
721
if(mem>xorriso->temp_mem_limit)
724
current= (struct DirentrY *) calloc(1, sizeof(struct DirentrY));
730
last->adr= strdup(name);
738
(*filev)= (char **) calloc(count, sizeof(char *));
742
for(current= last; current!=NULL; current= last) {
744
(*filev)[count++]= current->adr;
745
free((char *) current);
747
Sort_argv(*filec, *filev, 0);
750
for(current= last; current!=NULL; current= last) {
753
free((char *) current);
759
/* @param flag bit0= long format
760
bit1= do not print count of nodes
762
bit3= print directories as themselves (ls -d)
764
int Xorriso_lsx_filev(struct XorrisO *xorriso, char *wd,
765
int filec, char **filev, off_t boss_mem, int flag)
767
int i, ret, was_error= 0, dfilec= 0, pass, passes;
768
char sfe[5*SfileadrL], sfe2[5*SfileadrL], path[SfileadrL], *acl_text= NULL;
769
char *rpt, link_target[SfileadrL], **dfilev= NULL;
773
rpt= xorriso->result_line;
775
Sort_argv(filec, filev, 0);
777
/* Count valid nodes, warn of invalid ones */
778
for(i= 0; i<filec; i++) {
779
ret= Xorriso_make_abs_adr(xorriso, wd, filev[i], path, 1|2|4);
784
ret= lstat(path, &stbuf);
786
sprintf(xorriso->info_text, "Not found in local filesystem: %s",
787
Text_shellsafe(path, sfe, 0));
788
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 1);
794
if((flag&8) && !(flag&(2|4))) {
795
sprintf(xorriso->info_text,"Valid local files found: %d\n",filec-was_error);
796
Xorriso_info(xorriso,1);
797
if(filec-was_error<=0)
801
passes= 1+!(flag&(4|8));
802
for(pass= 0; pass<passes; pass++)
803
for(i= 0; i<filec && !(xorriso->request_to_abort); i++) {
804
ret= Xorriso_make_abs_adr(xorriso, wd, filev[i], path, 1|2|4);
807
ret= lstat(path, &stbuf);
810
if(S_ISLNK(stbuf.st_mode) &&
811
(xorriso->do_follow_links || xorriso->do_follow_param)) {
812
ret= stat(path, &stbuf);
814
ret= lstat(path, &stbuf);
818
if(S_ISDIR(stbuf.st_mode) && !(flag&(4|8))) {
822
strcpy(xorriso->result_line, "\n");
823
Xorriso_result(xorriso,0);
824
sprintf(xorriso->result_line, "%s:\n", Text_shellsafe(filev[i], sfe,0));
825
Xorriso_result(xorriso,0);
827
ret= Xorriso_sorted_dir_x(xorriso, path, &dfilec, &dfilev, boss_mem, 0);
830
/* >>> DirseQ loop and single item Xorriso_lsx_filev() */;
834
sprintf(xorriso->result_line, "total %d\n", dfilec);
835
Xorriso_result(xorriso,0);
837
Xorriso_lsx_filev(xorriso, path,
838
dfilec, dfilev, boss_mem, (flag&1)|2|8);
841
Sfile_destroy_argv(&dfilec, &dfilev, 0);
849
Xorriso_local_getfacl(xorriso, path, &acl_text, 16);
850
ret= Xorriso_format_ls_l(xorriso, &stbuf, (acl_text != NULL) << 1);
851
Xorriso_local_getfacl(xorriso, path, &acl_text, 1 << 15);
854
if(S_ISLNK(stbuf.st_mode)) {
855
ret= Xorriso_resolve_link(xorriso, path, link_target, 1);
859
} else if(flag&4) { /* -du or -dus */
861
if(S_ISDIR(stbuf.st_mode)) {
862
ret= Xorriso_show_dux_subs(xorriso, path, filev[i], &size, boss_mem,
869
sprintf(rpt, "%7.f ",(double) (size/1024));
872
sprintf(xorriso->result_line+strlen(xorriso->result_line), "%s -> %s\n",
873
Text_shellsafe(filev[i], sfe, 0),
874
Text_shellsafe(link_target, sfe2, 0));
876
sprintf(xorriso->result_line+strlen(xorriso->result_line), "%s\n",
877
Text_shellsafe(filev[i], sfe, 0));
878
Xorriso_result(xorriso, 0);
885
@param flag >>> bit0= remove whole sub tree: rm -r
886
bit1= remove empty directory: rmdir
887
bit2= recursion: do not reassure in mode 2 "tree"
888
bit3= this is for overwriting and not for plain removal
889
bit4= count deleted files in xorriso->pacifier_count
890
bit5= with bit0 only remove directory content, not the directory
891
bit6= permission to call Xorriso_make_accessible()
893
1 = removed leaf file object
894
2 = removed directory or tree
895
3 = did not remove on user revocation
897
int Xorriso_rmx(struct XorrisO *xorriso, off_t boss_mem, char *path, int flag)
899
int ret, is_dir= 0, made_accessible= 0;
900
struct stat victim_stbuf, *victim_node= NULL;
901
struct DirseQ *dirseq= NULL;
902
char *sfe= NULL, *sub_path= NULL;
903
struct PermiteM *perm_stack_mem;
905
perm_stack_mem= xorriso->perm_stack;
907
/* Avoiding large local memory objects in order to save stack space */
908
sfe= malloc(5*SfileadrL);
909
sub_path= malloc(2*SfileadrL);
910
if(sfe==NULL || sub_path==NULL) {
911
Xorriso_no_malloc_memory(xorriso, &sfe, 0);
915
if(Xorriso_much_too_long(xorriso, strlen(path), 0)<=0)
918
ret= lstat(path, &victim_stbuf);
920
if((flag & 64) && errno == EACCES) {
921
ret= Xorriso_make_accessible(xorriso, path, 0);
925
ret= lstat(path, &victim_stbuf);
928
sprintf(xorriso->info_text, "Cannot lstat(%s)",
929
Text_shellsafe(path, sfe, 0));
930
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE", 0);
934
if(strcmp(path, "/")==0) {
935
sprintf(xorriso->info_text, "May not delete root directory");
936
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
939
victim_node= &victim_stbuf;
940
if(S_ISDIR(victim_stbuf.st_mode))
943
if(flag&2) { /* rmdir */
944
sprintf(xorriso->info_text, "%s in disk filesystem is not a directory",
945
Text_shellsafe(path, sfe, 0));
946
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
950
if(flag&1) { /* rm -r */
952
#ifdef Osirrox_not_yeT
955
if((xorriso->do_reassure==1 && !xorriso->request_not_to_ask) ||
957
/* Iterate over subordinates and delete them */
960
ret= Xorriso_findi_iter(xorriso, (IsoDir *) victim_node, &mem,
961
&iter, &node_array, &node_count, &node_idx,
965
Xorriso_cannot_create_iter(xorriso, ret, 0);
969
strcpy(sub_path, path);
970
if(pl==0 || sub_path[pl-1]!='/') {
974
sub_name= sub_path+pl;
976
ret= Xorriso_findi_iter(xorriso, (IsoDir *) victim_node, &mem, &iter,
977
&node_array, &node_count, &node_idx, &node, 0);
980
if(ret==0 || xorriso->request_to_abort)
982
name= (char *) iso_node_get_name(node);
983
if(Xorriso_much_too_long(xorriso, pl+1+strlen(name), 0)<=0)
984
{ret= 0; goto rm_r_problem_handler;}
985
strcpy(sub_name, name);
986
ret= Xorriso_rmi(xorriso, iter, mem, sub_path, (flag&(1|2|8|16))|4);
987
if(ret==3 || ret<=0 || xorriso->request_to_abort) {
988
rm_r_problem_handler:;
990
fret= Xorriso_eval_problem_status(xorriso, ret, 1|2);
992
goto dir_not_removed;
1000
sprintf(xorriso->info_text, "Directory not removed: %s",
1001
Text_shellsafe(path, sfe, 0));
1002
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
1009
#else /* Osirrox_not_yeT */
1011
sprintf(xorriso->info_text, "-rm_rx is not implemented yet");
1012
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
1015
#endif /* !Osirrox_not_yeT */
1018
if(!(flag&2)) { /* not rmdir */
1019
sprintf(xorriso->info_text, "%s in disk filesystem is a directory",
1020
Text_shellsafe(path, sfe, 0));
1021
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
1024
ret= Dirseq_new(&dirseq, path, 1);
1026
ret= Dirseq_next_adr(dirseq, sfe, 0);
1028
sprintf(xorriso->info_text,
1029
"Directory not empty on attempt to delete: %s",
1030
Text_shellsafe(path, sfe, 0));
1031
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
1037
if(xorriso->request_to_abort)
1039
ret= Xorriso_reassure_restore(xorriso, path, (flag&(4|8)) | !!is_dir);
1040
if(ret<=0 || ret==3)
1047
if((flag & 64) && errno == EACCES && !made_accessible) {
1048
ret= Xorriso_make_accessible(xorriso, path, 0);
1058
sprintf(xorriso->info_text, "Cannot delete from disk filesystem %s",
1059
Text_shellsafe(path, sfe, 0));
1060
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE", 0);
1065
xorriso->pacifier_count++;
1069
Permstack_pop(&(xorriso->perm_stack), perm_stack_mem, xorriso, 0);
1074
Dirseq_destroy(&dirseq, 0);
1079
/* @param flag bit0= recursion
1081
int Xorriso_findx_action(struct XorrisO *xorriso, struct FindjoB *job,
1082
char *abs_path, char *show_path, int depth, int flag)
1084
int ret= 0, type, action= 0, dpl= 0, compare_result, uret;
1088
mode_t mode_or= 0, mode_and= ~1;
1089
char *target, *text_2, sfe[5*SfileadrL], *disk_prefix, iso_path[SfileadrL];
1091
struct FindjoB *subjob;
1094
action= Findjob_get_action_parms(job, &target, &text_2, &user, &group,
1095
&mode_and, &mode_or, &type, &date, &subjob, 0);
1100
if(action==15 || action==16 || action==18 || action==19 || action==20) {
1101
/* in_iso , not_in_iso, add_missing , empty_iso_dir , is_full_in_iso */
1102
Findjob_get_start_path(job, &disk_prefix, 0);
1103
if(strncmp(abs_path, disk_prefix, strlen(disk_prefix))!=0)
1105
dpl= strlen(disk_prefix);
1106
if(strlen(target)+strlen(abs_path)-dpl >= SfileadrL)
1108
if(abs_path[dpl]=='/')
1110
ret= Xorriso_make_abs_adr(xorriso, target, abs_path+dpl, iso_path, 4);
1115
if(action==15) { /* in_iso */
1116
ret= Xorriso_iso_lstat(xorriso, iso_path, &stbuf, 0);
1119
sprintf(xorriso->result_line, "%s\n", Text_shellsafe(show_path, sfe, 0));
1120
Xorriso_result(xorriso, 0);
1122
} else if(action==16) { /* not_in_iso */
1123
ret= Xorriso_compare_2_files(xorriso, abs_path, iso_path, abs_path+dpl,
1124
&compare_result, 4);
1125
if(ret<xorriso->find_compare_result)
1126
xorriso->find_compare_result= ret;
1129
} else if(action==18) { /* add_missing */
1130
ret= Xorriso_compare_2_files(xorriso, abs_path, iso_path, abs_path+dpl,
1131
&compare_result, 4|(1<<31));
1132
if(ret<xorriso->find_compare_result)
1133
xorriso->find_compare_result= ret;
1135
uret= Xorriso_update_interpreter(xorriso, NULL, NULL, compare_result,
1136
abs_path, iso_path, ((flag&1)<<2) | 2);
1142
} else if(action==19) { /* empty_iso_dir */
1143
ret= Xorriso_iso_lstat(xorriso, iso_path, &stbuf, 0);
1146
if(!S_ISDIR(stbuf.st_mode))
1148
ret= Xorriso_rmi(xorriso, NULL, (off_t) 0, iso_path, 1|32);
1150
sprintf(xorriso->info_text, "Emptied directory %s",
1151
Text_shellsafe(iso_path, sfe, 0));
1152
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "UPDATE", 0);
1154
} else if(action==20) { /* is_full_in_iso */
1155
ret= Xorriso_iso_lstat(xorriso, iso_path, &stbuf, 0);
1158
if(!S_ISDIR(stbuf.st_mode))
1160
strcpy(sfe, xorriso->wdi);
1161
strcpy(xorriso->wdi, iso_path);
1162
ret= Xorriso_ls(xorriso, 4|8);
1163
strcpy(xorriso->wdi, sfe);
1165
sprintf(xorriso->result_line,
1166
"d %s (ISO) : non-empty directory (would not match mount point)\n",
1167
Text_shellsafe(iso_path, sfe, 0));
1168
Xorriso_result(xorriso,0);
1171
} else if(action == 40) { /* estimate_size */
1172
basename= strrchr(abs_path, '/');
1173
if(basename != NULL)
1177
ret= lstat(abs_path, &stbuf);
1179
ret= Xorriso_estimate_file_size(xorriso, job, basename, stbuf.st_mode,
1182
sprintf(xorriso->result_line, "%s\n", Text_shellsafe(show_path, sfe, 0));
1183
Xorriso_result(xorriso, 0);
1187
if(action==15 || action==16 || action==18 || action==19 || action==20)
1188
if(xorriso->no_volset_present)
1189
xorriso->request_to_abort= 1; /* Need an image. No use to try again. */
1194
/* @param flag bit0=recursion
1196
int Xorriso_findx(struct XorrisO *xorriso, struct FindjoB *job,
1197
char *abs_dir_parm, char *dir_path,
1198
struct stat *dir_stbuf, int depth,
1199
struct LinkiteM *link_stack, int flag)
1201
int ret,is_link, no_dive;
1202
struct DirseQ *dirseq= NULL;
1204
struct LinkiteM *own_link_stack;
1205
char *abs_dir_path, *namept;
1206
char *name= NULL, *path= NULL, *sfe= NULL;
1207
char *abs_dir_path_data= NULL, *abs_path= NULL;
1209
if(xorriso->request_to_abort)
1212
sfe= malloc(5*SfileadrL);
1213
name= malloc(SfileadrL);
1214
path= malloc(SfileadrL);
1215
abs_dir_path_data= malloc(SfileadrL);
1216
abs_path= malloc(SfileadrL);
1217
if(name==NULL || sfe==NULL || path==NULL ||
1218
abs_dir_path_data==NULL || abs_path==NULL) {
1219
Xorriso_no_malloc_memory(xorriso, &sfe, 0);
1222
own_link_stack= link_stack;
1223
abs_dir_path= abs_dir_parm;
1224
if(abs_dir_path[0]==0) {
1225
ret= Xorriso_make_abs_adr(xorriso, xorriso->wdx, dir_path,
1226
abs_dir_path_data, 1|2|8);
1229
abs_dir_path= abs_dir_path_data;
1230
ret= Xorriso_path_is_excluded(xorriso, abs_dir_path, !(flag&1));
1235
ret= lstat(abs_dir_path, dir_stbuf);
1238
if(S_ISLNK(dir_stbuf->st_mode) &&
1239
(xorriso->do_follow_links || (xorriso->do_follow_param && !(flag&1))))
1240
if(stat(abs_dir_path, &stbuf)!=-1)
1241
if(dir_stbuf->st_dev == stbuf.st_dev ||
1242
(xorriso->do_follow_mount || (xorriso->do_follow_param && !(flag&1))))
1243
memcpy(dir_stbuf, &stbuf, sizeof(struct stat));
1245
namept= strrchr(dir_path, '/');
1251
ret= Findjob_test_2(xorriso, job, NULL, namept, dir_path, NULL, dir_stbuf,
1256
ret= Xorriso_findx_action(xorriso, job, abs_dir_path, dir_path, depth,
1258
if(xorriso->request_to_abort)
1261
if(Xorriso_eval_problem_status(xorriso, ret, 1|2)<0)
1266
if(xorriso->request_to_abort)
1268
if(!S_ISDIR(dir_stbuf->st_mode))
1271
ret= Dirseq_new(&dirseq, abs_dir_path, 1);
1273
sprintf(xorriso->info_text, "Cannot obtain disk directory iterator");
1274
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
1280
while(!xorriso->request_to_abort) {
1281
Linkitem_reset_stack(&own_link_stack, link_stack, 0);
1282
ret= Dirseq_next_adr(dirseq,name,0);
1286
sprintf(xorriso->info_text,"Failed to obtain next directory entry");
1287
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
1290
ret= Xorriso_make_abs_adr(xorriso, abs_dir_path, name, abs_path, 1);
1293
ret= Xorriso_make_abs_adr(xorriso, dir_path, name, path, 4);
1296
ret= Xorriso_path_is_excluded(xorriso, abs_path, 0); /* (is never param) */
1301
ret= lstat(abs_path, &stbuf);
1306
is_link= S_ISLNK(stbuf.st_mode);
1307
if(is_link && xorriso->do_follow_links) {
1308
ret= Xorriso_hop_link(xorriso, abs_path, &own_link_stack, &stbuf, 2);
1315
ret= Findjob_test_2(xorriso, job, NULL, name, path, dir_stbuf, &stbuf, 0);
1319
ret= Xorriso_findx_action(xorriso, job, abs_path, path, depth, flag&1);
1320
if(xorriso->request_to_abort)
1323
if(Xorriso_eval_problem_status(xorriso, ret, 1|2)<0)
1327
if(!S_ISDIR(stbuf.st_mode))
1329
if(dir_stbuf->st_dev != stbuf.st_dev && !xorriso->do_follow_mount)
1332
ret= Xorriso_findx(xorriso, job, abs_path, path, &stbuf, depth+1,
1333
own_link_stack, flag|1);
1347
if(abs_dir_path_data!=NULL)
1348
free(abs_dir_path_data);
1351
Dirseq_destroy(&dirseq, 0);
1356
/* @param flag bit0= no hardlink reconstruction
1357
bit1= do not set xorriso->node_*_prefixes
1358
bit5= -extract_single: eventually do not insert directory tree
1360
int Xorriso_restore_sorted(struct XorrisO *xorriso, int count,
1361
char **src_array, char **tgt_array,
1362
int *problem_count, int flag)
1364
int i, ret, with_node_array= 0, hflag= 0, hret;
1367
if(!(((xorriso->ino_behavior & 16) && xorriso->do_restore_sort_lba) ||
1368
(xorriso->ino_behavior & 4) || (flag & 1))) {
1369
ret= Xorriso_make_hln_array(xorriso, 0);
1373
if(xorriso->do_restore_sort_lba) {
1374
/* Count affected nodes */
1375
Xorriso_destroy_node_array(xorriso, 0);
1376
for(i= 0; i < count; i++) {
1377
if(src_array[i] == NULL || tgt_array[i] == NULL)
1379
/* sort_lba : Make directories plus node_array and then
1380
run array extractor (with eventual hardlink detection)
1382
hflag= (1 << 7) | ((!!(flag & 2)) << 9);
1383
ret= Xorriso_restore(xorriso, src_array[i], tgt_array[i],
1384
(off_t) 0, (off_t) 0, hflag);
1387
hret= Xorriso_eval_problem_status(xorriso, ret, 0);
1395
if(with_node_array) {
1396
/* Allocate and fill node array */
1397
if(xorriso->node_counter <= 0)
1399
ret= Xorriso_new_node_array(xorriso, xorriso->temp_mem_limit, 0,
1400
!xorriso->do_restore_sort_lba);
1403
for(i= 0; i < count; i++) {
1404
if(src_array[i] == NULL || tgt_array[i] == NULL)
1406
ret= Xorriso_restore(xorriso, src_array[i], tgt_array[i],
1407
(off_t) 0, (off_t) 0, 2 << 7);
1410
hret= Xorriso_eval_problem_status(xorriso, ret, 0);
1417
/* Perform restore operations */
1418
if(xorriso->do_restore_sort_lba) {
1419
ret= Xorriso_restore_node_array(xorriso, 0);
1423
for(i= 0; i < count; i++) {
1424
if(src_array[i] == NULL || tgt_array[i] == NULL)
1426
ret= Xorriso_restore(xorriso, src_array[i], tgt_array[i],
1427
(off_t) 0, (off_t) 0, 0);
1430
hret= Xorriso_eval_problem_status(xorriso, ret, flag & 32);
1443
/* @param flag bit0= path is a directory
1444
bit2= recursion: do not reassure in mode 2 "tree"
1445
bit3= this is for overwriting and not for plain removal
1447
int Xorriso_reassure_restore(struct XorrisO *xorriso, char *path, int flag)
1450
char sfe[5*SfileadrL];
1452
while((xorriso->do_reassure==1 || (xorriso->do_reassure==2 && !(flag&4)))
1453
&& !xorriso->request_not_to_ask) {
1455
Xorriso_lsx_filev(xorriso, xorriso->wdx, 1, &path, (off_t) 0, 1|2|8);
1456
if(flag&1) /* du -s */
1457
Xorriso_lsx_filev(xorriso, xorriso->wdx, 1, &path, (off_t) 0, 2|4);
1459
sprintf(xorriso->info_text,
1460
"File exists. Remove ? n= keep old, y= remove, x= abort, @= stop asking\n");
1462
sprintf(xorriso->info_text,
1463
"Remove above file ? n= keep it, y= remove it, x= abort, @= stop asking\n");
1464
Xorriso_info(xorriso, 4);
1465
ret= Xorriso_request_confirmation(xorriso, 1|2|4|16);
1468
if(xorriso->request_to_abort) {
1469
sprintf(xorriso->info_text,
1470
"Removal operation aborted by user before file: %s",
1471
Text_shellsafe(path, sfe, 0));
1472
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
1477
if(ret==6) /* yes */
1479
if(ret==4) { /* yes, do not ask again */
1480
xorriso->request_not_to_ask= 1;
1483
if(ret==1) { /* no */
1484
sprintf(xorriso->info_text, "Kept in existing state: %s",
1485
Text_shellsafe(path, sfe, 0));
1486
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
1496
/* @param flag bit7= return 4 if restore fails from denied permission
1497
do not issue error message
1498
@return <=0 failure , 1 success ,
1499
4 with bit7: permission to create file was denied
1501
int Xorriso_make_tmp_path(struct XorrisO *xorriso, char *orig_path,
1502
char *tmp_path, int *fd, int flag)
1506
cpt= strrchr(orig_path, '/');
1510
strncpy(tmp_path, orig_path, cpt+1-orig_path);
1511
tmp_path[cpt+1-orig_path]= 0;
1513
strcat(tmp_path, "_tmp_xorriso_restore_XXXXXX");
1514
*fd= mkstemp(tmp_path);
1516
if(errno == EACCES && (flag & 128))
1518
strcpy(xorriso->info_text, "Cannot create temporary file : ");
1519
Text_shellsafe(tmp_path, xorriso->info_text, 1);
1520
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE", 0);
1523
fchmod(*fd, S_IRUSR|S_IWUSR);
1528
/* @param flag bit0= change regardless of xorriso->do_auto_chmod
1529
bit1= desired is only rx
1530
@return -1=severe error , -2= cannot chmod, 0= nothing to do, 1 = chmoded
1532
int Xorriso_auto_chmod(struct XorrisO *xorriso, char *disk_path, int flag)
1534
int ret, is_link= 0;
1535
char *path_pt, sfe[5*SfileadrL], link_target[SfileadrL];
1536
mode_t mode, desired= S_IRUSR | S_IWUSR | S_IXUSR;
1539
if(!(xorriso->do_auto_chmod || (flag & 1)))
1543
desired &= ~S_IWUSR;
1545
ret= lstat(path_pt, &stbuf);
1548
if(S_ISLNK(stbuf.st_mode)) {
1550
ret= stat(path_pt, &stbuf);
1554
if(!S_ISDIR(stbuf.st_mode))
1557
ret= Xorriso_resolve_link(xorriso, path_pt, link_target, 0);
1560
path_pt= link_target;
1562
if((stbuf.st_mode & desired) == desired)
1564
if(stbuf.st_uid!=geteuid())
1567
mode= (stbuf.st_mode | desired) & 07777;
1568
ret= chmod(path_pt, mode);
1570
sprintf(xorriso->info_text,
1571
"Cannot change access permissions of disk directory: chmod %o %s",
1572
(unsigned int) (mode & 07777), Text_shellsafe(path_pt, sfe, 0));
1573
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "SORRY", 0);
1576
ret= Permstack_push(&(xorriso->perm_stack), path_pt, &stbuf, 0);
1583
int Xorriso_make_accessible(struct XorrisO *xorriso, char *disk_path, int flag)
1585
int done= 0, ret, just_rx= 2;
1586
char *npt, *apt, path[SfileadrL], *wpt;
1590
for(npt= apt; !done; apt= npt + 1) {
1591
npt= strchr(apt, '/');
1594
if(strchr(npt + 1, '/') == NULL)
1596
strncpy(wpt, apt, npt + 1 - apt);
1597
wpt+= npt + 1 - apt;
1599
ret= Xorriso_auto_chmod(xorriso, path, just_rx);
1609
/* @param flag bit0= prefer to find a match after *img_prefixes
1610
(but deliver img_prefixes if no other can be found)
1612
int Xorriso_make_restore_path(struct XorrisO *xorriso,
1613
struct Xorriso_lsT **img_prefixes, struct Xorriso_lsT **disk_prefixes,
1614
char img_path[SfileadrL], char disk_path[SfileadrL], int flag)
1617
struct Xorriso_lsT *s, *d, *found_s= NULL, *found_d= NULL;
1620
/* Obtain disk_path by replacing start piece of img_path */
1623
for(s= *img_prefixes; s != NULL;
1624
s= Xorriso_lst_get_next(s, 0), d= Xorriso_lst_get_next(d, 0)) {
1626
ipfx= Xorriso_lst_get_text(s, 0);
1628
dpfx= Xorriso_lst_get_text(d, 0);
1629
if(strncmp(img_path, ipfx, li) != 0)
1631
if(img_path[li] != 0 && img_path[li] != '/')
1633
if(strlen(dpfx) + strlen(img_path) - li + 1 >= SfileadrL)
1635
if(img_path[li]=='/')
1636
sprintf(disk_path, "%s/%s", dpfx, img_path + strlen(ipfx) + 1);
1638
strcpy(disk_path, dpfx);
1641
if(s != *img_prefixes || !(flag & 1))
1644
*img_prefixes= found_s;
1645
*disk_prefixes= found_d;
1646
return(found_s != NULL);
1650
/* @param flag bit0=permission to run Xorriso_make_accessible
1652
int Xorriso_restore_make_hl(struct XorrisO *xorriso,
1653
char *old_path, char *new_path, int flag)
1656
struct PermiteM *perm_stack_mem;
1658
ret= link(old_path, new_path);
1661
if(errno == EACCES && (flag & 1)) {
1662
perm_stack_mem= xorriso->perm_stack;
1663
ret= Xorriso_make_accessible(xorriso, new_path, 0);
1665
ret= link(old_path, new_path);
1667
Permstack_pop(&(xorriso->perm_stack), perm_stack_mem, xorriso, 0);
1671
Permstack_pop(&(xorriso->perm_stack), perm_stack_mem, xorriso, 0);
1674
sprintf(xorriso->info_text, "Hardlinking failed: ");
1675
Text_shellsafe(new_path, xorriso->info_text, 1);
1676
strcat(xorriso->info_text, " -> ");
1677
Text_shellsafe(old_path, xorriso->info_text, 1);
1678
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "WARNING", 0);
1683
int Xorriso_afile_fopen(struct XorrisO *xorriso,
1684
char *filename, char *mode, FILE **ret_fp, int flag)
1686
bit0= do not print error message on failure
1687
bit1= do not open stdin
1693
if(strcmp(filename,"-")==0) {
1694
if(mode[0]=='a' || mode[0]=='w' ||
1695
(mode[0]=='r' && mode[1]=='+') ||
1696
(mode[0]=='r' && mode[1]=='b' && mode[2]=='+'))
1699
Xorriso_msgs_submit(xorriso, 0, "Not allowed as input path: '-'", 0,
1703
Xorriso_msgs_submit(xorriso, 0, "Ready for data at standard input", 0,
1707
} else if(strncmp(filename,"tcp:",4)==0){
1708
Xorriso_msgs_submit(xorriso, 0, "TCP/IP service isn't implemented yet.", 0,
1710
} else if(strncmp(filename,"file:",5)==0){
1711
fp= fopen(filename+5,mode);
1713
fp= fopen(filename,mode);
1717
sprintf(xorriso->info_text,
1718
"Failed to open file '%s' in %s mode\n", filename, mode);
1719
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE", 0);
1729
@param flag bit0= make absolute command paths with known systems
1730
bit1= do not allow prefixes with cmd
1731
bit2= interpret unprefixed cmd as shell:
1733
int Xorriso_make_mount_cmd(struct XorrisO *xorriso, char *cmd,
1734
int lba, int track, int session, char *volid,
1735
char *devadr, char result[SfileadrL], int flag)
1737
int ret, reg_file= 0, is_safe= 0, sys_code= 0;
1738
char form[6*SfileadrL], session_text[12], track_text[12], lba_text[12];
1739
char *vars[5][2], sfe[5*SfileadrL], volid_sfe[5*80+1], *cpt, *sysname;
1742
if(strlen(cmd) > SfileadrL) {
1746
Xorriso_msgs_submit(xorriso, 0, "Argument much too long", 0, "FAILURE", 0);
1749
ret= stat(devadr, &stbuf);
1751
if(S_ISREG(stbuf.st_mode))
1753
if(strncmp(cmd, "linux:", 6) == 0 && !(flag & 2)) {
1756
} else if(strncmp(cmd, "freebsd:", 8) == 0 && !(flag & 2)) {
1759
} else if(strncmp(cmd, "string:", 7) == 0 && !(flag & 2)) {
1762
} else if(flag & 4) {
1767
ret= System_uname(&sysname, NULL, NULL, NULL, 0);
1769
Xorriso_msgs_submit(xorriso, 0,
1770
"-mount*: Cannot determine current system type",
1773
} else if(strcmp(sysname, "FreeBSD") == 0 ||
1774
strcmp(sysname, "GNU/kFreeBSD") == 0) {
1775
/* "GNU/kFreeBSD" = Debian kfreebsd */
1777
} else if(strcmp(sysname, "Linux") == 0) {
1780
sprintf(xorriso->info_text, "-mount*: Unsupported system type %s",
1781
Text_shellsafe(sysname, sfe, 0));
1782
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
1787
if(sys_code == 1) { /* GNU/Linux */
1789
"%smount -t iso9660 -o %snodev,noexec,nosuid,ro,sbsector=%%sbsector%% %%device%% %s",
1790
(flag & 1 ? "/bin/" : ""),
1791
(reg_file || (xorriso->mount_opts_flag & 1) ? "loop," : ""),
1792
Text_shellsafe(cpt, sfe, 0));
1794
} else if(sys_code == 2) { /* FreeBSD */
1797
/* <<< Considered to create vnode as of
1798
J.R. Oldroyd <fbsd@opal.com>, 20 Nov 2008
1799
but for now refraining from creating that persistent file object
1801
strcpy(form, "n=$(mdconfig -a -t vnode -f %device%)");
1802
sprintf(form + strlen(form),
1803
" && mount -t cd9660 -o noexec,nosuid -s %%sbsector%% /dev/\"$n\" %s",
1804
Text_shellsafe(cmd+8, sfe, 0));
1807
Xorriso_msgs_submit(xorriso, 0,
1808
"Detected regular file as mount device with FreeBSD style command.",
1810
Xorriso_msgs_submit(xorriso, 0,
1811
"Command mdconfig -a -t vnode -f can create a device node which uses the file",
1816
"%smount_cd9660 -o noexec,nosuid -s %%sbsector%% %%device%% %s",
1817
(flag & 1 ? "/sbin/" : ""), Text_shellsafe(cmd+8, sfe, 0));
1819
Not working on FreeBSD 7.2 according to Zsolt Kuti, 11 Oct 2009:
1820
"%smount -t cd9660 -o noexec,nosuid -o -s %%sbsector%% %%device%% %s",
1825
sprintf(session_text, "%d", session);
1826
sprintf(track_text, "%d", track);
1827
sprintf(lba_text, "%d", lba);
1828
vars[0][0]= "sbsector";
1829
vars[0][1]= lba_text;
1830
vars[1][0]= "track";
1831
vars[1][1]= track_text;
1832
vars[2][0]= "session";
1833
vars[2][1]= session_text;
1834
vars[3][0]= "volid";
1835
vars[3][1]= Text_shellsafe(volid, volid_sfe, 0);
1836
vars[4][0]= "device";
1837
vars[4][1]= Text_shellsafe(devadr, sfe, 0);
1838
ret= Sregex_resolve_var(form, vars, 5, "%", "%", "%", result, SfileadrL, 0);
1841
return(1 + is_safe);
1845
int Xorriso_append_scdbackup_record(struct XorrisO *xorriso, int flag)
1848
char dummy[81], name[81], timestamp[81], size[81], md5[81];
1850
if(xorriso->scdbackup_tag_written[0] == 0)
1853
name[0]= timestamp[0]= size[0]= md5[0]= 0;
1854
sscanf(xorriso->scdbackup_tag_written, "%s %s %s %s %s %s %s",
1855
dummy, dummy, dummy, name, timestamp, size, md5);
1856
sprintf(xorriso->info_text, "scdbackup tag written : %s %s %s %s\n",
1857
name, timestamp, size, md5);
1858
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
1860
if(xorriso->scdbackup_tag_listname[0]) {
1861
fp= fopen(xorriso->scdbackup_tag_listname, "a");
1863
strcpy(xorriso->info_text, "-scdbackup_tag: Cannot open file ");
1864
Text_shellsafe(xorriso->scdbackup_tag_listname, xorriso->info_text, 1);
1865
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
1868
fprintf(fp, "%s %s %s %s\n", name, timestamp, size, md5);