X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=daemon%2Ffind.c;h=2147c57946c7d63768240a93cb712d604189bb34;hb=0a0d743ba80e33e676084f2a254c63d4188857b0;hp=d8829530827d2d05846cc983a1db72233cc12111;hpb=78029b529ad98769685d607230b70f71832d5906;p=libguestfs.git diff --git a/daemon/find.c b/daemon/find.c index d882953..2147c57 100644 --- a/daemon/find.c +++ b/daemon/find.c @@ -48,7 +48,7 @@ input_to_nul (FILE *fp, char *buf, int maxlen) } char ** -do_find (char *dir) +do_find (const char *dir) { struct stat statbuf; int r, len, sysrootdirlen; @@ -59,9 +59,6 @@ do_find (char *dir) char *sysrootdir; char str[PATH_MAX]; - NEED_ROOT (NULL); - ABS_PATH (dir, NULL); - sysrootdir = sysroot_path (dir); if (!sysrootdir) { reply_with_perror ("malloc"); @@ -83,21 +80,14 @@ do_find (char *dir) sysrootdirlen = strlen (sysrootdir); /* Assemble the external find command. */ - len = 2 * sysrootdirlen + 32; - cmd = malloc (len); - if (!cmd) { + if (asprintf_nowarn (&cmd, "find %Q -print0", sysrootdir) == -1) { reply_with_perror ("malloc"); free (sysrootdir); return NULL; } - strcpy (cmd, "find "); - shell_quote (cmd+5, len-5, sysrootdir); - free (sysrootdir); - strcat (cmd, " -print0"); - if (verbose) - printf ("%s\n", cmd); + fprintf (stderr, "%s\n", cmd); fp = popen (cmd, "r"); if (fp == NULL) {