From: Stéphane Graber Date: Tue, 8 Apr 2025 14:36:14 +0000 (-0400) Subject: bionic: Remove bionic detection and support X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4d52fe8e0d6a649fd31c87cbe9778cbfa769c16a;p=thirdparty%2Flxc.git bionic: Remove bionic detection and support Signed-off-by: Stéphane Graber --- diff --git a/README.md b/README.md index adc94eed3..d99730e4d 100644 --- a/README.md +++ b/README.md @@ -116,7 +116,6 @@ LXC also supports at least the following C standard libraries: - glibc - musl -- bionic (Android's libc) ## Backwards Compatibility diff --git a/hooks/meson.build b/hooks/meson.build index b08b0a7f0..d78900750 100644 --- a/hooks/meson.build +++ b/hooks/meson.build @@ -1,11 +1,6 @@ # SPDX-License-Identifier: LGPL-2.1+ hooks_unmount_namespace_sources = files('unmount-namespace.c') -if srcconf.get('IS_BIONIC') == 1 or srcconf.get('HAVE_HASMNTOPT') == 0 or srcconf.get('HAVE_SETMNTENT') == 0 or srcconf.get('HAVE_ENDMNTENT') == 0 - hooks_unmount_namespace_sources += files( - '../src/include/lxcmntent.c', - '../src/include/lxcmntent.h') -endif hook_programs += executable( 'unmount-namespace', diff --git a/hooks/unmount-namespace.c b/hooks/unmount-namespace.c index a116bde8b..d5755cfad 100644 --- a/hooks/unmount-namespace.c +++ b/hooks/unmount-namespace.c @@ -23,12 +23,7 @@ #include /* openat, open */ #include /* openat, open */ #include /* errno */ - -#if IS_BIONIC -#include "lxcmntent.h" -#else #include -#endif #ifndef O_PATH #define O_PATH 010000000 diff --git a/meson.build b/meson.build index 9cea5108d..f0ab8c54e 100644 --- a/meson.build +++ b/meson.build @@ -123,9 +123,6 @@ conf.set('PACKAGE_VERSION', meson.project_version()) conf.set('RUNTIME_PATH', runtimepath) conf.set('SYSCONFDIR', sysconfdir) -# Cross-compile on Android. -srcconf.set10('IS_BIONIC', host_machine.system() == 'android') - # Custom configuration. cgrouppattern = get_option('cgroup-pattern') coverity = get_option('coverity-build') diff --git a/src/include/lxcmntent.c b/src/include/lxcmntent.c deleted file mode 100644 index 3547b6d5b..000000000 --- a/src/include/lxcmntent.c +++ /dev/null @@ -1,196 +0,0 @@ -/* Utilities for reading/writing fstab, mtab, etc. - * - * SPDX-License-Identifier: LGPL-2.1+ - * - */ - -#ifndef _GNU_SOURCE -#define _GNU_SOURCE 1 -#endif -#include -#include -#include -#include -#include -#include "../lxc/macro.h" - -/* Since the values in a line are separated by spaces, a name cannot - * contain a space. Therefore some programs encode spaces in names - * by the strings "\040". We undo the encoding when reading an entry. - * The decoding happens in place. - */ -static char *decode_name(char *buf) -{ - char *rp = buf; - char *wp = buf; - - do { - if (rp[0] == '\\' && rp[1] == '0' && rp[2] == '4' && - rp[3] == '0') { - /* \040 is a SPACE. */ - *wp++ = ' '; - rp += 3; - } else if (rp[0] == '\\' && rp[1] == '0' && rp[2] == '1' && - rp[3] == '1') { - /* \011 is a TAB. */ - *wp++ = '\t'; - rp += 3; - } else if (rp[0] == '\\' && rp[1] == '0' && rp[2] == '1' && - rp[3] == '2') { - /* \012 is a NEWLINE. */ - *wp++ = '\n'; - rp += 3; - } else if (rp[0] == '\\' && rp[1] == '\\') { - /* We have to escape \\ to be able to represent all characters. */ - *wp++ = '\\'; - rp += 1; - } else if (rp[0] == '\\' && rp[1] == '1' && rp[2] == '3' && - rp[3] == '4') { - /* \134 is also \\. */ - *wp++ = '\\'; - rp += 3; - } else { - *wp++ = *rp; - } - } while (*rp++ != '\0'); - - return buf; -} - -/* Read one mount table entry from STREAM. Returns a pointer to storage - * reused on the next call, or null for EOF or error (use feof/ferror to check). - */ -struct mntent *getmntent_r(FILE *stream, struct mntent *mp, char *buffer, int bufsiz) -{ - char *cp; - char *head; - - do { - char *end_ptr; - - if (!fgets(buffer, bufsiz, stream)) - return NULL; - - end_ptr = strchr(buffer, '\n'); - if (end_ptr != NULL) { - /* chop newline */ - *end_ptr = '\0'; - } else { - /* Not the whole line was read. Do it now but forget it. */ - char tmp[1024] = {0}; - - while (fgets(tmp, sizeof tmp, stream)) - if (strchr(tmp, '\n') != NULL) - break; - } - - head = buffer + strspn(buffer, " \t"); - /* skip empty lines and comment lines: */ - } while (head[0] == '\0' || head[0] == '#'); - - cp = strsep(&head, " \t"); - mp->mnt_fsname = cp ? decode_name(cp) : (char *)""; - if (head) - head += strspn(head, " \t"); - - cp = strsep(&head, " \t"); - mp->mnt_dir = cp ? decode_name(cp) : (char *)""; - if (head) - head += strspn(head, " \t"); - - cp = strsep(&head, " \t"); - mp->mnt_type = cp ? decode_name(cp) : (char *)""; - if (head) - head += strspn(head, " \t"); - - cp = strsep(&head, " \t"); - mp->mnt_opts = cp ? decode_name(cp) : (char *)""; - if (head) { - int ret = sscanf(head, " %d %d ", &mp->mnt_freq, &mp->mnt_passno); - - switch (ret) { - case 0: - mp->mnt_freq = 0; - break; - case 1: - mp->mnt_passno = 0; - break; - case 2: - break; - } - } else { - mp->mnt_freq = 0; - } - - return mp; -} - -struct mntent *getmntent(FILE *stream) -{ - static struct mntent m; - static char *getmntent_buffer; - - if (!getmntent_buffer) { - getmntent_buffer = (char *)malloc(LXC_MAX_BUFFER); - if (!getmntent_buffer) - return NULL; - } - - return getmntent_r(stream, &m, getmntent_buffer, LXC_MAX_BUFFER); -} - -/* Prepare to begin reading and/or writing mount table entries from the - * beginning of FILE. MODE is as for `fopen'. - */ -FILE *setmntent(const char *file, const char *mode) -{ - /* Extend the mode parameter with "c" to disable cancellation in the - * I/O functions and "e" to set FD_CLOEXEC. - */ - size_t modelen = strlen(mode); - char newmode[256]; - - if (modelen >= (sizeof(newmode) - 3)) { - errno = -EFBIG; - return NULL; - } - - memcpy(newmode, mode, modelen); - memcpy(newmode + modelen, "ce", 3); - - return fopen(file, newmode); -} - -/* Close a stream opened with `setmntent'. */ -int endmntent(FILE *stream) -{ - /* SunOS 4.x allows for NULL stream */ - if (stream) - fclose(stream); - - /* SunOS 4.x says to always return 1 */ - return 1; -} - -/* Search MNT->mnt_opts for an option matching OPT. - * Returns the address of the substring, or null if none found. - */ -char *hasmntopt(const struct mntent *mnt, const char *opt) -{ - const size_t optlen = strlen(opt); - char *rest = mnt->mnt_opts, *p; - - while ((p = strstr(rest, opt))) { - if ((p == rest || p[-1] == ',') && - (p[optlen] == '\0' || p[optlen] == '=' || p[optlen] == ',')) - return p; - - rest = strchr(p, ','); - if (!rest) - break; - - ++rest; - } - - return NULL; -} diff --git a/src/include/lxcmntent.h b/src/include/lxcmntent.h deleted file mode 100644 index 116f184eb..000000000 --- a/src/include/lxcmntent.h +++ /dev/null @@ -1,40 +0,0 @@ -/* Utilities for reading/writing fstab, mtab, etc. - * - * SPDX-License-Identifier: LGPL-2.1+ - * - */ - -#ifndef _LXCMNTENT_H -#define _LXCMNTENT_H - -#include "../lxc/compiler.h" - -#if IS_BIONIC -struct mntent -{ - char* mnt_fsname; - char* mnt_dir; - char* mnt_type; - char* mnt_opts; - int mnt_freq; - int mnt_passno; -}; - -__hidden extern struct mntent *getmntent(FILE *stream); -__hidden extern struct mntent *getmntent_r(FILE *stream, struct mntent *mp, - char *buffer, int bufsiz); -#endif - -#if !HAVE_SETMNTENT || IS_BIONIC -__hidden FILE *setmntent(const char *file, const char *mode); -#endif - -#if !HAVE_ENDMNTENT || IS_BIONIC -__hidden int endmntent(FILE *stream); -#endif - -#if !HAVE_HASMNTOPT || IS_BIONIC -__hidden extern char *hasmntopt(const struct mntent *mnt, const char *opt); -#endif - -#endif diff --git a/src/include/meson.build b/src/include/meson.build index e4a8340bc..7fd5d41bd 100644 --- a/src/include/meson.build +++ b/src/include/meson.build @@ -27,12 +27,6 @@ if srcconf.get('HAVE_GETGRGID_R') == 0 'getgrgid_r.h') endif -if srcconf.get('IS_BIONIC') == 1 or srcconf.get('HAVE_HASMNTOPT') == 0 or srcconf.get('HAVE_SETMNTENT') == 0 or srcconf.get('HAVE_ENDMNTENT') == 0 - include_sources += files( - 'lxcmntent.c', - 'lxcmntent.h') -endif - if srcconf.get('HAVE_STRLCPY') == 0 include_sources += files( 'strlcpy.c', diff --git a/src/lxc/compiler.h b/src/lxc/compiler.h index 907941d98..4193652a1 100644 --- a/src/lxc/compiler.h +++ b/src/lxc/compiler.h @@ -222,13 +222,7 @@ static inline bool __must_check __must_check_overflow(bool overflow) #ifndef __noreturn # if __STDC_VERSION__ >= 201112L -# if !IS_BIONIC -# define __noreturn _Noreturn -# else -# define __noreturn __attribute__((__noreturn__)) -# endif -# elif IS_BIONIC -# define __noreturn __attribute__((__noreturn__)) +# define __noreturn _Noreturn # else # define __noreturn __attribute__((noreturn)) # endif diff --git a/src/lxc/conf.c b/src/lxc/conf.c index f711d95b7..517b7c570 100644 --- a/src/lxc/conf.c +++ b/src/lxc/conf.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -86,12 +87,6 @@ #include "strlcat.h" #endif -#if IS_BIONIC -#include "lxcmntent.h" -#else -#include -#endif - #if !HAVE_PRLIMIT && HAVE_PRLIMIT64 #include "prlimit.h" #endif diff --git a/src/lxc/criu.c b/src/lxc/criu.c index 032552ecc..9996b888a 100644 --- a/src/lxc/criu.c +++ b/src/lxc/criu.c @@ -12,6 +12,7 @@ #include #include #include +#include #include "attach_options.h" @@ -28,12 +29,6 @@ #include "syscall_wrappers.h" #include "utils.h" -#if IS_BIONIC -#include "lxcmntent.h" -#else -#include -#endif - #if !HAVE_STRLCPY #include "strlcpy.h" #endif diff --git a/src/lxc/initutils.c b/src/lxc/initutils.c index a8ec1764b..208169247 100644 --- a/src/lxc/initutils.c +++ b/src/lxc/initutils.c @@ -56,7 +56,7 @@ const char *lxc_global_config_value(const char *option_name) { NULL, NULL }, }; - /* placed in the thread local storage pool for non-bionic targets */ + /* placed in the thread local storage pool */ static thread_local const char *values[sizeof(options) / sizeof(options[0])] = {0}; /* user_config_path is freed as soon as it is used */ diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c index 0bc446cdb..7b9ff9641 100644 --- a/src/lxc/lxccontainer.c +++ b/src/lxc/lxccontainer.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -72,12 +73,6 @@ #include #endif -#if IS_BIONIC -#include <../include/lxcmntent.h> -#else -#include -#endif - #if !HAVE_STRLCPY #include "include/strlcpy.h" #endif diff --git a/src/lxc/rexec.c b/src/lxc/rexec.c index 09c9da20b..f2802c2fa 100644 --- a/src/lxc/rexec.c +++ b/src/lxc/rexec.c @@ -16,10 +16,6 @@ #include "string_utils.h" #include "syscall_wrappers.h" -#if IS_BIONIC && !HAVE_FEXECVE -#include "fexecve.h" -#endif - #define LXC_MEMFD_REXEC_SEALS \ (F_SEAL_SEAL | F_SEAL_SHRINK | F_SEAL_GROW | F_SEAL_WRITE) diff --git a/src/lxc/storage/storage.h b/src/lxc/storage/storage.h index f8b0d1a87..148023bad 100644 --- a/src/lxc/storage/storage.h +++ b/src/lxc/storage/storage.h @@ -5,17 +5,12 @@ #include "config.h" +#include #include #include #include "lxc.h" -#if IS_BIONIC -#include "lxcmntent.h" -#else -#include -#endif - #include "compiler.h" #include "conf.h"