adb: win32: fix ReportServerStartupFailure
The code was passing an fd from adb_open() to android::base::ReadFdToString() which actually
takes a C-Runtime fd (on Windows), so it wasn't working.
The fix is to use APIs that deal with C-Runtime fds:
* unix_open()
* android::base::unique_fd
* unix_lseek() (added in this change)
I also removed an unnecessary call to GetProcessId() since we already have the process id
from the structure returned by CreateProcess().
Test: adb start-server on Win10 and Ubuntu (with a failing server)
Test: mma
Change-Id: Id6e2dd5532a02fe5d9caf96aa007a1b3434a0b59
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
diff --git a/sysdeps.h b/sysdeps.h
index 0c2e45c..bc18994 100644
--- a/sysdeps.h
+++ b/sysdeps.h
@@ -129,6 +129,13 @@
#undef write
#define write ___xxx_write
+// See the comments for the !defined(_WIN32) version of unix_lseek().
+static __inline__ int unix_lseek(int fd, int pos, int where) {
+ return lseek(fd, pos, where);
+}
+#undef lseek
+#define lseek ___xxx_lseek
+
// See the comments for the !defined(_WIN32) version of adb_open_mode().
static __inline__ int adb_open_mode(const char* path, int options, int mode)
{
@@ -523,6 +530,7 @@
// via _setmode()).
#define unix_read adb_read
#define unix_write adb_write
+#define unix_lseek adb_lseek
#define unix_close adb_close
static __inline__ int adb_thread_setname(const std::string& name) {