X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=daemon%2Fcommand.c;h=3254de58462b23fe83a3cf1dc6970008711a6be0;hb=3ed322c7c8f1b7342af095ba6a8fb60a8e9a076b;hp=1daccf6efd8937dc97e15868f5d253ff202897fa;hpb=296b536c965820b8334150df0247a0657f6e35fd;p=libguestfs.git diff --git a/daemon/command.c b/daemon/command.c index 1daccf6..3254de5 100644 --- a/daemon/command.c +++ b/daemon/command.c @@ -27,11 +27,11 @@ #include "actions.h" char * -do_command (char * const * const argv) +do_command (char **argv) { char *out, *err; int r; - int proc_ok, dev_ok, sys_ok; + int proc_ok, dev_ok, dev_pts_ok, sys_ok; /* We need a root filesystem mounted to do this. */ NEED_ROOT (NULL); @@ -55,6 +55,8 @@ do_command (char * const * const argv) */ r = command (NULL, NULL, "mount", "--bind", "/dev", "/sysroot/dev", NULL); dev_ok = r != -1; + r = command (NULL, NULL, "mount", "--bind", "/dev/pts", "/sysroot/dev/pts", NULL); + dev_pts_ok = r != -1; r = command (NULL, NULL, "mount", "--bind", "/proc", "/sysroot/proc", NULL); proc_ok = r != -1; r = command (NULL, NULL, "mount", "--bind", "/sys", "/sysroot/sys", NULL); @@ -66,6 +68,7 @@ do_command (char * const * const argv) if (sys_ok) command (NULL, NULL, "umount", "/sysroot/sys", NULL); if (proc_ok) command (NULL, NULL, "umount", "/sysroot/proc", NULL); + if (dev_pts_ok) command (NULL, NULL, "umount", "/sysroot/dev/pts", NULL); if (dev_ok) command (NULL, NULL, "umount", "/sysroot/dev", NULL); if (r == -1) { @@ -81,40 +84,19 @@ do_command (char * const * const argv) } char ** -do_command_lines (char * const * const argv) +do_command_lines (char **argv) { char *out; - char **lines = NULL; - int size = 0, alloc = 0; - char *p, *pend; + char **lines; out = do_command (argv); if (out == NULL) return NULL; - /* Now convert the output to a list of lines. */ - p = out; - while (p) { - pend = strchr (p, '\n'); - if (pend) { - *pend = '\0'; - pend++; - - /* Final \n? Don't return an empty final element. */ - if (*pend == '\0') break; - } - - if (add_string (&lines, &size, &alloc, p) == -1) { - free (out); - return NULL; - } - - p = pend; - } - + lines = split_lines (out); free (out); - if (add_string (&lines, &size, &alloc, NULL) == -1) + if (lines == NULL) return NULL; return lines; /* Caller frees. */