diff options
author | Ethan Yonker <dees_troy@teamw.in> | 2014-11-06 15:35:10 +0100 |
---|---|---|
committer | Ethan Yonker <dees_troy@teamw.in> | 2014-11-06 15:35:13 +0100 |
commit | a167416289a8aef5d4c35861c9f4181f87b8bfd0 (patch) | |
tree | cfb0b940141a4273ac6ddb58070e36ea706b7358 /minadbd/services.c | |
parent | 2.8.2.0 (diff) | |
parent | Use more aggressive sync writing to applypatch. (diff) | |
download | android_bootable_recovery-a167416289a8aef5d4c35861c9f4181f87b8bfd0.tar android_bootable_recovery-a167416289a8aef5d4c35861c9f4181f87b8bfd0.tar.gz android_bootable_recovery-a167416289a8aef5d4c35861c9f4181f87b8bfd0.tar.bz2 android_bootable_recovery-a167416289a8aef5d4c35861c9f4181f87b8bfd0.tar.lz android_bootable_recovery-a167416289a8aef5d4c35861c9f4181f87b8bfd0.tar.xz android_bootable_recovery-a167416289a8aef5d4c35861c9f4181f87b8bfd0.tar.zst android_bootable_recovery-a167416289a8aef5d4c35861c9f4181f87b8bfd0.zip |
Diffstat (limited to 'minadbd/services.c')
-rw-r--r-- | minadbd/services.c | 51 |
1 files changed, 18 insertions, 33 deletions
diff --git a/minadbd/services.c b/minadbd/services.c index aef37f7e4..218b84a38 100644 --- a/minadbd/services.c +++ b/minadbd/services.c @@ -22,6 +22,7 @@ #include "sysdeps.h" #include "fdevent.h" +#include "fuse_adb_provider.h" #define TRACE_TAG TRACE_SERVICES #include "adb.h" @@ -43,44 +44,23 @@ void *service_bootstrap_func(void *x) return 0; } -static void sideload_service(int s, void *cookie) +static void sideload_host_service(int sfd, void* cookie) { - unsigned char buf[4096]; - unsigned count = (unsigned) cookie; - int fd; - - fprintf(stderr, "sideload_service invoked\n"); - - fd = adb_creat(ADB_SIDELOAD_FILENAME, 0644); - if(fd < 0) { - fprintf(stderr, "failed to create %s\n", ADB_SIDELOAD_FILENAME); - adb_close(s); - return; - } + char* saveptr; + const char* s = strtok_r(cookie, ":", &saveptr); + uint64_t file_size = strtoull(s, NULL, 10); + s = strtok_r(NULL, ":", &saveptr); + uint32_t block_size = strtoul(s, NULL, 10); - while(count > 0) { - unsigned xfer = (count > 4096) ? 4096 : count; - if(readx(s, buf, xfer)) break; - if(writex(fd, buf, xfer)) break; - count -= xfer; - } + printf("sideload-host file size %llu block size %lu\n", file_size, block_size); - if(count == 0) { - writex(s, "OKAY", 4); - } else { - writex(s, "FAIL", 4); - } - adb_close(fd); - adb_close(s); + int result = run_adb_fuse(sfd, file_size, block_size); - if (count == 0) { - fprintf(stderr, "adbd exiting after successful sideload\n"); - sleep(1); - exit(0); - } + printf("sideload_host finished\n"); + sleep(1); + exit(result == 0 ? 0 : 1); } - #if 0 static void echo_service(int fd, void *cookie) { @@ -149,7 +129,12 @@ int service_to_fd(const char *name) int ret = -1; if (!strncmp(name, "sideload:", 9)) { - ret = create_service_thread(sideload_service, (void*) atoi(name + 9)); + // this exit status causes recovery to print a special error + // message saying to use a newer adb (that supports + // sideload-host). + exit(3); + } else if (!strncmp(name, "sideload-host:", 14)) { + ret = create_service_thread(sideload_host_service, (void*)(name + 14)); #if 0 } else if(!strncmp(name, "echo:", 5)){ ret = create_service_thread(echo_service, 0); |