[Libguestfs] [PATCH 1/4] Revert "launch: don't add a drive twice"

Richard W.M. Jones rjones at redhat.com
Thu Apr 12 18:34:50 UTC 2012


From: "Richard W.M. Jones" <rjones at redhat.com>

This reverts commit be47b66c3033105a2b880dbc10bfc2b163b7eafe.
---
 src/launch.c |   21 ++-------------------
 1 file changed, 2 insertions(+), 19 deletions(-)

diff --git a/src/launch.c b/src/launch.c
index 6388fd2..35cf49e 100644
--- a/src/launch.c
+++ b/src/launch.c
@@ -295,9 +295,7 @@ guestfs__add_drive_opts (guestfs_h *g, const char *filename,
   char *format;
   char *iface;
   char *name;
-  char *abs_path = NULL;
   int use_cache_off;
-  int check_duplicate;
 
   if (check_path(g, filename) == -1)
     return -1;
@@ -337,39 +335,24 @@ guestfs__add_drive_opts (guestfs_h *g, const char *filename,
     }
   }
 
-  /* Make the path canonical, so we can check if the user is trying to
-   * add the same path twice.  Allow /dev/null to be added multiple
-   * times, in accordance with traditional usage.
-   */
-  abs_path = realpath (filename, NULL);
-  check_duplicate = STRNEQ (abs_path, "/dev/null");
-
   struct drive **i = &(g->drives);
-  while (*i != NULL) {
-    if (check_duplicate && STREQ((*i)->path, abs_path)) {
-      error (g, _("drive %s can't be added twice"), abs_path);
-      goto err_out;
-    }
-    i = &((*i)->next);
-  }
+  while (*i != NULL) i = &((*i)->next);
 
   *i = safe_malloc (g, sizeof (struct drive));
   (*i)->next = NULL;
-  (*i)->path = safe_strdup (g, abs_path);
+  (*i)->path = safe_strdup (g, filename);
   (*i)->readonly = readonly;
   (*i)->format = format;
   (*i)->iface = iface;
   (*i)->name = name;
   (*i)->use_cache_off = use_cache_off;
 
-  free (abs_path);
   return 0;
 
 err_out:
   free (format);
   free (iface);
   free (name);
-  free (abs_path);
   return -1;
 }
 
-- 
1.7.9.3




More information about the Libguestfs mailing list