windows-fs-getfid-20090511
[openafs.git] / src / WINNT / afsd / fs.c
index 3286dfd..5ebadde 100644 (file)
@@ -9,6 +9,7 @@
 
 #include <afs/param.h>
 #include <afs/stds.h>
+#include <afs/com_err.h>
 
 #include <windows.h>
 #include <stdlib.h>
@@ -42,7 +43,7 @@
 #define        MAXSIZE 2048
 #define MAXINSIZE 1300    /* pioctl complains if data is larger than this */
 #define VMSGSIZE 128      /* size of msg buf in volume hdr */
-#define MAXCELLCHARS           64
+#define CELL_MAXNAMELEN                256
 #define MAXHOSTCHARS           64
 
 static char space[MAXSIZE];
@@ -50,17 +51,17 @@ static char tspace[1024];
 
 static struct ubik_client *uclient;
 
-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);
-static int MiniDumpCmd(struct cmd_syndesc *asp, char *arock);
+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;
@@ -245,13 +246,20 @@ static int
 InAFS(char *apath)
 {
     struct ViceIoctl blob;
+    cm_ioctlQueryOptions_t options;
+    cm_fid_t fid;
     afs_int32 code;
 
-    blob.in_size = 0;
-    blob.out_size = MAXSIZE;
-    blob.out = space;
+    memset(&options, 0, sizeof(options));
+    options.size = sizeof(options);
+    options.field_flags |= CM_IOCTL_QOPTS_FIELD_LITERAL;
+    options.literal = 1;
+    blob.in_size = options.size;    /* no variable length data */
+    blob.in = &options;
+    blob.out_size = sizeof(cm_fid_t);
+    blob.out = (char *) &fid;
 
-    code = pioctl(apath, VIOC_FILE_CELL_NAME, &blob, 1);
+    code = pioctl_utf8(apath, VIOCGETFID, &blob, 1);
     if (code) {
        if ((errno == EINVAL) || (errno == ENOENT)) 
             return 0;
@@ -269,9 +277,9 @@ IsFreelanceRoot(char *apath)
     blob.out_size = MAXSIZE;
     blob.out = space;
 
-    code = pioctl(apath, VIOC_FILE_CELL_NAME, &blob, 1);
+    code = pioctl_utf8(apath, VIOC_FILE_CELL_NAME, &blob, 1);
     if (code == 0)
-        return !strcmp("Freelance.Local.Root",space);
+        return !cm_stricmp_utf8N("Freelance.Local.Root",space);
     return 1;   /* assume it is because it is more restrictive that way */
 }
 
@@ -535,24 +543,36 @@ EmptyAcl(char *astr)
     tp->nplus = tp->nminus = 0;
     tp->pluslist = tp->minuslist = 0;
     tp->dfs = 0;
-    sscanf(astr, "%d dfs:%d %s", &junk, &tp->dfs, tp->cell);
+    if (astr == NULL || sscanf(astr, "%d dfs:%d %s", &junk, &tp->dfs, tp->cell) <= 0) {
+        tp->dfs = 0;
+        tp->cell[0] = '\0';
+    }
     return tp;
 }
 
 static struct Acl *
 ParseAcl (char *astr)
 {
-    int nplus, nminus, i, trights;
+    int nplus, nminus, i, trights, ret;
     char tname[MAXNAME];
-    struct AclEntry *first, *last, *tl;
+    struct AclEntry *first, *next, *last, *tl;
     struct Acl *ta;
 
-    ta = (struct Acl *) malloc (sizeof (struct Acl));
-    assert(ta);
-    ta->dfs = 0;
-    sscanf(astr, "%d dfs:%d %s", &ta->nplus, &ta->dfs, ta->cell);
+    ta = EmptyAcl(NULL);
+    if (astr == NULL || strlen(astr) == 0)
+        return ta;
+
+    ret = sscanf(astr, "%d dfs:%d %s", &ta->nplus, &ta->dfs, ta->cell);
+    if (ret <= 0) {
+        free(ta);
+        return NULL;
+    }
     astr = SkipLine(astr);
-    sscanf(astr, "%d", &ta->nminus);
+    ret = sscanf(astr, "%d", &ta->nminus);
+    if (ret <= 0) {
+        free(ta);
+        return NULL;
+    }
     astr = SkipLine(astr);
 
     nplus = ta->nplus;
@@ -561,10 +581,13 @@ ParseAcl (char *astr)
     last = 0;
     first = 0;
     for(i=0;i<nplus;i++) {
-        sscanf(astr, "%100s %d", tname, &trights);
+        ret = sscanf(astr, "%100s %d", tname, &trights); 
+        if (ret <= 0)
+            goto nplus_err;
         astr = SkipLine(astr);
         tl = (struct AclEntry *) malloc(sizeof (struct AclEntry));
-        assert(tl);
+        if (tl == NULL)
+            goto nplus_err;
         if (!first) 
             first = tl;
         strcpy(tl->name, tname);
@@ -579,10 +602,13 @@ ParseAcl (char *astr)
     last = 0;
     first = 0;
     for(i=0;i<nminus;i++) {
-        sscanf(astr, "%100s %d", tname, &trights);
+        ret = sscanf(astr, "%100s %d", tname, &trights);
+        if (ret <= 0)
+            goto nminus_err;
         astr = SkipLine(astr);
         tl = (struct AclEntry *) malloc(sizeof (struct AclEntry));
-        assert(tl);
+        if (tl == NULL)
+            goto nminus_err;
         if (!first) 
             first = tl;
         strcpy(tl->name, tname);
@@ -595,6 +621,21 @@ ParseAcl (char *astr)
     ta->minuslist = first;
 
     return ta;
+
+  nminus_err:
+    for (;first; first = next) {
+        next = first->next;
+        free(first);
+    }   
+    first = ta->pluslist;
+
+  nplus_err:
+    for (;first; first = next) {
+        next = first->next;
+        free(first);
+    }   
+    free(ta);
+    return NULL;
 }
 
 static int
@@ -702,7 +743,7 @@ static DWORD IsFreelance(void)
     DWORD enabled = 0;
 
     code = RegOpenKeyEx(HKEY_LOCAL_MACHINE, AFSREG_CLT_SVC_PARAM_SUBKEY,
-                         0, KEY_QUERY_VALUE, &parmKey);
+                         0, (IsWow64()?KEY_WOW64_64KEY:0)|KEY_QUERY_VALUE, &parmKey);
     if (code == ERROR_SUCCESS) {
         dummyLen = sizeof(cm_freelanceEnabled);
         code = RegQueryValueEx(parmKey, "FreelanceClient", NULL, NULL,
@@ -721,7 +762,7 @@ static const char * NetbiosName(void)
     DWORD enabled = 0;
 
     code = RegOpenKeyEx(HKEY_LOCAL_MACHINE, AFSREG_CLT_SVC_PARAM_SUBKEY,
-                         0, KEY_QUERY_VALUE, &parmKey);
+                         0, (IsWow64()?KEY_WOW64_64KEY:0)|KEY_QUERY_VALUE, &parmKey);
     if (code == ERROR_SUCCESS) {
         dummyLen = sizeof(buffer);
         code = RegQueryValueEx(parmKey, "NetbiosName", NULL, NULL,
@@ -873,7 +914,7 @@ static 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;
@@ -895,7 +936,7 @@ SetACLCmd(struct cmd_syndesc *as, char *arock)
        blob.out_size = MAXSIZE;
        blob.in_size = idf;
        blob.in = blob.out = space;
-       code = pioctl(ti->data, VIOCGETAL, &blob, 1);
+       code = pioctl_utf8(ti->data, VIOCGETAL, &blob, 1);
        if (code) {
            Die(errno, ti->data);
            error = 1;
@@ -904,6 +945,13 @@ SetACLCmd(struct cmd_syndesc *as, char *arock)
         if (ta)
             ZapAcl(ta);
        ta = ParseAcl(space);
+        if (!ta) {
+            fprintf(stderr,
+                    "fs: %s: invalid acl data returned from VIOCGETAL\n",
+                     ti->data);
+            error = 1;
+            continue;
+        }
        if (!plusp && ta->dfs) {
            fprintf(stderr,
                    "fs: %s: you may not use the -negative switch with DFS acl's.\n%s",
@@ -918,6 +966,13 @@ SetACLCmd(struct cmd_syndesc *as, char *arock)
             ta = EmptyAcl(space);
        else 
             ta = ParseAcl(space);
+        if (!ta) {
+            fprintf(stderr,
+                    "fs: %s: invalid acl data returned from VIOCGETAL\n",
+                     ti->data);
+            error = 1;
+            continue;
+        }
        CleanAcl(ta, ti->data);
        for(ui=as->parms[1].items; ui; ui=ui->next->next) {
            enum rtype rtype;
@@ -944,7 +999,7 @@ SetACLCmd(struct cmd_syndesc *as, char *arock)
        blob.in = AclToString(ta);
        blob.out_size=0;
        blob.in_size = 1+(long)strlen(blob.in);
-       code = pioctl(ti->data, VIOCSETAL, &blob, 1);
+       code = pioctl_utf8(ti->data, VIOCSETAL, &blob, 1);
        if (code) {
            if (errno == EINVAL) {
                if (ta->dfs) {
@@ -1003,7 +1058,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;
@@ -1021,18 +1076,24 @@ CopyACLCmd(struct cmd_syndesc *as, char *arock)
     blob.out_size = MAXSIZE;
     blob.in_size = idf;
     blob.in = blob.out = space;
-    code = pioctl(as->parms[0].items->data, VIOCGETAL, &blob, 1);
+    code = pioctl_utf8(as->parms[0].items->data, VIOCGETAL, &blob, 1);
     if (code) {
        Die(errno, as->parms[0].items->data);
        return 1;
     }
     fa = ParseAcl(space);
+    if (!fa) {
+        fprintf(stderr,
+                 "fs: %s: invalid acl data returned from VIOCGETAL\n",
+                 as->parms[0].items->data);
+        return 1;
+    }
     CleanAcl(fa, as->parms[0].items->data);
     for (ti=as->parms[1].items; ti;ti=ti->next) {
        blob.out_size = MAXSIZE;
        blob.in_size = idf;
        blob.in = blob.out = space;
-       code = pioctl(ti->data, VIOCGETAL, &blob, 1);
+       code = pioctl_utf8(ti->data, VIOCGETAL, &blob, 1);
        if (code) {
            Die(errno, ti->data);
            error = 1;
@@ -1044,6 +1105,13 @@ CopyACLCmd(struct cmd_syndesc *as, char *arock)
             ta = EmptyAcl(space);
        else 
             ta = ParseAcl(space);
+        if (!ta) {
+            fprintf(stderr,
+                    "fs: %s: invalid acl data returned from VIOCGETAL\n",
+                     ti->data);
+            error = 1;
+            continue;
+        }
        CleanAcl(ta, ti->data);
        if (ta->dfs != fa->dfs) {
            fprintf(stderr, 
@@ -1069,7 +1137,7 @@ CopyACLCmd(struct cmd_syndesc *as, char *arock)
        blob.in = AclToString(ta);
        blob.out_size=0;
        blob.in_size = 1+(long)strlen(blob.in);
-       code = pioctl(ti->data, VIOCSETAL, &blob, 1);
+       code = pioctl_utf8(ti->data, VIOCSETAL, &blob, 1);
        if (code) {
            if (errno == EINVAL) {
                fprintf(stderr,
@@ -1087,7 +1155,7 @@ CopyACLCmd(struct cmd_syndesc *as, char *arock)
     return error;
 }
 
-/* pioctl() call to get the cellname of a pathname */
+/* pioctl_utf8() call to get the cellname of a pathname */
 static afs_int32
 GetCell(char *fname, char *cellname)
 {
@@ -1095,11 +1163,11 @@ GetCell(char *fname, char *cellname)
     struct ViceIoctl blob;
 
     blob.in_size = 0;
-    blob.out_size = MAXCELLCHARS;
+    blob.out_size = CELL_MAXNAMELEN;
     blob.out = cellname;
 
-    code = pioctl(fname, VIOC_FILE_CELL_NAME, &blob, 1);
-    return code ? errno : 0;
+    code = pioctl_utf8(fname, VIOC_FILE_CELL_NAME, &blob, 1);
+    return code;
 }
 
 /* Check if a username is valid: If it contains only digits (or a
@@ -1111,7 +1179,8 @@ BadName(char *aname, char *fname)
 {
     afs_int32 tc, code, id;
     char *nm;
-    char cell[MAXCELLCHARS];
+    char cell[CELL_MAXNAMELEN];
+    char confDir[257];
 
     for ( nm = aname; tc = *nm; nm++) {
        /* all must be '-' or digit to be bad */
@@ -1124,7 +1193,9 @@ BadName(char *aname, char *fname)
     if (code)
         return 0;
 
-    pr_Initialize(1, AFSDIR_CLIENT_ETC_DIRPATH, cell);
+    cm_GetConfigDir(confDir, sizeof(confDir));
+
+    pr_Initialize(1, confDir, cell);
     code = pr_SNameToId(aname, &id);
     pr_End();
 
@@ -1179,7 +1250,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;
@@ -1194,7 +1265,7 @@ CleanACLCmd(struct cmd_syndesc *as, char *arock)
        blob.out_size = MAXSIZE;
        blob.in_size = 0;
        blob.out = space;
-       code = pioctl(ti->data, VIOCGETAL, &blob, 1);
+       code = pioctl_utf8(ti->data, VIOCGETAL, &blob, 1);
        if (code) {
            Die(errno, ti->data);
             error = 1;
@@ -1203,7 +1274,13 @@ CleanACLCmd(struct cmd_syndesc *as, char *arock)
         if (ta)
             ZapAcl(ta);
        ta = ParseAcl(space);
-
+        if (!ta) {
+            fprintf(stderr,
+                    "fs: %s: invalid acl data returned from VIOCGETAL\n",
+                     ti->data);
+            error = 1;
+            continue;
+        }
        if (ta->dfs) {
            fprintf(stderr,
                    "%s: cleanacl is not supported for DFS access lists.\n",
@@ -1219,7 +1296,7 @@ CleanACLCmd(struct cmd_syndesc *as, char *arock)
            blob.in=AclToString(ta);
            blob.in_size = (long)strlen(blob.in)+1;
            blob.out_size = 0;
-           code = pioctl(ti->data, VIOCSETAL, &blob, 1);
+           code = pioctl_utf8(ti->data, VIOCSETAL, &blob, 1);
            if (code) {
                if (errno == EINVAL) {
                    fprintf(stderr,
@@ -1266,7 +1343,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;
@@ -1282,13 +1359,20 @@ ListACLCmd(struct cmd_syndesc *as, char *arock)
        blob.out_size = MAXSIZE;
        blob.in_size = idf;
        blob.in = blob.out = space;
-       code = pioctl(ti->data, VIOCGETAL, &blob, 1);
+       code = pioctl_utf8(ti->data, VIOCGETAL, &blob, 1);
        if (code) {
            Die(errno, ti->data);
             error = 1;
            continue;
        }
        ta = ParseAcl(space);
+        if (!ta) {
+            fprintf(stderr,
+                    "fs: %s: invalid acl data returned from VIOCGETAL\n",
+                     ti->data);
+            error = 1;
+            continue;
+        }
        switch (ta->dfs) {
          case 0:
            printf("Access list for %s is\n", ti->data);
@@ -1332,13 +1416,13 @@ ListACLCmd(struct cmd_syndesc *as, char *arock)
 }
 
 static int
-FlushAllCmd(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);
+    code = pioctl_utf8(NULL, VIOC_FLUSHALL, &blob, 0);
     if (code) {
        fprintf(stderr, "Error flushing all ");
        return 1;
@@ -1347,7 +1431,7 @@ FlushAllCmd(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;
@@ -1357,7 +1441,7 @@ FlushVolumeCmd(struct cmd_syndesc *as, char *arock)
     SetDotDefault(&as->parms[0].items);
     for(ti=as->parms[0].items; ti; ti=ti->next) {
        blob.in_size = blob.out_size = 0;
-       code = pioctl(ti->data, VIOC_FLUSHVOLUME, &blob, 0);
+       code = pioctl_utf8(ti->data, VIOC_FLUSHVOLUME, &blob, 0);
        if (code) {
            fprintf(stderr, "Error flushing volume ");
             perror(ti->data);
@@ -1369,17 +1453,29 @@ 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;
-       code = pioctl(ti->data, VIOCFLUSH, &blob, 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_utf8(ti->data, VIOCFLUSH, &blob, 0);
        if (code) {
            if (errno == EMFILE) {
                fprintf(stderr, "%s: Can't flush active file %s\n", pn, 
@@ -1397,7 +1493,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 */
@@ -1406,7 +1502,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;
@@ -1461,7 +1557,7 @@ SetVolCmd(struct cmd_syndesc *as, char *arock) {
            input += strlen(motd) + 1;
        } else 
             *(input++) = '\0';
-       code = pioctl(ti->data,VIOCSETVOLSTAT, &blob, 1);
+       code = pioctl_utf8(ti->data,VIOCSETVOLSTAT, &blob, 1);
        if (code) {
            Die(errno, ti->data);
            error = 1;
@@ -1470,66 +1566,106 @@ SetVolCmd(struct cmd_syndesc *as, char *arock) {
     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;
     struct cmd_item *ti;
     struct VolumeStatus *status;
     char *name, *offmsg, *motd;
-    long   online_state;
     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) {
         cm_fid_t fid;
+        afs_uint32 filetype;
        afs_uint32 owner[2];
-       char cell[MAXCELLCHARS];
+       char cell[CELL_MAXNAMELEN];
+
+        /* 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;
 
-       code = GetCell(ti->data, cell);
-       if (code) {
+        blob.out_size = sizeof(cm_fid_t);
+        blob.out = (char *) &fid;
+        if (0 == pioctl_utf8(ti->data, VIOCGETFID, &blob, 1)) {
+            options.field_flags |= CM_IOCTL_QOPTS_FIELD_FID;
+            options.fid = fid;
+        } else {
            Die(errno, ti->data);
            error = 1;
            continue;
-       }
+        }
 
-       /* once per file */
-       blob.in_size = 0;
+        blob.out_size = sizeof(filetype);
+        blob.out = &filetype;
 
-        blob.out_size = sizeof(cm_fid_t);
-        blob.out = (char *) &fid;
-        if (0 == pioctl(ti->data, VIOCGETFID, &blob, 1)) {
-            printf("File %s (%u.%u.%u) contained in cell %s\n",
-                    ti->data, fid.volume, fid.vnode, fid.unique,
-                    cell);
-        }
+        code = pioctl_utf8(ti->data, VIOC_GETFILETYPE, &blob, 1);
+
+        blob.out_size = CELL_MAXNAMELEN;
+        blob.out = cell;
+
+        code = pioctl_utf8(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)) {
+       if (0 == pioctl_utf8(ti->data, VIOCGETOWNER, &blob, 1)) {
            char oname[PR_MAXNAMELEN] = "(unknown)";
+            char confDir[257];
 
            /* Go to the PRDB and see if this all number username is valid */
-           pr_Initialize(1, AFSDIR_CLIENT_ETC_DIRPATH, cell);
+            cm_GetConfigDir(confDir, sizeof(confDir));
+
+            pr_Initialize(1, confDir, cell);
            pr_SIdToName(owner[0], oname);
            printf("Owner %s (%u) Group %u\n", oname, owner[0], owner[1]);
         }
 
        blob.out = space;
        blob.out_size = MAXSIZE;
-       code = pioctl(ti->data, VIOCGETVOLSTAT, &blob, 1);
+       code = pioctl_utf8(ti->data, VIOCGETVOLSTAT, &blob, 1);
        if (code == 0) {
             status = (VolumeStatus *)space;
             name = (char *)status + sizeof(*status);
@@ -1540,22 +1676,25 @@ ExamineCmd(struct cmd_syndesc *as, char *arock)
         } else {
             Die(errno, ti->data);
         }
-        online_state = pioctl(ti->data, VIOC_PATH_AVAILABILITY, &blob, 1);
-        switch (online_state) {
+
+        errno = 0;
+        code = pioctl_utf8(ti->data, VIOC_PATH_AVAILABILITY, &blob, 1);
+        switch (errno) {
         case 0:
             printf("Volume is online\n");
             break;
-        case CM_ERROR_ALLOFFLINE:
-            printf("Volume offline\n");
+        case ENXIO:
+            printf("Volume is offline\n");
             break;
-        case CM_ERROR_ALLDOWN:
+        case ENOSYS:
             printf("All Volume servers are down\n");
             break;
-        case CM_ERROR_ALLBUSY:
+        case EBUSY:
             printf("All volume servers are busy\n");
             break;
         default:
-            Die(online_state, ti->data);
+            printf("Unknown volume state\n");
+            Die(errno, ti->data);
         }
         printf("\n");
     }
@@ -1563,7 +1702,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;
@@ -1581,7 +1720,7 @@ ListQuotaCmd(struct cmd_syndesc *as, char *arock)
        blob.out_size = MAXSIZE;
        blob.in_size = 0;
        blob.out = space;
-       code = pioctl(ti->data, VIOCGETVOLSTAT, &blob, 1);
+       code = pioctl_utf8(ti->data, VIOCGETVOLSTAT, &blob, 1);
        if (code) {
            Die(errno, ti->data);
             error = 1;
@@ -1595,7 +1734,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;
@@ -1604,22 +1743,56 @@ 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_utf8(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_utf8(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);
+       code = pioctl_utf8(ti->data, VIOCWHEREIS, &blob, 1);
        if (code) {
            Die(errno, ti->data);
             error = 1;
            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) 
@@ -1634,7 +1807,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;
@@ -1651,7 +1824,7 @@ DiskFreeCmd(struct cmd_syndesc *as, char *arock)
        blob.out_size = MAXSIZE;
        blob.in_size = 0;
        blob.out = space;
-       code = pioctl(ti->data, VIOCGETVOLSTAT, &blob, 1);
+       code = pioctl_utf8(ti->data, VIOCGETVOLSTAT, &blob, 1);
        if (code) {
            Die(errno, ti->data);
             error = 1;
@@ -1665,7 +1838,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;
@@ -1680,7 +1853,7 @@ QuotaCmd(struct cmd_syndesc *as, char *arock)
        blob.out_size = MAXSIZE;
        blob.in_size = 0;
        blob.out = space;
-       code = pioctl(ti->data, VIOCGETVOLSTAT, &blob, 1);
+       code = pioctl_utf8(ti->data, VIOCGETVOLSTAT, &blob, 1);
        if (code) {
            Die(errno, ti->data);
             error = 1;
@@ -1697,7 +1870,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;
@@ -1828,7 +2001,7 @@ ListMountCmd(struct cmd_syndesc *as, char *arock)
        blob.out = space;
        memset(space, 0, MAXSIZE);
 
-       code = pioctl(parent_dir, VIOC_AFS_STAT_MT_PT, &blob, 1);
+       code = pioctl_utf8(parent_dir, VIOC_AFS_STAT_MT_PT, &blob, 1);
 
        if (code == 0) {
            printf("'%s' is a %smount point for volume '%s'\n",
@@ -1849,7 +2022,7 @@ 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;
@@ -1862,6 +2035,8 @@ MakeMountCmd(struct cmd_syndesc *as, char *arock)
     struct ViceIoctl blob;
     char * parent;
 
+    memset(&info, 0, sizeof(info));
+
     if (as->parms[2].items)    /* cell name specified */
        cellName = as->parms[2].items->data;
     else
@@ -1925,13 +2100,16 @@ MakeMountCmd(struct cmd_syndesc *as, char *arock)
            blob.in_size = 0;
            blob.out_size = sizeof(localCellName);
            blob.out = localCellName;
-           code = pioctl(parent, VIOC_GET_WS_CELL, &blob, 1);
+           code = pioctl_utf8(parent, VIOC_GET_WS_CELL, &blob, 1);
            if (!code)
                cellName = localCellName;
        }
     } else {
-       if (!cellName)
-           GetCell(parent,space);
+       if (!cellName) {
+           code = GetCell(parent,space);
+            if (code)
+                return 1;
+        }
     }
 
     code = GetCellName(cellName?cellName:space, &info);
@@ -1973,10 +2151,14 @@ MakeMountCmd(struct cmd_syndesc *as, char *arock)
     blob.in_size = 1 + (long)strlen(space);
     blob.in = space;
     blob.out = NULL;
-    code = pioctl(path, VIOC_AFS_CREATE_MT_PT, &blob, 0);
+    code = pioctl_utf8(path, VIOC_AFS_CREATE_MT_PT, &blob, 0);
 #else /* not WIN32 */
     code = symlink(space, path);
 #endif /* not WIN32 */
+
+    if (info.linkedCell)
+        free(info.linkedCell);
+
     if (code) {
        Die(errno, path);
        return 1;
@@ -1991,7 +2173,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;
@@ -2034,7 +2216,7 @@ RemoveMountCmd(struct cmd_syndesc *as, char *arock) {
        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);
+       code = pioctl_utf8(tbuffer, VIOC_AFS_STAT_MT_PT, &blob, 0);
        if (code) {
            if (errno == EINVAL) {
                fprintf(stderr,"%s: '%s' is not a mount point.\n", pn, ti->data);
@@ -2054,7 +2236,7 @@ RemoveMountCmd(struct cmd_syndesc *as, char *arock) {
         blob.out_size = 0;
        blob.in = tp;
        blob.in_size = (long)strlen(tp)+1;
-       code = pioctl(tbuffer, VIOC_AFS_DELETE_MT_PT, &blob, 0);
+       code = pioctl_utf8(tbuffer, VIOC_AFS_DELETE_MT_PT, &blob, 0);
        if (code) {
            Die(errno, ti->data);
             error = 1;
@@ -2067,7 +2249,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;
@@ -2077,6 +2259,7 @@ CheckServersCmd(struct cmd_syndesc *as, char *arock)
     struct afsconf_cell info;
     struct chservinfo checkserv;
 
+    memset(&info, 0, sizeof(info));
     memset(&checkserv, 0, sizeof(struct chservinfo));
     blob.in_size=sizeof(struct chservinfo);
     blob.in=(caddr_t)&checkserv;
@@ -2103,6 +2286,8 @@ CheckServersCmd(struct cmd_syndesc *as, char *arock)
        }
        strcpy(checkserv.tbuffer,info.name);
        checkserv.tsize=(int)strlen(info.name)+1;
+        if (info.linkedCell)
+            free(info.linkedCell);
     } else {
         strcpy(checkserv.tbuffer,"\0");
         checkserv.tsize=0;
@@ -2137,7 +2322,7 @@ CheckServersCmd(struct cmd_syndesc *as, char *arock)
 #endif /* WIN32 */
     }
 
-    code = pioctl(0, VIOCCKSERV, &blob, 1);
+    code = pioctl_utf8(0, VIOCCKSERV, &blob, 1);
     if (code) {
        if ((errno == EACCES) && (checkserv.tinterval > 0)) {
            printf("Must be root to change -interval\n");
@@ -2173,7 +2358,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;
@@ -2207,7 +2392,7 @@ MessagesCmd(struct cmd_syndesc *as, char *arock)
     if (code)
         return 1;
 
-    code = pioctl(0, VIOC_GAG, &blob, 1);
+    code = pioctl_utf8(0, VIOC_GAG, &blob, 1);
     if (code) {
        Die(errno, 0);
         return 1;
@@ -2216,14 +2401,14 @@ 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;
     
     blob.in_size = 0;
     blob.out_size = 0;
-    code = pioctl(0, VIOCCKBACK, &blob, 1);
+    code = pioctl_utf8(0, VIOCCKBACK, &blob, 1);
     if (code) {
        Die(errno, 0);
        return 1;
@@ -2234,7 +2419,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;
@@ -2267,7 +2452,7 @@ SetCacheSizeCmd(struct cmd_syndesc *as, char *arock)
     blob.in = (char *) &temp;
     blob.in_size = sizeof(afs_int32);
     blob.out_size = 0;
-    code = pioctl(0, VIOCSETCACHESIZE, &blob, 1);
+    code = pioctl_utf8(0, VIOCSETCACHESIZE, &blob, 1);
     if (code) {
        Die(errno, (char *) 0);
         return 1;
@@ -2277,34 +2462,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_uint64 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;
-    code = pioctl(0, VIOCGETCACHEPARMS, &blob, 1);
+    blob.out = (char *) &parms;
+    code = pioctl_utf8(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;
@@ -2326,7 +2510,7 @@ ListCellsCmd(struct cmd_syndesc *as, char *arock)
        blob.in_size = sizeof(afs_int32);
        blob.in = space;
        blob.out = space;
-       code = pioctl(0, VIOCGETCELL, &blob, 1);
+       code = pioctl_utf8(0, VIOCGETCELL, &blob, 1);
        if (code < 0) {
            if (errno == EDOM) 
                 break; /* done with the list */
@@ -2364,7 +2548,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;
@@ -2377,7 +2561,7 @@ ListAliasesCmd(struct cmd_syndesc *as, char *arock)
        blob.in_size = sizeof(afs_int32);
        blob.in = space;
        blob.out = space;
-       code = pioctl(0, VIOC_GETALIAS, &blob, 1);
+       code = pioctl_utf8(0, VIOC_GETALIAS, &blob, 1);
        if (code < 0) {
            if (errno == EDOM)
                break;          /* done with the list */
@@ -2394,7 +2578,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;
@@ -2424,7 +2608,7 @@ CallBackRxConnCmd(struct cmd_syndesc *as, char *arock)
     blob.in = (char *) &hostAddr;
     blob.out = (char *) &hostAddr;
     
-    code = pioctl(0, VIOC_CBADDR, &blob, 1);
+    code = pioctl_utf8(0, VIOC_CBADDR, &blob, 1);
     if (code < 0) {
        Die(errno, 0);
        return 1;
@@ -2434,7 +2618,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;
@@ -2499,7 +2683,7 @@ NewCellCmd(struct cmd_syndesc *as, char *arock)
     blob.in_size = size;
     blob.in = space;
     blob.out_size = 0;
-    code = pioctl(0, VIOCNEWCELL, &blob, 1);
+    code = pioctl_utf8(0, VIOCNEWCELL, &blob, 1);
     if (code < 0)
        Die(errno, 0);
     return 0;
@@ -2517,7 +2701,7 @@ NewCellCmd(struct cmd_syndesc *as, char *arock)
     blob.out_size = MAXSIZE;
     blob.out = space;
 
-    code = pioctl((char *) 0, VIOCNEWCELL, &blob, 1);
+    code = pioctl_utf8((char *) 0, VIOCNEWCELL, &blob, 1);
 
     if (code) {
         Die(errno, (char *) 0);
@@ -2531,7 +2715,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;
@@ -2551,7 +2735,7 @@ NewAliasCmd(struct cmd_syndesc *as, char *arock)
     blob.in = space;
     blob.out_size = 0;
     blob.out = space;
-    code = pioctl(0, VIOC_NEWALIAS, &blob, 1);
+    code = pioctl_utf8(0, VIOC_NEWALIAS, &blob, 1);
     if (code < 0) {
        if (errno == EEXIST) {
            fprintf(stderr,
@@ -2567,16 +2751,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[CELL_MAXNAMELEN];
+
+        /* 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_utf8(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_utf8(ti->data, VIOC_GETFILETYPE, &blob, 1);
+
+        blob.out_size = CELL_MAXNAMELEN;
+        blob.out = cell;
+
+        code = pioctl_utf8(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);
@@ -2585,13 +2807,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;
@@ -2601,7 +2825,7 @@ WSCellCmd(struct cmd_syndesc *as, char *arock)
     blob.out_size = MAXSIZE;
     blob.out = space;
 
-    code = pioctl(NULL, VIOC_GET_WS_CELL, &blob, 1);
+    code = pioctl_utf8(NULL, VIOC_GET_WS_CELL, &blob, 1);
 
     if (code) {
        Die(errno, NULL);
@@ -2614,15 +2838,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;
@@ -2662,7 +2887,7 @@ MonitorCmd(struct cmd_syndesc *as, char *arock)
     blob.out_size = sizeof(afs_int32);
     blob.in = (char *) &hostAddr;
     blob.out = (char *) &hostAddr;
-    code = pioctl(0, VIOC_AFS_MARINER_HOST, &blob, 1);
+    code = pioctl_utf8(0, VIOC_AFS_MARINER_HOST, &blob, 1);
     if (code) {
        Die(errno, 0);
        return 1;
@@ -2680,9 +2905,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;
@@ -2724,7 +2950,7 @@ SysNameCmd(struct cmd_syndesc *as, char *arock)
         *(input++) = '\0';
     }
     memcpy(space, &setp, sizeof(afs_int32));
-    code = pioctl(0, VIOC_AFS_SYSNAME, &blob, 1);
+    code = pioctl_utf8(0, VIOC_AFS_SYSNAME, &blob, 1);
     if (code) {
         Die(errno, 0);
         return 1;
@@ -2751,8 +2977,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;
@@ -2829,7 +3056,7 @@ static int ExportAfsCmd(struct cmd_syndesc *as, char *arock)
     blob.in_size = sizeof(afs_int32);
     blob.out = (char *) &exportcall;
     blob.out_size = sizeof(afs_int32);
-    code = pioctl(0, VIOC_EXPORTAFS, &blob, 1);
+    code = pioctl_utf8(0, VIOC_EXPORTAFS, &blob, 1);
     if (code) {
        if (errno == ENODEV) {
            fprintf(stderr,
@@ -2852,10 +3079,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;
@@ -2867,6 +3094,7 @@ GetCellCmd(struct cmd_syndesc *as, char *arock)
     } args;
     int error = 0;
 
+    memset(&info, 0, sizeof(info));
     memset(&args, 0, sizeof(args));      /* avoid Purify UMR error */
     for(ti=as->parms[0].items; ti; ti=ti->next) {
        /* once per cell */
@@ -2877,9 +3105,11 @@ GetCellCmd(struct cmd_syndesc *as, char *arock)
             error = 1;
            continue;
        }
+        if (info.linkedCell)
+            free(info.linkedCell);
        blob.in_size = 1+(long)strlen(info.name);
        blob.in = info.name;
-       code = pioctl(0, VIOC_GETCELLSTATUS, &blob, 1);
+       code = pioctl_utf8(0, VIOC_GETCELLSTATUS, &blob, 1);
        if (code) {
            if (errno == ENOENT)
                fprintf(stderr,"%s: the cell named '%s' does not exist\n", pn, info.name);
@@ -2904,7 +3134,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;
@@ -2917,6 +3147,8 @@ static int SetCellCmd(struct cmd_syndesc *as, char *arock)
     } args;
     int error = 0;
 
+    memset(&info, 0, sizeof(info));
+
     /* Check arguments. */
     if (as->parms[1].items && as->parms[2].items) {
         fprintf(stderr, "Cannot specify both -suid and -nosuid.\n");
@@ -2950,12 +3182,14 @@ static int SetCellCmd(struct cmd_syndesc *as, char *arock)
             error = 1;
            continue;
        }
+        if (info.linkedCell)
+            free(info.linkedCell);
        strcpy(args.cname, info.name);
        blob.in_size = sizeof(args);
        blob.in = (caddr_t) &args;
        blob.out_size = 0;
        blob.out = (caddr_t) 0;
-       code = pioctl(0, VIOC_SETCELLSTATUS, &blob, 1);
+       code = pioctl_utf8(0, VIOC_SETCELLSTATUS, &blob, 1);
        if (code) {
            Die(errno, info.name);      /* XXX added cell name to Die() call */
             error = 1;
@@ -2964,45 +3198,22 @@ static int SetCellCmd(struct cmd_syndesc *as, char *arock)
     return error;
 }
 
-#ifdef WIN32
 static int
 GetCellName(char *cellNamep, struct afsconf_cell *infop)
 {
     strcpy(infop->name, cellNamep);
     return 0;
 }
-#else
-static int
-GetCellName(char *cellName, struct afsconf_cell *info)
-{
-    struct afsconf_dir *tdir;
-    int code;
-
-    tdir = afsconf_Open(AFSDIR_CLIENT_ETC_CLIENTNAME);
-    if (!tdir) {
-       fprintf(stderr,
-                "Could not process files in configuration directory (%s).\n",
-                 AFSDIR_CLIENT_ETC_CLIENTNAME);
-       return -1;
-    }
-
-    code = afsconf_GetCellInfo(tdir, cellName, AFSCONF_VLDBSERVICE, info);
-    if (code) {
-       fprintf(stderr,"fs: cell %s not in %s/CellServDB\n", cellName, 
-                AFSDIR_CLIENT_ETC_CLIENTNAME);
-       return code;
-    }
-
-    return 0;
-}
-#endif /* not WIN32 */
 
 static int
 VLDBInit(int noAuthFlag, struct afsconf_cell *info)
 {
     afs_int32 code;
+    char confDir[257];
+
+    cm_GetConfigDir(confDir, sizeof(confDir));
 
-    code = ugen_ClientInit(noAuthFlag, AFSDIR_CLIENT_ETC_DIRPATH, 
+    code = ugen_ClientInit(noAuthFlag, confDir, 
                           info->name, 0, &uclient, 
                            NULL, pn, rxkad_clear,
                            VLDB_MAXSERVERS, AFSCONF_VLDBSERVICE, 50,
@@ -3030,7 +3241,7 @@ pokeServers(void)
 {
     int code;
     cm_SSetPref_t *ssp;
-    code = pioctl(0, VIOC_SETSPREFS, &gblob, 1);
+    code = pioctl_utf8(0, VIOC_SETSPREFS, &gblob, 1);
 
     ssp = (cm_SSetPref_t *)space;
     gblob.in_size = (long)(((char *)&(ssp->servers[0])) - (char *)ssp);
@@ -3048,14 +3259,14 @@ pokeServers(void)
 {
     int code;
 
-    code = pioctl(0, VIOC_SETSPREFS, &gblob, 1);
+    code = pioctl_utf8(0, VIOC_SETSPREFS, &gblob, 1);
     if (code && (errno == EINVAL)) {
        struct setspref *ssp;
        ssp = (struct setspref *)gblob.in;
        if (!(ssp->flags & DBservers)) {
            gblob.in = (void *)&(ssp->servers[0]);
            gblob.in_size -= ((char *)&(ssp->servers[0])) - (char *)ssp;
-           code = pioctl(0, VIOC_SETSPREFS33, &gblob, 1);
+           code = pioctl_utf8(0, VIOC_SETSPREFS33, &gblob, 1);
            return code ? errno : 0;
        }
        fprintf(stderr,
@@ -3191,7 +3402,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;
@@ -3281,7 +3492,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;
@@ -3387,7 +3598,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;
@@ -3429,7 +3640,7 @@ GetPrefCmd(struct cmd_syndesc *as, char *arock)
         in->num_servers = (MAXSIZE - 2*sizeof(short))/sizeof(struct cm_SPref);
         in->flags = vlservers; 
 
-        code = pioctl(0, VIOC_GETSPREFS, &blob, 1);
+        code = pioctl_utf8(0, VIOC_GETSPREFS, &blob, 1);
         if (code){
             perror("getserverprefs pioctl");
             Die (errno,0);
@@ -3458,7 +3669,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;
@@ -3501,7 +3712,7 @@ GetPrefCmd(struct cmd_syndesc *as, char *arock)
            (MAXSIZE - 2 * sizeof(short)) / sizeof(struct spref);
        in->flags = vlservers;
 
-       code = pioctl(0, VIOC_GETSPREFS, &blob, 1);
+       code = pioctl_utf8(0, VIOC_GETSPREFS, &blob, 1);
        if (code) {
            perror("getserverprefs pioctl");
            return 1;
@@ -3528,8 +3739,112 @@ GetPrefCmd(struct cmd_syndesc *as, char *arock)
 }
 #endif /* WIN32 */
 
+static afs_int32
+SmbUnicodeCmd(struct cmd_syndesc * asp, void * arock)
+{
+    long inValue = 0;
+    long outValue = 0;
+    long code;
+
+    struct ViceIoctl blob;
+
+    if (asp->parms[0].items) {
+        /* On */
+
+        inValue = 3;
+    } else if (asp->parms[1].items) {
+        /* Off */
+
+        inValue = 2;
+    }
+
+    if (inValue != 0 && !IsAdmin()) {
+        fprintf (stderr, "Permission denied: Requires AFS Client Administrator access.\n");
+        return EACCES;
+    }
+
+    blob.in_size = sizeof(inValue);
+    blob.in = (char *) &inValue;
+    blob.out_size = sizeof(outValue);
+    blob.out = (char *) &outValue;
+
+    code = pioctl_utf8(NULL, VIOC_UNICODECTL, &blob, 1);
+    if (code) {
+        Die(errno, NULL);
+        return code;
+    }
+
+    if (outValue != 2) {
+        printf("Unicode support is %s%s.\n",
+               ((outValue != 0)? "enabled":"disabled"),
+               ((inValue != 0)? " for new SMB connections":""));
+    } else {
+        printf("Unicode support is absent in this installation of OpenAFS.\n");
+    }
+
+    return 0;
+}
+
 static int
-UuidCmd(struct cmd_syndesc *asp, char *arock)
+GetFidCmd(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;
+
+    SetDotDefault(&as->parms[0].items);
+    for(ti=as->parms[0].items; ti; ti=ti->next) {
+        cm_fid_t fid;
+        afs_uint32 filetype;
+       afs_uint32 owner[2];
+       char cell[CELL_MAXNAMELEN];
+
+        /* 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_utf8(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_utf8(ti->data, VIOC_GETFILETYPE, &blob, 1);
+
+        blob.out_size = CELL_MAXNAMELEN;
+        blob.out = cell;
+
+        code = pioctl_utf8(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);
+    }
+    return error;
+}
+
+static int
+UuidCmd(struct cmd_syndesc *asp, void *arock)
 {
     long code;
     long inValue;
@@ -3537,19 +3852,18 @@ UuidCmd(struct cmd_syndesc *asp, char *arock)
     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;
-    }
+        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;
-    }
+        if (geteuid()) {
+            fprintf (stderr, "Permission denied: requires root access.\n");
+            return EACCES;
+        }
 #endif
-
-    if (asp->parms[0].items) {
         inValue = 1;            /* generate new UUID */
     } else {
         inValue = 0;            /* just show the current UUID */
@@ -3560,7 +3874,7 @@ UuidCmd(struct cmd_syndesc *asp, char *arock)
     blob.out_size = sizeof(outValue);
     blob.out = (char *) &outValue;
 
-    code = pioctl(NULL, VIOC_UUIDCTL, &blob, 1);
+    code = pioctl_utf8(NULL, VIOC_UUIDCTL, &blob, 1);
     if (code) {
         Die(errno, NULL);
         return code;
@@ -3579,7 +3893,7 @@ UuidCmd(struct cmd_syndesc *asp, char *arock)
 }
 
 static int
-TraceCmd(struct cmd_syndesc *asp, char *arock)
+TraceCmd(struct cmd_syndesc *asp, void *arock)
 {
     long code;
     struct ViceIoctl blob;
@@ -3619,7 +3933,7 @@ TraceCmd(struct cmd_syndesc *asp, char *arock)
     blob.out_size = sizeof(long);
     blob.out = (char *) &outValue;
         
-    code = pioctl(NULL, VIOC_TRACECTL, &blob, 1);
+    code = pioctl_utf8(NULL, VIOC_TRACECTL, &blob, 1);
     if (code) {
         Die(errno, NULL);
         return code;
@@ -3641,7 +3955,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;
@@ -3700,14 +4014,14 @@ StoreBehindCmd(struct cmd_syndesc *as, char *arock)
     /* once per -file */
     for (ti = as->parms[1].items; ti; ti = ti->next) {
        /* Do this solely to see if the file is there */
-       code = pioctl(ti->data, VIOCWHEREIS, &blob, 1);
+       code = pioctl_utf8(ti->data, VIOCWHEREIS, &blob, 1);
        if (code) {
            Die(errno, ti->data);
            error = 1;
            continue;
        }
 
-       code = pioctl(ti->data, VIOC_STOREBEHIND, &blob, 1);
+       code = pioctl_utf8(ti->data, VIOC_STOREBEHIND, &blob, 1);
        if (code) {
            Die(errno, ti->data);
            error = 1;
@@ -3731,7 +4045,7 @@ StoreBehindCmd(struct cmd_syndesc *as, char *arock)
      */
     if (!as->parms[1].items || (allfiles != -1)) {
        tsb.sb_default = allfiles;
-       code = pioctl(0, VIOC_STOREBEHIND, &blob, 1);
+       code = pioctl_utf8(0, VIOC_STOREBEHIND, &blob, 1);
        if (code) {
            Die(errno, ((allfiles == -1) ? 0 : "-allfiles"));
            error = 1;
@@ -3748,7 +4062,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;
@@ -3766,22 +4080,24 @@ SetCryptCmd(struct cmd_syndesc *as, char *arock)
       flag = 1;
     else if (strcmp(tp, "off") == 0)
       flag = 0;
+    else if (strcmp(tp, "auth") == 0)
+      flag = 2;
     else {
-      fprintf (stderr, "%s: %s must be \"on\" or \"off\".\n", pn, tp);
+      fprintf (stderr, "%s: %s must be \"on\", \"auth\", or \"off\".\n", pn, tp);
       return EINVAL;
     }
 
     blob.in = (char *) &flag;
     blob.in_size = sizeof(flag);
     blob.out_size = 0;
-    code = pioctl(0, VIOC_SETRXKCRYPT, &blob, 1);
+    code = pioctl_utf8(0, VIOC_SETRXKCRYPT, &blob, 1);
     if (code)
         Die(code, NULL);
     return 0;
 }
 
 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;
@@ -3792,7 +4108,7 @@ GetCryptCmd(struct cmd_syndesc *as, char *arock)
     blob.out_size = sizeof(flag);
     blob.out = space;
 
-    code = pioctl(0, VIOC_GETRXKCRYPT, &blob, 1);
+    code = pioctl_utf8(0, VIOC_GETRXKCRYPT, &blob, 1);
 
     if (code) 
         Die(code, NULL);
@@ -3800,7 +4116,9 @@ GetCryptCmd(struct cmd_syndesc *as, char *arock)
       tp = space;
       memcpy(&flag, tp, sizeof(afs_int32));
       printf("Security level is currently ");
-      if (flag == 1)
+      if (flag == 2)
+          printf("auth (data integrity).\n");
+      else if (flag == 1)
         printf("crypt (data security).\n");
       else
         printf("clear.\n");
@@ -3809,7 +4127,7 @@ 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;
@@ -3838,7 +4156,7 @@ MemDumpCmd(struct cmd_syndesc *asp, char *arock)
     blob.out_size = sizeof(long);
     blob.out = (char *) &outValue;
 
-    code = pioctl(NULL, VIOC_TRACEMEMDUMP, &blob, 1);
+    code = pioctl_utf8(NULL, VIOC_TRACEMEMDUMP, &blob, 1);
     if (code) {
         Die(errno, NULL);
         return code;
@@ -3854,7 +4172,7 @@ MemDumpCmd(struct cmd_syndesc *asp, char *arock)
 }
 
 static int
-MiniDumpCmd(struct cmd_syndesc *asp, char *arock)
+MiniDumpCmd(struct cmd_syndesc *asp, void *arock)
 {
     BOOL success = 0;
     SERVICE_STATUS status;
@@ -3895,7 +4213,7 @@ MiniDumpCmd(struct cmd_syndesc *asp, char *arock)
 }
 
 static int
-CSCPolicyCmd(struct cmd_syndesc *asp, char *arock)
+CSCPolicyCmd(struct cmd_syndesc *asp, void *arock)
 {
     struct cmd_item *ti;
     char *share = NULL;
@@ -3923,7 +4241,7 @@ CSCPolicyCmd(struct cmd_syndesc *asp, char *arock)
                         0, 
                         "AFS", 
                         REG_OPTION_NON_VOLATILE,
-                        KEY_WRITE,
+                        (IsWow64()?KEY_WOW64_64KEY:0)|KEY_WRITE,
                         NULL, 
                         &hkCSCPolicy,
                         NULL );
@@ -3971,7 +4289,7 @@ CSCPolicyCmd(struct cmd_syndesc *asp, char *arock)
                         0, 
                         "AFS", 
                         REG_OPTION_NON_VOLATILE,
-                        KEY_READ|KEY_QUERY_VALUE,
+                        (IsWow64()?KEY_WOW64_64KEY:0)|KEY_READ|KEY_QUERY_VALUE,
                         NULL, 
                         &hkCSCPolicy,
                         NULL );
@@ -4009,7 +4327,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;
@@ -4030,7 +4348,7 @@ GetClientAddrsCmd(struct cmd_syndesc *as, char *arock)
        in->num_servers =
            (MAXSIZE - 2 * sizeof(short)) / sizeof(struct spref);
        /* returns addr in network byte order */
-       code = pioctl(0, VIOC_GETCPREFS, &blob, 1);
+       code = pioctl_utf8(0, VIOC_GETCPREFS, &blob, 1);
        if (code) {
            perror("getClientInterfaceAddr pioctl");
            return 1;
@@ -4055,7 +4373,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;
@@ -4119,7 +4437,7 @@ SetClientAddrsCmd(struct cmd_syndesc *as, char *arock)
     }
     blob.in_size = sizeUsed - sizeof(struct spref);
 
-    code = pioctl(0, VIOC_SETCPREFS, &blob, 1);        /* network order */
+    code = pioctl_utf8(0, VIOC_SETCPREFS, &blob, 1);   /* network order */
     if (code) {
        Die(errno, 0);
        error = 1;
@@ -4129,7 +4447,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;
@@ -4230,7 +4548,7 @@ FlushMountCmd(struct cmd_syndesc *as, char *arock)
        blob.out_size = 0;
        memset(space, 0, MAXSIZE);
 
-       code = pioctl(parent_dir, VIOC_AFS_FLUSHMOUNT, &blob, 1);
+       code = pioctl_utf8(parent_dir, VIOC_AFS_FLUSHMOUNT, &blob, 1);
 
        if (code != 0) {
            if (errno == EINVAL) {
@@ -4246,7 +4564,7 @@ FlushMountCmd(struct cmd_syndesc *as, char *arock)
 #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;
@@ -4270,7 +4588,7 @@ RxStatProcCmd(struct cmd_syndesc *as, char *arock)
     blob.in_size = sizeof(afs_int32);
     blob.out_size = 0;
 
-    code = pioctl(NULL, VIOC_RXSTAT_PROC, &blob, 1);
+    code = pioctl_utf8(NULL, VIOC_RXSTAT_PROC, &blob, 1);
     if (code != 0) {
        Die(errno, NULL);
        return 1;
@@ -4280,7 +4598,7 @@ 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;
@@ -4304,7 +4622,87 @@ RxStatPeerCmd(struct cmd_syndesc *as, char *arock)
     blob.in_size = sizeof(afs_int32);
     blob.out_size = 0;
 
-    code = pioctl(NULL, VIOC_RXSTAT_PEER, &blob, 1);
+    code = pioctl_utf8(NULL, VIOC_RXSTAT_PEER, &blob, 1);
+    if (code != 0) {
+       Die(errno, NULL);
+       return 1;
+    }
+
+    return 0;
+}
+
+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_utf8(NULL, VIOC_VOLSTAT_TEST, &blob, 1);
     if (code != 0) {
        Die(errno, NULL);
        return 1;
@@ -4317,10 +4715,55 @@ RxStatPeerCmd(struct cmd_syndesc *as, char *arock)
 #include "AFS_component_version_number.c"
 #endif
 
-main(int argc, char **argv)
+static void
+FreeUtf8CmdLine(int argc, char ** argv)
+{
+    int i;
+    for (i=0; i < argc; i++) {
+        if (argv[i])
+            free(argv[i]);
+    }
+    free(argv);
+}
+
+static char **
+MakeUtf8Cmdline(int argc, const wchar_t **wargv)
+{
+    char ** argv;
+    int i;
+
+    argv = calloc(argc, sizeof(argv[0]));
+    if (argv == NULL)
+        return NULL;
+
+    for (i=0; i < argc; i++) {
+        int s;
+
+        s = WideCharToMultiByte(CP_UTF8, 0, wargv[i], -1, NULL, 0, NULL, FALSE);
+        if (s == 0 ||
+            (argv[i] = calloc(s+1, sizeof(char))) == NULL) {
+            break;
+        }
+
+        s = WideCharToMultiByte(CP_UTF8, 0, wargv[i], -1, argv[i], s+1, NULL, FALSE);
+        if (s == 0) {
+            break;
+        }
+    }
+
+    if (i < argc) {
+        FreeUtf8CmdLine(argc, argv);
+        return NULL;
+    }
+
+    return argv;
+}
+
+int wmain(int argc, wchar_t **wargv)
 {
     afs_int32 code;
     struct cmd_syndesc *ts;
+    char ** argv;
 
 #ifdef AFS_AIX32_ENV
     /*
@@ -4342,36 +4785,38 @@ main(int argc, char **argv)
     WSAStartup(0x0101, &WSAjunk);
 #endif /* WIN32 */
 
+    argv = MakeUtf8Cmdline(argc, wargv);
+
     /* try to find volume location information */
     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");
@@ -4381,17 +4826,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");
@@ -4401,16 +4846,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
@@ -4420,29 +4866,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");
@@ -4457,31 +4904,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");
     
-    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
@@ -4489,7 +4936,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");
@@ -4506,110 +4953,131 @@ 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("flushall", FlushAllCmd, 0, "flush all data");
+    ts = cmd_CreateSyntax("flushall", FlushAllCmd, NULL, "flush all data");
 
-    ts = cmd_CreateSyntax("flushvolume", FlushVolumeCmd, 0, "flush all data in volume");
+    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");
 
-    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");
 
 #ifndef WIN32
-    ts = cmd_CreateSyntax("setcbaddr", CallBackRxConnCmd, 0, "configure callback connection address");
+    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("uuid", UuidCmd, 0, "manage the UUID for the cache manager");
+    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, 0, "dump memory allocs in debug builds");
+    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, 0, "Generate MiniDump of current service state");
+    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");
+
+    ts = cmd_CreateSyntax("smbunicode", SmbUnicodeCmd, NULL, "enable or disable Unicode on new SMB connections");
+    cmd_AddParm(ts, "-on", CMD_FLAG, CMD_OPTIONAL, "enable Unicode on new connections");
+    cmd_AddParm(ts, "-off", CMD_FLAG, CMD_OPTIONAL, "disable Unicode on new connections");
+
+    ts = cmd_CreateSyntax("getfid", GetFidCmd, NULL, "get file id for object(s) in afs");
+    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");
 
     code = cmd_Dispatch(argc, argv);
 
     if (rxInitDone) 
         rx_Finalize();
     
+    FreeUtf8CmdLine(argc, argv);
+    
     return code;
 }
 
@@ -4640,10 +5108,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) {
@@ -4655,6 +5123,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);