aboutsummaryrefslogtreecommitdiffstats
path: root/adb/commandline.c
diff options
context:
space:
mode:
authorChristopher Tate <ctate@google.com>2011-05-17 15:52:54 -0700
committerChristopher Tate <ctate@google.com>2011-05-17 15:52:54 -0700
commit702967afb1bebc97c0b8a23c075d4932820ef7a3 (patch)
tree9e61f9bfb550eaaa9e33ea2d53464d39a625d282 /adb/commandline.c
parent70080d97cfcb3fe273207b1c739df587f5f93767 (diff)
downloadsystem_core-702967afb1bebc97c0b8a23c075d4932820ef7a3.tar.gz
system_core-702967afb1bebc97c0b8a23c075d4932820ef7a3.tar.bz2
system_core-702967afb1bebc97c0b8a23c075d4932820ef7a3.zip
Add 'adb restore' to parallel 'adb backup'
It won't actually do anything until the 'bu' tool and framework are updated to respond properly, but this is the adb side of the necessary infrastructure: we copy the tarfile into the socket pointed at the device, using the existing mechanisms. Change-Id: Ic3b5779ade256bd1ad989a94b0685f7b1a7d59d2
Diffstat (limited to 'adb/commandline.c')
-rw-r--r--adb/commandline.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/adb/commandline.c b/adb/commandline.c
index 733cbffe..460120e8 100644
--- a/adb/commandline.c
+++ b/adb/commandline.c
@@ -142,6 +142,8 @@ void help()
" the -all or -shared flags are passed, then the package\n"
" list is optional.)\n"
"\n"
+ " adb restore <file> - restore device contents from the <file> backup tarfile\n"
+ "\n"
" adb help - show this help message\n"
" adb version - show version num\n"
"\n"
@@ -601,6 +603,33 @@ static int backup(int argc, char** argv) {
return 0;
}
+static int restore(int argc, char** argv) {
+ const char* filename;
+ int fd, tarFd;
+
+ if (argc != 2) return usage();
+
+ filename = argv[1];
+ tarFd = adb_open(filename, O_RDONLY);
+ if (tarFd < 0) {
+ fprintf(stderr, "adb: unable to open file %s\n", filename);
+ return -1;
+ }
+
+ fd = adb_connect("restore:");
+ if (fd < 0) {
+ fprintf(stderr, "adb: unable to connect for backup\n");
+ adb_close(tarFd);
+ return -1;
+ }
+
+ copy_to_file(tarFd, fd);
+
+ adb_close(fd);
+ adb_close(tarFd);
+ return 0;
+}
+
#define SENTINEL_FILE "config" OS_PATH_SEPARATOR_STR "envsetup.make"
static int top_works(const char *top)
{
@@ -1164,6 +1193,10 @@ top:
return backup(argc, argv);
}
+ if (!strcmp(argv[0], "restore")) {
+ return restore(argc, argv);
+ }
+
if (!strcmp(argv[0], "jdwp")) {
int fd = adb_connect("jdwp");
if (fd >= 0) {