2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 #include <afsconfig.h>
11 #include <afs/param.h>
15 #include <sys/types.h>
24 #include <afs/afsutil.h>
31 cmdproc(struct cmd_syndesc *as, void * arock)
39 if (as->parms[0].items) {
40 dbmfile = as->parms[0].items->data;
42 kdb = dbm_open(dbmfile, O_RDONLY, KALOG_DB_MODE);
47 if (!(ti = as->parms[1].items)) {
48 printf("Printing all entries found in %s\n", dbmfile);
49 for (key = dbm_firstkey(kdb); key.dptr;
50 key = afs_dbm_nextkey(kdb, key), cnt++) {
51 if (as->parms[2].items) {
52 data = dbm_fetch(kdb, key);
54 fprintf(stderr, "%s: no entry exists\n", ti->data);
57 if (data.dsize != sizeof(kalog_elt)) {
58 fprintf(stderr, "%s: data came out corrupt\n", ti->data);
61 memcpy(&rdata, data.dptr, sizeof(kalog_elt));
62 if (! as->parms[3].items) {
64 hostName = hostutil_GetNameByINet(rdata.host);
65 printf("%s: last operation from host %s at %s",
66 (char *)key.dptr, hostName,
67 ctime(&rdata.last_use));
71 hostIP = afs_inet_ntoa_r(rdata.host, hoststr);
72 printf("%s: last operation from host %s at %s",
73 (char *)key.dptr, hostIP,
74 ctime(&rdata.last_use));
77 printf("\t%s\n", (char *)key.dptr);
80 printf("%d entries were found\n", cnt);
82 for (; ti; ti = ti->next) {
83 key.dsize = strlen(ti->data) + 1;
85 data = dbm_fetch(kdb, key);
87 fprintf(stderr, "%s: no entry exists\n", ti->data);
90 if (data.dsize != sizeof(kalog_elt)) {
91 fprintf(stderr, "%s: data came out corrupt\n", ti->data);
94 memcpy(&rdata, data.dptr, sizeof(kalog_elt));
95 printf("%s: last operation from host %x at %s", ti->data,
96 rdata.host, ctime(&rdata.last_use));
104 #include "AFS_component_version_number.c"
107 main(int argc, char **argv)
109 struct cmd_syndesc *ts;
111 char dbmfile_help[AFSDIR_PATH_MAX];
113 sprintf(dbmfile_help, "dbmfile to use (default %s)",
114 AFSDIR_SERVER_KALOGDB_FILEPATH);
115 dbmfile = AFSDIR_SERVER_KALOGDB_FILEPATH;
116 ts = cmd_CreateSyntax(NULL, cmdproc, NULL, "Dump contents of dbm database");
117 cmd_AddParm(ts, "-dbmfile", CMD_SINGLE, CMD_OPTIONAL, dbmfile_help);
118 cmd_AddParm(ts, "-key", CMD_SINGLE, CMD_OPTIONAL,
119 "extract entries that match specified key");
120 cmd_AddParm(ts, "-long", CMD_FLAG, CMD_OPTIONAL, "print long info for each entry");
121 cmd_AddParm(ts, "-numeric", CMD_FLAG, CMD_OPTIONAL, "addresses only");
122 code = cmd_Dispatch(argc, argv);
127 #include "AFS_component_version_number.c"
132 printf("kdb not supported\n");