mirror of
https://github.com/samba-team/samba.git
synced 2025-08-08 13:49:29 +03:00
r5577: get recurse; dir working across single level dfs referrals
This commit is contained in:
committed by
Gerald (Jerry) Carter
parent
cadd5a44e7
commit
d4443807bc
@ -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;
|
||||
|
||||
|
@ -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 */
|
||||
|
@ -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);
|
||||
|
Reference in New Issue
Block a user