() diff --git a/devel/android-tools/files/patch-vendor_CMakeLists.txt b/devel/android-tools/files/patch-vendor_CMakeLists.txt new file mode 100644 index 000000000000..b1c5d6898cee --- /dev/null +++ b/devel/android-tools/files/patch-vendor_CMakeLists.txt @@ -0,0 +1,18 @@ +--- vendor/CMakeLists.txt 2024-08-29 19:46:57.000000000 +0200 ++++ vendor/CMakeLists.txt 2026-03-21 14:09:16.768573000 +0100 +@@ -41,6 +41,15 @@ + # 32-bit glibc platforms this is not the case by default. + add_compile_definitions(_FILE_OFFSET_BITS=64 _LARGEFILE64_SOURCE) + ++# On FreeBSD, _XOPEN_SOURCE (used by some sub-targets) hides BSD extensions ++# like getprogname(). Ensure BSD visibility is preserved. ++# Also provide compat macros for 64-bit functions that don't exist on FreeBSD ++# (off_t is always 64-bit on FreeBSD). ++if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") ++ add_compile_definitions(__BSD_VISIBLE=1) ++ add_compile_definitions(lseek64=lseek ftruncate64=ftruncate mmap64=mmap pread64=pread pwrite64=pwrite off64_t=off_t) ++endif() ++ + set(android-vendored + avb + adb diff --git a/devel/android-tools/files/patch-vendor_adb_client_file__sync__client.cpp b/devel/android-tools/files/patch-vendor_adb_client_file__sync__client.cpp deleted file mode 100644 index 4883dd619897..000000000000 --- a/devel/android-tools/files/patch-vendor_adb_client_file__sync__client.cpp +++ /dev/null @@ -1,37 +0,0 @@ ---- vendor/adb/client/file_sync_client.cpp.orig 2022-06-09 20:52:06 UTC -+++ vendor/adb/client/file_sync_client.cpp -@@ -394,9 +394,16 @@ class SyncConnection { - - void* p = buf.data(); - -+#ifdef __FreeBSD__ -+ // TODO: Delete when 12.x goes EOL -+ p = (char *)memcpy(p, &req, sizeof(SyncRequest)) + sizeof(SyncRequest); -+ p = (char *)memcpy(p, path.data(), path.length()) + path.length(); -+ p = (char *)memcpy(p, &msg.send_v2_setup, sizeof(msg.send_v2_setup)) + sizeof(msg.send_v2_setup); -+#else - p = mempcpy(p, &req, sizeof(SyncRequest)); - p = mempcpy(p, path.data(), path.length()); - p = mempcpy(p, &msg.send_v2_setup, sizeof(msg.send_v2_setup)); -+#endif - - return WriteFdExactly(fd, buf.data(), buf.size()); - } -@@ -441,9 +448,16 @@ class SyncConnection { - - void* p = buf.data(); - -+#ifdef __FreeBSD__ -+ // TODO: Delete when 12.x goes EOL -+ p = (char *)memcpy(p, &req, sizeof(SyncRequest)) + sizeof(SyncRequest); -+ p = (char *)memcpy(p, path.data(), path.length()) + path.length(); -+ p = (char *)memcpy(p, &msg.send_v2_setup, sizeof(msg.send_v2_setup)) + sizeof(msg.send_v2_setup); -+#else - p = mempcpy(p, &req, sizeof(SyncRequest)); - p = mempcpy(p, path.data(), path.length()); -- p = mempcpy(p, &msg.recv_v2_setup, sizeof(msg.recv_v2_setup)); -+ p = mempcpy(p, &msg.send_v2_setup, sizeof(msg.send_v2_setup)); -+#endif - - return WriteFdExactly(fd, buf.data(), buf.size()); - } diff --git a/devel/android-tools/files/patch-vendor_adb_client_usb_freebsd.cpp b/devel/android-tools/files/patch-vendor_adb_client_usb_freebsd.cpp new file mode 100644 index 000000000000..70b7adcea38b --- /dev/null +++ b/devel/android-tools/files/patch-vendor_adb_client_usb_freebsd.cpp @@ -0,0 +1,66 @@ +--- vendor/adb/client/usb_freebsd.cpp 1970-01-01 01:00:00.000000000 +0100 ++++ vendor/adb/client/usb_freebsd.cpp 2026-03-21 19:23:46.144092000 +0100 +@@ -0,0 +1,63 @@ ++/* ++ * Copyright (C) 2026 Baptiste Daroussin ++ * ++ * 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. ++ */ ++ ++/* ++ * On FreeBSD, the libusb backend (usb_libusb.cpp) is always used for USB ++ * device communication via LibusbConnection. These stub implementations of ++ * the native USB interface satisfy the linker for UsbConnection, which is ++ * only used on Linux and macOS. ++ */ ++ ++#include "client/usb.h" ++ ++void usb_init() { ++} ++ ++void usb_cleanup() { ++} ++ ++int usb_write(usb_handle*, const void*, int) { ++ return -1; ++} ++ ++int usb_read(usb_handle*, void*, int) { ++ return -1; ++} ++ ++int usb_close(usb_handle*) { ++ return -1; ++} ++ ++void usb_reset(usb_handle*) { ++} ++ ++void usb_kick(usb_handle*) { ++} ++ ++size_t usb_get_max_packet_size(usb_handle*) { ++ return 0; ++} diff --git a/devel/android-tools/files/patch-vendor_adb_client_usb_libusb.cpp b/devel/android-tools/files/patch-vendor_adb_client_usb_libusb.cpp new file mode 100644 index 000000000000..948f55ad3ae1 --- /dev/null +++ b/devel/android-tools/files/patch-vendor_adb_client_usb_libusb.cpp @@ -0,0 +1,54 @@ +--- vendor/adb/client/usb_libusb.cpp 2024-08-29 19:46:57.000000000 +0200 ++++ vendor/adb/client/usb_libusb.cpp 2026-03-21 14:00:02.239458000 +0100 +@@ -38,6 +38,8 @@ + + #ifdef ANDROID_TOOLS_USE_BUNDLED_LIBUSB + #include ++#elif defined(__FreeBSD__) ++#include + #else + #include + #endif +@@ -507,8 +509,10 @@ + return 5000; + case LIBUSB_SPEED_SUPER_PLUS: + return 10000; ++#ifdef LIBUSB_SPEED_SUPER_PLUS_X2 + case LIBUSB_SPEED_SUPER_PLUS_X2: + return 20000; ++#endif + case LIBUSB_SPEED_UNKNOWN: + default: + return 0; +@@ -540,6 +544,7 @@ + } + } + ++#ifdef LIBUSB_BT_SUPERSPEED_PLUS_CAPABILITY + static uint64_t ExtractMaxSuperSpeedPlus(libusb_ssplus_usb_device_capability_descriptor* cap) { + // The exponents is one of {bytes, kB, MB, or GB}. We express speed in MB so we use a 0 + // multiplier for value which would result in 0MB anyway. +@@ -552,6 +557,7 @@ + } + return max_speed; + } ++#endif + + void RetrieveSpeeds() { + negotiated_speed_ = ToConnectionSpeed(libusb_get_device_speed(device_.get())); +@@ -574,6 +580,7 @@ + libusb_free_ss_usb_device_capability_descriptor(cap); + } + } break; ++#ifdef LIBUSB_BT_SUPERSPEED_PLUS_CAPABILITY + case LIBUSB_BT_SUPERSPEED_PLUS_CAPABILITY: { + libusb_ssplus_usb_device_capability_descriptor* cap = nullptr; + if (!libusb_get_ssplus_usb_device_capability_descriptor( +@@ -582,6 +589,7 @@ + libusb_free_ssplus_usb_device_capability_descriptor(cap); + } + } break; ++#endif + default: + break; + } diff --git a/devel/android-tools/files/patch-vendor_adb_sysdeps.h b/devel/android-tools/files/patch-vendor_adb_sysdeps.h new file mode 100644 index 000000000000..2b73787a78be --- /dev/null +++ b/devel/android-tools/files/patch-vendor_adb_sysdeps.h @@ -0,0 +1,29 @@ +--- vendor/adb/sysdeps.h 2024-08-29 19:46:57.000000000 +0200 ++++ vendor/adb/sysdeps.h 2026-03-21 13:49:16.038468000 +0100 +@@ -526,7 +526,7 @@ + } + + static inline int adb_pread(borrowed_fd fd, void* buf, size_t len, off64_t offset) { +-#if defined(__APPLE__) ++#if defined(__APPLE__) || defined(__FreeBSD__) + return TEMP_FAILURE_RETRY(pread(fd.get(), buf, len, offset)); + #else + return TEMP_FAILURE_RETRY(pread64(fd.get(), buf, len, offset)); +@@ -548,7 +548,7 @@ + } + + static inline int adb_pwrite(int fd, const void* buf, size_t len, off64_t offset) { +-#if defined(__APPLE__) ++#if defined(__APPLE__) || defined(__FreeBSD__) + return TEMP_FAILURE_RETRY(pwrite(fd, buf, len, offset)); + #else + return TEMP_FAILURE_RETRY(pwrite64(fd, buf, len, offset)); +@@ -563,7 +563,7 @@ + #define pwrite ___xxx_pwrite + + static inline int64_t adb_lseek(borrowed_fd fd, int64_t pos, int where) { +-#if defined(__APPLE__) ++#if defined(__APPLE__) || defined(__FreeBSD__) + return lseek(fd.get(), pos, where); + #else + return lseek64(fd.get(), pos, where); diff --git a/devel/android-tools/files/patch-vendor_adb_tls_include_adb_tls_tls__connection.h b/devel/android-tools/files/patch-vendor_adb_tls_include_adb_tls_tls__connection.h deleted file mode 100644 index afc4ed589316..000000000000 --- a/devel/android-tools/files/patch-vendor_adb_tls_include_adb_tls_tls__connection.h +++ /dev/null @@ -1,10 +0,0 @@ ---- vendor/adb/tls/include/adb/tls/tls_connection.h.orig 2024-02-11 15:40:31 UTC -+++ vendor/adb/tls/include/adb/tls/tls_connection.h -@@ -21,6 +21,7 @@ - - #include - #include -+#include - - #include - #include diff --git a/devel/android-tools/files/patch-vendor_boringssl_crypto_x509_t__x509.c b/devel/android-tools/files/patch-vendor_boringssl_crypto_x509_t__x509.c deleted file mode 100644 index d860df822689..000000000000 --- a/devel/android-tools/files/patch-vendor_boringssl_crypto_x509_t__x509.c +++ /dev/null @@ -1,45 +0,0 @@ -https://github.com/google/boringssl/commit/af34f6460f0bf99dc267818f02b2936f60a30de7 - -From af34f6460f0bf99dc267818f02b2936f60a30de7 Mon Sep 17 00:00:00 2001 -From: Kent Ross -Date: Wed, 30 Mar 2022 14:11:02 -0700 -Subject: [PATCH] Remove unused variable - -This is causing -Werror failures with recent Clang builds. - -Change-Id: I0f82d99ae51d02037f5f614a8fadfb3efc0da2da -Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/52145 -Reviewed-by: Adam Langley -Commit-Queue: Adam Langley ---- - crypto/x509/t_x509.c | 6 +----- - 1 file changed, 1 insertion(+), 5 deletions(-) - -diff --git a/crypto/x509/t_x509.c b/crypto/x509/t_x509.c -index 4f9d40979a..5e633a9d87 100644 ---- vendor/boringssl/crypto/x509/t_x509.c -+++ vendor/boringssl/crypto/x509/t_x509.c -@@ -322,9 +322,7 @@ int X509_signature_print(BIO *bp, const X509_ALGOR *sigalg, - int X509_NAME_print(BIO *bp, const X509_NAME *name, int obase) - { - char *s, *c, *b; -- int ret = 0, l, i; -- -- l = 80 - 2 - obase; -+ int ret = 0, i; - - b = X509_NAME_oneline(name, NULL, 0); - if (!b) -@@ -351,12 +349,10 @@ int X509_NAME_print(BIO *bp, const X509_NAME *name, int obase) - if (BIO_write(bp, ", ", 2) != 2) - goto err; - } -- l--; - } - if (*s == '\0') - break; - s++; -- l--; - } - - ret = 1; diff --git a/devel/android-tools/files/patch-vendor_core_fastboot_usb_freebsd.cpp b/devel/android-tools/files/patch-vendor_core_fastboot_usb_freebsd.cpp new file mode 100644 index 000000000000..a9e7c0f12d70 --- /dev/null +++ b/devel/android-tools/files/patch-vendor_core_fastboot_usb_freebsd.cpp @@ -0,0 +1,257 @@ +--- vendor/core/fastboot/usb_freebsd.cpp 1970-01-01 01:00:00.000000000 +0100 ++++ vendor/core/fastboot/usb_freebsd.cpp 2026-03-21 19:36:02.025480000 +0100 +@@ -0,0 +1,254 @@ ++/* ++ * Copyright (C) 2026 Baptiste Daroussin ++ * ++ * 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. ++ */ ++ ++#include ++#include ++#include ++#include ++ ++#include ++ ++#include "usb.h" ++ ++using namespace std::chrono_literals; ++ ++#define MAX_RETRIES 2 ++#define MAX_BULK_TRANSFER_SIZE (16 * 1024) ++ ++static libusb_context *usb_context = nullptr; ++ ++struct usb_handle { ++ libusb_device_handle *devh; ++ uint8_t ep_in; ++ uint8_t ep_out; ++ uint8_t iface; ++}; ++ ++class FreeBSDUsbTransport : public UsbTransport { ++ public: ++ FreeBSDUsbTransport(std::unique_ptr handle, uint32_t ms_timeout = 0) ++ : handle_(std::move(handle)), ms_timeout_(ms_timeout) {} ++ ~FreeBSDUsbTransport() override; ++ ++ ssize_t Read(void* data, size_t len) override; ++ ssize_t Write(const void* data, size_t len) override; ++ int Close() override; ++ int Reset() override; ++ ++ private: ++ std::unique_ptr handle_; ++ const uint32_t ms_timeout_; ++}; ++ ++FreeBSDUsbTransport::~FreeBSDUsbTransport() { ++ Close(); ++} ++ ++ssize_t FreeBSDUsbTransport::Read(void* data, size_t len) { ++ unsigned char *buf = static_cast(data); ++ ssize_t total = 0; ++ ++ if (!handle_ || !handle_->devh || handle_->ep_in == 0) { ++ return -1; ++ } ++ ++ while (len > 0) { ++ int xfer = (len > MAX_BULK_TRANSFER_SIZE) ? MAX_BULK_TRANSFER_SIZE : len; ++ int transferred = 0; ++ int retry = 0; ++ int rc; ++ ++ do { ++ rc = libusb_bulk_transfer(handle_->devh, handle_->ep_in, ++ buf, xfer, &transferred, ++ ms_timeout_ ? ms_timeout_ : 0); ++ if (rc == LIBUSB_ERROR_TIMEOUT) { ++ if (++retry > MAX_RETRIES) return -1; ++ std::this_thread::sleep_for(100ms); ++ } else if (rc != 0) { ++ return -1; ++ } ++ } while (rc != 0); ++ ++ total += transferred; ++ len -= transferred; ++ buf += transferred; ++ ++ if (transferred < xfer) break; ++ } ++ ++ return total; ++} ++ ++ssize_t FreeBSDUsbTransport::Write(const void* data, size_t len) { ++ const unsigned char *buf = static_cast(data); ++ ssize_t total = 0; ++ ++ if (!handle_ || !handle_->devh || handle_->ep_out == 0) { ++ return -1; ++ } ++ ++ while (len > 0) { ++ int xfer = (len > MAX_BULK_TRANSFER_SIZE) ? MAX_BULK_TRANSFER_SIZE : len; ++ int transferred = 0; ++ ++ int rc = libusb_bulk_transfer(handle_->devh, handle_->ep_out, ++ const_cast(buf), ++ xfer, &transferred, ++ ms_timeout_ ? ms_timeout_ : 0); ++ if (rc != 0) return -1; ++ ++ total += transferred; ++ len -= transferred; ++ buf += transferred; ++ } ++ ++ return total; ++} ++ ++int FreeBSDUsbTransport::Close() { ++ if (handle_ && handle_->devh) { ++ libusb_release_interface(handle_->devh, handle_->iface); ++ libusb_close(handle_->devh); ++ handle_->devh = nullptr; ++ } ++ return 0; ++} ++ ++int FreeBSDUsbTransport::Reset() { ++ if (!handle_ || !handle_->devh) return -1; ++ return libusb_reset_device(handle_->devh); ++} ++ ++static std::unique_ptr find_usb_device(ifc_match_func callback) { ++ libusb_device **devs; ++ ssize_t cnt = libusb_get_device_list(usb_context, &devs); ++ if (cnt < 0) return nullptr; ++ ++ std::unique_ptr result; ++ ++ for (ssize_t i = 0; i < cnt && !result; i++) { ++ libusb_device *dev = devs[i]; ++ struct libusb_device_descriptor desc; ++ ++ if (libusb_get_device_descriptor(dev, &desc) != 0) continue; ++ ++ struct libusb_config_descriptor *config; ++ if (libusb_get_active_config_descriptor(dev, &config) != 0) { ++ if (libusb_get_config_descriptor(dev, 0, &config) != 0) continue; ++ } ++ ++ for (int j = 0; j < config->bNumInterfaces && !result; j++) { ++ const struct libusb_interface *iface = &config->interface[j]; ++ for (int k = 0; k < iface->num_altsetting && !result; k++) { ++ const struct libusb_interface_descriptor *altsetting = &iface->altsetting[k]; ++ ++ usb_ifc_info info = {}; ++ info.dev_vendor = desc.idVendor; ++ info.dev_product = desc.idProduct; ++ info.dev_class = desc.bDeviceClass; ++ info.dev_subclass = desc.bDeviceSubClass; ++ info.dev_protocol = desc.bDeviceProtocol; ++ info.ifc_class = altsetting->bInterfaceClass; ++ info.ifc_subclass = altsetting->bInterfaceSubClass; ++ info.ifc_protocol = altsetting->bInterfaceProtocol; ++ info.writable = 1; ++ ++ uint8_t ep_in = 0, ep_out = 0; ++ for (int e = 0; e < altsetting->bNumEndpoints; e++) { ++ const struct libusb_endpoint_descriptor *ep = &altsetting->endpoint[e]; ++ if ((ep->bmAttributes & LIBUSB_TRANSFER_TYPE_MASK) != LIBUSB_TRANSFER_TYPE_BULK) ++ continue; ++ if (ep->bEndpointAddress & LIBUSB_ENDPOINT_IN) { ++ ep_in = ep->bEndpointAddress; ++ } else { ++ ep_out = ep->bEndpointAddress; ++ } ++ } ++ ++ info.has_bulk_in = (ep_in != 0); ++ info.has_bulk_out = (ep_out != 0); ++ ++ snprintf(info.device_path, sizeof(info.device_path), ++ "usb:%d:%d", libusb_get_bus_number(dev), ++ libusb_get_device_address(dev)); ++ ++ /* ++ * Open device once, read serial, then decide whether to ++ * keep it based on callback result. ++ */ ++ libusb_device_handle *devh; ++ int rc = libusb_open(dev, &devh); ++ if (rc != 0) continue; ++ ++ /* Detach kernel driver (ugen) before any operations */ ++ libusb_set_auto_detach_kernel_driver(devh, 1); ++ ++ info.serial_number[0] = '\0'; ++ if (desc.iSerialNumber) { ++ libusb_get_string_descriptor_ascii( ++ devh, desc.iSerialNumber, ++ (unsigned char *)info.serial_number, ++ sizeof(info.serial_number)); ++ } ++ ++ info.interface[0] = '\0'; ++ ++ if (callback(&info) == 0) { ++ rc = libusb_claim_interface(devh, altsetting->bInterfaceNumber); ++ if (rc != 0) { ++ libusb_close(devh); ++ continue; ++ } ++ ++ result = std::make_unique(); ++ result->devh = devh; ++ result->ep_in = ep_in; ++ result->ep_out = ep_out; ++ result->iface = altsetting->bInterfaceNumber; ++ } else { ++ libusb_close(devh); ++ } ++ } ++ } ++ libusb_free_config_descriptor(config); ++ } ++ ++ libusb_free_device_list(devs, 1); ++ return result; ++} ++ ++std::unique_ptr usb_open(ifc_match_func callback, uint32_t timeout_ms) { ++ if (!usb_context) { ++ if (libusb_init(&usb_context) != 0) return nullptr; ++ } ++ ++ auto handle = find_usb_device(callback); ++ if (!handle) return nullptr; ++ ++ return std::make_unique(std::move(handle), timeout_ms); ++} diff --git a/devel/android-tools/files/patch-vendor_core_libcutils_include_private_fs_config.h b/devel/android-tools/files/patch-vendor_core_libcutils_include_private_fs_config.h new file mode 100644 index 000000000000..96837297946c --- /dev/null +++ b/devel/android-tools/files/patch-vendor_core_libcutils_include_private_fs_config.h @@ -0,0 +1,23 @@ +--- vendor/core/libcutils/include/private/fs_config.h 2024-08-29 19:46:57.000000000 +0200 ++++ vendor/core/libcutils/include/private/fs_config.h 2026-03-21 13:54:46.886972000 +0100 +@@ -26,7 +26,20 @@ + #include + #include + ++#ifdef __linux__ + #include ++#else ++/* Provide Linux capability constants for non-Linux platforms. */ ++#ifndef CAP_SETGID ++#define CAP_SETGID 6 ++#endif ++#ifndef CAP_SETUID ++#define CAP_SETUID 7 ++#endif ++#ifndef CAP_BLOCK_SUSPEND ++#define CAP_BLOCK_SUSPEND 36 ++#endif ++#endif + + /* Rules for directories and files has moved to system/code/libcutils/fs_config.c */ + diff --git a/devel/android-tools/files/patch-vendor_e2fsprogs_contrib_android_perms.c b/devel/android-tools/files/patch-vendor_e2fsprogs_contrib_android_perms.c new file mode 100644 index 000000000000..64014af8eed5 --- /dev/null +++ b/devel/android-tools/files/patch-vendor_e2fsprogs_contrib_android_perms.c @@ -0,0 +1,25 @@ +--- vendor/e2fsprogs/contrib/android/perms.c 2024-08-29 19:46:57.000000000 +0200 ++++ vendor/e2fsprogs/contrib/android/perms.c 2026-03-21 14:11:37.709049000 +0100 +@@ -6,6 +6,22 @@ + #include "support/nls-enable.h" + #include + #include ++ ++#ifdef __FreeBSD__ ++#ifndef VFS_CAP_REVISION_2 ++#define VFS_CAP_REVISION_2 0x02000002 ++#endif ++#ifndef VFS_CAP_FLAGS_EFFECTIVE ++#define VFS_CAP_FLAGS_EFFECTIVE 0x000001 ++#endif ++struct vfs_cap_data { ++ __le32 magic_etc; ++ struct { ++ __le32 permitted; ++ __le32 inheritable; ++ } data[2]; ++}; ++#endif + + #ifndef XATTR_SELINUX_SUFFIX + # define XATTR_SELINUX_SUFFIX "selinux" diff --git a/devel/android-tools/files/patch-vendor_e2fsprogs_lib_config.h b/devel/android-tools/files/patch-vendor_e2fsprogs_lib_config.h new file mode 100644 index 000000000000..371734116048 --- /dev/null +++ b/devel/android-tools/files/patch-vendor_e2fsprogs_lib_config.h @@ -0,0 +1,29 @@ +--- vendor/e2fsprogs/lib/config.h 2024-08-29 19:46:57.000000000 +0200 ++++ vendor/e2fsprogs/lib/config.h 2026-03-21 14:07:51.522475000 +0100 +@@ -28,7 +28,7 @@ + #define HAVE_UTIME_H 1 + + #define HAVE_SYS_STAT_H 1 +-#if !defined(__APPLE__) ++#if !defined(__APPLE__) && !defined(__FreeBSD__) + # define HAVE_SYS_SYSMACROS_H 1 + #endif + #define HAVE_SYS_TIME_H 1 +@@ -37,7 +37,7 @@ + #if defined(_WIN32) + # define HAVE_LINUX_TYPES_H 1 + #endif +-#if defined(__APPLE__) || defined(__linux__) ++#if defined(__APPLE__) || defined(__linux__) || defined(__FreeBSD__) + # define HAVE_FCNTL 1 + # define HAVE_FSYNC 1 + # define HAVE_GETPAGESIZE 1 +@@ -54,7 +54,7 @@ + # define HAVE_SYS_SELECT_H 1 + # define HAVE_SYS_WAIT_H 1 + #endif +-#ifdef __APPLE__ ++#if defined(__APPLE__) || defined(__FreeBSD__) + # define HAVE_GETMNTINFO 1 + #endif + #if defined(__linux__) diff --git a/devel/android-tools/files/patch-vendor_f2fs-tools_fsck_xattr.c b/devel/android-tools/files/patch-vendor_f2fs-tools_fsck_xattr.c new file mode 100644 index 000000000000..44c1dd4f0ccf --- /dev/null +++ b/devel/android-tools/files/patch-vendor_f2fs-tools_fsck_xattr.c @@ -0,0 +1,13 @@ +--- vendor/f2fs-tools/fsck/xattr.c 2024-08-29 19:46:57.000000000 +0200 ++++ vendor/f2fs-tools/fsck/xattr.c 2026-03-21 14:11:45.643441000 +0100 +@@ -16,6 +16,10 @@ + #include "fsck.h" + #include "node.h" + #include "xattr.h" ++ ++#ifndef ENODATA ++#define ENODATA ENOATTR ++#endif + + void *read_all_xattrs(struct f2fs_sb_info *sbi, struct f2fs_node *inode, + bool sanity_check) diff --git a/devel/android-tools/files/patch-vendor_f2fs-tools_lib_libf2fs.c b/devel/android-tools/files/patch-vendor_f2fs-tools_lib_libf2fs.c new file mode 100644 index 000000000000..c9a953459fc9 --- /dev/null +++ b/devel/android-tools/files/patch-vendor_f2fs-tools_lib_libf2fs.c @@ -0,0 +1,26 @@ +--- vendor/f2fs-tools/lib/libf2fs.c 2024-08-29 19:46:57.000000000 +0200 ++++ vendor/f2fs-tools/lib/libf2fs.c 2026-03-21 14:06:22.014748000 +0100 +@@ -43,6 +43,9 @@ + #ifdef HAVE_LINUX_LIMITS_H + #include + #endif ++#ifdef HAVE_LIMITS_H ++#include ++#endif + + /* SCSI command for standard inquiry*/ + #define MODELINQUIRY 0x12,0x00,0x00,0x00,0x4A,0x00 +@@ -945,6 +948,13 @@ + #define BLKGETSIZE DKIOCGETBLOCKCOUNT + #define BLKSSZGET DKIOCGETBLOCKCOUNT + #endif /* APPLE_DARWIN */ ++ ++#if defined(__FreeBSD__) ++#include ++#include ++#define BLKGETSIZE64 DIOCGMEDIASIZE ++#define BLKSSZGET DIOCGSECTORSIZE ++#endif /* __FreeBSD__ */ + + #ifndef _WIN32 + static int open_check_fs(char *path, int flag) diff --git a/devel/android-tools/files/patch-vendor_libbase_file.cpp b/devel/android-tools/files/patch-vendor_libbase_file.cpp new file mode 100644 index 000000000000..8bcc46af49f1 --- /dev/null +++ b/devel/android-tools/files/patch-vendor_libbase_file.cpp @@ -0,0 +1,25 @@ +--- vendor/libbase/file.cpp 2024-08-29 19:46:57.000000000 +0200 ++++ vendor/libbase/file.cpp 2026-03-21 14:02:01.670927000 +0100 +@@ -35,6 +35,9 @@ + + #if defined(__APPLE__) + #include ++#endif ++#if defined(__FreeBSD__) ++#include + #endif + #if defined(_WIN32) + #include *** 200 LINES SKIPPED ***