summaryrefslogtreecommitdiff
path: root/system/lvm2/fix-stdio-usage.patch
blob: 6b7ee0eaa82e993ffdbc89afad6e49e4aefefc29 (plain) (blame)
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
--- LVM2.2.03.08/tools/lvmcmdline.c	2020-02-11 03:59:27.000000000 -0600
+++ LVM2.2.03.08/tools/lvmcmdline.c	2020-03-22 16:17:35.470100377 -0500
@@ -3233,7 +3233,7 @@ static int _check_standard_fds(void)
 	int err = is_valid_fd(STDERR_FILENO);
 
 	if (!is_valid_fd(STDIN_FILENO) &&
-	    !(stdin = fopen(_PATH_DEVNULL, "r"))) {
+	    !freopen(_PATH_DEVNULL, "r", stdin)) {
 		if (err)
 			perror("stdin stream open");
 		else
@@ -3243,7 +3243,7 @@ static int _check_standard_fds(void)
 	}
 
 	if (!is_valid_fd(STDOUT_FILENO) &&
-	    !(stdout = fopen(_PATH_DEVNULL, "w"))) {
+	    !freopen(_PATH_DEVNULL, "w", stdout)) {
 		if (err)
 			perror("stdout stream open");
 		/* else no stdout */
@@ -3251,7 +3251,7 @@ static int _check_standard_fds(void)
 	}
 
 	if (!is_valid_fd(STDERR_FILENO) &&
-	    !(stderr = fopen(_PATH_DEVNULL, "w"))) {
+	    !freopen(_PATH_DEVNULL, "w", stderr)) {
 		printf("stderr stream open: %s\n",
 		       strerror(errno));
 		return 0;
--- LVM2.2.03.08/lib/commands/toolcontext.c	2020-02-11 03:59:27.000000000 -0600
+++ LVM2.2.03.08/lib/commands/toolcontext.c	2020-03-22 16:18:35.130101016 -0500
@@ -1599,7 +1599,7 @@ struct cmd_context *create_toolcontext(u
 	/* FIXME Make this configurable? */
 	reset_lvm_errno(1);
 
-#ifndef VALGRIND_POOL
+#if !defined(VALGRIND_POOL) && defined(__GLIBC__)
 	/* Set in/out stream buffering before glibc */
 	if (set_buffering
 #ifdef SYS_gettid
@@ -1980,7 +1980,7 @@ void destroy_toolcontext(struct cmd_cont
 
 	if (cmd->pending_delete_mem)
 		dm_pool_destroy(cmd->pending_delete_mem);
-#ifndef VALGRIND_POOL
+#if !defined(VALGRIND_POOL) && defined(__GLIBC__)
 	if (cmd->linebuffer) {
 		/* Reset stream buffering to defaults */
 		if (is_valid_fd(STDIN_FILENO) &&