svn commit: samba r14987 - in trunk/source/smbd: .

jra at samba.org jra at samba.org
Sat Apr 8 05:00:07 GMT 2006


Author: jra
Date: 2006-04-08 05:00:05 +0000 (Sat, 08 Apr 2006)
New Revision: 14987

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

Log:
Fix OS/2 directory delete bug found by kukks.
(Thanks a lot for all your hard work on this).
We were caching the results of *all* directory
scans, not just the results that match the
client wildcard. This actually made no sense,
as only matches on the client wildcard can be
returned to the client and so might need to
be searched for in the cache. This fixes the
directory cache to only cache entries that we
return to the client.
Jeremy.

Modified:
   trunk/source/smbd/dir.c
   trunk/source/smbd/trans2.c


Changeset:
Modified: trunk/source/smbd/dir.c
===================================================================
--- trunk/source/smbd/dir.c	2006-04-08 05:00:04 UTC (rev 14986)
+++ trunk/source/smbd/dir.c	2006-04-08 05:00:05 UTC (rev 14987)
@@ -645,6 +645,15 @@
 }
 
 /****************************************************************************
+ Add the name we're returning into the underlying cache.
+****************************************************************************/
+
+void dptr_DirCacheAdd(struct dptr_struct *dptr, const char *name, long offset)
+{
+	DirCacheAdd(dptr->dir_hnd, name, offset);
+}
+
+/****************************************************************************
  Fill the 5 byte server reserved dptr field.
 ****************************************************************************/
 
@@ -812,6 +821,8 @@
 			DEBUG(3,("get_dir_entry mask=[%s] found %s fname=%s\n",mask, pathreal,fname));
 
 			found = True;
+
+			DirCacheAdd(conn->dirptr->dir_hnd, dname, curoff);
 		}
 	}
 
@@ -1109,21 +1120,15 @@
 	}
 
 	while ((n = vfs_readdirname(conn, dirp->dir))) {
-		struct name_cache_entry *e;
 		/* Ignore . and .. - we've already returned them. */
 		if (*n == '.') {
 			if ((n[1] == '\0') || (n[1] == '.' && n[2] == '\0')) {
 				continue;
 			}
 		}
-		dirp->offset = SMB_VFS_TELLDIR(conn, dirp->dir);
-		dirp->name_cache_index = (dirp->name_cache_index+1) % NAME_CACHE_SIZE;
-		e = &dirp->name_cache[dirp->name_cache_index];
-		SAFE_FREE(e->name);
-		e->name = SMB_STRDUP(n);
-		*poffset = e->offset= dirp->offset;
+		*poffset = dirp->offset = SMB_VFS_TELLDIR(conn, dirp->dir);
 		dirp->file_number++;
-		return e->name;
+		return n;
 	}
 	*poffset = dirp->offset = END_OF_DIRECTORY_OFFSET;
 	return NULL;
@@ -1184,6 +1189,21 @@
 }
 
 /*******************************************************************
+ Add an entry into the dcache.
+********************************************************************/
+
+void DirCacheAdd(struct smb_Dir *dirp, const char *name, long offset)
+{
+	struct name_cache_entry *e;
+
+	dirp->name_cache_index = (dirp->name_cache_index+1) % NAME_CACHE_SIZE;
+	e = &dirp->name_cache[dirp->name_cache_index];
+	SAFE_FREE(e->name);
+	e->name = SMB_STRDUP(name);
+	e->offset = offset;
+}
+
+/*******************************************************************
  Find an entry by name. Leave us at the offset after it.
  Don't check for veto or invisible files.
 ********************************************************************/

Modified: trunk/source/smbd/trans2.c
===================================================================
--- trunk/source/smbd/trans2.c	2006-04-08 05:00:04 UTC (rev 14986)
+++ trunk/source/smbd/trans2.c	2006-04-08 05:00:05 UTC (rev 14987)
@@ -1163,6 +1163,8 @@
 			DEBUG(5,("get_lanman2_dir_entry found %s fname=%s\n",pathreal,fname));
 	  
 			found = True;
+
+			dptr_DirCacheAdd(conn->dirptr, dname, curr_dirpos);
 		}
 	}
 



More information about the samba-cvs mailing list