From 60f8666ae88c5a03b0da58acb94015337442e18b Mon Sep 17 00:00:00 2001 From: James Peach Date: Tue, 31 Jan 2006 06:09:18 +0000 Subject: r13255: New CIFS dd client for use in performance testing. The guts of this is in client/cifsdd*, which implements a minimal implementation of dd. The IO path is careful to always perform IO at the requested block size. There is a very basic test suite in script/tests/test_cifsdd.sh which covers local and remote IO at a variety of block sizes. Added to lib/util_str.c is a small set of conv_str_*() functions to convert strings to the corresponding type. smbcli_parse_unc is modified to insert NULL terminators after its hostname and sharename parameters. This allows it to correctly parse a path of the form //foo/share/path/file. (This used to be commit cd2f94a65817bfae20ac21b730a2c42d8e581ab3) --- source4/libcli/cliconnect.c | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) (limited to 'source4/libcli/cliconnect.c') diff --git a/source4/libcli/cliconnect.c b/source4/libcli/cliconnect.c index fe0ad9c9f5..9a5236a661 100644 --- a/source4/libcli/cliconnect.c +++ b/source4/libcli/cliconnect.c @@ -4,6 +4,7 @@ client connect/disconnect routines Copyright (C) Andrew Tridgell 2003-2005 + Copyright (C) James Peach 2005 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -175,11 +176,33 @@ struct smbcli_state *smbcli_state_init(TALLOC_CTX *mem_ctx) return talloc_zero(mem_ctx, struct smbcli_state); } +/* Insert a NULL at the first separator of the given path and return a pointer + * to the location it was inserted at. + */ +static char * +terminate_path_at_separator(char * path) +{ + char * p; + + if ((p = strchr_m(path, '/'))) { + *p = '\0'; + return(p); + } + + if ((p = strchr_m(path, '\\'))) { + *p = '\0'; + return(p); + } + + /* No terminator. Return pointer to the last byte. */ + return(p + strlen(path)); +} + /* parse a //server/share type UNC name */ BOOL smbcli_parse_unc(const char *unc_name, TALLOC_CTX *mem_ctx, - const char **hostname, const char **sharename) + char **hostname, char **sharename) { char *p; @@ -189,13 +212,10 @@ BOOL smbcli_parse_unc(const char *unc_name, TALLOC_CTX *mem_ctx, } *hostname = talloc_strdup(mem_ctx, &unc_name[2]); - p = strchr_m(&(*hostname)[2],'/'); - if (!p) { - p = strchr_m(&(*hostname)[2],'\\'); - if (!p) return False; - } - *p = 0; + p = terminate_path_at_separator(*hostname); + *sharename = talloc_strdup(mem_ctx, p+1); + p = terminate_path_at_separator(*sharename); return True; } -- cgit