summaryrefslogtreecommitdiffstats
path: root/minadbd21/fuse_adb_provider.c
diff options
context:
space:
mode:
authorEthan Yonker <dees_troy@teamw.in>2017-05-10 23:11:35 +0200
committerEthan Yonker <dees_troy@teamw.in>2017-05-10 23:11:35 +0200
commit84d61ce31c48d0da495617f64edb724eeb36d3bc (patch)
tree443d459f7e0e3b0b7080522891dd1b92dfb2e6c7 /minadbd21/fuse_adb_provider.c
parentAdopted Storage: backup keys but do not wipe them (diff)
parentAdd a checker for signature boundary in verifier am: 54ea136fde am: 0a34b17c8b am: fb80b4f72d am: d3d5e54a45 am: 6ea9888d51 am: a055eb93c3 am: 15ca2a4763 am: ca50d7b66a am: 64f0de7a13 am: e4ec60e045 (diff)
downloadandroid_bootable_recovery-84d61ce31c48d0da495617f64edb724eeb36d3bc.tar
android_bootable_recovery-84d61ce31c48d0da495617f64edb724eeb36d3bc.tar.gz
android_bootable_recovery-84d61ce31c48d0da495617f64edb724eeb36d3bc.tar.bz2
android_bootable_recovery-84d61ce31c48d0da495617f64edb724eeb36d3bc.tar.lz
android_bootable_recovery-84d61ce31c48d0da495617f64edb724eeb36d3bc.tar.xz
android_bootable_recovery-84d61ce31c48d0da495617f64edb724eeb36d3bc.tar.zst
android_bootable_recovery-84d61ce31c48d0da495617f64edb724eeb36d3bc.zip
Diffstat (limited to 'minadbd21/fuse_adb_provider.c')
-rw-r--r--minadbd21/fuse_adb_provider.c67
1 files changed, 67 insertions, 0 deletions
diff --git a/minadbd21/fuse_adb_provider.c b/minadbd21/fuse_adb_provider.c
new file mode 100644
index 000000000..18e990682
--- /dev/null
+++ b/minadbd21/fuse_adb_provider.c
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+
+#include "adb.h"
+#include "fuse_sideload.h"
+
+struct adb_data {
+ int sfd; // file descriptor for the adb channel
+
+ uint64_t file_size;
+ uint32_t block_size;
+};
+
+static int read_block_adb(void* cookie, uint32_t block, uint8_t* buffer, uint32_t fetch_size) {
+ struct adb_data* ad = (struct adb_data*)cookie;
+
+ char buf[10];
+ snprintf(buf, sizeof(buf), "%08u", block);
+ if (writex(ad->sfd, buf, 8) < 0) {
+ fprintf(stderr, "failed to write to adb host: %s\n", strerror(errno));
+ return -EIO;
+ }
+
+ if (readx(ad->sfd, buffer, fetch_size) < 0) {
+ fprintf(stderr, "failed to read from adb host: %s\n", strerror(errno));
+ return -EIO;
+ }
+
+ return 0;
+}
+
+static void close_adb(void* cookie) {
+ struct adb_data* ad = (struct adb_data*)cookie;
+
+ writex(ad->sfd, "DONEDONE", 8);
+}
+
+int run_adb_fuse(int sfd, uint64_t file_size, uint32_t block_size) {
+ struct adb_data ad;
+ struct provider_vtab vtab;
+
+ ad.sfd = sfd;
+ ad.file_size = file_size;
+ ad.block_size = block_size;
+
+ vtab.read_block = read_block_adb;
+ vtab.close = close_adb;
+
+ return run_old_fuse_sideload(&vtab, &ad, file_size, block_size);
+}