svn commit: samba r5578 - in branches/SAMBA_3_0/source: client libsmb

jerry at samba.org jerry at samba.org
Sat Feb 26 15:03:16 GMT 2005


Author: jerry
Date: 2005-02-26 15:03:16 +0000 (Sat, 26 Feb 2005)
New Revision: 5578

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=5578

Log:
get 'recurse; dir' working across multiple levels of dfs referrals 

note that this does not handle the situation where the same \\server\share
is mounted mutliple times in the dfs tree since I store a single mount
path per struct cli_state *


Modified:
   branches/SAMBA_3_0/source/client/client.c
   branches/SAMBA_3_0/source/libsmb/clidfs.c


Changeset:
Modified: branches/SAMBA_3_0/source/client/client.c
===================================================================
--- branches/SAMBA_3_0/source/client/client.c	2005-02-26 14:42:55 UTC (rev 5577)
+++ branches/SAMBA_3_0/source/client/client.c	2005-02-26 15:03:16 UTC (rev 5578)
@@ -217,7 +217,7 @@
 	struct cli_state *targetcli;
 	pstring targetpath;
 
-	if ( !cli_resolve_path( cli, cur_dir, &targetcli, targetpath ) ) {
+	if ( !cli_resolve_path( "", cli, cur_dir, &targetcli, targetpath ) ) {
 		d_printf("Error in dskattr: %s\n", cli_errstr(cli));
 	}
 
@@ -277,7 +277,7 @@
 	pstrcat(cur_dir,"\\");
 	dos_clean_name(cur_dir);
 	
-	if ( !cli_resolve_path( cli, dname, &targetcli, targetpath ) ) {
+	if ( !cli_resolve_path( "", cli, dname, &targetcli, targetpath ) ) {
 		d_printf("cd %s: %s\n", dname, cli_errstr(cli));
 		pstrcpy(cur_dir,saved_dir);
 		goto out;
@@ -582,7 +582,7 @@
 			
 			/* check for dfs */
 			
-			if ( !cli_resolve_path( cli, head, &targetcli, targetpath ) ) {
+			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;
@@ -609,7 +609,7 @@
 	} else {
 		/* check for dfs */
 			
-		if ( cli_resolve_path( cli, mask, &targetcli, targetpath ) ) {
+		if ( cli_resolve_path( "", cli, mask, &targetcli, targetpath ) ) {
 			if (cli_list(targetcli, targetpath, attribute, do_list_helper, NULL) == -1) 
 				d_printf("%s listing %s\n", cli_errstr(targetcli), targetpath);
 		}
@@ -722,7 +722,7 @@
 		strlower_m(lname);
 	}
 
-	if ( !cli_resolve_path( cli, rname, &targetcli, targetname ) ) {
+	if ( !cli_resolve_path( "", cli, rname, &targetcli, targetname ) ) {
 		d_printf("Failed to open %s: %s\n", rname, cli_errstr(cli));
 		return 1;
 	}
@@ -1018,7 +1018,7 @@
 	struct cli_state *targetcli;
 	pstring targetname;
 	
-	if ( !cli_resolve_path( cli, name, &targetcli, targetname ) ) {
+	if ( !cli_resolve_path( "", cli, name, &targetcli, targetname ) ) {
 		d_printf("mkdir %s: %s\n", name, cli_errstr(cli));
 		return False;
 	}
@@ -1143,7 +1143,7 @@
 	struct cli_state *targetcli;
 	pstring targetname;
 	
-	if ( !cli_resolve_path( cli, rname, &targetcli, targetname ) ) {
+	if ( !cli_resolve_path( "", cli, rname, &targetcli, targetname ) ) {
 		d_printf("Failed to open %s: %s\n", rname, cli_errstr(cli));
 		return 1;
 	}
@@ -1655,7 +1655,7 @@
 	}
 	pstrcat(mask,buf);
 
-	if ( !cli_resolve_path( cli, mask, &targetcli, targetname ) ) {
+	if ( !cli_resolve_path( "", cli, mask, &targetcli, targetname ) ) {
 		d_printf("open %s: %s\n", mask, cli_errstr(cli));
 		return 1;
 	}
@@ -1685,7 +1685,7 @@
 	}
 	pstrcat(mask,buf);
 
-	if ( !cli_resolve_path( cli, mask, &targetcli, targetname ) ) {
+	if ( !cli_resolve_path( "", cli, mask, &targetcli, targetname ) ) {
 		d_printf("rmdir %s: %s\n", mask, cli_errstr(cli));
 		return 1;
 	}
@@ -1721,7 +1721,7 @@
 	pstrcat(oldname,buf);
 	pstrcat(newname,buf2);
 
-	if ( !cli_resolve_path( cli, oldname, &targetcli, targetname ) ) {
+	if ( !cli_resolve_path( "", cli, oldname, &targetcli, targetname ) ) {
 		d_printf("link %s: %s\n", oldname, cli_errstr(cli));
 		return 1;
 	}
@@ -1796,7 +1796,7 @@
 	mode = (mode_t)strtol(buf, NULL, 8);
 	pstrcat(src,buf2);
 
-	if ( !cli_resolve_path( cli, src, &targetcli, targetname ) ) {
+	if ( !cli_resolve_path( "", cli, src, &targetcli, targetname ) ) {
 		d_printf("chmod %s: %s\n", src, cli_errstr(cli));
 		return 1;
 	}
@@ -1944,7 +1944,7 @@
 
 	pstrcat(src,name);
 	
-	if ( !cli_resolve_path( cli, src, &targetcli, targetname ) ) {
+	if ( !cli_resolve_path( "", cli, src, &targetcli, targetname ) ) {
 		d_printf("stat %s: %s\n", src, cli_errstr(cli));
 		return 1;
 	}
@@ -2109,7 +2109,7 @@
 	pstrcat(src,name);
 
 	
-	if ( !cli_resolve_path( cli, src, &targetcli, targetname ) ) {
+	if ( !cli_resolve_path( "", cli, src, &targetcli, targetname ) ) {
 		d_printf("stat %s: %s\n", src, cli_errstr(cli));
 		return 1;
 	}
@@ -2185,7 +2185,7 @@
 	gid = (gid_t)atoi(buf2);
 	pstrcat(src,buf3);
 
-	if ( !cli_resolve_path( cli, src, &targetcli, targetname ) ) {
+	if ( !cli_resolve_path( "", cli, src, &targetcli, targetname ) ) {
 		d_printf("chown %s: %s\n", src, cli_errstr(cli));
 		return 1;
 	}
@@ -2257,7 +2257,7 @@
 	pstrcat(src,buf);
 	pstrcat(dest,buf2);
 
-	if ( !cli_resolve_path( cli, src, &targetcli, targetname ) ) {
+	if ( !cli_resolve_path( "", cli, src, &targetcli, targetname ) ) {
 		d_printf("hardlink %s: %s\n", src, cli_errstr(cli));
 		return 1;
 	}
@@ -2669,7 +2669,7 @@
 	struct cli_state *targetcli;
 	pstring targetpath;
 	
-	if ( !cli_resolve_path( cli, cur_dir, &targetcli, targetpath ) ) {
+	if ( !cli_resolve_path( "", cli, cur_dir, &targetcli, targetpath ) ) {
 		d_printf("showconnect %s: %s\n", cur_dir, cli_errstr(cli));
 		return 1;
 	}

Modified: branches/SAMBA_3_0/source/libsmb/clidfs.c
===================================================================
--- branches/SAMBA_3_0/source/libsmb/clidfs.c	2005-02-26 14:42:55 UTC (rev 5577)
+++ branches/SAMBA_3_0/source/libsmb/clidfs.c	2005-02-26 15:03:16 UTC (rev 5578)
@@ -174,8 +174,6 @@
 {
 	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) )
@@ -185,14 +183,6 @@
 	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
 	}
 }
 
@@ -567,7 +557,7 @@
 /********************************************************************
 ********************************************************************/
 
-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;
@@ -579,6 +569,8 @@
 	fstring server, share;
 	struct cli_state *newcli;
 	pstring newpath;
+	pstring newmount;
+	char *ppath;
 	
 	SMB_STRUCT_STAT sbuf;
 	uint32 attributes;
@@ -637,17 +629,28 @@
 		return False;
 	}
 	
-	cli_cm_set_mntpoint( *targetcli, cleanpath );
+	/* 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;
 }



More information about the samba-cvs mailing list