Sun Oct 17 15:23:51 CEST 1999 Modified Files in squid/src store_dir_ufs.c Oops.. the cache_swap_log_name patch was not entirely correct. The generated name could contain somewhat more dots than intended.. ----------------------------------------------------------------- Squid-2.3.DEVEL2: cache_swap_log name based on cache_dir name Allow %s to be used in cache_swap_log to build a log file name based on the cache_dir name instead of numbering the files according to their corresponding cache_dir location in squid.conf. This is very useful if you'd like to be able to add or remove cache directories while using cache_swap_log to have the index files stored outside the cache directories. ----------------------------------------------------------------- Index: squid/src/cf.data.pre diff -u squid/src/cf.data.pre:1.1.1.39.2.4 squid/src/cf.data.pre:1.1.1.39.2.10 --- squid/src/cf.data.pre:1.1.1.39.2.4 Sat Aug 7 21:13:31 1999 +++ squid/src/cf.data.pre Sun Oct 17 15:08:46 1999 @@ -681,14 +684,19 @@ DOC_START Location for the cache "swap.log." This log file holds the metadata of objects saved on disk. It is used to rebuild the - cache during startup. Normally this file resides in the first + cache during startup. Normally this file resides in each 'cache_dir' directory, but you may specify an alternate pathname here. Note you must give a full filename, not just a directory. Since this is the index for the whole object list you CANNOT periodically rotate it! - If you have more than one 'cache_dir', these swap logs will - have names such as: + If %s can be used in the file name then it will be replaced with a + a representation of the cache_dir name where each / is replaced + with '.'. This is needed to allow adding/removing cache_dir + lines when cache_swap_log is being used. + + If have more than one 'cache_dir', and %s is not used in the name + then these swap logs will have names such as: cache_swap_log.00 cache_swap_log.01 Index: squid/src/store_dir_ufs.c diff -u squid/src/store_dir_ufs.c:1.1.1.2.2.1 squid/src/store_dir_ufs.c:1.1.1.2.2.3 --- squid/src/store_dir_ufs.c:1.1.1.2.2.1 Sat Aug 7 22:36:32 1999 +++ squid/src/store_dir_ufs.c Sun Oct 17 15:23:51 1999 @@ -200,12 +200,22 @@ storeUfsDirSwapLogFile(SwapDir * sd, const char *ext) { LOCAL_ARRAY(char, path, SQUID_MAXPATHLEN); + LOCAL_ARRAY(char, pathtmp, SQUID_MAXPATHLEN); LOCAL_ARRAY(char, digit, 32); + char *pathtmp2; if (Config.Log.swap) { - xstrncpy(path, Config.Log.swap, SQUID_MAXPATHLEN - 64); - strcat(path, "."); - snprintf(digit, 32, "%02d", sd->index); - strncat(path, digit, 3); + xstrncpy(pathtmp, sd->path, SQUID_MAXPATHLEN - 64); + while (index(pathtmp,'/')) + *index(pathtmp,'/')='.'; + while (strlen(pathtmp) && pathtmp[strlen(pathtmp)-1]=='.') + pathtmp[strlen(pathtmp)-1]= '\0'; + for(pathtmp2 = pathtmp; *pathtmp2 == '.'; pathtmp2++); + snprintf(path, SQUID_MAXPATHLEN-64, Config.Log.swap, pathtmp2); + if (strncmp(path, Config.Log.swap, SQUID_MAXPATHLEN - 64) == 0) { + strcat(path, "."); + snprintf(digit, 32, "%02d", sd->index); + strncat(path, digit, 3); + } } else { xstrncpy(path, sd->path, SQUID_MAXPATHLEN - 64); strcat(path, "/swap.state");