#include <afs/stds.h>
#include <afs/vice.h>
#include <afs/venus.h>
+#include <afs/com_err.h>
#ifdef AFS_AIX32_ENV
#include <signal.h>
#endif
#undef VICE
#include "afs/prs_fs.h"
#include <afs/afsint.h>
-#include <afs/auth.h>
#include <afs/cellconfig.h>
#include <ubik.h>
#include <rx/rxkad.h>
static struct ubik_client *uclient;
static int GetClientAddrsCmd(), SetClientAddrsCmd(), FlushMountCmd();
-static int RxStatProcCmd(), RxStatPeerCmd();
+static int RxStatProcCmd(), RxStatPeerCmd(), GetFidCmd(), UuidCmd();
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;
return error;
}
+/*
+ * The Windows version of UuidCmd displays the UUID.
+ * When the UNIX version is updated to do the same
+ * be sure to replace the CMD_REQUIRED flag with
+ * CMD_OPTIONAL in the cmd_AddParam(-generate) call
+ */
+static int
+UuidCmd(struct cmd_syndesc *as, char *arock)
+{
+ afs_int32 code;
+ struct ViceIoctl blob;
+
+ blob.in_size = 0;
+ blob.out_size = 0;
+
+ if (as->parms[0].items) {
+ if (geteuid()) {
+ fprintf (stderr, "Permission denied: requires root access.\n");
+ return EACCES;
+ }
+
+ /* generate new UUID */
+ code = pioctl(0, VIOC_NEWUUID, &blob, 1);
+
+ if (code) {
+ Die(errno, 0);
+ return 1;
+ }
+
+ printf("New uuid generated.\n");
+ } else {
+ /* This will never execute */
+ printf("Please add the '-generate' option to generate a new UUID.\n");
+ }
+ return 0;
+}
+
static int
FlushCmd(struct cmd_syndesc *as, char *arock)
{
if (code == 0) {
/* make the check. Don't complain if there are problems with init */
code =
- ubik_Call(VL_GetEntryByNameO, uclient, 0, volName,
+ ubik_VL_GetEntryByNameO(uclient, 0, volName,
&vldbEntry);
if (code == VL_NOENT) {
fprintf(stderr,
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]);
+
+ if (parms[2] == 0)
+ return 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;
}
}
static int
+NukeNFSCredsCmd(struct cmd_syndesc *as, char *arock)
+{
+ afs_int32 code;
+ struct ViceIoctl blob;
+ struct cmd_item *ti;
+ afs_int32 hostAddr;
+ struct hostent *thp;
+
+ ti = as->parms[0].items;
+ thp = hostutil_GetHostByName(ti->data);
+ if (!thp) {
+ fprintf(stderr, "host %s not found in host table.\n", ti->data);
+ return 1;
+ }
+ else memcpy(&hostAddr, thp->h_addr, sizeof(afs_int32));
+
+ /* now do operation */
+ blob.in_size = sizeof(afs_int32);
+ blob.out_size = sizeof(afs_int32);
+ blob.in = (char *) &hostAddr;
+ blob.out = (char *) &hostAddr;
+
+ code = pioctl(0, VIOC_NFS_NUKE_CREDS, &blob, 1);
+ if (code < 0) {
+ Die(errno, 0);
+ return 1;
+ }
+ return 0;
+}
+
+static int
NewCellCmd(struct cmd_syndesc *as, char *arock)
{
afs_int32 code, linkedstate = 0, size = 0, *lp;
struct ViceIoctl blob;
struct cmd_item *ti;
int export = 0, type = 0, mode = 0, exp = 0, exportcall, pwsync =
- 0, smounts = 0;
+ 0, smounts = 0, clipags = 0, pagcb = 0;
ti = as->parms[0].items;
if (strcmp(ti->data, "nfs") == 0)
return 1;
}
}
+ if (ti = as->parms[5].items) { /* -clipags */
+ if (strcmp(ti->data, "on") == 0)
+ clipags = 3;
+ else if (strcmp(ti->data, "off") == 0)
+ clipags = 2;
+ else {
+ fprintf(stderr, "Illegal argument %s\n", ti->data);
+ return 1;
+ }
+ }
+ if (ti = as->parms[6].items) { /* -pagcb */
+ if (strcmp(ti->data, "on") == 0)
+ pagcb = 3;
+ else if (strcmp(ti->data, "off") == 0)
+ pagcb = 2;
+ else {
+ fprintf(stderr, "Illegal argument %s\n", ti->data);
+ return 1;
+ }
+ }
exportcall =
- (type << 24) | (mode << 6) | (pwsync << 4) | (smounts << 2) | export;
+ (type << 24) | (pagcb << 10) | (clipags << 8) |
+ (mode << 6) | (pwsync << 4) | (smounts << 2) | export;
type &= ~0x70;
/* make the call */
blob.in = (char *)&exportcall;
printf("\t%s\n",
(exportcall & 8 ? "Allow mounts of /afs/.. subdirs" :
"Only mounts to /afs allowed"));
+ printf("\t%s\n",
+ (exportcall & 16 ? "Client-assigned PAG's are used" :
+ "Client-assigned PAG's are not used"));
+ printf("\t%s\n",
+ (exportcall & 32 ?
+ "Callbacks are made to get creds from new clients" :
+ "Callbacks are not made to get creds from new clients"));
} else {
printf("'%s' translator is disabled\n", exported_types[type]);
}
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");
"run on strict 'uid check' mode (on | off)");
cmd_AddParm(ts, "-submounts", CMD_SINGLE, CMD_OPTIONAL,
"allow nfs mounts to subdirs of /afs/.. (on | off)");
+ cmd_AddParm(ts, "-clipags", CMD_SINGLE, CMD_OPTIONAL,
+ "enable use of client-assigned PAG's (on | off)");
+ cmd_AddParm(ts, "-pagcb", CMD_SINGLE, CMD_OPTIONAL,
+ "enable callbacks to get creds from new clients (on | off)");
ts = cmd_CreateSyntax("storebehind", StoreBehindCmd, 0,
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
+
+ ts = cmd_CreateSyntax("nukenfscreds", NukeNFSCredsCmd, 0, "nuke credentials for NFS client");
+ cmd_AddParm(ts, "-addr", CMD_SINGLE, 0, "host name or address");
+
+ ts = cmd_CreateSyntax("uuid", UuidCmd, 0, "manage the UUID for the cache manager");
+ cmd_AddParm(ts, "-generate", CMD_FLAG, CMD_REQUIRED, "generate a new UUID");
+
code = cmd_Dispatch(argc, argv);
if (rxInitDone)
rx_Finalize();
fprintf(stderr, "%s:'%s'", pn, filename);
else
fprintf(stderr, "%s", pn);
- fprintf(stderr, ": %s\n", error_message(errnum));
+ fprintf(stderr, ": %s\n", afs_error_message(errnum));
break;
}
}
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;
+}
+