From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59937) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WKTpI-0006tW-Pm for qemu-devel@nongnu.org; Mon, 03 Mar 2014 09:26:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WKTpC-0001fs-Gz for qemu-devel@nongnu.org; Mon, 03 Mar 2014 09:26:40 -0500 Received: from [111.204.254.39] (port=9319 helo=localhost.localdomain) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WKTpB-0001fa-Q9 for qemu-devel@nongnu.org; Mon, 03 Mar 2014 09:26:34 -0500 From: Jun Li Date: Mon, 3 Mar 2014 22:02:19 +0800 Message-Id: <1393855339-13878-1-git-send-email-junmuzi@gmail.com> Subject: [Qemu-devel] [PATCH] Modify qemu-img can not create local filename contain ":" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Jun Li 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 --- 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