From patchwork Mon Mar 3 14:02:19 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: lijun X-Patchwork-Id: 325846 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 7E8A22C00D3 for ; Tue, 4 Mar 2014 01:27:09 +1100 (EST) Received: from localhost ([::1]:40021 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WKTpi-0007T1-QT for incoming@patchwork.ozlabs.org; Mon, 03 Mar 2014 09:27:06 -0500 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 Received: from localhost.localdomain (localhost [127.0.0.1]) by localhost.localdomain (8.14.7/8.14.7) with ESMTP id s23E2Un6013916; Mon, 3 Mar 2014 22:02:30 +0800 Received: (from lijun@localhost) by localhost.localdomain (8.14.7/8.14.7/Submit) id s23E2TNf013915; Mon, 3 Mar 2014 22:02:29 +0800 From: Jun Li To: qemu-devel@nongnu.org Date: Mon, 3 Mar 2014 22:02:19 +0800 Message-Id: <1393855339-13878-1-git-send-email-junmuzi@gmail.com> X-Mailer: git-send-email 1.8.3.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 111.204.254.39 Cc: Jun Li Subject: [Qemu-devel] [PATCH] Modify qemu-img can not create local filename contain ":" X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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)