summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2005-02-26 14:42:55 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 10:55:48 -0500
commit96572957fc3df956ec0fad242fc7d04ab6a6961f (patch)
tree59379dd1ff10ce299201eae187893c0b2124c716
parent76d72a6bc62cba0111cb82b87b560255513e49c2 (diff)
downloadsamba-96572957fc3df956ec0fad242fc7d04ab6a6961f.tar.gz
samba-96572957fc3df956ec0fad242fc7d04ab6a6961f.tar.bz2
samba-96572957fc3df956ec0fad242fc7d04ab6a6961f.zip
r5577: get recurse; dir working across single level dfs referrals
(This used to be commit d4443807bc7a5a8615c69517365a92709db7ce29)
-rw-r--r--source3/client/client.c8
-rw-r--r--source3/libsmb/clidfs.c53
-rw-r--r--source3/libsmb/clilist.c13
3 files changed, 66 insertions, 8 deletions
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;i<total_received;i++) {
+ const char *mnt = cli_cm_get_mntpoint( cli );
+
p += interpret_long_filename(cli,info_level,p,&finfo);
- fn(&finfo, Mask, state);
+
+ fn( mnt,&finfo, Mask, state );
}
/* free up the dirlist buffer */
@@ -365,7 +368,7 @@ static int interpret_short_filename(struct cli_state *cli, char *p,file_info *fi
****************************************************************************/
int cli_list_old(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)
{
char *p;
int received = 0;
@@ -472,7 +475,7 @@ int cli_list_old(struct cli_state *cli,const char *Mask,uint16 attribute,
for (p=dirlist,i=0;i<num_received;i++) {
file_info finfo;
p += interpret_short_filename(cli, p,&finfo);
- fn(&finfo, Mask, state);
+ fn("\\", &finfo, Mask, state);
}
SAFE_FREE(dirlist);
@@ -485,7 +488,7 @@ int cli_list_old(struct cli_state *cli,const char *Mask,uint16 attribute,
****************************************************************************/
int cli_list(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 (cli->protocol <= PROTOCOL_LANMAN1)
return cli_list_old(cli, Mask, attribute, fn, state);