From 28a557be5cd576c2a998f4e18c7df80b7c1f5af0 Mon Sep 17 00:00:00 2001 From: Gorgi Kosev Date: Sat, 9 Jun 2018 18:15:05 +0100 Subject: [PATCH] also read command stderr in some cases --- adbfs.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/adbfs.cpp b/adbfs.cpp index 11ab313..d710129 100644 --- a/adbfs.cpp +++ b/adbfs.cpp @@ -101,7 +101,7 @@ void shell_escape_command(string&); void adb_shell_escape_command(string&); queue adb_push(const string&, const string&); queue adb_pull(const string&, const string&); -queue adb_shell(const string&); +queue adb_shell(const string&, bool); queue shell(const string&); static const char PERMISSION_ERR_MSG[] = ": Permission denied"; @@ -144,13 +144,14 @@ queue shell(const string& command) @see exec_command. @todo perhaps avoid use of local shell to simplify escaping. */ -queue adb_shell(const string& command) +queue adb_shell(const string& command, bool getStderr = false) { string actual_command; actual_command.assign(command); //adb_shell_escape_command(actual_command); actual_command.insert(0, "adb shell \""); actual_command.append("\""); + if (getStderr) actual_command.append(" 2>&1"); return exec_command(actual_command); } @@ -385,7 +386,7 @@ static int adb_getattr(const char *path, struct stat *stbuf) string command = "ls -l -a -d '"; command.append(path_string); command.append("'"); - output = adb_shell(command); + output = adb_shell(command, true); if (output.empty()) return -EAGAIN; /* no phone */ // error format: "/sbin/healthd: Permission denied" if (