New options -cpax, -cp_rx, cp_rax to restore files and trees from ISO to disk
This commit is contained in:
@ -2692,12 +2692,14 @@ failed:;
|
||||
|
||||
|
||||
/* @param flag bit0= minimal transfer: access permissions only
|
||||
bit1= do not set timestamps
|
||||
*/
|
||||
int Permstack_pop(struct PermiteM **o, struct PermiteM *stopper,
|
||||
struct XorrisO *xorriso, int flag)
|
||||
{
|
||||
int ret;
|
||||
char sfe[5*SfileadrL];
|
||||
struct utimbuf utime_buffer;
|
||||
struct PermiteM *m, *m_next;
|
||||
|
||||
if((*o)==stopper)
|
||||
@ -2723,9 +2725,22 @@ int Permstack_pop(struct PermiteM **o, struct PermiteM *stopper,
|
||||
0);
|
||||
}
|
||||
}
|
||||
if(!(flag&1))
|
||||
if(!(flag&1)) {
|
||||
chown(m->disk_path, m->stbuf.st_uid, m->stbuf.st_gid);
|
||||
/* don't complain if it fails */
|
||||
if(!(flag&2)) {
|
||||
utime_buffer.actime= m->stbuf.st_atime;
|
||||
utime_buffer.modtime= m->stbuf.st_mtime;;
|
||||
ret= utime(m->disk_path,&utime_buffer);
|
||||
if(ret==-1 && xorriso!=NULL) {
|
||||
sprintf(xorriso->info_text,
|
||||
"Cannot change timestamps of disk directory: %s",
|
||||
Text_shellsafe(m->disk_path, sfe, 0));
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE",
|
||||
0);
|
||||
}
|
||||
}
|
||||
}
|
||||
m_next= m->next;
|
||||
free(m->disk_path);
|
||||
free((char *) m);
|
||||
@ -8711,7 +8726,10 @@ ex:;
|
||||
}
|
||||
|
||||
|
||||
/* Option -cpx */
|
||||
/* Options -cpx , -cpax, -cp_rx , -cp_rax */
|
||||
/* @param flag bit0= recursive (-cp_rx, -cp_rax)
|
||||
bit1= full property restore (-cpax, -cp_rax)
|
||||
*/
|
||||
int Xorriso_option_cpx(struct XorrisO *xorriso, int argc, char **argv,
|
||||
int *idx, int flag)
|
||||
{
|
||||
@ -8722,7 +8740,7 @@ int Xorriso_option_cpx(struct XorrisO *xorriso, int argc, char **argv,
|
||||
char **optv= NULL;
|
||||
struct stat stbuf;
|
||||
|
||||
ret= Xorriso_cpmv_args(xorriso, "-cpx", argc, argv, idx,
|
||||
ret= Xorriso_cpmv_args(xorriso, "-cp*x", argc, argv, idx,
|
||||
&optc, &optv, eff_dest, 1|4);
|
||||
if(ret<=0)
|
||||
goto ex;
|
||||
@ -8738,7 +8756,7 @@ int Xorriso_option_cpx(struct XorrisO *xorriso, int argc, char **argv,
|
||||
}
|
||||
if(xorriso->volset_change_pending) {
|
||||
sprintf(xorriso->info_text,
|
||||
"-cpx: Image changes pending. May not copy from image to disk.\n");
|
||||
"-cp*x: Image changes pending. May not copy from image to disk.\n");
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
|
||||
ret= 0; goto ex;
|
||||
}
|
||||
@ -8754,7 +8772,7 @@ int Xorriso_option_cpx(struct XorrisO *xorriso, int argc, char **argv,
|
||||
ret= Xorriso_iso_lstat(xorriso, eff_origin, &stbuf, 2|4);
|
||||
if(ret==-1)
|
||||
goto problem_handler;
|
||||
if(S_ISDIR(stbuf.st_mode)) {
|
||||
if(S_ISDIR(stbuf.st_mode) && !(flag&1)) {
|
||||
/* only allow directories if they actually represent split data files */
|
||||
ret= 0;
|
||||
if(xorriso->do_concat_split)
|
||||
@ -8782,7 +8800,7 @@ int Xorriso_option_cpx(struct XorrisO *xorriso, int argc, char **argv,
|
||||
goto problem_handler;
|
||||
}
|
||||
}
|
||||
ret= Xorriso_restore(xorriso, eff_origin, eff_dest, 16|64);
|
||||
ret= Xorriso_restore(xorriso, eff_origin, eff_dest, 16 | (!(flag&2)<<6));
|
||||
if(ret<=0 || xorriso->request_to_abort)
|
||||
goto problem_handler;
|
||||
if(ret==3 || (flag&1))
|
||||
@ -8804,7 +8822,7 @@ problem_handler:;
|
||||
xorriso->pacifier_total, "", 1);
|
||||
ret= !was_failure;
|
||||
ex:;
|
||||
Xorriso_opt_args(xorriso, "-cpx",
|
||||
Xorriso_opt_args(xorriso, "-cp*x",
|
||||
argc, argv, *idx, &end_idx_dummy, &optc, &optv, 256);
|
||||
return(ret);
|
||||
}
|
||||
@ -9728,9 +9746,15 @@ int Xorriso_option_help(struct XorrisO *xorriso, int flag)
|
||||
" to create, overwrite, delete files in the disk filesystem.",
|
||||
" -cpx iso_rr_path [***] disk_path",
|
||||
" Copy leaf file objects from ISO image to disk filesystem.",
|
||||
" -cpax iso_rr_path [***] disk_path",
|
||||
" Like -cpx but trying to restore timestamps and ownership.",
|
||||
" -cp_rx iso_rr_path [***] disk_path",
|
||||
" Copy directory trees from ISO image to disk filesystem.",
|
||||
" -cp_rax iso_rr_path [***] disk_path",
|
||||
" Like -cp_rx but trying to restore timestamps and ownership.",
|
||||
"",
|
||||
"Compatibility emulation (argument list may be ended by --):",
|
||||
" -as mkisofs [-help|-o|-R|-J|-V|-P|-f|-graft-points|-path-list|pathspecs]",
|
||||
" -as mkisofs [-help|-o|-R|-J|-V|-P|-f|-m|-graft-points|-path-list|pathspecs]",
|
||||
" Perform some mkisofs gestures, understand pathspecs as mkisofs",
|
||||
" does. Commit happens outside emulation at usual occasions.",
|
||||
" -as cdrecord [-help|-v|dev=|speed=|blank=|fs=|-eject|-atip|padsize=|path|-]",
|
||||
@ -11593,7 +11617,7 @@ int Xorriso_count_args(struct XorrisO *xorriso, int argc, char **argv,
|
||||
static char argn_commands[][40]= {
|
||||
"add","as","chgrp","chgrpi","chgrp_r","chgrp_ri","chmod","chmodi",
|
||||
"chmod_r","chmod_ri","chown","chowni","chown_r","chown_ri",
|
||||
"cpr","cpri","cpx",
|
||||
"cpr","cpri","cp_rax","cp_rx","cpax","cpx",
|
||||
"du","dui","dus","dusi","dux","dusx","find","findi","findx",
|
||||
"ls","lsi","lsl","lsli","lsd","lsdi","lsdl","lsdli",
|
||||
"lsx","lslx","lsdx","lsdlx","mv","mvi","mkdir","mkdiri",
|
||||
@ -11810,8 +11834,13 @@ next_command:;
|
||||
} else if(strcmp(cmd,"cpr")==0 || strcmp(cmd,"cpri")==0) {
|
||||
ret= Xorriso_option_cpri(xorriso, argc, argv, idx, 0);
|
||||
|
||||
} else if(strcmp(cmd,"cpx")==0) {
|
||||
ret= Xorriso_option_cpx(xorriso, argc, argv, idx, 0);
|
||||
} else if(strcmp(cmd,"cp_rx")==0 || strcmp(cmd,"cp_rax")==0) {
|
||||
ret= Xorriso_option_cpx(xorriso, argc, argv, idx,
|
||||
1|((strcmp(cmd,"cp_rax")==0)<<1));
|
||||
|
||||
} else if(strcmp(cmd,"cpx")==0 || strcmp(cmd,"cpax")==0) {
|
||||
ret= Xorriso_option_cpx(xorriso, argc, argv, idx,
|
||||
(strcmp(cmd,"cpax")==0)<<1);
|
||||
|
||||
} else if(strcmp(cmd,"cut_out")==0) {
|
||||
(*idx)+= 4;
|
||||
|
Reference in New Issue
Block a user