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>
16 #include <afs/afsutil.h>
26 cmdproc(struct cmd_syndesc *as, void * arock)
34 if (as->parms[0].items) {
35 dbmfile = as->parms[0].items->data;
37 kdb = dbm_open(dbmfile, O_RDONLY, KALOG_DB_MODE);
42 if (!(ti = as->parms[1].items)) {
43 printf("Printing all entries found in %s\n", dbmfile);
44 for (key = dbm_firstkey(kdb); key.dptr;
45 key = afs_dbm_nextkey(kdb, key), cnt++) {
46 if (as->parms[2].items) {
47 data = dbm_fetch(kdb, key);
49 fprintf(stderr, "%s: no entry exists\n", ti->data);
52 if (data.dsize != sizeof(kalog_elt)) {
53 fprintf(stderr, "%s: data came out corrupt\n", ti->data);
56 memcpy(&rdata, data.dptr, sizeof(kalog_elt));
57 if (! as->parms[3].items) {
59 hostName = hostutil_GetNameByINet(rdata.host);
60 printf("%s: last operation from host %s at %s",
61 (char *)key.dptr, hostName,
62 ctime(&rdata.last_use));
66 hostIP = afs_inet_ntoa_r(rdata.host, hoststr);
67 printf("%s: last operation from host %s at %s",
68 (char *)key.dptr, hostIP,
69 ctime(&rdata.last_use));
72 printf("\t%s\n", (char *)key.dptr);
75 printf("%d entries were found\n", cnt);
77 for (; ti; ti = ti->next) {
78 key.dsize = strlen(ti->data) + 1;
80 data = dbm_fetch(kdb, key);
82 fprintf(stderr, "%s: no entry exists\n", ti->data);
85 if (data.dsize != sizeof(kalog_elt)) {
86 fprintf(stderr, "%s: data came out corrupt\n", ti->data);
89 memcpy(&rdata, data.dptr, sizeof(kalog_elt));
90 printf("%s: last operation from host %x at %s", ti->data,
91 rdata.host, ctime(&rdata.last_use));
99 #include "AFS_component_version_number.c"
102 main(int argc, char **argv)
104 struct cmd_syndesc *ts;
106 char dbmfile_help[AFSDIR_PATH_MAX];
108 sprintf(dbmfile_help, "dbmfile to use (default %s)",
109 AFSDIR_SERVER_KALOGDB_FILEPATH);
110 dbmfile = AFSDIR_SERVER_KALOGDB_FILEPATH;
111 ts = cmd_CreateSyntax(NULL, cmdproc, NULL, "Dump contents of dbm database");
112 cmd_AddParm(ts, "-dbmfile", CMD_SINGLE, CMD_OPTIONAL, dbmfile_help);
113 cmd_AddParm(ts, "-key", CMD_SINGLE, CMD_OPTIONAL,
114 "extract entries that match specified key");
115 cmd_AddParm(ts, "-long", CMD_FLAG, CMD_OPTIONAL, "print long info for each entry");
116 cmd_AddParm(ts, "-numeric", CMD_FLAG, CMD_OPTIONAL, "addresses only");
117 code = cmd_Dispatch(argc, argv);
122 #include "AFS_component_version_number.c"
127 printf("kdb not supported\n");