windows-cm_ioctl_query_opts-20080115
[openafs.git] / src / WINNT / afsd / fs.c
index f33ffb9..22438f3 100644 (file)
 
 #include <osi.h>
 #include <afsint.h>
+#include <afs/cellconfig.h>
 #include <afs/ptserver.h>
 #include <afs/ptuser.h>
+#include <afs/volser.h>
+#include <WINNT\afsreg.h>
 
 #include "fs.h"
 #include "fs_utils.h"
 static char space[MAXSIZE];
 static char tspace[1024];
 
-#ifndef WIN32
 static struct ubik_client *uclient;
-#endif /* not WIN32 */
 
-static int GetClientAddrsCmd(struct cmd_syndesc *asp, char *arock);
-static int SetClientAddrsCmd(struct cmd_syndesc *asp, char *arock);
-static int FlushMountCmd(struct cmd_syndesc *asp, char *arock);
-static int RxStatProcCmd(struct cmd_syndesc *asp, char *arock);
-static int RxStatPeerCmd(struct cmd_syndesc *asp, char *arock);
+static int GetClientAddrsCmd(struct cmd_syndesc *asp, void *arock);
+static int SetClientAddrsCmd(struct cmd_syndesc *asp, void *arock);
+static int FlushMountCmd(struct cmd_syndesc *asp, void *arock);
+static int RxStatProcCmd(struct cmd_syndesc *asp, void *arock);
+static int RxStatPeerCmd(struct cmd_syndesc *asp, void *arock);
 
 extern struct cmd_syndesc *cmd_CreateSyntax();
 
-static int MemDumpCmd(struct cmd_syndesc *asp, char *arock);
-static int CSCPolicyCmd(struct cmd_syndesc *asp, char *arock);
-
-extern afs_int32 VL_GetEntryByNameO();
+static int MemDumpCmd(struct cmd_syndesc *asp, void *arock);
+static int CSCPolicyCmd(struct cmd_syndesc *asp, void *arock);
+static int MiniDumpCmd(struct cmd_syndesc *asp, void *arock);
 
 static char pn[] = "fs";
 static int rxInitDone = 0;
 
-struct afsconf_cell {
-    char name[MAXCELLCHARS];
-    short numServers;
-    short flags;
-    struct sockaddr_in hostAddr[MAXCELLHOSTS];
-    char hostName[MAXCELLHOSTS][MAXHOSTCHARS];
-    char *linkedCell;
-};      
-
-
 /*
  * Character to use between name and rights in printed representation for
  * DFS ACL's.
@@ -269,6 +259,22 @@ InAFS(char *apath)
     return 1;
 }
 
+static int 
+IsFreelanceRoot(char *apath)
+{
+    struct ViceIoctl blob;
+    afs_int32 code;
+
+    blob.in_size = 0;
+    blob.out_size = MAXSIZE;
+    blob.out = space;
+
+    code = pioctl(apath, VIOC_FILE_CELL_NAME, &blob, 1);
+    if (code == 0)
+        return !stricmp("Freelance.Local.Root",space);
+    return 1;   /* assume it is because it is more restrictive that way */
+}
+
 /* return a static pointer to a buffer */
 static char *
 Parent(char *apath)
@@ -326,7 +332,7 @@ Convert(char *arights, int dfs, enum rtype *rtypep)
        *rtypep = destroy; /* Remove entire entry */
        return 0;
     }
-    len = strlen(arights);
+    len = (int)strlen(arights);
     mode = 0;
     for(i=0;i<len;i++) {
         tc = *arights++;
@@ -594,7 +600,7 @@ ParseAcl (char *astr)
 static int
 PrintStatus(VolumeStatus *status, char *name, char *motd, char *offmsg)
 {
-    printf("Volume status for vid = %u named %s\n",status->Vid, name);
+    printf("Volume status for vid = %u named %s is\n",status->Vid, name);
     if (*offmsg != 0)
        printf("Current offline message is %s\n",offmsg);
     if (*motd != 0)
@@ -605,7 +611,7 @@ PrintStatus(VolumeStatus *status, char *name, char *motd, char *offmsg)
     else 
         printf("unlimited\n");
     printf("Current blocks used are %d\n",status->BlocksInUse);
-    printf("The partition has %d blocks available out of %d\n\n",
+    printf("The partition has %d blocks available out of %d\n",
             status->PartBlocksAvail, status->PartMaxBlocks);
     return 0;
 }
@@ -688,9 +694,48 @@ AclToString(struct Acl *acl)
     return mydata;
 }
 
+static DWORD IsFreelance(void)
+{
+    HKEY  parmKey;
+    DWORD code;
+    DWORD dummyLen;
+    DWORD enabled = 0;
+
+    code = RegOpenKeyEx(HKEY_LOCAL_MACHINE, AFSREG_CLT_SVC_PARAM_SUBKEY,
+                         0, KEY_QUERY_VALUE, &parmKey);
+    if (code == ERROR_SUCCESS) {
+        dummyLen = sizeof(cm_freelanceEnabled);
+        code = RegQueryValueEx(parmKey, "FreelanceClient", NULL, NULL,
+                            (BYTE *) &enabled, &dummyLen);
+        RegCloseKey (parmKey);
+    }
+    return enabled;
+}
+
+static const char * NetbiosName(void)
+{
+    static char buffer[1024] = "AFS";
+    HKEY  parmKey;
+    DWORD code;
+    DWORD dummyLen;
+    DWORD enabled = 0;
+
+    code = RegOpenKeyEx(HKEY_LOCAL_MACHINE, AFSREG_CLT_SVC_PARAM_SUBKEY,
+                         0, KEY_QUERY_VALUE, &parmKey);
+    if (code == ERROR_SUCCESS) {
+        dummyLen = sizeof(buffer);
+        code = RegQueryValueEx(parmKey, "NetbiosName", NULL, NULL,
+                              buffer, &dummyLen);
+        RegCloseKey (parmKey);
+    } else {
+       strcpy(buffer, "AFS");
+    }
+    return buffer;
+}
+
 #define AFSCLIENT_ADMIN_GROUPNAME "AFS Client Admins"
 
-BOOL IsAdmin (void)
+static BOOL IsAdmin (void)
 {
     static BOOL fAdmin = FALSE;
     static BOOL fTested = FALSE;
@@ -828,7 +873,7 @@ BOOL IsAdmin (void)
 }
 
 static int
-SetACLCmd(struct cmd_syndesc *as, char *arock)
+SetACLCmd(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 code;
     struct ViceIoctl blob;
@@ -898,7 +943,7 @@ SetACLCmd(struct cmd_syndesc *as, char *arock)
        }
        blob.in = AclToString(ta);
        blob.out_size=0;
-       blob.in_size = 1+strlen(blob.in);
+       blob.in_size = 1+(long)strlen(blob.in);
        code = pioctl(ti->data, VIOCSETAL, &blob, 1);
        if (code) {
            if (errno == EINVAL) {
@@ -958,7 +1003,7 @@ 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;
@@ -1023,7 +1068,7 @@ CopyACLCmd(struct cmd_syndesc *as, char *arock)
            ChangeList(ta, 0, tp->name, tp->rights);
        blob.in = AclToString(ta);
        blob.out_size=0;
-       blob.in_size = 1+strlen(blob.in);
+       blob.in_size = 1+(long)strlen(blob.in);
        code = pioctl(ti->data, VIOCSETAL, &blob, 1);
        if (code) {
            if (errno == EINVAL) {
@@ -1054,7 +1099,7 @@ GetCell(char *fname, char *cellname)
     blob.out = cellname;
 
     code = pioctl(fname, VIOC_FILE_CELL_NAME, &blob, 1);
-    return code ? errno : 0;
+    return code;
 }
 
 /* Check if a username is valid: If it contains only digits (or a
@@ -1134,7 +1179,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;
@@ -1172,7 +1217,7 @@ CleanACLCmd(struct cmd_syndesc *as, char *arock)
        if (changes) {
            /* now set the acl */
            blob.in=AclToString(ta);
-           blob.in_size = strlen(blob.in)+1;
+           blob.in_size = (long)strlen(blob.in)+1;
            blob.out_size = 0;
            code = pioctl(ti->data, VIOCSETAL, &blob, 1);
            if (code) {
@@ -1221,7 +1266,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 = 0;
@@ -1287,7 +1332,22 @@ ListACLCmd(struct cmd_syndesc *as, char *arock)
 }
 
 static int
-FlushVolumeCmd(struct cmd_syndesc *as, char *arock)
+FlushAllCmd(struct cmd_syndesc *as, void *arock)
+{
+    afs_int32 code;
+    struct ViceIoctl blob;
+
+    blob.in_size = blob.out_size = 0;
+    code = pioctl(NULL, VIOC_FLUSHALL, &blob, 0);
+    if (code) {
+       fprintf(stderr, "Error flushing all ");
+       return 1;
+    }
+    return 0;
+}
+
+static int
+FlushVolumeCmd(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 code;
     struct ViceIoctl blob;
@@ -1309,16 +1369,28 @@ FlushVolumeCmd(struct cmd_syndesc *as, char *arock)
 }
 
 static int 
-FlushCmd(struct cmd_syndesc *as, char *arock) 
+FlushCmd(struct cmd_syndesc *as, void *arock) 
 {
     afs_int32 code;
     struct ViceIoctl blob;
     struct cmd_item *ti;
-
     int error = 0;
+    int literal = 0;
+    cm_ioctlQueryOptions_t options;
 
+    if (as->parms[1].items)
+        literal = 1;
+    
     for(ti=as->parms[0].items; ti; ti=ti->next) {
-       blob.in_size = blob.out_size = 0;
+        /* once per file */
+        memset(&options, 0, sizeof(options));
+        options.size = sizeof(options);
+        options.field_flags |= CM_IOCTL_QOPTS_FIELD_LITERAL;
+        options.literal = literal;
+       blob.in_size = options.size;    /* no variable length data */
+        blob.in = &options;
+
+       blob.out_size = 0;
        code = pioctl(ti->data, VIOCFLUSH, &blob, 0);
        if (code) {
            if (errno == EMFILE) {
@@ -1337,7 +1409,7 @@ 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 */
@@ -1346,7 +1418,7 @@ SetQuotaCmd(struct cmd_syndesc *as, char *arock) {
 }
 
 static int
-SetVolCmd(struct cmd_syndesc *as, char *arock) {
+SetVolCmd(struct cmd_syndesc *as, void *arock) {
     afs_int32 code;
     struct ViceIoctl blob;
     struct cmd_item *ti;
@@ -1386,7 +1458,7 @@ SetVolCmd(struct cmd_syndesc *as, char *arock) {
                 continue;
             }
            strcpy(input,offmsg);
-           blob.in_size += strlen(offmsg);
+           blob.in_size += (long)strlen(offmsg);
            input += strlen(offmsg) + 1;
        } else 
             *(input++) = '\0';
@@ -1397,31 +1469,47 @@ SetVolCmd(struct cmd_syndesc *as, char *arock) {
                 return code;
             }
            strcpy(input,motd);
-           blob.in_size += strlen(motd);
+           blob.in_size += (long)strlen(motd);
            input += strlen(motd) + 1;
        } else 
             *(input++) = '\0';
        code = pioctl(ti->data,VIOCSETVOLSTAT, &blob, 1);
        if (code) {
+           Die(errno, ti->data);
            error = 1;
        }
     }
     return error;
 }
 
-#ifndef WIN32
-/* 
- * Why is VenusFid declared in the kernel-only section of afs.h, 
- * if it's the exported interface of the (UNIX) cache manager?
- */
-struct VenusFid {
-    afs_int32 Cell;
-    AFSFid Fid;
-};
-#endif /* WIN32 */
+/* values match cache manager File Types */
+static char *
+filetypestr(afs_uint32 type)
+{
+    char * s = "Object";
+
+    switch (type) {
+    case 1:     /* file */
+        s = "File";
+        break;
+    case 2:
+        s = "Directory";
+        break;
+    case 3:
+        s = "Symlink";
+        break;
+    case 4:
+        s = "Mountpoint";
+        break;
+    case 5:
+        s = "DfsLink";
+        break;
+    }
+    return s;
+}
 
 static int 
-ExamineCmd(struct cmd_syndesc *as, char *arock)
+ExamineCmd(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 code;
     struct ViceIoctl blob;
@@ -1429,43 +1517,105 @@ ExamineCmd(struct cmd_syndesc *as, char *arock)
     struct VolumeStatus *status;
     char *name, *offmsg, *motd;
     int error = 0;
-    
+    int literal = 0;
+    cm_ioctlQueryOptions_t options;
+
+    if (as->parms[1].items)
+        literal = 1;
+
     SetDotDefault(&as->parms[0].items);
     for(ti=as->parms[0].items; ti; ti=ti->next) {
-#ifndef WIN32
-        struct VenusFid vfid;
-#endif /* WIN32 */
-       /* once per file */
-       blob.out_size = MAXSIZE;
-       blob.in_size = 0;
-       blob.out = space;
-       code = pioctl(ti->data, VIOCGETVOLSTAT, &blob, 1);
-       if (code) {
+        cm_fid_t fid;
+        afs_uint32 filetype;
+       afs_uint32 owner[2];
+       char cell[MAXCELLCHARS];
+
+        /* once per file */
+        memset(&fid, 0, sizeof(fid));
+        memset(&options, 0, sizeof(options));
+        filetype = 0;
+        options.size = sizeof(options);
+        options.field_flags |= CM_IOCTL_QOPTS_FIELD_LITERAL;
+        options.literal = literal;
+       blob.in_size = options.size;    /* no variable length data */
+        blob.in = &options;
+
+        blob.out_size = sizeof(cm_fid_t);
+        blob.out = (char *) &fid;
+        if (0 == pioctl(ti->data, VIOCGETFID, &blob, 1)) {
+            options.field_flags |= CM_IOCTL_QOPTS_FIELD_FID;
+            options.fid = fid;
+        } else {
            Die(errno, ti->data);
            error = 1;
            continue;
-       }
-       status = (VolumeStatus *)space;
-       name = (char *)status + sizeof(*status);
-       offmsg = name + strlen(name) + 1;
-       motd = offmsg + strlen(offmsg) + 1;
+        }
 
-#ifndef WIN32
-        blob.out_size = sizeof(struct VenusFid);
-        blob.out = (char *) &vfid;
-        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);
+        blob.out_size = sizeof(filetype);
+        blob.out = &filetype;
+
+        code = pioctl(ti->data, VIOC_GETFILETYPE, &blob, 1);
+
+        blob.out_size = MAXCELLCHARS;
+        blob.out = cell;
+
+        code = pioctl(ti->data, VIOC_FILE_CELL_NAME, &blob, 1);
+        printf("%s %s (%u.%u.%u) contained in cell %s\n",
+                filetypestr(filetype),
+                ti->data, fid.volume, fid.vnode, fid.unique,
+                code ? "unknown-cell" : cell);
+
+       blob.out_size = 2 * sizeof(afs_uint32);
+        blob.out = (char *) &owner;
+       if (0 == pioctl(ti->data, VIOCGETOWNER, &blob, 1)) {
+           char oname[PR_MAXNAMELEN] = "(unknown)";
+
+           /* Go to the PRDB and see if this all number username is valid */
+           pr_Initialize(1, AFSDIR_CLIENT_ETC_DIRPATH, cell);
+           pr_SIdToName(owner[0], oname);
+           printf("Owner %s (%u) Group %u\n", oname, owner[0], owner[1]);
         }
-#endif /* WIN32 */
-       PrintStatus(status, name, motd, offmsg);
+
+       blob.out = space;
+       blob.out_size = MAXSIZE;
+       code = pioctl(ti->data, VIOCGETVOLSTAT, &blob, 1);
+       if (code == 0) {
+            status = (VolumeStatus *)space;
+            name = (char *)status + sizeof(*status);
+            offmsg = name + strlen(name) + 1;
+            motd = offmsg + strlen(offmsg) + 1;
+
+            PrintStatus(status, name, motd, offmsg);
+        } else {
+            Die(errno, ti->data);
+        }
+
+        errno = 0;
+        code = pioctl(ti->data, VIOC_PATH_AVAILABILITY, &blob, 1);
+        switch (errno) {
+        case 0:
+            printf("Volume is online\n");
+            break;
+        case ENXIO:
+            printf("Volume is offline\n");
+            break;
+        case ENOSYS:
+            printf("All Volume servers are down\n");
+            break;
+        case EBUSY:
+            printf("All volume servers are busy\n");
+            break;
+        default:
+            printf("Unknown volume state\n");
+            Die(errno, ti->data);
+        }
+        printf("\n");
     }
     return error;
 }
 
 static int
-ListQuotaCmd(struct cmd_syndesc *as, char *arock) 
+ListQuotaCmd(struct cmd_syndesc *as, void *arock) 
 {
     afs_int32 code;
     struct ViceIoctl blob;
@@ -1497,7 +1647,7 @@ ListQuotaCmd(struct cmd_syndesc *as, char *arock)
 }
 
 static int
-WhereIsCmd(struct cmd_syndesc *as, char *arock)
+WhereIsCmd(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 code;
     struct ViceIoctl blob;
@@ -1506,12 +1656,44 @@ WhereIsCmd(struct cmd_syndesc *as, char *arock)
     afs_int32 *hosts;
     char *tp;
     int error = 0;
+    int literal = 0;
+    cm_ioctlQueryOptions_t options;
+
+    if (as->parms[1].items)
+        literal = 1;
     
     SetDotDefault(&as->parms[0].items);
     for(ti=as->parms[0].items; ti; ti=ti->next) {
-       /* once per file */
-       blob.out_size = MAXSIZE;
-       blob.in_size = 0;
+        cm_fid_t fid;
+        afs_uint32 filetype;
+
+        /* once per file */
+        memset(&fid, 0, sizeof(fid));
+        memset(&options, 0, sizeof(options));
+        filetype = 0;
+        options.size = sizeof(options);
+        options.field_flags |= CM_IOCTL_QOPTS_FIELD_LITERAL;
+        options.literal = literal;
+       blob.in_size = options.size;    /* no variable length data */
+        blob.in = &options;
+        
+        blob.out_size = sizeof(cm_fid_t);
+        blob.out = (char *) &fid;
+        if (0 == pioctl(ti->data, VIOCGETFID, &blob, 1)) {
+            options.field_flags |= CM_IOCTL_QOPTS_FIELD_FID;
+            options.fid = fid;
+        } else {
+           Die(errno, ti->data);
+           error = 1;
+           continue;
+        }
+
+        blob.out_size = sizeof(filetype);
+        blob.out = &filetype;
+
+        code = pioctl(ti->data, VIOC_GETFILETYPE, &blob, 1);
+
+        blob.out_size = MAXSIZE;
        blob.out = space;
        memset(space, 0, sizeof(space));
        code = pioctl(ti->data, VIOCWHEREIS, &blob, 1);
@@ -1521,7 +1703,9 @@ WhereIsCmd(struct cmd_syndesc *as, char *arock)
            continue;
        }
        hosts = (afs_int32 *) space;
-       printf("File %s is on host%s ", ti->data, 
+       printf("%s %s is on host%s ", 
+                filetypestr(filetype),
+                ti->data,
                 (hosts[0] && !hosts[1]) ? "": "s");
        for(j=0; j<MAXHOSTS; j++) {
            if (hosts[j] == 0) 
@@ -1536,7 +1720,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;
@@ -1567,7 +1751,7 @@ DiskFreeCmd(struct cmd_syndesc *as, char *arock)
 }
 
 static int
-QuotaCmd(struct cmd_syndesc *as, char *arock)
+QuotaCmd(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 code;
     struct ViceIoctl blob;
@@ -1599,7 +1783,7 @@ QuotaCmd(struct cmd_syndesc *as, char *arock)
 }
 
 static int
-ListMountCmd(struct cmd_syndesc *as, char *arock)
+ListMountCmd(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 code;
     struct ViceIoctl blob;
@@ -1692,6 +1876,20 @@ ListMountCmd(struct cmd_syndesc *as, char *arock)
            strncpy(parent_dir, true_name, last_component - true_name + 1);
            parent_dir[last_component - true_name + 1] = 0;
            last_component++;   /*Skip the slash*/
+#ifdef WIN32
+           if (!InAFS(parent_dir)) {
+               const char * nbname = NetbiosName();
+               int len = (int)strlen(nbname);
+
+               if (parent_dir[0] == '\\' && parent_dir[1] == '\\' &&
+                   parent_dir[len+2] == '\\' &&
+                   parent_dir[len+3] == '\0' &&
+                   !strnicmp(nbname,&parent_dir[2],len))
+               {
+                   sprintf(parent_dir,"\\\\%s\\all\\", nbname);
+               }
+           }
+#endif
        } else {
            /*
             * No slash appears in the given file name.  Set parent_dir to the current
@@ -1711,7 +1909,7 @@ ListMountCmd(struct cmd_syndesc *as, char *arock)
        }
 
        blob.in = last_component;
-       blob.in_size = strlen(last_component)+1;
+       blob.in_size = (long)strlen(last_component)+1;
        blob.out_size = MAXSIZE;
        blob.out = space;
        memset(space, 0, MAXSIZE);
@@ -1737,27 +1935,18 @@ ListMountCmd(struct cmd_syndesc *as, char *arock)
 }
 
 static int
-MakeMountCmd(struct cmd_syndesc *as, char *arock)
+MakeMountCmd(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 code;
     char *cellName, *volName, *tmpName;
 #ifdef WIN32
-    char localCellName[1000];
-#else /* not WIN32 */
+    char localCellName[128];
+#endif
+    char path[1024] = "";
     struct afsconf_cell info;
     struct vldbentry vldbEntry;
-#endif /* not WIN32 */
     struct ViceIoctl blob;
-
-    /*
-
-    defect #3069
-
-    if (as->parms[5].items && !as->parms[2].items) {
-       fprintf(stderr,"%s: must provide cell when creating cellular mount point.\n", pn);
-       return 1;
-    }
-    */
+    char * parent;
 
     if (as->parms[2].items)    /* cell name specified */
        cellName = as->parms[2].items->data;
@@ -1784,21 +1973,56 @@ MakeMountCmd(struct cmd_syndesc *as, char *arock)
         volName = ++tmpName;
     }
 
-    if (!InAFS(Parent(as->parms[0].items->data))) {
-       fprintf(stderr,"%s: mount points must be created within the AFS file system\n", pn);
-       return 1;
+    parent = Parent(as->parms[0].items->data);
+    if (!InAFS(parent)) {
+#ifdef WIN32
+       const char * nbname = NetbiosName();
+       int len = (int)strlen(nbname);
+
+       if (parent[0] == '\\' && parent[1] == '\\' &&
+           parent[len+2] == '\\' &&
+           parent[len+3] == '\0' &&
+           !strnicmp(nbname,&parent[2],len))
+       {
+           sprintf(path,"%sall\\%s", parent, &as->parms[0].items->data[strlen(parent)]);
+           parent = Parent(path);
+           if (!InAFS(parent)) {
+               fprintf(stderr,"%s: mount points must be created within the AFS file system\n", pn);
+               return 1;
+           }
+       } else 
+#endif
+       {
+           fprintf(stderr,"%s: mount points must be created within the AFS file system\n", pn);
+           return 1;
+       }
     }
 
-    if (!cellName) {
-       blob.in_size = 0;
-       blob.out_size = MAXSIZE;
-       blob.out = space;
-       code = pioctl(Parent(as->parms[0].items->data), VIOC_FILE_CELL_NAME, &blob, 1);
+    if ( strlen(path) == 0 )
+       strcpy(path, as->parms[0].items->data);
+
+    if ( IsFreelanceRoot(parent) ) {
+       if ( !IsAdmin() ) {
+           fprintf(stderr,"%s: Only AFS Client Administrators may alter the root.afs volume\n", pn);
+           return 1;
+       }
+
+       if (!cellName) {
+           blob.in_size = 0;
+           blob.out_size = sizeof(localCellName);
+           blob.out = localCellName;
+           code = pioctl(parent, VIOC_GET_WS_CELL, &blob, 1);
+           if (!code)
+               cellName = localCellName;
+       }
+    } else {
+       if (!cellName) {
+           code = GetCell(parent,space);
+            if (code)
+                return 1;
+        }
     }
 
-#ifdef WIN32
-    strcpy(localCellName, (cellName? cellName : space));
-#else /* not win32 */
     code = GetCellName(cellName?cellName:space, &info);
     if (code) {
        return 1;
@@ -1811,14 +2035,13 @@ MakeMountCmd(struct cmd_syndesc *as, char *arock)
        code = VLDBInit(1, &info);
       if (code == 0) {
          /* make the check.  Don't complain if there are problems with init */
-         code = ubik_Call(VL_GetEntryByNameO, uclient, 0, volName, &vldbEntry);
+         code = ubik_VL_GetEntryByNameO(uclient, 0, volName, &vldbEntry);
          if (code == VL_NOENT) {
              fprintf(stderr,"%s: warning, volume %s does not exist in cell %s.\n",
                      pn, volName, cellName ? cellName : space);
          }
       }
     }
-#endif /* not WIN32 */
 
     if (as->parms[3].items)    /* if -rw specified */
        strcpy(space, "%");
@@ -1826,11 +2049,7 @@ MakeMountCmd(struct cmd_syndesc *as, char *arock)
        strcpy(space, "#");
     if (cellName) {
        /* cellular mount point, prepend cell prefix */
-#ifdef WIN32
-       strcat(space, localCellName);
-#else /* not WIN32 */
        strcat(space, info.name);
-#endif /* not WIN32 */
        strcat(space, ":");
     }
     strcat(space, volName);    /* append volume name */
@@ -1840,15 +2059,15 @@ MakeMountCmd(struct cmd_syndesc *as, char *arock)
      * have a symlink system call.
      */
     blob.out_size = 0;
-    blob.in_size = 1 + strlen(space);
+    blob.in_size = 1 + (long)strlen(space);
     blob.in = space;
     blob.out = NULL;
-    code = pioctl(as->parms[0].items->data, VIOC_AFS_CREATE_MT_PT, &blob, 0);
+    code = pioctl(path, VIOC_AFS_CREATE_MT_PT, &blob, 0);
 #else /* not WIN32 */
-    code = symlink(space, as->parms[0].items->data);
+    code = symlink(space, path);
 #endif /* not WIN32 */
     if (code) {
-       Die(errno, as->parms[0].items->data);
+       Die(errno, path);
        return 1;
     }
     return 0;
@@ -1861,7 +2080,7 @@ MakeMountCmd(struct cmd_syndesc *as, char *arock)
  *      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;
     struct cmd_item *ti;
@@ -1876,9 +2095,24 @@ RemoveMountCmd(struct cmd_syndesc *as, char *arock) {
        if (!tp)
            tp = (char *) strrchr(ti->data, '/');
        if (tp) {
-           strncpy(tbuffer, ti->data, code=tp-ti->data+1);  /* the dir name */
+           strncpy(tbuffer, ti->data, code=(afs_int32)(tp-ti->data+1));  /* the dir name */
             tbuffer[code] = 0;
            tp++;   /* skip the slash */
+
+#ifdef WIN32
+           if (!InAFS(tbuffer)) {
+               const char * nbname = NetbiosName();
+               int len = (int)strlen(nbname);
+
+               if (tbuffer[0] == '\\' && tbuffer[1] == '\\' &&
+                   tbuffer[len+2] == '\\' &&
+                   tbuffer[len+3] == '\0' &&
+                   !strnicmp(nbname,&tbuffer[2],len))
+               {
+                   sprintf(tbuffer,"\\\\%s\\all\\", nbname);
+               }
+           }
+#endif
        } else {
            fs_ExtractDriveLetter(ti->data, tbuffer);
            strcat(tbuffer, ".");
@@ -1886,7 +2120,7 @@ RemoveMountCmd(struct cmd_syndesc *as, char *arock) {
             fs_StripDriveLetter(tp, tp, 0);
        }
        blob.in = tp;
-       blob.in_size = strlen(tp)+1;
+       blob.in_size = (long)strlen(tp)+1;
        blob.out = lsbuffer;
        blob.out_size = sizeof(lsbuffer);
        code = pioctl(tbuffer, VIOC_AFS_STAT_MT_PT, &blob, 0);
@@ -1899,9 +2133,16 @@ RemoveMountCmd(struct cmd_syndesc *as, char *arock) {
             error = 1;
            continue;   /* don't bother trying */
        }
-       blob.out_size = 0;
+
+        if ( IsFreelanceRoot(tbuffer) && !IsAdmin() ) {
+            fprintf(stderr,"%s: Only AFS Client Administrators may alter the root.afs volume\n", pn);
+            error = 1;
+            continue;   /* skip */
+        }
+
+        blob.out_size = 0;
        blob.in = tp;
-       blob.in_size = strlen(tp)+1;
+       blob.in_size = (long)strlen(tp)+1;
        code = pioctl(tbuffer, VIOC_AFS_DELETE_MT_PT, &blob, 0);
        if (code) {
            Die(errno, ti->data);
@@ -1915,7 +2156,7 @@ 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;
@@ -1950,7 +2191,7 @@ CheckServersCmd(struct cmd_syndesc *as, char *arock)
            return 1;
        }
        strcpy(checkserv.tbuffer,info.name);
-       checkserv.tsize=strlen(info.name)+1;
+       checkserv.tsize=(int)strlen(info.name)+1;
     } else {
         strcpy(checkserv.tbuffer,"\0");
         checkserv.tsize=0;
@@ -1962,7 +2203,7 @@ CheckServersCmd(struct cmd_syndesc *as, char *arock)
         /* sanity check */
         if(checkserv.tinterval<0) {
             printf("Warning: The negative -interval is ignored; treated as an inquiry\n");
-            checkserv.tinterval=0;
+            checkserv.tinterval=-1;
         } else if(checkserv.tinterval> 600) {
             printf("Warning: The maximum -interval value is 10 mins (600 secs)\n");
             checkserv.tinterval=600;   /* 10 min max interval */
@@ -1971,7 +2212,7 @@ CheckServersCmd(struct cmd_syndesc *as, char *arock)
         checkserv.tinterval = -1;      /* don't change current interval */
     }
 
-    if ( checkserv.tinterval != 0 ) {
+    if ( checkserv.tinterval >= 0 ) {
 #ifdef WIN32
         if ( !IsAdmin() ) {
             fprintf (stderr,"Permission denied: requires AFS Client Administrator access.\n");
@@ -2021,7 +2262,7 @@ 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;
@@ -2064,7 +2305,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;
@@ -2082,7 +2323,7 @@ CheckVolumesCmd(struct cmd_syndesc *as, char *arock)
 }
 
 static int
-SetCacheSizeCmd(struct cmd_syndesc *as, char *arock)
+SetCacheSizeCmd(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 code;
     struct ViceIoctl blob;
@@ -2125,34 +2366,33 @@ SetCacheSizeCmd(struct cmd_syndesc *as, char *arock)
     return 0;
 }
 
-#define MAXGCSIZE      16
 static int
-GetCacheParmsCmd(struct cmd_syndesc *as, char *arock)
+GetCacheParmsCmd(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 code;
     struct ViceIoctl blob;
-    afs_int32 parms[MAXGCSIZE];
+    cm_cacheParms_t parms;
 
-    memset(parms, 0, sizeof(parms));
+    memset(&parms, 0, sizeof(parms));
     blob.in = NULL;
     blob.in_size = 0;
     blob.out_size = sizeof(parms);
-    blob.out = (char *) parms;
+    blob.out = (char *) &parms;
     code = pioctl(0, VIOCGETCACHEPARMS, &blob, 1);
     if (code) {
        Die(errno, NULL);
         return 1;
     }
      
-    printf("AFS using %d of the cache's available %d 1K byte blocks.\n",
-           parms[1], parms[0]);
-    if (parms[1] > parms[0])
+    printf("AFS using %I64u of the cache's available %I64u 1K byte blocks.\n",
+           parms.parms[1], parms.parms[0]);
+    if (parms.parms[1] > parms.parms[0])
         printf("[Cache guideline temporarily deliberately exceeded; it will be adjusted down but you may wish to increase the cache size.]\n");
     return 0;
 }
 
 static int
-ListCellsCmd(struct cmd_syndesc *as, char *arock)
+ListCellsCmd(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 code;
     afs_int32 i, j, *lp, magic, size;
@@ -2212,7 +2452,7 @@ ListCellsCmd(struct cmd_syndesc *as, char *arock)
 
 #ifndef WIN32
 static int
-ListAliasesCmd(struct cmd_syndesc *as, char *arock)
+ListAliasesCmd(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 code, i;
     char *tp, *aliasName, *realName;
@@ -2242,7 +2482,7 @@ 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;
@@ -2282,7 +2522,7 @@ CallBackRxConnCmd(struct cmd_syndesc *as, char *arock)
 #endif /* WIN32 */
 
 static int
-NewCellCmd(struct cmd_syndesc *as, char *arock)
+NewCellCmd(struct cmd_syndesc *as, void *arock)
 {
 #ifndef WIN32
     afs_int32 code, linkedstate=0, size=0, *lp;
@@ -2379,7 +2619,7 @@ NewCellCmd(struct cmd_syndesc *as, char *arock)
 
 #ifndef WIN32
 static int
-NewAliasCmd(struct cmd_syndesc *as, char *arock)
+NewAliasCmd(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 code;
     struct ViceIoctl blob;
@@ -2415,16 +2655,54 @@ NewAliasCmd(struct cmd_syndesc *as, char *arock)
 #endif /* WIN32 */
 
 static int
-WhichCellCmd(struct cmd_syndesc *as, char *arock)
+WhichCellCmd(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 code;
     struct cmd_item *ti;
+    struct ViceIoctl blob;
     int error = 0;
-    char cell[MAXCELLCHARS];
+    int literal = 0;
+    cm_ioctlQueryOptions_t options;
+
+    if (as->parms[1].items)
+        literal = 1;
     
     SetDotDefault(&as->parms[0].items);
     for(ti=as->parms[0].items; ti; ti=ti->next) {
-        code = GetCell(ti->data, cell);
+        cm_fid_t fid;
+        afs_uint32 filetype;
+       char cell[MAXCELLCHARS];
+
+        /* once per file */
+        memset(&fid, 0, sizeof(fid));
+        memset(&options, 0, sizeof(options));
+        filetype = 0;
+        options.size = sizeof(options);
+        options.field_flags |= CM_IOCTL_QOPTS_FIELD_LITERAL;
+        options.literal = literal;
+       blob.in_size = options.size;    /* no variable length data */
+        blob.in = &options;
+
+        blob.out_size = sizeof(cm_fid_t);
+        blob.out = (char *) &fid;
+        if (0 == pioctl(ti->data, VIOCGETFID, &blob, 1)) {
+            options.field_flags |= CM_IOCTL_QOPTS_FIELD_FID;
+            options.fid = fid;
+        } else {
+           Die(errno, ti->data);
+           error = 1;
+           continue;
+        }
+
+        blob.out_size = sizeof(filetype);
+        blob.out = &filetype;
+
+        code = pioctl(ti->data, VIOC_GETFILETYPE, &blob, 1);
+
+        blob.out_size = MAXCELLCHARS;
+        blob.out = cell;
+
+        code = pioctl(ti->data, VIOC_FILE_CELL_NAME, &blob, 1);
        if (code) {
            if (errno == ENOENT)
                fprintf(stderr,"%s: no such cell as '%s'\n", pn, ti->data);
@@ -2433,13 +2711,15 @@ WhichCellCmd(struct cmd_syndesc *as, char *arock)
            error = 1;
            continue;
        }
-        printf("File %s lives in cell '%s'\n", ti->data, cell);
+        printf("%s %s lives in cell '%s'\n",
+                filetypestr(filetype),
+                ti->data, cell);
     }
     return error;
 }
 
 static int
-WSCellCmd(struct cmd_syndesc *as, char *arock)
+WSCellCmd(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 code;
     struct ViceIoctl blob;
@@ -2462,15 +2742,16 @@ WSCellCmd(struct cmd_syndesc *as, char *arock)
 
 /*
 static int
-PrimaryCellCmd(struct cmd_syndesc *as, char *arock)
+PrimaryCellCmd(struct cmd_syndesc *as, void *arock)
 {
     fprintf(stderr,"This command is obsolete, as is the concept of a primary token.\n");
     return 0;
 }
 */
 
+#ifndef AFS_NT40_ENV
 static int
-MonitorCmd(struct cmd_syndesc *as, char *arock)
+MonitorCmd(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 code;
     struct ViceIoctl blob;
@@ -2528,9 +2809,10 @@ MonitorCmd(struct cmd_syndesc *as, char *arock)
     }
     return 0;
 }
+#endif /* AFS_NT40_ENV */
 
 static int
-SysNameCmd(struct cmd_syndesc *as, char *arock)
+SysNameCmd(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 code;
     struct ViceIoctl blob;
@@ -2561,7 +2843,7 @@ SysNameCmd(struct cmd_syndesc *as, char *arock)
     input += sizeof(afs_int32);
     for (; ti; ti = ti->next) {
         setp++;
-        blob.in_size += strlen(ti->data) + 1;
+        blob.in_size += (long)strlen(ti->data) + 1;
         if (blob.in_size > MAXSIZE) {
             fprintf(stderr, "%s: sysname%s too long.\n", pn,
                      setp > 1 ? "s" : "");
@@ -2599,8 +2881,9 @@ SysNameCmd(struct cmd_syndesc *as, char *arock)
     return 0;
 }
 
+#ifndef AFS_NT40_ENV
 static char *exported_types[] = {"null", "nfs", ""};
-static int ExportAfsCmd(struct cmd_syndesc *as, char *arock)
+static int ExportAfsCmd(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 code;
     struct ViceIoctl blob;
@@ -2700,10 +2983,10 @@ static int ExportAfsCmd(struct cmd_syndesc *as, char *arock)
     }
     return 0;
 }
-
+#endif
 
 static int
-GetCellCmd(struct cmd_syndesc *as, char *arock)
+GetCellCmd(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 code;
     struct ViceIoctl blob;
@@ -2725,7 +3008,7 @@ GetCellCmd(struct cmd_syndesc *as, char *arock)
             error = 1;
            continue;
        }
-       blob.in_size = 1+strlen(info.name);
+       blob.in_size = 1+(long)strlen(info.name);
        blob.in = info.name;
        code = pioctl(0, VIOC_GETCELLSTATUS, &blob, 1);
        if (code) {
@@ -2752,7 +3035,7 @@ GetCellCmd(struct cmd_syndesc *as, char *arock)
     return error;
 }
 
-static int SetCellCmd(struct cmd_syndesc *as, char *arock)
+static int SetCellCmd(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 code;
     struct ViceIoctl blob;
@@ -2819,13 +3102,7 @@ GetCellName(char *cellNamep, struct afsconf_cell *infop)
     strcpy(infop->name, cellNamep);
     return 0;
 }
-
-static int
-VLDBInit(int noAuthFlag, struct afsconf_cell *infop)
-{
-    return 0;
-}
-#else /* not WIN32 */
+#else
 static int
 GetCellName(char *cellName, struct afsconf_cell *info)
 {
@@ -2849,14 +3126,14 @@ GetCellName(char *cellName, struct afsconf_cell *info)
 
     return 0;
 }
-
+#endif /* not WIN32 */
 
 static int
 VLDBInit(int noAuthFlag, struct afsconf_cell *info)
 {
     afs_int32 code;
 
-    code = ugen_ClientInit(noAuthFlag, AFSDIR_CLIENT_ETC_DIRPATH, 
+    code = ugen_ClientInit(noAuthFlag, (char *)AFSDIR_CLIENT_ETC_DIRPATH, 
                           info->name, 0, &uclient, 
                            NULL, pn, rxkad_clear,
                            VLDB_MAXSERVERS, AFSCONF_VLDBSERVICE, 50,
@@ -2864,7 +3141,6 @@ VLDBInit(int noAuthFlag, struct afsconf_cell *info)
     rxInitDone = 1;
     return code;
 }
-#endif /* not WIN32 */
 
 static struct ViceIoctl gblob;
 static int debug = 0;
@@ -2888,7 +3164,7 @@ pokeServers(void)
     code = pioctl(0, VIOC_SETSPREFS, &gblob, 1);
 
     ssp = (cm_SSetPref_t *)space;
-    gblob.in_size = ((char *)&(ssp->servers[0])) - (char *)ssp;
+    gblob.in_size = (long)(((char *)&(ssp->servers[0])) - (char *)ssp);
     gblob.in = space;
     return code;
 }
@@ -3046,7 +3322,7 @@ static BOOL IsWindowsNT (void)
 
 #ifdef WIN32
 static int
-SetPrefCmd(struct cmd_syndesc *as, char * arock)
+SetPrefCmd(struct cmd_syndesc *as, void * arock)
 {
     FILE *infd;
     afs_int32 code;
@@ -3058,7 +3334,7 @@ SetPrefCmd(struct cmd_syndesc *as, char * arock)
     ssp = (cm_SSetPref_t *)space;
     ssp->flags = 0;
     ssp->num_servers = 0;
-    gblob.in_size = ((char*)&(ssp->servers[0])) - (char *)ssp;
+    gblob.in_size = (long)(((char*)&(ssp->servers[0])) - (char *)ssp);
     gblob.in = space;
     gblob.out = space;
     gblob.out_size = MAXSIZE;
@@ -3106,7 +3382,7 @@ SetPrefCmd(struct cmd_syndesc *as, char * arock)
         printf("now working on vlservers, code=%d, errno=%d\n",code,errno);
 
     ssp = (cm_SSetPref_t *)space;
-    gblob.in_size = ((char*)&(ssp->servers[0])) - (char *)ssp;
+    gblob.in_size = (long)(((char*)&(ssp->servers[0])) - (char *)ssp);
     gblob.in = space;
     ssp->flags = CM_SPREF_VLONLY;
     ssp->num_servers = 0;
@@ -3136,7 +3412,7 @@ SetPrefCmd(struct cmd_syndesc *as, char * arock)
 }
 #else
 static int
-SetPrefCmd(struct cmd_syndesc *as, char *arock)
+SetPrefCmd(struct cmd_syndesc *as, void *arock)
 {
     FILE *infd;
     afs_int32 code;
@@ -3242,7 +3518,7 @@ SetPrefCmd(struct cmd_syndesc *as, char *arock)
 
 #ifdef WIN32
 static int 
-GetPrefCmd(struct cmd_syndesc *as, char *arock)
+GetPrefCmd(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 code;
     struct cmd_item *ti;
@@ -3313,7 +3589,7 @@ GetPrefCmd(struct cmd_syndesc *as, char *arock)
 }
 #else
 static int
-GetPrefCmd(struct cmd_syndesc *as, char *arock)
+GetPrefCmd(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 code;
     struct cmd_item *ti;
@@ -3384,7 +3660,56 @@ GetPrefCmd(struct cmd_syndesc *as, char *arock)
 #endif /* WIN32 */
 
 static int
-TraceCmd(struct cmd_syndesc *asp, char *arock)
+UuidCmd(struct cmd_syndesc *asp, void *arock)
+{
+    long code;
+    long inValue;
+    afsUUID outValue;
+    struct ViceIoctl blob;
+    char * uuidstring = NULL;
+
+    if (asp->parms[0].items) {
+#ifdef WIN32
+        if ( !IsAdmin() ) {
+            fprintf (stderr,"Permission denied: requires AFS Client Administrator access.\n");
+            return EACCES;
+        }
+#else
+        if (geteuid()) {
+            fprintf (stderr, "Permission denied: requires root access.\n");
+            return EACCES;
+        }
+#endif
+        inValue = 1;            /* generate new UUID */
+    } else {
+        inValue = 0;            /* just show the current UUID */
+    }
+
+    blob.in_size = sizeof(inValue);
+    blob.in = (char *) &inValue;
+    blob.out_size = sizeof(outValue);
+    blob.out = (char *) &outValue;
+
+    code = pioctl(NULL, VIOC_UUIDCTL, &blob, 1);
+    if (code) {
+        Die(errno, NULL);
+        return code;
+    }
+
+    UuidToString((UUID *) &outValue, &uuidstring);
+
+    printf("%sUUID: %s",
+           ((inValue == 1)?"New ":""),
+           uuidstring);
+
+    if (uuidstring)
+        RpcStringFree(&uuidstring);
+
+    return 0;
+}
+
+static int
+TraceCmd(struct cmd_syndesc *asp, void *arock)
 {
     long code;
     struct ViceIoctl blob;
@@ -3446,7 +3771,7 @@ static void sbusage(void)
 
 /* fs sb -kbytes 9999 -files *.o -default 64 */
 static int
-StoreBehindCmd(struct cmd_syndesc *as, char *arock)
+StoreBehindCmd(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 code = 0;
     struct ViceIoctl blob;
@@ -3553,7 +3878,7 @@ StoreBehindCmd(struct cmd_syndesc *as, char *arock)
 }
 
 static afs_int32 
-SetCryptCmd(struct cmd_syndesc *as, char *arock)
+SetCryptCmd(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 code = 0, flag;
     struct ViceIoctl blob;
@@ -3586,7 +3911,7 @@ SetCryptCmd(struct cmd_syndesc *as, char *arock)
 }
 
 static afs_int32 
-GetCryptCmd(struct cmd_syndesc *as, char *arock)
+GetCryptCmd(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 code = 0, flag;
     struct ViceIoctl blob;
@@ -3614,25 +3939,30 @@ GetCryptCmd(struct cmd_syndesc *as, char *arock)
 }
 
 static int
-MemDumpCmd(struct cmd_syndesc *asp, char *arock)
+MemDumpCmd(struct cmd_syndesc *asp, void *arock)
 {
     long code;
     struct ViceIoctl blob;
-    long inValue;
+    long inValue = 0;
     long outValue;
-  
+
+    if ( !IsAdmin() ) {
+        fprintf (stderr,"Permission denied: requires AFS Client Administrator access.\n");
+        return EACCES;
+    }
+
     if ((asp->parms[0].items && asp->parms[1].items)) {
         fprintf(stderr, "%s trace: must use at most one of '-begin' or '-end'\n", pn);
         return EINVAL;
     }
-  
+
     /* determine if we're turning this tracing on or off */
-    inValue = 0;
     if (asp->parms[0].items)
         inValue = 1;            /* begin */
-    else if (asp->parms[1].items) 
+    else if (asp->parms[1].items)
         inValue = 0;            /* end */
-  
+
+
     blob.in_size = sizeof(long);
     blob.in = (char *) &inValue;
     blob.out_size = sizeof(long);
@@ -3644,19 +3974,68 @@ MemDumpCmd(struct cmd_syndesc *asp, char *arock)
         return code;
     }
 
-    if (outValue) printf("AFS memdump begin.\n");
-    else printf("AFS memdump end.\n");
+    if (!outValue) { 
+        printf("AFS memdump created.\n");
+        return 0;
+    } else {
+        printf("AFS memdump failed.\n");
+        return -1;
+    }
+}
 
-    return 0;
+static int
+MiniDumpCmd(struct cmd_syndesc *asp, void *arock)
+{
+    BOOL success = 0;
+    SERVICE_STATUS status;
+    SC_HANDLE hManager = NULL;
+    SC_HANDLE hService = NULL;
+
+    if ( !IsAdmin() ) {
+        fprintf (stderr,"Permission denied: requires AFS Client Administrator access.\n");
+        return EACCES;
+    }
+
+    hManager = OpenSCManager(NULL, NULL, SC_MANAGER_CONNECT);
+    if (!hManager)
+        goto failure;
+
+    hService = OpenService(hManager, "TransarcAFSDaemon", SERVICE_USER_DEFINED_CONTROL);
+    if (!hService)
+        goto failure;
+
+    success = ControlService(hService, SERVICE_CONTROL_CUSTOM_DUMP, &status);
+
+    if (success) {
+        CloseServiceHandle(hService);
+        CloseServiceHandle(hManager);
+
+        printf("AFS minidump generated.\n");
+        return 0;
+    }
+
+  failure: 
+    if (hService)
+        CloseServiceHandle(hService);
+    if (hManager)
+        CloseServiceHandle(hManager);
+
+    printf("AFS minidump failed.\n");
+    return -1;
 }
 
 static int
-CSCPolicyCmd(struct cmd_syndesc *asp, char *arock)
+CSCPolicyCmd(struct cmd_syndesc *asp, void *arock)
 {
     struct cmd_item *ti;
     char *share = NULL;
     HKEY hkCSCPolicy;
 
+    if ( !IsAdmin() ) {
+        fprintf (stderr,"Permission denied: requires AFS Client Administrator access.\n");
+        return EACCES;
+    }
+
     for(ti=asp->parms[0].items; ti;ti=ti->next) {
         share = ti->data;
         if (share)
@@ -3670,7 +4049,7 @@ CSCPolicyCmd(struct cmd_syndesc *asp, char *arock)
         char *policy;
 
         RegCreateKeyEx( HKEY_LOCAL_MACHINE, 
-                        "SOFTWARE\\OpenAFS\\Client\\CSCPolicy",
+                         AFSREG_CLT_OPENAFS_SUBKEY "\\CSCPolicy",
                         0, 
                         "AFS", 
                         REG_OPTION_NON_VOLATILE,
@@ -3701,7 +4080,7 @@ CSCPolicyCmd(struct cmd_syndesc *asp, char *arock)
         if (asp->parms[4].items)
             policy = "disable";
                
-        RegSetValueEx( hkCSCPolicy, share, 0, REG_SZ, policy, strlen(policy)+1);
+        RegSetValueEx( hkCSCPolicy, share, 0, REG_SZ, policy, (DWORD)strlen(policy)+1);
                
         printf("CSC policy on share \"%s\" changed to \"%s\".\n\n", share, policy);
         printf("Close all applications that accessed files on this share or restart AFS Client for the change to take effect.\n"); 
@@ -3718,7 +4097,7 @@ CSCPolicyCmd(struct cmd_syndesc *asp, char *arock)
         /* list current csc policies */
 
         RegCreateKeyEx( HKEY_LOCAL_MACHINE, 
-                        "SOFTWARE\\OpenAFS\\Client\\CSCPolicy",
+                        AFSREG_CLT_OPENAFS_SUBKEY "\\CSCPolicy",
                         0, 
                         "AFS", 
                         REG_OPTION_NON_VOLATILE,
@@ -3760,7 +4139,7 @@ CSCPolicyCmd(struct cmd_syndesc *asp, char *arock)
 #ifndef WIN32
 /* 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;
@@ -3806,7 +4185,7 @@ 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;
@@ -3880,7 +4259,7 @@ 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;
@@ -3994,14 +4373,14 @@ FlushMountCmd(struct cmd_syndesc *as, char *arock)
     }
     return error;
 }
+#endif /* WIN32 */
 
 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;
@@ -4031,12 +4410,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;
@@ -4064,7 +4442,86 @@ RxStatPeerCmd(struct cmd_syndesc *as, char *arock)
 
     return 0;
 }
-#endif /* WIN32 */
+
+static int
+TestVolStatCmd(struct cmd_syndesc *as, void *arock)
+{
+    afs_int32 code;
+    struct VolStatTest test;
+    struct ViceIoctl blob;
+    char * tp;
+    afs_uint32 n;
+
+    memset(&test, 0, sizeof(test));
+
+    if (as->parms[0].items) {  /* -network */
+        tp = as->parms[0].items->data;
+        if (strcmp(tp, "up") == 0)
+            test.flags |= VOLSTAT_TEST_NETWORK_UP;
+        else if (strcmp(tp, "down") == 0)
+            test.flags |= VOLSTAT_TEST_NETWORK_DOWN;
+        else {
+            fprintf (stderr, "%s: %s must be \"up\" or \"down\".\n", pn, tp);
+            return EINVAL;
+        }
+    }
+    if (as->parms[1].items) {  /* check */
+        test.flags |= VOLSTAT_TEST_CHECK_VOLUME;
+    }
+    if (as->parms[2].items) {  /* cell */
+        tp = as->parms[2].items->data;
+        n = atoi(tp);
+        if (n != 0)
+            test.fid.cell = n;
+        else {
+            strncpy(test.cellname, tp, sizeof(test.cellname));
+            test.cellname[sizeof(test.cellname)-1] = '\0';
+        }
+    }
+    if (as->parms[3].items) {  /* volume */
+        tp = as->parms[3].items->data;
+        n = atoi(tp);
+        if (n != 0)
+            test.fid.volume = n;
+        else {
+            strncpy(test.volname, tp, sizeof(test.volname));
+            test.volname[sizeof(test.volname)-1] = '\0';
+        }
+    }
+    if (as->parms[4].items) {   /* state */
+        tp = as->parms[4].items->data;
+        if (strcmp(tp, "online") == 0)
+            test.state = vl_online;
+        else if (strcmp(tp, "busy") == 0)
+            test.state = vl_busy;
+        else if (strcmp(tp, "offline") == 0)
+            test.state = vl_offline;
+        else if (strcmp(tp, "down") == 0)
+            test.state = vl_alldown;
+        else {
+            fprintf (stderr, "%s: %s must be \"online\", \"busy\", \"offline\" or \"down\".\n", pn, tp);
+            return EINVAL;
+        }
+    }
+
+    if ((test.fid.cell || test.cellname[0]) && !(test.fid.volume || test.volname[0]) ||
+         !(test.fid.cell || test.cellname[0]) && (test.fid.volume || test.volname[0])) {
+        fprintf (stderr, "%s: both a cell and a volume must be specified.\n", pn, tp);
+        return EINVAL;
+    }
+
+    blob.in = (char *)&test;
+    blob.in_size = sizeof(test);
+    blob.out_size = 0;
+
+    code = pioctl(NULL, VIOC_VOLSTAT_TEST, &blob, 1);
+    if (code != 0) {
+       Die(errno, NULL);
+       return 1;
+    }
+
+    return 0;
+}
 
 #ifndef WIN32
 #include "AFS_component_version_number.c"
@@ -4099,32 +4556,32 @@ main(int argc, char **argv)
     osi_Init();
 
 #ifndef WIN32
-    ts = cmd_CreateSyntax("getclientaddrs", GetClientAddrsCmd, 0,
+    ts = cmd_CreateSyntax("getclientaddrs", GetClientAddrsCmd, NULL,
                          "get client network interface addresses");
     cmd_CreateAlias(ts, "gc");
 
-    ts = cmd_CreateSyntax("setclientaddrs", SetClientAddrsCmd, 0,
+    ts = cmd_CreateSyntax("setclientaddrs", SetClientAddrsCmd, NULL,
                          "set client network interface addresses");
     cmd_AddParm(ts, "-address", CMD_LIST, CMD_OPTIONAL | CMD_EXPANDS,
                 "client network interfaces");
     cmd_CreateAlias(ts, "sc");
 #endif /* WIN32 */
 
-    ts = cmd_CreateSyntax("setserverprefs", SetPrefCmd, 0, "set server ranks");
+    ts = cmd_CreateSyntax("setserverprefs", SetPrefCmd, NULL, "set server ranks");
     cmd_AddParm(ts, "-servers", CMD_LIST, CMD_OPTIONAL|CMD_EXPANDS, "fileserver names and ranks");
     cmd_AddParm(ts, "-vlservers", CMD_LIST, CMD_OPTIONAL|CMD_EXPANDS, "VL server names and ranks");
     cmd_AddParm(ts, "-file", CMD_SINGLE, CMD_OPTIONAL, "input from named file");
     cmd_AddParm(ts, "-stdin", CMD_FLAG, CMD_OPTIONAL, "input from stdin");
     cmd_CreateAlias(ts, "sp");
 
-    ts = cmd_CreateSyntax("getserverprefs", GetPrefCmd, 0, "get server ranks");
+    ts = cmd_CreateSyntax("getserverprefs", GetPrefCmd, NULL, "get server ranks");
     cmd_AddParm(ts, "-file", CMD_SINGLE, CMD_OPTIONAL, "output to named file");
     cmd_AddParm(ts, "-numeric", CMD_FLAG, CMD_OPTIONAL, "addresses only");
     cmd_AddParm(ts, "-vlservers", CMD_FLAG, CMD_OPTIONAL, "VL servers");
     /* 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, "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");
@@ -4134,17 +4591,17 @@ main(int argc, char **argv)
     cmd_AddParm(ts, "-if", CMD_FLAG, CMD_OPTIONAL, "initial file acl (DFS only)");
     cmd_CreateAlias(ts, "sa");
     
-    ts = cmd_CreateSyntax("listacl", ListACLCmd, 0, "list access control list");
+    ts = cmd_CreateSyntax("listacl", ListACLCmd, NULL, "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_CreateAlias(ts, "la");
     
-    ts = cmd_CreateSyntax("cleanacl", CleanACLCmd, 0, "clean up access control list");
+    ts = cmd_CreateSyntax("cleanacl", CleanACLCmd, NULL, "clean up access control list");
     cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
     
-    ts = cmd_CreateSyntax("copyacl", CopyACLCmd, 0, "copy access control list");
+    ts = cmd_CreateSyntax("copyacl", CopyACLCmd, NULL, "copy access control list");
     cmd_AddParm(ts, "-fromdir", CMD_SINGLE, 0, "source directory (or DFS file)");
     cmd_AddParm(ts, "-todir", CMD_LIST, 0, "destination directory (or DFS file)");
     cmd_AddParm(ts, "-clear", CMD_FLAG, CMD_OPTIONAL, "first clear dest access list");
@@ -4154,16 +4611,17 @@ 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, "flush file from cache");
     cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
+    cmd_AddParm(ts, "-literal", CMD_FLAG, CMD_OPTIONAL, "literal evaluation of mountpoints and symlinks");
     
 #ifndef WIN32
-    ts = cmd_CreateSyntax("flushmount", FlushMountCmd, 0,
+    ts = cmd_CreateSyntax("flushmount", FlushMountCmd, NULL,
                            "flush mount symlink from cache");
     cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
 #endif
 
-    ts = cmd_CreateSyntax("setvol", SetVolCmd, 0, "set volume status");
+    ts = cmd_CreateSyntax("setvol", SetVolCmd, NULL, "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");
 #ifdef notdef
@@ -4173,29 +4631,30 @@ main(int argc, char **argv)
     cmd_AddParm(ts, "-offlinemsg", CMD_SINGLE, CMD_OPTIONAL, "offline message");
     cmd_CreateAlias(ts, "sv");
     
-    ts = cmd_CreateSyntax("messages", MessagesCmd, 0, "control Cache Manager messages");
+    ts = cmd_CreateSyntax("messages", MessagesCmd, NULL, "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, "display file/volume status");
     cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
+    cmd_AddParm(ts, "-literal", CMD_FLAG, CMD_OPTIONAL, "literal evaluation of mountpoints and symlinks");
     cmd_CreateAlias(ts, "lv");
     cmd_CreateAlias(ts, "listvol");
     
-    ts = cmd_CreateSyntax("listquota", ListQuotaCmd, 0, "list volume quota");
+    ts = cmd_CreateSyntax("listquota", ListQuotaCmd, NULL, "list volume quota");
     cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
     cmd_CreateAlias(ts, "lq");
     
-    ts = cmd_CreateSyntax("diskfree", DiskFreeCmd, 0, "show server disk space usage");
+    ts = cmd_CreateSyntax("diskfree", DiskFreeCmd, NULL, "show server disk space usage");
     cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
     cmd_CreateAlias(ts, "df");
     
-    ts = cmd_CreateSyntax("quota", QuotaCmd, 0, "show volume quota usage");
+    ts = cmd_CreateSyntax("quota", QuotaCmd, NULL, "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, "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, "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");
@@ -4210,31 +4669,31 @@ main(int argc, char **argv)
     */
 
     
-    ts = cmd_CreateSyntax("rmmount", RemoveMountCmd, 0, "remove mount point");
+    ts = cmd_CreateSyntax("rmmount", RemoveMountCmd, NULL, "remove mount point");
     cmd_AddParm(ts, "-dir", CMD_LIST, 0, "directory");
     
-    ts = cmd_CreateSyntax("checkservers", CheckServersCmd, 0, "check local cell's servers");
+    ts = cmd_CreateSyntax("checkservers", CheckServersCmd, NULL, "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");
     cmd_AddParm(ts, "-fast", CMD_FLAG, CMD_OPTIONAL, "just list, don't check");
-       cmd_AddParm(ts,"-interval",CMD_SINGLE,CMD_OPTIONAL,"seconds between probes");
+    cmd_AddParm(ts,"-interval",CMD_SINGLE,CMD_OPTIONAL,"seconds between probes");
     
-    ts = cmd_CreateSyntax("checkvolumes", CheckVolumesCmd,0, "check volumeID/name mappings");
+    ts = cmd_CreateSyntax("checkvolumes", CheckVolumesCmd, NULL, "check volumeID/name mappings");
     cmd_CreateAlias(ts, "checkbackups");
 
     
-    ts = cmd_CreateSyntax("setcachesize", SetCacheSizeCmd, 0, "set cache size");
+    ts = cmd_CreateSyntax("setcachesize", SetCacheSizeCmd, NULL, "set cache size");
     cmd_AddParm(ts, "-blocks", CMD_SINGLE, CMD_OPTIONAL, "size in 1K byte blocks (0 => reset)");
     cmd_CreateAlias(ts, "cachesize");
 
     cmd_AddParm(ts, "-reset", CMD_FLAG, CMD_OPTIONAL, "reset size back to boot value");
     
-    ts = cmd_CreateSyntax("getcacheparms", GetCacheParmsCmd, 0, "get cache usage info");
+    ts = cmd_CreateSyntax("getcacheparms", GetCacheParmsCmd, NULL, "get cache usage info");
 
-    ts = cmd_CreateSyntax("listcells", ListCellsCmd, 0, "list configured cells");
+    ts = cmd_CreateSyntax("listcells", ListCellsCmd, NULL, "list configured cells");
     cmd_AddParm(ts, "-numeric", CMD_FLAG, CMD_OPTIONAL, "addresses only");
     
-    ts = cmd_CreateSyntax("setquota", SetQuotaCmd, 0, "set volume quota");
+    ts = cmd_CreateSyntax("setquota", SetQuotaCmd, NULL, "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
@@ -4242,7 +4701,7 @@ main(int argc, char **argv)
 #endif
     cmd_CreateAlias(ts, "sq");
 
-    ts = cmd_CreateSyntax("newcell", NewCellCmd, 0, "configure new cell");
+    ts = cmd_CreateSyntax("newcell", NewCellCmd, NULL, "configure new cell");
 #ifndef WIN32
     cmd_AddParm(ts, "-name", CMD_SINGLE, 0, "cell name");
     cmd_AddParm(ts, "-servers", CMD_LIST, CMD_REQUIRED, "primary servers");
@@ -4259,104 +4718,120 @@ main(int argc, char **argv)
     cmd_AddParm(ts, "-vlport", CMD_SINGLE, CMD_OPTIONAL, "cell's vldb server port");
 #endif
 
-    ts = cmd_CreateSyntax("newalias", NewAliasCmd, 0,
+    ts = cmd_CreateSyntax("newalias", NewAliasCmd, NULL,
                          "configure new cell alias");
     cmd_AddParm(ts, "-alias", CMD_SINGLE, 0, "alias name");
     cmd_AddParm(ts, "-name", CMD_SINGLE, 0, "real name of cell");
 #endif
 
-    ts = cmd_CreateSyntax("whichcell", WhichCellCmd, 0, "list file's cell");
+    ts = cmd_CreateSyntax("whichcell", WhichCellCmd, NULL, "list file's cell");
     cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
+    cmd_AddParm(ts, "-literal", CMD_FLAG, CMD_OPTIONAL, "literal evaluation of mountpoints and symlinks");
 
-    ts = cmd_CreateSyntax("whereis", WhereIsCmd, 0, "list file's location");
+    ts = cmd_CreateSyntax("whereis", WhereIsCmd, NULL, "list file's location");
     cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
+    cmd_AddParm(ts, "-literal", CMD_FLAG, CMD_OPTIONAL, "literal evaluation of mountpoints and symlinks");
 
-    ts = cmd_CreateSyntax("wscell", WSCellCmd, 0, "list workstation's cell");
+    ts = cmd_CreateSyntax("wscell", WSCellCmd, NULL, "list workstation's cell");
     
     /*
      ts = cmd_CreateSyntax("primarycell", PrimaryCellCmd, 0, "obsolete (listed primary cell)");
      */
     
-    ts = cmd_CreateSyntax("monitor", MonitorCmd, 0, "set cache monitor host address");
+#ifndef AFS_NT40_ENV
+    ts = cmd_CreateSyntax("monitor", MonitorCmd, NULL, "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");
+#endif
+
+    ts = cmd_CreateSyntax("getcellstatus", GetCellCmd, NULL, "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, "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, "flush all data in volume");
+
+    ts = cmd_CreateSyntax("flushall", FlushAllCmd, NULL, "flush all data");
+
+    ts = cmd_CreateSyntax("flushvolume", FlushVolumeCmd, NULL, "flush all data in volume");
     cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
 
-    ts = cmd_CreateSyntax("sysname", SysNameCmd, 0, "get/set sysname (i.e. @sys) value");
+    ts = cmd_CreateSyntax("sysname", SysNameCmd, NULL, "get/set sysname (i.e. @sys) value");
     cmd_AddParm(ts, "-newsys", CMD_LIST, CMD_OPTIONAL, "new sysname");
 
-    ts = cmd_CreateSyntax("exportafs", ExportAfsCmd, 0, "enable/disable translators to AFS");
+#ifndef AFS_NT40_ENV
+    ts = cmd_CreateSyntax("exportafs", ExportAfsCmd, NULL, "enable/disable translators to AFS");
     cmd_AddParm(ts, "-type", CMD_SINGLE, 0, "exporter name");
     cmd_AddParm(ts, "-start", CMD_SINGLE, CMD_OPTIONAL, "start/stop translator ('on' or 'off')");
     cmd_AddParm(ts, "-convert", CMD_SINGLE, CMD_OPTIONAL, "convert from afs to unix mode ('on or 'off')");
     cmd_AddParm(ts, "-uidcheck", CMD_SINGLE, CMD_OPTIONAL, "run on strict 'uid check' mode ('on' or 'off')");
     cmd_AddParm(ts, "-submounts", CMD_SINGLE, CMD_OPTIONAL, "allow nfs mounts to subdirs of /afs/.. ('on' or 'off')");
+#endif
 
-
-    ts = cmd_CreateSyntax("storebehind", StoreBehindCmd, 0, 
+    ts = cmd_CreateSyntax("storebehind", StoreBehindCmd, NULL, 
                          "store to server after file close");
     cmd_AddParm(ts, "-kbytes", CMD_SINGLE, CMD_OPTIONAL, "asynchrony for specified names");
     cmd_AddParm(ts, "-files", CMD_LIST, CMD_OPTIONAL, "specific pathnames");
     cmd_AddParm(ts, "-allfiles", CMD_SINGLE, CMD_OPTIONAL, "new default (KB)");
     cmd_CreateAlias(ts, "sb");
 
-    ts = cmd_CreateSyntax("setcrypt", SetCryptCmd, 0, "set cache manager encryption flag");
+    ts = cmd_CreateSyntax("setcrypt", SetCryptCmd, NULL, "set cache manager encryption flag");
     cmd_AddParm(ts, "-crypt", CMD_SINGLE, 0, "on or off");
 
-    ts = cmd_CreateSyntax("getcrypt", GetCryptCmd, 0, "get cache manager encryption flag");
+    ts = cmd_CreateSyntax("getcrypt", GetCryptCmd, NULL, "get cache manager encryption flag");
 
-#ifndef WIN32
-    ts = cmd_CreateSyntax("rxstatproc", RxStatProcCmd, 0,
+    ts = cmd_CreateSyntax("rxstatproc", RxStatProcCmd, NULL,
                          "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,
                          "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");
+#ifndef WIN32
+    ts = cmd_CreateSyntax("setcbaddr", CallBackRxConnCmd, NULL, "configure callback connection address");
     cmd_AddParm(ts, "-addr", CMD_SINGLE, CMD_OPTIONAL, "host name or address");
 #endif
 
-    ts = cmd_CreateSyntax("trace", TraceCmd, 0, "enable or disable CM tracing");
+    ts = cmd_CreateSyntax("trace", TraceCmd, NULL, "enable or disable CM tracing");
     cmd_AddParm(ts, "-on", CMD_FLAG, CMD_OPTIONAL, "enable tracing");
     cmd_AddParm(ts, "-off", CMD_FLAG, CMD_OPTIONAL, "disable tracing");
     cmd_AddParm(ts, "-reset", CMD_FLAG, CMD_OPTIONAL, "reset log contents");
     cmd_AddParm(ts, "-dump", CMD_FLAG, CMD_OPTIONAL, "dump log contents");
     cmd_CreateAlias(ts, "tr");
 
-    ts = cmd_CreateSyntax("memdump", MemDumpCmd, 0, "dump memory allocs in debug builds");
+    ts = cmd_CreateSyntax("uuid", UuidCmd, NULL, "manage the UUID for the cache manager");
+    cmd_AddParm(ts, "-generate", CMD_FLAG, CMD_OPTIONAL, "generate a new UUID");
+
+    ts = cmd_CreateSyntax("memdump", MemDumpCmd, NULL, "dump memory allocs in debug builds");
     cmd_AddParm(ts, "-begin", CMD_FLAG, CMD_OPTIONAL, "set a memory checkpoint");
     cmd_AddParm(ts, "-end", CMD_FLAG, CMD_OPTIONAL, "dump memory allocs");
     
-    ts = cmd_CreateSyntax("cscpolicy", CSCPolicyCmd, 0, "change client side caching policy for AFS shares");
+    ts = cmd_CreateSyntax("cscpolicy", CSCPolicyCmd, NULL, "change client side caching policy for AFS shares");
     cmd_AddParm(ts, "-share", CMD_SINGLE, CMD_OPTIONAL, "AFS share");
     cmd_AddParm(ts, "-manual", CMD_FLAG, CMD_OPTIONAL, "manual caching of documents");
     cmd_AddParm(ts, "-programs", CMD_FLAG, CMD_OPTIONAL, "automatic caching of programs and documents");
     cmd_AddParm(ts, "-documents", CMD_FLAG, CMD_OPTIONAL, "automatic caching of documents");
     cmd_AddParm(ts, "-disable", CMD_FLAG, CMD_OPTIONAL, "disable caching");
 
+    ts = cmd_CreateSyntax("minidump", MiniDumpCmd, NULL, "Generate MiniDump of current service state");
+
+    ts = cmd_CreateSyntax("test_volstat", TestVolStatCmd, NULL, (char *)CMD_HIDDEN);
+    cmd_AddParm(ts, "-network", CMD_SINGLE, CMD_OPTIONAL, "set network state up or down");
+    cmd_AddParm(ts, "-check",   CMD_FLAG,   CMD_OPTIONAL, "check state of offline volumes");
+    cmd_AddParm(ts, "-cell",    CMD_SINGLE, CMD_OPTIONAL, "cell name or number");
+    cmd_AddParm(ts, "-volume",  CMD_SINGLE, CMD_OPTIONAL, "volume name or number");
+    cmd_AddParm(ts, "-state",   CMD_SINGLE, CMD_OPTIONAL, "new volume state: online, busy, offline, down");
+
     code = cmd_Dispatch(argc, argv);
 
-#ifndef WIN32
     if (rxInitDone) 
         rx_Finalize();
-#endif /* not WIN32 */
     
     return code;
 }
@@ -4388,10 +4863,10 @@ Die(int code, char *filename)
     else if (code == ENODEV) {
        fprintf(stderr,"%s: AFS service may not have started.\n", pn);
     }
-    else if (code == ESRCH) {
+    else if (code == ESRCH) {   /* hack */
        fprintf(stderr,"%s: Cell name not recognized.\n", pn);
     }
-    else if (code == EPIPE) {
+    else if (code == EPIPE) {   /* hack */
        fprintf(stderr,"%s: Volume name or ID not recognized.\n", pn);
     }
     else if (code == EFBIG) {
@@ -4403,6 +4878,24 @@ Die(int code, char *filename)
        else
            fprintf(stderr,"%s: Connection timed out", pn);
     }
+    else if (code == EBUSY) {
+       if (filename) 
+            fprintf(stderr,"%s: All servers are busy on which '%s' resides\n", pn, filename);
+       else 
+            fprintf(stderr,"%s: All servers are busy\n", pn);
+    } 
+    else if (code == ENXIO) {
+       if (filename) 
+            fprintf(stderr,"%s: All volume instances are offline on which '%s' resides\n", pn, filename);
+       else 
+            fprintf(stderr,"%s: All volume instances are offline\n", pn);
+    } 
+    else if (code == ENOSYS) {
+       if (filename) 
+            fprintf(stderr,"%s: All servers are down on which '%s' resides\n", pn, filename);
+       else 
+            fprintf(stderr,"%s: All servers are down\n", pn);
+    } 
     else {
        if (filename) 
             fprintf(stderr,"%s:'%s'", pn, filename);
@@ -4411,7 +4904,7 @@ Die(int code, char *filename)
 #ifdef WIN32
        fprintf(stderr, ": code 0x%x\n", code);
 #else /* not WIN32 */
-       fprintf(stderr,": %s\n", error_message(code));
+       fprintf(stderr,": %s\n", afs_error_message(code));
 #endif /* not WIN32 */
     }
 } /*Die*/