android-tools 10: port some patches from version 5

Signed-off-by: Khem Raj <raj.khem@gmail.com>
This commit is contained in:
Etienne Cordonnier
2023-03-14 14:05:33 +01:00
committed by Khem Raj
parent b65453d5bc
commit 545c524c11
3 changed files with 77 additions and 0 deletions
@@ -0,0 +1,50 @@
From f9fe8163cd759c21dd5ec0711b56dccd79ff1c4a Mon Sep 17 00:00:00 2001
From: Etienne Cordonnier <ecordonnier@snap.com>
Date: Tue, 14 Mar 2023 13:39:23 +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
when initializing structures, i.e in a context where a function call
is not allowed.
It works fine on little endian systems because htole16/32 are defined
by the C library as no-ops. But on big-endian systems, they are
actually doing something, which might involve calling a function,
causing build failures.
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>
[Forward-ported to version 10]
Signed-off-by: Etienne Cordonnier <ecordonnier@snap.com>
---
adb/daemon/usb_ffs.cpp | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/adb/daemon/usb_ffs.cpp b/adb/daemon/usb_ffs.cpp
index 07b4ba89..25f30352 100644
--- a/adb/daemon/usb_ffs.cpp
+++ b/adb/daemon/usb_ffs.cpp
@@ -37,8 +37,15 @@
// Number of buffers needed to fit MAX_PAYLOAD, with an extra for ZLPs.
#define USB_FFS_NUM_BUFS ((4 * MAX_PAYLOAD / USB_FFS_BULK_SIZE) + 1)
-#define cpu_to_le16(x) htole16(x)
-#define cpu_to_le32(x) htole32(x)
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+# define cpu_to_le16(x) (x)
+# define cpu_to_le32(x) (x)
+#else
+# define cpu_to_le16(x) ((((x) >> 8) & 0xffu) | (((x) & 0xffu) << 8))
+# define cpu_to_le32(x) \
+ ((((x) & 0xff000000u) >> 24) | (((x) & 0x00ff0000u) >> 8) | \
+ (((x) & 0x0000ff00u) << 8) | (((x) & 0x000000ffu) << 24))
+#endif
struct func_desc {
struct usb_interface_descriptor intf;
--
2.36.1.vfs.0.0
@@ -0,0 +1,25 @@
From 0bc94c83b9d846416613f9c8831cae6caf1713e5 Mon Sep 17 00:00:00 2001
From: Etienne Cordonnier <ecordonnier@snap.com>
Date: Tue, 14 Mar 2023 13:53:51 +0100
Subject: [PATCH] adb: Allow adbd to be run as root
Signed-off-by: Etienne Cordonnier <ecordonnier@snap.com>
---
adb/daemon/main.cpp | 1 +
1 file changed, 1 insertion(+)
diff --git a/adb/daemon/main.cpp b/adb/daemon/main.cpp
index c75263c4..d27f6996 100644
--- a/adb/daemon/main.cpp
+++ b/adb/daemon/main.cpp
@@ -72,6 +72,7 @@ static bool should_drop_capabilities_bounding_set() {
}
static bool should_drop_privileges() {
+ return true;
// "adb root" not allowed, always drop privileges.
if (!ALLOW_ADBD_ROOT && !is_device_unlocked()) return true;
--
2.36.1.vfs.0.0
@@ -79,6 +79,8 @@ SRC_URI += " \
file://core/0017-Update-usage-of-usbdevfs_urb-to-match-new-kernel-UAP.patch;patchdir=system/core \
file://core/0018-img2simg-Fix-wrong-rpath.patch;patchdir=system/core \
file://core/0019-Fix-compilation-with-gcc.patch;patchdir=system/core \
file://core/0020-adb-Fix-build-on-big-endian-systems.patch;patchdir=system/core \
file://core/0021-adb-Allow-adbd-to-be-run-as-root.patch;patchdir=system/core \
file://0001-libcrypto.mk-modifications-to-make-it-build-in-yocto.patch;patchdir=external/boringssl \
file://0001-patching-libundwind-to-build-in-yocto-environment.patch;patchdir=external/libunwind \
file://0001-libext4_utils.mk-modifications-to-make-it-build-in-y.patch;patchdir=system/extras \