On 29/08/17 10:12, Assaf Gordon wrote:
> 1.
> Possibly due to the recent "renameat2" addition,
> compiling on linux now requires <linux/fs.h> header.
> On GNU/Linux systems it is likely part of the "linux-libc-dev"
> package and is always available,
> but on non-gnu (e.g. AlpineLinux) it is not available by default.
> compilation then fails with:
> ===
> CC       lib/argmatch.o
> CC       lib/argv-iter.o
> CC       lib/backupfile.o
> In file included from lib/backupfile.c:26:0:
> lib/renameat2.h:22:23: fatal error: linux/fs.h: No such file or directory
> # include <linux/fs.h>

gnulib patch attached
>From 58c0514fa38c16ebef9db95e215195570862f872 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <[email protected]>
Date: Wed, 30 Aug 2017 00:16:39 -0700
Subject: [PATCH] renameat2: fix compilation on alpine linux

* m4/renameat.m4: Check for <linux/fs.h> presence.
* lib/renameat2.h: Only include <linux/fs.h> if present.
Reported by Assaf Gordon on Alpine Linux.
---
 ChangeLog       | 7 +++++++
 lib/renameat2.h | 2 +-
 m4/renameat.m4  | 1 +
 3 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 994123a..0b3c06a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2017-08-30  Pádraig Brady  <[email protected]>
+
+	renameat2: fix compilation on alpine linux
+	* m4/renameat.m4: Check for <linux/fs.h> presence.
+	* lib/renameat2.h: Only include <linux/fs.h> if present.
+	Reported by Assaf Gordon on Alpine Linux.
+
 2017-08-24  Paul Eggert  <[email protected]>
 
 	glob: try to port recent changes to MS-Windows
diff --git a/lib/renameat2.h b/lib/renameat2.h
index da3d78c..f69929b 100644
--- a/lib/renameat2.h
+++ b/lib/renameat2.h
@@ -18,7 +18,7 @@
 
 /* Get RENAME_* macros from linux/fs.h if present, otherwise supply
    the traditional Linux values.  */
-#ifdef __linux__
+#if HAVE_LINUX_FS_H
 # include <linux/fs.h>
 #endif
 #ifndef RENAME_NOREPLACE
diff --git a/m4/renameat.m4 b/m4/renameat.m4
index cfbfe15..1b97774 100644
--- a/m4/renameat.m4
+++ b/m4/renameat.m4
@@ -14,6 +14,7 @@ AC_DEFUN([gl_FUNC_RENAMEAT],
   AC_REQUIRE([gl_FUNC_RENAME])
   AC_REQUIRE([gl_STDIO_H_DEFAULTS])
   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
+  AC_CHECK_HEADERS([linux/fs.h])
   AC_CHECK_FUNCS_ONCE([renameat])
   if test $ac_cv_func_renameat = no; then
     HAVE_RENAMEAT=0
-- 
2.9.3

Reply via email to