/*
* Copyright 2000, International Business Machines Corporation and others.
* All Rights Reserved.
- *
+ *
* This software has been released under the terms of the IBM Public
* License. For details, see the LICENSE file in the top-level source
* directory or online at http://www.openafs.org/dl/license10.html
#include <afsconfig.h>
#include <afs/param.h>
+#include <afs/stds.h>
-RCSID
- ("$Header$");
+#include <roken.h>
-#include <afs/stds.h>
-#include <sys/types.h>
-#ifdef HAVE_TIME_H
-#include <time.h>
-#endif
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
#ifdef AFS_NT40_ENV
-#include <winsock2.h>
#include <WINNT/afsevent.h>
#endif
-#ifdef HAVE_SYS_TIME_H
-#include <sys/time.h>
-#endif
#ifdef HAVE_SYS_FILE_H
#include <sys/file.h>
#endif
-#ifdef HAVE_NETDB_H
-#include <netdb.h>
-#endif
-#ifdef HAVE_NETINET_IN_H
-#include <netinet/in.h>
-#endif
-#include <stdio.h>
-#include <string.h>
+#include <ctype.h>
#include <afs/afsutil.h>
#include <rx/xdr.h>
#include <afs/cmd.h>
#include <lock.h>
#include <ubik.h>
+
#include "vlserver.h"
-#include "vlclient.h"
-
-void fill_listattributes_entry();
-void display_listattributes_entry();
-void display_entry();
-void display_entryN();
-void display_update_entry();
-void dump_stats();
-void GetArgs();
-void print_usage();
-void fill_entry();
-void fill_update_entry();
+
+void fill_listattributes_entry(struct VldbListByAttributes *, char **, int);
+void display_listattributes_entry(struct VldbListByAttributes *,int);
+void display_entry(struct vldbentry *, int);
+void display_entryN(struct nvldbentry *, int);
+void display_update_entry(struct VldbUpdateEntry *, int);
+void dump_stats(vldstats *, vital_vlheader *);
+void GetArgs(char *, char **, int *);
+void print_usage(void);
+void fill_entry(struct vldbentry *, char **, int);
+void fill_update_entry(struct VldbUpdateEntry *, char **, int);
#define VL_NUMBER_OPCODESX 34
static char *opcode_names[VL_NUMBER_OPCODESX] = {
"ListAttributes",
"LinkedList",
"GetStats",
- "Probe",
+ "Probe", /* RPC is ProbeServer */
"GetAddrs",
"ChangeAddr",
"CreateEntryN",
char *(args[50]);
struct Vlent *
-GetVolume(vol, entry)
- struct vldbentry *entry;
+GetVolume(int vol, struct vldbentry *entry)
{
- register int i;
- register struct Vlent *vl;
+ int i;
+ struct Vlent *vl;
if (!vol)
return NULL;
/* Almost identical's to pr_Initialize in vlserver/pruser.c */
afs_int32
-vl_Initialize(int auth, char *confDir, int server, char *cellp)
+vl_Initialize(char *confDir, int secFlags, int server, char *cellp)
{
- return ugen_ClientInit(auth?0:1, confDir, cellp, 0,
- &cstruct, NULL, "vl_Initialize", rxkad_clear,
- MAXSERVERS, AFSCONF_VLDBSERVICE, 50, server,
- htons(AFSCONF_VLDBPORT), USER_SERVICE_ID);
+ return ugen_ClientInitServer(confDir, cellp, secFlags, &cstruct,
+ MAXSERVERS, AFSCONF_VLDBSERVICE, 90,
+ server, htons(AFSCONF_VLDBPORT));
}
/* return host address in network byte order */
afs_int32
GetServer(char *aname)
{
- register struct hostent *th;
- afs_int32 addr;
+ struct hostent *th;
+ afs_uint32 addr;
int b1, b2, b3, b4;
- register afs_int32 code;
+ afs_int32 code;
code = sscanf(aname, "%d.%d.%d.%d", &b1, &b2, &b3, &b4);
if (code == 4) {
static int
handleit(struct cmd_syndesc *as, void *arock)
{
- register struct cmd_item *ti;
- register afs_int32 code, server = 0, sawserver = 0;
+ struct cmd_item *ti;
+ afs_int32 code, server = 0, sawserver = 0;
afs_int32 id, voltype;
struct vldbentry entry;
- char *cmd = 0, *cellp = 0;
+ char *cellp = 0;
struct VldbUpdateEntry updateentry;
struct VldbListByAttributes listbyattributes;
- int noAuth = 1; /* Default is authenticated connections */
+ int secFlags = AFSCONF_SECOPTS_FALLBACK_NULL;
- if (ti = as->parms[0].items) /* -cellpath <dir> */
+ if ((ti = as->parms[0].items)) /* -cellpath <dir> */
strcpy(confdir, ti->data);
if (as->parms[1].items) /* -server */
strcpy(confdir, AFSDIR_SERVER_ETC_DIRPATH);
if (as->parms[2].items) /* -noauth */
- noAuth = 0;
- if (ti = as->parms[3].items) { /* -host */
+ secFlags |= AFSCONF_SECOPTS_NOAUTH;
+ if ((ti = as->parms[3].items)) { /* -host */
server = GetServer(ti->data);
if (server == 0) {
printf("server '%s' not found in host table\n", ti->data);
}
sawserver = 1;
}
- if (!sawserver && noAuth && (!(ti = as->parms[4].items))) {
+ if (sawserver && !as->parms[2].items && (!(ti = as->parms[4].items))) {
printf
("Must also specify the -cell' option along with -host for authenticated conns\n");
exit(1);
}
- if (ti = as->parms[4].items) { /* -cell */
+ if ((ti = as->parms[4].items)) { /* -cell */
cellp = ti->data;
}
- if (code = vl_Initialize(noAuth, confdir, server, cellp)) {
+ if ((code = vl_Initialize(confdir, secFlags, server, cellp))) {
printf("Couldn't initialize vldb library (code=%d).\n", code);
exit(1);
}
- if (as->parms[5].items) { /* -gstats */
+ if (as->parms[6].items) { /* -probe */
+ int nconns = 0;
+ int status = 0;
+ int i;
+ char hoststr[16];
+ afs_uint32 addr;
+
+ for (i = 0; cstruct->conns[i]; i++, nconns++) {
+ rx_SetConnDeadTime(cstruct->conns[i], 6);
+ addr = rx_HostOf(rx_PeerOf(cstruct->conns[i]));
+ if (!nconns) {
+ printf("probing");
+ }
+ printf(" %s", afs_inet_ntoa_r(addr, hoststr));
+ }
+ if (nconns == 0) {
+ printf("no connections\n");
+ return 255;
+ }
+ printf("\n");
+ multi_Rx(cstruct->conns, nconns) {
+ multi_VL_ProbeServer();
+ addr = rx_HostOf(rx_PeerOf(cstruct->conns[multi_i]));
+ if (!multi_error) {
+ printf(" ok: %s\n", afs_inet_ntoa_r(addr, hoststr));
+ } else {
+ status = 255;
+ printf(" not ok (%d): %s\n", multi_error,
+ afs_inet_ntoa_r(addr, hoststr));
+ }
+ }
+ multi_End;
+ return status;
+ }
+
+ if (as->parms[5].items) { /* -getstats */
vldstats stats;
vital_vlheader vital_header;
- code = ubik_Call(VL_GetStats, cstruct, 0, &stats, &vital_header);
+ code = ubik_VL_GetStats(cstruct, 0, &stats, &vital_header);
if (!code)
dump_stats(&stats, &vital_header);
exit(0);
exit(0);
} else {
char *oper, *vname;
- register char **argp = args;
+ char **argp = args;
+
GetArgs(line, argp, &nargs);
oper = &argp[0][0];
++argp, --nargs;
- if (!strcmp(oper, "cr")) {
+ if (!*line) {
+ } else if (!strcmp(oper, "cr")) {
fill_entry(&entry, argp, nargs);
display_entry(&entry, 0);
- code = ubik_Call(VL_CreateEntry, cstruct, 0, &entry);
+ code = ubik_VL_CreateEntry(cstruct, 0, &entry);
printf("return code is %d\n", code);
} else if (!strcmp(oper, "rm")) {
sscanf(&(*argp)[0], "%d", &id);
++argp, --nargs;
sscanf(&(*argp)[0], "%d", &voltype);
- code = ubik_Call(VL_DeleteEntry, cstruct, 0, id, voltype);
+ code = ubik_VL_DeleteEntry(cstruct, 0, id, voltype);
printf("return code is %d\n", code);
} else if (!strcmp(oper, "re")) {
sscanf(&(*argp)[0], "%d", &id);
fill_entry(&entry, argp, nargs);
display_entry(&entry, 0);
code =
- ubik_Call(VL_ReplaceEntry, cstruct, 0, id, voltype,
+ ubik_VL_ReplaceEntry(
+ cstruct, 0, id, voltype,
&entry, releasetype);
printf("return code is %d\n", code);
} else if (!strcmp(oper, "up")) {
fill_update_entry(&updateentry, argp, nargs);
display_update_entry(&updateentry, 0);
code =
- ubik_Call(VL_UpdateEntry, cstruct, 0, id, voltype,
+ ubik_VL_UpdateEntry(cstruct, 0, id, voltype,
&updateentry, releasetype);
printf("return code is %d\n", code);
} else if (!strcmp(oper, "ls")) {
for (index = 0; 1; index = next_index) {
memset(&entry, 0, sizeof(entry));
code =
- ubik_Call(VL_ListEntry, cstruct, 0, index, &count,
+ ubik_VL_ListEntry(cstruct, 0, index, &count,
&next_index, &entry);
if (code) {
printf("VL_ListEntry returned code = %d\n", code);
afs_int32 index, count, num = 0, num1 = 0, next_index;
struct Vlent *vl1;
- VL = SVL =
- (struct Vlent *)malloc(ALLOCNT * sizeof(struct Vlent));
+ VL = SVL = malloc(ALLOCNT * sizeof(struct Vlent));
if (VL == NULL) {
printf("Can't allocate memory...\n");
exit(1);
for (index = 0; 1; index = next_index) {
memset(&entry, 0, sizeof(entry));
code =
- ubik_Call(VL_ListEntry, cstruct, 0, index, &count,
+ ubik_VL_ListEntry(cstruct, 0, index, &count,
&next_index, &entry);
if (code) {
printf("VL_ListEntry returned code = %d\n", code);
if (!next_index)
break;
num++;
- if (vl1 = GetVolume(entry.volumeId[0], &entry)) {
+ if ((vl1 = GetVolume(entry.volumeId[0], &entry))) {
num1++;
printf
("Duplicate entry is found for RW vol %u: [RW %u, RO %u, BA %u, name=%s]\n",
entry.volumeId[0], vl1->rwid, vl1->roid,
vl1->baid, vl1->name);
}
- if (vl1 = GetVolume(entry.volumeId[1], &entry)) {
+ if ((vl1 = GetVolume(entry.volumeId[1], &entry))) {
num1++;
printf
("Duplicate entry is found for RO vol %u: [RW %u, RO %u, BA %u, name=%s]\n",
entry.volumeId[1], vl1->rwid, vl1->roid,
vl1->baid, vl1->name);
}
- if (vl1 = GetVolume(entry.volumeId[2], &entry)) {
+ if ((vl1 = GetVolume(entry.volumeId[2], &entry))) {
num1++;
printf
("Duplicate entry is found for BA vol %u: [RW %u, RO %u, BA %u, name=%s]\n",
0, num31 = 0, num4 = 0, num41 = 0, next_index;
struct vldbentry tentry;
- VL = SVL =
- (struct Vlent *)malloc(ALLOCNT * sizeof(struct Vlent));
+ VL = SVL = malloc(ALLOCNT * sizeof(struct Vlent));
if (VL == NULL) {
printf("Can't allocate memory...\n");
exit(1);
for (index = 0; 1; index = next_index) {
memset(&entry, 0, sizeof(entry));
code =
- ubik_Call(VL_ListEntry, cstruct, 0, index, &count,
+ ubik_VL_ListEntry(cstruct, 0, index, &count,
&next_index, &entry);
if (code) {
printf("VL_ListEntry returned code = %d\n", code);
break;
num++;
code =
- ubik_Call(VL_GetEntryByNameO, cstruct, 0, entry.name,
+ ubik_VL_GetEntryByNameO(cstruct, 0, entry.name,
&tentry);
if (code == VL_NOENT) {
num1++;
entry.name, entry.volumeId[RWVOL]);
}
code =
- ubik_Call(VL_GetEntryByID, cstruct, 0,
+ ubik_VL_GetEntryByID(cstruct, 0,
entry.volumeId[RWVOL], RWVOL, &tentry);
if (code == VL_NOENT) {
num2++;
}
if (entry.volumeId[BACKVOL]) {
code =
- ubik_Call(VL_GetEntryByID, cstruct, 0,
+ ubik_VL_GetEntryByID(cstruct, 0,
entry.volumeId[BACKVOL], BACKVOL,
&tentry);
num31++;
}
if (entry.volumeId[ROVOL]) {
code =
- ubik_Call(VL_GetEntryByID, cstruct, 0,
+ ubik_VL_GetEntryByID(cstruct, 0,
entry.volumeId[ROVOL], ROVOL, &tentry);
num41++;
if (code == VL_NOENT) {
0;
struct vldbentry tentry;
- VL = SVL =
- (struct Vlent *)malloc(ALLOCNT * sizeof(struct Vlent));
+ VL = SVL = malloc(ALLOCNT * sizeof(struct Vlent));
if (VL == NULL) {
printf("Can't allocate memory...\n");
exit(1);
("Volumes not found in main hash tables in vldb will be fixed...\n");
memset(&updateentry, 0, sizeof(updateentry));
for (index = 0; 1; index = next_index) {
- /* FIXME: n2 is never changed for some reason */
- int n1 = 0, n2 = 0, n3 = 0, n4 = 0;
memset(&entry, 0, sizeof(entry));
code =
- ubik_Call(VL_ListEntry, cstruct, 0, index, &count,
+ ubik_VL_ListEntry(cstruct, 0, index, &count,
&next_index, &entry);
if (code) {
printf("VL_ListEntry returned code = %d\n", code);
break;
num++;
code =
- ubik_Call(VL_GetEntryByNameO, cstruct, 0, entry.name,
+ ubik_VL_GetEntryByNameO(cstruct, 0, entry.name,
&tentry);
if (code == VL_NOENT) {
num1++;
- n1 = 1;
updateentry.Mask = VLUPDATE_VOLNAMEHASH;
printf("\tVolume %s %d (not in namehash)\n",
entry.name, entry.volumeId[RWVOL]);
code =
- ubik_Call(VL_UpdateEntry, cstruct, 0,
+ ubik_VL_UpdateEntry(cstruct, 0,
entry.volumeId[RWVOL], -1, &updateentry,
0);
if (code) {
}
}
code =
- ubik_Call(VL_GetEntryByID, cstruct, 0,
+ ubik_VL_GetEntryByID(cstruct, 0,
entry.volumeId[RWVOL], RWVOL, &tentry);
if (code == VL_NOENT) {
num1++;
printf("\tVolume %s %d (not in rw id hash)\n",
entry.name, entry.volumeId[RWVOL]);
code =
- ubik_Call(VL_UpdateEntryByName, cstruct, 0,
+ ubik_VL_UpdateEntryByName(cstruct, 0,
entry.name, &updateentry, 0);
if (code) {
printf("\tFailed to update volume %s (err=%d)\n",
}
x++;
}
- if (entry.volumeId[BACKVOL] && !n2) {
+ if (entry.volumeId[BACKVOL]) {
code =
- ubik_Call(VL_GetEntryByID, cstruct, 0,
+ ubik_VL_GetEntryByID(cstruct, 0,
entry.volumeId[BACKVOL], BACKVOL,
&tentry);
if (code == VL_NOENT) {
- n3 = 1;
num1++;
updateentry.Mask = VLUPDATE_BACKUPID;
updateentry.BackupId = entry.volumeId[BACKVOL];
printf("\tVolume %s %d (not in backup id hash)\n",
entry.name, entry.volumeId[BACKVOL]);
code =
- ubik_Call(VL_UpdateEntry, cstruct, 0,
+ ubik_VL_UpdateEntry(cstruct, 0,
entry.volumeId[RWVOL], -1,
&updateentry, 0);
if (code) {
}
}
}
- if (entry.volumeId[ROVOL && !n2]) {
+ if (entry.volumeId[ROVOL]) {
code =
- ubik_Call(VL_GetEntryByID, cstruct, 0,
+ ubik_VL_GetEntryByID(cstruct, 0,
entry.volumeId[ROVOL], ROVOL, &tentry);
if (code == VL_NOENT) {
- n4 = 1;
num1++;
updateentry.Mask = VLUPDATE_READONLYID;
updateentry.ReadOnlyId = entry.volumeId[ROVOL];
printf("\tVolume %s %d (not in RO id hash)\n",
entry.name, entry.volumeId[ROVOL]);
code =
- ubik_Call(VL_UpdateEntry, cstruct, 0,
+ ubik_VL_UpdateEntry(cstruct, 0,
entry.volumeId[RWVOL], -1,
&updateentry, 0);
if (code) {
fill_listattributes_entry(&listbyattributes, argp, nargs);
display_listattributes_entry(&listbyattributes, 0);
code =
- ubik_Call(VL_ListAttributes, cstruct, 0,
+ ubik_VL_ListAttributes(cstruct, 0,
&listbyattributes, &nentries, &entries);
if (code) {
printf("VL_ListAttributes returned code = %d\n", code);
for (i = 0; i < nentries; i++, entry++)
display_entry(entry, 0);
if (entries.bulkentries_val)
- free((char *)entries.bulkentries_val);
+ free(entries.bulkentries_val);
} else if (!strcmp(oper, "lan2")) {
int nentries, i, si, nsi, t = 0;
nbulkentries entries;
nentries = 0;
memset(&entries, 0, sizeof(entries));
code =
- ubik_Call(VL_ListAttributesN2, cstruct, 0,
+ ubik_VL_ListAttributesN2(cstruct, 0,
&listbyattributes, name, si, &nentries,
&entries, &nsi);
if (code) {
for (i = 0; i < nentries; i++, entry++)
display_entryN(entry, 0);
if (entries.nbulkentries_val)
- free((char *)entries.nbulkentries_val);
+ free(entries.nbulkentries_val);
}
printf("--- %d volumes ---\n", t);
} else if (!strcmp(oper, "ln")) {
display_listattributes_entry(&listbyattributes, 0);
memset(&linkedvldbs, 0, sizeof(vldb_list));
code =
- ubik_Call(VL_LinkedList, cstruct, 0, &listbyattributes,
+ ubik_VL_LinkedList(cstruct, 0, &listbyattributes,
&netries, &linkedvldbs);
if (code) {
printf("VL_LinkedList returned code = %d\n", code);
(netries == 1 ? "y" : "ies"));
for (vllist = linkedvldbs.node; vllist; vllist = vllist1) {
vllist1 = vllist->next_vldb;
- display_entry(&vllist->VldbEntry, 0);
- free((char *)vllist);
+ display_entry((struct vldbentry *) &vllist->VldbEntry, 0);
+ free(vllist);
}
} else if (!strcmp(oper, "lnn")) {
int netries;
display_listattributes_entry(&listbyattributes, 0);
memset(&linkedvldbs, 0, sizeof(vldb_list));
code =
- ubik_Call(VL_LinkedListN, cstruct, 0, &listbyattributes,
+ ubik_VL_LinkedListN(cstruct, 0, &listbyattributes,
&netries, &linkedvldbs);
if (code) {
printf("VL_LinkedList returned code = %d\n", code);
(netries == 1 ? "y" : "ies"));
for (vllist = linkedvldbs.node; vllist; vllist = vllist1) {
vllist1 = vllist->next_vldb;
- display_entry(&vllist->VldbEntry, 0);
- free((char *)vllist);
+ display_entry((struct vldbentry *)&vllist->VldbEntry, 0);
+ free(vllist);
}
} else if (!strcmp(oper, "di")) {
sscanf(&(*argp)[0], "%d", &id);
++argp, --nargs;
sscanf(&(*argp)[0], "%d", &voltype);
code =
- ubik_Call(VL_GetEntryByID, cstruct, 0, id, voltype,
+ ubik_VL_GetEntryByID(cstruct, 0, id, voltype,
&entry);
display_entry(&entry, code);
printf("return code is %d.\n", code);
++argp, --nargs;
sscanf(&(*argp)[0], "%d", &voltype);
code =
- ubik_Call(VL_GetEntryByID, cstruct, 0, id, voltype,
+ ubik_VL_GetEntryByID(cstruct, 0, id, voltype,
&entry);
display_entry(&entry, code);
memset(&updateentry, 0, sizeof(updateentry));
printf("\tRehashing namehash table for %s (%d)\n", entry.name,
entry.volumeId[RWVOL]);
code =
- ubik_Call(VL_UpdateEntry, cstruct, 0,
+ ubik_VL_UpdateEntry(cstruct, 0,
entry.volumeId[RWVOL], -1, &updateentry, 0);
if (code) {
printf("\tFailed to update volume %s (err=%d)\n",
for (index = 0; 1; index = next_index) {
memset(&entry, 0, sizeof(entry));
code =
- ubik_Call(VL_ListEntry, cstruct, 0, index, &count,
+ ubik_VL_ListEntry(cstruct, 0, index, &count,
&next_index, &entry);
if (code) {
printf("VL_ListEntry returned code = %d\n", code);
("\tUndeleting vldb entry for vol %d (%s)\n",
id, entry.name);
code =
- ubik_Call(VL_UpdateEntry, cstruct, 0, id, -1,
+ ubik_VL_UpdateEntry(cstruct, 0, id, -1,
&updateentry, 0);
if (code) {
printf
} else if (!strcmp(oper, "dn")) {
vname = &argp[0][0];
code =
- ubik_Call(VL_GetEntryByNameO, cstruct, 0, vname, &entry);
+ ubik_VL_GetEntryByNameO(cstruct, 0, vname, &entry);
display_entry(&entry, code);
printf("return code is %d.\n", code);
} else if (!strcmp(oper, "nv")) {
- int newvolid;
+ unsigned int newvolid;
sscanf(&(*argp)[0], "%d", &id);
code =
- ubik_Call(VL_GetNewVolumeId, cstruct, 0, id, &newvolid);
+ ubik_VL_GetNewVolumeId(cstruct, 0, id, &newvolid);
if (!code)
- printf("Current Max volid is (in hex):%X\n", newvolid);
+ printf("Current Max volid is (in hex):0x%x\n", newvolid);
printf("return code is %d\n", code);
} else if (!strcmp(oper, "gs")) {
vldstats stats;
vital_vlheader vital_header;
code =
- ubik_Call(VL_GetStats, cstruct, 0, &stats, &vital_header);
+ ubik_VL_GetStats(cstruct, 0, &stats, &vital_header);
if (!code)
dump_stats(&stats, &vital_header);
printf("return code is %d.\n", code);
addrs.bulkaddrs_val = 0;
addrs.bulkaddrs_len = 0;
- code = ubik_Call(VL_GetAddrs, cstruct, 0, 0 /*Handle */ ,
+ code = ubik_VL_GetAddrs(cstruct, 0, 0 /*Handle */ ,
0 /*spare2 */ , &vlcb,
&nentries, &addrs);
if (code) {
printf("[0x%x %u] %s\n", *addrp, *addrp,
hostutil_GetNameByINet(ntohl(*addrp)));
}
- free((char *)addrs.bulkaddrs_val);
+ free(addrs.bulkaddrs_val);
} else if (!strcmp(oper, "gau")) {
int nentries, i, j;
afs_uint32 *addrp;
addrs.bulkaddrs_val = 0;
addrs.bulkaddrs_len = 0;
- code = ubik_Call(VL_GetAddrs, cstruct, 0, 0 /*Handle */ ,
+ code = ubik_VL_GetAddrs(cstruct, 0, 0 /*Handle */ ,
0 /*spare2 */ , &vlcb,
&nentries, &addrs);
if (code) {
printf("[0x%x %u] (special multi-homed entry)\n",
*addrp, *addrp);
+ memset(&attrs, 0, sizeof(attrs));
attrs.Mask = VLADDR_INDEX;
mhaddrs.bulkaddrs_val = 0;
mhaddrs.bulkaddrs_len = 0;
attrs.index = *addrp & 0x00ffffff;
code =
- ubik_Call(VL_GetAddrsU, cstruct, 0, &attrs, &uuid,
+ ubik_VL_GetAddrsU(cstruct, 0, &attrs, &uuid,
&unique, &mhnentries, &mhaddrs);
if (code) {
printf("VL_GetAddrsU returned code = %d\n", code);
hostutil_GetNameByINet(mhaddrp[j]));
}
if (mhaddrs.bulkaddrs_val)
- free((char *)mhaddrs.bulkaddrs_val);
+ free(mhaddrs.bulkaddrs_val);
} else {
printf("[0x%x %u] %s\n", *addrp, *addrp,
hostutil_GetNameByINet(ntohl(*addrp)));
}
}
- free((char *)addrs.bulkaddrs_val);
+ free(addrs.bulkaddrs_val);
} else if (!strcmp(oper, "mhc")) {
- afs_int32 serveraddrs[MAXSERVERID + 1][VL_MAXIPADDRS_PERMH];
+ afs_uint32 serveraddrs[MAXSERVERID + 1][VL_MAXIPADDRS_PERMH];
afs_int32 serveraddrtype[MAXSERVERID + 1];
int nentries1, nentries2, i, j, x, y, unique, found;
afs_uint32 *addrp1, *addrp2;
addrs1.bulkaddrs_val = 0;
addrs1.bulkaddrs_len = 0;
code =
- ubik_Call(VL_GetAddrs, cstruct, 0, 0, 0, &vlcb,
+ ubik_VL_GetAddrs(cstruct, 0, 0, 0, &vlcb,
&nentries1, &addrs1);
if (code) {
printf("VL_GetAddrs returned code = %d\n", code);
addrs2.bulkaddrs_val = 0;
addrs2.bulkaddrs_len = 0;
+ memset(&attrs, 0, sizeof(attrs));
attrs.Mask = VLADDR_INDEX;
attrs.index = (base * VL_MHSRV_PERBLK) + index;
code =
- ubik_Call(VL_GetAddrsU, cstruct, 0, &attrs, &uuid,
+ ubik_VL_GetAddrsU(cstruct, 0, &attrs, &uuid,
&unique, &nentries2, &addrs2);
if (code) {
printf("VL_GetAddrsU returned code = %d\n", code);
for (j = 0; j < nentries2; j++) {
serveraddrs[i][j] = ntohl(addrp2[j]);
}
- free((char *)addrs2.bulkaddrs_val);
+ free(addrs2.bulkaddrs_val);
}
if (nargs) {
}
}
}
- free((char *)addrs1.bulkaddrs_val);
+ free(addrs1.bulkaddrs_val);
/* Look for any duplicates */
for (i = 0; i < MAXSERVERID + 1; i++) {
printf("Illegal # entries = %d\n", nargs);
continue;
}
- addrp = (afs_uint32 *) malloc(20 * 4);
+ addrp = malloc(20 * 4);
addrs.bulkaddrs_val = addrp;
addrs.bulkaddrs_len = nargs;
while (nargs > 0) {
++argp, --nargs;
}
code =
- ubik_Call(VL_RegisterAddrs, cstruct, 0, &uuid,
+ ubik_VL_RegisterAddrs(cstruct, 0, &uuid,
0 /*spare */ , &addrs);
if (code) {
printf("VL_RegisterAddrs returned code = %d\n", code);
continue;
}
} else if (!strcmp(oper, "ca")) {
- extern struct hostent *hostutil_GetHostByName();
struct hostent *h1, *h2;
afs_uint32 a1, a2;
printf("changing 0x%x to 0x%x\n", ntohl(a1), ntohl(a2));
code =
- ubik_Call(VL_ChangeAddr, cstruct, 0, ntohl(a1),
+ ubik_VL_ChangeAddr(cstruct, 0, ntohl(a1),
ntohl(a2));
if (code) {
printf("VL_ChangeAddr returned code = %d\n", code);
++argp, --nargs;
sscanf(&(*argp)[0], "%d", &a2);
printf(" to %d (0x%x)\n", a2, a2);
- code = ubik_Call(VL_ChangeAddr, cstruct, 0, a1, a2);
+ code = ubik_VL_ChangeAddr(cstruct, 0, a1, a2);
if (code) {
printf("VL_ChangeAddr returned code = %d\n", code);
continue;
}
- } else if ((!strcmp(oper, "?")) || !strcmp(oper, "h"))
+ } else if ((!strcmp(oper, "?")) || !strcmp(oper, "h") || !strcmp(oper, "help"))
print_usage();
else if ((!strcmp(oper, "q")) || !strcmp(oper, "quit"))
exit(0);
else {
- printf("Unknown oper!\n");
+ printf("Unknown oper (%s)!\n", oper);
+ print_usage();
}
}
}
#include "AFS_component_version_number.c"
-main(argc, argv)
- int argc;
- char **argv;
+int
+main(int argc, char **argv)
{
- register struct cmd_syndesc *ts;
+ struct cmd_syndesc *ts;
afs_int32 code;
strcpy(confdir, AFSDIR_CLIENT_ETC_DIRPATH);
- ts = cmd_CreateSyntax("initcmd", handleit, NULL, "initialize the program");
+ ts = cmd_CreateSyntax("initcmd", handleit, NULL, 0, "initialize the program");
cmd_AddParm(ts, "-cellpath", CMD_LIST, CMD_OPTIONAL,
"Cell configuration directory");
cmd_AddParm(ts, "-server", CMD_LIST, CMD_OPTIONAL,
"cellname '-host' belongs to (required for auth conns)");
cmd_AddParm(ts, "-getstats", CMD_FLAG, CMD_OPTIONAL,
"print vldb statistics (non interactive)");
+ cmd_AddParm(ts, "-probe", CMD_FLAG, CMD_OPTIONAL,
+ "probe vldb servers, use with -host to probe only one. (non interactive)");
code = cmd_Dispatch(argc, argv);
exit(code);
}
void
-fill_entry(entry, argp, nargs)
- struct vldbentry *entry;
- char **argp;
- int nargs;
+fill_entry(struct vldbentry *entry, char **argp, int nargs)
{
char *name;
int i;
}
for (i = 0; i < MAXTYPES; i++) {
++argp, --nargs;
- sscanf(&(*argp)[0], "%d", &entry->volumeId[i]);
+ sscanf(&(*argp)[0], "%u", &entry->volumeId[i]);
}
++argp, --nargs;
sscanf(&(*argp)[0], "%d", &entry->flags);
++argp, --nargs;
- sscanf(&(*argp)[0], "%d", &entry->cloneId);
+ sscanf(&(*argp)[0], "%u", &entry->cloneId);
}
void
-fill_update_entry(entry, argp, nargs)
- struct VldbUpdateEntry *entry;
- char **argp;
- int nargs;
+fill_update_entry(struct VldbUpdateEntry *entry, char **argp, int nargs)
{
int i, Mask;
char *name;
if (entry->flags != -1)
entry->Mask |= VLUPDATE_FLAGS;
++argp, --nargs;
- sscanf(&(*argp)[0], "%d", &entry->cloneId);
+ sscanf(&(*argp)[0], "%u", &entry->cloneId);
if (entry->flags != -1)
entry->Mask |= VLUPDATE_CLONEID;
++argp, --nargs;
- sscanf(&(*argp)[0], "%d", &entry->ReadOnlyId);
+ sscanf(&(*argp)[0], "%u", &entry->ReadOnlyId);
if (entry->ReadOnlyId != -1)
entry->Mask |= VLUPDATE_READONLYID;
++argp, --nargs;
- sscanf(&(*argp)[0], "%d", &entry->BackupId);
+ sscanf(&(*argp)[0], "%u", &entry->BackupId);
if (entry->BackupId != -1)
entry->Mask |= VLUPDATE_BACKUPID;
++argp, --nargs;
}
void
-fill_listattributes_entry(entry, argp, nargs)
- struct VldbListByAttributes *entry;
- char **argp;
- int nargs;
+fill_listattributes_entry(struct VldbListByAttributes *entry, char **argp,
+ int nargs)
{
entry->Mask = 0;
}
void
-display_listattributes_entry(entry, error)
- struct VldbListByAttributes *entry;
- int error;
+display_listattributes_entry(struct VldbListByAttributes *entry, int error)
{
if (error)
return;
#define volumetype_string(type) (type == RWVOL? "read/write":type == ROVOL? "readonly":type == BACKVOL? "backup":"unknown")
void
-display_entry(entry, error)
- struct vldbentry *entry;
- int error;
+display_entry(struct vldbentry *entry, int error)
{
int i;
}
void
-display_entryN(entry, error)
- struct nvldbentry *entry;
- int error;
+display_entryN(struct nvldbentry *entry, int error)
{
int i, et, ei;
}
void
-display_update_entry(entry, error)
- struct VldbUpdateEntry *entry;
- int error;
+display_update_entry(struct VldbUpdateEntry *entry, int error)
{
int i;
if (entry->Mask & VLUPDATE_CLONEID)
printf("\tNew CloneId: %X\n", entry->cloneId);
if (entry->Mask & VLUPDATE_READONLYID)
- printf("\tNew RO id: %D\n", entry->ReadOnlyId);
+ printf("\tNew RO id: %d\n", entry->ReadOnlyId);
if (entry->Mask & VLUPDATE_BACKUPID)
- printf("\tNew BACKUP id: %D\n", entry->BackupId);
+ printf("\tNew BACKUP id: %d\n", entry->BackupId);
if (entry->Mask & VLUPDATE_REPSITES) {
printf("\tRepsites info:\n");
printf("\tFlag\tTServer\tTPart\tNServer\tNPart\tNFlag\n");
for (i = 0; i < entry->nModifiedRepsites; i++) {
- printf("\t%4x\t%7U\t%5d", entry->RepsitesMask[i],
+ printf("\t%4x\t%7u\t%5d", entry->RepsitesMask[i],
entry->RepsitesTargetServer[i],
entry->RepsitesTargetPart[i]);
if ((entry->RepsitesMask[i] & VLUPDATE_REPS_ADD)
|| (entry->RepsitesMask[i] & VLUPDATE_REPS_MODSERV))
- printf("\t%7U", entry->RepsitesNewServer[i]);
+ printf("\t%7u", entry->RepsitesNewServer[i]);
else
printf("\t-------");
if ((entry->RepsitesMask[i] & VLUPDATE_REPS_ADD)
}
void
-dump_stats(stats, vital_header)
- vldstats *stats;
- vital_vlheader *vital_header;
+dump_stats(vldstats *stats, vital_vlheader *vital_header)
{
int i;
char strg[30];
time_t start_time = stats->start_time;
+ struct tm tm;
- strncpy(strg, ctime(&start_time), sizeof(strg));
- strg[strlen(strg) - 1] = 0;
+ strftime(strg, sizeof(strg), "%a %b %d %H:%M:%S %Y",
+ localtime_r(&start_time, &tm));
printf("Dynamic statistics stats (starting time: %s):\n", strg);
printf("OpcodeName\t# Requests\t# Aborts\n");
for (i = 0; i < VL_NUMBER_OPCODESX; i++)
}
void
-GetArgs(line, args, nargs)
- register char *line;
- register char **args;
- register int *nargs;
+GetArgs(char *line, char **args, int *nargs)
{
*nargs = 0;
while (*line) {
- register char *last = line;
- while (*line == ' ')
+ char *last = line;
+ while (isspace(*line))
line++;
- if (*last == ' ')
+ if (isspace(*last))
*last = 0;
if (!*line)
break;
*args++ = line, (*nargs)++;
- while (*line && *line != ' ')
+ while (*line && !isspace(*line))
line++;
}
}
void
-print_usage()
+print_usage(void)
{
printf("Valid Commands:\n");