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>
17 #include <sys/types.h>
26 #include <afs/afsutil.h>
33 cmdproc(register struct cmd_syndesc *as, void * arock)
38 register afs_int32 code = 0, cnt = 0;
39 register struct cmd_item *ti;
41 if (as->parms[0].items) {
42 dbmfile = as->parms[0].items->data;
44 kdb = dbm_open(dbmfile, O_RDONLY, KALOG_DB_MODE);
49 if (!(ti = as->parms[1].items)) {
50 printf("Printing all entries found in %s\n", dbmfile);
51 for (key = dbm_firstkey(kdb); key.dptr;
52 key = afs_dbm_nextkey(kdb, key), cnt++) {
53 if (as->parms[2].items) {
54 data = dbm_fetch(kdb, key);
56 fprintf(stderr, "%s: no entry exists\n", ti->data);
59 if (data.dsize != sizeof(kalog_elt)) {
60 fprintf(stderr, "%s: data came out corrupt\n", ti->data);
63 memcpy(&rdata, data.dptr, sizeof(kalog_elt));
64 if (! as->parms[3].items) {
66 hostName = hostutil_GetNameByINet(rdata.host);
67 printf("%s: last operation from host %s at %s", key.dptr,
68 hostName, ctime(&rdata.last_use));
71 hostIP = afs_inet_ntoa(rdata.host);
72 printf("%s: last operation from host %s at %s", key.dptr,
73 hostIP, ctime(&rdata.last_use));
76 printf("\t%s\n", key.dptr);
79 printf("%d entries were found\n", cnt);
81 for (; ti; ti = ti->next) {
82 key.dsize = strlen(ti->data) + 1;
84 data = dbm_fetch(kdb, key);
86 fprintf(stderr, "%s: no entry exists\n", ti->data);
89 if (data.dsize != sizeof(kalog_elt)) {
90 fprintf(stderr, "%s: data came out corrupt\n", ti->data);
93 memcpy(&rdata, data.dptr, sizeof(kalog_elt));
94 printf("%s: last operation from host %x at %s", ti->data,
95 rdata.host, ctime(&rdata.last_use));
103 #include "AFS_component_version_number.c"
106 main(int argc, char **argv)
108 register struct cmd_syndesc *ts;
109 register afs_int32 code;
110 char dbmfile_help[AFSDIR_PATH_MAX];
112 sprintf(dbmfile_help, "dbmfile to use (default %s)",
113 AFSDIR_SERVER_KALOGDB_FILEPATH);
114 dbmfile = AFSDIR_SERVER_KALOGDB_FILEPATH;
115 ts = cmd_CreateSyntax(NULL, cmdproc, NULL, "Dump contents of dbm database");
116 cmd_AddParm(ts, "-dbmfile", CMD_SINGLE, CMD_OPTIONAL, dbmfile_help);
117 cmd_AddParm(ts, "-key", CMD_SINGLE, CMD_OPTIONAL,
118 "extract entries that match specified key");
119 cmd_AddParm(ts, "-long", CMD_FLAG, CMD_OPTIONAL, "print long info for each entry");
120 cmd_AddParm(ts, "-numeric", CMD_FLAG, CMD_OPTIONAL, "addresses only");
121 code = cmd_Dispatch(argc, argv);
126 #include "AFS_component_version_number.c"
131 printf("kdb not supported\n");