* src/generator.ml: Change all `String "device"' to `Device "device"'.
[libguestfs.git] / daemon / cpmv.c
index b87d7a4..37f1219 100644 (file)
@@ -1,5 +1,5 @@
 /* libguestfs - the guestfsd daemon
- * Copyright (C) 2009 Red Hat Inc. 
+ * Copyright (C) 2009 Red Hat Inc.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -49,32 +49,26 @@ static int
 cpmv_cmd (const char *cmd, const char *flags, const char *src, const char *dest)
 {
   char *srcbuf, *destbuf;
-  int srclen, destlen;
   char *err;
   int r;
 
   NEED_ROOT (-1);
-  ABS_PATH (src, -1);
-  ABS_PATH (dest, -1);
+  ABS_PATH (src, return -1);
+  ABS_PATH (dest, return -1);
 
-  srclen = strlen (src) + 32;
-  srcbuf = malloc (srclen);
+  srcbuf = sysroot_path (src);
   if (srcbuf == NULL) {
     reply_with_perror ("malloc");
     return -1;
   }
 
-  destlen = strlen (dest) + 32;
-  destbuf = malloc (destlen);
+  destbuf = sysroot_path (dest);
   if (destbuf == NULL) {
     reply_with_perror ("malloc");
     free (srcbuf);
     return -1;
   }
 
-  snprintf (srcbuf, srclen, "/sysroot%s", src);
-  snprintf (destbuf, destlen, "/sysroot%s", dest);
-
   if (flags)
     r = command (NULL, &err, cmd, flags, srcbuf, destbuf, NULL);
   else