]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
bionic: Remove bionic detection and support
authorStéphane Graber <stgraber@stgraber.org>
Tue, 8 Apr 2025 14:36:14 +0000 (10:36 -0400)
committerStéphane Graber <stgraber@stgraber.org>
Tue, 8 Apr 2025 14:49:24 +0000 (10:49 -0400)
Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
14 files changed:
README.md
hooks/meson.build
hooks/unmount-namespace.c
meson.build
src/include/lxcmntent.c [deleted file]
src/include/lxcmntent.h [deleted file]
src/include/meson.build
src/lxc/compiler.h
src/lxc/conf.c
src/lxc/criu.c
src/lxc/initutils.c
src/lxc/lxccontainer.c
src/lxc/rexec.c
src/lxc/storage/storage.h

index adc94eed31353eb2cc89cab886952b7a84abb809..d99730e4d6264a3f107d3d2b4d9e98a054cbb597 100644 (file)
--- 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
 
index b08b0a7f01bd03b9d78e94713cbc94936e2294d5..d789007507c2f0f131c940cdf2a04e2f6a2c25c7 100644 (file)
@@ -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',
index a116bde8b0b49ab441646b67034bdbfbc15a5b18..d5755cfad072a584972c0dfc2ea2fa0074b68138 100644 (file)
 #include <sys/stat.h>  /* openat, open */
 #include <fcntl.h>     /* openat, open */
 #include <errno.h>     /* errno */
-
-#if IS_BIONIC
-#include "lxcmntent.h"
-#else
 #include <mntent.h>
-#endif
 
 #ifndef O_PATH
 #define O_PATH 010000000
index 9cea5108d2a12f49d968b2bb18d0d02eb066d414..f0ab8c54e4155b39140909624bfd28db50bb2e51 100644 (file)
@@ -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 (file)
index 3547b6d..0000000
+++ /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 <errno.h>
-#include <mntent.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#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 (file)
index 116f184..0000000
+++ /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
index e4a8340bc705125ab763ada9eb2a467d7a9dfdb1..7fd5d41bd138743c975fd60d4a8fd1874ddd7941 100644 (file)
@@ -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',
index 907941d9812072f6d459bcf62890ea18014bc5e9..4193652a17793db227e3a811c284b48cc26888c4 100644 (file)
@@ -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
index f711d95b79fd61e88168aca08c93b08c29d72703..517b7c570df99b76a1febc203edbc59bfdce8abb 100644 (file)
@@ -10,6 +10,7 @@
 #include <inttypes.h>
 #include <libgen.h>
 #include <linux/loop.h>
+#include <mntent.h>
 #include <net/if.h>
 #include <netinet/in.h>
 #include <pwd.h>
 #include "strlcat.h"
 #endif
 
-#if IS_BIONIC
-#include "lxcmntent.h"
-#else
-#include <mntent.h>
-#endif
-
 #if !HAVE_PRLIMIT && HAVE_PRLIMIT64
 #include "prlimit.h"
 #endif
index 032552eccc3d46f4a4c0db6716bab6dbe9499183..9996b888aa431ecdf13a60456daf84088f8ae86b 100644 (file)
@@ -12,6 +12,7 @@
 #include <sys/types.h>
 #include <sys/wait.h>
 #include <unistd.h>
+#include <mntent.h>
 
 #include "attach_options.h"
 
 #include "syscall_wrappers.h"
 #include "utils.h"
 
-#if IS_BIONIC
-#include "lxcmntent.h"
-#else
-#include <mntent.h>
-#endif
-
 #if !HAVE_STRLCPY
 #include "strlcpy.h"
 #endif
index a8ec1764bb2ca7816aeaf7dbc779b9b224c640a3..2081692475ce5be9622b140c6b8a87f64e9c4814 100644 (file)
@@ -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 */
index 0bc446cdb9edd61385d359e7a6db4282ad1bda0a..7b9ff9641da416e8aa1e623a7e1319899d58aceb 100644 (file)
@@ -8,6 +8,7 @@
 #include <fcntl.h>
 #include <grp.h>
 #include <libgen.h>
+#include <mntent.h>
 #include <pthread.h>
 #include <sched.h>
 #include <stdarg.h>
 #include <sys/mkdev.h>
 #endif
 
-#if IS_BIONIC
-#include <../include/lxcmntent.h>
-#else
-#include <mntent.h>
-#endif
-
 #if !HAVE_STRLCPY
 #include "include/strlcpy.h"
 #endif
index 09c9da20b1f13e88c044620500a9e4d3cb7700ff..f2802c2fa71f545a0b49bf6bba1d1fe4990953a0 100644 (file)
 #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)
 
index f8b0d1a87814db3e67e3d7a0277a2b9bafd5175d..148023bad1e3f93d754c3fe48e3fbb1ea1d46742 100644 (file)
@@ -5,17 +5,12 @@
 
 #include "config.h"
 
+#include <mntent.h>
 #include <stdint.h>
 #include <sys/mount.h>
 
 #include "lxc.h"
 
-#if IS_BIONIC
-#include "lxcmntent.h"
-#else
-#include <mntent.h>
-#endif
-
 #include "compiler.h"
 #include "conf.h"