cmd: avoid piggy-backing flags in the help string
[openafs.git] / src / venus / fs.c
index 439bc78..caf7ce3 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * 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
@@ -9,34 +9,19 @@
 
 #include <afsconfig.h>
 #include <afs/param.h>
+#include <afs/stds.h>
 
-RCSID
-    ("$Header$");
+#include <roken.h>
+#include <ctype.h>
+#include <assert.h>
 
+#include <afs/afs_consts.h>
 #include <afs/afs_args.h>
 #include <rx/xdr.h>
-#include <sys/ioctl.h>
-#include <sys/socket.h>
-#include <netdb.h>
-#include <errno.h>
-#include <stdio.h>
-#include <netinet/in.h>
-#include <sys/stat.h>
-#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
-
-#ifdef HAVE_STRING_H
-#include <string.h>
-#else
-#ifdef HAVE_STRINGS_H
-#include <strings.h>
-#endif
-#endif
+#include <afs/afs_consts.h>
 
 #undef VIRTUE
 #undef VICE
@@ -50,42 +35,39 @@ RCSID
 #include <afs/volser.h>
 #include <afs/vlserver.h>
 #include <afs/cmd.h>
-#include <afs/afsutil.h>
-#include <stdlib.h>
-#include <assert.h>
+#include <afs/com_err.h>
 #include <afs/ptclient.h>
+#include <afs/ptuser.h>
+#include <afs/afsutil.h>
+#include <afs/sys_prototypes.h>
 
-
-#define        MAXHOSTS 13
-#define        OMAXHOSTS 8
-#define MAXCELLHOSTS 8
 #define MAXNAME 100
-#define        MAXSIZE 2048
 #define MAXINSIZE 1300         /* pioctl complains if data is larger than this */
 #define VMSGSIZE 128           /* size of msg buf in volume hdr */
 
-static char space[MAXSIZE];
+static char space[AFS_PIOCTL_MAXSIZE];
 static char tspace[1024];
 static struct ubik_client *uclient;
 
-static int GetClientAddrsCmd(), SetClientAddrsCmd(), FlushMountCmd();
-static int RxStatProcCmd(), RxStatPeerCmd(), GetFidCmd(), NewUuidCmd();
-
-extern char *hostutil_GetNameByINet();
-extern struct hostent *hostutil_GetHostByName();
-
+static int GetClientAddrsCmd(struct cmd_syndesc *, void *);
+static int SetClientAddrsCmd(struct cmd_syndesc *, void *);
+static int FlushMountCmd(struct cmd_syndesc *, void *);
+static int RxStatProcCmd(struct cmd_syndesc *, void *);
+static int RxStatPeerCmd(struct cmd_syndesc *, void *);
+static int GetFidCmd(struct cmd_syndesc *, void *);
+static int UuidCmd(struct cmd_syndesc *, void *);
 
-extern struct cmd_syndesc *cmd_CreateSyntax();
 static char pn[] = "fs";
 static int rxInitDone = 0;
 
-static void ZapList();
-static int PruneList();
-static CleanAcl();
-static SetVolCmd();
-static GetCellName();
-static VLDBInit();
-static void Die();
+struct AclEntry;
+struct Acl;
+static void ZapList(struct AclEntry *);
+static int PruneList(struct AclEntry **, int);
+static int CleanAcl(struct Acl *, char *);
+static int SetVolCmd(struct cmd_syndesc *as, void *arock);
+static int GetCellName(char *, struct afsconf_cell *);
+static void Die(int, char *);
 
 /*
  * Character to use between name and rights in printed representation for
@@ -120,8 +102,7 @@ struct vcxstat2 {
 };
 
 static void
-ZapAcl(acl)
-     struct Acl *acl;
+ZapAcl(struct Acl *acl)
 {
     if (!acl)
        return;
@@ -130,10 +111,8 @@ ZapAcl(acl)
     free(acl);
 }
 
-static
-foldcmp(a, b)
-     char *a;
-     char *b;
+static int
+foldcmp(char *a, char *b)
 {
     char t, u;
     while (1) {
@@ -286,6 +265,7 @@ PRights(afs_int32 arights, int dfs)
        if (arights & DFS_USR7)
            printf("H");
     }
+    return 0;
 }
 
 /* this function returns TRUE (1) if the file is in AFS, otherwise false (0) */
@@ -296,7 +276,7 @@ InAFS(char *apath)
     afs_int32 code;
 
     blob.in_size = 0;
-    blob.out_size = MAXSIZE;
+    blob.out_size = AFS_PIOCTL_MAXSIZE;
     blob.out = space;
 
     code = pioctl(apath, VIOC_FILE_CELL_NAME, &blob, 1);
@@ -312,26 +292,45 @@ static char *
 Parent(char *apath)
 {
     char *tp;
-    strcpy(tspace, apath);
+    strlcpy(tspace, apath, sizeof(tspace));
     tp = strrchr(tspace, '/');
-    if (tp) {
-       *tp = 0;
-    } else
-       strcpy(tspace, ".");
+    if (tp == (char *)tspace)
+       tp++;
+    else if (tp == NULL) {
+       tp      = (char *)tspace;
+       *(tp++) = '.';
+    }
+    *tp = '\0';
     return tspace;
 }
 
-enum rtype { add, destroy, deny };
+                                /* added relative add resp. delete    */
+                                /* (so old add really means to set)   */
+enum rtype { add, destroy, deny, reladd, reldel };
 
 static afs_int32
 Convert(char *arights, int dfs, enum rtype *rtypep)
 {
-    int i, len;
     afs_int32 mode;
     char tc;
+    char *tcp;                  /* to walk through the rights string  */
 
     *rtypep = add;             /* add rights, by default */
 
+                                /* analyze last character of string   */
+    tcp = arights + strlen(arights);
+    if ( tcp-- > arights ) {    /* assure non-empty string            */
+        if ( *tcp == '+' )
+            *rtypep = reladd;   /* '+' indicates more rights          */
+        else if ( *tcp == '-' )
+            *rtypep = reldel;   /* '-' indicates less rights          */
+        else if ( *tcp == '=' )
+            *rtypep = add;      /* '=' also allows old behaviour      */
+        else
+            tcp++;              /* back to original null byte         */
+        *tcp = '\0';            /* do not disturb old strcmp-s        */
+    }
+
     if (dfs) {
        if (!strcmp(arights, "null")) {
            *rtypep = deny;
@@ -361,10 +360,9 @@ Convert(char *arights, int dfs, enum rtype *rtypep)
        *rtypep = destroy;      /* Remove entire entry */
        return 0;
     }
-    len = strlen(arights);
     mode = 0;
-    for (i = 0; i < len; i++) {
-       tc = *arights++;
+    tcp = arights;
+    while ((tc = *tcp++ )) {
        if (dfs) {
            if (tc == '-')
                continue;
@@ -461,32 +459,47 @@ SetDotDefault(struct cmd_item **aitemp)
     if (*aitemp)
        return;                 /* already has value */
     /* otherwise, allocate an item representing "." */
-    ti = (struct cmd_item *)malloc(sizeof(struct cmd_item));
+    ti = malloc(sizeof(struct cmd_item));
     assert(ti);
     ti->next = (struct cmd_item *)0;
-    ti->data = (char *)malloc(2);
+    ti->data = malloc(2);
     assert(ti->data);
     strcpy(ti->data, ".");
     *aitemp = ti;
 }
 
 static void
-ChangeList(struct Acl *al, afs_int32 plus, char *aname, afs_int32 arights)
+ChangeList(struct Acl *al, afs_int32 plus, char *aname, afs_int32 arights,
+          enum rtype *artypep)
 {
     struct AclEntry *tlist;
     tlist = (plus ? al->pluslist : al->minuslist);
     tlist = FindList(tlist, aname);
     if (tlist) {
-       /* Found the item already in the list. */
-       tlist->rights = arights;
+       /* Found the item already in the list.
+        * modify rights in case of reladd and reladd only,
+        * use standard - add, ie. set - otherwise
+        */
+        if ( artypep == NULL )
+            tlist->rights = arights;
+        else if ( *artypep == reladd )
+            tlist->rights |= arights;
+        else if ( *artypep == reldel )
+            tlist->rights &= ~arights;
+        else
+            tlist->rights = arights;
+
        if (plus)
            al->nplus -= PruneList(&al->pluslist, al->dfs);
        else
            al->nminus -= PruneList(&al->minuslist, al->dfs);
        return;
     }
+    if ( artypep != NULL && *artypep == reldel )
+        return;                 /* can't reduce non-existing rights   */
+
     /* Otherwise we make a new item and plug in the new data. */
-    tlist = (struct AclEntry *)malloc(sizeof(struct AclEntry));
+    tlist = malloc(sizeof(struct AclEntry));
     assert(tlist);
     strcpy(tlist->name, aname);
     tlist->rights = arights;
@@ -559,12 +572,12 @@ EmptyAcl(char *astr)
     struct Acl *tp;
     int junk;
 
-    tp = (struct Acl *)malloc(sizeof(struct Acl));
+    tp = malloc(sizeof(struct Acl));
     assert(tp);
     tp->nplus = tp->nminus = 0;
     tp->pluslist = tp->minuslist = 0;
     tp->dfs = 0;
-    sscanf(astr, "%d dfs:%d %s", &junk, &tp->dfs, tp->cell);
+    sscanf(astr, "%d dfs:%d %1024s", &junk, &tp->dfs, tp->cell);
     return tp;
 }
 
@@ -576,10 +589,10 @@ ParseAcl(char *astr)
     struct AclEntry *first, *last, *tl;
     struct Acl *ta;
 
-    ta = (struct Acl *)malloc(sizeof(struct Acl));
+    ta = malloc(sizeof(struct Acl));
     assert(ta);
     ta->dfs = 0;
-    sscanf(astr, "%d dfs:%d %s", &ta->nplus, &ta->dfs, ta->cell);
+    sscanf(astr, "%d dfs:%d %1024s", &ta->nplus, &ta->dfs, ta->cell);
     astr = SkipLine(astr);
     sscanf(astr, "%d", &ta->nminus);
     astr = SkipLine(astr);
@@ -590,9 +603,9 @@ ParseAcl(char *astr)
     last = 0;
     first = 0;
     for (i = 0; i < nplus; i++) {
-       sscanf(astr, "%100s %d", tname, &trights);
+       sscanf(astr, "%99s %d", tname, &trights);
        astr = SkipLine(astr);
-       tl = (struct AclEntry *)malloc(sizeof(struct AclEntry));
+       tl = malloc(sizeof(struct AclEntry));
        assert(tl);
        if (!first)
            first = tl;
@@ -608,9 +621,9 @@ ParseAcl(char *astr)
     last = 0;
     first = 0;
     for (i = 0; i < nminus; i++) {
-       sscanf(astr, "%100s %d", tname, &trights);
+       sscanf(astr, "%99s %d", tname, &trights);
        astr = SkipLine(astr);
-       tl = (struct AclEntry *)malloc(sizeof(struct AclEntry));
+       tl = malloc(sizeof(struct AclEntry));
        assert(tl);
        if (!first)
            first = tl;
@@ -643,8 +656,30 @@ PrintStatus(VolumeStatus * status, char *name, char *offmsg)
     return 0;
 }
 
+static const char power_letter[] = {
+  'K',  /* kibi */
+  'M',  /* mebi */
+  'G',  /* gibi */
+  'T',  /* tebi */
+  'P',  /* pebi */
+};
+
+static void
+HumanPrintSpace(afs_int32 int_space)
+{
+    int exponent = 0;
+    int exponent_max = sizeof(power_letter) - 1;
+    float space = int_space;
+
+    while (space >= 1024 && exponent < exponent_max) {
+       exponent++;
+       space /= 1024;
+    }
+    printf("%9.1f%c", space, power_letter[exponent]);
+}
+
 static int
-QuickPrintStatus(VolumeStatus * status, char *name)
+QuickPrintStatus(VolumeStatus * status, char *name, int human)
 {
     double QuotaUsed = 0.0;
     double PartUsed = 0.0;
@@ -652,11 +687,22 @@ QuickPrintStatus(VolumeStatus * status, char *name)
     printf("%-25.25s", name);
 
     if (status->MaxQuota != 0) {
-       printf("%10d%10d", status->MaxQuota, status->BlocksInUse);
+       if (human) {
+           printf(" ");
+           HumanPrintSpace(status->MaxQuota);
+           printf(" ");
+           HumanPrintSpace(status->BlocksInUse);
+       }
+       else
+           printf(" %10d %10d", status->MaxQuota, status->BlocksInUse);
        QuotaUsed =
            ((((double)status->BlocksInUse) / status->MaxQuota) * 100.0);
     } else {
-       printf("  no limit%10d", status->BlocksInUse);
+       printf("   no limit ");
+       if (human)
+           HumanPrintSpace(status->BlocksInUse);
+       else
+           printf("%10d", status->BlocksInUse);
     }
     if (QuotaUsed > 90.0) {
        printf("%5.0f%%<<", QuotaUsed);
@@ -680,15 +726,21 @@ QuickPrintStatus(VolumeStatus * status, char *name)
 }
 
 static int
-QuickPrintSpace(VolumeStatus * status, char *name)
+QuickPrintSpace(VolumeStatus * status, char *name, int human)
 {
     double PartUsed = 0.0;
     int WARN = 0;
     printf("%-25.25s", name);
 
-    printf("%10d%10d%10d", status->PartMaxBlocks,
-          status->PartMaxBlocks - status->PartBlocksAvail,
-          status->PartBlocksAvail);
+    if (human) {
+       HumanPrintSpace(status->PartMaxBlocks);
+       HumanPrintSpace(status->PartMaxBlocks - status->PartBlocksAvail);
+       HumanPrintSpace(status->PartBlocksAvail);
+    }
+    else
+       printf("%10d%10d%10d", status->PartMaxBlocks,
+               status->PartMaxBlocks - status->PartBlocksAvail,
+               status->PartBlocksAvail);
 
     PartUsed =
        (100.0 -
@@ -709,8 +761,8 @@ QuickPrintSpace(VolumeStatus * status, char *name)
 static char *
 AclToString(struct Acl *acl)
 {
-    static char mydata[MAXSIZE];
-    char tstring[MAXSIZE];
+    static char mydata[AFS_PIOCTL_MAXSIZE];
+    char tstring[AFS_PIOCTL_MAXSIZE];
     char dfsstring[30];
     struct AclEntry *tp;
 
@@ -731,7 +783,7 @@ AclToString(struct Acl *acl)
 }
 
 static int
-SetACLCmd(struct cmd_syndesc *as, char *arock)
+SetACLCmd(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 code;
     struct ViceIoctl blob;
@@ -749,7 +801,7 @@ SetACLCmd(struct cmd_syndesc *as, char *arock)
        clear = 0;
     plusp = !(as->parms[3].items);
     for (ti = as->parms[0].items; ti; ti = ti->next) {
-       blob.out_size = MAXSIZE;
+       blob.out_size = AFS_PIOCTL_MAXSIZE;
        blob.in_size = idf;
        blob.in = blob.out = space;
        code = pioctl(ti->data, VIOCGETAL, &blob, 1);
@@ -798,7 +850,7 @@ SetACLCmd(struct cmd_syndesc *as, char *arock)
                plusp = 0;
            if (rtype == destroy && ta->dfs)
                rights = -1;
-           ChangeList(ta, plusp, ui->data, rights);
+           ChangeList(ta, plusp, ui->data, rights, &rtype);
        }
        blob.in = AclToString(ta);
        blob.out_size = 0;
@@ -865,15 +917,13 @@ SetACLCmd(struct cmd_syndesc *as, char *arock)
 
 
 static int
-CopyACLCmd(struct cmd_syndesc *as, char *arock)
+CopyACLCmd(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 code;
     struct ViceIoctl blob;
     struct Acl *fa, *ta = 0;
     struct AclEntry *tp;
-    struct cmd_item *ti, *ui;
-    int plusp;
-    afs_int32 rights;
+    struct cmd_item *ti;
     int clear;
     int idf = getidf(as, parm_copyacl_id);
     int error = 0;
@@ -882,7 +932,7 @@ CopyACLCmd(struct cmd_syndesc *as, char *arock)
        clear = 1;
     else
        clear = 0;
-    blob.out_size = MAXSIZE;
+    blob.out_size = AFS_PIOCTL_MAXSIZE;
     blob.in_size = idf;
     blob.in = blob.out = space;
     code = pioctl(as->parms[0].items->data, VIOCGETAL, &blob, 1);
@@ -893,7 +943,7 @@ CopyACLCmd(struct cmd_syndesc *as, char *arock)
     fa = ParseAcl(space);
     CleanAcl(fa, as->parms[0].items->data);
     for (ti = as->parms[1].items; ti; ti = ti->next) {
-       blob.out_size = MAXSIZE;
+       blob.out_size = AFS_PIOCTL_MAXSIZE;
        blob.in_size = idf;
        blob.in = blob.out = space;
        code = pioctl(ti->data, VIOCGETAL, &blob, 1);
@@ -927,10 +977,11 @@ CopyACLCmd(struct cmd_syndesc *as, char *arock)
            }
            strcpy(ta->cell, fa->cell);
        }
+                                /* NULL rtype for standard handling   */
        for (tp = fa->pluslist; tp; tp = tp->next)
-           ChangeList(ta, 1, tp->name, tp->rights);
+           ChangeList(ta, 1, tp->name, tp->rights, NULL);
        for (tp = fa->minuslist; tp; tp = tp->next)
-           ChangeList(ta, 0, tp->name, tp->rights);
+           ChangeList(ta, 0, tp->name, tp->rights, NULL);
        blob.in = AclToString(ta);
        blob.out_size = 0;
        blob.in_size = 1 + strlen(blob.in);
@@ -972,14 +1023,14 @@ GetCell(char *fname, char *cellname)
  * negative sign), then it might be bad. We then query the ptserver
  * to see.
  */
-static
+static int
 BadName(char *aname, char *fname)
 {
     afs_int32 tc, code, id;
     char *nm;
     char cell[MAXCELLCHARS];
 
-    for (nm = aname; tc = *nm; nm++) {
+    for (nm = aname; (tc = *nm); nm++) {
        /* all must be '-' or digit to be bad */
        if (tc != '-' && (tc < '0' || tc > '9'))
            return 0;
@@ -1001,7 +1052,7 @@ BadName(char *aname, char *fname)
 
 /* clean up an access control list of its bad entries; return 1 if we made
    any changes to the list, and 0 otherwise */
-static
+static int
 CleanAcl(struct Acl *aa, char *fname)
 {
     struct AclEntry *te, **le, *ne;
@@ -1045,7 +1096,7 @@ CleanAcl(struct Acl *aa, char *fname)
 
 /* clean up an acl to not have bogus entries */
 static int
-CleanACLCmd(struct cmd_syndesc *as, char *arock)
+CleanACLCmd(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 code;
     struct Acl *ta = 0;
@@ -1057,7 +1108,7 @@ CleanACLCmd(struct cmd_syndesc *as, char *arock)
 
     SetDotDefault(&as->parms[0].items);
     for (ti = as->parms[0].items; ti; ti = ti->next) {
-       blob.out_size = MAXSIZE;
+       blob.out_size = AFS_PIOCTL_MAXSIZE;
        blob.in_size = 0;
        blob.out = space;
        code = pioctl(ti->data, VIOCGETAL, &blob, 1);
@@ -1132,7 +1183,7 @@ CleanACLCmd(struct cmd_syndesc *as, char *arock)
 }
 
 static int
-ListACLCmd(struct cmd_syndesc *as, char *arock)
+ListACLCmd(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 code;
     struct Acl *ta;
@@ -1144,7 +1195,7 @@ ListACLCmd(struct cmd_syndesc *as, char *arock)
 
     SetDotDefault(&as->parms[0].items);
     for (ti = as->parms[0].items; ti; ti = ti->next) {
-       blob.out_size = MAXSIZE;
+       blob.out_size = AFS_PIOCTL_MAXSIZE;
        blob.in_size = idf;
        blob.in = blob.out = space;
        code = pioctl(ti->data, VIOCGETAL, &blob, 1);
@@ -1154,49 +1205,68 @@ ListACLCmd(struct cmd_syndesc *as, char *arock)
            continue;
        }
        ta = ParseAcl(space);
-       switch (ta->dfs) {
-       case 0:
-           printf("Access list for %s is\n", ti->data);
-           break;
-       case 1:
-           printf("DFS access list for %s is\n", ti->data);
-           break;
-       case 2:
-           printf("DFS initial directory access list of %s is\n", ti->data);
-           break;
-       case 3:
-           printf("DFS initial file access list of %s is\n", ti->data);
-           break;
-       }
-       if (ta->dfs) {
-           printf("  Default cell = %s\n", ta->cell);
-       }
-       if (ta->nplus > 0) {
-           if (!ta->dfs)
-               printf("Normal rights:\n");
-           for (te = ta->pluslist; te; te = te->next) {
-               printf("  %s ", te->name);
-               PRights(te->rights, ta->dfs);
-               printf("\n");
+        if (as->parms[3].items) {                      /* -cmd */
+            printf("fs setacl -dir %s -acl ", ti->data);
+            if (ta->nplus > 0) {
+                for (te = ta->pluslist; te; te = te->next) {
+                    printf("  %s ", te->name);
+                    PRights(te->rights, ta->dfs);
+                }
+            }
+            printf("\n");
+            if (ta->nminus > 0) {
+                printf("fs setacl -dir %s -acl ", ti->data);
+                for (te = ta->minuslist; te; te = te->next) {
+                    printf("  %s ", te->name);
+                    PRights(te->rights, ta->dfs);
+                }
+                printf(" -negative\n");
+            }
+        } else {
+           switch (ta->dfs) {
+           case 0:
+               printf("Access list for %s is\n", ti->data);
+               break;
+           case 1:
+               printf("DFS access list for %s is\n", ti->data);
+               break;
+           case 2:
+               printf("DFS initial directory access list of %s is\n", ti->data);
+               break;
+           case 3:
+               printf("DFS initial file access list of %s is\n", ti->data);
+               break;
            }
-       }
-       if (ta->nminus > 0) {
-           printf("Negative rights:\n");
-           for (te = ta->minuslist; te; te = te->next) {
-               printf("  %s ", te->name);
-               PRights(te->rights, ta->dfs);
-               printf("\n");
+           if (ta->dfs) {
+               printf("  Default cell = %s\n", ta->cell);
            }
+           if (ta->nplus > 0) {
+               if (!ta->dfs)
+                   printf("Normal rights:\n");
+               for (te = ta->pluslist; te; te = te->next) {
+                   printf("  %s ", te->name);
+                   PRights(te->rights, ta->dfs);
+                   printf("\n");
+               }
+           }
+           if (ta->nminus > 0) {
+               printf("Negative rights:\n");
+               for (te = ta->minuslist; te; te = te->next) {
+                   printf("  %s ", te->name);
+                   PRights(te->rights, ta->dfs);
+                   printf("\n");
+               }
+           }
+           if (ti->next)
+               printf("\n");
        }
-       if (ti->next)
-           printf("\n");
        ZapAcl(ta);
     }
     return error;
 }
 
 static int
-GetCallerAccess(struct cmd_syndesc *as, char *arock)
+GetCallerAccess(struct cmd_syndesc *as, void *arock)
 {
     struct cmd_item *ti;
     int error = 0;
@@ -1223,7 +1293,7 @@ GetCallerAccess(struct cmd_syndesc *as, char *arock)
 }
 
 static int
-FlushVolumeCmd(struct cmd_syndesc *as, char *arock)
+FlushVolumeCmd(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 code;
     struct ViceIoctl blob;
@@ -1245,25 +1315,131 @@ FlushVolumeCmd(struct cmd_syndesc *as, char *arock)
 }
 
 static int
-NewUuidCmd(struct cmd_syndesc *as, char *arock)
+FlushAllVolumesCmd(struct cmd_syndesc *as, void *arock)
+{
+    afs_int32 code;
+    struct ViceIoctl blob;
+    int error = 0;
+
+    blob.in_size = 0;
+    blob.out_size = AFS_PIOCTL_MAXSIZE;
+    blob.out = space;
+
+    code = pioctl(NULL, VIOC_FLUSHALL, &blob, 0);
+    if (code) {
+       fprintf(stderr, "Error flushing all volumes\n");
+       error = 1;
+    }
+    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, void *arock)
 {
     afs_int32 code;
     struct ViceIoctl blob;
 
     blob.in_size = 0;
     blob.out_size = 0;
-    code = pioctl(0, VIOC_NEWUUID, &blob, 1);
+
+    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;
+}
+
+#if defined(AFS_CACHE_BYPASS)
+/*
+ * Set cache-bypass threshold.  Files larger than this size will not be cached.
+ * With a threshold of 0, the cache is always bypassed.  With a threshold of -1,
+ * cache bypass is disabled.
+ */
+
+static int
+BypassThresholdCmd(struct cmd_syndesc *as, void *arock)
+{
+    afs_int32 code;
+    struct ViceIoctl blob;
+    afs_int32 threshold_i, threshold_o;
+    char *tp;
+
+    /* if new threshold supplied, then set and confirm, else,
+     * get current threshold and print
+     */
+
+    if(as->parms[0].items) {
+       int digit, ix, len;
+
+       tp = as->parms[0].items->data;
+       len = strlen(tp);
+
+        if (!strcmp(tp,"-1")) {
+            threshold_i = -1;
+        } else {
+            digit = 1;
+            for(ix = 0; ix < len; ++ix) {
+                if(!isdigit(tp[0])) {
+                    digit = 0;
+                    break;
+                }
+            }
+            if (digit == 0) {
+                fprintf(stderr, "fs bypassthreshold -size: %s must be an integer between -1 and 2^31\n", tp);
+                return EINVAL;
+            }
+            threshold_i = atoi(tp);
+            if(ix > 9 && threshold_i < 2147483647)
+                threshold_i = 2147483647;
+        }
+        blob.in = (char *) &threshold_i;
+        blob.in_size = sizeof(threshold_i);
+    } else {
+       blob.in = NULL;
+       blob.in_size = 0;
+    }
+
+    blob.out = (char *) &threshold_o;
+    blob.out_size = sizeof(threshold_o);
+    code = pioctl(0, VIOC_SETBYPASS_THRESH, &blob, 1);
     if (code) {
-       Die(errno, 0);
+       Die(errno, NULL);
        return 1;
+    } else {
+       printf("Cache bypass threshold %d", threshold_o);
+       if(threshold_o ==  -1)
+           printf(" (disabled)");
+       printf("\n");
     }
 
-    printf("New uuid generated.\n");
     return 0;
 }
 
+#endif
+
 static int
-FlushCmd(struct cmd_syndesc *as, char *arock)
+FlushCmd(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 code;
     struct ViceIoctl blob;
@@ -1290,17 +1466,17 @@ FlushCmd(struct cmd_syndesc *as, char *arock)
 
 /* all this command does is repackage its args and call SetVolCmd */
 static int
-SetQuotaCmd(struct cmd_syndesc *as, char *arock)
+SetQuotaCmd(struct cmd_syndesc *as, void *arock)
 {
     struct cmd_syndesc ts;
 
     /* copy useful stuff from our command slot; we may later have to reorder */
     memcpy(&ts, as, sizeof(ts));       /* copy whole thing */
-    return SetVolCmd(&ts);
+    return SetVolCmd(&ts, arock);
 }
 
 static int
-SetVolCmd(struct cmd_syndesc *as, char *arock)
+SetVolCmd(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 code;
     struct ViceIoctl blob;
@@ -1312,7 +1488,7 @@ SetVolCmd(struct cmd_syndesc *as, char *arock)
     SetDotDefault(&as->parms[0].items);
     for (ti = as->parms[0].items; ti; ti = ti->next) {
        /* once per file */
-       blob.out_size = MAXSIZE;
+       blob.out_size = AFS_PIOCTL_MAXSIZE;
        blob.in_size = sizeof(*status) + 3;     /* for the three terminating nulls */
        blob.out = space;
        blob.in = space;
@@ -1320,7 +1496,7 @@ SetVolCmd(struct cmd_syndesc *as, char *arock)
        status->MinQuota = status->MaxQuota = -1;
        offmsg = NULL;
        if (as->parms[1].items) {
-           code = util_GetInt32(as->parms[1].items->data, &status->MaxQuota);
+           code = util_GetHumanInt32(as->parms[1].items->data, &status->MaxQuota);
            if (code) {
                fprintf(stderr, "%s: bad integer specified for quota.\n", pn);
                error = 1;
@@ -1364,7 +1540,7 @@ struct VenusFid {
 };
 
 static int
-ExamineCmd(struct cmd_syndesc *as, char *arock)
+ExamineCmd(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 code;
     struct ViceIoctl blob;
@@ -1378,7 +1554,7 @@ ExamineCmd(struct cmd_syndesc *as, char *arock)
        struct VenusFid vfid;
 
        /* once per file */
-       blob.out_size = MAXSIZE;
+       blob.out_size = AFS_PIOCTL_MAXSIZE;
        blob.in_size = 0;
        blob.out = space;
        code = pioctl(ti->data, VIOCGETVOLSTAT, &blob, 1);
@@ -1405,7 +1581,7 @@ ExamineCmd(struct cmd_syndesc *as, char *arock)
 }
 
 static int
-ListQuotaCmd(struct cmd_syndesc *as, char *arock)
+ListQuotaCmd(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 code;
     struct ViceIoctl blob;
@@ -1413,13 +1589,17 @@ ListQuotaCmd(struct cmd_syndesc *as, char *arock)
     struct VolumeStatus *status;
     char *name;
     int error = 0;
+    int human = 0;
+
+    if (as->parms[1].items)
+       human = 1;
 
-    printf("%-25s%-10s%-10s%-7s%-11s\n", "Volume Name", "     Quota",
-          "      Used", " %Used", "  Partition");
+    printf("%-25s%-11s%-11s%-7s%-11s\n", "Volume Name", "      Quota",
+          "       Used", " %Used", "  Partition");
     SetDotDefault(&as->parms[0].items);
     for (ti = as->parms[0].items; ti; ti = ti->next) {
        /* once per file */
-       blob.out_size = MAXSIZE;
+       blob.out_size = AFS_PIOCTL_MAXSIZE;
        blob.in_size = 0;
        blob.out = space;
        code = pioctl(ti->data, VIOCGETVOLSTAT, &blob, 1);
@@ -1430,13 +1610,13 @@ ListQuotaCmd(struct cmd_syndesc *as, char *arock)
        }
        status = (VolumeStatus *) space;
        name = (char *)status + sizeof(*status);
-       QuickPrintStatus(status, name);
+       QuickPrintStatus(status, name, human);
     }
     return error;
 }
 
 static int
-WhereIsCmd(struct cmd_syndesc *as, char *arock)
+WhereIsCmd(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 code;
     struct ViceIoctl blob;
@@ -1449,7 +1629,7 @@ WhereIsCmd(struct cmd_syndesc *as, char *arock)
     SetDotDefault(&as->parms[0].items);
     for (ti = as->parms[0].items; ti; ti = ti->next) {
        /* once per file */
-       blob.out_size = MAXSIZE;
+       blob.out_size = AFS_PIOCTL_MAXSIZE;
        blob.in_size = 0;
        blob.out = space;
        memset(space, 0, sizeof(space));
@@ -1462,7 +1642,7 @@ WhereIsCmd(struct cmd_syndesc *as, char *arock)
        hosts = (afs_int32 *) space;
        printf("File %s is on host%s ", ti->data,
               (hosts[0] && !hosts[1]) ? "" : "s");
-       for (j = 0; j < MAXHOSTS; j++) {
+       for (j = 0; j < AFS_MAXHOSTS; j++) {
            if (hosts[j] == 0)
                break;
            tp = hostutil_GetNameByINet(hosts[j]);
@@ -1475,7 +1655,7 @@ WhereIsCmd(struct cmd_syndesc *as, char *arock)
 
 
 static int
-DiskFreeCmd(struct cmd_syndesc *as, char *arock)
+DiskFreeCmd(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 code;
     struct ViceIoctl blob;
@@ -1483,13 +1663,17 @@ DiskFreeCmd(struct cmd_syndesc *as, char *arock)
     char *name;
     struct VolumeStatus *status;
     int error = 0;
+    int human = 0;
 
-    printf("%-25s%-10s%-10s%-10s%-6s\n", "Volume Name", "    kbytes",
-          "      used", "     avail", " %used");
+    if (as->parms[1].items)
+       human = 1;
+
+    printf("%-25s%10s%10s%10s%6s\n", "Volume Name",
+          human ? "total" : "kbytes", "used", "avail", "%used");
     SetDotDefault(&as->parms[0].items);
     for (ti = as->parms[0].items; ti; ti = ti->next) {
        /* once per file */
-       blob.out_size = MAXSIZE;
+       blob.out_size = AFS_PIOCTL_MAXSIZE;
        blob.in_size = 0;
        blob.out = space;
        code = pioctl(ti->data, VIOCGETVOLSTAT, &blob, 1);
@@ -1500,13 +1684,13 @@ DiskFreeCmd(struct cmd_syndesc *as, char *arock)
        }
        status = (VolumeStatus *) space;
        name = (char *)status + sizeof(*status);
-       QuickPrintSpace(status, name);
+       QuickPrintSpace(status, name, human);
     }
     return error;
 }
 
 static int
-QuotaCmd(struct cmd_syndesc *as, char *arock)
+QuotaCmd(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 code;
     struct ViceIoctl blob;
@@ -1518,7 +1702,7 @@ QuotaCmd(struct cmd_syndesc *as, char *arock)
     SetDotDefault(&as->parms[0].items);
     for (ti = as->parms[0].items; ti; ti = ti->next) {
        /* once per file */
-       blob.out_size = MAXSIZE;
+       blob.out_size = AFS_PIOCTL_MAXSIZE;
        blob.in_size = 0;
        blob.out = space;
        code = pioctl(ti->data, VIOCGETVOLSTAT, &blob, 1);
@@ -1539,109 +1723,138 @@ QuotaCmd(struct cmd_syndesc *as, char *arock)
 }
 
 static int
-ListMountCmd(struct cmd_syndesc *as, char *arock)
+GetLastComponent(const char *data, char **outdir, char **outbase,
+                int *thru_symlink)
 {
-    afs_int32 code;
-    struct ViceIoctl blob;
-    struct cmd_item *ti;
-    char orig_name[1024];      /*Original name, may be modified */
-    char true_name[1024];      /*``True'' dirname (e.g., symlink target) */
-    char parent_dir[1024];     /*Parent directory of true name */
-    char *last_component;      /*Last component of true name */
+    char orig_name[MAXPATHLEN];        /*Original name, may be modified */
+    char true_name[MAXPATHLEN];        /*``True'' dirname (e.g., symlink target) */
+    char *lastSlash;
     struct stat statbuff;      /*Buffer for status info */
     int link_chars_read;       /*Num chars read in readlink() */
-    int thru_symlink;          /*Did we get to a mount point via a symlink? */
-    int error = 0;
+    char *dirname = NULL;
+    char *basename = NULL;
 
-    for (ti = as->parms[0].items; ti; ti = ti->next) {
-       /* once per file */
-       thru_symlink = 0;
-       sprintf(orig_name, "%s%s", (ti->data[0] == '/') ? "" : "./",
-               ti->data);
+    *outbase = NULL;
+    *outdir = NULL;
+
+    if (thru_symlink)
+       *thru_symlink = 0;
 
-       if (lstat(orig_name, &statbuff) < 0) {
-           /* if lstat fails, we should still try the pioctl, since it
-            * may work (for example, lstat will fail, but pioctl will
-            * work if the volume of offline (returning ENODEV). */
-           statbuff.st_mode = S_IFDIR; /* lie like pros */
+    snprintf(orig_name, sizeof(orig_name), "%s%s",
+            (data[0] == '/') ? "" : "./", data);
+
+    if (lstat(orig_name, &statbuff) < 0) {
+       /* if lstat fails, we should still try the pioctl, since it
+        * may work (for example, lstat will fail, but pioctl will
+        * work if the volume of offline (returning ENODEV). */
+       statbuff.st_mode = S_IFDIR;     /* lie like pros */
+    }
+
+    /*
+     * The lstat succeeded.  If the given file is a symlink, substitute
+     * the file name with the link name.
+     */
+    if ((statbuff.st_mode & S_IFMT) == S_IFLNK) {
+       if (thru_symlink)
+            *thru_symlink = 1;
+
+       /* Read name of resolved file (leave space for NULL!) */
+       link_chars_read = readlink(orig_name, true_name, MAXPATHLEN-1);
+       if (link_chars_read <= 0) {
+           fprintf(stderr,
+                   "%s: Can't read target name for '%s' symbolic link!\n",
+                   pn, orig_name);
+           goto out;
        }
 
+       /* Add a trailing null to what was read, bump the length. */
+       true_name[link_chars_read++] = 0;
+
        /*
-        * The lstat succeeded.  If the given file is a symlink, substitute
-        * the file name with the link name.
+        * If the symlink is an absolute pathname, we're fine.  Otherwise, we
+        * have to create a full pathname using the original name and the
+        * relative symlink name.  Find the rightmost slash in the original
+        * name (we know there is one) and splice in the symlink value.
         */
-       if ((statbuff.st_mode & S_IFMT) == S_IFLNK) {
-           thru_symlink = 1;
-           /*
-            * Read name of resolved file.
-            */
-           link_chars_read = readlink(orig_name, true_name, 1024);
-           if (link_chars_read <= 0) {
-               fprintf(stderr,
-                       "%s: Can't read target name for '%s' symbolic link!\n",
-                       pn, orig_name);
-               error = 1;
-               continue;
-           }
-
-           /*
-            * Add a trailing null to what was read, bump the length.
-            */
-           true_name[link_chars_read++] = 0;
-
-           /*
-            * If the symlink is an absolute pathname, we're fine.  Otherwise, we
-            * have to create a full pathname using the original name and the
-            * relative symlink name.  Find the rightmost slash in the original
-            * name (we know there is one) and splice in the symlink value.
-            */
-           if (true_name[0] != '/') {
-               last_component = (char *)strrchr(orig_name, '/');
-               strcpy(++last_component, true_name);
-               strcpy(true_name, orig_name);
-           }
-       } else
+       if (true_name[0] != '/') {
+           lastSlash = strrchr(orig_name, '/');
+           strcpy(++lastSlash, true_name);
            strcpy(true_name, orig_name);
-
+       }
+     } else {
+       strcpy(true_name, orig_name);
+     }
+
+    /* Find rightmost slash, if any. */
+    lastSlash = strrchr(true_name, '/');
+    if (lastSlash == true_name) {
+       dirname = strdup("/");
+       basename = strdup(lastSlash+1);
+    } else if (lastSlash != NULL) {
        /*
-        * Find rightmost slash, if any.
+        * Found it.  Designate everything before it as the parent directory,
+        * everything after it as the final component.
         */
-       last_component = (char *)strrchr(true_name, '/');
-       if (last_component) {
-           /*
-            * Found it.  Designate everything before it as the parent directory,
-            * everything after it as the final component.
-            */
-           strncpy(parent_dir, true_name, last_component - true_name);
-           parent_dir[last_component - true_name] = 0;
-           last_component++;   /*Skip the slash */
-       } else {
-           /*
-            * No slash appears in the given file name.  Set parent_dir to the current
-            * directory, and the last component as the given name.
-            */
-           strcpy(parent_dir, ".");
-           last_component = true_name;
-       }
+       *lastSlash = '\0';
+       dirname = strdup(true_name);
+       basename = strdup(lastSlash+1);
+    } else {
+       /*
+        * No slash appears in the given file name.  Set parent_dir to the current
+        * directory, and the last component as the given name.
+        */
+       dirname = strdup(".");
+       basename = strdup(true_name);
+    }
 
-       if (strcmp(last_component, ".") == 0
-           || strcmp(last_component, "..") == 0) {
-           fprintf(stderr,
-                   "%s: you may not use '.' or '..' as the last component\n",
-                   pn);
-           fprintf(stderr, "%s: of a name in the 'fs lsmount' command.\n",
-                   pn);
+    if (strcmp(basename, ".") == 0
+       || strcmp(basename, "..") == 0) {
+       fprintf(stderr,
+               "%s: you may not use '.' or '..' as the last component\n", pn);
+       fprintf(stderr, "%s: of a name in this fs command.\n", pn);
+       goto out;
+    }
+
+    *outdir = dirname;
+    *outbase = basename;
+
+    return 0;
+
+out:
+    if (dirname)
+       free(dirname);
+    if (basename)
+       free(basename);
+    return -1;
+}
+
+
+static int
+ListMountCmd(struct cmd_syndesc *as, void *arock)
+{
+    afs_int32 code;
+    struct ViceIoctl blob;
+    struct cmd_item *ti;
+    char *last_component;
+    char *parent_dir;
+    int thru_symlink = 0;
+    int error = 0;
+
+    for (ti = as->parms[0].items; ti; ti = ti->next) {
+       if (GetLastComponent(ti->data, &parent_dir,
+                            &last_component, &thru_symlink) != 0) {
            error = 1;
            continue;
        }
 
        blob.in = last_component;
        blob.in_size = strlen(last_component) + 1;
-       blob.out_size = MAXSIZE;
+       blob.out_size = AFS_PIOCTL_MAXSIZE;
        blob.out = space;
-       memset(space, 0, MAXSIZE);
+       memset(space, 0, AFS_PIOCTL_MAXSIZE);
 
        code = pioctl(parent_dir, VIOC_AFS_STAT_MT_PT, &blob, 1);
+       free(last_component);
 
        if (code == 0) {
            printf("'%s' is a %smount point for volume '%s'\n", ti->data,
@@ -1655,18 +1868,20 @@ ListMountCmd(struct cmd_syndesc *as, char *arock)
            }
            error = 1;
        }
+       free(parent_dir);
     }
     return error;
 }
 
-static
-MakeMountCmd(struct cmd_syndesc *as, char *arock)
+static int
+MakeMountCmd(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 code;
     char *cellName, *volName, *tmpName;
     struct afsconf_cell info;
     struct vldbentry vldbEntry;
     struct ViceIoctl blob;
+    struct afsconf_dir *dir;
 
 /*
 
@@ -1693,7 +1908,7 @@ defect #3069
 
     /* Check for a cellname in the volume specification, and complain
      * if it doesn't match what was specified with -cell */
-    if (tmpName = strchr(volName, ':')) {
+    if ((tmpName = strchr(volName, ':'))) {
        *tmpName = '\0';
        if (cellName) {
            if (strcasecmp(cellName, volName)) {
@@ -1714,21 +1929,42 @@ defect #3069
 
     if (!cellName) {
        blob.in_size = 0;
-       blob.out_size = MAXSIZE;
+       blob.out_size = AFS_PIOCTL_MAXSIZE;
        blob.out = space;
-       code =
-           pioctl(Parent(as->parms[0].items->data), VIOC_FILE_CELL_NAME,
-                  &blob, 1);
+       code = pioctl(Parent(as->parms[0].items->data), VIOC_FILE_CELL_NAME,
+                     &blob, 1);
+       if (code) {
+          fprintf(stderr,
+                  "%s: couldn't get cell name for file's parent\n", pn);
+          return 1;
+       }
     }
 
-    code = GetCellName(cellName ? cellName : space, &info);
+    dir = afsconf_Open(AFSDIR_CLIENT_ETC_DIRPATH);
+    if (!dir) {
+       fprintf(stderr,
+               "Could not process files in configuration directory (%s).\n",
+               AFSDIR_CLIENT_ETC_DIRPATH);
+        return 1;
+    }
+
+    code = afsconf_GetCellInfo(dir, cellName ? cellName : space,
+                              AFSCONF_VLDBSERVICE, &info);
     if (code) {
+       fprintf(stderr,
+               "%s: cell %s not in %s\n", pn, cellName ? cellName : space,
+               AFSDIR_CLIENT_CELLSERVDB_FILEPATH);
        return 1;
     }
+
     if (!(as->parms[4].items)) {
        /* not fast, check which cell the mountpoint is being created in */
-       /* not fast, check name with VLDB */
-       code = VLDBInit(1, &info);
+       code = ugen_ClientInitCell(dir, &info,
+                                  AFSCONF_SECOPTS_FALLBACK_NULL |
+                                  AFSCONF_SECOPTS_NOAUTH,
+                                  &uclient, VLDB_MAXSERVERS,
+                                  AFSCONF_VLDBSERVICE, 50);
+
        if (code == 0) {
            /* make the check.  Don't complain if there are problems with init */
            code =
@@ -1768,7 +2004,7 @@ defect #3069
  *      tp: Set to point to the actual name of the mount point to nuke.
  */
 static int
-RemoveMountCmd(struct cmd_syndesc *as, char *arock)
+RemoveMountCmd(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 code = 0;
     struct ViceIoctl blob;
@@ -1793,7 +2029,7 @@ RemoveMountCmd(struct cmd_syndesc *as, char *arock)
        blob.in_size = strlen(tp) + 1;
        blob.out = lsbuffer;
        blob.out_size = sizeof(lsbuffer);
-       code = pioctl(tbuffer, VIOC_AFS_STAT_MT_PT, &blob, 0);
+       code = pioctl(tbuffer, VIOC_AFS_STAT_MT_PT, &blob, 1);
        if (code) {
            if (errno == EINVAL) {
                fprintf(stderr, "%s: '%s' is not a mount point.\n", pn,
@@ -1807,7 +2043,7 @@ RemoveMountCmd(struct cmd_syndesc *as, char *arock)
        blob.out_size = 0;
        blob.in = tp;
        blob.in_size = strlen(tp) + 1;
-       code = pioctl(tbuffer, VIOC_AFS_DELETE_MT_PT, &blob, 0);
+       code = pioctl(tbuffer, VIOC_AFS_DELETE_MT_PT, &blob, 1);
        if (code) {
            Die(errno, ti->data);
            error = 1;
@@ -1820,15 +2056,13 @@ RemoveMountCmd(struct cmd_syndesc *as, char *arock)
 */
 
 static int
-CheckServersCmd(struct cmd_syndesc *as, char *arock)
+CheckServersCmd(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 code;
     struct ViceIoctl blob;
     afs_int32 j;
     afs_int32 temp;
     char *tp;
-    char tbuffer[128];
-    afs_int32 interval;
     struct afsconf_cell info;
     struct chservinfo checkserv;
 
@@ -1836,7 +2070,7 @@ CheckServersCmd(struct cmd_syndesc *as, char *arock)
     blob.in_size = sizeof(struct chservinfo);
     blob.in = (caddr_t) & checkserv;
 
-    blob.out_size = MAXSIZE;
+    blob.out_size = AFS_PIOCTL_MAXSIZE;
     blob.out = space;
     memset(space, 0, sizeof(afs_int32));       /* so we assure zero when nothing is copied back */
 
@@ -1919,23 +2153,21 @@ CheckServersCmd(struct cmd_syndesc *as, char *arock)
 }
 
 static int
-MessagesCmd(struct cmd_syndesc *as, char *arock)
+MessagesCmd(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 code = 0;
     struct ViceIoctl blob;
-    afs_int32 j;
-    afs_int32 temp;
     struct gaginfo gagflags;
     struct cmd_item *show;
 
     memset(&gagflags, 0, sizeof(struct gaginfo));
     blob.in_size = sizeof(struct gaginfo);
     blob.in = (caddr_t) & gagflags;
-    blob.out_size = MAXSIZE;
+    blob.out_size = AFS_PIOCTL_MAXSIZE;
     blob.out = space;
     memset(space, 0, sizeof(afs_int32));       /* so we assure zero when nothing is copied back */
 
-    if (show = as->parms[0].items) {
+    if ((show = as->parms[0].items)) {
        if (!strcasecmp(show->data, "user"))
            gagflags.showflags |= GAGUSER;
        else if (!strcasecmp(show->data, "console"))
@@ -1965,7 +2197,7 @@ MessagesCmd(struct cmd_syndesc *as, char *arock)
 }
 
 static int
-CheckVolumesCmd(struct cmd_syndesc *as, char *arock)
+CheckVolumesCmd(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 code;
     struct ViceIoctl blob;
@@ -1983,19 +2215,52 @@ CheckVolumesCmd(struct cmd_syndesc *as, char *arock)
 }
 
 static int
-SetCacheSizeCmd(struct cmd_syndesc *as, char *arock)
+PreCacheCmd(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 code;
     struct ViceIoctl blob;
     afs_int32 temp;
 
     if (!as->parms[0].items && !as->parms[1].items) {
-       fprintf(stderr, "%s: syntax error in setcachesize cmd.\n", pn);
+       fprintf(stderr, "%s: syntax error in precache cmd.\n", pn);
        return 1;
     }
     if (as->parms[0].items) {
        code = util_GetInt32(as->parms[0].items->data, &temp);
        if (code) {
+           fprintf(stderr, "%s: bad integer specified for precache size.\n",
+                   pn);
+           return 1;
+       }
+    } else
+       temp = 0;
+    blob.in = (char *)&temp;
+    blob.in_size = sizeof(afs_int32);
+    blob.out_size = 0;
+    code = pioctl(0, VIOCPRECACHE, &blob, 1);
+    if (code) {
+       Die(errno, NULL);
+       return 1;
+    }
+
+    printf("New precache size set.\n");
+    return 0;
+}
+
+static int
+SetCacheSizeCmd(struct cmd_syndesc *as, void *arock)
+{
+    afs_int32 code;
+    struct ViceIoctl blob;
+    afs_int32 temp;
+
+    if (!as->parms[0].items && !as->parms[1].items) {
+       fprintf(stderr, "%s: syntax error in setcachesize cmd.\n", pn);
+       return 1;
+    }
+    if (as->parms[0].items) {
+       code = util_GetHumanInt32(as->parms[0].items->data, &temp);
+       if (code) {
            fprintf(stderr, "%s: bad integer specified for cache size.\n",
                    pn);
            return 1;
@@ -2022,7 +2287,7 @@ SetCacheSizeCmd(struct cmd_syndesc *as, char *arock)
 
 #define MAXGCSIZE      16
 static int
-GetCacheParmsCmd(struct cmd_syndesc *as, char *arock)
+GetCacheParmsCmd(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 code, filesUsed;
     struct ViceIoctl blob;
@@ -2075,36 +2340,35 @@ GetCacheParmsCmd(struct cmd_syndesc *as, char *arock)
            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("        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("        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]); 
+       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");
+       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");
-        
+       printf("[cache file usage over 90%%, consider increasing '-files' argument to afsd]\n");
+
     return 0;
 }
 
 static int
-ListCellsCmd(struct cmd_syndesc *as, char *arock)
+ListCellsCmd(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 code;
     afs_int32 i, j;
-    char *tcp, *tp;
-    afs_int32 clear;
+    char *tp;
     struct ViceIoctl blob;
     int resolve;
 
@@ -2113,7 +2377,7 @@ ListCellsCmd(struct cmd_syndesc *as, char *arock)
     for (i = 0;; i++) {
        tp = space;
        memcpy(tp, &i, sizeof(afs_int32));
-       blob.out_size = MAXSIZE;
+       blob.out_size = AFS_PIOCTL_MAXSIZE;
        blob.in_size = sizeof(afs_int32);
        blob.in = space;
        blob.out = space;
@@ -2125,8 +2389,8 @@ ListCellsCmd(struct cmd_syndesc *as, char *arock)
            return 1;
        }
        tp = space;
-       printf("Cell %s on hosts", tp + MAXCELLHOSTS * sizeof(afs_int32));
-       for (j = 0; j < MAXCELLHOSTS; j++) {
+       printf("Cell %s on hosts", tp + AFS_MAXCELLHOSTS * sizeof(afs_int32));
+       for (j = 0; j < AFS_MAXCELLHOSTS; j++) {
            afs_int32 addr;
            char *name, tbuffer[20];
 
@@ -2150,7 +2414,7 @@ ListCellsCmd(struct cmd_syndesc *as, char *arock)
 }
 
 static int
-ListAliasesCmd(struct cmd_syndesc *as, char *arock)
+ListAliasesCmd(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 code, i;
     char *tp, *aliasName, *realName;
@@ -2159,7 +2423,7 @@ ListAliasesCmd(struct cmd_syndesc *as, char *arock)
     for (i = 0;; i++) {
        tp = space;
        memcpy(tp, &i, sizeof(afs_int32));
-       blob.out_size = MAXSIZE;
+       blob.out_size = AFS_PIOCTL_MAXSIZE;
        blob.in_size = sizeof(afs_int32);
        blob.in = space;
        blob.out = space;
@@ -2180,18 +2444,15 @@ ListAliasesCmd(struct cmd_syndesc *as, char *arock)
 }
 
 static int
-CallBackRxConnCmd(struct cmd_syndesc *as, char *arock)
+CallBackRxConnCmd(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 code;
     struct ViceIoctl blob;
     struct cmd_item *ti;
     afs_int32 hostAddr;
     struct hostent *thp;
-    char *tp;
-    int setp;
-    
+
     ti = as->parms[0].items;
-    setp = 1;
     if (ti) {
         thp = hostutil_GetHostByName(ti->data);
        if (!thp) {
@@ -2201,15 +2462,14 @@ CallBackRxConnCmd(struct cmd_syndesc *as, char *arock)
        else memcpy(&hostAddr, thp->h_addr, sizeof(afs_int32));
     } else {
         hostAddr = 0;   /* means don't set host */
-       setp = 0;       /* aren't setting host */
     }
-    
+
     /* 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_CBADDR, &blob, 1);
     if (code < 0) {
        Die(errno, 0);
@@ -2219,14 +2479,14 @@ CallBackRxConnCmd(struct cmd_syndesc *as, char *arock)
 }
 
 static int
-NukeNFSCredsCmd(struct cmd_syndesc *as, char *arock)
+NukeNFSCredsCmd(struct cmd_syndesc *as, void *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) {
@@ -2234,13 +2494,13 @@ NukeNFSCredsCmd(struct cmd_syndesc *as, char *arock)
        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);
@@ -2250,7 +2510,7 @@ NukeNFSCredsCmd(struct cmd_syndesc *as, char *arock)
 }
 
 static int
-NewCellCmd(struct cmd_syndesc *as, char *arock)
+NewCellCmd(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 code, linkedstate = 0, size = 0, *lp;
     struct ViceIoctl blob;
@@ -2258,12 +2518,12 @@ NewCellCmd(struct cmd_syndesc *as, char *arock)
     char *tp, *cellname = 0;
     struct hostent *thp;
     afs_int32 fsport = 0, vlport = 0;
-    afs_int32 magic, scount;   /* Number of servers to pass in pioctl call */
+    afs_int32 scount;          /* Number of servers to pass in pioctl call */
 
     /* Yuck!
      * With the NEWCELL pioctl call, 3.4 clients take an array of
-     * MAXHOSTS (13) servers while 3.5 clients take an array of
-     * MAXCELLHOSTS (8) servers. To determine which we are talking to,
+     * AFS_MAXHOSTS (13) servers while 3.5 clients take an array of
+     * AFS_MAXCELLHOSTS (8) servers. To determine which we are talking to,
      * do a GETCELL pioctl and pass it a magic number. If an array of
      * 8 comes back, its a 3.5 client. If not, its a 3.4 client.
      * If we get back EDOM, there are no cells in the kernel yet,
@@ -2273,7 +2533,7 @@ NewCellCmd(struct cmd_syndesc *as, char *arock)
     lp = (afs_int32 *) tp;
     *lp++ = 0;                 /* first cell entry */
     *lp = 0x12345678;          /* magic */
-    blob.out_size = MAXSIZE;
+    blob.out_size = AFS_PIOCTL_MAXSIZE;
     blob.in_size = sizeof(afs_int32) + sizeof(afs_int32);
     blob.in = space;
     blob.out = space;
@@ -2283,11 +2543,11 @@ NewCellCmd(struct cmd_syndesc *as, char *arock)
        return 1;
     }
     if (code < 1 && errno == EDOM) {
-       scount = MAXHOSTS;
+       scount = AFS_MAXHOSTS;
     } else {
        tp = space;
-       cellname = tp + MAXCELLHOSTS * sizeof(afs_int32);
-       scount = ((cellname[0] != '\0') ? MAXCELLHOSTS : MAXHOSTS);
+       cellname = tp + AFS_MAXCELLHOSTS * sizeof(afs_int32);
+       scount = ((cellname[0] != '\0') ? AFS_MAXCELLHOSTS : AFS_MAXHOSTS);
     }
 
     /* Now setup and do the NEWCELL pioctl call */
@@ -2362,7 +2622,7 @@ NewCellCmd(struct cmd_syndesc *as, char *arock)
 }
 
 static int
-NewAliasCmd(struct cmd_syndesc *as, char *arock)
+NewAliasCmd(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 code;
     struct ViceIoctl blob;
@@ -2397,7 +2657,7 @@ NewAliasCmd(struct cmd_syndesc *as, char *arock)
 }
 
 static int
-WhichCellCmd(struct cmd_syndesc *as, char *arock)
+WhichCellCmd(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 code;
     struct cmd_item *ti;
@@ -2422,14 +2682,14 @@ WhichCellCmd(struct cmd_syndesc *as, char *arock)
 }
 
 static int
-WSCellCmd(struct cmd_syndesc *as, char *arock)
+WSCellCmd(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 code;
     struct ViceIoctl blob;
 
     blob.in_size = 0;
     blob.in = NULL;
-    blob.out_size = MAXSIZE;
+    blob.out_size = AFS_PIOCTL_MAXSIZE;
     blob.out = space;
 
     code = pioctl(NULL, VIOC_GET_WS_CELL, &blob, 1);
@@ -2452,7 +2712,7 @@ static PrimaryCellCmd(as)
 */
 
 static int
-MonitorCmd(struct cmd_syndesc *as, char *arock)
+MonitorCmd(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 code;
     struct ViceIoctl blob;
@@ -2513,7 +2773,7 @@ MonitorCmd(struct cmd_syndesc *as, char *arock)
 }
 
 static int
-SysNameCmd(struct cmd_syndesc *as, char *arock)
+SysNameCmd(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 code;
     struct ViceIoctl blob;
@@ -2524,13 +2784,13 @@ SysNameCmd(struct cmd_syndesc *as, char *arock)
     ti = as->parms[0].items;
     blob.in = space;
     blob.out = space;
-    blob.out_size = MAXSIZE;
+    blob.out_size = AFS_PIOCTL_MAXSIZE;
     blob.in_size = sizeof(afs_int32);
     input += sizeof(afs_int32);
     for (; ti; ti = ti->next) {
        setp++;
        blob.in_size += strlen(ti->data) + 1;
-       if (blob.in_size > MAXSIZE) {
+       if (blob.in_size > AFS_PIOCTL_MAXSIZE) {
            fprintf(stderr, "%s: sysname%s too long.\n", pn,
                    setp > 1 ? "s" : "");
            return 1;
@@ -2567,12 +2827,12 @@ SysNameCmd(struct cmd_syndesc *as, char *arock)
 
 static char *exported_types[] = { "null", "nfs", "" };
 static int
-ExportAfsCmd(struct cmd_syndesc *as, char *arock)
+ExportAfsCmd(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 code;
     struct ViceIoctl blob;
     struct cmd_item *ti;
-    int export = 0, type = 0, mode = 0, exp = 0, exportcall, pwsync =
+    int export = 0, type = 0, mode = 0, exportcall, pwsync =
        0, smounts = 0, clipags = 0, pagcb = 0;
 
     ti = as->parms[0].items;
@@ -2594,9 +2854,8 @@ ExportAfsCmd(struct cmd_syndesc *as, char *arock)
            fprintf(stderr, "Illegal argument %s\n", ti->data);
            return 1;
        }
-       exp = 1;
     }
-    if (ti = as->parms[2].items) {     /* -noconvert */
+    if ((ti = as->parms[2].items)) {   /* -noconvert */
        if (strcmp(ti->data, "on") == 0)
            mode = 2;
        else if (strcmp(ti->data, "off") == 0)
@@ -2606,7 +2865,7 @@ ExportAfsCmd(struct cmd_syndesc *as, char *arock)
            return 1;
        }
     }
-    if (ti = as->parms[3].items) {     /* -uidcheck */
+    if ((ti = as->parms[3].items)) {   /* -uidcheck */
        if (strcmp(ti->data, "on") == 0)
            pwsync = 3;
        else if (strcmp(ti->data, "off") == 0)
@@ -2616,7 +2875,7 @@ ExportAfsCmd(struct cmd_syndesc *as, char *arock)
            return 1;
        }
     }
-    if (ti = as->parms[4].items) {     /* -submounts */
+    if ((ti = as->parms[4].items)) {   /* -submounts */
        if (strcmp(ti->data, "on") == 0)
            smounts = 3;
        else if (strcmp(ti->data, "off") == 0)
@@ -2626,7 +2885,7 @@ ExportAfsCmd(struct cmd_syndesc *as, char *arock)
            return 1;
        }
     }
-    if (ti = as->parms[5].items) {     /* -clipags */
+    if ((ti = as->parms[5].items)) {   /* -clipags */
        if (strcmp(ti->data, "on") == 0)
            clipags = 3;
        else if (strcmp(ti->data, "off") == 0)
@@ -2636,7 +2895,7 @@ ExportAfsCmd(struct cmd_syndesc *as, char *arock)
            return 1;
        }
     }
-    if (ti = as->parms[6].items) {     /* -pagcb */
+    if ((ti = as->parms[6].items)) {   /* -pagcb */
        if (strcmp(ti->data, "on") == 0)
            pagcb = 3;
        else if (strcmp(ti->data, "off") == 0)
@@ -2694,7 +2953,7 @@ ExportAfsCmd(struct cmd_syndesc *as, char *arock)
 
 
 static int
-GetCellCmd(struct cmd_syndesc *as, char *arock)
+GetCellCmd(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 code;
     struct ViceIoctl blob;
@@ -2745,7 +3004,7 @@ GetCellCmd(struct cmd_syndesc *as, char *arock)
 }
 
 static int
-SetCellCmd(struct cmd_syndesc *as, char *arock)
+SetCellCmd(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 code;
     struct ViceIoctl blob;
@@ -2817,25 +3076,10 @@ GetCellName(char *cellName, struct afsconf_cell *info)
     return 0;
 }
 
-
-static int
-VLDBInit(int noAuthFlag, struct afsconf_cell *info)
-{
-    afs_int32 code;
-
-    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;
 static int debug = 0;
 /*
- * here follow some routines in suport of the setserverprefs and
+ * here follow some routines in support of the setserverprefs and
  * getserverprefs commands.  They are:
  * SetPrefCmd  "top-level" routine
  * addServer   adds a server to the list of servers to be poked into the
@@ -2885,7 +3129,6 @@ addServer(char *name, afs_int32 rank)
     struct setspref *ssp;
     struct spref *sp;
     struct hostent *thostent;
-    afs_uint32 addr;
     int error = 0;
 
 #ifndef MAXUSHORT
@@ -2921,7 +3164,7 @@ addServer(char *name, afs_int32 rank)
 
        if (debug)
            fprintf(stderr, "adding server %s, rank %d, ip addr 0x%lx\n",
-                   name, sp->rank, sp->server.s_addr);
+                   name, sp->rank, (long unsigned int) sp->server.s_addr);
     }
 
     return error;
@@ -2929,13 +3172,13 @@ addServer(char *name, afs_int32 rank)
 
 
 static int
-SetPrefCmd(struct cmd_syndesc *as, char *arock)
+SetPrefCmd(struct cmd_syndesc *as, void *arock)
 {
     FILE *infd;
     afs_int32 code;
     struct cmd_item *ti;
     char name[80];
-    afs_int32 rank;
+    int rank;
     struct setspref *ssp;
     int error = 0;             /* -1 means error message printed,
                                 * >0 means errno value for unprinted message */
@@ -2946,7 +3189,7 @@ SetPrefCmd(struct cmd_syndesc *as, char *arock)
     gblob.in_size = ((char *)&(ssp->servers[0])) - (char *)ssp;
     gblob.in = space;
     gblob.out = space;
-    gblob.out_size = MAXSIZE;
+    gblob.out_size = AFS_PIOCTL_MAXSIZE;
 
 
     if (geteuid()) {
@@ -2962,7 +3205,7 @@ SetPrefCmd(struct cmd_syndesc *as, char *arock)
            perror(ti->data);
            error = -1;
        } else {
-           while (fscanf(infd, "%79s%ld", name, &rank) != EOF) {
+           while (fscanf(infd, "%79s%d", name, &rank) != EOF) {
                code = addServer(name, (unsigned short)rank);
                if (code)
                    error = code;
@@ -2972,7 +3215,7 @@ SetPrefCmd(struct cmd_syndesc *as, char *arock)
 
     ti = as->parms[3].items;   /* -stdin */
     if (ti) {
-       while (scanf("%79s%ld", name, &rank) != EOF) {
+       while (scanf("%79s%d", name, &rank) != EOF) {
            code = addServer(name, (unsigned short)rank);
            if (code)
                error = code;
@@ -3035,12 +3278,12 @@ SetPrefCmd(struct cmd_syndesc *as, char *arock)
 
 
 static int
-GetPrefCmd(struct cmd_syndesc *as, char *arock)
+GetPrefCmd(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 code;
     struct cmd_item *ti;
     char *name, tbuffer[20];
-    afs_int32 rank, addr;
+    afs_int32 addr;
     FILE *outfd;
     int resolve;
     int vlservers = 0;
@@ -3072,17 +3315,26 @@ GetPrefCmd(struct cmd_syndesc *as, char *arock)
        blob.in_size = sizeof(struct sprefrequest);
        blob.in = (char *)in;
        blob.out = space;
-       blob.out_size = MAXSIZE;
+       blob.out_size = AFS_PIOCTL_MAXSIZE;
 
        in->num_servers =
-           (MAXSIZE - 2 * sizeof(short)) / sizeof(struct spref);
+           (AFS_PIOCTL_MAXSIZE - 2 * sizeof(short)) / sizeof(struct spref);
        in->flags = vlservers;
 
-       code = pioctl(0, VIOC_GETSPREFS, &blob, 1);
-       if (code) {
-           perror("getserverprefs pioctl");
-           return 1;
-       }
+       do {
+           code = pioctl(0, VIOC_GETSPREFS, &blob, 1);
+           if (code) {
+               if ((errno != E2BIG) || (2 * blob.out_size > 0x7FFF)) {
+                   perror("getserverprefs pioctl");
+                   return 1;
+               }
+               blob.out_size *= 2;
+               if (blob.out == space)
+                   blob.out = malloc(blob.out_size);
+               else
+                   blob.out = realloc(blob.out, blob.out_size);
+           }
+       } while (code != 0);
 
        out = (struct sprefinfo *)blob.out;
 
@@ -3101,11 +3353,14 @@ GetPrefCmd(struct cmd_syndesc *as, char *arock)
        in->offset = out->next_offset;
     } while (out->next_offset > 0);
 
+    if (blob.out != space)
+       free(blob.out);
+
     return 0;
 }
 
 static int
-StoreBehindCmd(struct cmd_syndesc *as, char *arock)
+StoreBehindCmd(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 code = 0;
     struct ViceIoctl blob;
@@ -3115,6 +3370,7 @@ StoreBehindCmd(struct cmd_syndesc *as, char *arock)
     afs_int32 allfiles;
     char *t;
     int error = 0;
+    int async_default = -1;
 
     tsb.sb_thisfile = -1;
     ti = as->parms[0].items;   /* -kbytes */
@@ -3150,13 +3406,14 @@ StoreBehindCmd(struct cmd_syndesc *as, char *arock)
        verbose = 1;
 
     blob.in = (char *)&tsb;
-    blob.out = (char *)&tsb2;
-    blob.in_size = blob.out_size = sizeof(struct sbstruct);
-    memset(&tsb2, 0, sizeof(tsb2));
+    blob.in_size = sizeof(struct sbstruct);
 
     /* once per -file */
     for (ti = as->parms[1].items; ti; ti = ti->next) {
        /* Do this solely to see if the file is there */
+
+        blob.out = space;
+       blob.out_size = AFS_PIOCTL_MAXSIZE;
        code = pioctl(ti->data, VIOCWHEREIS, &blob, 1);
        if (code) {
            Die(errno, ti->data);
@@ -3164,6 +3421,9 @@ StoreBehindCmd(struct cmd_syndesc *as, char *arock)
            continue;
        }
 
+       memset(&tsb2, 0, sizeof(tsb2));
+       blob.out = (char *)&tsb2;
+       blob.out_size = sizeof(struct sbstruct);
        code = pioctl(ti->data, VIOC_STORBEHIND, &blob, 1);
        if (code) {
            Die(errno, ti->data);
@@ -3171,14 +3431,18 @@ StoreBehindCmd(struct cmd_syndesc *as, char *arock)
            continue;
        }
 
-       if (verbose && (blob.out_size == sizeof(tsb2))) {
-           if (tsb2.sb_thisfile == -1) {
-               fprintf(stdout, "Will store %s according to default.\n",
-                       ti->data);
+       if (blob.out_size == sizeof(tsb2)) {
+           async_default = tsb2.sb_default;
+
+           if (verbose) {
+               if (tsb2.sb_thisfile == -1) {
+                   fprintf(stdout, "Will store %s according to default.\n",
+                           ti->data);
            } else {
-               fprintf(stdout,
-                       "Will store up to %d kbytes of %s asynchronously.\n",
-                       (tsb2.sb_thisfile / 1024), ti->data);
+                   fprintf(stdout,
+                           "Will store up to %d kbytes of %s asynchronously.\n",
+                           (tsb2.sb_thisfile / 1024), ti->data);
+               }
            }
        }
     }
@@ -3186,27 +3450,33 @@ StoreBehindCmd(struct cmd_syndesc *as, char *arock)
     /* If no files - make at least one pioctl call, or
      * set the allfiles default if we need to.
      */
-    if (!as->parms[1].items || (allfiles != -1)) {
+    if (async_default < 0 || (allfiles != -1)) {
        tsb.sb_default = allfiles;
+        memset(&tsb2, 0, sizeof(tsb2));
+       blob.out = (char *)&tsb2;
+       blob.out_size = sizeof(struct sbstruct);
        code = pioctl(0, VIOC_STORBEHIND, &blob, 1);
        if (code) {
            Die(errno, ((allfiles == -1) ? 0 : "-allfiles"));
            error = 1;
+
+       } else if (blob.out_size == sizeof(tsb2)) {
+           async_default = tsb2.sb_default;
        }
     }
 
     /* Having no arguments also reports the default store asynchrony */
-    if (verbose && (blob.out_size == sizeof(tsb2))) {
+    if (async_default >= 0 && verbose) {
        fprintf(stdout, "Default store asynchrony is %d kbytes.\n",
-               (tsb2.sb_default / 1024));
+               (async_default / 1024));
     }
 
     return error;
 }
 
 
-static afs_int32
-SetCryptCmd(struct cmd_syndesc *as, char *arock)
+static int
+SetCryptCmd(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 code = 0, flag;
     struct ViceIoctl blob;
@@ -3232,8 +3502,8 @@ SetCryptCmd(struct cmd_syndesc *as, char *arock)
 }
 
 
-static afs_int32
-GetCryptCmd(struct cmd_syndesc *as, char *arock)
+static int
+GetCryptCmd(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 code = 0, flag;
     struct ViceIoctl blob;
@@ -3260,28 +3530,38 @@ GetCryptCmd(struct cmd_syndesc *as, char *arock)
     return 0;
 }
 
-#ifdef AFS_DISCON_ENV
 static char *modenames[] = {
-    "discon",
-    "fetchonly",
-    "partial",
-    "nat",
-    "full",
+    "offline",
+    "online",
+    "readonly",  /* Not currently supported */
+    "fetchonly", /* Not currently supported */
+    "partial",   /* Not currently supported */
     NULL
 };
 
-static afs_int32
-DisconCmd(struct cmd_syndesc *as, char *arock)
+static char *policynames[] = {
+    "client",
+    "server",
+    "closer",  /* Not currently supported. */
+    "manual",  /* Not currently supported. */
+    NULL
+};
+
+static int
+DisconCmd(struct cmd_syndesc *as, void *arock)
 {
     struct cmd_item *ti;
     char *modename;
-    int modelen;
-    afs_int32 mode, code;
+    char *policyname;
+    int modelen, policylen;
+    afs_int32 mode, policy, code, unixuid = 0;
     struct ViceIoctl blob;
 
     blob.in = NULL;
     blob.in_size = 0;
 
+    space[0] = space[1] = space[2] = space[3] = 0;
+
     ti = as->parms[0].items;
     if (ti) {
        modename = ti->data;
@@ -3292,11 +3572,41 @@ DisconCmd(struct cmd_syndesc *as, char *arock)
        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;
+           space[0] = mode + 1;
        }
     }
+    ti = as->parms[1].items;
+    if (ti) {
+       policyname = ti->data;
+       policylen = strlen(policyname);
+       for (policy = 0; policynames[policy] != NULL; policy++)
+           if (!strncasecmp(policyname, policynames[policy], policylen))
+               break;
+       if (policynames[policy] == NULL)
+           printf("Unknown discon mode \"%s\"\n", policyname);
+       else {
+           space[1] = policy + 1;
+       }
+    }
+
+    if (as->parms[2].items) {
+       space[2] = 1;
+       printf("force on\n");
+    }
+
+    ti = as->parms[3].items;
+    if (ti) {
+       code = util_GetInt32(ti->data, &unixuid);
+       if (code) {
+           fprintf(stderr, "%s: bad integer specified for uid.\n", pn);
+            return 1;
+        }
+       space[3] = unixuid;
+    } else
+       space[3] = 0;
+
+    blob.in = space;
+    blob.in_size = 4 * sizeof(afs_int32);
 
     blob.out_size = sizeof(mode);
     blob.out = space;
@@ -3313,7 +3623,6 @@ DisconCmd(struct cmd_syndesc *as, char *arock)
 
     return 0;
 }
-#endif
 
 #include "AFS_component_version_number.c"
 
@@ -3339,17 +3648,17 @@ main(int argc, char **argv)
 #endif
 
     /* try to find volume location information */
-    ts = cmd_CreateSyntax("getclientaddrs", GetClientAddrsCmd, 0,
+    ts = cmd_CreateSyntax("getclientaddrs", GetClientAddrsCmd, NULL, 0,
                          "get client network interface addresses");
     cmd_CreateAlias(ts, "gc");
 
-    ts = cmd_CreateSyntax("setclientaddrs", SetClientAddrsCmd, 0,
+    ts = cmd_CreateSyntax("setclientaddrs", SetClientAddrsCmd, NULL, 0,
                          "set client network interface addresses");
     cmd_AddParm(ts, "-address", CMD_LIST, CMD_OPTIONAL | CMD_EXPANDS,
                "client network interfaces");
     cmd_CreateAlias(ts, "sc");
 
-    ts = cmd_CreateSyntax("setserverprefs", SetPrefCmd, 0,
+    ts = cmd_CreateSyntax("setserverprefs", SetPrefCmd, NULL, 0,
                          "set server ranks");
     cmd_AddParm(ts, "-servers", CMD_LIST, CMD_OPTIONAL | CMD_EXPANDS,
                "fileserver names and ranks");
@@ -3360,7 +3669,7 @@ main(int argc, char **argv)
     cmd_AddParm(ts, "-stdin", CMD_FLAG, CMD_OPTIONAL, "input from stdin");
     cmd_CreateAlias(ts, "sp");
 
-    ts = cmd_CreateSyntax("getserverprefs", GetPrefCmd, 0,
+    ts = cmd_CreateSyntax("getserverprefs", GetPrefCmd, NULL, 0,
                          "get server ranks");
     cmd_AddParm(ts, "-file", CMD_SINGLE, CMD_OPTIONAL,
                "output to named file");
@@ -3369,7 +3678,7 @@ main(int argc, char **argv)
 /*    cmd_AddParm(ts, "-cell", CMD_FLAG, CMD_OPTIONAL, "cellname"); */
     cmd_CreateAlias(ts, "gp");
 
-    ts = cmd_CreateSyntax("setacl", SetACLCmd, 0, "set access control list");
+    ts = cmd_CreateSyntax("setacl", SetACLCmd, NULL, 0, "set access control list");
     cmd_AddParm(ts, "-dir", CMD_LIST, 0, "directory");
     cmd_AddParm(ts, "-acl", CMD_LIST, 0, "access list entries");
     cmd_AddParm(ts, "-clear", CMD_FLAG, CMD_OPTIONAL, "clear access list");
@@ -3382,24 +3691,25 @@ main(int argc, char **argv)
                "initial file acl (DFS only)");
     cmd_CreateAlias(ts, "sa");
 
-    ts = cmd_CreateSyntax("listacl", ListACLCmd, 0,
+    ts = cmd_CreateSyntax("listacl", ListACLCmd, NULL, 0,
                          "list access control list");
     cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
     parm_listacl_id = ts->nParms;
     cmd_AddParm(ts, "-id", CMD_FLAG, CMD_OPTIONAL, "initial directory acl");
     cmd_AddParm(ts, "-if", CMD_FLAG, CMD_OPTIONAL, "initial file acl");
+    cmd_AddParm(ts, "-cmd", CMD_FLAG, CMD_OPTIONAL, "output as 'fs setacl' command");
     cmd_CreateAlias(ts, "la");
 
-    ts = cmd_CreateSyntax("getcalleraccess", GetCallerAccess, 0,
+    ts = cmd_CreateSyntax("getcalleraccess", GetCallerAccess, NULL, 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,
+    ts = cmd_CreateSyntax("cleanacl", CleanACLCmd, NULL, 0,
                          "clean up access control list");
     cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
 
-    ts = cmd_CreateSyntax("copyacl", CopyACLCmd, 0,
+    ts = cmd_CreateSyntax("copyacl", CopyACLCmd, NULL, 0,
                          "copy access control list");
     cmd_AddParm(ts, "-fromdir", CMD_SINGLE, 0,
                "source directory (or DFS file)");
@@ -3413,13 +3723,13 @@ main(int argc, char **argv)
 
     cmd_CreateAlias(ts, "ca");
 
-    ts = cmd_CreateSyntax("flush", FlushCmd, 0, "flush file from cache");
+    ts = cmd_CreateSyntax("flush", FlushCmd, NULL, 0, "flush file from cache");
     cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
-    ts = cmd_CreateSyntax("flushmount", FlushMountCmd, 0,
+    ts = cmd_CreateSyntax("flushmount", FlushMountCmd, NULL, 0,
                          "flush mount symlink from cache");
     cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
 
-    ts = cmd_CreateSyntax("setvol", SetVolCmd, 0, "set volume status");
+    ts = cmd_CreateSyntax("setvol", SetVolCmd, NULL, 0, "set volume status");
     cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
     cmd_AddParm(ts, "-max", CMD_SINGLE, CMD_OPTIONAL,
                "disk space quota in 1K units");
@@ -3432,32 +3742,34 @@ main(int argc, char **argv)
                "offline message");
     cmd_CreateAlias(ts, "sv");
 
-    ts = cmd_CreateSyntax("messages", MessagesCmd, 0,
+    ts = cmd_CreateSyntax("messages", MessagesCmd, NULL, 0,
                          "control Cache Manager messages");
     cmd_AddParm(ts, "-show", CMD_SINGLE, CMD_OPTIONAL,
                "[user|console|all|none]");
 
-    ts = cmd_CreateSyntax("examine", ExamineCmd, 0, "display file/volume status");
+    ts = cmd_CreateSyntax("examine", ExamineCmd, NULL, 0, "display file/volume status");
     cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
     cmd_CreateAlias(ts, "lv");
     cmd_CreateAlias(ts, "listvol");
 
-    ts = cmd_CreateSyntax("listquota", ListQuotaCmd, 0, "list volume quota");
+    ts = cmd_CreateSyntax("listquota", ListQuotaCmd, NULL, 0, "list volume quota");
     cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
+    cmd_AddParm(ts, "-human", CMD_FLAG, CMD_OPTIONAL, "human-readable listing");
     cmd_CreateAlias(ts, "lq");
 
-    ts = cmd_CreateSyntax("diskfree", DiskFreeCmd, 0,
+    ts = cmd_CreateSyntax("diskfree", DiskFreeCmd, NULL, 0,
                          "show server disk space usage");
     cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
+    cmd_AddParm(ts, "-human", CMD_FLAG, CMD_OPTIONAL, "human-readable listing");
     cmd_CreateAlias(ts, "df");
 
-    ts = cmd_CreateSyntax("quota", QuotaCmd, 0, "show volume quota usage");
+    ts = cmd_CreateSyntax("quota", QuotaCmd, NULL, 0, "show volume quota usage");
     cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
 
-    ts = cmd_CreateSyntax("lsmount", ListMountCmd, 0, "list mount point");
+    ts = cmd_CreateSyntax("lsmount", ListMountCmd, NULL, 0, "list mount point");
     cmd_AddParm(ts, "-dir", CMD_LIST, 0, "directory");
 
-    ts = cmd_CreateSyntax("mkmount", MakeMountCmd, 0, "make mount point");
+    ts = cmd_CreateSyntax("mkmount", MakeMountCmd, NULL, 0, "make mount point");
     cmd_AddParm(ts, "-dir", CMD_SINGLE, 0, "directory");
     cmd_AddParm(ts, "-vol", CMD_SINGLE, 0, "volume name");
     cmd_AddParm(ts, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell name");
@@ -3465,6 +3777,12 @@ main(int argc, char **argv)
     cmd_AddParm(ts, "-fast", CMD_FLAG, CMD_OPTIONAL,
                "don't check name with VLDB");
 
+#if defined(AFS_CACHE_BYPASS)
+       ts = cmd_CreateSyntax("bypassthreshold", BypassThresholdCmd, NULL, 0,
+               "get/set cache bypass file size threshold");
+       cmd_AddParm(ts, "-size", CMD_SINGLE, CMD_OPTIONAL, "file size");
+#endif
+
 /*
 
 defect 3069
@@ -3473,10 +3791,10 @@ defect 3069
 */
 
 
-    ts = cmd_CreateSyntax("rmmount", RemoveMountCmd, 0, "remove mount point");
+    ts = cmd_CreateSyntax("rmmount", RemoveMountCmd, NULL, 0, "remove mount point");
     cmd_AddParm(ts, "-dir", CMD_LIST, 0, "directory");
 
-    ts = cmd_CreateSyntax("checkservers", CheckServersCmd, 0,
+    ts = cmd_CreateSyntax("checkservers", CheckServersCmd, NULL, 0,
                          "check local cell's servers");
     cmd_AddParm(ts, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell to check");
     cmd_AddParm(ts, "-all", CMD_FLAG, CMD_OPTIONAL, "check all cells");
@@ -3485,12 +3803,12 @@ defect 3069
     cmd_AddParm(ts, "-interval", CMD_SINGLE, CMD_OPTIONAL,
                "seconds between probes");
 
-    ts = cmd_CreateSyntax("checkvolumes", CheckVolumesCmd, 0,
+    ts = cmd_CreateSyntax("checkvolumes", CheckVolumesCmd, NULL, 0,
                          "check volumeID/name mappings");
     cmd_CreateAlias(ts, "checkbackups");
 
 
-    ts = cmd_CreateSyntax("setcachesize", SetCacheSizeCmd, 0,
+    ts = cmd_CreateSyntax("setcachesize", SetCacheSizeCmd, NULL, 0,
                          "set cache size");
     cmd_AddParm(ts, "-blocks", CMD_SINGLE, CMD_OPTIONAL,
                "size in 1K byte blocks (0 => reset)");
@@ -3499,19 +3817,19 @@ defect 3069
     cmd_AddParm(ts, "-reset", CMD_FLAG, CMD_OPTIONAL,
                "reset size back to boot value");
 
-    ts = cmd_CreateSyntax("getcacheparms", GetCacheParmsCmd, 0,
+    ts = cmd_CreateSyntax("getcacheparms", GetCacheParmsCmd, NULL, 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,
+    ts = cmd_CreateSyntax("listcells", ListCellsCmd, NULL, 0,
                          "list configured cells");
     cmd_AddParm(ts, "-numeric", CMD_FLAG, CMD_OPTIONAL, "addresses only");
 
-    ts = cmd_CreateSyntax("listaliases", ListAliasesCmd, 0,
-                         "list configured cell aliases");
+    cmd_CreateSyntax("listaliases", ListAliasesCmd, NULL, 0,
+                    "list configured cell aliases");
 
-    ts = cmd_CreateSyntax("setquota", SetQuotaCmd, 0, "set volume quota");
+    ts = cmd_CreateSyntax("setquota", SetQuotaCmd, NULL, 0, "set volume quota");
     cmd_AddParm(ts, "-path", CMD_SINGLE, CMD_OPTIONAL, "dir/file path");
     cmd_AddParm(ts, "-max", CMD_SINGLE, 0, "max quota in kbytes");
 #ifdef notdef
@@ -3519,13 +3837,13 @@ defect 3069
 #endif
     cmd_CreateAlias(ts, "sq");
 
-    ts = cmd_CreateSyntax("newcell", NewCellCmd, 0, "configure new cell");
+    ts = cmd_CreateSyntax("newcell", NewCellCmd, NULL, 0, "configure new cell");
     cmd_AddParm(ts, "-name", CMD_SINGLE, 0, "cell name");
     cmd_AddParm(ts, "-servers", CMD_LIST, CMD_REQUIRED, "primary servers");
     cmd_AddParm(ts, "-linkedcell", CMD_SINGLE, CMD_OPTIONAL,
                "linked cell name");
 
-    ts = cmd_CreateSyntax("newalias", NewAliasCmd, 0,
+    ts = cmd_CreateSyntax("newalias", NewAliasCmd, NULL, 0,
                          "configure new cell alias");
     cmd_AddParm(ts, "-alias", CMD_SINGLE, 0, "alias name");
     cmd_AddParm(ts, "-name", CMD_SINGLE, 0, "real name of cell");
@@ -3543,42 +3861,43 @@ defect 3069
                "cell's vldb server port");
 #endif
 
-    ts = cmd_CreateSyntax("whichcell", WhichCellCmd, 0, "list file's cell");
+    ts = cmd_CreateSyntax("whichcell", WhichCellCmd, NULL, 0, "list file's cell");
     cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
 
-    ts = cmd_CreateSyntax("whereis", WhereIsCmd, 0, "list file's location");
+    ts = cmd_CreateSyntax("whereis", WhereIsCmd, NULL, 0, "list file's location");
     cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
 
-    ts = cmd_CreateSyntax("wscell", WSCellCmd, 0, "list workstation's cell");
+    cmd_CreateSyntax("wscell", WSCellCmd, NULL, 0, "list workstation's cell");
 
 /*
-    ts = cmd_CreateSyntax("primarycell", PrimaryCellCmd, 0, "obsolete (listed primary cell)");
+    ts = cmd_CreateSyntax("primarycell", PrimaryCellCmd, NULL, "obsolete (listed primary cell)");
 */
 
-    /* set cache monitor host address */
-    ts = cmd_CreateSyntax("monitor", MonitorCmd, 0, (char *)CMD_HIDDEN);
+    ts = cmd_CreateSyntax("monitor", MonitorCmd, NULL, CMD_HIDDEN, "set cache monitor host address");
     cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL,
                "host name or 'off'");
     cmd_CreateAlias(ts, "mariner");
 
-    ts = cmd_CreateSyntax("getcellstatus", GetCellCmd, 0, "get cell status");
+    ts = cmd_CreateSyntax("getcellstatus", GetCellCmd, NULL, 0, "get cell status");
     cmd_AddParm(ts, "-cell", CMD_LIST, 0, "cell name");
 
-    ts = cmd_CreateSyntax("setcell", SetCellCmd, 0, "set cell status");
+    ts = cmd_CreateSyntax("setcell", SetCellCmd, NULL, 0, "set cell status");
     cmd_AddParm(ts, "-cell", CMD_LIST, 0, "cell name");
     cmd_AddParm(ts, "-suid", CMD_FLAG, CMD_OPTIONAL, "allow setuid programs");
     cmd_AddParm(ts, "-nosuid", CMD_FLAG, CMD_OPTIONAL,
                "disallow setuid programs");
 
-    ts = cmd_CreateSyntax("flushvolume", FlushVolumeCmd, 0,
+    ts = cmd_CreateSyntax("flushvolume", FlushVolumeCmd, NULL, 0,
                          "flush all data in volume");
     cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
 
-    ts = cmd_CreateSyntax("sysname", SysNameCmd, 0,
+    cmd_CreateSyntax("flushall", FlushAllVolumesCmd, NULL, 0, "flush all data from the cache");
+
+    ts = cmd_CreateSyntax("sysname", SysNameCmd, NULL, 0,
                          "get/set sysname (i.e. @sys) value");
     cmd_AddParm(ts, "-newsys", CMD_LIST, CMD_OPTIONAL, "new sysname");
 
-    ts = cmd_CreateSyntax("exportafs", ExportAfsCmd, 0,
+    ts = cmd_CreateSyntax("exportafs", ExportAfsCmd, NULL, 0,
                          "enable/disable translators to AFS");
     cmd_AddParm(ts, "-type", CMD_SINGLE, 0, "exporter name");
     cmd_AddParm(ts, "-start", CMD_SINGLE, CMD_OPTIONAL,
@@ -3595,7 +3914,7 @@ defect 3069
                "enable callbacks to get creds from new clients (on  | off)");
 
 
-    ts = cmd_CreateSyntax("storebehind", StoreBehindCmd, 0,
+    ts = cmd_CreateSyntax("storebehind", StoreBehindCmd, NULL, 0,
                          "store to server after file close");
     cmd_AddParm(ts, "-kbytes", CMD_SINGLE, CMD_OPTIONAL,
                "asynchrony for specified names");
@@ -3605,44 +3924,50 @@ defect 3069
     cmd_AddParm(ts, "-verbose", CMD_FLAG, CMD_OPTIONAL, "show status");
     cmd_CreateAlias(ts, "sb");
 
-    ts = cmd_CreateSyntax("setcrypt", SetCryptCmd, 0,
+    ts = cmd_CreateSyntax("setcrypt", SetCryptCmd, NULL, 0,
                          "set cache manager encryption flag");
     cmd_AddParm(ts, "-crypt", CMD_SINGLE, 0, "on or off");
 
-    ts = cmd_CreateSyntax("getcrypt", GetCryptCmd, 0,
+    cmd_CreateSyntax("getcrypt", GetCryptCmd, NULL, 0,
                          "get cache manager encryption flag");
 
-    ts = cmd_CreateSyntax("rxstatproc", RxStatProcCmd, 0,
+    ts = cmd_CreateSyntax("rxstatproc", RxStatProcCmd, NULL, 0,
                          "Manage per process RX statistics");
     cmd_AddParm(ts, "-enable", CMD_FLAG, CMD_OPTIONAL, "Enable RX stats");
     cmd_AddParm(ts, "-disable", CMD_FLAG, CMD_OPTIONAL, "Disable RX stats");
     cmd_AddParm(ts, "-clear", CMD_FLAG, CMD_OPTIONAL, "Clear RX stats");
 
-    ts = cmd_CreateSyntax("rxstatpeer", RxStatPeerCmd, 0,
+    ts = cmd_CreateSyntax("rxstatpeer", RxStatPeerCmd, NULL, 0,
                          "Manage per peer RX statistics");
     cmd_AddParm(ts, "-enable", CMD_FLAG, CMD_OPTIONAL, "Enable RX stats");
     cmd_AddParm(ts, "-disable", CMD_FLAG, CMD_OPTIONAL, "Disable RX stats");
     cmd_AddParm(ts, "-clear", CMD_FLAG, CMD_OPTIONAL, "Clear RX stats");
 
-    ts = cmd_CreateSyntax("setcbaddr", CallBackRxConnCmd, 0, "configure callback connection address");
+    ts = cmd_CreateSyntax("setcbaddr", CallBackRxConnCmd, NULL, 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,
+    ts = cmd_CreateSyntax("getfid", GetFidCmd, NULL, 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,
+    ts = cmd_CreateSyntax("discon", DisconCmd, NULL, 0,
                          "disconnection mode");
-    cmd_AddParm(ts, "-mode", CMD_SINGLE, CMD_OPTIONAL, "nat | full");
-#endif
+    cmd_AddParm(ts, "-mode", CMD_SINGLE, CMD_REQUIRED, "offline | online");
+    cmd_AddParm(ts, "-policy", CMD_SINGLE, CMD_OPTIONAL, "client | server");
+    cmd_AddParm(ts, "-force", CMD_FLAG, CMD_OPTIONAL, "Force reconnection, despite any synchronization issues.");
+    cmd_AddParm(ts, "-uid", CMD_SINGLE, CMD_OPTIONAL, "Numeric UID of user whose tokens to use at reconnect.");
 
-    ts = cmd_CreateSyntax("nukenfscreds", NukeNFSCredsCmd, 0, "nuke credentials for NFS client");
+    ts = cmd_CreateSyntax("nukenfscreds", NukeNFSCredsCmd, NULL, 0, "nuke credentials for NFS client");
     cmd_AddParm(ts, "-addr", CMD_SINGLE, 0, "host name or address");
 
-    ts = cmd_CreateSyntax("newuuid", NewUuidCmd, 0,
-                         "force a new uuid");
+    ts = cmd_CreateSyntax("uuid", UuidCmd, NULL, 0, "manage the UUID for the cache manager");
+    cmd_AddParm(ts, "-generate", CMD_FLAG, CMD_REQUIRED, "generate a new UUID");
+
+    ts = cmd_CreateSyntax("precache", PreCacheCmd, NULL, 0,
+                         "set precache size");
+    cmd_AddParm(ts, "-blocks", CMD_SINGLE, CMD_OPTIONAL,
+               "size in 1K byte blocks (0 => disable)");
 
     code = cmd_Dispatch(argc, argv);
     if (rxInitDone)
@@ -3684,6 +4009,9 @@ Die(int errnum, char *filename)
                    "%s: You do not have the required rights to do this operation\n",
                    pn);
        break;
+    case ESRCH: /* hack: pioctls stole ESRCH for cell name not available errors. */
+       fprintf(stderr, "%s: Cell name not recognized.\n", pn);
+       break;
     default:
        if (filename)
            fprintf(stderr, "%s:'%s'", pn, filename);
@@ -3696,11 +4024,9 @@ Die(int errnum, char *filename)
 
 /* get clients interface addresses */
 static int
-GetClientAddrsCmd(struct cmd_syndesc *as, char *arock)
+GetClientAddrsCmd(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 code;
-    struct cmd_item *ti;
-    char *name;
     struct ViceIoctl blob;
     struct sprefrequest *in;
     struct sprefinfo *out;
@@ -3712,10 +4038,10 @@ GetClientAddrsCmd(struct cmd_syndesc *as, char *arock)
        blob.in_size = sizeof(struct sprefrequest);
        blob.in = (char *)in;
        blob.out = space;
-       blob.out_size = MAXSIZE;
+       blob.out_size = AFS_PIOCTL_MAXSIZE;
 
        in->num_servers =
-           (MAXSIZE - 2 * sizeof(short)) / sizeof(struct spref);
+           (AFS_PIOCTL_MAXSIZE - 2 * sizeof(short)) / sizeof(struct spref);
        /* returns addr in network byte order */
        code = pioctl(0, VIOC_GETCPREFS, &blob, 1);
        if (code) {
@@ -3742,15 +4068,14 @@ GetClientAddrsCmd(struct cmd_syndesc *as, char *arock)
 }
 
 static int
-SetClientAddrsCmd(struct cmd_syndesc *as, char *arock)
+SetClientAddrsCmd(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 code, addr;
     struct cmd_item *ti;
-    char name[80];
     struct ViceIoctl blob;
     struct setspref *ssp;
     int sizeUsed = 0, i, flag;
-    afs_int32 existingAddr[1024];      /* existing addresses on this host */
+    afs_uint32 existingAddr[1024];     /* existing addresses on this host */
     int existNu;
     int error = 0;
 
@@ -3758,7 +4083,7 @@ SetClientAddrsCmd(struct cmd_syndesc *as, char *arock)
     ssp->num_servers = 0;
     blob.in = space;
     blob.out = space;
-    blob.out_size = MAXSIZE;
+    blob.out_size = AFS_PIOCTL_MAXSIZE;
 
     if (geteuid()) {
        fprintf(stderr, "Permission denied: requires root access.\n");
@@ -3816,98 +4141,18 @@ SetClientAddrsCmd(struct cmd_syndesc *as, char *arock)
 }
 
 static int
-FlushMountCmd(struct cmd_syndesc *as, char *arock)
+FlushMountCmd(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 code;
     struct ViceIoctl blob;
     struct cmd_item *ti;
-    char orig_name[1024];      /*Original name, may be modified */
-    char true_name[1024];      /*``True'' dirname (e.g., symlink target) */
-    char parent_dir[1024];     /*Parent directory of true name */
-    char *last_component;      /*Last component of true name */
-    struct stat statbuff;      /*Buffer for status info */
-    int link_chars_read;       /*Num chars read in readlink() */
-    int thru_symlink;          /*Did we get to a mount point via a symlink? */
+    char *last_component;
+    char *parent_dir;
     int error = 0;
 
     for (ti = as->parms[0].items; ti; ti = ti->next) {
-       /* once per file */
-       thru_symlink = 0;
-       sprintf(orig_name, "%s%s", (ti->data[0] == '/') ? "" : "./",
-               ti->data);
-
-       if (lstat(orig_name, &statbuff) < 0) {
-           /* if lstat fails, we should still try the pioctl, since it
-            * may work (for example, lstat will fail, but pioctl will
-            * work if the volume of offline (returning ENODEV). */
-           statbuff.st_mode = S_IFDIR; /* lie like pros */
-       }
-
-       /*
-        * The lstat succeeded.  If the given file is a symlink, substitute
-        * the file name with the link name.
-        */
-       if ((statbuff.st_mode & S_IFMT) == S_IFLNK) {
-           thru_symlink = 1;
-           /*
-            * Read name of resolved file.
-            */
-           link_chars_read = readlink(orig_name, true_name, 1024);
-           if (link_chars_read <= 0) {
-               fprintf(stderr,
-                       "%s: Can't read target name for '%s' symbolic link!\n",
-                       pn, orig_name);
-               error = 1;
-               continue;
-           }
-
-           /*
-            * Add a trailing null to what was read, bump the length.
-            */
-           true_name[link_chars_read++] = 0;
-
-           /*
-            * If the symlink is an absolute pathname, we're fine.  Otherwise, we
-            * have to create a full pathname using the original name and the
-            * relative symlink name.  Find the rightmost slash in the original
-            * name (we know there is one) and splice in the symlink value.
-            */
-           if (true_name[0] != '/') {
-               last_component = (char *)strrchr(orig_name, '/');
-               strcpy(++last_component, true_name);
-               strcpy(true_name, orig_name);
-           }
-       } else
-           strcpy(true_name, orig_name);
-
-       /*
-        * Find rightmost slash, if any.
-        */
-       last_component = (char *)strrchr(true_name, '/');
-       if (last_component) {
-           /*
-            * Found it.  Designate everything before it as the parent directory,
-            * everything after it as the final component.
-            */
-           strncpy(parent_dir, true_name, last_component - true_name);
-           parent_dir[last_component - true_name] = 0;
-           last_component++;   /*Skip the slash */
-       } else {
-           /*
-            * No slash appears in the given file name.  Set parent_dir to the current
-            * directory, and the last component as the given name.
-            */
-           strcpy(parent_dir, ".");
-           last_component = true_name;
-       }
-
-       if (strcmp(last_component, ".") == 0
-           || strcmp(last_component, "..") == 0) {
-           fprintf(stderr,
-                   "%s: you may not use '.' or '..' as the last component\n",
-                   pn);
-           fprintf(stderr, "%s: of a name in the 'fs flushmount' command.\n",
-                   pn);
+       if (GetLastComponent(ti->data, &parent_dir,
+                            &last_component, NULL) != 0) {
            error = 1;
            continue;
        }
@@ -3915,10 +4160,11 @@ FlushMountCmd(struct cmd_syndesc *as, char *arock)
        blob.in = last_component;
        blob.in_size = strlen(last_component) + 1;
        blob.out_size = 0;
-       memset(space, 0, MAXSIZE);
 
        code = pioctl(parent_dir, VIOC_AFS_FLUSHMOUNT, &blob, 1);
 
+       free(last_component);
+
        if (code != 0) {
            if (errno == EINVAL) {
                fprintf(stderr, "'%s' is not a mount point.\n", ti->data);
@@ -3927,17 +4173,17 @@ FlushMountCmd(struct cmd_syndesc *as, char *arock)
            }
            error = 1;
        }
+       free(parent_dir);
     }
     return error;
 }
 
 static int
-RxStatProcCmd(struct cmd_syndesc *as, char *arock)
+RxStatProcCmd(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 code;
     afs_int32 flags = 0;
     struct ViceIoctl blob;
-    struct cmd_item *ti;
 
     if (as->parms[0].items) {  /* -enable */
        flags |= AFSCALL_RXSTATS_ENABLE;
@@ -3967,12 +4213,11 @@ RxStatProcCmd(struct cmd_syndesc *as, char *arock)
 }
 
 static int
-RxStatPeerCmd(struct cmd_syndesc *as, char *arock)
+RxStatPeerCmd(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 code;
     afs_int32 flags = 0;
     struct ViceIoctl blob;
-    struct cmd_item *ti;
 
     if (as->parms[0].items) {  /* -enable */
        flags |= AFSCALL_RXSTATS_ENABLE;
@@ -4002,24 +4247,46 @@ RxStatPeerCmd(struct cmd_syndesc *as, char *arock)
 }
 
 static int
-GetFidCmd(struct cmd_syndesc *as, char *arock)
+GetFidCmd(struct cmd_syndesc *as, void *arock)
 {
     struct ViceIoctl blob;
     struct cmd_item *ti;
+
+    afs_int32 code;
+    int error = 0;
+    char cell[MAXCELLCHARS];
+
+    SetDotDefault(&as->parms[0].items);
     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);
-      }
+        struct VenusFid vfid;
+
+        blob.out_size = sizeof(struct VenusFid);
+        blob.out = (char *) &vfid;
+        blob.in_size = 0;
+
+        code = pioctl(ti->data, VIOCGETFID, &blob, 1);
+        if (code) {
+            Die(errno,ti->data);
+            error = 1;
+            continue;
+        }
+
+        code = GetCell(ti->data, cell);
+        if (code) {
+           if (errno == ENOENT)
+               fprintf(stderr, "%s: no such cell as '%s'\n", pn, ti->data);
+           else
+               Die(errno, ti->data);
+           error = 1;
+           continue;
+        }
+
+        printf("File %s (%u.%u.%u) located in cell %s\n",
+               ti->data, vfid.Fid.Volume, vfid.Fid.Vnode, vfid.Fid.Unique,
+               cell);
+
     }
 
-    return 0;
+    return error;
 }