summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>1998-09-10 00:35:10 +0000
committerJeremy Allison <jra@samba.org>1998-09-10 00:35:10 +0000
commitaab0323d294770f80c6514389e5f84d3abf82429 (patch)
tree1baacda2492a93d24fd6a84498f9956b60081942 /source3
parent5de3c136808d891ca25009beefc194dc825a5a16 (diff)
downloadsamba-aab0323d294770f80c6514389e5f84d3abf82429.tar.gz
samba-aab0323d294770f80c6514389e5f84d3abf82429.tar.bz2
samba-aab0323d294770f80c6514389e5f84d3abf82429.zip
Improved stat cache code by uppercasing any search name that gets added to
it if we're in case insensitive mode, and then doing a memcmp rather than a StrnCaseCmp (which is *horribly* slow) on every lookup. Fixed bug with refusing NT SMB's (use *brackets* where needed :-). Jeremy. (This used to be commit 02b3fddce33a58a4db2102670b502fc0c6f45fab)
Diffstat (limited to 'source3')
-rw-r--r--source3/smbd/filename.c32
-rw-r--r--source3/smbd/negprot.c4
2 files changed, 17 insertions, 19 deletions
diff --git a/source3/smbd/filename.c b/source3/smbd/filename.c
index 0910e03ee3..caba4064d7 100644
--- a/source3/smbd/filename.c
+++ b/source3/smbd/filename.c
@@ -115,26 +115,17 @@ typedef struct {
static ubi_dlList stat_cache = { NULL, (ubi_dlNodePtr)&stat_cache, 0};
/****************************************************************************
- Compare two names in the stat cache - to check if we already have such an
- entry.
-*****************************************************************************/
-
-static BOOL stat_name_equal( char *s1, char *s2)
-{
- return (case_sensitive ? (strcmp( s1, s2) == 0) : (StrCaseCmp(s1, s2) == 0));
-}
-
-/****************************************************************************
Compare a pathname to a name in the stat cache - of a given length.
Note - this code always checks that the next character in the pathname
is either a '/' character, or a '\0' character - to ensure we only
- match *full* pathname components.
+ match *full* pathname components. Note we don't need to handle case
+ here, if we're case insensitive the stat cache orig names are all upper
+ case.
*****************************************************************************/
static BOOL stat_name_equal_len( char *stat_name, char *orig_name, int len)
{
- BOOL matched = (case_sensitive ? (strncmp( stat_name, orig_name, len) == 0) :
- (StrnCaseCmp(stat_name, orig_name, len) == 0));
+ BOOL matched = (memcmp( stat_name, orig_name, len) == 0);
if(orig_name[len] != '/' && orig_name[len] != '\0')
return False;
@@ -159,7 +150,7 @@ static void stat_cache_add( char *full_orig_name, char *orig_translated_path)
/*
* Don't cache trivial valid directory entries.
*/
- if(strequal(full_orig_name, ".") || strequal(full_orig_name, ".."))
+ if((strcmp(full_orig_name, ".") == 0) || (strcmp(full_orig_name, "..") == 0))
return;
/*
@@ -189,6 +180,8 @@ static void stat_cache_add( char *full_orig_name, char *orig_translated_path)
*/
StrnCpy(orig_name, full_orig_name, namelen);
+ if(!case_sensitive)
+ strupper( orig_name );
/*
* Check this name doesn't exist in the cache before we
@@ -197,7 +190,7 @@ static void stat_cache_add( char *full_orig_name, char *orig_translated_path)
for( scp = (stat_cache_entry *)ubi_dlFirst( &stat_cache); scp;
scp = (stat_cache_entry *)ubi_dlNext( scp )) {
- if(stat_name_equal( scp->orig_name, orig_name) &&
+ if((strcmp( scp->orig_name, orig_name) == 0) &&
(strcmp( scp->translated_name, translated_path) == 0)) {
/*
* Name does exist - promote it.
@@ -239,6 +232,7 @@ static BOOL stat_cache_lookup( char *name, char *dirpath, char **start, SMB_STRU
{
stat_cache_entry *scp;
stat_cache_entry *longest_hit = NULL;
+ pstring chk_name;
int namelen;
if (!lp_stat_cache()) return False;
@@ -251,15 +245,19 @@ static BOOL stat_cache_lookup( char *name, char *dirpath, char **start, SMB_STRU
/*
* Don't lookup trivial valid directory entries.
*/
- if(strequal(name, ".") || strequal(name, "..")) {
+ if((strcmp(name, ".") == 0) || (strcmp(name, "..") == 0)) {
global_stat_cache_misses++;
return False;
}
+ pstrcpy(chk_name, name);
+ if(!case_sensitive)
+ strupper( chk_name );
+
for( scp = (stat_cache_entry *)ubi_dlFirst( &stat_cache); scp;
scp = (stat_cache_entry *)ubi_dlNext( scp )) {
if(scp->name_len <= namelen) {
- if(stat_name_equal_len(scp->orig_name, name, scp->name_len)) {
+ if(stat_name_equal_len(scp->orig_name, chk_name, scp->name_len)) {
if((longest_hit == NULL) || (longest_hit->name_len <= scp->name_len))
longest_hit = scp;
}
diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c
index b1e8a65c94..6a9cc9fb9b 100644
--- a/source3/smbd/negprot.c
+++ b/source3/smbd/negprot.c
@@ -156,8 +156,8 @@ reply for the nt protocol
static int reply_nt1(char *outbuf)
{
/* dual names + lock_and_read + nt SMBs + remote API calls */
- int capabilities = CAP_NT_FIND|CAP_LOCK_AND_READ|CAP_RPC_REMOTE_APIS |
- lp_nt_smb_support() ? CAP_NT_SMBS : 0;
+ int capabilities = CAP_NT_FIND|CAP_LOCK_AND_READ|
+ (lp_nt_smb_support() ? CAP_NT_SMBS | CAP_RPC_REMOTE_APIS : 0);
/*
other valid capabilities which we may support at some time...