From 96572957fc3df956ec0fad242fc7d04ab6a6961f Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Sat, 26 Feb 2005 14:42:55 +0000 Subject: r5577: get recurse; dir working across single level dfs referrals (This used to be commit d4443807bc7a5a8615c69517365a92709db7ce29) --- source3/client/client.c | 8 +++++--- source3/libsmb/clidfs.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++ source3/libsmb/clilist.c | 13 +++++++----- 3 files changed, 66 insertions(+), 8 deletions(-) (limited to 'source3') diff --git a/source3/client/client.c b/source3/client/client.c index 55e9f1a71d..515a2335ad 100644 --- a/source3/client/client.c +++ b/source3/client/client.c @@ -509,7 +509,7 @@ static int do_list_queue_empty(void) A helper for do_list. ****************************************************************************/ -static void do_list_helper(file_info *f, const char *mask, void *state) +static void do_list_helper(const char *mntpoint, file_info *f, const char *mask, void *state) { if (f->mode & aDIR) { if (do_list_dirs && do_this_one(f)) { @@ -526,7 +526,8 @@ static void do_list_helper(file_info *f, const char *mask, void *state) return; } - pstrcpy(mask2, mask); + pstrcpy(mask2, mntpoint); + pstrcat(mask2, mask); p = strrchr_m(mask2,'\\'); if (!p) return; @@ -583,6 +584,7 @@ void do_list(const char *mask,uint16 attribute,void (*fn)(file_info *),BOOL rec, if ( !cli_resolve_path( cli, head, &targetcli, targetpath ) ) { d_printf("do_list: [%s] %s\n", head, cli_errstr(cli)); + remove_do_list_queue_head(); continue; } @@ -2871,7 +2873,7 @@ typedef struct { int len; } completion_remote_t; -static void completion_remote_filter(file_info *f, const char *mask, void *state) +static void completion_remote_filter(const char *mnt, file_info *f, const char *mask, void *state) { completion_remote_t *info = (completion_remote_t *)state; diff --git a/source3/libsmb/clidfs.c b/source3/libsmb/clidfs.c index 6db6330ca6..62b682a748 100644 --- a/source3/libsmb/clidfs.c +++ b/source3/libsmb/clidfs.c @@ -27,6 +27,7 @@ struct client_connection { struct client_connection *prev, *next; struct cli_state *cli; + pstring mount; }; /* global state....globals reek! */ @@ -166,6 +167,54 @@ static struct cli_state *do_connect( const char *server, const char *share, return c; } +/**************************************************************************** +****************************************************************************/ + +static void cli_cm_set_mntpoint( struct cli_state *c, const char *mnt ) +{ + struct client_connection *p; + int i; + pstring path; + char *ppath; + + for ( p=connections,i=0; p; p=p->next,i++ ) { + if ( strequal(p->cli->desthost, c->desthost) && strequal(p->cli->share, c->share) ) + break; + } + + if ( p ) { + pstrcpy( p->mount, mnt ); + dos_clean_name( p->mount ); + +#if 0 + /* strip any leading '\\' */ + ppath = path; + if ( *ppath == '\\' ) + ppath++; + pstrcpy( p->mount, ppath ); +#endif + } +} + +/**************************************************************************** +****************************************************************************/ + +const char * cli_cm_get_mntpoint( struct cli_state *c ) +{ + struct client_connection *p; + int i; + + for ( p=connections,i=0; p; p=p->next,i++ ) { + if ( strequal(p->cli->desthost, c->desthost) && strequal(p->cli->share, c->share) ) + break; + } + + if ( p ) + return p->mount; + + return NULL; +} + /******************************************************************** Add a new connection to the list ********************************************************************/ @@ -186,6 +235,8 @@ static struct cli_state* cli_cm_connect( const char *server, const char *share, DLIST_ADD( connections, node ); + cli_cm_set_mntpoint( node->cli, "" ); + return node->cli; } @@ -585,6 +636,8 @@ BOOL cli_resolve_path( struct cli_state *rootcli, const char *path, return False; } + + cli_cm_set_mntpoint( *targetcli, cleanpath ); /* check for another dfs refeerrali, note that we are not checking for loops here */ diff --git a/source3/libsmb/clilist.c b/source3/libsmb/clilist.c index 532fb3a772..4e90a79719 100644 --- a/source3/libsmb/clilist.c +++ b/source3/libsmb/clilist.c @@ -143,7 +143,7 @@ static int interpret_long_filename(struct cli_state *cli, ****************************************************************************/ int cli_list_new(struct cli_state *cli,const char *Mask,uint16 attribute, - void (*fn)(file_info *, const char *, void *), void *state) + void (*fn)(const char *, file_info *, const char *, void *), void *state) { #if 0 int max_matches = 1366; /* Match W2k - was 512. */ @@ -322,8 +322,11 @@ int cli_list_new(struct cli_state *cli,const char *Mask,uint16 attribute, } for (p=dirlist,i=0;iprotocol <= PROTOCOL_LANMAN1) return cli_list_old(cli, Mask, attribute, fn, state); -- cgit