X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=daemon%2Fguestfsd.c;h=d16826f04165f7f0d9420934349277d2a5e15283;hp=bf06c73d1ffe4a160fa7e9f7c2949644f7266db8;hb=e645763007e7097c14c1c3ba94010f2e32e536bf;hpb=d714547ab361962ca6f76ec07736f1515595b2df diff --git a/daemon/guestfsd.c b/daemon/guestfsd.c index bf06c73..d16826f 100644 --- a/daemon/guestfsd.c +++ b/daemon/guestfsd.c @@ -38,6 +38,8 @@ #include #include "c-ctype.h" +#include "ignore-value.h" + #include "daemon.h" static char *read_cmdline (void); @@ -546,7 +548,7 @@ commandf (char **stdoutput, char **stderror, int flags, const char *name, ...) va_end (args); - r = commandvf (stdoutput, stderror, flags, (char **) argv); + r = commandvf (stdoutput, stderror, flags, (const char * const*) argv); /* NB: Mustn't free the strings which are on the stack. */ free (argv); @@ -603,7 +605,8 @@ commandrf (char **stdoutput, char **stderror, int flags, const char *name, ...) /* Same as 'command', but passing an argv. */ int -commandvf (char **stdoutput, char **stderror, int flags, char *const *argv) +commandvf (char **stdoutput, char **stderror, int flags, + char const *const *argv) { int r; @@ -638,7 +641,7 @@ commandvf (char **stdoutput, char **stderror, int flags, char *const *argv) */ int commandrvf (char **stdoutput, char **stderror, int flags, - char const* const *argv) + char const* const *argv) { int so_size = 0, se_size = 0; int so_fd[2], se_fd[2]; @@ -742,15 +745,20 @@ commandrvf (char **stdoutput, char **stderror, int flags, } if (r == 0) { FD_CLR (se_fd[0], &rset); quit++; } - if (r > 0 && stderror) { - se_size += r; - p = realloc (*stderror, se_size); - if (p == NULL) { - perror ("realloc"); - goto quit; + if (r > 0) { + if (verbose) + ignore_value (write (2, buf, r)); + + if (stderror) { + se_size += r; + p = realloc (*stderror, se_size); + if (p == NULL) { + perror ("realloc"); + goto quit; + } + *stderror = p; + memcpy (*stderror + se_size - r, buf, r); } - *stderror = p; - memcpy (*stderror + se_size - r, buf, r); } } }