summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2006-04-08 05:00:04 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:15:55 -0500
commit876f2deb3a6029b4e02ec25bc3099bfa07840a14 (patch)
treee176a8a31a7240ab551fba55e6529e4179f772c4
parent4ee43dbd477140bd4bf6c42d156dc0a736994da2 (diff)
downloadsamba-876f2deb3a6029b4e02ec25bc3099bfa07840a14.tar.gz
samba-876f2deb3a6029b4e02ec25bc3099bfa07840a14.tar.bz2
samba-876f2deb3a6029b4e02ec25bc3099bfa07840a14.zip
r14986: 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. (This used to be commit c88af597d042390ff11b26fe802b0b10d0faa6ce)
-rw-r--r--source3/smbd/dir.c36
-rw-r--r--source3/smbd/trans2.c2
2 files changed, 30 insertions, 8 deletions
diff --git a/source3/smbd/dir.c b/source3/smbd/dir.c
index 81fe7c4021..cd6c1b0bda 100644
--- a/source3/smbd/dir.c
+++ b/source3/smbd/dir.c
@@ -645,6 +645,15 @@ BOOL dptr_SearchDir(struct dptr_struct *dptr, const char *name, long *poffset, S
}
/****************************************************************************
+ 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 @@ BOOL get_dir_entry(connection_struct *conn,char *mask,uint32 dirtype, pstring fn
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 @@ const char *ReadDirName(struct smb_Dir *dirp, long *poffset)
}
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 @@ long TellDir(struct smb_Dir *dirp)
}
/*******************************************************************
+ 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.
********************************************************************/
diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
index 8429cd7149..4f5039e86c 100644
--- a/source3/smbd/trans2.c
+++ b/source3/smbd/trans2.c
@@ -1163,6 +1163,8 @@ static BOOL get_lanman2_dir_entry(connection_struct *conn,
DEBUG(5,("get_lanman2_dir_entry found %s fname=%s\n",pathreal,fname));
found = True;
+
+ dptr_DirCacheAdd(conn->dirptr, dname, curr_dirpos);
}
}