Browse Source

lvm2: fix build with musl

stdin, stderr and stdout are constants on musl and it doesn't provide
mallinfo.
Both, overwriting std* were used to catch and work around various
misbehaviours of glibc, so it's hopefully save to just skip them when
building against other libc implementations.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Daniel Golle 9 years ago
parent
commit
f5cc8c27d7
2 changed files with 71 additions and 0 deletions
  1. 58
    0
      utils/lvm2/patches/002-const-stdio.patch
  2. 13
    0
      utils/lvm2/patches/003-no-mallinfo.patch

+ 58
- 0
utils/lvm2/patches/002-const-stdio.patch View File

@@ -0,0 +1,58 @@
1
+Index: LVM2.2.02.118/lib/commands/toolcontext.c
2
+===================================================================
3
+--- LVM2.2.02.118.orig/lib/commands/toolcontext.c
4
++++ LVM2.2.02.118/lib/commands/toolcontext.c
5
+@@ -1625,8 +1625,10 @@ struct cmd_context *create_toolcontext(u
6
+ 				       unsigned threaded)
7
+ {
8
+ 	struct cmd_context *cmd;
9
++#if defined(__GLIBC__) && !defined(VALGRIND_POOL)
10
+ 	FILE *new_stream;
11
+ 	int flags;
12
++#endif
13
+ 
14
+ #ifdef M_MMAP_MAX
15
+ 	mallopt(M_MMAP_MAX, 0);
16
+@@ -1662,7 +1664,7 @@ struct cmd_context *create_toolcontext(u
17
+ 	/* FIXME Make this configurable? */
18
+ 	reset_lvm_errno(1);
19
+ 
20
+-#ifndef VALGRIND_POOL
21
++#if defined(__GLIBC__) && !defined(VALGRIND_POOL)
22
+ 	/* Set in/out stream buffering before glibc */
23
+ 	if (set_buffering) {
24
+ 		/* Allocate 2 buffers */
25
+@@ -2035,7 +2037,7 @@ void destroy_toolcontext(struct cmd_cont
26
+ 	if (cmd->libmem)
27
+ 		dm_pool_destroy(cmd->libmem);
28
+ 
29
+-#ifndef VALGRIND_POOL
30
++#if defined(__GLIBC__) && !defined(VALGRIND_POOL)
31
+ 	if (cmd->linebuffer) {
32
+ 		/* Reset stream buffering to defaults */
33
+ 		if (is_valid_fd(STDIN_FILENO) &&
34
+Index: LVM2.2.02.118/tools/lvmcmdline.c
35
+===================================================================
36
+--- LVM2.2.02.118.orig/tools/lvmcmdline.c
37
++++ LVM2.2.02.118/tools/lvmcmdline.c
38
+@@ -1602,6 +1602,7 @@ int lvm_split(char *str, int *argc, char
39
+ /* Make sure we have always valid filedescriptors 0,1,2 */
40
+ static int _check_standard_fds(void)
41
+ {
42
++#ifdef __GLIBC__
43
+ 	int err = is_valid_fd(STDERR_FILENO);
44
+ 
45
+ 	if (!is_valid_fd(STDIN_FILENO) &&
46
+@@ -1628,6 +1629,12 @@ static int _check_standard_fds(void)
47
+ 		       strerror(errno));
48
+ 		return 0;
49
+ 	}
50
++#else
51
++	if (!is_valid_fd(STDERR_FILENO) ||
52
++	    !is_valid_fd(STDOUT_FILENO) ||
53
++	    !is_valid_fd(STDIN_FILENO))
54
++		return 0;
55
++#endif
56
+ 
57
+ 	return 1;
58
+ }

+ 13
- 0
utils/lvm2/patches/003-no-mallinfo.patch View File

@@ -0,0 +1,13 @@
1
+Index: LVM2.2.02.118/lib/mm/memlock.c
2
+===================================================================
3
+--- LVM2.2.02.118.orig/lib/mm/memlock.c
4
++++ LVM2.2.02.118/lib/mm/memlock.c
5
+@@ -137,7 +137,7 @@ static void _touch_memory(void *mem, siz
6
+ 
7
+ static void _allocate_memory(void)
8
+ {
9
+-#ifndef VALGRIND_POOL
10
++#if defined(__GLIBC__) && !defined(VALGRIND_POOL)
11
+ 	void *stack_mem;
12
+ 	struct rlimit limit;
13
+ 	int i, area = 0, missing = _size_malloc_tmp, max_areas = 32, hblks;