summaryrefslogtreecommitdiffstats
path: root/minadbd/services.c
diff options
context:
space:
mode:
Diffstat (limited to 'minadbd/services.c')
-rw-r--r--minadbd/services.c51
1 files changed, 18 insertions, 33 deletions
diff --git a/minadbd/services.c b/minadbd/services.c
index 752b33e82..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)(uintptr_t)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);
- exit(1);
- }
+ 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*)(uintptr_t)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);