From dacfaea338b024383d2512cf3c29c738d942c2c9 Mon Sep 17 00:00:00 2001 From: DreamConnected <1487442471@qq.com> Date: Sun, 31 Aug 2025 15:40:14 +0800 Subject: [PATCH 1/3] Revert "meson.build: add native build" This reverts commit 50dd47d081d5391734f2cbdcaacc68049d9c4dc3. Signed-off-by: DreamConnected <1487442471@qq.com> --- meson.build | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/meson.build b/meson.build index 088eddc8f6..6b3322914b 100644 --- a/meson.build +++ b/meson.build @@ -272,23 +272,6 @@ endif have = cc.get_id().contains('clang') and cc.has_header('android/log.h') srcconf.set10('IS_BIONIC', have) -## Android Native Build -srcconf.set10('IS_BIONIC_NATIVE', false) -if meson.is_cross_build() == false and srcconf.get('IS_BIONIC') == 1 - sdk_version = run_command('getprop', 'ro.build.version.sdk', check: true).stdout().strip() - cpu_arch = build_machine.cpu_family() - if cpu_arch == 'aarch64' - add_project_arguments('--target=aarch64-linux-android' + sdk_version, language: 'c') - elif cpu_arch == 'arm' - add_project_arguments('--target=armv7a-linux-androideabi' + sdk_version, language: 'c') - elif cpu_arch == 'X86_64' - add_project_arguments('--target=x86_64-linux-android' + sdk_version, language: 'c') - else - error('Unsupported arch:', cpu_arch) - endif - srcconf.set10('IS_BIONIC_NATIVE', true) -endif - # Feature detection ## Android Log System. srcconf.set10('USE_ANDROID_LOG', false) From 44f49a6f8303170a078892e9e9198150d0508948 Mon Sep 17 00:00:00 2001 From: DreamConnected <1487442471@qq.com> Date: Sun, 31 Aug 2025 15:53:46 +0800 Subject: [PATCH 2/3] include/hasmntopt: add hasmntopt() from musl Now, the API support for Android is reduced from 26 to 24. Signed-off-by: DreamConnected <1487442471@qq.com> --- src/include/hasmntopt.c | 30 ++++++++++++++++++++++++++++++ src/include/hasmntopt.h | 15 +++++++++++++++ src/include/meson.build | 6 ++++++ src/lxc/conf.c | 4 ++++ 4 files changed, 55 insertions(+) create mode 100644 src/include/hasmntopt.c create mode 100644 src/include/hasmntopt.h diff --git a/src/include/hasmntopt.c b/src/include/hasmntopt.c new file mode 100644 index 0000000000..d2808f0194 --- /dev/null +++ b/src/include/hasmntopt.c @@ -0,0 +1,30 @@ +/* liblxcapi + * + * SPDX-License-Identifier: LGPL-2.1+ * + * + * This function has been copied from musl. + */ + +#include + +struct mntent { + char* mnt_fsname; + char* mnt_dir; + char* mnt_type; + char* mnt_opts; + int mnt_freq; + int mnt_passno; +}; + +char *hasmntopt(const struct mntent *mnt, const char *opt) +{ + size_t l = strlen(opt); + char *p = mnt->mnt_opts; + for (;;) { + if (!strncmp(p, opt, l) && (!p[l] || p[l]==',' || p[l]=='=')) + return p; + p = strchr(p, ','); + if (!p) return 0; + p++; + } +} \ No newline at end of file diff --git a/src/include/hasmntopt.h b/src/include/hasmntopt.h new file mode 100644 index 0000000000..1fae5892fd --- /dev/null +++ b/src/include/hasmntopt.h @@ -0,0 +1,15 @@ +/* liblxcapi + * + * SPDX-License-Identifier: LGPL-2.1+ * + * + * This function has been copied from musl. + */ + +#ifndef _HASMNTOPT_H +#define _HASMNTOPT_H + +#include "../lxc/compiler.h" + +__hidden extern char* hasmntopt(const struct mntent* mnt, const char* opt); + +#endif \ No newline at end of file diff --git a/src/include/meson.build b/src/include/meson.build index 74fc43897c..c39fc1bebf 100644 --- a/src/include/meson.build +++ b/src/include/meson.build @@ -38,3 +38,9 @@ if srcconf.get('HAVE_STRCHRNUL') == 0 'strchrnul.c', 'strchrnul.h') endif + +if srcconf.get('HAVE_HASMNTOPT') == 0 + include_sources += files( + 'hasmntopt.c', + 'hasmntopt.h') +endif diff --git a/src/lxc/conf.c b/src/lxc/conf.c index 1899b2806d..ba6bc57eeb 100644 --- a/src/lxc/conf.c +++ b/src/lxc/conf.c @@ -90,6 +90,10 @@ #include "strchrnul.h" #endif +#if !HAVE_HASMNTOPT +#include "hasmntopt.h" +#endif + lxc_log_define(conf, lxc); /* From 51031a65f4476affb0d8558492893a1cf2df6793 Mon Sep 17 00:00:00 2001 From: DreamConnected <1487442471@qq.com> Date: Sun, 31 Aug 2025 15:58:58 +0800 Subject: [PATCH 3/3] lxc/rexec.c: fix memfd_create on less than api 30 Signed-off-by: DreamConnected <1487442471@qq.com> --- src/lxc/rexec.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/lxc/rexec.c b/src/lxc/rexec.c index fdc44c2334..6e3eb587b5 100644 --- a/src/lxc/rexec.c +++ b/src/lxc/rexec.c @@ -96,10 +96,9 @@ static void lxc_rexec_as_memfd(char **argv, char **envp, const char *memfd_name) tmpfd = -EBADF; int ret; ssize_t bytes_sent = 0; -#if IS_BIONIC && __ANDROID_API__ >= 30 +#if IS_BIONIC off_t fd_size = -1; #else - #error "memfd_create() not implemented under Android 30" struct stat st = {0}; #endif