All of lore.kernel.org
 help / color / mirror / Atom feed
From: <info@mobile-stream.com>
To: linux-xfs@vger.kernel.org
Subject: xfsprogs: MAP_SYNC detection/usage problems with musl
Date: Fri, 16 Nov 2018 19:10:00 +0000	[thread overview]
Message-ID: <20181116162346.456255382F@mx7.valuehost.ru> (raw)

xfsprogs configure script tries to detect the MAP_SYNC mmap() flag support in kernel
by looking for the symbol in <asm-generic/mman{-common}.h> files. But some architectures
(e.g. mips) do not use the generic files and define all the mman bits in <asm/mman.h>.
Thus xfs_io ends up with the incorrectly detected MAP_SYNC support. Not a big deal, just
no graceful exit on 'xfs_io mmap -S'.

Worse problem is related to the MAP_SYNC handling in the musl library. They first define
MAP_SYNC unconditionally in <sys/mman.h> then undefine it in mips-specific <bits/mman.h>.
So io/mmap.c compilation fails since <sys/mman.h> (which undefines MAP_SYNC) is included
after "linux.h" (which either defines fallback values or pulls <asm-generic/mman{-common.h}>).

The diff below is not really a suggested patch (though it works for me in alpine/mipsel) but
merely an additional illustration of the above.

--- a/include/linux.h
+++ b/include/linux.h
@@ -327,12 +327,4 @@
 #define HAVE_GETFSMAP
 #endif /* HAVE_GETFSMAP */
 
-#ifndef HAVE_MAP_SYNC
-#define MAP_SYNC 0
-#define MAP_SHARED_VALIDATE 0
-#else
-#include <asm-generic/mman.h>
-#include <asm-generic/mman-common.h>
-#endif /* HAVE_MAP_SYNC */
-
 #endif	/* __XFS_LINUX_H__ */
--- a/io/mmap.c
+++ b/io/mmap.c
@@ -23,6 +23,11 @@
 #include "init.h"
 #include "io.h"
 
+#ifndef HAVE_MAP_SYNC
+#define MAP_SYNC 0
+#define MAP_SHARED_VALIDATE 0
+#endif
+
 static cmdinfo_t mmap_cmd;
 static cmdinfo_t mread_cmd;
 static cmdinfo_t msync_cmd;
--- a/m4/package_libcdev.m4
+++ b/m4/package_libcdev.m4
@@ -335,8 +335,7 @@
 AC_DEFUN([AC_HAVE_MAP_SYNC],
   [ AC_MSG_CHECKING([for MAP_SYNC])
     AC_TRY_COMPILE([
-#include <asm-generic/mman.h>
-#include <asm-generic/mman-common.h>
+#include <asm/mman.h>
     ], [
         int flags = MAP_SYNC | MAP_SHARED_VALIDATE;
     ], have_map_sync=yes

                 reply	other threads:[~2018-11-17  2:46 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181116162346.456255382F@mx7.valuehost.ru \
    --to=info@mobile-stream.com \
    --cc=linux-xfs@vger.kernel.org \
    --subject='Re: xfsprogs: MAP_SYNC detection/usage problems with musl' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.