diff options
Diffstat (limited to 'meta-oe/recipes-devtools/android-tools/android-tools')
31 files changed, 1825 insertions, 283 deletions
diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/android-tools-adbd.service b/meta-oe/recipes-devtools/android-tools/android-tools/android-tools-adbd.service index 88ed6871d3..ddf8d7f74e 100644 --- a/meta-oe/recipes-devtools/android-tools/android-tools/android-tools-adbd.service +++ b/meta-oe/recipes-devtools/android-tools/android-tools/android-tools-adbd.service @@ -1,12 +1,13 @@ [Unit] Description=Android Debug Bridge +ConditionPathExists=/var/usb-debugging-enabled +Before=android-system.service [Service] Type=simple Restart=on-failure -ExecStartPre=/usr/bin/android-gadget-setup adb +ExecStartPre=-/usr/bin/android-gadget-setup adb ExecStart=/usr/bin/adbd -StandardOutput=null [Install] WantedBy=basic.target diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/build/0001-Riscv-Add-risc-v-Android-config-header.patch b/meta-oe/recipes-devtools/android-tools/android-tools/build/0001-Riscv-Add-risc-v-Android-config-header.patch new file mode 100644 index 0000000000..c091fd404b --- /dev/null +++ b/meta-oe/recipes-devtools/android-tools/android-tools/build/0001-Riscv-Add-risc-v-Android-config-header.patch @@ -0,0 +1,361 @@ +From 82dce13ea7b5b31c63851bd67f66072413917e73 Mon Sep 17 00:00:00 2001 +From: Chenxi Mao <maochenxi@eswin.com> +Date: Mon, 20 Apr 2020 15:32:40 +0800 +Subject: [PATCH 1/1] Riscv: Add risc-v Android config header + +--- +Upstream-Status: Pending + + .../arch/linux-riscv64/AndroidConfig.h | 340 ++++++++++++++++++ + 1 file changed, 340 insertions(+) + create mode 100644 core/combo/include/arch/linux-riscv64/AndroidConfig.h + +diff --git a/core/combo/include/arch/linux-riscv64/AndroidConfig.h b/core/combo/include/arch/linux-riscv64/AndroidConfig.h +new file mode 100644 +index 0000000000..bcbda8f87f +--- /dev/null ++++ b/core/combo/include/arch/linux-riscv64/AndroidConfig.h +@@ -0,0 +1,340 @@ ++/* ++ * Copyright (C) 2013 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. ++ */ ++ ++/* ++ * Android config -- "android-aarch64". Used for ARM aarch64 device builds. ++ */ ++#ifndef _ANDROID_CONFIG_H ++#define _ANDROID_CONFIG_H ++ ++/* ++ * =========================================================================== ++ * !!! IMPORTANT !!! ++ * =========================================================================== ++ * ++ * This file is included by ALL C/C++ source files. Don't put anything in ++ * here unless you are absolutely certain it can't go anywhere else. ++ * ++ * Any C++ stuff must be wrapped with "#ifdef __cplusplus". Do not use "//" ++ * comments. ++ */ ++ ++/* ++ * Threading model. Choose one: ++ * ++ * HAVE_PTHREADS - use the pthreads library. ++ * HAVE_WIN32_THREADS - use Win32 thread primitives. ++ * -- combine HAVE_CREATETHREAD, HAVE_CREATEMUTEX, and HAVE__BEGINTHREADEX ++ */ ++#define HAVE_PTHREADS ++ ++/* ++ * Do we have pthread_setname_np()? ++ * ++ * (HAVE_PTHREAD_SETNAME_NP is used by WebKit to enable a function with ++ * the same name but different parameters, so we can't use that here.) ++ */ ++#define HAVE_ANDROID_PTHREAD_SETNAME_NP ++ ++/* ++ * Do we have the futex syscall? ++ */ ++#define HAVE_FUTEX ++ ++/* ++ * Process creation model. Choose one: ++ * ++ * HAVE_FORKEXEC - use fork() and exec() ++ * HAVE_WIN32_PROC - use CreateProcess() ++ */ ++#define HAVE_FORKEXEC ++ ++/* ++ * Process out-of-memory adjustment. Set if running on Linux, ++ * where we can write to /proc/<pid>/oom_adj to modify the out-of-memory ++ * badness adjustment. ++ */ ++#define HAVE_OOM_ADJ ++ ++/* ++ * IPC model. Choose one: ++ * ++ * HAVE_SYSV_IPC - use the classic SysV IPC mechanisms (semget, shmget). ++ * HAVE_MACOSX_IPC - use Macintosh IPC mechanisms (sem_open, mmap). ++ * HAVE_WIN32_IPC - use Win32 IPC (CreateSemaphore, CreateFileMapping). ++ * HAVE_ANDROID_IPC - use Android versions (?, mmap). ++ */ ++#define HAVE_ANDROID_IPC ++ ++/* ++ * Memory-mapping model. Choose one: ++ * ++ * HAVE_POSIX_FILEMAP - use the Posix sys/mmap.h ++ * HAVE_WIN32_FILEMAP - use Win32 filemaps ++ */ ++#define HAVE_POSIX_FILEMAP ++ ++/* ++ * Define this if you have <termio.h> ++ */ ++#define HAVE_TERMIO_H 1 ++ ++/* ++ * Define this if you have <sys/sendfile.h> ++ */ ++#define HAVE_SYS_SENDFILE_H 1 ++ ++/* ++ * Define this if you build against MSVCRT.DLL ++ */ ++/* #define HAVE_MS_C_RUNTIME */ ++ ++/* ++ * Define this if you have sys/uio.h ++ */ ++#define HAVE_SYS_UIO_H 1 ++ ++/* ++ * Define this if your platforms implements symbolic links ++ * in its filesystems ++ */ ++#define HAVE_SYMLINKS ++ ++/* ++ * Define this if we have localtime_r(). ++ */ ++/* #define HAVE_LOCALTIME_R 1 */ ++ ++/* ++ * Define this if we have gethostbyname_r(). ++ */ ++/* #define HAVE_GETHOSTBYNAME_R */ ++ ++/* ++ * Define this if we have ioctl(). ++ */ ++#define HAVE_IOCTL ++ ++/* ++ * Define this if we want to use WinSock. ++ */ ++/* #define HAVE_WINSOCK */ ++ ++/* ++ * Define this if have clock_gettime() and friends ++ */ ++#define HAVE_POSIX_CLOCKS ++ ++/* ++ * Define this if we have linux style epoll() ++ */ ++#define HAVE_EPOLL ++ ++/* ++ * Endianness of the target machine. Choose one: ++ * ++ * HAVE_ENDIAN_H -- have endian.h header we can include. ++ * HAVE_LITTLE_ENDIAN -- we are little endian. ++ * HAVE_BIG_ENDIAN -- we are big endian. ++ */ ++#define HAVE_ENDIAN_H ++#define HAVE_LITTLE_ENDIAN ++ ++#define _FILE_OFFSET_BITS 64 ++/* #define _LARGEFILE_SOURCE 1 */ ++ ++/* ++ * Define if platform has off64_t (and lseek64 and other xxx64 functions) ++ */ ++#define HAVE_OFF64_T ++ ++/* ++ * Defined if we have the backtrace() call for retrieving a stack trace. ++ * Needed for CallStack to operate; if not defined, CallStack is ++ * non-functional. ++ */ ++#define HAVE_BACKTRACE 0 ++ ++/* ++ * Defined if we have the cxxabi.h header for demangling C++ symbols. If ++ * not defined, stack crawls will be displayed with raw mangled symbols ++ */ ++#define HAVE_CXXABI 0 ++ ++/* ++ * Defined if we have the gettid() system call. ++ */ ++#define HAVE_GETTID ++ ++/* ++ * Defined if we have the sched_setscheduler() call ++ */ ++#define HAVE_SCHED_SETSCHEDULER ++ ++/* ++ * Add any extra platform-specific defines here. ++ */ ++#ifndef __linux__ ++#define __linux__ ++#endif ++ ++/* ++ * Define if we have <malloc.h> header ++ */ ++#define HAVE_MALLOC_H ++ ++/* ++ * Define if we're running on *our* linux on device or emulator. ++ */ ++#define HAVE_ANDROID_OS 1 ++ ++/* ++ * Define if we have Linux-style non-filesystem Unix Domain Sockets ++ */ ++#define HAVE_LINUX_LOCAL_SOCKET_NAMESPACE 1 ++ ++/* ++ * Define if we have Linux's inotify in <sys/inotify.h>. ++ */ ++#define HAVE_INOTIFY 1 ++ ++/* ++ * Define if we have madvise() in <sys/mman.h> ++ */ ++#define HAVE_MADVISE 1 ++ ++/* ++ * Define if tm struct has tm_gmtoff field ++ */ ++#define HAVE_TM_GMTOFF 1 ++ ++/* ++ * Define if dirent struct has d_type field ++ */ ++#define HAVE_DIRENT_D_TYPE 1 ++ ++/* ++ * Define if libc includes Android system properties implementation. ++ */ ++#define HAVE_LIBC_SYSTEM_PROPERTIES 1 ++ ++/* ++ * Define if system provides a system property server (should be ++ * mutually exclusive with HAVE_LIBC_SYSTEM_PROPERTIES). ++ */ ++/* #define HAVE_SYSTEM_PROPERTY_SERVER */ ++ ++/* ++ * What CPU architecture does this platform use? ++ */ ++#define ARCH_AARCH64 ++ ++/* ++ * Define if the size of enums is as short as possible, ++ */ ++/* #define HAVE_SHORT_ENUMS */ ++ ++/* ++ * sprintf() format string for shared library naming. ++ */ ++#define OS_SHARED_LIB_FORMAT_STR "lib%s.so" ++ ++/* ++ * type for the third argument to mincore(). ++ */ ++#define MINCORE_POINTER_TYPE unsigned char * ++ ++/* ++ * The default path separator for the platform ++ */ ++#define OS_PATH_SEPARATOR '/' ++ ++/* ++ * Is the filesystem case sensitive? ++ */ ++#define OS_CASE_SENSITIVE ++ ++/* ++ * Define if <sys/socket.h> exists. ++ */ ++#define HAVE_SYS_SOCKET_H 1 ++ ++/* ++ * Define if the strlcpy() function exists on the system. ++ */ ++#define HAVE_STRLCPY 1 ++ ++/* ++ * Define if the open_memstream() function exists on the system. ++ */ ++/* #define HAVE_OPEN_MEMSTREAM 1 */ ++ ++/* ++ * Define if the BSD funopen() function exists on the system. ++ */ ++#define HAVE_FUNOPEN 1 ++ ++/* ++ * Define if prctl() exists ++ */ ++#define HAVE_PRCTL 1 ++ ++/* ++ * Define if writev() exists ++ */ ++#define HAVE_WRITEV 1 ++ ++/* ++ * Define if <stdint.h> exists. ++ */ ++#define HAVE_STDINT_H 1 ++ ++/* ++ * Define if <stdbool.h> exists. ++ */ ++#define HAVE_STDBOOL_H 1 ++ ++/* ++ * Define if <sched.h> exists. ++ */ ++#define HAVE_SCHED_H 1 ++ ++/* ++ * Define if pread() exists ++ */ ++#define HAVE_PREAD 1 ++ ++/* ++ * Define if we have st_mtim in struct stat ++ */ ++#define HAVE_STAT_ST_MTIM 1 ++ ++/* ++ * Define if printf() supports %zd for size_t arguments ++ */ ++#define HAVE_PRINTF_ZD 1 ++ ++/* ++ * Define to 1 if <stdlib.h> provides qsort_r() with a BSD style function prototype. ++ */ ++#define HAVE_BSD_QSORT_R 0 ++ ++/* ++ * Define to 1 if <stdlib.h> provides qsort_r() with a GNU style function prototype. ++ */ ++#define HAVE_GNU_QSORT_R 0 ++ ++#endif /* _ANDROID_CONFIG_H */ +-- +2.17.1 + diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/core/0001-adb-remove-selinux-extensions.patch b/meta-oe/recipes-devtools/android-tools/android-tools/core/0001-adb-remove-selinux-extensions.patch new file mode 100644 index 0000000000..7d20c50680 --- /dev/null +++ b/meta-oe/recipes-devtools/android-tools/android-tools/core/0001-adb-remove-selinux-extensions.patch @@ -0,0 +1,44 @@ +From 7b7200727413ca4a9bb132221c543ec033dffafa Mon Sep 17 00:00:00 2001 +From: Sergio Schvezov <sergio.schvezov@canonical.com> +Date: Wed, 7 Sep 2016 12:58:47 +0300 +Subject: [PATCH] adb: remove selinux extensions + +* drop useless includes of Android SELINUX extensions +* avoids having to clone another module +* this should be sent upstream + +Upstream-Status: Inappropriate + +Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com> +--- + adb/file_sync_service.c | 3 --- + 1 file changed, 3 deletions(-) + +diff --git a/adb/file_sync_service.c b/adb/file_sync_service.c +index 7933858516..3cbd0cd863 100644 +--- a/adb/file_sync_service.c ++++ b/adb/file_sync_service.c +@@ -26,7 +26,6 @@ + + #include <errno.h> + #include <private/android_filesystem_config.h> +-#include <selinux/android.h> + #include "sysdeps.h" + + #define TRACE_TAG TRACE_SYNC +@@ -73,7 +72,6 @@ static int mkdirs(char *name) + *x = '/'; + return ret; + } +- selinux_android_restorecon(name, 0); + } + *x++ = '/'; + } +@@ -251,7 +249,6 @@ static int handle_send_file(int s, char *path, uid_t uid, + if(fd >= 0) { + struct utimbuf u; + adb_close(fd); +- selinux_android_restorecon(path, 0); + u.actime = timestamp; + u.modtime = timestamp; + utime(path, &u); diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/core/0001-memory.h-Always-define-strlcpy-for-glibc-based-syste.patch b/meta-oe/recipes-devtools/android-tools/android-tools/core/0001-memory.h-Always-define-strlcpy-for-glibc-based-syste.patch new file mode 100644 index 0000000000..82e97152be --- /dev/null +++ b/meta-oe/recipes-devtools/android-tools/android-tools/core/0001-memory.h-Always-define-strlcpy-for-glibc-based-syste.patch @@ -0,0 +1,35 @@ +From db3a3714be07c8ab51b9ae7b035e4afe9f39c645 Mon Sep 17 00:00:00 2001 +From: Khem Raj <raj.khem@gmail.com> +Date: Wed, 7 Sep 2022 13:20:22 -0700 +Subject: [PATCH] memory.h: Always define strlcpy for glibc based systems + +android-config.h file includes on compiler cmdline sets HAVE_STRLCPY +unconditionally, since bionic supports it, its no big deal on android +and also no problem when using musl since implementation exists for musl +too, but glibc does not provide this. So either we include libbsd or use +the implementation provided by android-tools here. We are currently +using the in tree implementation for systems which do not provide it + +Upstream-Status: Pending + +Signed-off-by: Khem Raj <raj.khem@gmail.com> +--- + include/cutils/memory.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/include/cutils/memory.h b/include/cutils/memory.h +index e725cdd032..9e99353c58 100644 +--- a/include/cutils/memory.h ++++ b/include/cutils/memory.h +@@ -30,7 +30,7 @@ void android_memset16(uint16_t* dst, uint16_t value, size_t size); + /* size is given in bytes and must be multiple of 4 */ + void android_memset32(uint32_t* dst, uint32_t value, size_t size); + +-#if !HAVE_STRLCPY ++#if !HAVE_STRLCPY || defined(__GLIBC__) + /* Declaration of strlcpy() for platforms that don't already have it. */ + size_t strlcpy(char *dst, const char *src, size_t size); + #endif +-- +2.37.3 + diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/use-local-socket.patch b/meta-oe/recipes-devtools/android-tools/android-tools/core/0002-adb-Use-local-sockets-where-appropriate.patch index 7facd61b90..3627110ad8 100644 --- a/meta-oe/recipes-devtools/android-tools/android-tools/use-local-socket.patch +++ b/meta-oe/recipes-devtools/android-tools/android-tools/core/0002-adb-Use-local-sockets-where-appropriate.patch @@ -1,15 +1,19 @@ -Subject: adb: Use local sockets where appropriate -Author: Hilko Bengen <bengen@debian.org> +From d855f042ca09a358cebe2d3c1d29d512afd7ebb8 Mon Sep 17 00:00:00 2001 +From: Hilko Bengen <bengen@debian.org> +Date: Wed, 7 Sep 2016 12:58:47 +0300 +Subject: [PATCH] adb: Use local sockets where appropriate Upstream-Status: Inappropriate --- - system/core/adb/adb.c | 6 +++++- - system/core/adb/adb_client.c | 5 +++-- - system/core/adb/transport_local.c | 3 ++- + adb/adb.c | 6 +++++- + adb/adb_client.c | 5 +++-- + adb/transport_local.c | 3 ++- 3 files changed, 10 insertions(+), 4 deletions(-) ---- a/system/core/adb/adb.c -+++ b/system/core/adb/adb.c +diff --git a/adb/adb.c b/adb/adb.c +index 10a1e0da26..027edd9359 100644 +--- a/adb/adb.c ++++ b/adb/adb.c @@ -1230,7 +1230,11 @@ int launch_server(int server_port) */ void build_local_name(char* target_str, size_t target_size, int server_port) @@ -23,8 +27,10 @@ Upstream-Status: Inappropriate } #if !ADB_HOST ---- a/system/core/adb/adb_client.c -+++ b/system/core/adb/adb_client.c +diff --git a/adb/adb_client.c b/adb/adb_client.c +index eb1720d22c..a383faefe3 100644 +--- a/adb/adb_client.c ++++ b/adb/adb_client.c @@ -185,12 +185,12 @@ int _adb_connect(const char *service) strcpy(__adb_error, "service name too long"); return -1; @@ -48,9 +54,11 @@ Upstream-Status: Inappropriate if(writex(fd, tmp, 4) || writex(fd, service, len)) { strcpy(__adb_error, "write failure during connection"); adb_close(fd); ---- a/system/core/adb/transport_local.c -+++ b/system/core/adb/transport_local.c -@@ -121,7 +121,8 @@ int local_connect_arbitrary_ports(int co +diff --git a/adb/transport_local.c b/adb/transport_local.c +index 948cc15812..71582a8c88 100644 +--- a/adb/transport_local.c ++++ b/adb/transport_local.c +@@ -121,7 +121,8 @@ int local_connect_arbitrary_ports(int console_port, int adb_port) } #endif if (fd < 0) { diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/core/0003-adb-define-shell-command.patch b/meta-oe/recipes-devtools/android-tools/android-tools/core/0003-adb-define-shell-command.patch new file mode 100644 index 0000000000..cf1d9cbc3d --- /dev/null +++ b/meta-oe/recipes-devtools/android-tools/android-tools/core/0003-adb-define-shell-command.patch @@ -0,0 +1,29 @@ +From 4421c2e19946dcd651fd8ac022b96627fc526149 Mon Sep 17 00:00:00 2001 +From: Fathi Boudra <fabo@debian.org> +Date: Wed, 7 Sep 2016 12:58:47 +0300 +Subject: [PATCH] adb: define shell command + +we intend to run on Linux system so the shell is always /bin/sh, +for the host or the target. + +Upstream-Status: Inappropriate +--- + adb/services.c | 4 ---- + 1 file changed, 4 deletions(-) + +diff --git a/adb/services.c b/adb/services.c +index 21b08dc201..d44b0c5068 100644 +--- a/adb/services.c ++++ b/adb/services.c +@@ -299,11 +299,7 @@ static int create_subproc_raw(const char *cmd, const char *arg0, const char *arg + } + #endif /* !ABD_HOST */ + +-#if ADB_HOST + #define SHELL_COMMAND "/bin/sh" +-#else +-#define SHELL_COMMAND "/system/bin/sh" +-#endif + + #if !ADB_HOST + static void subproc_waiter_service(int fd, void *cookie) diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/fix-big-endian-build.patch b/meta-oe/recipes-devtools/android-tools/android-tools/core/0004-adb-Fix-build-on-big-endian-systems.patch index 8deaf3a3d7..7f03cd2beb 100644 --- a/meta-oe/recipes-devtools/android-tools/android-tools/fix-big-endian-build.patch +++ b/meta-oe/recipes-devtools/android-tools/android-tools/core/0004-adb-Fix-build-on-big-endian-systems.patch @@ -1,4 +1,7 @@ -Fix build on big endian systems +From 548b8ca62c64a16305929e2eaf3d546d48de9c25 Mon Sep 17 00:00:00 2001 +From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> +Date: Tue, 21 Feb 2017 19:46:24 +0100 +Subject: [PATCH] adb: Fix build on big endian systems The usb_linux_client.c file defines cpu_to_le16/32 by using the C library htole16/32 function calls. However, cpu_to_le16/32 are used @@ -14,11 +17,16 @@ To solve this, we simply open-code cpu_to_le16/32 in a way that allows them to be used when initializing structures. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> +--- +Upstream-Status: Pending -Index: b/system/core/adb/usb_linux_client.c -=================================================================== ---- a/system/core/adb/usb_linux_client.c -+++ b/system/core/adb/usb_linux_client.c + adb/usb_linux_client.c | 11 +++++++++-- + 1 file changed, 9 insertions(+), 2 deletions(-) + +diff --git a/adb/usb_linux_client.c b/adb/usb_linux_client.c +index 8426e0ea14..6e8b5bbbd2 100644 +--- a/adb/usb_linux_client.c ++++ b/adb/usb_linux_client.c @@ -34,8 +34,15 @@ #define MAX_PACKET_SIZE_FS 64 #define MAX_PACKET_SIZE_HS 512 diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/0001-add-base64-implementation.patch b/meta-oe/recipes-devtools/android-tools/android-tools/core/0005-adb-add-base64-implementation.patch index 680d21f3ac..4827ffe042 100644 --- a/meta-oe/recipes-devtools/android-tools/android-tools/0001-add-base64-implementation.patch +++ b/meta-oe/recipes-devtools/android-tools/android-tools/core/0005-adb-add-base64-implementation.patch @@ -1,21 +1,23 @@ -From bbeb72f11c64f190b23abbed5f44311bd021bdc9 Mon Sep 17 00:00:00 2001 +From 753bcb5971401b82fb2e6197d31c9e386f6d0392 Mon Sep 17 00:00:00 2001 From: Khem Raj <raj.khem@gmail.com> Date: Fri, 15 Sep 2017 15:46:38 -0700 -Subject: [PATCH 1/2] add base64 implementation +Subject: [PATCH] adb: add base64 implementation musl needs it Signed-off-by: Khem Raj <raj.khem@gmail.com> --- - system/core/adb/adb_auth_client.c | 2 +- - system/core/adb/base64.c | 315 ++++++++++++++++++++++++++++++++++++++ +Upstream-Status: Pending + + adb/adb_auth_client.c | 2 +- + adb/base64.c | 315 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 316 insertions(+), 1 deletion(-) - create mode 100644 system/core/adb/base64.c + create mode 100644 adb/base64.c -diff --git a/system/core/adb/adb_auth_client.c b/system/core/adb/adb_auth_client.c -index 55e9dca..104b413 100644 ---- a/system/core/adb/adb_auth_client.c -+++ b/system/core/adb/adb_auth_client.c +diff --git a/adb/adb_auth_client.c b/adb/adb_auth_client.c +index 55e9dcad19..104b413b8b 100644 +--- a/adb/adb_auth_client.c ++++ b/adb/adb_auth_client.c @@ -75,7 +75,7 @@ static void read_keys(const char *file, struct listnode *list) if (sep) *sep = '\0'; @@ -25,11 +27,11 @@ index 55e9dca..104b413 100644 if (ret != sizeof(key->key)) { D("%s: Invalid base64 data ret=%d\n", file, ret); free(key); -diff --git a/system/core/adb/base64.c b/system/core/adb/base64.c +diff --git a/adb/base64.c b/adb/base64.c new file mode 100644 -index 0000000..95da284 +index 0000000000..95da284d0d --- /dev/null -+++ b/system/core/adb/base64.c ++++ b/adb/base64.c @@ -0,0 +1,315 @@ +/* + * Copyright (c) 1996-1999 by Internet Software Consortium. @@ -346,6 +348,3 @@ index 0000000..95da284 + return (tarindex); +} + --- -2.14.1 - diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/0002-adb-Musl-fixes.patch b/meta-oe/recipes-devtools/android-tools/android-tools/core/0006-adb-Musl-fixes.patch index c7aebb6411..182b1eb29e 100644 --- a/meta-oe/recipes-devtools/android-tools/android-tools/0002-adb-Musl-fixes.patch +++ b/meta-oe/recipes-devtools/android-tools/android-tools/core/0006-adb-Musl-fixes.patch @@ -1,7 +1,7 @@ -From f8653ed0ede4aa781ab758fcd44fdc05ffbe0b0a Mon Sep 17 00:00:00 2001 +From 62d957a1271c88ec08d67984fbe31601f0bd41a9 Mon Sep 17 00:00:00 2001 From: Khem Raj <raj.khem@gmail.com> Date: Fri, 15 Sep 2017 15:50:57 -0700 -Subject: [PATCH 2/2] adb: Musl fixes +Subject: [PATCH] adb: Musl fixes __nonnull is gcc specific include sys/types.h for size_t @@ -9,16 +9,16 @@ Do not redefine close() and lseek() Signed-off-by: Khem Raj <raj.khem@gmail.com> --- - system/core/adb/adb.h | 2 ++ - system/core/adb/disable_verity_service.c | 13 ++++++++----- - system/core/adb/framebuffer_service.c | 7 ++++--- - system/core/adb/sysdeps.h | 12 ++++++------ +Upstream-Status: Pending + + adb/adb.h | 2 ++ + adb/disable_verity_service.c | 13 ++++++++----- + adb/framebuffer_service.c | 7 ++++--- + adb/sysdeps.h | 12 ++++++------ 4 files changed, 20 insertions(+), 14 deletions(-) -diff --git a/system/core/adb/adb.h b/system/core/adb/adb.h -index 44e5981..bcdc49f 100644 ---- a/system/core/adb/adb.h -+++ b/system/core/adb/adb.h +--- a/adb/adb.h ++++ b/adb/adb.h @@ -18,7 +18,9 @@ #define __ADB_H @@ -29,11 +29,9 @@ index 44e5981..bcdc49f 100644 #include "adb_trace.h" #include "transport.h" /* readx(), writex() */ -diff --git a/system/core/adb/disable_verity_service.c b/system/core/adb/disable_verity_service.c -index ed3da52..29fa3d6 100644 ---- a/system/core/adb/disable_verity_service.c -+++ b/system/core/adb/disable_verity_service.c -@@ -14,25 +14,28 @@ +--- a/adb/disable_verity_service.c ++++ b/adb/disable_verity_service.c +@@ -14,25 +14,32 @@ * limitations under the License. */ @@ -51,13 +49,18 @@ index ed3da52..29fa3d6 100644 #include <sys/stat.h> #include <fcntl.h> #include <inttypes.h> -+#include <unistd.h> -+#include <errno.h> -+#include <stdbool.h> - +- -#include "cutils/properties.h" -#include "ext4_sb.h" -#include <fs_mgr.h> ++#include <unistd.h> ++#include <errno.h> ++#include <stdbool.h> ++ ++#if defined(__linux__) && !defined(__GLIBC__) ++#define lseek64 lseek ++#define off64_t off_t ++#endif #define FSTAB_PREFIX "/fstab." struct fstab *fstab; @@ -67,10 +70,8 @@ index ed3da52..29fa3d6 100644 static void write_console(int fd, const char* format, ...) { char buffer[256]; -diff --git a/system/core/adb/framebuffer_service.c b/system/core/adb/framebuffer_service.c -index 8cbe840..8f0ccfb 100644 ---- a/system/core/adb/framebuffer_service.c -+++ b/system/core/adb/framebuffer_service.c +--- a/adb/framebuffer_service.c ++++ b/adb/framebuffer_service.c @@ -14,6 +14,10 @@ * limitations under the License. */ @@ -92,11 +93,9 @@ index 8cbe840..8f0ccfb 100644 #include <linux/fb.h> #include <sys/ioctl.h> #include <sys/mman.h> -diff --git a/system/core/adb/sysdeps.h b/system/core/adb/sysdeps.h -index cc1f839..ea39ac3 100644 ---- a/system/core/adb/sysdeps.h -+++ b/system/core/adb/sysdeps.h -@@ -123,8 +123,8 @@ static __inline__ int unix_close(int fd) +--- a/adb/sysdeps.h ++++ b/adb/sysdeps.h +@@ -123,8 +123,8 @@ static __inline__ int unix_close(int fd { return close(fd); } @@ -118,7 +117,7 @@ index cc1f839..ea39ac3 100644 static __inline__ int adb_read(int fd, void* buf, size_t len) -@@ -392,8 +392,8 @@ static __inline__ int adb_lseek(int fd, int pos, int where) +@@ -392,8 +392,8 @@ static __inline__ int adb_lseek(int f { return lseek(fd, pos, where); } @@ -129,6 +128,3 @@ index cc1f839..ea39ac3 100644 static __inline__ int adb_unlink(const char* path) { --- -2.14.1 - diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/core/0007-adb-usb_linux.c-fix-build-with-glibc-2.28.patch b/meta-oe/recipes-devtools/android-tools/android-tools/core/0007-adb-usb_linux.c-fix-build-with-glibc-2.28.patch new file mode 100644 index 0000000000..64fbce4cbe --- /dev/null +++ b/meta-oe/recipes-devtools/android-tools/android-tools/core/0007-adb-usb_linux.c-fix-build-with-glibc-2.28.patch @@ -0,0 +1,26 @@ +From de393bba41c8feff932c77d6c30233945f380d42 Mon Sep 17 00:00:00 2001 +From: Martin Jansa <Martin.Jansa@gmail.com> +Date: Sat, 11 Aug 2018 13:23:37 +0000 +Subject: [PATCH] adb: usb_linux.c: fix build with glibc-2.28 + +* include sysmacros for major, minor + +Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com> +--- +Upstream-Status: Pending + + adb/usb_linux.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/adb/usb_linux.c b/adb/usb_linux.c +index f16bdd0361..c8a7732441 100644 +--- a/adb/usb_linux.c ++++ b/adb/usb_linux.c +@@ -22,6 +22,7 @@ + #include <sys/ioctl.h> + #include <sys/types.h> + #include <sys/time.h> ++#include <sys/sysmacros.h> + #include <dirent.h> + #include <fcntl.h> + #include <errno.h> diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/core/0008-adb-Allow-adbd-to-be-ran-as-root.patch b/meta-oe/recipes-devtools/android-tools/android-tools/core/0008-adb-Allow-adbd-to-be-ran-as-root.patch new file mode 100644 index 0000000000..ad21b5aaa6 --- /dev/null +++ b/meta-oe/recipes-devtools/android-tools/android-tools/core/0008-adb-Allow-adbd-to-be-ran-as-root.patch @@ -0,0 +1,23 @@ +From 3a788e9168c9b9eac66c4fa479413f4a95c61be4 Mon Sep 17 00:00:00 2001 +From: Florent Revest <revestflo@gmail.com> +Date: Mon, 30 Oct 2017 21:05:46 +0100 +Subject: [PATCH] adb: Allow adbd to be ran as root + +--- +Upstream-Status: Pending + + adb/adb.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/adb/adb.c b/adb/adb.c +index 027edd9359..e0f7ecde45 100644 +--- a/adb/adb.c ++++ b/adb/adb.c +@@ -1271,6 +1271,7 @@ static int should_drop_privileges() { + int secure = 0; + char value[PROPERTY_VALUE_MAX]; + ++ return 0; + /* run adbd in secure mode if ro.secure is set and + ** we are not in the emulator + */ diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/mkbootimg-Add-dt-parameter-to-specify-DT-image.patch b/meta-oe/recipes-devtools/android-tools/android-tools/core/0009-mkbootimg-Add-dt-parameter-to-specify-DT-image.patch index 35bb766a7f..a4dc6e1e35 100644 --- a/meta-oe/recipes-devtools/android-tools/android-tools/mkbootimg-Add-dt-parameter-to-specify-DT-image.patch +++ b/meta-oe/recipes-devtools/android-tools/android-tools/core/0009-mkbootimg-Add-dt-parameter-to-specify-DT-image.patch @@ -1,21 +1,21 @@ -From cc5e7b02a3be57709a1aed6e34be100b82a71620 Mon Sep 17 00:00:00 2001 +From dd195778a9930b7967b21a3b8eb390b70253dbad Mon Sep 17 00:00:00 2001 From: David Ng <dave@codeaurora.org> Date: Fri, 27 Jul 2012 17:15:03 -0700 -Subject: [PATCH 1/2] mkbootimg: Add --dt parameter to specify DT image +Subject: [PATCH] mkbootimg: Add --dt parameter to specify DT image New optional --dt parameter to specify a kernel device tree image. -Change-Id: Ie29a11cbf4138426bfd19ae486d69a5fcbd8f442 - Upstream-Status: Inappropriate --- - system/core/mkbootimg/bootimg.h | 7 +++++-- - system/core/mkbootimg/mkbootimg.c | 21 +++++++++++++++++++++ + mkbootimg/bootimg.h | 7 +++++-- + mkbootimg/mkbootimg.c | 21 +++++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) ---- a/system/core/mkbootimg/bootimg.h -+++ b/system/core/mkbootimg/bootimg.h +diff --git a/mkbootimg/bootimg.h b/mkbootimg/bootimg.h +index 9171d85a7b..308c537d6b 100644 +--- a/mkbootimg/bootimg.h ++++ b/mkbootimg/bootimg.h @@ -41,8 +41,8 @@ struct boot_img_hdr unsigned tags_addr; /* physical addr for kernel tags */ @@ -41,8 +41,10 @@ Upstream-Status: Inappropriate ** ** 0. all entities are page_size aligned in flash ** 1. kernel and ramdisk are required (size != 0) ---- a/system/core/mkbootimg/mkbootimg.c -+++ b/system/core/mkbootimg/mkbootimg.c +diff --git a/mkbootimg/mkbootimg.c b/mkbootimg/mkbootimg.c +index fc92b4dc30..658052cdf2 100644 +--- a/mkbootimg/mkbootimg.c ++++ b/mkbootimg/mkbootimg.c @@ -65,6 +65,7 @@ int usage(void) " [ --board <boardname> ]\n" " [ --base <address> ]\n" diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/core/0010-Use-linux-capability.h-on-linux-systems-too.patch b/meta-oe/recipes-devtools/android-tools/android-tools/core/0010-Use-linux-capability.h-on-linux-systems-too.patch new file mode 100644 index 0000000000..2c607ff67c --- /dev/null +++ b/meta-oe/recipes-devtools/android-tools/android-tools/core/0010-Use-linux-capability.h-on-linux-systems-too.patch @@ -0,0 +1,23 @@ +From ef743c9c3c7452ae904a5c343ee2b759ab3a87cb Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Lo=C3=AFc=20Minier?= <loic.minier@ubuntu.com> +Date: Wed, 7 Sep 2016 12:58:47 +0300 +Subject: [PATCH] Use linux/capability.h on linux systems too + +Upstream-Status: Inappropriate +--- + include/private/android_filesystem_config.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/include/private/android_filesystem_config.h b/include/private/android_filesystem_config.h +index 2f528b95c8..3e0b00928e 100644 +--- a/include/private/android_filesystem_config.h ++++ b/include/private/android_filesystem_config.h +@@ -27,7 +27,7 @@ + #include <sys/types.h> + #include <stdint.h> + +-#ifdef HAVE_ANDROID_OS ++#if defined(HAVE_ANDROID_OS) || defined(__linux__) + #include <linux/capability.h> + #else + #include "android_filesystem_capability.h" diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/remove-bionic-android.patch b/meta-oe/recipes-devtools/android-tools/android-tools/core/0011-Remove-bionic-specific-calls.patch index e933724cfd..5b18f461a3 100644 --- a/meta-oe/recipes-devtools/android-tools/android-tools/remove-bionic-android.patch +++ b/meta-oe/recipes-devtools/android-tools/android-tools/core/0011-Remove-bionic-specific-calls.patch @@ -1,15 +1,19 @@ -Description: remove bionic specific calls -Author: Fathi Boudra <fabo@debian.org> +From 9eff8799831961c0edf6e37e5d4cbf43baa7c748 Mon Sep 17 00:00:00 2001 +From: Fathi Boudra <fabo@debian.org> +Date: Wed, 7 Sep 2016 12:58:47 +0300 +Subject: [PATCH] Remove bionic specific calls Upstream-Status: Inappropriate --- - system/core/include/cutils/properties.h | 1 - - system/core/libcutils/properties.c | 2 +- - system/core/liblog/logd_write.c | 5 +++++ + include/cutils/properties.h | 1 - + libcutils/properties.c | 2 +- + liblog/logd_write.c | 5 +++++ 3 files changed, 6 insertions(+), 2 deletions(-) ---- a/system/core/include/cutils/properties.h -+++ b/system/core/include/cutils/properties.h +diff --git a/include/cutils/properties.h b/include/cutils/properties.h +index 798db8b36f..7d01f28d6e 100644 +--- a/include/cutils/properties.h ++++ b/include/cutils/properties.h @@ -19,7 +19,6 @@ #include <sys/cdefs.h> @@ -18,8 +22,26 @@ Upstream-Status: Inappropriate #include <stdint.h> #ifdef __cplusplus ---- a/system/core/liblog/logd_write.c -+++ b/system/core/liblog/logd_write.c +diff --git a/libcutils/properties.c b/libcutils/properties.c +index b283658aa4..4151e7882c 100644 +--- a/libcutils/properties.c ++++ b/libcutils/properties.c +@@ -104,10 +104,10 @@ int32_t property_get_int32(const char *key, int32_t default_value) { + return (int32_t)property_get_imax(key, INT32_MIN, INT32_MAX, default_value); + } + ++#undef HAVE_LIBC_SYSTEM_PROPERTIES + #ifdef HAVE_LIBC_SYSTEM_PROPERTIES + + #define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_ +-#include <sys/_system_properties.h> + + int property_set(const char *key, const char *value) + { +diff --git a/liblog/logd_write.c b/liblog/logd_write.c +index b2668cedb7..f5a44fe901 100644 +--- a/liblog/logd_write.c ++++ b/liblog/logd_write.c @@ -23,6 +23,7 @@ #include <stdlib.h> #include <string.h> @@ -28,7 +50,7 @@ Upstream-Status: Inappropriate #include <sys/types.h> #if (FAKE_LOG_DEVICE == 0) #include <sys/socket.h> -@@ -205,7 +206,11 @@ static int __write_to_log_kernel(log_id_ +@@ -205,7 +206,11 @@ static int __write_to_log_kernel(log_id_t log_id, struct iovec *vec, size_t nr) realtime_ts.tv_nsec = ts.tv_nsec; log_id_buf = log_id; @@ -40,28 +62,3 @@ Upstream-Status: Inappropriate newVec[0].iov_base = (unsigned char *) &log_id_buf; newVec[0].iov_len = sizeof_log_id_t; ---- a/system/core/libcutils/properties.c -+++ b/system/core/libcutils/properties.c -@@ -104,10 +104,10 @@ int32_t property_get_int32(const char *k - return (int32_t)property_get_imax(key, INT32_MIN, INT32_MAX, default_value); - } - -+#undef HAVE_LIBC_SYSTEM_PROPERTIES - #ifdef HAVE_LIBC_SYSTEM_PROPERTIES - - #define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_ --#include <sys/_system_properties.h> - - int property_set(const char *key, const char *value) - { ---- a/external/libselinux/src/procattr.c -+++ b/external/libselinux/src/procattr.c -@@ -8,7 +8,7 @@ - #include "selinux_internal.h" - #include "policy.h" - --#ifdef HOST -+#ifndef __BIONIC__ - static pid_t gettid(void) - { - return syscall(__NR_gettid); diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/core/0012-Fix-implicit-declaration-of-stlcat-strlcopy-function.patch b/meta-oe/recipes-devtools/android-tools/android-tools/core/0012-Fix-implicit-declaration-of-stlcat-strlcopy-function.patch new file mode 100644 index 0000000000..b0feb65921 --- /dev/null +++ b/meta-oe/recipes-devtools/android-tools/android-tools/core/0012-Fix-implicit-declaration-of-stlcat-strlcopy-function.patch @@ -0,0 +1,50 @@ +From cd4525d760c6f88c9bf85f7bf488da79cd0d3264 Mon Sep 17 00:00:00 2001 +From: Fathi Boudra <fabo@debian.org> +Date: Wed, 7 Sep 2016 12:58:47 +0300 +Subject: [PATCH] Fix implicit declaration of stlcat/strlcopy functions + +Upstream-Status: Inappropriate +--- + adb/adb.c | 1 + + fs_mgr/fs_mgr_fstab.c | 2 +- + include/cutils/sockets.h | 2 +- + 3 files changed, 3 insertions(+), 2 deletions(-) + +diff --git a/adb/adb.c b/adb/adb.c +index e0f7ecde45..aaefd9b401 100644 +--- a/adb/adb.c ++++ b/adb/adb.c +@@ -41,6 +41,7 @@ + #include <sys/prctl.h> + #include <getopt.h> + #include <selinux/selinux.h> ++#include <grp.h> + #else + #include "usb_vendors.h" + #endif +diff --git a/fs_mgr/fs_mgr_fstab.c b/fs_mgr/fs_mgr_fstab.c +index edd9591164..9ddb4643b5 100644 +--- a/fs_mgr/fs_mgr_fstab.c ++++ b/fs_mgr/fs_mgr_fstab.c +@@ -17,7 +17,7 @@ + #include <ctype.h> + #include <stdio.h> + #include <stdlib.h> +-#include <string.h> ++#include <bsd/string.h> + #include <sys/mount.h> + + #include "fs_mgr_priv.h" +diff --git a/include/cutils/sockets.h b/include/cutils/sockets.h +index daf43ec944..d3270c69e7 100644 +--- a/include/cutils/sockets.h ++++ b/include/cutils/sockets.h +@@ -19,7 +19,7 @@ + + #include <errno.h> + #include <stdlib.h> +-#include <string.h> ++#include <bsd/string.h> + #include <stdbool.h> + + #ifdef HAVE_WINSOCK diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/core/0013-adb-Support-riscv64.patch b/meta-oe/recipes-devtools/android-tools/android-tools/core/0013-adb-Support-riscv64.patch new file mode 100644 index 0000000000..5138556d63 --- /dev/null +++ b/meta-oe/recipes-devtools/android-tools/android-tools/core/0013-adb-Support-riscv64.patch @@ -0,0 +1,191 @@ +From 48ddf4fb999931942c359350fb31cd557514e1c6 Mon Sep 17 00:00:00 2001 +From: Chenxi Mao <maochenxi@eswin.com> +Date: Mon, 20 Apr 2020 15:27:22 +0800 +Subject: [PATCH 1/1] adb: Support riscv64 + +--- +Upstream-Status: Pending + + include/cutils/atomic-inline.h | 2 + + include/cutils/atomic-riscv64.h | 156 ++++++++++++++++++++++++++++++++ + 2 files changed, 158 insertions(+) + create mode 100644 include/cutils/atomic-riscv64.h + +diff --git a/include/cutils/atomic-inline.h b/include/cutils/atomic-inline.h +index a31e913579..b5dc38209c 100644 +--- a/include/cutils/atomic-inline.h ++++ b/include/cutils/atomic-inline.h +@@ -55,6 +55,8 @@ extern "C" { + #include <cutils/atomic-mips64.h> + #elif defined(__mips__) + #include <cutils/atomic-mips.h> ++#elif defined(__riscv) && __riscv_xlen == 64 ++#include <cutils/atomic-riscv64.h> + #else + #error atomic operations are unsupported + #endif +diff --git a/include/cutils/atomic-riscv64.h b/include/cutils/atomic-riscv64.h +new file mode 100644 +index 0000000000..2664db5a86 +--- /dev/null ++++ b/include/cutils/atomic-riscv64.h +@@ -0,0 +1,156 @@ ++/* ++ * Copyright (C) 2014 The Android Open Source Project ++ * All rights reserved. ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * * Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * * Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ++ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ++ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS ++ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ++ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, ++ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, ++ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS ++ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED ++ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, ++ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT ++ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ++ * SUCH DAMAGE. ++ */ ++ ++#ifndef ANDROID_CUTILS_ATOMIC_RISCV64_H ++#define ANDROID_CUTILS_ATOMIC_RISCV64_H ++ ++#include <stdint.h> ++ ++#ifndef ANDROID_ATOMIC_INLINE ++#define ANDROID_ATOMIC_INLINE inline __attribute__((always_inline)) ++#endif ++ ++/* ++ TODOAArch64: Revisit the below functions and check for potential ++ optimizations using assembly code or otherwise. ++*/ ++ ++extern ANDROID_ATOMIC_INLINE ++void android_compiler_barrier(void) ++{ ++ __asm__ __volatile__ ("" : : : "memory"); ++} ++ ++extern ANDROID_ATOMIC_INLINE ++void android_memory_barrier(void) ++{ ++ __asm__ __volatile__ ("fence rw,rw" : : : "memory"); ++} ++ ++extern ANDROID_ATOMIC_INLINE ++int32_t android_atomic_acquire_load(volatile const int32_t *ptr) ++{ ++ int32_t value = *ptr; ++ android_memory_barrier(); ++ return value; ++} ++ ++extern ANDROID_ATOMIC_INLINE ++int32_t android_atomic_release_load(volatile const int32_t *ptr) ++{ ++ android_memory_barrier(); ++ return *ptr; ++} ++ ++extern ANDROID_ATOMIC_INLINE ++void android_atomic_acquire_store(int32_t value, volatile int32_t *ptr) ++{ ++ *ptr = value; ++ android_memory_barrier(); ++} ++ ++extern ANDROID_ATOMIC_INLINE ++void android_atomic_release_store(int32_t value, volatile int32_t *ptr) ++{ ++ android_memory_barrier(); ++ *ptr = value; ++} ++ ++extern ANDROID_ATOMIC_INLINE ++int android_atomic_cas(int32_t old_value, int32_t new_value, ++ volatile int32_t *ptr) ++{ ++ return __sync_val_compare_and_swap(ptr, old_value, new_value) != old_value; ++} ++ ++extern ANDROID_ATOMIC_INLINE ++int android_atomic_acquire_cas(int32_t old_value, int32_t new_value, ++ volatile int32_t *ptr) ++{ ++ int status = android_atomic_cas(old_value, new_value, ptr); ++ android_memory_barrier(); ++ return status; ++} ++ ++extern ANDROID_ATOMIC_INLINE ++int android_atomic_release_cas(int32_t old_value, int32_t new_value, ++ volatile int32_t *ptr) ++{ ++ android_memory_barrier(); ++ return android_atomic_cas(old_value, new_value, ptr); ++} ++ ++extern ANDROID_ATOMIC_INLINE ++int32_t android_atomic_add(int32_t increment, volatile int32_t *ptr) ++{ ++ int32_t prev, status; ++ android_memory_barrier(); ++ do { ++ prev = *ptr; ++ status = android_atomic_cas(prev, prev + increment, ptr); ++ } while (__builtin_expect(status != 0, 0)); ++ return prev; ++} ++ ++extern ANDROID_ATOMIC_INLINE ++int32_t android_atomic_inc(volatile int32_t *addr) ++{ ++ return android_atomic_add(1, addr); ++} ++ ++extern ANDROID_ATOMIC_INLINE ++int32_t android_atomic_dec(volatile int32_t *addr) ++{ ++ return android_atomic_add(-1, addr); ++} ++ ++extern ANDROID_ATOMIC_INLINE ++int32_t android_atomic_and(int32_t value, volatile int32_t *ptr) ++{ ++ int32_t prev, status; ++ android_memory_barrier(); ++ do { ++ prev = *ptr; ++ status = android_atomic_cas(prev, prev & value, ptr); ++ } while (__builtin_expect(status != 0, 0)); ++ return prev; ++} ++ ++extern ANDROID_ATOMIC_INLINE ++int32_t android_atomic_or(int32_t value, volatile int32_t *ptr) ++{ ++ int32_t prev, status; ++ android_memory_barrier(); ++ do { ++ prev = *ptr; ++ status = android_atomic_cas(prev, prev | value, ptr); ++ } while (__builtin_expect(status != 0, 0)); ++ return prev; ++} ++ ++#endif /* ANDROID_CUTILS_ATOMIC_RISCV_H */ +-- +2.17.1 + diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/core/0014-add-u3-ss-descriptor-support-for-adb.patch b/meta-oe/recipes-devtools/android-tools/android-tools/core/0014-add-u3-ss-descriptor-support-for-adb.patch new file mode 100644 index 0000000000..cf23f3c251 --- /dev/null +++ b/meta-oe/recipes-devtools/android-tools/android-tools/core/0014-add-u3-ss-descriptor-support-for-adb.patch @@ -0,0 +1,344 @@ +From dae9a11f3a158357966399aef97c48b5f16934d9 Mon Sep 17 00:00:00 2001 +From: Jiacheng Liu <jiacheng.liu@mediatek.com> +Date: Sat, 24 Jul 2021 11:01:18 +0800 +Subject: [PATCH] android-tools: adb: add u3 ss descriptor support + +Porting u3 Superspeed descriptor support to open-embedded android-tools package. +This patch origins from the the patch in android project [1], but has been +modified for backporting to android-tools_5.1.1.r37. + +[1] https://android.googlesource.com/platform/system/core/+/d6ee9f26a5163af4121f4380264fcbd4e6851a17%5E%21 + +Signed-off-by: Macpaul Lin <macpaul.lin@mediatek.com> +Signed-off-by: Jiacheng Liu <jiacheng.liu@mediatek.com> +--- +Upstream-Status: Pending + + adb/usb_linux_client.c | 275 +++++++++++++++++++++++++++++++---------- + 1 file changed, 207 insertions(+), 68 deletions(-) + +diff --git a/adb/usb_linux_client.c b/adb/usb_linux_client.c +index 6e8b5bb..884e85e 100644 +--- a/adb/usb_linux_client.c ++++ b/adb/usb_linux_client.c +@@ -31,8 +31,10 @@ + #define TRACE_TAG TRACE_USB + #include "adb.h" + ++#define USB_EXT_PROP_UNICODE 1 + #define MAX_PACKET_SIZE_FS 64 + #define MAX_PACKET_SIZE_HS 512 ++#define MAX_PACKET_SIZE_SS 1024 + + #if __BYTE_ORDER == __LITTLE_ENDIAN + # define cpu_to_le16(x) (x) +@@ -62,74 +64,185 @@ struct usb_handle + int bulk_in; /* "in" from the host's perspective => sink for adbd */ + }; + +-static const struct { +- struct usb_functionfs_descs_head header; +- struct { +- struct usb_interface_descriptor intf; +- struct usb_endpoint_descriptor_no_audio source; +- struct usb_endpoint_descriptor_no_audio sink; +- } __attribute__((packed)) fs_descs, hs_descs; +-} __attribute__((packed)) descriptors = { +- .header = { +- .magic = cpu_to_le32(FUNCTIONFS_DESCRIPTORS_MAGIC), +- .length = cpu_to_le32(sizeof(descriptors)), +- .fs_count = 3, +- .hs_count = 3, ++struct func_desc { ++ struct usb_interface_descriptor intf; ++ struct usb_endpoint_descriptor_no_audio source; ++ struct usb_endpoint_descriptor_no_audio sink; ++} __attribute__((packed)); ++ ++struct ss_func_desc { ++ struct usb_interface_descriptor intf; ++ struct usb_endpoint_descriptor_no_audio source; ++ struct usb_ss_ep_comp_descriptor source_comp; ++ struct usb_endpoint_descriptor_no_audio sink; ++ struct usb_ss_ep_comp_descriptor sink_comp; ++} __attribute__((packed)); ++ ++struct desc_v1 { ++ struct usb_functionfs_descs_head_v1 { ++ __le32 magic; ++ __le32 length; ++ __le32 fs_count; ++ __le32 hs_count; ++ } __attribute__((packed)) header; ++ struct func_desc fs_descs, hs_descs; ++} __attribute__((packed)); ++ ++struct usb_os_desc_ext_prop { ++ uint32_t dwSize; ++ uint32_t dwPropertyDataType; ++ ++ // Property name and value are transmitted as UTF-16, but the kernel only ++ // accepts ASCII values and performs the conversion for us. ++ uint16_t wPropertyNameLength; ++ char bPropertyName[20]; ++ ++ uint32_t dwPropertyDataLength; ++ char bProperty[39]; ++} __attribute__((packed)) os_desc_guid = { ++ .dwSize = sizeof(struct usb_os_desc_ext_prop), ++ .dwPropertyDataType = cpu_to_le32(USB_EXT_PROP_UNICODE), ++ .wPropertyNameLength = cpu_to_le16(20), ++ .bPropertyName = "DeviceInterfaceGUID", ++ .dwPropertyDataLength = cpu_to_le32(39), ++ .bProperty = "{F72FE0D4-CBCB-407D-8814-9ED673D0DD6B}", ++}; ++ ++struct usb_ext_prop_values { ++ struct usb_os_desc_ext_prop guid; ++} __attribute__((packed)); ++ ++struct desc_v2 { ++ struct usb_functionfs_descs_head_v2 header; ++ // The rest of the structure depends on the flags in the header. ++ __le32 fs_count; ++ __le32 hs_count; ++ __le32 ss_count; ++ __le32 os_count; ++ struct func_desc fs_descs, hs_descs; ++ struct ss_func_desc ss_descs; ++ struct usb_os_desc_header os_header; ++ struct usb_ext_compat_desc os_desc; ++ struct usb_os_desc_header os_prop_header; ++ struct usb_ext_prop_values os_prop_values; ++} __attribute__((packed)); ++ ++static struct func_desc fs_descriptors = { ++ .intf = { ++ .bLength = sizeof(fs_descriptors.intf), ++ .bDescriptorType = USB_DT_INTERFACE, ++ .bInterfaceNumber = 0, ++ .bNumEndpoints = 2, ++ .bInterfaceClass = ADB_CLASS, ++ .bInterfaceSubClass = ADB_SUBCLASS, ++ .bInterfaceProtocol = ADB_PROTOCOL, ++ .iInterface = 1, /* first string from the provided table */ ++ }, ++ .source = { ++ .bLength = sizeof(fs_descriptors.source), ++ .bDescriptorType = USB_DT_ENDPOINT, ++ .bEndpointAddress = 1 | USB_DIR_OUT, ++ .bmAttributes = USB_ENDPOINT_XFER_BULK, ++ .wMaxPacketSize = MAX_PACKET_SIZE_FS, ++ }, ++ .sink = { ++ .bLength = sizeof(fs_descriptors.sink), ++ .bDescriptorType = USB_DT_ENDPOINT, ++ .bEndpointAddress = 2 | USB_DIR_IN, ++ .bmAttributes = USB_ENDPOINT_XFER_BULK, ++ .wMaxPacketSize = MAX_PACKET_SIZE_FS, ++ }, ++}; ++ ++static struct func_desc hs_descriptors = { ++ .intf = { ++ .bLength = sizeof(hs_descriptors.intf), ++ .bDescriptorType = USB_DT_INTERFACE, ++ .bInterfaceNumber = 0, ++ .bNumEndpoints = 2, ++ .bInterfaceClass = ADB_CLASS, ++ .bInterfaceSubClass = ADB_SUBCLASS, ++ .bInterfaceProtocol = ADB_PROTOCOL, ++ .iInterface = 1, /* first string from the provided table */ ++ }, ++ .source = { ++ .bLength = sizeof(hs_descriptors.source), ++ .bDescriptorType = USB_DT_ENDPOINT, ++ .bEndpointAddress = 1 | USB_DIR_OUT, ++ .bmAttributes = USB_ENDPOINT_XFER_BULK, ++ .wMaxPacketSize = MAX_PACKET_SIZE_HS, ++ }, ++ .sink = { ++ .bLength = sizeof(hs_descriptors.sink), ++ .bDescriptorType = USB_DT_ENDPOINT, ++ .bEndpointAddress = 2 | USB_DIR_IN, ++ .bmAttributes = USB_ENDPOINT_XFER_BULK, ++ .wMaxPacketSize = MAX_PACKET_SIZE_HS, ++ }, ++}; ++ ++static struct ss_func_desc ss_descriptors = { ++ .intf = { ++ .bLength = sizeof(ss_descriptors.intf), ++ .bDescriptorType = USB_DT_INTERFACE, ++ .bInterfaceNumber = 0, ++ .bNumEndpoints = 2, ++ .bInterfaceClass = ADB_CLASS, ++ .bInterfaceSubClass = ADB_SUBCLASS, ++ .bInterfaceProtocol = ADB_PROTOCOL, ++ .iInterface = 1, /* first string from the provided table */ ++ }, ++ .source = { ++ .bLength = sizeof(ss_descriptors.source), ++ .bDescriptorType = USB_DT_ENDPOINT, ++ .bEndpointAddress = 1 | USB_DIR_OUT, ++ .bmAttributes = USB_ENDPOINT_XFER_BULK, ++ .wMaxPacketSize = MAX_PACKET_SIZE_SS, ++ }, ++ .source_comp = { ++ .bLength = sizeof(ss_descriptors.source_comp), ++ .bDescriptorType = USB_DT_SS_ENDPOINT_COMP, ++ .bMaxBurst = 4, + }, +- .fs_descs = { +- .intf = { +- .bLength = sizeof(descriptors.fs_descs.intf), +- .bDescriptorType = USB_DT_INTERFACE, +- .bInterfaceNumber = 0, +- .bNumEndpoints = 2, +- .bInterfaceClass = ADB_CLASS, +- .bInterfaceSubClass = ADB_SUBCLASS, +- .bInterfaceProtocol = ADB_PROTOCOL, +- .iInterface = 1, /* first string from the provided table */ +- }, +- .source = { +- .bLength = sizeof(descriptors.fs_descs.source), +- .bDescriptorType = USB_DT_ENDPOINT, +- .bEndpointAddress = 1 | USB_DIR_OUT, +- .bmAttributes = USB_ENDPOINT_XFER_BULK, +- .wMaxPacketSize = MAX_PACKET_SIZE_FS, +- }, +- .sink = { +- .bLength = sizeof(descriptors.fs_descs.sink), +- .bDescriptorType = USB_DT_ENDPOINT, +- .bEndpointAddress = 2 | USB_DIR_IN, +- .bmAttributes = USB_ENDPOINT_XFER_BULK, +- .wMaxPacketSize = MAX_PACKET_SIZE_FS, +- }, ++ .sink = { ++ .bLength = sizeof(ss_descriptors.sink), ++ .bDescriptorType = USB_DT_ENDPOINT, ++ .bEndpointAddress = 2 | USB_DIR_IN, ++ .bmAttributes = USB_ENDPOINT_XFER_BULK, ++ .wMaxPacketSize = MAX_PACKET_SIZE_SS, + }, +- .hs_descs = { +- .intf = { +- .bLength = sizeof(descriptors.hs_descs.intf), +- .bDescriptorType = USB_DT_INTERFACE, +- .bInterfaceNumber = 0, +- .bNumEndpoints = 2, +- .bInterfaceClass = ADB_CLASS, +- .bInterfaceSubClass = ADB_SUBCLASS, +- .bInterfaceProtocol = ADB_PROTOCOL, +- .iInterface = 1, /* first string from the provided table */ +- }, +- .source = { +- .bLength = sizeof(descriptors.hs_descs.source), +- .bDescriptorType = USB_DT_ENDPOINT, +- .bEndpointAddress = 1 | USB_DIR_OUT, +- .bmAttributes = USB_ENDPOINT_XFER_BULK, +- .wMaxPacketSize = MAX_PACKET_SIZE_HS, +- }, +- .sink = { +- .bLength = sizeof(descriptors.hs_descs.sink), +- .bDescriptorType = USB_DT_ENDPOINT, +- .bEndpointAddress = 2 | USB_DIR_IN, +- .bmAttributes = USB_ENDPOINT_XFER_BULK, +- .wMaxPacketSize = MAX_PACKET_SIZE_HS, +- }, ++ .sink_comp = { ++ .bLength = sizeof(ss_descriptors.sink_comp), ++ .bDescriptorType = USB_DT_SS_ENDPOINT_COMP, ++ .bMaxBurst = 4, + }, + }; + ++struct usb_ext_compat_desc os_desc_compat = { ++ .bFirstInterfaceNumber = 0, ++ .Reserved1 = cpu_to_le32(1), ++ .CompatibleID = { 'W', 'I', 'N', 'U', 'S', 'B', '\0', '\0'}, ++ .SubCompatibleID = {0}, ++ .Reserved2 = {0}, ++}; ++ ++static struct usb_os_desc_header os_desc_header = { ++ .interface = cpu_to_le32(0), ++ .dwLength = cpu_to_le32(sizeof(os_desc_header) + sizeof(os_desc_compat)), ++ .bcdVersion = cpu_to_le32(1), ++ .wIndex = cpu_to_le32(4), ++ .bCount = cpu_to_le32(1), ++ .Reserved = cpu_to_le32(0), ++}; ++ ++static struct usb_os_desc_header os_prop_header = { ++ .interface = cpu_to_le32(0), ++ .dwLength = cpu_to_le32(sizeof(os_desc_header) + sizeof(struct usb_ext_prop_values)), ++ .bcdVersion = cpu_to_le32(1), ++ .wIndex = cpu_to_le32(5), ++ .wCount = cpu_to_le16(1), ++}; ++ + #define STR_INTERFACE_ "ADB Interface" + + static const struct { +@@ -151,8 +264,6 @@ static const struct { + }, + }; + +- +- + static void *usb_adb_open_thread(void *x) + { + struct usb_handle *usb = (struct usb_handle *)x; +@@ -270,6 +381,24 @@ static void usb_adb_init() + static void init_functionfs(struct usb_handle *h) + { + ssize_t ret; ++ struct desc_v1 v1_descriptor = {}; ++ struct desc_v2 v2_descriptor = {}; ++ ++ v2_descriptor.header.magic = cpu_to_le32(FUNCTIONFS_DESCRIPTORS_MAGIC_V2); ++ v2_descriptor.header.length = cpu_to_le32(sizeof(v2_descriptor)); ++ v2_descriptor.header.flags = FUNCTIONFS_HAS_FS_DESC | FUNCTIONFS_HAS_HS_DESC | ++ FUNCTIONFS_HAS_SS_DESC | FUNCTIONFS_HAS_MS_OS_DESC; ++ v2_descriptor.fs_count = 3; ++ v2_descriptor.hs_count = 3; ++ v2_descriptor.ss_count = 5; ++ v2_descriptor.os_count = 2; ++ v2_descriptor.fs_descs = fs_descriptors; ++ v2_descriptor.hs_descs = hs_descriptors; ++ v2_descriptor.ss_descs = ss_descriptors; ++ v2_descriptor.os_header = os_desc_header; ++ v2_descriptor.os_desc = os_desc_compat; ++ v2_descriptor.os_prop_header = os_prop_header; ++ v2_descriptor.os_prop_values.guid = os_desc_guid; + + if (h->control < 0) { // might have already done this before + D("OPENING %s\n", USB_FFS_ADB_EP0); +@@ -279,10 +408,20 @@ static void init_functionfs(struct usb_handle *h) + goto err; + } + +- ret = adb_write(h->control, &descriptors, sizeof(descriptors)); ++ ret = adb_write(h->control, &v2_descriptor, sizeof(v2_descriptor)); + if (ret < 0) { +- D("[ %s: write descriptors failed: errno=%d ]\n", USB_FFS_ADB_EP0, errno); +- goto err; ++ D("[ %s: write v2_descriptor failed: errno=%d ]\n", USB_FFS_ADB_EP0, errno); ++ v1_descriptor.header.magic = cpu_to_le32(FUNCTIONFS_DESCRIPTORS_MAGIC); ++ v1_descriptor.header.length = cpu_to_le32(sizeof(v1_descriptor)); ++ v1_descriptor.header.fs_count = 3; ++ v1_descriptor.header.hs_count = 3; ++ v1_descriptor.fs_descs = fs_descriptors; ++ v1_descriptor.hs_descs = hs_descriptors; ++ ret = adb_write(h->control, &v1_descriptor, sizeof(v1_descriptor)); ++ if (ret < 0) { ++ D("[ %s: failed to write USB descriptors]\n", USB_FFS_ADB_EP0); ++ goto err; ++ } + } + + ret = adb_write(h->control, &strings, sizeof(strings)); +-- +2.18.0 + diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/core/0015-libsparse-Split-off-most-of-sparse_file_read_normal-.patch b/meta-oe/recipes-devtools/android-tools/android-tools/core/0015-libsparse-Split-off-most-of-sparse_file_read_normal-.patch new file mode 100644 index 0000000000..5009c73a05 --- /dev/null +++ b/meta-oe/recipes-devtools/android-tools/android-tools/core/0015-libsparse-Split-off-most-of-sparse_file_read_normal-.patch @@ -0,0 +1,60 @@ +From 7b74d23ed955206a789a96bdc3288593e702afac Mon Sep 17 00:00:00 2001 +From: Sean Anderson <sean.anderson@seco.com> +Date: Thu, 30 Dec 2021 15:16:08 -0500 +Subject: [PATCH] libsparse: Split off most of sparse_file_read_normal into a + helper function + +This carves out the core of sparse_file_read_normal and splits it off so +it can be reused in the next patch. No functional change intended. + +Change-Id: Id00491fd7e5bb6fa28c517a0bb32b8b506539d4d +Upstream-Status: Backport [95657f3e5976d96073f7bbfe3a49192509999d1d] +Signed-off-by: Sean Anderson <sean.anderson@seco.com> +--- + libsparse/sparse_read.c | 21 ++++++++++++++++----- + 1 file changed, 16 insertions(+), 5 deletions(-) + +diff --git a/libsparse/sparse_read.c b/libsparse/sparse_read.c +index 8e188e9a4..ee4abd86a 100644 +--- a/libsparse/sparse_read.c ++++ b/libsparse/sparse_read.c +@@ -353,13 +353,11 @@ static int sparse_file_read_sparse(struct sparse_file *s, int fd, bool crc) + return 0; + } + +-static int sparse_file_read_normal(struct sparse_file *s, int fd) ++static int do_sparse_file_read_normal(struct sparse_file *s, int fd, uint32_t* buf, int64_t offset, ++ int64_t remain) + { + int ret; +- uint32_t *buf = malloc(s->block_size); +- unsigned int block = 0; +- int64_t remain = s->len; +- int64_t offset = 0; ++ unsigned int block = offset / s->block_size; + unsigned int to_read; + unsigned int i; + bool sparse_block; +@@ -403,6 +401,19 @@ static int sparse_file_read_normal(struct sparse_file *s, int fd) + return 0; + } + ++static int sparse_file_read_normal(struct sparse_file* s, int fd) ++{ ++ int ret; ++ uint32_t* buf = (uint32_t*)malloc(s->block_size); ++ ++ if (!buf) ++ return -ENOMEM; ++ ++ ret = do_sparse_file_read_normal(s, fd, buf, 0, s->len); ++ free(buf); ++ return ret; ++} ++ + int sparse_file_read(struct sparse_file *s, int fd, bool sparse, bool crc) + { + if (crc && !sparse) { +-- +2.35.1.1320.gc452695387.dirty + diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/core/0016-libsparse-Add-hole-mode-to-sparse_file_read.patch b/meta-oe/recipes-devtools/android-tools/android-tools/core/0016-libsparse-Add-hole-mode-to-sparse_file_read.patch new file mode 100644 index 0000000000..e5221d2b4c --- /dev/null +++ b/meta-oe/recipes-devtools/android-tools/android-tools/core/0016-libsparse-Add-hole-mode-to-sparse_file_read.patch @@ -0,0 +1,188 @@ +From 41574b628ec4229c24dfe289af7b6978edcca4ed Mon Sep 17 00:00:00 2001 +From: Sean Anderson <sean.anderson@seco.com> +Date: Thu, 30 Dec 2021 15:19:41 -0500 +Subject: [PATCH] libsparse: Add "hole" mode to sparse_file_read + +This adds support for filesystem-level sparse files. These files have +holes which are not stored in the filesystem and when read are full of +zeros. While these zeros may be significant in some types of files, +other types of files may not care about the contents of holes. For +example, most filesystem creation tools write to all the blocks they +care about. Those blocks not written to will remain holes, and can be +safely represented by "don't care" chunks. Using "don't care" chunks +instead of fill chunks can result in a substantial reduction of the time +it takes to program a sparse image. + +To accomplish this, we extend the existing "sparse" boolean parameter to +be an enum of mode types. This enum represents the strategy we take when +reading in a file. For the most part the implementation is +straightforward. We use lseek to determine where the holes in the file +are, and then use do_sparse_file_read_normal to create chunks for the +data section. Note that every file has an implicit hole at its end. + +Change-Id: I0cfbf08886fca9a91cb753ec8734c84fcbe52c9f +Upstream-Status: Backport [f96466b05543b984ef7315d830bab4a409228d35] +Signed-off-by: Sean Anderson <sean.anderson@seco.com> +--- + libsparse/img2simg.c | 2 +- + libsparse/include/sparse/sparse.h | 32 +++++++++++--- + libsparse/sparse_read.c | 71 +++++++++++++++++++++++++++++-- + 3 files changed, 93 insertions(+), 12 deletions(-) + +diff --git a/libsparse/img2simg.c b/libsparse/img2simg.c +index a0db36f45..2e171b613 100644 +--- a/libsparse/img2simg.c ++++ b/libsparse/img2simg.c +@@ -96,7 +96,7 @@ int main(int argc, char *argv[]) + } + + sparse_file_verbose(s); +- ret = sparse_file_read(s, in, false, false); ++ ret = sparse_file_read(s, in, SPARSE_READ_MODE_NORMAL, false); + if (ret) { + fprintf(stderr, "Failed to read file\n"); + exit(-1); +diff --git a/libsparse/include/sparse/sparse.h b/libsparse/include/sparse/sparse.h +index 8b757d22a..b68aa21a8 100644 +--- a/libsparse/include/sparse/sparse.h ++++ b/libsparse/include/sparse/sparse.h +@@ -196,23 +196,41 @@ int64_t sparse_file_len(struct sparse_file *s, bool sparse, bool crc); + int sparse_file_callback(struct sparse_file *s, bool sparse, bool crc, + int (*write)(void *priv, const void *data, int len), void *priv); + ++/** ++ * enum sparse_read_mode - The method to use when reading in files ++ * @SPARSE_READ_MODE_NORMAL: The input is a regular file. Constant chunks of ++ * data (including holes) will be be converted to ++ * fill chunks. ++ * @SPARSE_READ_MODE_SPARSE: The input is an Android sparse file. ++ * @SPARSE_READ_MODE_HOLE: The input is a regular file. Holes will be converted ++ * to "don't care" chunks. Other constant chunks will ++ * be converted to fill chunks. ++ */ ++enum sparse_read_mode { ++ SPARSE_READ_MODE_NORMAL = false, ++ SPARSE_READ_MODE_SPARSE = true, ++ SPARSE_READ_MODE_HOLE, ++}; ++ + /** + * sparse_file_read - read a file into a sparse file cookie + * + * @s - sparse file cookie + * @fd - file descriptor to read from +- * @sparse - read a file in the Android sparse file format ++ * @mode - mode to use when reading the input file + * @crc - verify the crc of a file in the Android sparse file format + * +- * Reads a file into a sparse file cookie. If sparse is true, the file is +- * assumed to be in the Android sparse file format. If sparse is false, the +- * file will be sparsed by looking for block aligned chunks of all zeros or +- * another 32 bit value. If crc is true, the crc of the sparse file will be +- * verified. ++ * Reads a file into a sparse file cookie. If @mode is ++ * %SPARSE_READ_MODE_SPARSE, the file is assumed to be in the Android sparse ++ * file format. If @mode is %SPARSE_READ_MODE_NORMAL, the file will be sparsed ++ * by looking for block aligned chunks of all zeros or another 32 bit value. If ++ * @mode is %SPARSE_READ_MODE_HOLE, the file will be sparsed like ++ * %SPARSE_READ_MODE_NORMAL, but holes in the file will be converted to "don't ++ * care" chunks. If crc is true, the crc of the sparse file will be verified. + * + * Returns 0 on success, negative errno on error. + */ +-int sparse_file_read(struct sparse_file *s, int fd, bool sparse, bool crc); ++int sparse_file_read(struct sparse_file *s, int fd, enum sparse_read_mode mode, bool crc); + + /** + * sparse_file_import - import an existing sparse file +diff --git a/libsparse/sparse_read.c b/libsparse/sparse_read.c +index ee4abd86a..81f48cc13 100644 +--- a/libsparse/sparse_read.c ++++ b/libsparse/sparse_read.c +@@ -414,16 +414,79 @@ static int sparse_file_read_normal(struct sparse_file* s, int fd) + return ret; + } + +-int sparse_file_read(struct sparse_file *s, int fd, bool sparse, bool crc) ++#ifdef __linux__ ++static int sparse_file_read_hole(struct sparse_file* s, int fd) + { +- if (crc && !sparse) { ++ int ret; ++ uint32_t* buf = (uint32_t*)malloc(s->block_size); ++ int64_t end = 0; ++ int64_t start = 0; ++ ++ if (!buf) { ++ return -ENOMEM; ++ } ++ ++ do { ++ start = lseek(fd, end, SEEK_DATA); ++ if (start < 0) { ++ if (errno == ENXIO) ++ /* The rest of the file is a hole */ ++ break; ++ ++ error("could not seek to data"); ++ free(buf); ++ return -errno; ++ } else if (start > s->len) { ++ break; ++ } ++ ++ end = lseek(fd, start, SEEK_HOLE); ++ if (end < 0) { ++ error("could not seek to end"); ++ free(buf); ++ return -errno; ++ } ++ end = min(end, s->len); ++ ++ start = ALIGN_DOWN(start, s->block_size); ++ end = ALIGN(end, s->block_size); ++ if (lseek(fd, start, SEEK_SET) < 0) { ++ free(buf); ++ return -errno; ++ } ++ ++ ret = do_sparse_file_read_normal(s, fd, buf, start, end - start); ++ if (ret) { ++ free(buf); ++ return ret; ++ } ++ } while (end < s->len); ++ ++ free(buf); ++ return 0; ++} ++#else ++static int sparse_file_read_hole(struct sparse_file* s __unused, int fd __unused) ++{ ++ return -ENOTSUP; ++} ++#endif ++ ++int sparse_file_read(struct sparse_file *s, int fd, enum sparse_read_mode mode, bool crc) ++{ ++ if (crc && mode != SPARSE_READ_MODE_SPARSE) { + return -EINVAL; + } + +- if (sparse) { ++ switch (mode) { ++ case SPARSE_READ_MODE_SPARSE: + return sparse_file_read_sparse(s, fd, crc); +- } else { ++ case SPARSE_READ_MODE_NORMAL: + return sparse_file_read_normal(s, fd); ++ case SPARSE_READ_MODE_HOLE: ++ return sparse_file_read_hole(s, fd); ++ default: ++ return -EINVAL; + } + } + +-- +2.35.1.1320.gc452695387.dirty + diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/core/0017-img2simg-Add-support-for-converting-holes-to-don-t-c.patch b/meta-oe/recipes-devtools/android-tools/android-tools/core/0017-img2simg-Add-support-for-converting-holes-to-don-t-c.patch new file mode 100644 index 0000000000..9d19f58095 --- /dev/null +++ b/meta-oe/recipes-devtools/android-tools/android-tools/core/0017-img2simg-Add-support-for-converting-holes-to-don-t-c.patch @@ -0,0 +1,114 @@ +From 00cce57eff1a0de3b93efa5da225e9eb33d19659 Mon Sep 17 00:00:00 2001 +From: Sean Anderson <sean.anderson@seco.com> +Date: Thu, 30 Dec 2021 15:34:28 -0500 +Subject: [PATCH] img2simg: Add support for converting holes to "don't care" + chunks + +This adds support for converting files with holes to "don't care" +chunks. This can result in a substantial reduction in the time it takes +to program an image if it has many holes. + +Generally, constants compared to argc have been reduced by one, since we +no longer have the program name as the first argument. + +Change-Id: I00750edc07d6415dcc07ae0351e9397b0222b7ba +Upstream-Status: Backport [6150b00b6025918da8c28e5c2f929ecdf480a9d6] +Signed-off-by: Sean Anderson <sean.anderson@seco.com> +--- + libsparse/img2simg.c | 41 ++++++++++++++++++++++++++++++----------- + 1 file changed, 30 insertions(+), 11 deletions(-) + +diff --git a/libsparse/img2simg.c b/libsparse/img2simg.c +index 2e171b613..c985d5449 100644 +--- a/libsparse/img2simg.c ++++ b/libsparse/img2simg.c +@@ -40,25 +40,42 @@ + + void usage() + { +- fprintf(stderr, "Usage: img2simg <raw_image_file> <sparse_image_file> [<block_size>]\n"); ++ fprintf(stderr, "Usage: img2simg [-s] <raw_image_file> <sparse_image_file> [<block_size>]\n"); + } + + int main(int argc, char *argv[]) + { ++ char *arg_in; ++ char *arg_out; ++ enum sparse_read_mode mode = SPARSE_READ_MODE_NORMAL; ++ int extra; + int in; ++ int opt; + int out; + int ret; + struct sparse_file *s; + unsigned int block_size = 4096; + off64_t len; + +- if (argc < 3 || argc > 4) { ++ while ((opt = getopt(argc, argv, "s")) != -1) { ++ switch (opt) { ++ case 's': ++ mode = SPARSE_READ_MODE_HOLE; ++ break; ++ default: ++ usage(); ++ exit(-1); ++ } ++ } ++ ++ extra = argc - optind; ++ if (extra < 2 || extra > 3) { + usage(); + exit(-1); + } + +- if (argc == 4) { +- block_size = atoi(argv[3]); ++ if (extra == 3) { ++ block_size = atoi(argv[optind + 2]); + } + + if (block_size < 1024 || block_size % 4 != 0) { +@@ -66,22 +83,24 @@ int main(int argc, char *argv[]) + exit(-1); + } + +- if (strcmp(argv[1], "-") == 0) { ++ arg_in = argv[optind]; ++ if (strcmp(arg_in, "-") == 0) { + in = STDIN_FILENO; + } else { +- in = open(argv[1], O_RDONLY | O_BINARY); ++ in = open(arg_in, O_RDONLY | O_BINARY); + if (in < 0) { +- fprintf(stderr, "Cannot open input file %s\n", argv[1]); ++ fprintf(stderr, "Cannot open input file %s\n", arg_in); + exit(-1); + } + } + +- if (strcmp(argv[2], "-") == 0) { ++ arg_out = argv[optind + 1]; ++ if (strcmp(arg_out, "-") == 0) { + out = STDOUT_FILENO; + } else { +- out = open(argv[2], O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0664); ++ out = open(arg_out, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0664); + if (out < 0) { +- fprintf(stderr, "Cannot open output file %s\n", argv[2]); ++ fprintf(stderr, "Cannot open output file %s\n", arg_out); + exit(-1); + } + } +@@ -96,7 +115,7 @@ int main(int argc, char *argv[]) + } + + sparse_file_verbose(s); +- ret = sparse_file_read(s, in, SPARSE_READ_MODE_NORMAL, false); ++ ret = sparse_file_read(s, in, mode, false); + if (ret) { + fprintf(stderr, "Failed to read file\n"); + exit(-1); +-- +2.35.1.1320.gc452695387.dirty + diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/core/adb_libssl_11.diff b/meta-oe/recipes-devtools/android-tools/android-tools/core/adb_libssl_11.diff new file mode 100644 index 0000000000..ddb41ea4b0 --- /dev/null +++ b/meta-oe/recipes-devtools/android-tools/android-tools/core/adb_libssl_11.diff @@ -0,0 +1,48 @@ +Description: adb: Make compatible with openssl 1.1 + OpenSSL version 1.1 brought some API changes which broke the build here, + fix that by accessing rsa->n (and e) directly, using RSA_get0_key instead. +Author: Chirayu Desai <chirayudesai1@gmail.com +Last-Update: 2016-11-10 +--- +Upstream-Status: Pending + +This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ +--- +Upstream-Status: Pending + + system/core/adb/adb_auth_host.c | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +--- a/adb/adb_auth_host.c ++++ b/adb/adb_auth_host.c +@@ -75,6 +75,7 @@ static int RSA_to_RSAPublicKey(RSA *rsa, + BIGNUM* rem = BN_new(); +- BIGNUM* n = BN_new(); ++ const BIGNUM* n; + BIGNUM* n0inv = BN_new(); ++ const BIGNUM* e; + + if (RSA_size(rsa) != RSANUMBYTES) { + ret = 0; +@@ -82,7 +83,7 @@ static int RSA_to_RSAPublicKey(RSA *rsa, + } + + BN_set_bit(r32, 32); +- BN_copy(n, rsa->n); ++ RSA_get0_key(rsa, &n, &e, NULL); + BN_set_bit(r, RSANUMWORDS * 32); + BN_mod_sqr(rr, r, n, ctx); + BN_div(NULL, rem, n, r32, ctx); +@@ -96,11 +97,10 @@ static int RSA_to_RSAPublicKey(RSA *rsa, + BN_div(n, rem, n, r32, ctx); + pkey->n[i] = BN_get_word(rem); + } +- pkey->exponent = BN_get_word(rsa->e); ++ pkey->exponent = BN_get_word(e); + + out: + BN_free(n0inv); +- BN_free(n); + BN_free(rem); + BN_free(r); + BN_free(rr); diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/core/b64_pton_function_decl.patch b/meta-oe/recipes-devtools/android-tools/android-tools/core/b64_pton_function_decl.patch new file mode 100644 index 0000000000..80410f1d2b --- /dev/null +++ b/meta-oe/recipes-devtools/android-tools/android-tools/core/b64_pton_function_decl.patch @@ -0,0 +1,14 @@ +Add protoype declaration for b64_pton + +Upstream-Status: Pending +Signed-off-by: Khem Raj <raj.khem@gmail.com> +--- a/adb/adb_auth_client.c ++++ b/adb/adb_auth_client.c +@@ -29,6 +29,7 @@ + + #define TRACE_TAG TRACE_AUTH + ++extern int b64_pton(const char* src, uint8_t* target, size_t targsize); + + struct adb_public_key { + struct listnode node; diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/define-shell-command.patch b/meta-oe/recipes-devtools/android-tools/android-tools/define-shell-command.patch deleted file mode 100644 index 8381967c44..0000000000 --- a/meta-oe/recipes-devtools/android-tools/android-tools/define-shell-command.patch +++ /dev/null @@ -1,23 +0,0 @@ -Description: we intend to run on Linux system so the shell is always /bin/sh, - for the host or the target. -Author: Fathi Boudra <fabo@debian.org> - -Upstream-Status: Inappropriate ---- - system/core/adb/services.c | 4 ---- - 1 file changed, 4 deletions(-) - ---- a/system/core/adb/services.c -+++ b/system/core/adb/services.c -@@ -299,11 +299,7 @@ static int create_subproc_raw(const char - } - #endif /* !ABD_HOST */ - --#if ADB_HOST - #define SHELL_COMMAND "/bin/sh" --#else --#define SHELL_COMMAND "/system/bin/sh" --#endif - - #if !ADB_HOST - static void subproc_waiter_service(int fd, void *cookie) diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/extras/0001-ext4_utils-remove-selinux-extensions.patch b/meta-oe/recipes-devtools/android-tools/android-tools/extras/0001-ext4_utils-remove-selinux-extensions.patch new file mode 100644 index 0000000000..4a19a5d65a --- /dev/null +++ b/meta-oe/recipes-devtools/android-tools/android-tools/extras/0001-ext4_utils-remove-selinux-extensions.patch @@ -0,0 +1,39 @@ +From 354604da9d152f1931e91991d3f34197fc8fc759 Mon Sep 17 00:00:00 2001 +From: Sergio Schvezov <sergio.schvezov@canonical.com> +Date: Tue, 2 Oct 2018 16:36:54 +0000 +Subject: [PATCH] ext4_utils: remove selinux extensions + +* drop useless includes of Android SELINUX extensions +* avoids having to clone another module +* this should be sent upstream + +Upstream-Status: Inappropriate +--- + ext4_utils/make_ext4fs.c | 1 - + ext4_utils/make_ext4fs_main.c | 1 - + 2 files changed, 2 deletions(-) + +diff --git a/ext4_utils/make_ext4fs.c b/ext4_utils/make_ext4fs.c +index 2f89ae8a0..732afbed7 100644 +--- a/ext4_utils/make_ext4fs.c ++++ b/ext4_utils/make_ext4fs.c +@@ -62,7 +62,6 @@ + + #include <selinux/selinux.h> + #include <selinux/label.h> +-#include <selinux/android.h> + + #define O_BINARY 0 + +diff --git a/ext4_utils/make_ext4fs_main.c b/ext4_utils/make_ext4fs_main.c +index a6c5f6160..f8e7b9da9 100644 +--- a/ext4_utils/make_ext4fs_main.c ++++ b/ext4_utils/make_ext4fs_main.c +@@ -32,7 +32,6 @@ + #ifndef USE_MINGW + #include <selinux/selinux.h> + #include <selinux/label.h> +-#include <selinux/android.h> + #else + struct selabel_handle; + #endif diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/preserve-ownership.patch b/meta-oe/recipes-devtools/android-tools/android-tools/extras/0002-ext4_utils-add-o-argument-to-preserve-ownership.patch index 85af81f0f9..3b50ffbf36 100644 --- a/meta-oe/recipes-devtools/android-tools/android-tools/preserve-ownership.patch +++ b/meta-oe/recipes-devtools/android-tools/android-tools/extras/0002-ext4_utils-add-o-argument-to-preserve-ownership.patch @@ -1,19 +1,47 @@ -Description: add -o argument to preserve ownership -Author: Markus Mayer <mmayer@mmayer.net> +From b9254539811ce912bfd16dd1d185eba7a10cceff Mon Sep 17 00:00:00 2001 +From: Markus Mayer <mmayer@mmayer.net> +Date: Wed, 7 Sep 2016 12:58:47 +0300 +Subject: [PATCH] ext4_utils: add -o argument to preserve ownership See also https://android-review.googlesource.com/#/c/100312/ Upstream-Status: Inappropriate --- - system/extras/ext4_utils/make_ext4fs.c | 6 ++++++ - system/extras/ext4_utils/make_ext4fs_main.c | 10 ++++++++-- + ext4_utils/make_ext4fs.c | 6 ++++++ + ext4_utils/make_ext4fs_main.c | 10 ++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) ---- a/system/extras/ext4_utils/make_ext4fs_main.c -+++ b/system/extras/ext4_utils/make_ext4fs_main.c -@@ -49,13 +49,15 @@ extern struct fs_info info; +diff --git a/ext4_utils/make_ext4fs.c b/ext4_utils/make_ext4fs.c +index 732afbed7..2cbf04399 100644 +--- a/ext4_utils/make_ext4fs.c ++++ b/ext4_utils/make_ext4fs.c +@@ -67,6 +67,8 @@ + + #endif + ++int preserve_owner = 0; ++ + /* TODO: Not implemented: + Allocating blocks in the same block group as the file inode + Hash or binary tree directories +@@ -185,6 +187,10 @@ static u32 build_directory_structure(const char *full_path, const char *dir_path + } else { + dentries[i].mtime = fixed_time; + } ++ if (preserve_owner) { ++ dentries[i].uid = stat.st_uid; ++ dentries[i].gid = stat.st_gid; ++ } + uint64_t capabilities; + if (fs_config_func != NULL) { + #ifdef ANDROID +diff --git a/ext4_utils/make_ext4fs_main.c b/ext4_utils/make_ext4fs_main.c +index f8e7b9da9..e82d43277 100644 +--- a/ext4_utils/make_ext4fs_main.c ++++ b/ext4_utils/make_ext4fs_main.c +@@ -47,13 +47,15 @@ struct selabel_handle; + extern struct fs_info info; - extern struct selabel_handle* selinux_android_file_context_handle(void); +extern int preserve_owner; + @@ -28,7 +56,7 @@ Upstream-Status: Inappropriate fprintf(stderr, " <filename> [<directory>]\n"); } -@@ -81,7 +83,7 @@ int main(int argc, char **argv) +@@ -79,7 +81,7 @@ int main(int argc, char **argv) struct selinux_opt seopts[] = { { SELABEL_OPT_PATH, "" } }; #endif @@ -37,7 +65,7 @@ Upstream-Status: Inappropriate switch (opt) { case 'l': info.len = parse_num(optarg); -@@ -144,6 +146,10 @@ int main(int argc, char **argv) +@@ -142,6 +144,10 @@ int main(int argc, char **argv) } #endif break; @@ -48,25 +76,3 @@ Upstream-Status: Inappropriate case 'v': verbose = 1; break; ---- a/system/extras/ext4_utils/make_ext4fs.c -+++ b/system/extras/ext4_utils/make_ext4fs.c -@@ -67,6 +67,8 @@ - - #endif - -+int preserve_owner = 0; -+ - /* TODO: Not implemented: - Allocating blocks in the same block group as the file inode - Hash or binary tree directories -@@ -185,6 +187,10 @@ static u32 build_directory_structure(con - } else { - dentries[i].mtime = fixed_time; - } -+ if (preserve_owner) { -+ dentries[i].uid = stat.st_uid; -+ dentries[i].gid = stat.st_gid; -+ } - uint64_t capabilities; - if (fs_config_func != NULL) { - #ifdef ANDROID diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/.gitignore b/meta-oe/recipes-devtools/android-tools/android-tools/gitignore index b034c10a1e..b034c10a1e 100644 --- a/meta-oe/recipes-devtools/android-tools/android-tools/.gitignore +++ b/meta-oe/recipes-devtools/android-tools/android-tools/gitignore diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/implicit-declaration-function-strlcat-strlcopy.patch b/meta-oe/recipes-devtools/android-tools/android-tools/implicit-declaration-function-strlcat-strlcopy.patch deleted file mode 100644 index 64db6168c6..0000000000 --- a/meta-oe/recipes-devtools/android-tools/android-tools/implicit-declaration-function-strlcat-strlcopy.patch +++ /dev/null @@ -1,42 +0,0 @@ -Description: fix implicit declaration of stlcat/strlcopy functions. -Author: Fathi Boudra <fabo@debian.org> - -Upstream-Status: Inappropriate ---- - system/core/adb/adb.c | 1 + - system/core/fs_mgr/fs_mgr_fstab.c | 2 +- - system/core/include/cutils/sockets.h | 2 +- - 3 files changed, 3 insertions(+), 2 deletions(-) - ---- a/system/core/fs_mgr/fs_mgr_fstab.c -+++ b/system/core/fs_mgr/fs_mgr_fstab.c -@@ -17,7 +17,7 @@ - #include <ctype.h> - #include <stdio.h> - #include <stdlib.h> --#include <string.h> -+#include <bsd/string.h> - #include <sys/mount.h> - - #include "fs_mgr_priv.h" ---- a/system/core/include/cutils/sockets.h -+++ b/system/core/include/cutils/sockets.h -@@ -19,7 +19,7 @@ - - #include <errno.h> - #include <stdlib.h> --#include <string.h> -+#include <bsd/string.h> - #include <stdbool.h> - - #ifdef HAVE_WINSOCK ---- a/system/core/adb/adb.c -+++ b/system/core/adb/adb.c -@@ -41,6 +41,7 @@ - #include <sys/prctl.h> - #include <getopt.h> - #include <selinux/selinux.h> -+#include <grp.h> - #else - #include "usb_vendors.h" - #endif diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/libselinux/0001-Remove-bionic-specific-calls.patch b/meta-oe/recipes-devtools/android-tools/android-tools/libselinux/0001-Remove-bionic-specific-calls.patch new file mode 100644 index 0000000000..9de2593df8 --- /dev/null +++ b/meta-oe/recipes-devtools/android-tools/android-tools/libselinux/0001-Remove-bionic-specific-calls.patch @@ -0,0 +1,25 @@ +From 36654a4484117e5f4d63a810c0d94bc9c7ee3a83 Mon Sep 17 00:00:00 2001 +From: Fathi Boudra <fabo@debian.org> +Date: Tue, 2 Oct 2018 16:36:54 +0000 +Subject: [PATCH] Remove bionic specific calls + +Upstream-Status: Inappropriate + +Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com> +--- + src/procattr.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/procattr.c b/src/procattr.c +index f350808..761cf8e 100644 +--- a/src/procattr.c ++++ b/src/procattr.c +@@ -8,7 +8,7 @@ + #include "selinux_internal.h" + #include "policy.h" + +-#ifdef HOST ++#ifndef __BIONIC__ + static pid_t gettid(void) + { + return syscall(__NR_gettid); diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/libselinux/0001-libselinux-Do-not-define-gettid-if-glibc-2.30-is-use.patch b/meta-oe/recipes-devtools/android-tools/android-tools/libselinux/0001-libselinux-Do-not-define-gettid-if-glibc-2.30-is-use.patch new file mode 100644 index 0000000000..8b5e4cf999 --- /dev/null +++ b/meta-oe/recipes-devtools/android-tools/android-tools/libselinux/0001-libselinux-Do-not-define-gettid-if-glibc-2.30-is-use.patch @@ -0,0 +1,51 @@ +From f4f9d24860e1b5cd4f6a014f3fda7cd33ebe5be7 Mon Sep 17 00:00:00 2001 +From: Petr Lautrbach <plautrba@redhat.com> +Date: Sat, 27 Jul 2019 08:20:20 -0700 +Subject: [PATCH] libselinux: Do not define gettid() if glibc >= 2.30 is used +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Since version 2.30 glibc implements gettid() system call wrapper, see +https://sourceware.org/bugzilla/show_bug.cgi?id=6399 + +Fixes: +cc -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -I../include -D_GNU_SOURCE -DNO_ANDROID_BACKEND -c -o procattr.o procattr.c +procattr.c:28:14: error: static declaration of ‘gettid’ follows non-static declaration + 28 | static pid_t gettid(void) + | ^~~~~~ +In file included from /usr/include/unistd.h:1170, + from procattr.c:2: +/usr/include/bits/unistd_ext.h:34:16: note: previous declaration of ‘gettid’ was here + 34 | extern __pid_t gettid (void) __THROW; + | ^~~~~~ + +Signed-off-by: Petr Lautrbach <plautrba@redhat.com> +Acked-by: Stephen Smalley <sds@tycho.nsa.gov> +Signed-off-by: Khem Raj <raj.khem@gmail.com> +--- +Upstream-Status: Pending + + src/procattr.c | 14 +++++++++++++- + 1 file changed, 13 insertions(+), 1 deletion(-) + +--- a/src/procattr.c ++++ b/src/procattr.c +@@ -8,12 +8,16 @@ + #include "selinux_internal.h" + #include "policy.h" + +-#ifndef __BIONIC__ ++/* Bionic and glibc >= 2.30 declare gettid() system call wrapper in unistd.h and ++ * has a definition for it */ ++#if defined(__GLIBC_) ++#if !__GLIBC_PREREQ(2,30) + static pid_t gettid(void) + { + return syscall(__NR_gettid); + } + #endif ++#endif + + static int getprocattrcon(char ** context, + pid_t pid, const char *attr) diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/remove-selinux-android.patch b/meta-oe/recipes-devtools/android-tools/android-tools/remove-selinux-android.patch deleted file mode 100644 index d4a37f82be..0000000000 --- a/meta-oe/recipes-devtools/android-tools/android-tools/remove-selinux-android.patch +++ /dev/null @@ -1,56 +0,0 @@ -Subject: drop useless includes of Android SELINUX extensions; avoids having to clone another module; this should be sent upstream -Author: Sergio Schvezov <sergio.schvezov@canonical.com> - -Upstream-Status: Inappropriate ---- - system/core/adb/file_sync_service.c | 3 --- - system/extras/ext4_utils/make_ext4fs.c | 1 - - system/extras/ext4_utils/make_ext4fs_main.c | 1 - - 3 files changed, 5 deletions(-) - ---- a/system/extras/ext4_utils/make_ext4fs.c -+++ b/system/extras/ext4_utils/make_ext4fs.c -@@ -62,7 +62,6 @@ - - #include <selinux/selinux.h> - #include <selinux/label.h> --#include <selinux/android.h> - - #define O_BINARY 0 - ---- a/system/extras/ext4_utils/make_ext4fs_main.c -+++ b/system/extras/ext4_utils/make_ext4fs_main.c -@@ -32,7 +32,6 @@ - #ifndef USE_MINGW - #include <selinux/selinux.h> - #include <selinux/label.h> --#include <selinux/android.h> - #else - struct selabel_handle; - #endif ---- a/system/core/adb/file_sync_service.c -+++ b/system/core/adb/file_sync_service.c -@@ -26,7 +26,6 @@ - - #include <errno.h> - #include <private/android_filesystem_config.h> --#include <selinux/android.h> - #include "sysdeps.h" - - #define TRACE_TAG TRACE_SYNC -@@ -73,7 +72,6 @@ static int mkdirs(char *name) - *x = '/'; - return ret; - } -- selinux_android_restorecon(name, 0); - } - *x++ = '/'; - } -@@ -251,7 +249,6 @@ static int handle_send_file(int s, char - if(fd >= 0) { - struct utimbuf u; - adb_close(fd); -- selinux_android_restorecon(path, 0); - u.actime = timestamp; - u.modtime = timestamp; - utime(path, &u); diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/use-capability.patch b/meta-oe/recipes-devtools/android-tools/android-tools/use-capability.patch deleted file mode 100644 index b8ebe09dc0..0000000000 --- a/meta-oe/recipes-devtools/android-tools/android-tools/use-capability.patch +++ /dev/null @@ -1,19 +0,0 @@ -Subject: use linux/capability.h on linux systems too -Author: Loïc Minier <loic.minier@ubuntu.com> - -Upstream-Status: Inappropriate ---- - system/core/include/private/android_filesystem_config.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - ---- a/system/core/include/private/android_filesystem_config.h -+++ b/system/core/include/private/android_filesystem_config.h -@@ -27,7 +27,7 @@ - #include <sys/types.h> - #include <stdint.h> - --#ifdef HAVE_ANDROID_OS -+#if defined(HAVE_ANDROID_OS) || defined(__linux__) - #include <linux/capability.h> - #else - #include "android_filesystem_capability.h" |