From: wessels <> Date: Thu, 12 Feb 1998 01:48:50 +0000 (+0000) Subject: Another storeDirClean() fix. Had to write a 'belongs here' function. X-Git-Tag: SQUID_3_0_PRE1~4112 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=68c2e6f720f6c3d4a11638a8e455ffa36b37977e;p=thirdparty%2Fsquid.git Another storeDirClean() fix. Had to write a 'belongs here' function. --- diff --git a/src/protos.h b/src/protos.h index b4e7ebc833..e1124d2ca0 100644 --- a/src/protos.h +++ b/src/protos.h @@ -503,6 +503,7 @@ extern void storeCreateSwapDirectories(void); extern int storeVerifyCacheDirs(void); extern int storeDirWriteCleanLogs(int reopen); extern int storeDirValidFileno(int fn); +extern int storeFilenoBelongsHere(int, int, int, int); /* diff --git a/src/store_dir.cc b/src/store_dir.cc index c16a21448e..492f94dcb5 100644 --- a/src/store_dir.cc +++ b/src/store_dir.cc @@ -1,6 +1,6 @@ /* - * $Id: store_dir.cc,v 1.52 1998/02/11 03:14:39 wessels Exp $ + * $Id: store_dir.cc,v 1.53 1998/02/11 18:48:52 wessels Exp $ * * DEBUG: section 47 Store Directory Routines * AUTHOR: Duane Wessels @@ -94,6 +94,33 @@ storeSwapSubSubDir(int fn, char *fullpath) return fullpath; } +/* + * Does swapfile number 'fn' belong in cachedir #F0, + * level1 dir #F1, level2 dir #F2? + * + * This is called by storeDirClean(), but placed here because + * the algorithm needs to match storeSwapSubSubDir(). + */ +int +storeFilenoBelongsHere(int fn, int F0, int F1, int F2) +{ + int D0, D1, D2; + int L1, L2; + int filn = fn & SWAP_FILE_MASK; + D0 = (fn >> SWAP_DIR_SHIFT) % Config.cacheSwap.n_configured; + if (F0 != D0) + return 0; + L1 = Config.cacheSwap.swapDirs[D0].l1; + L2 = Config.cacheSwap.swapDirs[D0].l2; + D1 = ((filn / L2) / L2) % L1; + if (F1 != D1) + return 0; + D2 = (filn / L2) % L2; + if (F2 != D2) + return 0; + return 1; +} + static void storeCreateDirectory(const char *path, int lvl) {