summaryrefslogtreecommitdiffstats
path: root/src/launch.c
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2012-01-10 16:51:36 +0000
committerRichard W.M. Jones <rjones@redhat.com>2012-01-10 16:51:36 +0000
commit39a10c9fabcf7646b3dcb183c22ddba577d2a075 (patch)
treeab2c948a29abaf6db08b4dc1b4392073322a2cb7 /src/launch.c
parent01e717b3c141c509a7200b0a6c560f75815c08f2 (diff)
downloadlibguestfs-39a10c9fabcf7646b3dcb183c22ddba577d2a075.tar.gz
libguestfs-39a10c9fabcf7646b3dcb183c22ddba577d2a075.tar.xz
libguestfs-39a10c9fabcf7646b3dcb183c22ddba577d2a075.zip
Allow /dev/null to be added multiple times.
Change the test for duplicate drives so that you're allowed to add /dev/null multiple times. This corresponds to traditional usage. This amends commit be47b66c3033105a2b880dbc10bfc2b163b7eafe.
Diffstat (limited to 'src/launch.c')
-rw-r--r--src/launch.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/launch.c b/src/launch.c
index 986c459a..e47eda9a 100644
--- a/src/launch.c
+++ b/src/launch.c
@@ -297,6 +297,7 @@ guestfs__add_drive_opts (guestfs_h *g, const char *filename,
char *name;
char *abs_path = NULL;
int use_cache_off;
+ int check_duplicate;
if (check_path(g, filename) == -1)
return -1;
@@ -336,10 +337,16 @@ 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 (STREQ((*i)->path, abs_path)) {
+ if (check_duplicate && STREQ((*i)->path, abs_path)) {
error (g, _("drive %s can't be added twice"), abs_path);
goto err_out;
}