From e45ea5585ec1a4d3f083f4c9203e3f39899b9665 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Sat, 12 Jan 2008 15:44:40 +0000 Subject: [PATCH] DEVEL15-cmdebug-cellservdb-20080112 LICENSE MIT Add -cellservdb option to the cmdebug command. This option will retrieve the volume location database information for all cells known to the cache manager and output the data in the format required by the CellServDB file. This functionality is supported by the UNIX cache managers and Windows cache managers 1.5.31 and later. (cherry picked from commit b3fe9727b3e775348561bcbe0cf0c14cff82e597) --- src/venus/cmdebug.c | 76 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 70 insertions(+), 6 deletions(-) diff --git a/src/venus/cmdebug.c b/src/venus/cmdebug.c index 81b1c6179..04ea0632d 100644 --- a/src/venus/cmdebug.c +++ b/src/venus/cmdebug.c @@ -82,6 +82,7 @@ PrintCacheConfig(struct rx_connection *aconn) } else { printf("cmdebug: unsupported server version %d\n", srv_ver); } + return 0; } #ifndef CAPABILITY_BITS @@ -473,6 +474,58 @@ PrintCacheEntries(struct rx_connection *aconn, int aint32) return PrintCacheEntries32(aconn, aint32); } +static int +PrintCellServDBEntry(struct rx_connection *aconn, afs_int32 cellnum) +{ + static struct cell_cache *cache; + int code; + char *cellname; + serverList sl; + unsigned int n; + int rc = 0; + + cellname = NULL; + sl.serverList_len = 0; + sl.serverList_val = NULL; + code = RXAFSCB_GetCellServDB(aconn, cellnum, &cellname, &sl); + if (code) + return 0; + + if ( !cellname || !cellname[0] ) + goto done; + + rc = 1; + printf(">%-23s#%s\n", cellname, cellname); + + if (sl.serverList_val) { + for ( n=0; nh_name : ""); + } + } + + done: + if (cellname) + free(cellname); + + if (sl.serverList_val) + free(sl.serverList_val); + + return rc; +} + +static void +PrintCellServDB(struct rx_connection *aconn) +{ + afs_int32 index; + + for ( index = 0 ; PrintCellServDBEntry(aconn, index); index++ ); +} + int CommandProc(struct cmd_syndesc *as, void *arock) { @@ -502,18 +555,25 @@ CommandProc(struct cmd_syndesc *as, void *arock) hostName); exit(1); } - if (as->parms[5].items) { + + if (as->parms[6].items) { /* -addrs */ PrintInterfaces(conn); return 0; } - if (as->parms[6].items) { + if (as->parms[7].items) { /* -cache */ PrintCacheConfig(conn); return 0; } - if (as->parms[7].items) + if (as->parms[8].items) { + /* -cellservdb */ + PrintCellServDB(conn); + return 0; + } + + if (as->parms[5].items) print_ctime = 1; if (as->parms[2].items) @@ -568,7 +628,7 @@ main(int argc, char **argv) rx_Init(0); - ts = cmd_CreateSyntax(NULL, CommandProc, NULL, "probe unik server"); + ts = cmd_CreateSyntax(NULL, CommandProc, NULL, "query afs cache manager"); cmd_AddParm(ts, "-servers", CMD_SINGLE, CMD_REQUIRED, "server machine"); cmd_AddParm(ts, "-port", CMD_SINGLE, CMD_OPTIONAL, "IP port"); cmd_AddParm(ts, "-long", CMD_FLAG, CMD_OPTIONAL, "print all info"); @@ -576,12 +636,16 @@ main(int argc, char **argv) "print only cache entries with positive reference counts"); cmd_AddParm(ts, "-callbacks", CMD_FLAG, CMD_OPTIONAL, "print only cache entries with callbacks"); + cmd_AddParm(ts, "-ctime", CMD_FLAG, CMD_OPTIONAL, + "print human readable expiration time"); + + cmd_AddParm(ts, "-addrs", CMD_FLAG, CMD_OPTIONAL, "print only host interfaces"); cmd_AddParm(ts, "-cache", CMD_FLAG, CMD_OPTIONAL, "print only cache configuration"); - cmd_AddParm(ts, "-ctime", CMD_FLAG, CMD_OPTIONAL, - "print human readable expiration time"); + cmd_AddParm(ts, "-cellservdb", CMD_FLAG, CMD_OPTIONAL, + "print only cellservdb info"); cmd_Dispatch(argc, argv); exit(0); -- 2.39.5