blob: 231da806c405861b1e8cfd31b9855fec31ce0ca7 [file] [log] [blame]
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08001From f8a22f16c03e51d3c779b12f37d362faaa0ecf31 Mon Sep 17 00:00:00 2001
Brad Bishop316dfdd2018-06-25 12:45:53 -04002From: Khem Raj <raj.khem@gmail.com>
3Date: Wed, 31 Jan 2018 21:28:53 -0800
4Subject: [PATCH] build: Check for sync_file_range libc function
5
6glibc 2.27 now has sync_file_range()
7
Brad Bishop316dfdd2018-06-25 12:45:53 -04008Upstream-Status: Pending
9
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080010Signed-off-by: Khem Raj <raj.khem@gmail.com>
11---
Brad Bishop316dfdd2018-06-25 12:45:53 -040012 include/builddefs.in | 1 +
13 io/Makefile | 5 ++++-
14 io/io.h | 2 +-
15 io/sync_file_range.c | 3 +++
16 4 files changed, 9 insertions(+), 2 deletions(-)
17
18diff --git a/include/builddefs.in b/include/builddefs.in
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080019index b895949..a388c83 100644
Brad Bishop316dfdd2018-06-25 12:45:53 -040020--- a/include/builddefs.in
21+++ b/include/builddefs.in
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080022@@ -95,6 +95,7 @@ HAVE_FIEMAP = @have_fiemap@
Brad Bishop316dfdd2018-06-25 12:45:53 -040023 HAVE_PREADV = @have_preadv@
24 HAVE_PWRITEV2 = @have_pwritev2@
25 HAVE_COPY_FILE_RANGE = @have_copy_file_range@
26+HAVE_NR_COPY_FILE_RANGE = @have_nr_copy_file_range@
27 HAVE_SYNC_FILE_RANGE = @have_sync_file_range@
28 HAVE_SYNCFS = @have_syncfs@
29 HAVE_READDIR = @have_readdir@
30diff --git a/io/Makefile b/io/Makefile
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080031index 00ede48..dd001b0 100644
Brad Bishop316dfdd2018-06-25 12:45:53 -040032--- a/io/Makefile
33+++ b/io/Makefile
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080034@@ -60,10 +60,13 @@ CFILES += inject.c resblks.c
Brad Bishop316dfdd2018-06-25 12:45:53 -040035 LCFLAGS += -DHAVE_INJECT -DHAVE_RESBLKS
36 endif
37
38-ifeq ($(HAVE_COPY_FILE_RANGE),yes)
39+ifeq ($(HAVE_NR_COPY_FILE_RANGE),yes)
40 CFILES += copy_file_range.c
41+LCFLAGS += -DHAVE_NR_COPY_FILE_RANGE
42+ifeq ($(HAVE_COPY_FILE_RANGE),yes)
43 LCFLAGS += -DHAVE_COPY_FILE_RANGE
44 endif
45+endif
46
47 ifeq ($(HAVE_SYNC_FILE_RANGE),yes)
48 CFILES += sync_file_range.c
49diff --git a/io/io.h b/io/io.h
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080050index e1f3d95..fe2e6a2 100644
Brad Bishop316dfdd2018-06-25 12:45:53 -040051--- a/io/io.h
52+++ b/io/io.h
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080053@@ -151,7 +151,7 @@ extern void fiemap_init(void);
Brad Bishop316dfdd2018-06-25 12:45:53 -040054 #define fiemap_init() do { } while (0)
55 #endif
56
57-#ifdef HAVE_COPY_FILE_RANGE
58+#if defined(HAVE_NR_COPY_FILE_RANGE) && !defined(HAVE_COPY_FILE_RANGE)
59 extern void copy_range_init(void);
60 #else
61 #define copy_range_init() do { } while (0)
62diff --git a/io/sync_file_range.c b/io/sync_file_range.c
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080063index 30bbc93..6c49d73 100644
Brad Bishop316dfdd2018-06-25 12:45:53 -040064--- a/io/sync_file_range.c
65+++ b/io/sync_file_range.c
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080066@@ -4,6 +4,7 @@
67 * All Rights Reserved.
Brad Bishop316dfdd2018-06-25 12:45:53 -040068 */
69
70+#ifndef HAVE_COPY_FILE_RANGE
71 #include "command.h"
72 #include "input.h"
73 #include "init.h"
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080074@@ -92,3 +93,5 @@ sync_range_init(void)
Brad Bishop316dfdd2018-06-25 12:45:53 -040075
76 add_command(&sync_range_cmd);
77 }
78+
79+#endif