From b17b110bb681358920e946960a567bdac299e4ee Mon Sep 17 00:00:00 2001 From: Oliver Bolte Date: Tue, 12 Jun 2007 05:08:51 +0000 Subject: INTEGRATION: CWS dmake48 (1.6.2); FILE MERGED 2007/01/21 23:21:13 vq 1.6.2.1: #i73661# Improve case insensitive directory caching on case sensitive file systems but it is *not* recommended to to so. A comment was added to the man page emphasizing this. --- dmake/unix/dcache.c | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) (limited to 'dmake/unix') diff --git a/dmake/unix/dcache.c b/dmake/unix/dcache.c index c03dfd5d144b..169d037303c3 100644 --- a/dmake/unix/dcache.c +++ b/dmake/unix/dcache.c @@ -1,6 +1,6 @@ /* $RCSfile: dcache.c,v $ --- $Revision: 1.6 $ --- last change: $Author: vg $ $Date: 2007-01-18 09:43:52 $ +-- $Revision: 1.7 $ +-- last change: $Author: obo $ $Date: 2007-06-12 06:08:51 $ -- -- SYNOPSIS -- Directory cache management routines. @@ -98,6 +98,7 @@ int force; char *spath; char *comp; char *dir; + char *udir; /* Hold the unchanged (DcacheRespCase) directory. */ int loaded=FALSE; if (If_root_path(path)) @@ -107,13 +108,17 @@ int force; fpath = DmStrDup(spath); - /* do caching and comparing lower case if told so. */ - if( !STOBOOL(DcacheRespCase) ) - strlwr(fpath); - - comp = Basename(fpath); + comp = Basename(fpath); /* Use before the Filedir() call. */ dir = Filedir(fpath); + /* do caching and comparing lower case if told so. */ + if( !STOBOOL(DcacheRespCase) ) { + udir = DmStrDup(dir); + strlwr(comp); + strlwr(dir); + } else + udir = dir; + hv = Hash(dir,&hkey); for(dp=dtab[hv]; dp; dp=dp->next) @@ -137,7 +142,18 @@ int force; dp->path = DmStrDup(dir); dp->hkey = hkey; - if (Set_dir(dir) == 0) { + /* We use the unchanged (not potentially lowercased because of + * DcacheRespCase) directory as this would fail on a case sensitive + * file system. + * Note: Using case insensitive directory caching on case sensitive + * file systems is a *BAD* idea. If in doubt use case sensitive + * directory caching even on case insensitive file systems as the + * worst case in this szenario is that /foo/bar/ and /foo/BAR/ are + * cached separately (with the same content) even though they are + * the same directory. This would only happen if different targets + * using different upper/lower case spellings for the same directory + * and is *never* a good idea. */ + if (Set_dir(udir) == 0) { if((dirp=opendir(".")) != NIL(DIR)) { while((direntp=readdir(dirp)) != NULL) { TALLOC(ep,1,Entry); @@ -199,6 +215,9 @@ int force; Pname, spath, ep ? ep->mtime : 0L); } + if( udir != dir ) + FREE(udir); /* Keep this before the free of fpath. */ + FREE(fpath); return(!ep ? (time_t)0L : ((STOBOOL(Augmake) && ep->isdir)?0L:ep->mtime)); } -- cgit v1.2.3