static struct ubik_client *uclient;
static int GetClientAddrsCmd(), SetClientAddrsCmd(), FlushMountCmd();
-static int RxStatProcCmd(), RxStatPeerCmd();
+static int RxStatProcCmd(), RxStatPeerCmd(), GetFidCmd();
extern char *hostutil_GetNameByINet();
extern struct hostent *hostutil_GetHostByName();
afs_int32 rights;
};
+struct vcxstat2 {
+ afs_int32 callerAccess;
+ afs_int32 cbExpires;
+ afs_int32 anyAccess;
+ char mvstat;
+};
+
static void
ZapAcl(acl)
struct Acl *acl;
}
static int
+GetCallerAccess(struct cmd_syndesc *as, char *arock)
+{
+ struct cmd_item *ti;
+ int error = 0;
+
+ SetDotDefault(&as->parms[0].items);
+ for (ti = as->parms[0].items; ti; ti = ti->next) {
+ afs_int32 code;
+ struct ViceIoctl blob;
+ struct vcxstat2 stat;
+ blob.out_size = sizeof(struct vcxstat2);
+ blob.in_size = 0;
+ blob.out = (void *)&stat;
+ code = pioctl(ti->data, VIOC_GETVCXSTATUS2, &blob, 1);
+ if (code) {
+ Die(errno, ti->data);
+ error = 1;
+ continue;
+ }
+ printf("Callers access to %s is ", ti->data);
+ PRights(stat.callerAccess, 0);
+ printf("\n");
+ }
+ return error;
+}
+
+static int
FlushVolumeCmd(struct cmd_syndesc *as, char *arock)
{
afs_int32 code;
static int
GetCacheParmsCmd(struct cmd_syndesc *as, char *arock)
{
- afs_int32 code;
+ afs_int32 code, filesUsed;
struct ViceIoctl blob;
afs_int32 parms[MAXGCSIZE];
+ double percentFiles, percentBlocks;
+ afs_int32 flags = 0;
+
+ if (as->parms[0].items){ /* -files */
+ flags = 1;
+ } else if (as->parms[1].items){ /* -excessive */
+ flags = 2;
+ } else {
+ flags = 0;
+ }
memset(parms, '\0', sizeof parms); /* avoid Purify UMR error */
- blob.in = NULL;
- blob.in_size = 0;
+ if (flags){
+ blob.in = (char *)&flags;
+ blob.in_size = sizeof(afs_int32);
+ } else { /* be backward compatible */
+ blob.in = NULL;
+ blob.in_size = 0;
+ }
blob.out_size = sizeof(parms);
blob.out = (char *)parms;
code = pioctl(0, VIOCGETCACHEPARMS, &blob, 1);
Die(errno, NULL);
return 1;
}
- printf("AFS using %d of the cache's available %d 1K byte blocks.\n",
- parms[1], parms[0]);
- if (parms[1] > parms[0])
- printf
- ("[Cache guideline temporarily deliberately exceeded; it will be adjusted down but you may wish to increase the cache size.]\n");
+
+ if (!flags){
+ printf("AFS using %d of the cache's available %d 1K byte blocks.\n",
+ parms[1], parms[0]);
+ if (parms[1] > parms[0])
+ printf("[Cache guideline temporarily deliberately exceeded; it will be adjusted down but you may wish to increase the cache size.]\n");
+ return 0;
+ }
+
+ percentBlocks = ((double)parms[1]/parms[0]) * 100;
+ printf("AFS using %5.0f%% of cache blocks (%d of %d 1k blocks)\n",
+ percentBlocks, parms[1], parms[0]);
+
+ filesUsed = parms[2] - parms[3];
+ percentFiles = ((double)filesUsed/parms[2]) * 100;
+ printf(" %5.0f%% of the cache files (%d of %d files)\n",
+ percentFiles, filesUsed, parms[2]);
+ if (flags == 2){
+ printf(" afs_cacheFiles: %10d\n", parms[2]);
+ printf(" IFFree: %10d\n", parms[3]);
+ printf(" IFEverUsed: %10d\n", parms[4]);
+ printf(" IFDataMod: %10d\n", parms[5]);
+ printf(" IFDirtyPages: %10d\n", parms[6]);
+ printf(" IFAnyPages: %10d\n", parms[7]);
+ printf(" IFDiscarded: %10d\n", parms[8]);
+ printf(" DCentries: %10d\n", parms[9]);
+ printf(" 0k- 4K: %10d\n", parms[10]);
+ printf(" 4k- 16k: %10d\n", parms[11]);
+ printf(" 16k- 64k: %10d\n", parms[12]);
+ printf(" 64k- 256k: %10d\n", parms[13]);
+ printf(" 256k- 1M: %10d\n", parms[14]);
+ printf(" >=1M: %10d\n", parms[15]);
+ }
+
+ if (percentBlocks > 90)
+ printf("[cache size usage over 90%, consider increasing cache size]\n");
+ if (percentFiles > 90)
+ printf("[cache file usage over 90%, consider increasing '-files' argument to afsd]\n");
+
return 0;
}
VLDBInit(int noAuthFlag, struct afsconf_cell *info)
{
afs_int32 code;
- struct ktc_principal sname;
- struct ktc_token ttoken;
- afs_int32 scIndex;
- struct rx_securityClass *sc;
- struct rx_connection *serverconns[VLDB_MAXSERVERS];
- afs_int32 i;
-
- code = rx_Init(0);
- if (code) {
- fprintf(stderr, "%s: could not initialize rx.\n", pn);
- return code;
- }
- rxInitDone = 1;
- rx_SetRxDeadTime(50);
- if (!noAuthFlag) { /* we don't need tickets for null */
- strcpy(sname.cell, info->name);
- sname.instance[0] = 0;
- strcpy(sname.name, "afs");
- code = ktc_GetToken(&sname, &ttoken, sizeof(ttoken), NULL);
- if (code) {
- fprintf(stderr,
- "%s: Could not get afs tokens, running unauthenticated.\n",
- pn);
- scIndex = 0;
- } else {
- /* got a ticket */
- if (ttoken.kvno >= 0 && ttoken.kvno <= 255)
- scIndex = 2; /* kerberos */
- else {
- fprintf(stderr, "%s: funny kvno (%d) in ticket, proceeding\n",
- pn, ttoken.kvno);
- scIndex = 2;
- }
- }
- } else
- scIndex = 0; /* don't authenticate */
- switch (scIndex) {
- case 0:
- sc = rxnull_NewClientSecurityObject();
- break;
-
- case 1:
- break;
- case 2:
- sc = (struct rx_securityClass *)
- rxkad_NewClientSecurityObject(rxkad_clear, &ttoken.sessionKey,
- ttoken.kvno, ttoken.ticketLen,
- ttoken.ticket);
- break;
- }
- if (info->numServers > VLDB_MAXSERVERS) {
- fprintf(stderr, "%s: info.numServers=%d (> VLDB_MAXSERVERS=%d)\n", pn,
- info->numServers, VLDB_MAXSERVERS);
- exit(1);
- }
- memset(serverconns, 0, sizeof(serverconns));
- for (i = 0; i < info->numServers; i++)
- serverconns[i] =
- rx_NewConnection(info->hostAddr[i].sin_addr.s_addr,
- info->hostAddr[i].sin_port, USER_SERVICE_ID, sc,
- scIndex);
- code = ubik_ClientInit(serverconns, &uclient);
-
- if (code) {
- fprintf(stderr, "%s: ubik client init failed.\n", pn);
- return code;
- }
- return 0;
+ code = ugen_ClientInit(noAuthFlag, AFSDIR_CLIENT_ETC_DIRPATH,
+ info->name, 0, &uclient,
+ NULL, pn, rxkad_clear,
+ VLDB_MAXSERVERS, AFSCONF_VLDBSERVICE, 50,
+ 0, 0, USER_SERVICE_ID);
+ rxInitDone = 1;
+ return code;
}
static struct ViceIoctl gblob;
return 0;
}
+#ifdef AFS_DISCON_ENV
+static char *modenames[] = {
+ "discon",
+ "fetchonly",
+ "partial",
+ "nat",
+ "full",
+ NULL
+};
+
+static afs_int32
+DisconCmd(struct cmd_syndesc *as, char *arock)
+{
+ struct cmd_item *ti;
+ char *modename;
+ int modelen;
+ afs_int32 mode, code;
+ struct ViceIoctl blob;
+
+ blob.in = NULL;
+ blob.in_size = 0;
+
+ ti = as->parms[0].items;
+ if (ti) {
+ modename = ti->data;
+ modelen = strlen(modename);
+ for (mode = 0; modenames[mode] != NULL; mode++)
+ if (!strncasecmp(modename, modenames[mode], modelen))
+ break;
+ if (modenames[mode] == NULL)
+ printf("Unknown discon mode \"%s\"\n", modename);
+ else {
+ memcpy(space, &mode, sizeof mode);
+ blob.in = space;
+ blob.in_size = sizeof mode;
+ }
+ }
+
+ blob.out_size = sizeof(mode);
+ blob.out = space;
+ code = pioctl(0, VIOC_DISCON, &blob, 1);
+ if (code)
+ Die(errno, NULL);
+ else {
+ memcpy(&mode, space, sizeof mode);
+ if (mode < sizeof modenames / sizeof (char *))
+ printf("Discon mode is now \"%s\"\n", modenames[mode]);
+ else
+ printf("Unknown discon mode %d\n", mode);
+ }
+
+ return 0;
+}
+#endif
+
#include "AFS_component_version_number.c"
int
cmd_AddParm(ts, "-if", CMD_FLAG, CMD_OPTIONAL, "initial file acl");
cmd_CreateAlias(ts, "la");
+ ts = cmd_CreateSyntax("getcalleraccess", GetCallerAccess, 0,
+ "list callers access");
+ cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
+ cmd_CreateAlias(ts, "gca");
+
ts = cmd_CreateSyntax("cleanacl", CleanACLCmd, 0,
"clean up access control list");
cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
ts = cmd_CreateSyntax("getcacheparms", GetCacheParmsCmd, 0,
"get cache usage info");
+ cmd_AddParm(ts, "-files", CMD_FLAG, CMD_OPTIONAL, "Show cach files used as well");
+ cmd_AddParm(ts, "-excessive", CMD_FLAG, CMD_OPTIONAL, "excessively verbose cache stats");
ts = cmd_CreateSyntax("listcells", ListCellsCmd, 0,
"list configured cells");
cmd_AddParm(ts, "-crypt", CMD_SINGLE, 0, "on or off");
ts = cmd_CreateSyntax("getcrypt", GetCryptCmd, 0,
- "set cache manager encryption flag");
+ "get cache manager encryption flag");
ts = cmd_CreateSyntax("rxstatproc", RxStatProcCmd, 0,
"Manage per process RX statistics");
ts = cmd_CreateSyntax("setcbaddr", CallBackRxConnCmd, 0, "configure callback connection address");
cmd_AddParm(ts, "-addr", CMD_SINGLE, CMD_OPTIONAL, "host name or address");
+ /* try to find volume location information */
+ ts = cmd_CreateSyntax("getfid", GetFidCmd, 0,
+ "get fid for file(s)");
+ cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
+
+#ifdef AFS_DISCON_ENV
+ ts = cmd_CreateSyntax("discon", DisconCmd, 0,
+ "disconnection mode");
+ cmd_AddParm(ts, "-mode", CMD_SINGLE, CMD_OPTIONAL, "nat | full");
+#endif
+
code = cmd_Dispatch(argc, argv);
if (rxInitDone)
rx_Finalize();
return 0;
}
+static int
+GetFidCmd(struct cmd_syndesc *as, char *arock)
+{
+ struct ViceIoctl blob;
+ struct cmd_item *ti;
+ for (ti = as->parms[0].items; ti; ti = ti->next) {
+ struct VenusFid vfid;
+
+ blob.out_size = sizeof(struct VenusFid);
+ blob.out = (char *) &vfid;
+ blob.in_size = 0;
+
+ if (0 == pioctl(ti->data, VIOCGETFID, &blob, 1)) {
+ printf("File %s (%u.%u.%u) contained in volume %u\n",
+ ti->data, vfid.Fid.Volume, vfid.Fid.Vnode, vfid.Fid.Unique,
+ vfid.Fid.Volume);
+ }
+ }
+
+ return 0;
+}
+