aboutsummaryrefslogtreecommitdiffstats
path: root/testing/android-tools/musl-fixes.patch
blob: 4c093ce918472339b7990f4bc16d6a400e1ff830 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
This patch has been taken from the Void Linux distribution.

https://github.com/voidlinux/void-packages/tree/master/srcpkgs/android-tools/patches/android-tools-musl.patch

diff --git core/include/ziparchive/zip_archive.h core/include/ziparchive/zip_archive.h
index 7dc60ae..8886a35 100644
--- core/include/ziparchive/zip_archive.h
+++ core/include/ziparchive/zip_archive.h
@@ -22,11 +22,12 @@
 
 #include <stdint.h>
 #include <string.h>
-#include <sys/cdefs.h>
 #include <sys/types.h>
 #include <utils/Compat.h>
 
-__BEGIN_DECLS
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 /* Zip compression methods we support */
 enum {
@@ -215,6 +216,8 @@ int GetFileDescriptor(const ZipArchiveHandle handle);
 
 const char* ErrorCodeString(int32_t error_code);
 
-__END_DECLS
+#ifdef __cplusplus
+}
+#endif
 
 #endif  // LIBZIPARCHIVE_ZIPARCHIVE_H_
diff --git core/liblog/log_portability.h core/liblog/log_portability.h
index 3ad2060..2b859c4 100644
--- core/liblog/log_portability.h
+++ core/liblog/log_portability.h
@@ -17,7 +17,6 @@
 #ifndef _LIBLOG_PORTABILITY_H__
 #define _LIBLOG_PORTABILITY_H__
 
-#include <sys/cdefs.h>
 #include <unistd.h>
 
 /* Helpful private sys/cdefs.h like definitions */

diff --git core/include/private/android_filesystem_config.h core/include/private/android_filesystem_config.h
index c220a0c..d38f971 100644
--- core/include/private/android_filesystem_config.h
+++ core/include/private/android_filesystem_config.h
@@ -22,7 +22,6 @@
 #ifndef _ANDROID_FILESYSTEM_CONFIG_H_
 #define _ANDROID_FILESYSTEM_CONFIG_H_
 
-#include <sys/cdefs.h>
 #include <sys/types.h>
 #include <stdint.h>
 
@@ -230,7 +229,10 @@ struct fs_path_config {
 
 /* Rules for directories and files has moved to system/code/libcutils/fs_config.c */
 
-__BEGIN_DECLS
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 
 /*
  * Used in:
@@ -247,7 +249,9 @@ void fs_config(const char *path, int dir, const char *target_out_path,
 
 ssize_t fs_config_generate(char *buffer, size_t length, const struct fs_path_config *pc);
 
-__END_DECLS
+#ifdef __cplusplus
+}
+#endif
 
 #endif
 #endif
diff --git core/base/file.cpp core/base/file.cpp
index da1adba..7ba6d23 100644
--- core/base/file.cpp
+++ core/base/file.cpp
@@ -111,7 +111,7 @@ bool WriteStringToFile(const std::string& content, const std::string& path,
 
 bool WriteStringToFile(const std::string& content, const std::string& path) {
   int flags = O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC | O_NOFOLLOW | O_BINARY;
-  int fd = TEMP_FAILURE_RETRY(open(path.c_str(), flags, DEFFILEMODE));
+  int fd = TEMP_FAILURE_RETRY(open(path.c_str(), flags, (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)));
   if (fd == -1) {
     return false;
   }
diff --git core/adb/sysdeps.h core/adb/sysdeps.h
index 75dcc86..2dba172 100644
--- core/adb/sysdeps.h
+++ core/adb/sysdeps.h
@@ -757,18 +757,7 @@ static __inline__ int adb_thread_setname(const std::string& name) {
 #ifdef __APPLE__
     return pthread_setname_np(name.c_str());
 #else
-    const char *s = name.c_str();
-
-    // pthread_setname_np fails rather than truncating long strings.
-    const int max_task_comm_len = 16; // including the null terminator
-    if (name.length() > (max_task_comm_len - 1)) {
-        char buf[max_task_comm_len];
-        strncpy(buf, name.c_str(), sizeof(buf) - 1);
-        buf[sizeof(buf) - 1] = '\0';
-        s = buf;
-    }
-
-    return pthread_setname_np(pthread_self(), s) ;
+    return 0;
 #endif
 }
 
diff --git core/adb/diagnose_usb.cpp core/adb/diagnose_usb.cpp
index 0f067b0..1138f8d 100644
--- core/adb/diagnose_usb.cpp
+++ core/adb/diagnose_usb.cpp
@@ -32,28 +32,7 @@ static const char kPermissionsHelpUrl[] = "http://developer.android.com/tools/de
 // Returns a message describing any potential problems we find with udev, or nullptr if we can't
 // find plugdev information (i.e. udev is not installed).
 static const char* GetUdevProblem() {
-#if defined(__linux__)
-    errno = 0;
-    group* plugdev_group = getgrnam("plugdev");
-
-    if (plugdev_group == nullptr) {
-        if (errno != 0) {
-            perror("failed to read plugdev group info");
-        }
-        // We can't give any generally useful advice here, just let the caller print the help URL.
-        return nullptr;
-    }
-
-    // getgroups(2) indicates that the group_member() may not check the egid so we check it
-    // additionally just to be sure.
-    if (group_member(plugdev_group->gr_gid) || getegid() == plugdev_group->gr_gid) {
-        // The user is in plugdev so the problem is likely with the udev rules.
-        return "verify udev rules";
-    }
-    return "udev requires plugdev group membership";
-#else
     return nullptr;
-#endif
 }
 
 // Short help text must be a single line, and will look something like:
diff --git core/fastboot/socket.cpp core/fastboot/socket.cpp
index 14ecd93..aff905c 100644
--- core/fastboot/socket.cpp
+++ core/fastboot/socket.cpp
@@ -31,6 +31,8 @@
 #include <android-base/errors.h>
 #include <android-base/stringprintf.h>
 
+#include <sys/select.h>
+
 Socket::Socket(cutils_socket_t sock) : sock_(sock) {}
 
 Socket::~Socket() {