summaryrefslogtreecommitdiffstats
path: root/mtp/twrpMtp.cpp
diff options
context:
space:
mode:
authorEthan Yonker <dees_troy@teamw.in>2014-12-17 03:01:38 +0100
committerEthan Yonker <dees_troy@teamw.in>2014-12-19 23:27:34 +0100
commit726a0206326ca4cf22aa7c59e174a83a0da9727f (patch)
tree5f0275dfed9c51b255e73feaeba609cd7a762da1 /mtp/twrpMtp.cpp
parentRecovery init.rc setenforce 0 to make SELinux permissive (diff)
downloadandroid_bootable_recovery-726a0206326ca4cf22aa7c59e174a83a0da9727f.tar
android_bootable_recovery-726a0206326ca4cf22aa7c59e174a83a0da9727f.tar.gz
android_bootable_recovery-726a0206326ca4cf22aa7c59e174a83a0da9727f.tar.bz2
android_bootable_recovery-726a0206326ca4cf22aa7c59e174a83a0da9727f.tar.lz
android_bootable_recovery-726a0206326ca4cf22aa7c59e174a83a0da9727f.tar.xz
android_bootable_recovery-726a0206326ca4cf22aa7c59e174a83a0da9727f.tar.zst
android_bootable_recovery-726a0206326ca4cf22aa7c59e174a83a0da9727f.zip
Diffstat (limited to 'mtp/twrpMtp.cpp')
-rwxr-xr-xmtp/twrpMtp.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/mtp/twrpMtp.cpp b/mtp/twrpMtp.cpp
index d9db4246e..d47b8fa0d 100755
--- a/mtp/twrpMtp.cpp
+++ b/mtp/twrpMtp.cpp
@@ -72,12 +72,14 @@ twrpMtp::twrpMtp(int debug_enabled = 0) {
if (debug_enabled)
MtpDebug::enableDebug();
mtpstorages = new storages;
+ mtp_read_pipe = -1;
}
int twrpMtp::start(void) {
MTPI("Starting MTP\n");
twmtp_MtpServer *mtp = new twmtp_MtpServer();
mtp->set_storages(mtpstorages);
+ mtp->set_read_pipe(mtp_read_pipe);
mtp->start();
return 0;
}
@@ -90,7 +92,7 @@ pthread_t twrpMtp::threadserver(void) {
return thread;
}
-pid_t twrpMtp::forkserver(void) {
+pid_t twrpMtp::forkserver(int mtppipe[2]) {
pid_t pid;
if ((pid = fork()) == -1) {
MTPE("MTP fork failed.\n");
@@ -98,8 +100,11 @@ pid_t twrpMtp::forkserver(void) {
}
if (pid == 0) {
// Child process
+ close(mtppipe[1]); // Child closes write side
+ mtp_read_pipe = mtppipe[0];
start();
MTPD("MTP child process exited.\n");
+ close(mtppipe[0]);
_exit(0);
} else {
return pid;