From: hno <> Date: Tue, 8 May 2001 21:24:34 +0000 (+0000) Subject: Generalized how cache_dir lines are dumped on mgr:config X-Git-Tag: SQUID_3_0_PRE1~1516 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=25a77f038f3eb57aae2ddb44050ef6bf85e56c6d;p=thirdparty%2Fsquid.git Generalized how cache_dir lines are dumped on mgr:config --- diff --git a/doc/Programming-Guide/prog-guide.sgml b/doc/Programming-Guide/prog-guide.sgml index d699293201..8c5f510560 100644 --- a/doc/Programming-Guide/prog-guide.sgml +++ b/doc/Programming-Guide/prog-guide.sgml @@ -2,7 +2,7 @@
Squid Programmers Guide Duane Wessels, Squid Developers -$Id: prog-guide.sgml,v 1.39 2001/04/27 23:42:05 wessels Exp $ +$Id: prog-guide.sgml,v 1.40 2001/05/08 15:24:34 hno Exp $ Squid is a WWW Cache application developed by the National Laboratory @@ -990,15 +990,16 @@ Squid consists of the following major components

typedef void - STDUMP(StoreEntry *e, const char *path, SwapDir *SD); + STDUMP(StoreEntry *e, SwapDir *SD);

- Dump the configuration of the current freefs diff --git a/src/cache_cf.cc b/src/cache_cf.cc index 563d67a688..22fc67b23b 100644 --- a/src/cache_cf.cc +++ b/src/cache_cf.cc @@ -1,6 +1,6 @@ /* - * $Id: cache_cf.cc,v 1.380 2001/05/04 13:37:41 hno Exp $ + * $Id: cache_cf.cc,v 1.381 2001/05/08 15:24:35 hno Exp $ * * DEBUG: section 3 Configuration File Parsing * AUTHOR: Harvest Derived @@ -55,6 +55,7 @@ static const char *const B_MBYTES_STR = "MB"; static const char *const B_GBYTES_STR = "GB"; static const char *const list_sep = ", \t\n\r"; +static struct cache_dir_option common_cachedir_options[]; static void update_maxobjsize(void); static void configDoConfigure(void); @@ -888,6 +889,16 @@ free_http_header_replace(header_mangler header[]) } } +void +dump_cachedir_options(StoreEntry * entry, struct cache_dir_option *options, SwapDir * sd) +{ + struct cache_dir_option *option; + if (!options) + return; + for (option = options; option->name; option++) + option->dump(entry, option->name, sd); +} + static void dump_cachedir(StoreEntry * entry, const char *name, cacheSwap swap) { @@ -895,7 +906,11 @@ dump_cachedir(StoreEntry * entry, const char *name, cacheSwap swap) int i; for (i = 0; i < swap.n_configured; i++) { s = swap.swapDirs + i; - s->dump(entry, name, s); + storeAppendPrintf(entry, "%s %s %s", name, s->type, s->path); + if (s->dump) + s->dump(entry, s); + dump_cachedir_options(entry, common_cachedir_options, s); + storeAppendPrintf(entry, "\n"); } } @@ -1098,6 +1113,13 @@ parse_cachedir_option_readonly(SwapDir * sd, const char *option, const char *val sd->flags.read_only = read_only; } +static void +dump_cachedir_option_readonly(StoreEntry * e, const char *option, SwapDir * sd) +{ + if (sd->flags.read_only) + storeAppendPrintf(e, " %s", option); +} + static void parse_cachedir_option_maxsize(SwapDir * sd, const char *option, const char *value, int reconfiguring) { @@ -1114,10 +1136,17 @@ parse_cachedir_option_maxsize(SwapDir * sd, const char *option, const char *valu sd->max_objsize = size; } +static void +dump_cachedir_option_maxsize(StoreEntry * e, const char *option, SwapDir * sd) +{ + if (sd->max_objsize != -1) + storeAppendPrintf(e, " %s=%d", option, sd->max_objsize); +} + static struct cache_dir_option common_cachedir_options[] = { - {"read-only", parse_cachedir_option_readonly}, - {"max-size", parse_cachedir_option_maxsize}, + {"read-only", parse_cachedir_option_readonly, dump_cachedir_option_readonly}, + {"max-size", parse_cachedir_option_maxsize, dump_cachedir_option_maxsize}, {NULL, NULL} }; diff --git a/src/fs/aufs/store_dir_aufs.cc b/src/fs/aufs/store_dir_aufs.cc index 09af0ea573..d542e2114b 100644 --- a/src/fs/aufs/store_dir_aufs.cc +++ b/src/fs/aufs/store_dir_aufs.cc @@ -1,6 +1,6 @@ /* - * $Id: store_dir_aufs.cc,v 1.34 2001/03/17 13:31:16 hno Exp $ + * $Id: store_dir_aufs.cc,v 1.35 2001/05/08 15:24:36 hno Exp $ * * DEBUG: section 47 Store Directory Routines * AUTHOR: Duane Wessels @@ -1493,8 +1493,8 @@ storeAufsDirStats(SwapDir * SD, StoreEntry * sentry) static struct cache_dir_option options[] = { #if NOT_YET_DONE - {"L1", storeAufsDirParseL1}, - {"L2", storeAufsDirParseL2}, + {"L1", storeAufsDirParseL1, storeAufsDirDumpL1}, + {"L2", storeAufsDirParseL2, storeAufsDirDumpL2}, #endif {NULL, NULL} }; @@ -1540,16 +1540,14 @@ storeAufsDirReconfigure(SwapDir * sd, int index, char *path) } void -storeAufsDirDump(StoreEntry * entry, const char *name, SwapDir * s) +storeAufsDirDump(StoreEntry * entry, SwapDir * s) { aioinfo_t *aioinfo = (aioinfo_t *) s->fsdata; - storeAppendPrintf(entry, "%s %s %s %d %d %d\n", - name, - "aufs", - s->path, + storeAppendPrintf(entry, " %d %d %d", s->max_size >> 10, aioinfo->l1, aioinfo->l2); + dump_cachedir_options(entry, options, s); } /* diff --git a/src/fs/coss/store_dir_coss.cc b/src/fs/coss/store_dir_coss.cc index 7982c0c386..660b2dbb37 100644 --- a/src/fs/coss/store_dir_coss.cc +++ b/src/fs/coss/store_dir_coss.cc @@ -1,6 +1,6 @@ /* - * $Id: store_dir_coss.cc,v 1.20 2001/03/03 10:39:37 hno Exp $ + * $Id: store_dir_coss.cc,v 1.21 2001/05/08 15:24:36 hno Exp $ * * DEBUG: section 81 Store COSS Directory Routines * AUTHOR: Eric Stern @@ -793,13 +793,11 @@ storeCossDirReconfigure(SwapDir * sd, int index, char *path) } void -storeCossDirDump(StoreEntry * entry, const char *name, SwapDir * s) +storeCossDirDump(StoreEntry * entry, SwapDir * s) { - storeAppendPrintf(entry, "%s %s %s %d\n", - name, - s->type, - s->path, + storeAppendPrintf(entry, " %d", s->max_size >> 20); + dump_cachedir_options(entry, NULL, sd); } #if OLD_UNUSED_CODE diff --git a/src/fs/diskd/store_dir_diskd.cc b/src/fs/diskd/store_dir_diskd.cc index 6b507c17ba..944c3a8938 100644 --- a/src/fs/diskd/store_dir_diskd.cc +++ b/src/fs/diskd/store_dir_diskd.cc @@ -1,6 +1,6 @@ /* - * $Id: store_dir_diskd.cc,v 1.48 2001/04/03 20:22:11 adrian Exp $ + * $Id: store_dir_diskd.cc,v 1.49 2001/05/08 15:24:36 hno Exp $ * * DEBUG: section 47 Store Directory Routines * AUTHOR: Duane Wessels @@ -1713,6 +1713,13 @@ storeDiskdDirParseQ1(SwapDir * sd, const char *name, const char *value, int reco debug(3, 1) ("cache_dir '%s' new Q1 value '%d'\n", diskdinfo->magic1); } +static void +storeDiskdDirDumpQ1(StoreEntry * e, const char *option, SwapDir *sd) +{ + diskdinfo_t *diskdinfo = sd->fsdata; + storeAppendPrintf(e, " Q1=%d", diskdinfo->magic1); +} + static void storeDiskdDirParseQ2(SwapDir * sd, const char *name, const char *value, int reconfiguring) { @@ -1723,14 +1730,21 @@ storeDiskdDirParseQ2(SwapDir * sd, const char *name, const char *value, int reco debug(3, 1) ("cache_dir '%s' new Q2 value '%d'\n", diskdinfo->magic2); } +static void +storeDiskdDirDumpQ2(StoreEntry * e, const char *option, SwapDir *sd) +{ + diskdinfo_t *diskdinfo = sd->fsdata; + storeAppendPrintf(e, " Q2=%d", diskdinfo->magic2); +} + struct cache_dir_option options[] = { #if NOT_YET - {"L1", storeDiskdDirParseL1}, - {"L2", storeDiskdDirParseL2}, + {"L1", storeDiskdDirParseL1, storeDiskdDirDumpL1}, + {"L2", storeDiskdDirParseL2, storeDiskdDirDumpL2}, #endif - {"Q1", storeDiskdDirParseQ1}, - {"Q2", storeDiskdDirParseQ2}, + {"Q1", storeDiskdDirParseQ1, storeDiskdDirDumpQ1}, + {"Q2", storeDiskdDirParseQ2, storeDiskdDirDumpQ2}, {NULL, NULL} }; @@ -1772,16 +1786,14 @@ storeDiskdDirReconfigure(SwapDir * sd, int index, char *path) } void -storeDiskdDirDump(StoreEntry * entry, const char *name, SwapDir * s) +storeDiskdDirDump(StoreEntry * entry, SwapDir * s) { diskdinfo_t *diskdinfo = s->fsdata; - storeAppendPrintf(entry, "%s %s %s %d %d %d\n", - name, - "diskd", - s->path, + storeAppendPrintf(entry, " %d %d %d", s->max_size >> 10, diskdinfo->l1, diskdinfo->l2); + dump_cachedir_options(entry, options, s); } /* diff --git a/src/fs/ufs/store_dir_ufs.cc b/src/fs/ufs/store_dir_ufs.cc index 8bc298457c..937b4974bd 100644 --- a/src/fs/ufs/store_dir_ufs.cc +++ b/src/fs/ufs/store_dir_ufs.cc @@ -1,6 +1,6 @@ /* - * $Id: store_dir_ufs.cc,v 1.33 2001/03/14 22:28:41 wessels Exp $ + * $Id: store_dir_ufs.cc,v 1.34 2001/05/08 15:24:37 hno Exp $ * * DEBUG: section 47 Store Directory Routines * AUTHOR: Duane Wessels @@ -1475,8 +1475,8 @@ storeUfsDirStats(SwapDir * SD, StoreEntry * sentry) static struct cache_dir_option options[] = { #if NOT_YET_DONE - {"L1", storeAufsDirParseL1}, - {"L2", storeAufsDirParseL2}, + {"L1", storeUfsDirParseL1, storeUfsDirDumpL1}, + {"L2", storeUfsDirParseL2, storeUfsDirDumpL2}, #endif {NULL, NULL} }; @@ -1520,16 +1520,14 @@ storeUfsDirReconfigure(SwapDir * sd, int index, char *path) } void -storeUfsDirDump(StoreEntry * entry, const char *name, SwapDir * s) +storeUfsDirDump(StoreEntry * entry, SwapDir * s) { ufsinfo_t *ufsinfo = (ufsinfo_t *) s->fsdata; - storeAppendPrintf(entry, "%s %s %s %d %d %d\n", - name, - "ufs", - s->path, + storeAppendPrintf(entry, " %d %d %d", s->max_size >> 10, ufsinfo->l1, ufsinfo->l2); + dump_cachedir_options(entry, options, s); } /* diff --git a/src/protos.h b/src/protos.h index d2cf7b02a7..78ad5a001b 100644 --- a/src/protos.h +++ b/src/protos.h @@ -1,6 +1,6 @@ /* - * $Id: protos.h,v 1.404 2001/05/05 17:49:55 hno Exp $ + * $Id: protos.h,v 1.405 2001/05/08 15:24:35 hno Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -94,6 +94,7 @@ extern void parse_wordlist(wordlist ** list); extern void requirePathnameExists(const char *name, const char *path); extern void parse_time_t(time_t * var); extern void parse_cachedir_options(SwapDir * sd, struct cache_dir_option *options, int reconfiguring); +extern void dump_cachedir_options(StoreEntry * e, struct cache_dir_option *options, SwapDir * sd); /* diff --git a/src/structs.h b/src/structs.h index e7e073bb91..aaa905eefa 100644 --- a/src/structs.h +++ b/src/structs.h @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.389 2001/05/04 13:37:42 hno Exp $ + * $Id: structs.h,v 1.390 2001/05/08 15:24:35 hno Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -2110,4 +2110,5 @@ struct _Logfile { struct cache_dir_option { char *name; void (*parse) (SwapDir * sd, const char *option, const char *value, int reconfiguring); + void (*dump) (StoreEntry * e, const char *option, SwapDir * sd); }; diff --git a/src/typedefs.h b/src/typedefs.h index f91598b52f..6c5db0ee87 100644 --- a/src/typedefs.h +++ b/src/typedefs.h @@ -1,6 +1,6 @@ /* - * $Id: typedefs.h,v 1.127 2001/05/04 13:37:42 hno Exp $ + * $Id: typedefs.h,v 1.128 2001/05/08 15:24:35 hno Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -252,7 +252,7 @@ typedef void IDNSCB(void *, rfc1035_rr *, int); typedef void STINIT(SwapDir *); typedef void STNEWFS(SwapDir *); -typedef void STDUMP(StoreEntry *, const char *, SwapDir *); +typedef void STDUMP(StoreEntry *, SwapDir *); typedef void STFREE(SwapDir *); typedef int STDBLCHECK(SwapDir *, StoreEntry *); typedef void STSTATFS(SwapDir *, StoreEntry *);