Package: libeatmydata / 82-6

bug-702711.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
Description: Do not fail when open() is called before eatmydata is initialized
 Make sure open() calls done before the eatmydata_init(), for example
 called by ctors, do not return an unexpected error.
Author: Roland Stigge <stigge@antcom.de>
Reviewed-By: Petter Reinholdtsen <pere@hungry.com>
Reviewed-By: Mattia Rizzolo <mattia@mapreri.org>
Bug: https://launchpad.net/bugs/1374862
Bug-Debian: https://bugs.debian.org/702711
Bug-Debian: https://bugs.debian.org/765738
Forwarded: https://launchpad.net/bugs/1374862
Last-Update: 2014-10-29

--- a/libeatmydata/libeatmydata.c
+++ b/libeatmydata/libeatmydata.c
@@ -69,11 +69,13 @@
 
 
 int LIBEATMYDATA_API msync(void *addr, size_t length, int flags);
+static int initing = 0;
 
 void __attribute__ ((constructor)) eatmydata_init(void);
 
 void __attribute__ ((constructor)) eatmydata_init(void)
 {
+    initing = 1;
 	ASSIGN_DLSYM_OR_DIE(open);
 	ASSIGN_DLSYM_OR_DIE(open64);
 	ASSIGN_DLSYM_OR_DIE(fsync);
@@ -83,6 +85,7 @@
 #ifdef HAVE_SYNC_FILE_RANGE
 	ASSIGN_DLSYM_IF_EXIST(sync_file_range);
 #endif
+    initing = 0;
 }
 
 static int eatmydata_is_hungry(void)
@@ -144,7 +147,7 @@
 
 	/* In pthread environments the dlsym() may call our open(). */
 	/* We simply ignore it because libc is already loaded       */
-	if (!libc_open) {
+	if (initing) {
 		errno = EFAULT;
 		return -1;
 	}
@@ -171,7 +174,7 @@
 
 	/* In pthread environments the dlsym() may call our open(). */
 	/* We simply ignore it because libc is already loaded       */
-	if (!libc_open64) {
+	if (initing) {
 		errno = EFAULT;
 		return -1;
 	}