From 9905aa4142e5dd4cb3c0882389d10a0ec0ae26e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Kohlschu=CC=88tter?= Date: Wed, 15 Jan 2025 12:08:17 +0000 Subject: [PATCH] Add support for Alpine Linux 3.21 / linux-musl Prerequisites: sudo apk add alpine-sdk autoconf automake libtool rpcgen flex bison \ gperftools-dev tcmalloc-minimal openssl-dev util-linux-dev acl-dev \ zlib-dev libxml2-dev argp-standalone liburing-dev linux-headers \ userspace-rcu-dev libucontext-dev Fixes: #268 --- configure.ac | 11 +++++++++++ contrib/fuse-lib/mount-gluster-compat.h | 2 ++ contrib/fuse-util/fusermount.c | 1 + glusterfsd/src/glusterfsd.c | 1 + libglusterfs/src/glusterfs/compat-errno.h | 1 + libglusterfs/src/glusterfs/compat.h | 14 ++++++++++++++ libglusterfs/src/glusterfs/syscall.h | 1 + libglusterfs/src/syncop.c | 8 ++++++++ xlators/cluster/afr/src/afr.h | 1 + xlators/features/changelog/src/changelog-helpers.c | 1 + 10 files changed, 41 insertions(+) diff --git a/configure.ac b/configure.ac index ab1b4a7641a..918803202bd 100644 --- a/configure.ac +++ b/configure.ac @@ -1108,6 +1108,9 @@ case $host_os in *netbsd*) ARGP_LDADD=-largp ;; + linux-musl*) + ARGP_LDADD=-largp + ;; esac dnl argp-standalone does not provide a pkg-config file AC_CHECK_HEADER([argp.h], AC_DEFINE(HAVE_ARGP, 1, [have argp])) @@ -1441,6 +1444,14 @@ prefix=$old_prefix GFAPI_EXTRA_LDFLAGS='-Wl,--version-script=$(top_srcdir)/api/src/gfapi.map' case $host_os in + linux-musl*) + GF_HOST_OS="GF_LINUX_HOST_OS" + GF_FUSE_CFLAGS="-DFUSERMOUNT_DIR=\\\"\$(bindir)\\\"" + GLUSTERD_WORKDIR="${LOCALSTATEDIR}/lib/glusterd" + GF_CFLAGS="${GF_CFLAGS} -I/usr/include/arch/common -Wno-incompatible-pointer-types -Doff64_t=int64_t -D__off64_t=int64_t -DF_SETLK64=F_SETLK -DF_SETLKW64=F_SETLKW -DF_GETLK64=F_GETLK -DUSE_LIBUCONTEXT=1" + GF_LDFLAGS="-lbsd -lucontext ${GF_LDFLAGS}" + GF_LDADD="${ARGP_LDADD}" + ;; linux*) GF_HOST_OS="GF_LINUX_HOST_OS" GF_FUSE_CFLAGS="-DFUSERMOUNT_DIR=\\\"\$(bindir)\\\"" diff --git a/contrib/fuse-lib/mount-gluster-compat.h b/contrib/fuse-lib/mount-gluster-compat.h index d3646d08d8e..f3239500b57 100644 --- a/contrib/fuse-lib/mount-gluster-compat.h +++ b/contrib/fuse-lib/mount-gluster-compat.h @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -91,6 +92,7 @@ typedef long long mount_flag_t; #define _PATH_MOUNT "/sbin/mount" #endif +#include "glusterfs/compat.h" #ifdef FUSE_UTIL #define MALLOC(size) malloc (size) #define FREE(ptr) free (ptr) diff --git a/contrib/fuse-util/fusermount.c b/contrib/fuse-util/fusermount.c index ff743f75a21..7b559e50a4b 100644 --- a/contrib/fuse-util/fusermount.c +++ b/contrib/fuse-util/fusermount.c @@ -14,6 +14,7 @@ #ifndef HAVE_UMOUNT2 #include "mount-gluster-compat.h" #endif +#include "glusterfs/compat.h" #include #include diff --git a/glusterfsd/src/glusterfsd.c b/glusterfsd/src/glusterfsd.c index 6b5bec6dc9a..49d9dc7de3f 100644 --- a/glusterfsd/src/glusterfsd.c +++ b/glusterfsd/src/glusterfsd.c @@ -15,6 +15,7 @@ #include #include #include +#include #ifdef GF_LINUX_HOST_OS #ifdef HAVE_LINUX_OOM_H diff --git a/libglusterfs/src/glusterfs/compat-errno.h b/libglusterfs/src/glusterfs/compat-errno.h index 1f9926e850a..b90636d864c 100644 --- a/libglusterfs/src/glusterfs/compat-errno.h +++ b/libglusterfs/src/glusterfs/compat-errno.h @@ -12,6 +12,7 @@ #define __COMPAT_ERRNO_H__ #include +#include #define GF_ERROR_CODE_SUCCESS 0 #define GF_ERROR_CODE_UNKNOWN 1024 diff --git a/libglusterfs/src/glusterfs/compat.h b/libglusterfs/src/glusterfs/compat.h index 55bd035ce70..a59a0c7d35f 100644 --- a/libglusterfs/src/glusterfs/compat.h +++ b/libglusterfs/src/glusterfs/compat.h @@ -17,8 +17,22 @@ #define LLONG_MAX __LONG_LONG_MAX__ /* compat with old gcc */ #endif /* LLONG_MAX */ +#include +#include + #ifdef GF_LINUX_HOST_OS +#ifndef HAVE_OFF64_T +typedef int64_t off64_t; +#endif +#ifndef HAVE_INET_NET_PTON +#include +int inet_net_pton(int af, const char *src, void *dst, size_t size); +#endif +#ifndef _PATH_MOUNTED +#define _PATH_MOUNTED "/etc/mtab" +#endif + #define UNIX_PATH_MAX 108 #include diff --git a/libglusterfs/src/glusterfs/syscall.h b/libglusterfs/src/glusterfs/syscall.h index f6c904df38d..537868bcd4f 100644 --- a/libglusterfs/src/glusterfs/syscall.h +++ b/libglusterfs/src/glusterfs/syscall.h @@ -19,6 +19,7 @@ #include #include #include +#include "glusterfs/compat.h" /* GF follows the Linux XATTR definition, which differs in Darwin. */ #define GF_XATTR_CREATE 0x1 /* set value, fail if attr already exists */ diff --git a/libglusterfs/src/syncop.c b/libglusterfs/src/syncop.c index f3d2651b673..b9adfcb17c7 100644 --- a/libglusterfs/src/syncop.c +++ b/libglusterfs/src/syncop.c @@ -23,6 +23,14 @@ #include #endif +#ifdef USE_LIBUCONTEXT +#include +#define getcontext libucontext_getcontext +#define makecontext libucontext_makecontext +#define setcontext libucontext_setcontext +#define swapcontext libucontext_swapcontext +#endif + int syncopctx_setfsuid(void *uid) { diff --git a/xlators/cluster/afr/src/afr.h b/xlators/cluster/afr/src/afr.h index 13f1f129022..bf977eec227 100644 --- a/xlators/cluster/afr/src/afr.h +++ b/xlators/cluster/afr/src/afr.h @@ -11,6 +11,7 @@ #ifndef __AFR_H__ #define __AFR_H__ +#include #include #include #include "afr-mem-types.h" diff --git a/xlators/features/changelog/src/changelog-helpers.c b/xlators/features/changelog/src/changelog-helpers.c index 9c8b54b9341..7a820a92298 100644 --- a/xlators/features/changelog/src/changelog-helpers.c +++ b/xlators/features/changelog/src/changelog-helpers.c @@ -20,6 +20,7 @@ #include "changelog-rpc-common.h" #include #include +#include static void changelog_cleanup_free_mutex(void *arg_mutex)