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 <junm...@gmail.com> --- 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