Sun Oct 17 01:29:24 CEST 1999 Modified Files in squid/src store_dir.c Oops.. my earlier patch for directory specific component other than a number to cache_swap_log was slightly broken. It did work, but the generated name had one more dot in it than intended. ----------------------------------------------------------------- This patch adds the capability of having a directory name specific part in cache_swap_log names (%s), replacing the numeric component. Handy if you want to be able to add/remove cache_dir lines while using cache_swap_log to move the index files to another location. ----------------------------------------------------------------- Index: squid/src/cf.data.pre diff -u squid/src/cf.data.pre:1.1.1.38.2.6 squid/src/cf.data.pre:1.1.1.38.2.7 --- squid/src/cf.data.pre:1.1.1.38.2.6 Tue Jul 13 00:50:45 1999 +++ squid/src/cf.data.pre Sun Aug 1 17:44:26 1999 @@ -664,14 +664,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.c diff -u squid/src/store_dir.c:1.1.1.22.2.1 squid/src/store_dir.c:1.1.1.22.2.6 --- squid/src/store_dir.c:1.1.1.22.2.1 Tue Jul 13 00:51:31 1999 +++ squid/src/store_dir.c Sun Oct 17 01:29:24 1999 @@ -442,12 +442,24 @@ storeDirSwapLogFile(int dirn, 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", dirn); - strncat(path, digit, 3); + xstrncpy(pathtmp, storeSwapDir(dirn), SQUID_MAXPATHLEN); + while (index(pathtmp,'/')) + *index(pathtmp,'/')='.'; + while (strlen(pathtmp) && pathtmp[strlen(pathtmp)-1]=='.') + pathtmp[strlen(pathtmp)-1]= '\0'; + pathtmp2 = pathtmp; + while (*pathtmp2 == '.') + pathtmp2 += 1; + snprintf(path, SQUID_MAXPATHLEN, Config.Log.swap, pathtmp2); + if (strcmp(path, Config.Log.swap) == 0) { + strcat(path, "."); + snprintf(digit, 32, "%02d", dirn); + strncat(path, digit, 3); + } } else { xstrncpy(path, storeSwapDir(dirn), SQUID_MAXPATHLEN - 64); strcat(path, "/swap.state");