blob: 45417fb85ab82eb42e55b42cb6f931b6fb9c6009 [file] [log] [blame]
Koushik K. Duttaee57bbc2010-03-12 23:21:12 -08001#include <ctype.h>
2#include <errno.h>
3#include <fcntl.h>
4#include <getopt.h>
5#include <limits.h>
6#include <linux/input.h>
7#include <stdio.h>
8#include <stdlib.h>
9#include <string.h>
10#include <sys/reboot.h>
11#include <sys/types.h>
12#include <time.h>
13#include <unistd.h>
14
15#include <sys/wait.h>
16#include <sys/limits.h>
17#include <dirent.h>
18#include <sys/stat.h>
19
20#include <signal.h>
21#include <sys/wait.h>
22
23#include "bootloader.h"
24#include "common.h"
25#include "cutils/properties.h"
26#include "firmware.h"
27#include "install.h"
28#include "minui/minui.h"
29#include "minzip/DirUtil.h"
30#include "roots.h"
31#include "recovery_ui.h"
32
Koushik K. Duttaee57bbc2010-03-12 23:21:12 -080033#include "../../external/yaffs2/yaffs2/utils/mkyaffs2image.h"
34#include "../../external/yaffs2/yaffs2/utils/unyaffs.h"
35
Koushik K. Dutta78686292010-03-25 17:58:45 -070036#include <sys/vfs.h>
37
Koushik K. Duttaee57bbc2010-03-12 23:21:12 -080038#include "extendedcommands.h"
39#include "nandroid.h"
40
Koushik Duttadf1e4062010-12-18 17:42:31 -080041int print_and_error(const char* message) {
42 ui_print("%s", message);
Koushik K. Dutta4b249cd2010-03-15 16:31:03 -070043 return 1;
44}
45
Koushik K. Duttaee57bbc2010-03-12 23:21:12 -080046int yaffs_files_total = 0;
47int yaffs_files_count = 0;
48void yaffs_callback(char* filename)
49{
50 char* justfile = basename(filename);
51 if (strlen(justfile) < 30)
Koushik Duttadf1e4062010-12-18 17:42:31 -080052 ui_print("%s", justfile);
Koushik K. Duttaee57bbc2010-03-12 23:21:12 -080053 yaffs_files_count++;
54 if (yaffs_files_total != 0)
55 ui_set_progress((float)yaffs_files_count / (float)yaffs_files_total);
56 ui_reset_text_col();
57}
58
59void compute_directory_stats(char* directory)
60{
61 char tmp[PATH_MAX];
62 sprintf(tmp, "find %s | wc -l > /tmp/dircount", directory);
63 __system(tmp);
64 char count_text[100];
65 FILE* f = fopen("/tmp/dircount", "r");
66 fread(count_text, 1, sizeof(count_text), f);
67 fclose(f);
68 yaffs_files_count = 0;
69 yaffs_files_total = atoi(count_text);
70 ui_reset_progress();
71 ui_show_progress(1, 0);
72}
73
Koushik Duttadf1e4062010-12-18 17:42:31 -080074int nandroid_backup_partition_extended(const char* backup_path, const char* mount_point, int umount_when_finished) {
Koushik K. Dutta4b249cd2010-03-15 16:31:03 -070075 int ret = 0;
Koushik K. Dutta68b01902010-04-01 12:20:39 -070076 char* name = basename(mount_point);
Koushik Dutta58131e72010-06-09 12:41:20 -070077
78 struct stat file_info;
79 mkyaffs2image_callback callback = NULL;
80 if (0 != stat("/sdcard/clockworkmod/.hidenandroidprogress", &file_info)) {
81 callback = yaffs_callback;
82 }
Koushik K. Dutta4b249cd2010-03-15 16:31:03 -070083
84 ui_print("Backing up %s...\n", name);
Koushik Duttadf1e4062010-12-18 17:42:31 -080085 if (0 != (ret = ensure_path_mounted(mount_point) != 0)) {
Koushik K. Dutta4b249cd2010-03-15 16:31:03 -070086 ui_print("Can't mount %s!\n", mount_point);
87 return ret;
88 }
89 compute_directory_stats(mount_point);
90 char tmp[PATH_MAX];
91 sprintf(tmp, "%s/%s.img", backup_path, name);
Koushik Dutta58131e72010-06-09 12:41:20 -070092 ret = mkyaffs2image(mount_point, tmp, 0, callback);
Koushik Dutta062d6b02010-07-03 13:54:21 -070093 if (umount_when_finished) {
Koushik Duttadf1e4062010-12-18 17:42:31 -080094 ensure_path_unmounted(mount_point);
Koushik Dutta062d6b02010-07-03 13:54:21 -070095 }
Koushik K. Dutta4b249cd2010-03-15 16:31:03 -070096 if (0 != ret) {
97 ui_print("Error while making a yaffs2 image of %s!\n", mount_point);
98 return ret;
99 }
100 return 0;
101}
102
Koushik Dutta53c9bd82011-01-04 11:38:31 -0800103int nandroid_backup_partition(const char* backup_path, const char* root) {
104 Volume *vol = volume_for_path(root);
105 // make sure the volume exists before attempting anything...
106 if (vol == NULL || vol->fs_type == NULL)
107 return NULL;
108
109 // see if we need a raw backup (mtd)
110 char tmp[PATH_MAX];
111 int ret;
Christopher Lais066a1022011-01-16 06:02:34 -0600112 if (strcmp(vol->fs_type, "mtd") == 0 ||
113 strcmp(vol->fs_type, "emmc") == 0) {
Koushik Dutta53c9bd82011-01-04 11:38:31 -0800114 const char* name = basename(root);
115 sprintf(tmp, "%s/%s.img", backup_path, name);
116 ui_print("Backing up %s image...\n", name);
117 if (0 != (ret = backup_raw_partition(vol->device, tmp))) {
118 ui_print("Error while backing up %s image!", name);
119 return ret;
120 }
121 return 0;
122 }
123
Koushik Dutta062d6b02010-07-03 13:54:21 -0700124 return nandroid_backup_partition_extended(backup_path, root, 1);
125}
126
Koushik Dutta2f73e582010-04-18 16:00:21 -0700127int nandroid_backup(const char* backup_path)
Koushik K. Duttaee57bbc2010-03-12 23:21:12 -0800128{
129 ui_set_background(BACKGROUND_ICON_INSTALLING);
130
Koushik Duttadf1e4062010-12-18 17:42:31 -0800131 if (ensure_path_mounted("/sdcard") != 0)
Koushik K. Duttaee57bbc2010-03-12 23:21:12 -0800132 return print_and_error("Can't mount /sdcard\n");
133
Koushik K. Dutta78686292010-03-25 17:58:45 -0700134 int ret;
Koushik K. Duttaf3534d02010-04-18 18:06:24 -0700135 struct statfs s;
Koushik K. Dutta78686292010-03-25 17:58:45 -0700136 if (0 != (ret = statfs("/sdcard", &s)))
137 return print_and_error("Unable to stat /sdcard\n");
Koushik K. Dutta68b01902010-04-01 12:20:39 -0700138 uint64_t bavail = s.f_bavail;
139 uint64_t bsize = s.f_bsize;
140 uint64_t sdcard_free = bavail * bsize;
141 uint64_t sdcard_free_mb = sdcard_free / (uint64_t)(1024 * 1024);
142 ui_print("SD Card space free: %lluMB\n", sdcard_free_mb);
143 if (sdcard_free_mb < 150)
Koushik K. Duttac0970932010-03-25 23:19:19 -0700144 ui_print("There may not be enough free space to complete backup... continuing...\n");
Koushik K. Dutta78686292010-03-25 17:58:45 -0700145
Koushik K. Duttaee57bbc2010-03-12 23:21:12 -0800146 char tmp[PATH_MAX];
147 sprintf(tmp, "mkdir -p %s", backup_path);
148 __system(tmp);
149
Koushik Dutta53c9bd82011-01-04 11:38:31 -0800150 if (0 != (ret = nandroid_backup_partition(backup_path, "/boot")))
151 return ret;
Koushik K. Dutta6923cc32010-03-29 14:46:00 -0700152
Koushik Dutta53c9bd82011-01-04 11:38:31 -0800153 if (0 != (ret = nandroid_backup_partition(backup_path, "/recovery")))
154 return ret;
Koushik K. Dutta6923cc32010-03-29 14:46:00 -0700155
agrabren1f76a5d2010-12-29 12:15:18 -0600156 if (0 == (ret = get_partition_device("wimax", tmp)))
157 {
Joshua Wise05d4a092010-12-31 02:05:35 -0500158 char serialno[PROPERTY_VALUE_MAX];
Joshua Wiseca889ec2010-12-30 02:48:25 -0500159 ui_print("Backing up WiMAX...\n");
Joshua Wise05d4a092010-12-31 02:05:35 -0500160 serialno[0] = 0;
161 property_get("ro.serialno", serialno, "");
162 sprintf(tmp, "%s/wimax.%s.img", backup_path, serialno);
agrabren1f76a5d2010-12-29 12:15:18 -0600163 ret = backup_raw_partition("wimax", tmp);
164 if (0 != ret)
Joshua Wiseca889ec2010-12-30 02:48:25 -0500165 return print_and_error("Error while dumping WiMAX image!\n");
agrabren1f76a5d2010-12-29 12:15:18 -0600166 }
167
Koushik Duttadf1e4062010-12-18 17:42:31 -0800168 if (0 != (ret = nandroid_backup_partition(backup_path, "/system")))
Koushik K. Dutta4b249cd2010-03-15 16:31:03 -0700169 return ret;
170
Koushik Duttadf1e4062010-12-18 17:42:31 -0800171 if (0 != (ret = nandroid_backup_partition(backup_path, "/data")))
Koushik K. Dutta4b249cd2010-03-15 16:31:03 -0700172 return ret;
173
Koushik Dutta5460f0c2010-12-18 22:37:49 -0800174 if (has_datadata()) {
175 if (0 != (ret = nandroid_backup_partition(backup_path, "/datadata")))
176 return ret;
177 }
Koushik Dutta8b5e1852010-06-14 22:04:22 -0700178
Koushik Dutta062d6b02010-07-03 13:54:21 -0700179 struct stat st;
180 if (0 != stat("/sdcard/.android_secure", &st))
181 {
182 ui_print("No /sdcard/.android_secure found. Skipping backup of applications on external storage.\n");
183 }
184 else
185 {
Koushik Duttadf1e4062010-12-18 17:42:31 -0800186 if (0 != (ret = nandroid_backup_partition_extended(backup_path, "/sdcard/.android_secure", 0)))
Koushik Dutta062d6b02010-07-03 13:54:21 -0700187 return ret;
188 }
189
Koushik Duttadf1e4062010-12-18 17:42:31 -0800190 if (0 != (ret = nandroid_backup_partition_extended(backup_path, "/cache", 0)))
Koushik K. Dutta4b249cd2010-03-15 16:31:03 -0700191 return ret;
Koushik K. Dutta3f995392010-03-30 23:29:43 -0700192
Koushik Duttadf1e4062010-12-18 17:42:31 -0800193 Volume *vol = volume_for_path("/sd-ext");
194 if (vol == NULL || 0 != stat(vol->device, &st))
Koushik K. Dutta6771aca2010-04-03 23:28:39 -0700195 {
Koushik K. Dutta71ef11f2010-04-02 22:17:42 -0700196 ui_print("No sd-ext found. Skipping backup of sd-ext.\n");
Koushik K. Dutta6771aca2010-04-03 23:28:39 -0700197 }
198 else
199 {
Koushik Duttadf1e4062010-12-18 17:42:31 -0800200 if (0 != ensure_path_mounted("/sd-ext"))
Koushik Dutta8b5e1852010-06-14 22:04:22 -0700201 ui_print("Could not mount sd-ext. sd-ext backup may not be supported on this device. Skipping backup of sd-ext.\n");
Koushik Duttae06e5392011-01-16 02:33:04 -0800202 else if (0 != (ret = nandroid_backup_partition(backup_path, "/sd-ext")))
Koushik K. Dutta6771aca2010-04-03 23:28:39 -0700203 return ret;
204 }
Koushik Dutta062d6b02010-07-03 13:54:21 -0700205
Koushik K. Duttad7178922010-03-24 14:38:40 -0700206 ui_print("Generating md5 sum...\n");
Koushik K. Dutta68b01902010-04-01 12:20:39 -0700207 sprintf(tmp, "nandroid-md5.sh %s", backup_path);
Koushik K. Duttab0a25032010-03-24 10:34:38 -0700208 if (0 != (ret = __system(tmp))) {
209 ui_print("Error while generating md5 sum!\n");
210 return ret;
211 }
Koushik K. Duttaee57bbc2010-03-12 23:21:12 -0800212
Koushik K. Dutta3f38f322010-03-12 23:45:25 -0800213 sync();
Koushik K. Duttaee57bbc2010-03-12 23:21:12 -0800214 ui_set_background(BACKGROUND_ICON_NONE);
215 ui_reset_progress();
Koushik K. Dutta4b249cd2010-03-15 16:31:03 -0700216 ui_print("\nBackup complete!\n");
217 return 0;
218}
219
Koushik K. Dutta68b01902010-04-01 12:20:39 -0700220typedef int (*format_function)(char* root);
221
Koushik Dutta5aaa8232010-07-20 16:23:18 -0700222static void ensure_directory(const char* dir) {
223 char tmp[PATH_MAX];
224 sprintf(tmp, "mkdir -p %s", dir);
225 __system(tmp);
226}
227
Koushik Duttadf1e4062010-12-18 17:42:31 -0800228int nandroid_restore_partition_extended(const char* backup_path, const char* mount_point, int umount_when_finished) {
Koushik K. Dutta4b249cd2010-03-15 16:31:03 -0700229 int ret = 0;
Koushik K. Dutta68b01902010-04-01 12:20:39 -0700230 char* name = basename(mount_point);
Koushik K. Dutta4b249cd2010-03-15 16:31:03 -0700231
Koushik Dutta5aaa8232010-07-20 16:23:18 -0700232 char tmp[PATH_MAX];
233 sprintf(tmp, "%s/%s.img", backup_path, name);
Koushik Dutta58131e72010-06-09 12:41:20 -0700234 struct stat file_info;
Koushik Dutta5aaa8232010-07-20 16:23:18 -0700235 if (0 != (ret = statfs(tmp, &file_info))) {
Koushik Duttad4060c32010-07-22 20:14:44 -0700236 ui_print("%s.img not found. Skipping restore of %s.\n", name, mount_point);
Koushik Dutta5aaa8232010-07-20 16:23:18 -0700237 return 0;
238 }
239
240 ensure_directory(mount_point);
241
Koushik Dutta58131e72010-06-09 12:41:20 -0700242 unyaffs_callback callback = NULL;
243 if (0 != stat("/sdcard/clockworkmod/.hidenandroidprogress", &file_info)) {
244 callback = yaffs_callback;
245 }
246
Koushik K. Dutta4b249cd2010-03-15 16:31:03 -0700247 ui_print("Restoring %s...\n", name);
Koushik Dutta852bb422010-07-24 11:18:00 -0700248 /*
Koushik K. Dutta4b249cd2010-03-15 16:31:03 -0700249 if (0 != (ret = ensure_root_path_unmounted(root))) {
250 ui_print("Can't unmount %s!\n", mount_point);
251 return ret;
252 }
Koushik Dutta852bb422010-07-24 11:18:00 -0700253 */
Koushik Duttabf4444f2010-12-18 18:57:47 -0800254 if (0 != (ret = format_volume(mount_point))) {
Koushik Duttadf1e4062010-12-18 17:42:31 -0800255 ui_print("Error while formatting %s!\n", mount_point);
Koushik K. Dutta4b249cd2010-03-15 16:31:03 -0700256 return ret;
257 }
258
Koushik Duttadf1e4062010-12-18 17:42:31 -0800259 if (0 != (ret = ensure_path_mounted(mount_point))) {
Koushik K. Dutta4b249cd2010-03-15 16:31:03 -0700260 ui_print("Can't mount %s!\n", mount_point);
261 return ret;
262 }
263
Koushik Dutta58131e72010-06-09 12:41:20 -0700264 if (0 != (ret = unyaffs(tmp, mount_point, callback))) {
Koushik K. Dutta4b249cd2010-03-15 16:31:03 -0700265 ui_print("Error while restoring %s!\n", mount_point);
266 return ret;
267 }
Koushik Dutta2f73e582010-04-18 16:00:21 -0700268
Koushik Dutta062d6b02010-07-03 13:54:21 -0700269 if (umount_when_finished) {
Koushik Duttadf1e4062010-12-18 17:42:31 -0800270 ensure_path_unmounted(mount_point);
Koushik Dutta2f73e582010-04-18 16:00:21 -0700271 }
Koushik Dutta062d6b02010-07-03 13:54:21 -0700272
Koushik K. Duttaee57bbc2010-03-12 23:21:12 -0800273 return 0;
274}
275
Koushik Dutta062d6b02010-07-03 13:54:21 -0700276int nandroid_restore_partition(const char* backup_path, const char* root) {
Koushik Dutta53c9bd82011-01-04 11:38:31 -0800277 Volume *vol = volume_for_path(root);
278 // make sure the volume exists...
279 if (vol == NULL || vol->fs_type == NULL)
280 return 0;
281
282 // see if we need a raw restore (mtd)
283 char tmp[PATH_MAX];
Christopher Lais066a1022011-01-16 06:02:34 -0600284 if (strcmp(vol->fs_type, "mtd") == 0 ||
285 strcmp(vol->fs_type, "emmc") == 0) {
Koushik Dutta53c9bd82011-01-04 11:38:31 -0800286 int ret;
287 const char* name = basename(root);
288 ui_print("Erasing %s before restore...\n", name);
289 if (0 != (ret = format_volume(root))) {
290 ui_print("Error while erasing %s image!", name);
291 return ret;
292 }
293 sprintf(tmp, "%s%s.img", backup_path, root);
294 ui_print("Restoring %s image...\n", name);
295 if (0 != (ret = restore_raw_partition(vol->device, tmp))) {
296 ui_print("Error while flashing %s image!", name);
297 return ret;
298 }
299 return 0;
300 }
Koushik Dutta062d6b02010-07-03 13:54:21 -0700301 return nandroid_restore_partition_extended(backup_path, root, 1);
302}
303
agrabren1f76a5d2010-12-29 12:15:18 -0600304int nandroid_restore(const char* backup_path, int restore_boot, int restore_system, int restore_data, int restore_cache, int restore_sdext, int restore_wimax)
Koushik K. Duttaee57bbc2010-03-12 23:21:12 -0800305{
306 ui_set_background(BACKGROUND_ICON_INSTALLING);
307 ui_show_indeterminate_progress();
308 yaffs_files_total = 0;
309
Koushik Duttadf1e4062010-12-18 17:42:31 -0800310 if (ensure_path_mounted("/sdcard") != 0)
Koushik K. Duttaee57bbc2010-03-12 23:21:12 -0800311 return print_and_error("Can't mount /sdcard\n");
312
313 char tmp[PATH_MAX];
314
315 ui_print("Checking MD5 sums...\n");
Koushik K. Duttaface5882010-03-13 10:15:55 -0800316 sprintf(tmp, "cd %s && md5sum -c nandroid.md5", backup_path);
Koushik K. Duttaee57bbc2010-03-12 23:21:12 -0800317 if (0 != __system(tmp))
318 return print_and_error("MD5 mismatch!\n");
319
Koushik K. Dutta4b249cd2010-03-15 16:31:03 -0700320 int ret;
Koushik Dutta53c9bd82011-01-04 11:38:31 -0800321
322 if (restore_boot && NULL != volume_for_path("/boot") && 0 != (ret = nandroid_restore_partition(backup_path, "/boot")))
323 return ret;
Koushik K. Duttaf7215942010-03-16 13:34:51 -0700324
agrabren1f76a5d2010-12-29 12:15:18 -0600325 if (restore_wimax && 0 == (ret = get_partition_device("wimax", tmp)))
326 {
Joshua Wise05d4a092010-12-31 02:05:35 -0500327 char serialno[PROPERTY_VALUE_MAX];
328
329 serialno[0] = 0;
330 property_get("ro.serialno", serialno, "");
331 sprintf(tmp, "%s/wimax.%s.img", backup_path, serialno);
agrabren1f76a5d2010-12-29 12:15:18 -0600332
333 struct stat st;
334 if (0 != stat(tmp, &st))
335 {
Joshua Wiseca889ec2010-12-30 02:48:25 -0500336 ui_print("WARNING: WiMAX partition exists, but nandroid\n");
337 ui_print(" backup does not contain WiMAX image.\n");
agrabren1f76a5d2010-12-29 12:15:18 -0600338 ui_print(" You should create a new backup to\n");
Joshua Wiseca889ec2010-12-30 02:48:25 -0500339 ui_print(" protect your WiMAX keys.\n");
agrabren1f76a5d2010-12-29 12:15:18 -0600340 }
341 else
342 {
Joshua Wise5a3f1d82010-12-31 02:16:00 -0500343 ui_print("Erasing WiMAX before restore...\n");
Koushik Duttaa25deae2011-01-01 18:17:48 -0800344 if (0 != (ret = format_volume("/wimax")))
Joshua Wise5a3f1d82010-12-31 02:16:00 -0500345 return print_and_error("Error while formatting wimax!\n");
Joshua Wise05d4a092010-12-31 02:05:35 -0500346 ui_print("Restoring WiMAX image...\n");
agrabren1f76a5d2010-12-29 12:15:18 -0600347 if (0 != (ret = restore_raw_partition("wimax", tmp)))
348 return ret;
349 }
350 }
351
Koushik Duttadf1e4062010-12-18 17:42:31 -0800352 if (restore_system && 0 != (ret = nandroid_restore_partition(backup_path, "/system")))
Koushik K. Dutta4b249cd2010-03-15 16:31:03 -0700353 return ret;
Koushik K. Duttaee57bbc2010-03-12 23:21:12 -0800354
Koushik Duttadf1e4062010-12-18 17:42:31 -0800355 if (restore_data && 0 != (ret = nandroid_restore_partition(backup_path, "/data")))
Koushik K. Dutta4b249cd2010-03-15 16:31:03 -0700356 return ret;
Koushik Dutta8b5e1852010-06-14 22:04:22 -0700357
Koushik Dutta5460f0c2010-12-18 22:37:49 -0800358 if (has_datadata()) {
359 if (restore_data && 0 != (ret = nandroid_restore_partition(backup_path, "/datadata")))
360 return ret;
361 }
Koushik K. Duttaee57bbc2010-03-12 23:21:12 -0800362
Koushik Duttadf1e4062010-12-18 17:42:31 -0800363 if (restore_data && 0 != (ret = nandroid_restore_partition_extended(backup_path, "/sdcard/.android_secure", 0)))
Koushik Dutta5aaa8232010-07-20 16:23:18 -0700364 return ret;
Koushik Dutta062d6b02010-07-03 13:54:21 -0700365
Koushik Duttadf1e4062010-12-18 17:42:31 -0800366 if (restore_cache && 0 != (ret = nandroid_restore_partition_extended(backup_path, "/cache", 0)))
Koushik K. Dutta4b249cd2010-03-15 16:31:03 -0700367 return ret;
368
Koushik Duttadf1e4062010-12-18 17:42:31 -0800369 if (restore_sdext && 0 != (ret = nandroid_restore_partition(backup_path, "/sd-ext")))
Koushik Dutta5aaa8232010-07-20 16:23:18 -0700370 return ret;
Koushik K. Dutta68b01902010-04-01 12:20:39 -0700371
Koushik K. Dutta3f38f322010-03-12 23:45:25 -0800372 sync();
Koushik K. Duttaee57bbc2010-03-12 23:21:12 -0800373 ui_set_background(BACKGROUND_ICON_NONE);
374 ui_reset_progress();
Koushik K. Dutta4b249cd2010-03-15 16:31:03 -0700375 ui_print("\nRestore complete!\n");
Koushik K. Duttaee57bbc2010-03-12 23:21:12 -0800376 return 0;
377}
Koushik Dutta08370912010-06-26 12:25:02 -0700378
379void nandroid_generate_timestamp_path(char* backup_path)
380{
381 time_t t = time(NULL);
382 struct tm *tmp = localtime(&t);
383 if (tmp == NULL)
384 {
385 struct timeval tp;
386 gettimeofday(&tp, NULL);
387 sprintf(backup_path, "/sdcard/clockworkmod/backup/%d", tp.tv_sec);
388 }
389 else
390 {
391 strftime(backup_path, PATH_MAX, "/sdcard/clockworkmod/backup/%F.%H.%M.%S", tmp);
392 }
393}
394
395int nandroid_usage()
396{
397 printf("Usage: nandroid backup\n");
398 printf("Usage: nandroid restore <directory>\n");
399 return 1;
400}
401
402int nandroid_main(int argc, char** argv)
403{
404 if (argc > 3 || argc < 2)
405 return nandroid_usage();
406
407 if (strcmp("backup", argv[1]) == 0)
408 {
409 if (argc != 2)
410 return nandroid_usage();
411
412 char backup_path[PATH_MAX];
413 nandroid_generate_timestamp_path(backup_path);
414 return nandroid_backup(backup_path);
415 }
416
417 if (strcmp("restore", argv[1]) == 0)
418 {
419 if (argc != 3)
420 return nandroid_usage();
Koushik Dutta5b7f34a2010-12-29 23:36:03 -0800421 return nandroid_restore(argv[2], 1, 1, 1, 1, 1, 0);
Koushik Dutta08370912010-06-26 12:25:02 -0700422 }
423
424 return nandroid_usage();
425}