summaryrefslogtreecommitdiff
path: root/package/lvm/patches/patch-lib_commands_toolcontext_c
diff options
context:
space:
mode:
Diffstat (limited to 'package/lvm/patches/patch-lib_commands_toolcontext_c')
-rw-r--r--package/lvm/patches/patch-lib_commands_toolcontext_c74
1 files changed, 74 insertions, 0 deletions
diff --git a/package/lvm/patches/patch-lib_commands_toolcontext_c b/package/lvm/patches/patch-lib_commands_toolcontext_c
new file mode 100644
index 000000000..397576c9b
--- /dev/null
+++ b/package/lvm/patches/patch-lib_commands_toolcontext_c
@@ -0,0 +1,74 @@
+--- LVM2.2.02.106.orig/lib/commands/toolcontext.c 2014-04-10 17:38:44.000000000 +0200
++++ LVM2.2.02.106/lib/commands/toolcontext.c 2014-05-29 17:55:05.101305501 +0200
+@@ -1334,6 +1334,8 @@ struct cmd_context *create_toolcontext(u
+ {
+ struct cmd_context *cmd;
+ FILE *new_stream;
++ FILE *stdin_stream = stdin;
++ FILE *stdout_stream = stdout;
+ int flags;
+
+ #ifdef M_MMAP_MAX
+@@ -1383,10 +1385,10 @@ struct cmd_context *create_toolcontext(u
+ if (is_valid_fd(STDIN_FILENO) &&
+ ((flags = fcntl(STDIN_FILENO, F_GETFL)) > 0) &&
+ (flags & O_ACCMODE) != O_WRONLY) {
+- if (!_reopen_stream(stdin, STDIN_FILENO, "r", "stdin", &new_stream))
++ if (!_reopen_stream(stdin_stream, STDIN_FILENO, "r", "stdin", &new_stream))
+ goto_out;
+- stdin = new_stream;
+- if (setvbuf(stdin, cmd->linebuffer, _IOLBF, linebuffer_size)) {
++ stdin_stream = new_stream;
++ if (setvbuf(stdin_stream, cmd->linebuffer, _IOLBF, linebuffer_size)) {
+ log_sys_error("setvbuf", "");
+ goto out;
+ }
+@@ -1395,10 +1397,10 @@ struct cmd_context *create_toolcontext(u
+ if (is_valid_fd(STDOUT_FILENO) &&
+ ((flags = fcntl(STDOUT_FILENO, F_GETFL)) > 0) &&
+ (flags & O_ACCMODE) != O_RDONLY) {
+- if (!_reopen_stream(stdout, STDOUT_FILENO, "w", "stdout", &new_stream))
++ if (!_reopen_stream(stdout_stream, STDOUT_FILENO, "w", "stdout", &new_stream))
+ goto_out;
+- stdout = new_stream;
+- if (setvbuf(stdout, cmd->linebuffer + linebuffer_size,
++ stdout_stream = new_stream;
++ if (setvbuf(stdout_stream, cmd->linebuffer + linebuffer_size,
+ _IOLBF, linebuffer_size)) {
+ log_sys_error("setvbuf", "");
+ goto out;
+@@ -1681,6 +1683,8 @@ void destroy_toolcontext(struct cmd_cont
+ {
+ struct dm_config_tree *cft_cmdline;
+ FILE *new_stream;
++ FILE *stdin_stream = stdin;
++ FILE *stdout_stream = stdout;
+ int flags;
+
+ if (cmd->dump_filter && cmd->filter && cmd->filter->dump &&
+@@ -1717,9 +1721,9 @@ void destroy_toolcontext(struct cmd_cont
+ if (is_valid_fd(STDIN_FILENO) &&
+ ((flags = fcntl(STDIN_FILENO, F_GETFL)) > 0) &&
+ (flags & O_ACCMODE) != O_WRONLY) {
+- if (_reopen_stream(stdin, STDIN_FILENO, "r", "stdin", &new_stream)) {
+- stdin = new_stream;
+- setlinebuf(stdin);
++ if (_reopen_stream(stdin_stream, STDIN_FILENO, "r", "stdin", &new_stream)) {
++ stdin_stream = new_stream;
++ setlinebuf(stdin_stream);
+ } else
+ cmd->linebuffer = NULL; /* Leave buffer in place (deliberate leak) */
+ }
+@@ -1727,9 +1731,9 @@ void destroy_toolcontext(struct cmd_cont
+ if (is_valid_fd(STDOUT_FILENO) &&
+ ((flags = fcntl(STDOUT_FILENO, F_GETFL)) > 0) &&
+ (flags & O_ACCMODE) != O_RDONLY) {
+- if (_reopen_stream(stdout, STDOUT_FILENO, "w", "stdout", &new_stream)) {
+- stdout = new_stream;
+- setlinebuf(stdout);
++ if (_reopen_stream(stdout_stream, STDOUT_FILENO, "w", "stdout", &new_stream)) {
++ stdout_stream = new_stream;
++ setlinebuf(stdout_stream);
+ } else
+ cmd->linebuffer = NULL; /* Leave buffer in place (deliberate leak) */
+ }