blob: 5debcc5209e8d851c3fadf1adb70f69f075f9fa2 [file] [log] [blame]
Brad Bishop316dfdd2018-06-25 12:45:53 -04001From 9d260d408f9e17abd1d1dccd685bd7e80a3655a9 Mon Sep 17 00:00:00 2001
2From: Donn Seeley <donn.seeley@windriver.com>
3Date: Tue, 25 Feb 2014 17:44:04 +0800
4Subject: [PATCH] dpkg: fix a link problem for dpkg-native on CentOS 5.8
5
Patrick Williamsc124f4f2015-09-15 14:41:29 -05006CentOS 5.8 kernels and headers support the sync_file_range() system call,
7but glibc 2.5 doesn't provide the syscall stub. It appears that this
8problem is known but will never be fixed:
9
10 https://bugzilla.redhat.com/show_bug.cgi?id=518581
11
Brad Bishop316dfdd2018-06-25 12:45:53 -040012 Bug 518581 - [RHEL5] glibc misses sync_file_range syscall interface
Patrick Williamsc124f4f2015-09-15 14:41:29 -050013
Brad Bishop316dfdd2018-06-25 12:45:53 -040014 Status: CLOSED CANTFIX
Patrick Williamsc124f4f2015-09-15 14:41:29 -050015 Last Closed: 2009-11-22 22:19:55
16
17 Kirby Zhou 2009-08-20 23:37:55 EDT
18
19 Description of problem:
20
21 glibc misses sync_file_range syscall interface. The header file and
22 man page both say 'sync_file_range' should exist. From man page,
23 sync_file_range should exist sinc kernel-2.6.17
24
25 Andreas Schwab 2009-08-21 03:24:24 EDT
26
27 It has only been added to glibc 2.6, and cannot be backported due to
28 ABI breakage. You can always fall back to syscall(3).
29
30 Ulrich Drepper 2009-11-22 22:19:55 EST
31
32 As comment #1 says, no chance to backport this.
33
34 See the syscall man page for instructions.
35
36 Jon E 2010-03-19 10:32:37 EDT
37
38 then why document it if it's broken and you're not going to fix it?
39 .. might want to FTFM over at sync_file_range(2) - in the meantime -
40 borrowing from glibc 2.6 .. any thoughts on this implementation for a
41 hacky workaround for those still on your "ancient releases" .. (eg:
42 RHEL5.3)?:
43
44 #ifdef ULI_WONT_FIX_THIS_IN_GLIBC2.5
45 #define NR_sync_file_range 277
46 int sync_file_range (int fd, __off64_t from, __off64_t to, unsigned int flags)
47 {
48 return syscall (NR_sync_file_range, fd,
49 __LONG_LONG_PAIR ((long) (from >> 32), (long) from),
50 __LONG_LONG_PAIR ((long) (to >> 32), (long) to),
51 flags);
52 }
53 #endif
54
55 assuming of course that you're on an x86_64 and include/asm-
56 x86_64/unistd.h has the correct entry
57
58 (fwiw - fio is starting to use this now)
59
60Rather than attempting to provide an implementation using syscall(),
61we take the more conservative route and ignore header support for
62sync_file_range() flags when the glibc version is <= 2.5.
63
64Upstream-Status: Inappropriate [everyone else builds on newer hosts :-)]
65
66Signed-off-by: Donn Seeley <donn.seeley@windriver.com>
67Signed-off-by: Lei Liu <lei.liu2@windriver.com>
Brad Bishop316dfdd2018-06-25 12:45:53 -040068
Brad Bishop19323692019-04-05 15:28:33 -040069Update patch context for dpkg 1.19.4.
70
71Signed-off-by: Kai Kang <kai.kang@windriver.com>
Patrick Williamsc124f4f2015-09-15 14:41:29 -050072---
Brad Bishop316dfdd2018-06-25 12:45:53 -040073 src/archives.c | 4 ++--
Patrick Williamsc124f4f2015-09-15 14:41:29 -050074 1 file changed, 2 insertions(+), 2 deletions(-)
75
Brad Bishop316dfdd2018-06-25 12:45:53 -040076diff --git a/src/archives.c b/src/archives.c
Brad Bishop19323692019-04-05 15:28:33 -040077index 8476a5c..b05a63f 100644
Patrick Williamsc124f4f2015-09-15 14:41:29 -050078--- a/src/archives.c
79+++ b/src/archives.c
Brad Bishop19323692019-04-05 15:28:33 -040080@@ -68,7 +68,7 @@ fd_writeback_init(int fd)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050081 /* Ignore the return code as it should be considered equivalent to an
82 * asynchronous hint for the kernel, we are doing an fsync() later on
83 * anyway. */
84-#if defined(SYNC_FILE_RANGE_WRITE)
85+#if defined(SYNC_FILE_RANGE_WRITE) && __GLIBC_PREREQ(2, 6)
86 sync_file_range(fd, 0, 0, SYNC_FILE_RANGE_WRITE);
87 #elif defined(HAVE_POSIX_FADVISE)
88 posix_fadvise(fd, 0, 0, POSIX_FADV_DONTNEED);
Brad Bishop19323692019-04-05 15:28:33 -040089@@ -1093,7 +1093,7 @@ tarobject(struct tar_archive *tar, struct tar_entry *ti)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050090 return 0;
91 }
92
93-#if defined(SYNC_FILE_RANGE_WAIT_BEFORE)
94+#if defined(SYNC_FILE_RANGE_WAIT_BEFORE) && __GLIBC_PREREQ(2, 6)
95 static void
Brad Bishop19323692019-04-05 15:28:33 -040096 tar_writeback_barrier(struct fsys_namenode_list *files, struct pkginfo *pkg)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050097 {
Brad Bishop316dfdd2018-06-25 12:45:53 -040098--
992.16.2
100