diff options
author | Gerald Carter <jerry@samba.org> | 2005-03-11 10:52:54 +0000 |
---|---|---|
committer | Gerald Carter <jerry@samba.org> | 2005-03-11 10:52:54 +0000 |
commit | 061a07f6b476428c622618d83a5a1e54c5f05fe5 (patch) | |
tree | 5e926c06e720253210687391b68aa82f553c9ad3 /source/libsmb/clidfs.c | |
parent | 6c30768e14f5639328e06a73940f133f9078b90e (diff) | |
download | samba-061a07f6b476428c622618d83a5a1e54c5f05fe5.tar.gz |
r5739: sync for 3.0.12rc1 (current with SAMBA_3_0 r5738)
Diffstat (limited to 'source/libsmb/clidfs.c')
-rw-r--r-- | source/libsmb/clidfs.c | 66 |
1 files changed, 61 insertions, 5 deletions
diff --git a/source/libsmb/clidfs.c b/source/libsmb/clidfs.c index 6db6330ca6b..e4308fdb5a4 100644 --- a/source/libsmb/clidfs.c +++ b/source/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,44 @@ 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; + + 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 ); + } +} + +/**************************************************************************** +****************************************************************************/ + +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 +225,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; } @@ -443,7 +484,7 @@ BOOL cli_dfs_get_referral( struct cli_state *cli, const char *path, char *p; size_t pathlen = 2*(strlen(path)+1); uint16 num_referrals; - CLIENT_DFS_REFERRAL *referrals; + CLIENT_DFS_REFERRAL *referrals = NULL; memset(param, 0, sizeof(param)); SSVAL(param, 0, 0x03); /* max referral level */ @@ -516,7 +557,7 @@ BOOL cli_dfs_get_referral( struct cli_state *cli, const char *path, /******************************************************************** ********************************************************************/ -BOOL cli_resolve_path( struct cli_state *rootcli, const char *path, +BOOL cli_resolve_path( const char *mountpt, struct cli_state *rootcli, const char *path, struct cli_state **targetcli, pstring targetpath ) { CLIENT_DFS_REFERRAL *refs = NULL; @@ -528,6 +569,8 @@ BOOL cli_resolve_path( struct cli_state *rootcli, const char *path, fstring server, share; struct cli_state *newcli; pstring newpath; + pstring newmount; + char *ppath; SMB_STRUCT_STAT sbuf; uint32 attributes; @@ -585,16 +628,29 @@ BOOL cli_resolve_path( struct cli_state *rootcli, const char *path, return False; } + + /* parse out the consumed mount path */ + /* trim off the \server\share\ */ - /* check for another dfs refeerrali, note that we are not + fullpath[consumed/2] = '\0'; + dos_clean_name( fullpath ); + ppath = strchr_m( fullpath, '\\' ); + ppath = strchr_m( ppath+1, '\\' ); + ppath = strchr_m( ppath+1, '\\' ); + ppath++; + + pstr_sprintf( newmount, "%s\\%s", mountpt, ppath ); + cli_cm_set_mntpoint( *targetcli, newmount ); + + /* check for another dfs referral, note that we are not checking for loops here */ if ( !strequal( targetpath, "\\" ) ) { - if ( cli_resolve_path( *targetcli, targetpath, &newcli, newpath ) ) { + if ( cli_resolve_path( newmount, *targetcli, targetpath, &newcli, newpath ) ) { *targetcli = newcli; pstrcpy( targetpath, newpath ); } } - + return True; } |