Skip to content

Commit

Permalink
Add support for Alpine Linux 3.21 / linux-musl
Browse files Browse the repository at this point in the history
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: gluster#268
  • Loading branch information
kohlschuetter committed Jan 15, 2025
1 parent 7663679 commit 9905aa4
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 0 deletions.
11 changes: 11 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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]))
Expand Down Expand Up @@ -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)\\\""
Expand Down
2 changes: 2 additions & 0 deletions contrib/fuse-lib/mount-gluster-compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <stddef.h>
#include <limits.h>
#include <fcntl.h>
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions contrib/fuse-util/fusermount.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#ifndef HAVE_UMOUNT2
#include "mount-gluster-compat.h"
#endif
#include "glusterfs/compat.h"

#include <stdio.h>
#include <stdlib.h>
Expand Down
1 change: 1 addition & 0 deletions glusterfsd/src/glusterfsd.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <pthread.h>
#include <errno.h>
#include <pwd.h>
#include <libgen.h>

#ifdef GF_LINUX_HOST_OS
#ifdef HAVE_LINUX_OOM_H
Expand Down
1 change: 1 addition & 0 deletions libglusterfs/src/glusterfs/compat-errno.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#define __COMPAT_ERRNO_H__

#include <errno.h>
#include <stdint.h>

#define GF_ERROR_CODE_SUCCESS 0
#define GF_ERROR_CODE_UNKNOWN 1024
Expand Down
14 changes: 14 additions & 0 deletions libglusterfs/src/glusterfs/compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,22 @@
#define LLONG_MAX __LONG_LONG_MAX__ /* compat with old gcc */
#endif /* LLONG_MAX */

#include <libgen.h>
#include <string.h>

#ifdef GF_LINUX_HOST_OS

#ifndef HAVE_OFF64_T
typedef int64_t off64_t;
#endif
#ifndef HAVE_INET_NET_PTON
#include <stddef.h>
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 <sys/un.h>
Expand Down
1 change: 1 addition & 0 deletions libglusterfs/src/glusterfs/syscall.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <sys/socket.h>
#include <sys/types.h>
#include <stdio.h>
#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 */
Expand Down
8 changes: 8 additions & 0 deletions libglusterfs/src/syncop.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@
#include <valgrind/valgrind.h>
#endif

#ifdef USE_LIBUCONTEXT
#include <libucontext/libucontext.h>
#define getcontext libucontext_getcontext
#define makecontext libucontext_makecontext
#define setcontext libucontext_setcontext
#define swapcontext libucontext_swapcontext
#endif

int
syncopctx_setfsuid(void *uid)
{
Expand Down
1 change: 1 addition & 0 deletions xlators/cluster/afr/src/afr.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#ifndef __AFR_H__
#define __AFR_H__

#include <libgen.h>
#include <glusterfs/call-stub.h>
#include <glusterfs/compat-errno.h>
#include "afr-mem-types.h"
Expand Down
1 change: 1 addition & 0 deletions xlators/features/changelog/src/changelog-helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "changelog-rpc-common.h"
#include <pthread.h>
#include <time.h>
#include <libgen.h>

static void
changelog_cleanup_free_mutex(void *arg_mutex)
Expand Down

0 comments on commit 9905aa4

Please sign in to comment.