X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=daemon%2Fcommand.c;h=1a9bebb634fa4b4b26865d22df59e901a0f045d0;hp=1daccf6efd8937dc97e15868f5d253ff202897fa;hb=b6adf09c4d2cc3f1d0285950c151b1fd7688ec67;hpb=296b536c965820b8334150df0247a0657f6e35fd diff --git a/daemon/command.c b/daemon/command.c index 1daccf6..1a9bebb 100644 --- a/daemon/command.c +++ b/daemon/command.c @@ -53,11 +53,11 @@ do_command (char * const * const argv) * We deliberately allow these commands to fail silently, BUT * if a mount fails, don't unmount the corresponding mount. */ - r = command (NULL, NULL, "mount", "--bind", "/dev", "/sysroot/dev", NULL); + r = command (NULL, NULL, "mount", "--rbind", "/dev", "/sysroot/dev", NULL); dev_ok = r != -1; - r = command (NULL, NULL, "mount", "--bind", "/proc", "/sysroot/proc", NULL); + r = command (NULL, NULL, "mount", "--rbind", "/proc", "/sysroot/proc", NULL); proc_ok = r != -1; - r = command (NULL, NULL, "mount", "--bind", "/sys", "/sysroot/sys", NULL); + r = command (NULL, NULL, "mount", "--rbind", "/sys", "/sysroot/sys", NULL); sys_ok = r != -1; CHROOT_IN; @@ -84,37 +84,16 @@ char ** do_command_lines (char * const * const 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. */