From patchwork Fri Nov 16 19:10:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: info@mobile-stream.com X-Patchwork-Id: 10686653 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0734713B5 for ; Fri, 16 Nov 2018 16:33:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EB8F92CA6C for ; Fri, 16 Nov 2018 16:33:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DFCD52CA88; Fri, 16 Nov 2018 16:33:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F0A932CA6C for ; Fri, 16 Nov 2018 16:33:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729036AbeKQCqN (ORCPT ); Fri, 16 Nov 2018 21:46:13 -0500 Received: from mx7.valuehost.ru ([217.112.42.214]:32154 "EHLO mx7.valuehost.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728175AbeKQCqM (ORCPT ); Fri, 16 Nov 2018 21:46:12 -0500 X-Greylist: delayed 560 seconds by postgrey-1.27 at vger.kernel.org; Fri, 16 Nov 2018 21:46:11 EST Received: from mx7.valuehost.ru (unknown [127.0.0.255]) by mx7.valuehost.ru (Postfix) with ESMTP id 456255382F for ; Fri, 16 Nov 2018 19:23:46 +0300 (MSK) From: Date: Fri, 16 Nov 2018 19:10:00 +0000 Subject: xfsprogs: MAP_SYNC detection/usage problems with musl To: linux-xfs@vger.kernel.org Message-Id: <20181116162346.456255382F@mx7.valuehost.ru> Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP xfsprogs configure script tries to detect the MAP_SYNC mmap() flag support in kernel by looking for the symbol in files. But some architectures (e.g. mips) do not use the generic files and define all the mman bits in . 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 then undefine it in mips-specific . So io/mmap.c compilation fails since (which undefines MAP_SYNC) is included after "linux.h" (which either defines fallback values or pulls ). 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 -#include -#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 -#include +#include ], [ int flags = MAP_SYNC | MAP_SHARED_VALIDATE; ], have_map_sync=yes