mirror of
https://codeberg.org/kiss-community/repo
synced 2024-08-22 22:16:19 +00:00
73 lines
2.0 KiB
Diff
73 lines
2.0 KiB
Diff
--- ./tools/lvmcmdline.c
|
|
+++ ./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;
|
|
--- a/lib/commands/toolcontext.c
|
|
+++ b/lib/commands/toolcontext.c
|
|
@@ -1649,7 +1649,7 @@ struct cmd_context *create_toolcontext(unsigned is_clvmd,
|
|
/* FIXME Make this configurable? */
|
|
reset_lvm_errno(1);
|
|
|
|
-#ifndef VALGRIND_POOL
|
|
+#if defined(__GLIBC__) && !defined(VALGRIND_POOL)
|
|
/* Set in/out stream buffering before glibc */
|
|
if (set_buffering
|
|
#ifdef SYS_gettid
|
|
@@ -2031,7 +2031,7 @@ void destroy_toolcontext(struct cmd_context *cmd)
|
|
if (cmd->libmem)
|
|
dm_pool_destroy(cmd->libmem);
|
|
|
|
-#ifndef VALGRIND_POOL
|
|
+#if defined(__GLIBC__) && !defined(VALGRIND_POOL)
|
|
if (cmd->linebuffer) {
|
|
/* Reset stream buffering to defaults */
|
|
if (is_valid_fd(STDIN_FILENO) &&
|
|
--- a/tools/lvmcmdline.c
|
|
+++ b/tools/lvmcmdline.c
|
|
@@ -3055,6 +3055,7 @@ int lvm_split(char *str, int *argc, char **argv, int max)
|
|
/* Make sure we have always valid filedescriptors 0,1,2 */
|
|
static int _check_standard_fds(void)
|
|
{
|
|
+#ifdef __GLIBC__
|
|
int err = is_valid_fd(STDERR_FILENO);
|
|
|
|
if (!is_valid_fd(STDIN_FILENO) &&
|
|
@@ -3081,6 +3082,12 @@ static int _check_standard_fds(void)
|
|
strerror(errno));
|
|
return 0;
|
|
}
|
|
+#else
|
|
+ if (!is_valid_fd(STDERR_FILENO) ||
|
|
+ !is_valid_fd(STDOUT_FILENO) ||
|
|
+ !is_valid_fd(STDIN_FILENO))
|
|
+ return 0;
|
|
+#endif
|
|
|
|
return 1;
|
|
}
|