diff options
author | Timo Teräs <timo.teras@iki.fi> | 2013-10-08 07:03:58 +0000 |
---|---|---|
committer | Timo Teräs <timo.teras@iki.fi> | 2013-10-08 07:04:49 +0000 |
commit | 2e7e4206a16a6e5cbd67403e39389a57e6dfe741 (patch) | |
tree | b8bcf5a53acd964b1386c4b8c0d5872864b3e3fc /main/lvm2/fix-stdio-usage.patch | |
parent | 21edb0b26d14c4e3bbbf5f463b1ede63b9f8b32d (diff) | |
download | aports-2e7e4206a16a6e5cbd67403e39389a57e6dfe741.tar.bz2 aports-2e7e4206a16a6e5cbd67403e39389a57e6dfe741.tar.xz |
main/lvm2: upgrade to 2.02.103, and fix musl build
Diffstat (limited to 'main/lvm2/fix-stdio-usage.patch')
-rw-r--r-- | main/lvm2/fix-stdio-usage.patch | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/main/lvm2/fix-stdio-usage.patch b/main/lvm2/fix-stdio-usage.patch new file mode 100644 index 0000000000..71fa5bfae1 --- /dev/null +++ b/main/lvm2/fix-stdio-usage.patch @@ -0,0 +1,111 @@ +--- LVM2.2.02.103.orig/lib/commands/toolcontext.c ++++ LVM2.2.02.103/lib/commands/toolcontext.c +@@ -1336,7 +1336,10 @@ + /* + * Close and reopen stream on file descriptor fd. + */ +-static int _reopen_stream(FILE *stream, int fd, const char *mode, const char *name, FILE **new_stream) ++#ifdef __GLIBC__ ++#define _reopen_stream(stream, fd, mode, name) __reopen_stream(stream, fd, mode, name, &stream) ++ ++static int __reopen_stream(FILE *stream, int fd, const char *mode, const char *name, FILE **new_stream) + { + int fd_copy, new_fd; + +@@ -1363,6 +1366,9 @@ + + return 1; + } ++#else ++#define _reopen_stream(stream, fd, mode, name) (freopen(NULL, mode, stream) != NULL) ++#endif + + /* Entry point */ + struct cmd_context *create_toolcontext(unsigned is_long_lived, +@@ -1371,7 +1377,6 @@ + unsigned threaded) + { + struct cmd_context *cmd; +- FILE *new_stream; + int flags; + + #ifdef M_MMAP_MAX +@@ -1421,9 +1426,8 @@ + 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, STDIN_FILENO, "r", "stdin")) + goto_out; +- stdin = new_stream; + if (setvbuf(stdin, cmd->linebuffer, _IOLBF, linebuffer_size)) { + log_sys_error("setvbuf", ""); + goto out; +@@ -1433,9 +1437,8 @@ + 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, STDOUT_FILENO, "w", "stdout")) + goto_out; +- stdout = new_stream; + if (setvbuf(stdout, cmd->linebuffer + linebuffer_size, + _IOLBF, linebuffer_size)) { + log_sys_error("setvbuf", ""); +@@ -1715,7 +1718,6 @@ + void destroy_toolcontext(struct cmd_context *cmd) + { + struct dm_config_tree *cft_cmdline; +- FILE *new_stream; + int flags; + + if (cmd->dump_filter && cmd->filter && cmd->filter->dump && +@@ -1752,8 +1754,7 @@ + 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; ++ if (_reopen_stream(stdin, STDIN_FILENO, "r", "stdin")) { + setlinebuf(stdin); + } else + cmd->linebuffer = NULL; /* Leave buffer in place (deliberate leak) */ +@@ -1762,8 +1763,7 @@ + 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; ++ if (_reopen_stream(stdout, STDOUT_FILENO, "w", "stdout")) { + setlinebuf(stdout); + } else + cmd->linebuffer = NULL; /* Leave buffer in place (deliberate leak) */ +--- LVM2.2.02.103.orig/tools/lvmcmdline.c ++++ LVM2.2.02.103/tools/lvmcmdline.c +@@ -1252,7 +1252,7 @@ + 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 +@@ -1262,7 +1262,7 @@ + } + + 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 */ +@@ -1270,7 +1270,7 @@ + } + + 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; |