2010-05-15 18:48:10 +00:00
|
|
|
|
|
|
|
/* xorriso - creates, loads, manipulates and burns ISO 9660 filesystem images.
|
|
|
|
|
2020-01-02 17:50:59 +00:00
|
|
|
Copyright 2007-2020 Thomas Schmitt, <scdbackup@gmx.net>
|
2010-05-15 18:48:10 +00:00
|
|
|
|
|
|
|
Provided under GPL version 2 or later.
|
|
|
|
|
|
|
|
This file contains the implementation of options as mentioned in man page
|
|
|
|
or info file derived from xorriso.texi.
|
|
|
|
*/
|
|
|
|
|
2010-05-16 09:32:14 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "../config.h"
|
|
|
|
#endif
|
|
|
|
|
2010-05-15 18:48:10 +00:00
|
|
|
#include <ctype.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <time.h>
|
|
|
|
#include <errno.h>
|
|
|
|
|
|
|
|
#include "xorriso.h"
|
|
|
|
#include "xorriso_private.h"
|
|
|
|
#include "xorrisoburn.h"
|
|
|
|
|
|
|
|
|
2019-04-18 09:28:35 +00:00
|
|
|
/* Command -iso_nowtime "dynamic"|timespec */
|
|
|
|
int Xorriso_option_iso_nowtime(struct XorrisO *xorriso, char *text, int flag)
|
|
|
|
{
|
|
|
|
char *time_type = "m";
|
|
|
|
int t_type= 0, ret;
|
|
|
|
time_t t;
|
|
|
|
|
|
|
|
if(strcmp(text, "dynamic") == 0) {
|
|
|
|
xorriso->do_override_now_time= 0;
|
|
|
|
Xorriso_set_libisofs_now(xorriso, 2);
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, "-iso_nowtime: Set to \"dynamic\"", 0,
|
|
|
|
"NOTE", 0);
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
ret= Xorriso_convert_datestring(xorriso, "-iso_nowtime", time_type, text,
|
|
|
|
&t_type, &t, 0);
|
|
|
|
if(ret<=0)
|
|
|
|
goto ex;
|
|
|
|
xorriso->do_override_now_time= 1;
|
|
|
|
xorriso->now_time_override= t;
|
|
|
|
Xorriso_set_libisofs_now(xorriso, 1);
|
|
|
|
sprintf(xorriso->info_text, "-iso_nowtime: Set to =%.f", (double) t);
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
|
|
|
|
ret= 1;
|
|
|
|
ex:;
|
|
|
|
return(ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-05-15 18:48:10 +00:00
|
|
|
/* Option -iso_rr_pattern "on"|"ls"|"off" */
|
|
|
|
int Xorriso_option_iso_rr_pattern(struct XorrisO *xorriso, char *mode,int flag)
|
|
|
|
{
|
|
|
|
if(strcmp(mode, "off")==0)
|
|
|
|
xorriso->do_iso_rr_pattern= 0;
|
|
|
|
else if(strcmp(mode, "on")==0)
|
|
|
|
xorriso->do_iso_rr_pattern= 1;
|
|
|
|
else if(strcmp(mode, "ls")==0)
|
|
|
|
xorriso->do_iso_rr_pattern= 2;
|
|
|
|
else {
|
|
|
|
sprintf(xorriso->info_text, "-iso_rr_pattern: unknown mode '%s'", mode);
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-09-29 09:24:20 +00:00
|
|
|
/* Option -jigdo aspect argument */
|
|
|
|
int Xorriso_option_jigdo(struct XorrisO *xorriso, char *aspect, char *arg,
|
|
|
|
int flag)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret= Xorriso_jigdo_interpreter(xorriso, aspect, arg, 0);
|
|
|
|
return(ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-05-15 18:48:10 +00:00
|
|
|
/* Option -joliet "on"|"off" */
|
|
|
|
int Xorriso_option_joliet(struct XorrisO *xorriso, char *mode, int flag)
|
|
|
|
{
|
|
|
|
if(strcmp(mode, "off")==0)
|
|
|
|
xorriso->do_joliet= 0;
|
|
|
|
else if(strcmp(mode, "on")==0)
|
|
|
|
xorriso->do_joliet= 1;
|
|
|
|
else {
|
|
|
|
sprintf(xorriso->info_text, "-joliet: unknown mode '%s'", mode);
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-04 10:35:01 +00:00
|
|
|
/* Command -joliet_map */
|
|
|
|
int Xorriso_option_joliet_map(struct XorrisO *xorriso, char *mode, int flag)
|
|
|
|
{
|
|
|
|
if(strcmp(mode, "unmapped") == 0) {
|
|
|
|
xorriso->joliet_map= 0;
|
|
|
|
} else if(strcmp(mode, "stripped") == 0) {
|
|
|
|
xorriso->joliet_map= 1;
|
|
|
|
} else {
|
|
|
|
sprintf(xorriso->info_text, "-joliet_map: unknown mode '%s'", mode);
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-12-20 20:22:58 +00:00
|
|
|
/* Command -launch_frontend */
|
2012-12-25 17:56:24 +00:00
|
|
|
int Xorriso_option_launch_frontend(struct XorrisO *xorriso,
|
|
|
|
int argc, char **argv, int *idx, int flag)
|
2012-12-20 20:22:58 +00:00
|
|
|
{
|
2012-12-25 17:56:24 +00:00
|
|
|
int ret, end_idx;
|
2012-12-20 20:22:58 +00:00
|
|
|
|
2012-12-25 17:56:24 +00:00
|
|
|
end_idx= Xorriso_end_idx(xorriso, argc, argv, *idx, 1);
|
2012-12-20 20:22:58 +00:00
|
|
|
|
|
|
|
if(xorriso->launch_frontend_banned) {
|
|
|
|
sprintf(xorriso->info_text,
|
|
|
|
"-launch_frontend was already executed in this xorriso run");
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
|
2012-12-25 17:56:24 +00:00
|
|
|
ret= 0; goto ex;
|
2012-12-20 20:22:58 +00:00
|
|
|
}
|
|
|
|
xorriso->launch_frontend_banned= 1;
|
2012-12-25 17:56:24 +00:00
|
|
|
if(end_idx <= *idx)
|
|
|
|
{ret= 1; goto ex;}
|
|
|
|
if(argv[*idx][0] == 0)
|
|
|
|
{ret= 1; goto ex;}
|
|
|
|
xorriso->dialog= 2;
|
|
|
|
ret= Xorriso_launch_frontend(xorriso, end_idx - *idx, argv + *idx,
|
|
|
|
"", "", 0);
|
|
|
|
ex:;
|
|
|
|
(*idx)= end_idx;
|
2012-12-20 20:22:58 +00:00
|
|
|
return(ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-01-31 13:04:28 +00:00
|
|
|
/* Option -list_arg_sorting */
|
|
|
|
int Xorriso_option_list_arg_sorting(struct XorrisO *xorriso, int flag)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret= Xorriso_cmd_sorting_rank(xorriso, 0, NULL, 0, 1);
|
|
|
|
return(ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-05-15 18:48:10 +00:00
|
|
|
/* Option -list_delimiter */
|
|
|
|
int Xorriso_option_list_delimiter(struct XorrisO *xorriso, char *text,
|
|
|
|
int flag)
|
|
|
|
{
|
|
|
|
int ret, argc;
|
|
|
|
char **argv= NULL;
|
|
|
|
|
|
|
|
if(text[0] == 0) {
|
|
|
|
sprintf(xorriso->info_text,
|
|
|
|
"-list_delimiter: New delimiter text is empty");
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
if(strlen(text) > 80) {
|
|
|
|
sprintf(xorriso->info_text,
|
|
|
|
"-list_delimiter: New delimiter text is too long");
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
ret= Sfile_make_argv(xorriso->progname, text, &argc, &argv, 4);
|
|
|
|
if(ret > 0) {
|
|
|
|
if(argc > 2) {
|
|
|
|
sprintf(xorriso->info_text,
|
|
|
|
"-list_delimiter: New delimiter text contains more than one word");
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
|
|
|
|
}
|
|
|
|
Sfile_make_argv(xorriso->progname, text, &argc, &argv, 2);
|
|
|
|
if(argc > 2)
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
if(strchr(text, '"') != NULL || strchr(text, '\'') != NULL) {
|
|
|
|
sprintf(xorriso->info_text,
|
|
|
|
"-list_delimiter: New delimiter text contains quotation marks");
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
strcpy(xorriso->list_delimiter, text);
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-08-18 15:19:27 +00:00
|
|
|
/* Option -list_extras */
|
|
|
|
int Xorriso_option_list_extras(struct XorrisO *xorriso, char *mode, int flag)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret= Xorriso_list_extras(xorriso, mode, 0);
|
|
|
|
return(ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-05-15 18:48:10 +00:00
|
|
|
/* Option -list_formats */
|
|
|
|
int Xorriso_option_list_formats(struct XorrisO *xorriso, int flag)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret= Xorriso_list_formats(xorriso, 0);
|
|
|
|
return(ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-07-04 09:29:00 +00:00
|
|
|
/* Option -list_speeds */
|
|
|
|
int Xorriso_option_list_speeds(struct XorrisO *xorriso, int flag)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret= Xorriso_list_speeds(xorriso, 0);
|
|
|
|
return(ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-05-15 18:48:10 +00:00
|
|
|
/* Option -list_profiles */
|
|
|
|
int Xorriso_option_list_profiles(struct XorrisO *xorriso, char *which,
|
|
|
|
int flag)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
int mode= 0;
|
|
|
|
|
|
|
|
if(strncmp(which,"in",2)==0)
|
|
|
|
mode|= 1;
|
|
|
|
else if(strncmp(which,"out",3)==0)
|
|
|
|
mode|= 2;
|
|
|
|
else
|
|
|
|
mode|= 3;
|
|
|
|
if(mode & 1) {
|
|
|
|
ret= Xorriso_toc(xorriso, 1 | 16 | 32);
|
|
|
|
if(ret > 0)
|
|
|
|
Xorriso_list_profiles(xorriso, 0);
|
|
|
|
}
|
|
|
|
if((mode & 2) && xorriso->in_drive_handle != xorriso->out_drive_handle) {
|
|
|
|
ret= Xorriso_toc(xorriso, 1 | 2 | 16 | 32);
|
|
|
|
if(ret > 0)
|
|
|
|
Xorriso_list_profiles(xorriso, 2);
|
|
|
|
}
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-10-19 08:19:02 +00:00
|
|
|
/* Command -lns alias -lnsi */
|
|
|
|
int Xorriso_option_lnsi(struct XorrisO *xorriso, char *target, char *path,
|
|
|
|
int flag)
|
|
|
|
{
|
|
|
|
int ret;
|
2015-09-17 12:12:41 +00:00
|
|
|
char *eff_path= NULL, *buffer= NULL, *namept;
|
2012-10-19 08:19:02 +00:00
|
|
|
|
|
|
|
Xorriso_alloc_meM(eff_path, char, SfileadrL);
|
2015-09-17 12:12:41 +00:00
|
|
|
Xorriso_alloc_meM(buffer, char, SfileadrL);
|
2012-10-19 08:19:02 +00:00
|
|
|
|
|
|
|
ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, path, eff_path, 1);
|
|
|
|
if(ret < 0)
|
|
|
|
{ret= 0; goto ex;}
|
|
|
|
if(ret > 0) {
|
|
|
|
sprintf(xorriso->info_text, "-lns: Address already existing: ");
|
|
|
|
Text_shellsafe(eff_path, xorriso->info_text, 1);
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
|
|
|
|
{ret= 0; goto ex;}
|
|
|
|
}
|
|
|
|
ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, path, eff_path, 2);
|
|
|
|
if(ret < 0)
|
|
|
|
{ret= 0; goto ex;}
|
2015-09-17 12:12:41 +00:00
|
|
|
ret= Xorriso_truncate_path_comps(xorriso, target, buffer, &namept, 0);
|
|
|
|
if(ret < 0)
|
|
|
|
{ret= 0; goto ex;}
|
|
|
|
ret= Xorriso_graft_in(xorriso, NULL, namept, eff_path, (off_t) 0, (off_t) 0,
|
2012-10-19 08:19:02 +00:00
|
|
|
1024);
|
|
|
|
if(ret <= 0)
|
|
|
|
{ret= 0; goto ex;}
|
|
|
|
ret= 1;
|
|
|
|
ex:;
|
2015-09-17 12:12:41 +00:00
|
|
|
Xorriso_free_meM(buffer);
|
2012-10-19 08:19:02 +00:00
|
|
|
Xorriso_free_meM(eff_path);
|
|
|
|
return(ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-05-15 18:48:10 +00:00
|
|
|
/* Option -load session|track|sbsector value */
|
|
|
|
/* @param flag bit0= with adr_mode sbsector: adr_value is possibly 16 too high
|
|
|
|
@return <=0 error , 1 success, 2 revoked by -reassure
|
|
|
|
*/
|
|
|
|
int Xorriso_option_load(struct XorrisO *xorriso, char *adr_mode,
|
|
|
|
char *adr_value, int flag)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
2012-03-03 13:39:50 +00:00
|
|
|
if(Xorriso_change_is_pending(xorriso, 0)) {
|
2010-05-15 18:48:10 +00:00
|
|
|
sprintf(xorriso->info_text,
|
|
|
|
"-load: Image changes pending. -commit or -rollback first");
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
ret= Xorriso_reassure(xorriso, "-load", "loads an alternative image", 0);
|
|
|
|
if(ret<=0)
|
|
|
|
return(2);
|
|
|
|
ret= Xorriso_decode_load_adr(xorriso, "-load", adr_mode, adr_value,
|
|
|
|
&(xorriso->image_start_mode),
|
|
|
|
xorriso->image_start_value, flag & 1);
|
|
|
|
if(ret <= 0)
|
|
|
|
return(ret);
|
|
|
|
xorriso->image_start_mode|= (1<<30); /* enable non-default msc1 processing */
|
|
|
|
if(strlen(xorriso->indev)>0) {
|
|
|
|
ret= Xorriso_option_rollback(xorriso, 1); /* Load image, no -reassure */
|
|
|
|
if(ret<=0)
|
|
|
|
return(ret);
|
|
|
|
}
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Option -logfile */
|
|
|
|
int Xorriso_option_logfile(struct XorrisO *xorriso, char *channel,
|
|
|
|
char *fileadr, int flag)
|
|
|
|
{
|
|
|
|
int hflag,channel_no= 0, ret;
|
|
|
|
|
|
|
|
if(channel[0]==0) {
|
|
|
|
logfile_wrong_form:;
|
|
|
|
sprintf(xorriso->info_text,"Wrong form. Correct would be: -logfile \".\"|\"R\"|\"I\"|\"M\" file_address");
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
hflag= 2;
|
|
|
|
if(channel[0]=='R')
|
|
|
|
channel_no= 1;
|
|
|
|
else if(channel[0]=='I')
|
|
|
|
channel_no= 2;
|
|
|
|
else if(channel[0]=='M')
|
|
|
|
channel_no= 3;
|
|
|
|
else if(channel[0]=='.')
|
|
|
|
hflag= 4;
|
|
|
|
else
|
|
|
|
goto logfile_wrong_form;
|
|
|
|
if(strcmp(fileadr,"-")==0 || fileadr[0]==0)
|
|
|
|
hflag|= (1<<15);
|
|
|
|
xorriso->logfile[channel_no][0]= 0;
|
|
|
|
ret= Xorriso_write_to_channel(xorriso, fileadr, channel_no, hflag);
|
|
|
|
if(ret<=0) {
|
|
|
|
sprintf(xorriso->info_text, "Cannot open logfile: %s", fileadr);
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
|
|
|
|
} else if(!(hflag&(1<<15)))
|
|
|
|
if(Sfile_str(xorriso->logfile[channel_no], fileadr, 0)<=0)
|
|
|
|
return(-1);
|
|
|
|
return(ret>0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Options -ls alias -lsi and -lsl alias -lsli
|
|
|
|
and -lsd alias -lsdi and -lsdl alias -lsdli
|
|
|
|
and -du alias -dui and -dus alias -dusi
|
2013-07-05 16:40:46 +00:00
|
|
|
@param flag bit0= long format (-lsl , -du, not -dus, not -ls)
|
2010-05-15 18:48:10 +00:00
|
|
|
bit1= do not expand patterns but use literally
|
2013-07-05 16:40:46 +00:00
|
|
|
bit2= -du rather than -ls
|
|
|
|
bit3= list directories as themselves (-lsd)
|
2010-05-15 18:48:10 +00:00
|
|
|
*/
|
|
|
|
int Xorriso_option_lsi(struct XorrisO *xorriso, int argc, char **argv,
|
|
|
|
int *idx, int flag)
|
|
|
|
{
|
2013-07-05 16:40:46 +00:00
|
|
|
int ret, end_idx, filec= 0, nump, i, star= 1;
|
2010-05-15 18:48:10 +00:00
|
|
|
char **filev= NULL, **patterns= NULL;
|
|
|
|
off_t mem= 0;
|
|
|
|
struct stat stbuf;
|
|
|
|
|
2013-07-05 16:40:46 +00:00
|
|
|
if(flag & 4) {
|
|
|
|
if(!(flag & 1))
|
|
|
|
star= 0;
|
|
|
|
} else {
|
|
|
|
if(flag & 8)
|
|
|
|
star= 0;
|
|
|
|
}
|
|
|
|
|
2010-05-15 18:48:10 +00:00
|
|
|
end_idx= Xorriso_end_idx(xorriso, argc, argv, *idx, 1);
|
|
|
|
if(xorriso->do_iso_rr_pattern==0)
|
|
|
|
flag|= 2;
|
|
|
|
|
|
|
|
nump= end_idx - *idx;
|
|
|
|
if((flag&2) && nump>0 ) {
|
|
|
|
;
|
|
|
|
} else if(nump <= 0) {
|
|
|
|
if(Xorriso_iso_lstat(xorriso, xorriso->wdi, &stbuf, 0)<0) {
|
|
|
|
sprintf(xorriso->info_text,
|
|
|
|
"Current -cd path does not yet exist in the ISO image");
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
|
|
|
|
{ret= 0; goto ex;}
|
|
|
|
}
|
|
|
|
if(!S_ISDIR(stbuf.st_mode)) {
|
|
|
|
sprintf(xorriso->info_text,
|
|
|
|
"Current -cd meanwhile points to a non-directory in ISO image");
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
|
|
|
|
{ret= 0; goto ex;}
|
|
|
|
}
|
|
|
|
patterns= calloc(1, sizeof(char *));
|
|
|
|
if(patterns == NULL) {
|
|
|
|
no_memory:;
|
|
|
|
sprintf(xorriso->info_text,
|
|
|
|
"Cannot allocate enough memory for pattern expansion");
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
|
|
|
|
{ret= -1; goto ex;}
|
|
|
|
}
|
|
|
|
nump= 1;
|
2013-07-05 16:40:46 +00:00
|
|
|
if(star)
|
2010-05-15 18:48:10 +00:00
|
|
|
patterns[0]= "*";
|
2013-07-05 16:40:46 +00:00
|
|
|
else
|
|
|
|
patterns[0]= ".";
|
2010-05-15 18:48:10 +00:00
|
|
|
flag&= ~2;
|
|
|
|
} else {
|
|
|
|
patterns= calloc(nump, sizeof(char *));
|
|
|
|
if(patterns==NULL)
|
|
|
|
goto no_memory;
|
|
|
|
for(i= 0; i<nump; i++) {
|
2013-07-05 16:40:46 +00:00
|
|
|
if(argv[i + *idx][0]==0) {
|
|
|
|
if(star)
|
|
|
|
patterns[i]= "*";
|
|
|
|
else
|
|
|
|
patterns[i]= ".";
|
|
|
|
} else
|
2010-05-15 18:48:10 +00:00
|
|
|
patterns[i]= argv[i + *idx];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-06 16:17:42 +00:00
|
|
|
if((flag & 1) && !(xorriso->ino_behavior & 32)) {
|
2010-05-15 18:48:10 +00:00
|
|
|
ret= Xorriso_make_hln_array(xorriso, 0); /* for stbuf.st_nlink */
|
|
|
|
if(ret < 0)
|
2015-11-03 15:00:02 +00:00
|
|
|
goto ex;
|
2010-05-15 18:48:10 +00:00
|
|
|
}
|
|
|
|
if(flag&2) {
|
|
|
|
ret= Xorriso_ls_filev(xorriso, xorriso->wdi, nump, argv + (*idx), mem,
|
|
|
|
flag&(1|4|8));
|
|
|
|
} else if(nump==1 && strcmp(patterns[0],"*")==0 && !(flag&4)){
|
|
|
|
/* save temporary memory by calling simpler function */
|
|
|
|
ret= Xorriso_ls(xorriso, (flag&1)|4);
|
|
|
|
} else {
|
|
|
|
ret= Xorriso_expand_pattern(xorriso, nump, patterns, 0, &filec, &filev,
|
|
|
|
&mem, 0);
|
|
|
|
if(ret<=0)
|
|
|
|
{ret= 0; goto ex;}
|
|
|
|
ret= Xorriso_ls_filev(xorriso, xorriso->wdi, filec, filev, mem,
|
|
|
|
flag&(1|4|8));
|
|
|
|
}
|
|
|
|
if(ret<=0)
|
|
|
|
{ret= 0; goto ex;}
|
|
|
|
|
|
|
|
ret= 1;
|
|
|
|
ex:;
|
|
|
|
if(patterns!=NULL)
|
|
|
|
free((char *) patterns);
|
|
|
|
Sfile_destroy_argv(&filec, &filev, 0);
|
|
|
|
(*idx)= end_idx;
|
|
|
|
return(ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Options -lsx, -lslx, -lsdx , -lsdlx , -dux , -dusx
|
|
|
|
@param flag bit0= long format (-lslx , -dux)
|
|
|
|
bit1= do not expand patterns but use literally
|
|
|
|
bit2= du rather than ls
|
|
|
|
bit3= list directories as themselves (ls -d)
|
|
|
|
*/
|
|
|
|
int Xorriso_option_lsx(struct XorrisO *xorriso, int argc, char **argv,
|
|
|
|
int *idx, int flag)
|
|
|
|
{
|
|
|
|
int ret, end_idx, filec= 0, nump, i;
|
|
|
|
char **filev= NULL, **patterns= NULL;
|
|
|
|
off_t mem= 0;
|
|
|
|
|
|
|
|
end_idx= Xorriso_end_idx(xorriso, argc, argv, *idx, 1|2);
|
|
|
|
if(xorriso->do_disk_pattern==0)
|
|
|
|
flag|= 2;
|
|
|
|
|
|
|
|
nump= end_idx - *idx;
|
|
|
|
if((flag&2) && nump>0) {
|
|
|
|
;
|
|
|
|
} else if(nump <= 0) {
|
|
|
|
patterns= calloc(1, sizeof(char *));
|
|
|
|
if(patterns == NULL) {
|
|
|
|
no_memory:;
|
|
|
|
sprintf(xorriso->info_text,
|
|
|
|
"Cannot allocate enough memory for pattern expansion");
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
|
|
|
|
{ret= -1; goto ex;}
|
|
|
|
}
|
|
|
|
nump= 1;
|
|
|
|
if(flag&8)
|
|
|
|
patterns[0]= ".";
|
|
|
|
else
|
|
|
|
patterns[0]= "*";
|
|
|
|
flag&= ~2;
|
|
|
|
} else {
|
|
|
|
patterns= calloc(nump, sizeof(char *));
|
|
|
|
if(patterns==NULL)
|
|
|
|
goto no_memory;
|
|
|
|
for(i= 0; i<nump; i++) {
|
|
|
|
if(argv[i + *idx][0]==0)
|
|
|
|
patterns[i]= "*";
|
|
|
|
else
|
|
|
|
patterns[i]= argv[i + *idx];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(flag&2) {
|
|
|
|
ret= Xorriso_lsx_filev(xorriso, xorriso->wdx,
|
|
|
|
nump, argv + (*idx), mem, flag&(1|4|8));
|
|
|
|
|
|
|
|
#ifdef Not_yeT
|
|
|
|
} else if(nump==1 && strcmp(patterns[0],"*")==0 && !(flag&4)){
|
|
|
|
/* save temporary memory by calling simpler function */
|
|
|
|
ret= Xorriso_ls(xorriso, (flag&1)|4);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
} else {
|
|
|
|
ret= Xorriso_expand_disk_pattern(xorriso, nump, patterns, 0, &filec, &filev,
|
|
|
|
&mem, 0);
|
|
|
|
if(ret<=0)
|
|
|
|
{ret= 0; goto ex;}
|
|
|
|
ret= Xorriso_lsx_filev(xorriso, xorriso->wdx, filec, filev, mem,
|
|
|
|
flag&(1|4|8));
|
|
|
|
}
|
|
|
|
if(ret<=0)
|
|
|
|
{ret= 0; goto ex;}
|
|
|
|
|
|
|
|
ret= 1;
|
|
|
|
ex:;
|
|
|
|
if(patterns!=NULL)
|
|
|
|
free((char *) patterns);
|
|
|
|
Sfile_destroy_argv(&filec, &filev, 0);
|
|
|
|
(*idx)= end_idx;
|
|
|
|
return(ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Option -map , -map_single */
|
|
|
|
/* @param flag bit0=do not report the added item
|
|
|
|
bit1=do not reset pacifier, no final pacifier message
|
2015-09-22 20:46:57 +00:00
|
|
|
bit5= -map_single: do not insert directory tree
|
2010-05-15 18:48:10 +00:00
|
|
|
*/
|
|
|
|
int Xorriso_option_map(struct XorrisO *xorriso, char *disk_path,
|
|
|
|
char *iso_path, int flag)
|
|
|
|
{
|
|
|
|
int ret;
|
2011-05-05 16:38:12 +00:00
|
|
|
char *eff_origin= NULL, *eff_dest= NULL, *ipth;
|
|
|
|
|
|
|
|
Xorriso_alloc_meM(eff_origin, char, SfileadrL);
|
|
|
|
Xorriso_alloc_meM(eff_dest, char, SfileadrL);
|
2010-05-15 18:48:10 +00:00
|
|
|
|
|
|
|
if(!(flag&2))
|
|
|
|
Xorriso_pacifier_reset(xorriso, 0);
|
|
|
|
|
|
|
|
ipth= iso_path;
|
|
|
|
if(ipth[0]==0)
|
|
|
|
ipth= disk_path;
|
|
|
|
if(disk_path[0]==0) {
|
|
|
|
sprintf(xorriso->info_text, "-map: Empty disk_path given");
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 1);
|
2011-05-05 16:38:12 +00:00
|
|
|
{ret= 0; goto ex;}
|
2010-05-15 18:48:10 +00:00
|
|
|
}
|
|
|
|
ret= Xorriso_normalize_img_path(xorriso, xorriso->wdx, disk_path, eff_origin,
|
|
|
|
2|4);
|
|
|
|
if(ret<=0)
|
2011-05-05 16:38:12 +00:00
|
|
|
goto ex;
|
2010-05-15 18:48:10 +00:00
|
|
|
ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, ipth, eff_dest, 2);
|
|
|
|
if(ret<=0)
|
2011-05-05 16:38:12 +00:00
|
|
|
goto ex;
|
2010-05-15 18:48:10 +00:00
|
|
|
ret= Xorriso_graft_in(xorriso, NULL, eff_origin, eff_dest,
|
|
|
|
(off_t) 0, (off_t) 0, 2|(flag&32));
|
|
|
|
if(!(flag&2))
|
|
|
|
Xorriso_pacifier_callback(xorriso, "files added", xorriso->pacifier_count,
|
|
|
|
xorriso->pacifier_total, "", 1);
|
|
|
|
if(ret<=0)
|
2011-05-05 16:38:12 +00:00
|
|
|
goto ex;
|
2010-05-15 18:48:10 +00:00
|
|
|
|
|
|
|
if(!(flag&1)) {
|
|
|
|
sprintf(xorriso->info_text, "Added to ISO image: %s '%s'='%s'\n",
|
|
|
|
(ret>1 ? "directory" : "file"), (eff_dest[0] ? eff_dest : "/"),
|
|
|
|
eff_origin);
|
|
|
|
Xorriso_info(xorriso,0);
|
|
|
|
}
|
2011-05-05 16:38:12 +00:00
|
|
|
ret= 1;
|
|
|
|
ex:;
|
|
|
|
Xorriso_free_meM(eff_origin);
|
|
|
|
Xorriso_free_meM(eff_dest);
|
|
|
|
return(ret);
|
2010-05-15 18:48:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-12-14 09:18:14 +00:00
|
|
|
/* Command -map_l , -compare_l , -update_l , -extract_l , -update_lxi ,
|
|
|
|
-update_li
|
|
|
|
*/
|
2010-05-15 18:48:10 +00:00
|
|
|
/* @param flag bit4= do not establish and dispose xorriso->di_array
|
|
|
|
for update_l
|
|
|
|
bit8-11= mode 0= -map_l
|
|
|
|
1= -compare_l
|
|
|
|
2= -update_l
|
|
|
|
3= -extract_l
|
2016-12-05 13:35:04 +00:00
|
|
|
4= -update_lxi
|
2016-12-14 09:18:14 +00:00
|
|
|
5= -update_li
|
2010-05-15 18:48:10 +00:00
|
|
|
*/
|
|
|
|
int Xorriso_option_map_l(struct XorrisO *xorriso, int argc, char **argv,
|
|
|
|
int *idx, int flag)
|
|
|
|
{
|
2016-12-05 13:35:04 +00:00
|
|
|
int ret, end_idx, optc= 0, was_failure= 1, i, j, fret, mode, problem_count;
|
|
|
|
int ns_flag= 2|4, nt_flag= 2, opt_args_flag= 2, arg2c= 0, opt2c= 0;
|
|
|
|
int new_opt2c;
|
2011-05-05 16:38:12 +00:00
|
|
|
char *source_prefix= NULL, *target_prefix= NULL, *cmd, **optv= NULL;
|
2016-12-05 13:35:04 +00:00
|
|
|
char *eff_source= NULL, *eff_target= NULL, *s_wd, *t_wd;
|
|
|
|
char **eff_src_array= NULL, **eff_tgt_array= NULL, **opt2v= NULL;
|
|
|
|
char **arg2v= NULL;
|
2010-05-15 18:48:10 +00:00
|
|
|
|
|
|
|
cmd= "-map_l";
|
|
|
|
s_wd= xorriso->wdx;
|
|
|
|
t_wd= xorriso->wdi;
|
|
|
|
Xorriso_pacifier_reset(xorriso, 0);
|
|
|
|
mode= (flag>>8) & 15;
|
|
|
|
|
|
|
|
if(mode==1)
|
|
|
|
cmd= "-compare_l";
|
|
|
|
else if(mode==2)
|
|
|
|
cmd= "-update_l";
|
2016-12-14 09:18:14 +00:00
|
|
|
else if(mode == 3 || mode == 5) {
|
|
|
|
if(mode == 5)
|
|
|
|
cmd= "-update_li";
|
|
|
|
else
|
|
|
|
cmd= "-extract_l";
|
2010-05-15 18:48:10 +00:00
|
|
|
ns_flag= 2;
|
|
|
|
s_wd= xorriso->wdi;
|
|
|
|
nt_flag= 2|4;
|
|
|
|
t_wd= xorriso->wdx;
|
|
|
|
opt_args_flag= 0;
|
2016-12-05 13:35:04 +00:00
|
|
|
} else if(mode == 4) {
|
|
|
|
cmd= "-update_lxi";
|
2010-05-15 18:48:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
end_idx= Xorriso_end_idx(xorriso, argc, argv, *idx, 1|2);
|
|
|
|
if(end_idx - (*idx) < 3) {
|
|
|
|
sprintf(xorriso->info_text, "%s: Not enough arguments given (%d < 3)", cmd,
|
|
|
|
end_idx - (*idx));
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 1);
|
|
|
|
ret= 0; goto ex;
|
|
|
|
}
|
2011-05-22 18:14:56 +00:00
|
|
|
|
|
|
|
Xorriso_alloc_meM(source_prefix, char, SfileadrL);
|
|
|
|
Xorriso_alloc_meM(target_prefix, char, SfileadrL);
|
|
|
|
Xorriso_alloc_meM(eff_source, char, SfileadrL);
|
|
|
|
Xorriso_alloc_meM(eff_target, char, SfileadrL);
|
|
|
|
|
2010-05-15 18:48:10 +00:00
|
|
|
ret= Xorriso_normalize_img_path(xorriso, s_wd, argv[*idx],
|
|
|
|
source_prefix, ns_flag | 64);
|
|
|
|
if(ret<=0)
|
|
|
|
goto ex;
|
|
|
|
ret= Xorriso_normalize_img_path(xorriso, t_wd, argv[(*idx)+1],
|
|
|
|
target_prefix, nt_flag);
|
|
|
|
if(ret<=0)
|
|
|
|
goto ex;
|
|
|
|
ret= Xorriso_opt_args(xorriso, cmd, argc, argv, (*idx)+2, &end_idx,
|
|
|
|
&optc, &optv, opt_args_flag);
|
|
|
|
if(ret<=0)
|
|
|
|
goto ex;
|
2016-12-05 13:35:04 +00:00
|
|
|
if(mode == 4) {
|
|
|
|
/* Convert pattern from disk to iso_rr */
|
|
|
|
arg2c= end_idx - *idx - 2;
|
|
|
|
Xorriso_alloc_meM(arg2v, char *, arg2c);
|
|
|
|
for(i = 0; i < arg2c; i++)
|
|
|
|
arg2v[i]= NULL;
|
|
|
|
arg2c= 0;
|
|
|
|
for(i = (*idx) + 2; i < end_idx; i++) {
|
|
|
|
ret= Xorriso_normalize_img_path(xorriso, s_wd, argv[i],
|
|
|
|
eff_source, ns_flag);
|
|
|
|
if(ret<=0)
|
|
|
|
goto ex;
|
|
|
|
ret= Xorriso__exchange_prefix(source_prefix, target_prefix,
|
|
|
|
eff_source, eff_target, 0);
|
|
|
|
if(ret <= 0)
|
|
|
|
continue;
|
|
|
|
Xorriso_alloc_meM(arg2v[arg2c], char, strlen(eff_target) + 1);
|
|
|
|
strcpy(arg2v[arg2c], eff_target);
|
|
|
|
arg2c++;
|
|
|
|
}
|
|
|
|
/* Expand wildcards in iso_rr, do not include unmatched patterns */
|
|
|
|
ret= Xorriso_opt_args(xorriso, cmd, arg2c, arg2v, 0, &i,
|
|
|
|
&opt2c, &opt2v, (1 << 10) | (1 << 7));
|
|
|
|
if(ret<=0)
|
|
|
|
goto ex;
|
|
|
|
/* Convert from iso_rr path to disk path */
|
|
|
|
new_opt2c= 0;
|
|
|
|
for(i = 0; i < opt2c; i++) {
|
|
|
|
ret= Xorriso__exchange_prefix(target_prefix, source_prefix,
|
|
|
|
opt2v[i], eff_source, 0);
|
|
|
|
free(opt2v[i]);
|
|
|
|
opt2v[i]= NULL;
|
|
|
|
if(ret <= 0)
|
|
|
|
continue;
|
|
|
|
Xorriso_alloc_meM(opt2v[new_opt2c], char, strlen(eff_source) + 1);
|
|
|
|
strcpy(opt2v[new_opt2c], eff_source);
|
|
|
|
new_opt2c++;
|
|
|
|
}
|
|
|
|
opt2c= new_opt2c;
|
|
|
|
/* Merge both results */
|
|
|
|
if(opt2c > 0) {
|
|
|
|
Sfile_destroy_argv(&arg2c, &arg2v, 0);
|
|
|
|
Xorriso_alloc_meM(arg2v, char *, optc + opt2c);
|
|
|
|
for(i = 0; i < optc + opt2c; i++)
|
|
|
|
arg2v[i]= NULL;
|
|
|
|
arg2c= 0;
|
|
|
|
for(i= 0; i < optc; i++) {
|
|
|
|
ret= Xorriso_normalize_img_path(xorriso, s_wd, optv[i],
|
|
|
|
eff_source, ns_flag);
|
|
|
|
if(ret<=0)
|
|
|
|
goto ex;
|
|
|
|
Xorriso_alloc_meM(arg2v[arg2c], char, strlen(eff_source) + 1);
|
|
|
|
strcpy(arg2v[arg2c], eff_source);
|
|
|
|
arg2c++;
|
|
|
|
}
|
|
|
|
for(i= 0; i < opt2c; i++) {
|
|
|
|
for(j= 0; j < optc; j++)
|
|
|
|
if(strcmp(opt2v[i], arg2v[j]) == 0)
|
|
|
|
break;
|
|
|
|
if(j < optc)
|
|
|
|
continue;
|
|
|
|
arg2v[arg2c++]= opt2v[i];
|
|
|
|
opt2v[i]= NULL;
|
|
|
|
}
|
|
|
|
Sfile_destroy_argv(&optc, &optv, 0);
|
|
|
|
optv= arg2v;
|
|
|
|
arg2v= NULL;
|
|
|
|
optc= arg2c;
|
|
|
|
arg2c= 0;
|
|
|
|
}
|
|
|
|
}
|
2010-05-15 18:48:10 +00:00
|
|
|
|
|
|
|
if(mode == 3 &&
|
|
|
|
(xorriso->do_restore_sort_lba || !(xorriso->ino_behavior & 4))) {
|
|
|
|
eff_src_array= calloc(optc, sizeof(char *));
|
|
|
|
eff_tgt_array= calloc(optc, sizeof(char *));
|
|
|
|
if(eff_src_array == NULL || eff_tgt_array == NULL) {
|
|
|
|
Xorriso_no_malloc_memory(xorriso, NULL, 0);
|
|
|
|
ret= -1; goto ex;
|
|
|
|
}
|
|
|
|
for(i= 0; i < optc; i++)
|
|
|
|
eff_src_array[i]= eff_tgt_array[i]= NULL;
|
|
|
|
}
|
2016-12-05 13:35:04 +00:00
|
|
|
if((mode == 2 || mode == 4) &&
|
|
|
|
!((xorriso->ino_behavior & 2) || (flag & 16) ||
|
|
|
|
xorriso->di_array != NULL)) {
|
2010-05-15 18:48:10 +00:00
|
|
|
/* Create all-image node array sorted by isofs.di */
|
|
|
|
ret= Xorriso_make_di_array(xorriso, 0);
|
|
|
|
if(ret <= 0)
|
|
|
|
goto ex;
|
|
|
|
}
|
|
|
|
|
|
|
|
for(i= 0; i<optc; i++) {
|
|
|
|
ret= Xorriso_normalize_img_path(xorriso, s_wd, optv[i],
|
|
|
|
eff_source, ns_flag);
|
|
|
|
if(ret<=0)
|
|
|
|
goto ex;
|
2016-12-05 13:35:04 +00:00
|
|
|
ret= Xorriso__exchange_prefix(source_prefix, target_prefix,
|
|
|
|
eff_source, eff_target, 0);
|
|
|
|
if(ret == 0) {
|
|
|
|
sprintf(xorriso->info_text, "%s: disk_path ", cmd);
|
|
|
|
Text_shellsafe(eff_source, xorriso->info_text, 1);
|
|
|
|
strcat(xorriso->info_text, " does not begin with disk_prefix ");
|
|
|
|
Text_shellsafe(source_prefix, xorriso->info_text, 1);
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 1);
|
2010-05-15 18:48:10 +00:00
|
|
|
}
|
2016-12-05 13:35:04 +00:00
|
|
|
if(ret <= 0)
|
|
|
|
goto ex;
|
2010-05-15 18:48:10 +00:00
|
|
|
|
|
|
|
if(mode==0)
|
|
|
|
ret= Xorriso_option_map(xorriso, eff_source, eff_target, 2);
|
|
|
|
else if(mode==1)
|
|
|
|
ret= Xorriso_option_compare(xorriso, eff_source, eff_target, 2|8);
|
2016-12-05 13:35:04 +00:00
|
|
|
else if(mode == 2 || mode == 4)
|
2010-05-15 18:48:10 +00:00
|
|
|
ret= Xorriso_option_update(xorriso, eff_source, eff_target, 2 | 8 | 16);
|
|
|
|
else if(mode==3) {
|
|
|
|
if(eff_src_array != NULL) {
|
|
|
|
eff_src_array[i]= strdup(eff_source);
|
|
|
|
eff_tgt_array[i]= strdup(eff_target);
|
|
|
|
if(eff_src_array[i] == NULL || eff_tgt_array[i] == NULL) {
|
|
|
|
Xorriso_no_malloc_memory(xorriso, &(eff_src_array[i]), 0);
|
|
|
|
ret= -1; goto ex;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
ret= Xorriso_option_extract(xorriso, eff_source, eff_target, 2 | 4);
|
|
|
|
}
|
2016-12-14 09:18:14 +00:00
|
|
|
} else if(mode == 5) {
|
|
|
|
ret= Xorriso_option_update(xorriso, eff_target, eff_source, 2 | 8 | 16);
|
2010-05-15 18:48:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(ret>0 && !xorriso->request_to_abort)
|
|
|
|
continue; /* regular bottom of loop */
|
|
|
|
was_failure= 1;
|
2011-08-16 16:05:11 +00:00
|
|
|
fret= Xorriso_eval_problem_status(xorriso, ret, 1 | 2);
|
2010-05-15 18:48:10 +00:00
|
|
|
if(fret>=0)
|
|
|
|
continue;
|
|
|
|
goto ex;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret= 1;
|
|
|
|
if(mode == 3 && eff_src_array != NULL) {
|
|
|
|
ret= Xorriso_lst_append_binary(&(xorriso->node_disk_prefixes),
|
|
|
|
target_prefix, strlen(target_prefix) + 1, 0);
|
|
|
|
if(ret <= 0)
|
|
|
|
goto ex;
|
|
|
|
ret= Xorriso_lst_append_binary(&(xorriso->node_img_prefixes),
|
|
|
|
source_prefix, strlen(source_prefix) + 1, 0);
|
|
|
|
if(ret <= 0)
|
|
|
|
goto ex;
|
2010-11-30 10:47:30 +00:00
|
|
|
ret= Xorriso_restore_sorted(xorriso, optc, eff_src_array, eff_tgt_array,
|
|
|
|
&problem_count, 0);
|
|
|
|
if(ret <= 0 || problem_count > 0)
|
|
|
|
was_failure= 1;
|
2010-05-15 18:48:10 +00:00
|
|
|
}
|
|
|
|
if(mode==0)
|
|
|
|
Xorriso_pacifier_callback(xorriso, "files added", xorriso->pacifier_count,
|
|
|
|
xorriso->pacifier_total, "", 1);
|
2016-12-14 09:18:14 +00:00
|
|
|
else if(mode==1 || mode==2 || mode == 4 || mode == 5)
|
2010-05-15 18:48:10 +00:00
|
|
|
Xorriso_pacifier_callback(xorriso, "content bytes read",
|
2012-01-23 10:40:59 +00:00
|
|
|
xorriso->pacifier_count, 0, "", 1 | 8 | 32);
|
2010-05-15 18:48:10 +00:00
|
|
|
else if(mode==3)
|
|
|
|
Xorriso_pacifier_callback(xorriso, "files restored",xorriso->pacifier_count,
|
|
|
|
xorriso->pacifier_total, "", 1|4);
|
|
|
|
ex:;
|
|
|
|
Xorriso_destroy_node_array(xorriso, 0);
|
|
|
|
i= optc;
|
|
|
|
Sfile_destroy_argv(&i, &eff_src_array, 0);
|
|
|
|
i= optc;
|
|
|
|
Sfile_destroy_argv(&i, &eff_tgt_array, 0);
|
2011-05-05 16:38:12 +00:00
|
|
|
Xorriso_free_meM(source_prefix);
|
|
|
|
Xorriso_free_meM(target_prefix);
|
|
|
|
Xorriso_free_meM(eff_source);
|
|
|
|
Xorriso_free_meM(eff_target);
|
2010-05-15 18:48:10 +00:00
|
|
|
(*idx)= end_idx;
|
|
|
|
Xorriso_opt_args(xorriso, cmd, argc, argv, *idx, &end_idx, &optc, &optv, 256);
|
2016-12-05 13:35:04 +00:00
|
|
|
Xorriso_opt_args(xorriso, cmd, argc, argv, *idx, &end_idx, &opt2c, &opt2v,
|
|
|
|
256);
|
|
|
|
if(arg2c > 0)
|
|
|
|
Sfile_destroy_argv(&arg2c, &arg2v, 0);
|
|
|
|
else if(arg2v != NULL)
|
|
|
|
Xorriso_free_meM(arg2v);
|
|
|
|
|
2010-05-15 18:48:10 +00:00
|
|
|
if(ret<=0)
|
|
|
|
return(ret);
|
|
|
|
return(!was_failure);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Option -mark */
|
|
|
|
int Xorriso_option_mark(struct XorrisO *xorriso, char *mark, int flag)
|
|
|
|
{
|
|
|
|
if(mark[0]==0)
|
|
|
|
xorriso->mark_text[0]= 0;
|
|
|
|
else
|
|
|
|
strncpy(xorriso->mark_text,mark,sizeof(xorriso->mark_text)-1);
|
|
|
|
xorriso->mark_text[sizeof(xorriso->mark_text)-1]= 0;
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Option -md5 "on"|"all"|"off" */
|
|
|
|
int Xorriso_option_md5(struct XorrisO *xorriso, char *mode, int flag)
|
|
|
|
{
|
|
|
|
char *npt, *cpt;
|
|
|
|
int l;
|
|
|
|
|
|
|
|
npt= cpt= mode;
|
|
|
|
for(; npt!=NULL; cpt= npt+1) {
|
|
|
|
npt= strchr(cpt,':');
|
|
|
|
if(npt==NULL)
|
|
|
|
l= strlen(cpt);
|
|
|
|
else
|
|
|
|
l= npt-cpt;
|
|
|
|
if(l == 0)
|
|
|
|
continue;
|
|
|
|
if(l == 3 && strncmp(cpt, "off", l) == 0)
|
|
|
|
xorriso->do_md5&= ~31;
|
|
|
|
else if(l == 2 && strncmp(cpt, "on", l) == 0)
|
|
|
|
xorriso->do_md5= (xorriso->do_md5 & ~31) | 7 | 16;
|
|
|
|
else if(l == 3 && strncmp(cpt, "all", l) == 0)
|
|
|
|
xorriso->do_md5|= 31;
|
|
|
|
else if(l == 18 && strncmp(cpt, "stability_check_on", l) == 0)
|
|
|
|
xorriso->do_md5|= 8;
|
|
|
|
else if(l == 19 && strncmp(cpt, "stability_check_off", l) == 0)
|
|
|
|
xorriso->do_md5&= ~8;
|
2011-03-09 07:14:49 +00:00
|
|
|
else if(l == 13 && strncmp(cpt, "load_check_on", l) == 0)
|
|
|
|
xorriso->do_md5&= ~32;
|
|
|
|
else if(l == 14 && strncmp(cpt, "load_check_off", l) == 0)
|
|
|
|
xorriso->do_md5|= 32;
|
2010-05-15 18:48:10 +00:00
|
|
|
else {
|
|
|
|
sprintf(xorriso->info_text, "-md5: unknown mode ");
|
|
|
|
Text_shellsafe(cpt, xorriso->info_text, 1);
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Option -mkdir alias -mkdiri */
|
|
|
|
int Xorriso_option_mkdiri(struct XorrisO *xorriso, int argc, char **argv,
|
|
|
|
int *idx, int flag)
|
|
|
|
{
|
|
|
|
int i, end_idx, ret, was_failure= 0, fret;
|
|
|
|
|
|
|
|
end_idx= Xorriso_end_idx(xorriso, argc, argv, *idx, 0);
|
|
|
|
|
|
|
|
for(i= *idx; i<end_idx; i++) {
|
|
|
|
ret= Xorriso_mkdir(xorriso, argv[i], 0);
|
|
|
|
if(ret>0 && !xorriso->request_to_abort)
|
|
|
|
continue; /* regular bottom of loop */
|
|
|
|
was_failure= 1;
|
|
|
|
fret= Xorriso_eval_problem_status(xorriso, ret, 1|2);
|
|
|
|
if(fret>=0)
|
|
|
|
continue;
|
|
|
|
goto ex;
|
|
|
|
}
|
|
|
|
ret= 1;
|
|
|
|
ex:;
|
|
|
|
(*idx)= end_idx;
|
|
|
|
if(ret<=0)
|
|
|
|
return(ret);
|
|
|
|
return(!was_failure);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-07-31 16:23:08 +00:00
|
|
|
int Xorriso_option_modesty_on_drive(struct XorrisO *xorriso, char *mode,
|
|
|
|
int flag)
|
|
|
|
{
|
|
|
|
char *npt, *cpt, *ppt;
|
|
|
|
int l, num, set_min;
|
|
|
|
|
|
|
|
npt= cpt= mode;
|
|
|
|
for(; npt!=NULL; cpt= npt+1) {
|
|
|
|
npt= strchr(cpt,':');
|
|
|
|
if(npt==NULL)
|
|
|
|
l= strlen(cpt);
|
|