qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH] Modify qemu-img can not create local filename conta


From: Jun Li
Subject: [Qemu-devel] [PATCH] Modify qemu-img can not create local filename contain ":"
Date: Mon, 3 Mar 2014 22:02:19 +0800

Such as how to visit glusterfs:
file=gluster://1.2.3.4/testvol/a.img
file=gluster+tcp://1.2.3.4/testvol/a.img
file=gluster+tcp://1.2.3.4:24007/testvol/dir/a.img
file=gluster+tcp://[1:2:3:4:5:6:7:8]/testvol/dir/a.img
file=gluster+tcp://[1:2:3:4:5:6:7:8]:24007/testvol/dir/a.img
file=gluster+tcp://server.domain.com:24007/testvol/dir/a.img
file=gluster+rdma://1.2.3.4:24007/testvol/a.img
----
So if only the path contain "://", the path maybe contain a protocol. So use
strstr() to replace func strcspn().

Signed-off-by: Jun Li <address@hidden>
---
 block.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/block.c b/block.c
index 2fd5482..aead10e 100644
--- a/block.c
+++ b/block.c
@@ -237,12 +237,12 @@ static int path_has_protocol(const char *path)
         is_windows_drive_prefix(path)) {
         return 0;
     }
-    p = path + strcspn(path, ":/\\");
+    p = strstr(path, ":/\\");
 #else
-    p = path + strcspn(path, ":/");
+    p = strstr(path, "://");
 #endif
 
-    return *p == ':';
+    return p != NULL;
 }
 
 int path_is_absolute(const char *path)
-- 
1.8.3.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]