23
23
24
24
#define INFILE "/dev/block/mmcblk0p17"
25
25
#define OUTFILE "/dev/block/mmcblk0p17"
26
- #define BACKUPFILE "/sdcard/part17backup-%lu.bin "
26
+ #define PATH_FOR_BACKUP "/sdcard"
27
27
28
28
//#define INFILE "/opt/install/g2/my_dump/p17/mmcblk0p17.img"
29
29
//#define OUTFILE "/opt/install/g2/my_dump/p17/mmcblk0p17-new.img"
30
30
//#define BACKUPFILE "/opt/install/g2/my_dump/p17/part17backup-%lu.bin"
31
31
32
32
#define VERSION_A 0
33
- #define VERSION_B 4
33
+ #define VERSION_B 5
34
34
35
35
int main (int argc , const char * * argv ) {
36
36
@@ -39,6 +39,7 @@ int main(int argc, const char **argv) {
39
39
const char * s_cid ;
40
40
const char * s_ruu_flag ;
41
41
const char s_ruu_string [15 ] = "SetRuuNbhUpdate" ;
42
+ const char * s_backupPath ;
42
43
43
44
if (argc > 1 ) {
44
45
@@ -47,6 +48,7 @@ int main(int argc, const char **argv) {
47
48
gopt_option ( 'v' , 0 , gopt_shorts ( 'v' ), gopt_longs ( "version" )),
48
49
gopt_option ( 'c' , GOPT_ARG , gopt_shorts ('c' ), gopt_longs ("cid" )),
49
50
gopt_option ( 'r' , GOPT_ARG , gopt_shorts ( 'r' ), gopt_longs ( "setRUUflag" )),
51
+ gopt_option ( 'p' , GOPT_ARG , gopt_shorts ( 'p' ), gopt_longs ("path" )),
50
52
gopt_option ( 's' , GOPT_ARG , gopt_shorts ( 's' ), gopt_longs ( "set_version" ))));
51
53
52
54
if ( gopt ( options , 'h' ) ){
@@ -102,6 +104,12 @@ int main(int argc, const char **argv) {
102
104
}
103
105
}
104
106
107
+ if (gopt_arg (options , 'p' , & s_backupPath ))
108
+ {
109
+ // if -p or --path was specified, set backup path
110
+ printf ("--path set. backups will be stored in: %s instead of %s \n" , s_backupPath , PATH_FOR_BACKUP );
111
+ }
112
+
105
113
} else {
106
114
help = 1 ;
107
115
}
@@ -114,16 +122,20 @@ int main(int argc, const char **argv) {
114
122
fprintf ( stdout , "\t-v | --version: display program version\n" );
115
123
fprintf ( stdout , "\t-c | --cid <CID>: set the CID in misc to the 8-char long CID\n" );
116
124
fprintf ( stdout , "\t-s | --set_version <VERSION>: set the version in misc to the 10-char long VERSION\n" );
125
+ fprintf ( stdout , "\t-p | --path: <backup path>: create backup files in directory <backup path>\n" );
117
126
fprintf ( stdout , "\t-r | --setRUUflag <on|off>. Set of clear the RUU flag\n" );
118
127
exit (0 );
119
128
}
120
129
130
+ if (s_backupPath == NULL )
131
+ s_backupPath = PATH_FOR_BACKUP ;
132
+
121
133
char * backupFile ;
122
134
time_t ourTime ;
123
135
124
136
ourTime = time (0 );
125
- backupFile = malloc (snprintf (0 , 0 , BACKUPFILE , ourTime ) + 1 );
126
- sprintf (backupFile , BACKUPFILE , ourTime );
137
+ backupFile = malloc (snprintf (0 , 0 , "%s/part17backup-%lu.bin" , s_backupPath , ourTime ) + 1 );
138
+ sprintf (backupFile , "%s/part17backup-%lu.bin" , s_backupPath , ourTime );
127
139
128
140
FILE * fdin , * fdout ;
129
141
char ch ;
0 commit comments