Windows: Explorer shell GetUnixModeBits()
[openafs.git] / src / WINNT / client_exp / gui2fs.cpp
index 3bfc1b8..faba0ca 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright 2000, International Business Machines Corporation and others.
  * All Rights Reserved.
- * 
+ *
  * This software has been released under the terms of the IBM Public
  * License.  For details, see the LICENSE file in the top-level source
  * directory or online at http://www.openafs.org/dl/license10.html
@@ -12,7 +12,9 @@
 #include <ws2tcpip.h>
 
 extern "C" {
+#include <afsconfig.h>
 #include <afs/param.h>
+#include <roken.h>
 #include <afs/stds.h>
 }
 
@@ -30,24 +32,40 @@ extern "C" {
 
 extern "C" {
 #include <rx/rx_globals.h>
-#include "fs.h"
 #include "fs_utils.h"
-#include <afsint.h>
+#include "fs_acl.h"
+#include <afs/afsint.h>
+#include <afs/afs_consts.h>
 #include <afs/cellconfig.h>
+#include <afs/ptserver.h>
+#include <afs/ptuser.h>
 #include <afs/vldbint.h>
 #include <afs/volser.h>
 #include <afs/auth.h>
 #include <WINNT\afsreg.h>
 #include <cm.h>
+#include <cm_nls.h>
+#include <osi.h>
+#include <cm_user.h>
+#include <cm_scache.h>
+#include <cm_ioctl.h>
+#include <cm_config.h>
 }
 
+#define STRSAFE_NO_DEPRECATE
+#include <strsafe.h>
+
+/*
+ * the NO_CALLER symbol is used to document functions
+ * that are present in this file but have no caller
+ */
+#define NO_CALLER
+
+
 #define PCCHAR(str)            ((char *)(const char *)(str))
 #define VL_NOENT                (363524L)
 
-#define        MAXHOSTS 13
-#define        OMAXHOSTS 8
 #define MAXNAME 100
-#define        MAXSIZE 2048
 #define MAXINSIZE 1300    /* pioctl complains if data is larger than this */
 #define VMSGSIZE 128      /* size of msg buf in volume hdr */
 
@@ -55,9 +73,6 @@ extern "C" {
 #define MAXHOSTCHARS           64
 #define MAXHOSTSPERCELL                8
 
-static char space[MAXSIZE];
-static char tspace[1024];
-
 static struct ubik_client *uclient;
 static int rxInitDone = 0;
 static char pn[] = "fs";
@@ -68,13 +83,89 @@ static char pn[] = "fs";
 static char *szLogFileName = "afsguilog.txt";
 #endif
 
-static int
+#ifdef UNICODE
+class CStringUtf8 : public CStringA
+{
+public:
+    CStringUtf8(const CStringW& csw) : CStringA()
+    {
+        SetString(csw);
+    }
+
+    CStringUtf8(const char * cp) : CStringA(cp) {}
+
+    CStringUtf8() :CStringA() {}
+
+    void SetString(const CStringW& csw)
+    {
+        char buffer[1024];
+        int rv;
+
+        rv = WideCharToMultiByte(CP_UTF8, 0, csw, -1,
+                                 buffer, sizeof(buffer),
+                                 NULL, FALSE);
+
+        if (rv != 0) {
+            CStringA::SetString(buffer);
+        } else {
+            if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
+                int cb_req;
+
+                cb_req = WideCharToMultiByte(CP_UTF8, 0, csw, -1, NULL, 0, NULL, FALSE);
+                if (cb_req != 0) {
+                    cb_req ++;
+
+                    WideCharToMultiByte(CP_UTF8, 0, csw, -1, CStringA::GetBuffer(cb_req), cb_req, NULL, FALSE);
+                    CStringA::ReleaseBuffer();
+                }
+            } else {
+#ifdef DEBUG
+                DebugBreak();
+#endif
+            }
+        }
+    }
+
+    static CString _Utf8ToCString(const char * ustr)
+    {
+        CString cs;
+        int cch;
+
+        cch = MultiByteToWideChar(CP_UTF8, 0, ustr, -1, NULL, 0);
+        if (cch == 0) {
+            cs.Empty();
+            return cs;
+        }
+
+        cch++;
+        cch = MultiByteToWideChar(CP_UTF8, 0, ustr, -1, cs.GetBuffer(cch), cch);
+        cs.ReleaseBuffer();
+
+        return cs;
+    }
+};
+
+long
+pioctl_T(const CString& path, long opcode, struct ViceIoctl * blob, int follow)
+{
+    CStringUtf8 upath(path);
+
+    return pioctl_utf8(PCCHAR(upath), opcode, blob, follow);
+}
+
+#define Utf8ToCString(cs) CStringUtf8::_Utf8ToCString(cs)
+#else
+#define pioctl_T(path, op, vblob, follow) pioctl(PCCHAR(path), op, vblob, follow)
+#define Utf8ToCString(cs) (cs)
+#endif
+
+static int NO_CALLER
 VLDBInit(int noAuthFlag, struct afsconf_cell *info)
 {
     afs_int32 code;
 
-    code = ugen_ClientInit(noAuthFlag, (char *)AFSDIR_CLIENT_ETC_DIRPATH, 
-                          info->name, 0, &uclient, 
+    code = ugen_ClientInit(noAuthFlag, (char *)AFSDIR_CLIENT_ETC_DIRPATH,
+                          info->name, 0, &uclient,
                            NULL, pn, rxkad_clear,
                            VLDB_MAXSERVERS, AFSCONF_VLDBSERVICE, 50,
                            0, 0, USER_SERVICE_ID);
@@ -82,15 +173,16 @@ VLDBInit(int noAuthFlag, struct afsconf_cell *info)
     return code;
 }
 
-FILE *OpenFile(char *file, char *rwp)
+static FILE *
+OpenFile(char *file, char *rwp)
 {
     char wdir[256];
     long code;
     long tlen;
     FILE *fp;
 
-    code = GetWindowsDirectory(wdir, sizeof(wdir));
-    if (code == 0 || code > sizeof(wdir)) 
+    code = GetWindowsDirectoryA(wdir, sizeof(wdir));
+    if (code == 0 || code > sizeof(wdir))
         return FALSE;
 
     /* add trailing backslash, if required */
@@ -103,9 +195,9 @@ FILE *OpenFile(char *file, char *rwp)
     fp = fopen(wdir, rwp);
 
     return fp;
-}       
+}
 
-CString StripPath(CString& strPath)
+CString StripPath(const CString& strPath)
 {
     int nIndex = strPath.ReverseFind('\\');
 
@@ -116,7 +208,8 @@ CString StripPath(CString& strPath)
     return strFile;
 }
 
-CStringArray& StripPath(CStringArray& files)
+CStringArray&
+StripPath(CStringArray& files)
 {
     for (int i = 0; i < files.GetSize(); i++)
         files[i] = StripPath(files[i]);
@@ -124,9 +217,10 @@ CStringArray& StripPath(CStringArray& files)
     return files;
 }
 
-void Flush(const CStringArray& files)
+void
+Flush(const CStringArray& files)
 {
-    register LONG code;
+    LONG code;
     struct ViceIoctl blob;
     int error = 0;
 
@@ -135,23 +229,24 @@ void Flush(const CStringArray& files)
     for (int i = 0; i < files.GetSize(); i++) {
         blob.in_size = blob.out_size = 0;
 
-        code = pioctl(PCCHAR(files[i]), VIOCFLUSH, &blob, 0);
+        code = pioctl_T(files[i], VIOCFLUSH, &blob, 0);
         if (code) {
             error = 1;
             if (errno == EMFILE)
                 ShowMessageBox(IDS_FLUSH_FAILED, MB_ICONERROR, IDS_FLUSH_FAILED, files[i]);
-            else 
+            else
                 ShowMessageBox(IDS_FLUSH_ERROR, MB_ICONERROR, IDS_FLUSH_ERROR, files[i], strerror(errno));
         }
-    }   
+    }
 
     if (!error)
         ShowMessageBox(IDS_FLUSH_OK, MB_ICONINFORMATION, IDS_FLUSH_OK);
-}       
+}
 
-void FlushVolume(const CStringArray& files)
+void
+FlushVolume(const CStringArray& files)
 {
-    register LONG code;
+    LONG code;
     struct ViceIoctl blob;
     int error = 0;
 
@@ -160,20 +255,21 @@ void FlushVolume(const CStringArray& files)
     for (int i = 0; i < files.GetSize(); i++) {
         blob.in_size = blob.out_size = 0;
 
-        code = pioctl(PCCHAR(files[i]), VIOC_FLUSHVOLUME, &blob, 0);
+        code = pioctl_T(files[i], VIOC_FLUSHVOLUME, &blob, 0);
         if (code) {
             error = 1;
             ShowMessageBox(IDS_FLUSH_VOLUME_ERROR, MB_ICONERROR, IDS_FLUSH_VOLUME_ERROR, files[i], strerror(errno));
         }
-    }   
+    }
 
     if (!code)
         ShowMessageBox(IDS_FLUSH_VOLUME_OK, MB_ICONINFORMATION, IDS_FLUSH_VOLUME_OK);
-}       
+}
 
-void WhichCell(CStringArray& files)
+void NO_CALLER
+WhichCell(CStringArray& files)
 {
-    register LONG code;
+    LONG code;
     struct ViceIoctl blob;
     int error;
     CString str;
@@ -186,20 +282,24 @@ void WhichCell(CStringArray& files)
     HOURGLASS hourglass;
 
     for (int i = 0; i < files.GetSize(); i++) {
+        char space[AFS_PIOCTL_MAXSIZE];
+
         blob.in_size = 0;
-        blob.out_size = MAXSIZE;
+        blob.out_size = AFS_PIOCTL_MAXSIZE;
         blob.out = space;
 
-        code = pioctl(PCCHAR(files[i]), VIOC_FILE_CELL_NAME, &blob, 1);
+        code = pioctl_T(files[i], VIOC_FILE_CELL_NAME, &blob, 1);
         if (code) {
             if (code == ENOENT) {
                 LoadString (str, IDS_CANT_GET_CELL);
                 results.Add(str);
             } else
                 results.Add(GetAfsError(errno));
-        } else
-            results.Add(space);
-    }       
+        } else {
+            space[AFS_PIOCTL_MAXSIZE - 1] = '\0';
+            results.Add(Utf8ToCString(space));
+        }
+    }
 
     LoadString (str, IDS_SHOW_CELL);
     LoadString (str2, IDS_SHOW_CELL_COLUMN);
@@ -208,32 +308,34 @@ void WhichCell(CStringArray& files)
     dlg.DoModal();
 }
 
-void WSCellCmd()
+void NO_CALLER
+WSCellCmd(void)
 {
-    register LONG code;
+    char space[AFS_PIOCTL_MAXSIZE];
+    LONG code;
     struct ViceIoctl blob;
-    
+
     HOURGLASS hourglass;
 
     blob.in_size = 0;
     blob.in = (char *) 0;
-    blob.out_size = MAXSIZE;
+    blob.out_size = AFS_PIOCTL_MAXSIZE;
     blob.out = space;
 
     code = pioctl((char *) 0, VIOC_GET_WS_CELL, &blob, 1);
 
-    if (code) {
-        //Die(errno, (char *) 0);
-    }
-    //else
-    //printf("This workstation belongs to cell '%s'\n", space);
+    /*
+     * Cell name is left in 'space' as side effect.
+     * At present no callers of this function.
+     */
 }
 
-BOOL CheckVolumes()
+BOOL NO_CALLER
+CheckVolumes(void)
 {
-    register LONG code;
+    LONG code;
     struct ViceIoctl blob;
-    
+
     blob.in_size = 0;
     blob.out_size = 0;
     code = pioctl(0, VIOCCKBACK, &blob, 1);
@@ -247,11 +349,12 @@ BOOL CheckVolumes()
     return TRUE;
 }
 
-void SetCacheSizeCmd(LONG nNewCacheSize)
+void NO_CALLER
+SetCacheSizeCmd(LONG nNewCacheSize)
 {
-    register LONG code;
+    LONG code;
     struct ViceIoctl blob;
-    
+
     HOURGLASS hourglass;
 
     blob.in = (char *) &nNewCacheSize;
@@ -259,15 +362,14 @@ void SetCacheSizeCmd(LONG nNewCacheSize)
     blob.out_size = 0;
 
     code = pioctl(0, VIOCSETCACHESIZE, &blob, 1);
-    //if (code)
-    // Die(errno, (char *) 0);
-    //else
-    // printf("New cache size set.\n");
+
+    /* error handling? */
 }
 
-void WhereIs(CStringArray& files)
+void NO_CALLER
+WhereIs(CStringArray& files)
 {
-    register LONG code;
+    LONG code;
     struct ViceIoctl blob;
     CStringArray servers;
     CStringArray resultFiles;
@@ -277,12 +379,14 @@ void WhereIs(CStringArray& files)
     HOURGLASS hourglass;
 
     for (int i = 0; i < files.GetSize(); i++) {
-        blob.out_size = MAXSIZE;
+        char space[AFS_PIOCTL_MAXSIZE];
+
+        blob.out_size = AFS_PIOCTL_MAXSIZE;
         blob.in_size = 0;
         blob.out = space;
         memset(space, 0, sizeof(space));
 
-        code = pioctl(PCCHAR(files[i]), VIOCWHEREIS, &blob, 1);
+        code = pioctl_T(files[i], VIOCWHEREIS, &blob, 1);
         if (code) {
             resultFiles.Add(StripPath(files[i]));
             servers.Add(GetAfsError(errno));
@@ -293,7 +397,7 @@ void WhereIs(CStringArray& files)
         BOOL bFirst = TRUE;
         str = "";
 
-        for (int j = 0; j < MAXHOSTS; j++) {
+        for (int j = 0; j < AFS_MAXHOSTS; j++) {
             if (hosts[j] == 0)
                 break;
             char *hostName = hostutil_GetNameByINet(hosts[j]);
@@ -311,7 +415,7 @@ void WhereIs(CStringArray& files)
     CResultsDlg dlg(SHOW_FILE_SERVERS_HELP_ID);
     dlg.SetContents(str, str2, resultFiles, servers);
     dlg.DoModal();
-}       
+}
 
 static int
 CMtoUNIXerror(int cm_code)
@@ -355,7 +459,8 @@ CMtoUNIXerror(int cm_code)
     }
 }
 
-CString GetAfsError(int code, const char *filename)
+CString
+GetAfsError(int code, const TCHAR *filename)
 {
     CString strMsg;
 
@@ -363,60 +468,38 @@ CString GetAfsError(int code, const char *filename)
 
     if (code == EINVAL) {
         if (filename)
-            strMsg.Format("Invalid argument; it is possible that the file is not in AFS");
-        else 
-            strMsg.Format("Invalid argument");
+            strMsg.Format(_T("Invalid argument; it is possible that the file is not in AFS"));
+        else
+            strMsg.Format(_T("Invalid argument"));
     } else if (code == ENOENT) {
-        if (filename) 
-            strMsg.Format("The file does not exist");
-        else 
-            strMsg.Format("No such file returned");
+        if (filename)
+            strMsg.Format(_T("The file does not exist"));
+        else
+            strMsg.Format(_T("No such file returned"));
     } else if (code == EROFS)  {
-        strMsg.Format("You can not change a backup or readonly volume");
+        strMsg.Format(_T("You can not change a backup or readonly volume"));
     } else if (code == EACCES || code == EPERM) {
-        strMsg.Format("You do not have the required rights to do this operation");
+        strMsg.Format(_T("You do not have the required rights to do this operation"));
     } else if (code == ENODEV) {
-        strMsg.Format("AFS service may not have started");
+        strMsg.Format(_T("AFS service may not have started"));
     } else if (code == ESRCH) {
-        strMsg.Format("Cell name not recognized");
+        strMsg.Format(_T("Cell name not recognized"));
     } else if (code == ETIMEDOUT) {
-        strMsg.Format("Connection timed out");
+        strMsg.Format(_T("Connection timed out"));
     } else if (code == EPIPE) {
-        strMsg.Format("Volume name or ID not recognized");
+        strMsg.Format(_T("Volume name or ID not recognized"));
     } else {
-        strMsg.Format("Error 0x%x occurred", code);
+        strMsg.Format(_T("Error 0x%x occurred"), code);
     }
 
     return strMsg;
 }
 
 
-/************************************************************************
-************************** ACL Code *************************************
-************************************************************************/
-
-typedef char sec_rgy_name_t[1025];     /* A DCE definition */
-
-struct AclEntry {
-    struct AclEntry *next;
-    char name[MAXNAME];
-    LONG rights;
-};
-
-struct Acl {
-    int dfs;                   //      Originally true if a dfs acl; now also the type
-                                //     of the acl (1, 2, or 3, corresponding to object,
-                               //      initial dir, or initial object).
-    sec_rgy_name_t cell;       //      DFS cell name
-    int nplus;
-    int nminus;
-    struct AclEntry *pluslist;
-    struct AclEntry *minuslist;
-};
-
-int foldcmp (register char *a, register char *b)
+static int
+foldcmp (char *a, char *b)
 {
-    register char t, u;
+    char t, u;
     while (1) {
         t = *a++;
         u = *b++;
@@ -427,241 +510,55 @@ int foldcmp (register char *a, register char *b)
     }
 }
 
-extern "C" void ZapList(struct AclEntry *alist)
-{
-    register struct AclEntry *tp, *np;
-
-    for (tp = alist; tp; tp = np) {
-        np = tp->next;
-        free(tp);
-    }
-}
-
-extern "C" void ZapAcl (struct Acl *acl)
-{
-    ZapList(acl->pluslist);
-    ZapList(acl->minuslist);
-    free(acl);
-}
-
-extern "C" int PruneList (struct AclEntry **ae, int dfs)
-{
-    struct AclEntry **lp = ae;
-    struct AclEntry *te, *ne;
-    LONG ctr = 0;
-    
-    for (te = *ae; te; te = ne) {
-        if ((!dfs && te->rights == 0) || te->rights == -1) {
-            *lp = te->next;
-            ne = te->next;
-            free(te);
-            ctr++;
-        }
-        else {
-            ne = te->next;
-            lp = &te->next;
-        }
-    }
-    
-    return ctr;
-}
-
-char *SkipLine (register char *astr)
-{
-    while (*astr != '\n') 
-        astr++;
-    
-    astr++;
-    
-    return astr;
-}
-
-/* tell if a name is 23 or -45 (digits or minus digits), which are bad names we must prune */
-static int BadName(register char *aname)
-{
-    register int tc;
-
-    /* all must be '-' or digit to be bad */
-    while (tc = *aname++) {
-        if ((tc != '-') && (tc < '0' || tc > '9')) 
-            return 0;
-    }
-
-    return 1;
-}
-
-CString GetRightsString(register LONG arights, int dfs)
+CString
+GetRightsString(LONG arights, int dfs)
 {
     CString str;
 
     if (!dfs) {
-        if (arights & PRSFS_READ) str += "r";
-        if (arights & PRSFS_LOOKUP) str += "l";
-        if (arights & PRSFS_INSERT) str += "i";
-        if (arights & PRSFS_DELETE) str += "d";
-        if (arights & PRSFS_WRITE) str += "w";
-        if (arights & PRSFS_LOCK) str += "k";
-        if (arights & PRSFS_ADMINISTER) str += "a";
+        if (arights & PRSFS_READ) str += _T("r");
+        if (arights & PRSFS_LOOKUP) str += _T("l");
+        if (arights & PRSFS_INSERT) str += _T("i");
+        if (arights & PRSFS_DELETE) str += _T("d");
+        if (arights & PRSFS_WRITE) str += _T("w");
+        if (arights & PRSFS_LOCK) str += _T("k");
+        if (arights & PRSFS_ADMINISTER) str += _T("a");
     } else {
         ASSERT(FALSE);
 /*
-               if (arights & DFS_READ) str += "r"; else str += "-";
-               if (arights & DFS_WRITE) str += "w"; else printf("-");
-               if (arights & DFS_EXECUTE) str += "x"; else printf("-");
-               if (arights & DFS_CONTROL) str += "c"; else printf("-");
-               if (arights & DFS_INSERT) str += "i"; else printf("-");
-               if (arights & DFS_DELETE) str += "d"; else printf("-");
-               if (arights & (DFS_USRALL)) str += "+";
+               if (arights & DFS_READ) str += _T("r"); else str += _T("-");
+               if (arights & DFS_WRITE) str += _T("w"); else printf(_T("-"));
+               if (arights & DFS_EXECUTE) str += _T("x"); else printf(_T("-"));
+               if (arights & DFS_CONTROL) str += _T("c"); else printf(_T("-"));
+               if (arights & DFS_INSERT) str += _T("i"); else printf(_T("-"));
+               if (arights & DFS_DELETE) str += _T("d"); else printf(_T("-"));
+               if (arights & (DFS_USRALL)) str += _T("+");
 */
-    }  
+    }
 
     return str;
 }
 
-char *AclToString(struct Acl *acl)
+struct Acl *
+EmptyAcl(const CString& strCellName)
 {
-    static char mydata[MAXSIZE];
-    char tstring[MAXSIZE];
-    char dfsstring[30];
-    struct AclEntry *tp;
-    
-    if (acl->dfs)
-        sprintf(dfsstring, " dfs:%d %s", acl->dfs, acl->cell);
-    else
-        dfsstring[0] = '\0';
-    sprintf(mydata, "%d%s\n%d\n", acl->nplus, dfsstring, acl->nminus);
-    
-    for(tp = acl->pluslist; tp; tp = tp->next) {
-        sprintf(tstring, "%s %d\n", tp->name, tp->rights);
-        strcat(mydata, tstring);
-    }
-    
-    for(tp = acl->minuslist; tp; tp = tp->next) {
-        sprintf(tstring, "%s %d\n", tp->name, tp->rights);
-        strcat(mydata, tstring);
-    }
-    
-    return mydata;
-}
+    struct Acl *tp;
+    CStringUtf8 ustrCell(strCellName);
 
-struct Acl *EmptyAcl(const CString& strCellName)
-{
-    register struct Acl *tp;
-    
     tp = (struct Acl *)malloc(sizeof (struct Acl));
     tp->nplus = tp->nminus = 0;
     tp->pluslist = tp->minuslist = 0;
     tp->dfs = 0;
-    strcpy(tp->cell, strCellName);
+    StringCbCopyA(tp->cell, sizeof(tp->cell), ustrCell);
 
     return tp;
 }
 
-struct Acl *ParseAcl(char *astr)
+void
+CleanACL(CStringArray& names)
 {
-    int nplus, nminus, i, trights;
-    char tname[MAXNAME];
-    struct AclEntry *first, *last, *tl;
+    LONG code;
     struct Acl *ta;
-
-    ta = (struct Acl *) malloc (sizeof (struct Acl));
-    ta->dfs = 0;
-    sscanf(astr, "%d dfs:%d %s", &ta->nplus, &ta->dfs, ta->cell);
-    astr = SkipLine(astr);
-    sscanf(astr, "%d", &ta->nminus);
-    astr = SkipLine(astr);
-
-    nplus = ta->nplus;
-    nminus = ta->nminus;
-
-    last = 0;
-    first = 0;
-    for(i = 0; i < nplus; i++) {
-        sscanf(astr, "%100s %d", tname, &trights);
-        astr = SkipLine(astr);
-        tl = (struct AclEntry *) malloc(sizeof (struct AclEntry));
-        if (!first)
-                       first = tl;
-        strcpy(tl->name, tname);
-        tl->rights = trights;
-        tl->next = 0;
-        if (last)
-                       last->next = tl;
-        last = tl;
-    }
-    ta->pluslist = first;
-
-    last = 0;
-    first = 0;
-    for(i=0; i < nminus; i++) {
-        sscanf(astr, "%100s %d", tname, &trights);
-        astr = SkipLine(astr);
-        tl = (struct AclEntry *) malloc(sizeof (struct AclEntry));
-        if (!first) 
-                       first = tl;
-        strcpy(tl->name, tname);
-        tl->rights = trights;
-        tl->next = 0;
-        if (last) 
-                       last->next = tl;
-        last = tl;
-    }
-    ta->minuslist = first;
-
-    return ta;
-}
-
-/* clean up an access control list of its bad entries; return 1 if we made
-   any changes to the list, and 0 otherwise */
-extern "C" int CleanAcl(struct Acl *aa)
-{
-    register struct AclEntry *te, **le, *ne;
-    int changes;
-
-    HOURGLASS hourglass;
-
-    /* Don't correct DFS ACL's for now */
-    if (aa->dfs)
-        return 0;
-
-    /* prune out bad entries */
-    changes = 0;           /* count deleted entries */
-    le = &aa->pluslist;
-    for(te = aa->pluslist; te; te = ne) {
-        ne = te->next;
-        if (BadName(te->name)) {
-            /* zap this dude */
-            *le = te->next;
-            aa->nplus--;
-            free(te);
-            changes++;
-        }
-        else
-            le = &te->next;
-    }
-
-    le = &aa->minuslist;
-    
-    for(te = aa->minuslist; te; te = ne) {
-        ne = te->next;
-        if (BadName(te->name)) {
-            /* zap this dude */
-            *le = te->next;
-            aa->nminus--;
-            free(te);
-            changes++;
-        }
-        else
-            le = &te->next;
-    }   
-
-    return changes;
-}
-
-void CleanACL(CStringArray& names)
-{
-    register LONG code;
-    register struct Acl *ta;
     struct ViceIoctl blob;
     int changes;
 
@@ -670,23 +567,29 @@ void CleanACL(CStringArray& names)
     HOURGLASS hourglass;
 
     for (int i = 0; i < names.GetSize(); i++) {
-        blob.out_size = MAXSIZE;
+        char space[AFS_PIOCTL_MAXSIZE];
+
+        blob.out_size = AFS_PIOCTL_MAXSIZE;
         blob.in_size = 0;
         blob.out = space;
 
-        code = pioctl(PCCHAR(names[i]), VIOCGETAL, &blob, 1);
+        code = pioctl_T(names[i], VIOCGETAL, &blob, 1);
         if (code) {
             ShowMessageBox(IDS_CLEANACL_ERROR, MB_ICONERROR, 0, names[i], GetAfsError(errno));
             continue;
         }
 
-        ta = ParseAcl(space);
+        ta = ParseAcl(space, AFS_PIOCTL_MAXSIZE);
+        if (ta == NULL) {
+            ShowMessageBox(IDS_INVALID_ACL_DATA, MB_ICONERROR, IDS_INVALID_ACL_DATA);
+            continue;
+        }
         if (ta->dfs) {
             ShowMessageBox(IDS_CLEANACL_NOT_SUPPORTED, MB_ICONERROR, IDS_CLEANACL_NOT_SUPPORTED, names[i]);
             continue;
         }
 
-        changes = CleanAcl(ta);
+        changes = CleanAcl(ta, NULL);
         if (!changes)
             continue;
 
@@ -694,8 +597,8 @@ void CleanACL(CStringArray& names)
         blob.in = AclToString(ta);
         blob.in_size = strlen((char *)blob.in) + 1;
         blob.out_size = 0;
-               
-        code = pioctl(PCCHAR(names[i]), VIOCSETAL, &blob, 1);
+
+        code = pioctl_T(names[i], VIOCSETAL, &blob, 1);
         if (code) {
             if (errno == EINVAL) {
                 ShowMessageBox(IDS_CLEANACL_INVALID_ARG, MB_ICONERROR, IDS_CLEANACL_INVALID_ARG, names[i]);
@@ -707,30 +610,35 @@ void CleanACL(CStringArray& names)
             }
         }
     }
-}       
+}
 
 // Derived from fs.c's ListAclCmd
-BOOL GetRights(const CString& strDir, CStringArray& strNormal, CStringArray& strNegative)
+BOOL
+GetRights(const CString& strDir, CStringArray& strNormal, CStringArray& strNegative)
 {
-    register LONG code;
-    register struct Acl *ta;
+    LONG code;
+    struct Acl *ta;
     struct ViceIoctl blob;
     struct AclEntry *te;
     int idf = 0; //getidf(as, parm_listacl_id);
-
+    char space[AFS_PIOCTL_MAXSIZE];
     HOURGLASS hourglass;
 
-    blob.out_size = MAXSIZE;
+    blob.out_size = AFS_PIOCTL_MAXSIZE;
     blob.in_size = idf;
     blob.in = blob.out = space;
-       
-    code = pioctl(PCCHAR(strDir), VIOCGETAL, &blob, 1);
+
+    code = pioctl_T(strDir, VIOCGETAL, &blob, 1);
     if (code) {
         ShowMessageBox(IDS_GETRIGHTS_ERROR, MB_ICONERROR, IDS_GETRIGHTS_ERROR, strDir, GetAfsError(errno));
         return FALSE;
     }
 
-    ta = ParseAcl(space);
+    ta = ParseAcl(space, AFS_PIOCTL_MAXSIZE);
+    if (ta == NULL) {
+        ShowMessageBox(IDS_INVALID_ACL_DATA, MB_ICONERROR, IDS_INVALID_ACL_DATA);
+        return FALSE;
+    }
     if (ta->dfs) {
         ShowMessageBox(IDS_DFSACL_ERROR, MB_ICONERROR, IDS_DFSACL_ERROR);
         return FALSE;
@@ -758,28 +666,31 @@ BOOL GetRights(const CString& strDir, CStringArray& strNormal, CStringArray& str
     return TRUE;
 }
 
-struct AclEntry *FindList(register struct AclEntry *pCurEntry, const char *entryName)
+struct AclEntry *
+FindList(struct AclEntry *pCurEntry, const char *entryName)
 {
     while (pCurEntry) {
         if (!foldcmp(pCurEntry->name, PCCHAR(entryName)))
             return pCurEntry;
         pCurEntry = pCurEntry->next;
     }
-    
+
     return 0;
 }
 
-void ChangeList (struct Acl *pAcl, BYTE bNormalRights, const char *entryName, LONG nEntryRights)
+void
+ChangeList(struct Acl *pAcl, BYTE bNormalRights, const CString & entryName, LONG nEntryRights)
 {
     ASSERT(pAcl);
     ASSERT(entryName);
-    
+
     struct AclEntry *pEntry;
+    CStringUtf8 uEntryName(entryName);
 
     HOURGLASS hourglass;
 
     pEntry = (bNormalRights ? pAcl->pluslist : pAcl->minuslist);
-    pEntry = FindList(pEntry, entryName);
+    pEntry = FindList(pEntry, uEntryName);
 
     /* Found the item already in the list. */
     if (pEntry) {
@@ -794,10 +705,10 @@ void ChangeList (struct Acl *pAcl, BYTE bNormalRights, const char *entryName, LO
     /* Otherwise we make a new item and plug in the new data. */
     pEntry = (struct AclEntry *) malloc(sizeof (struct AclEntry));
     ASSERT(pEntry);
-       
-    strcpy(pEntry->name, entryName);
+
+    strcpy(pEntry->name, uEntryName);
     pEntry->rights = nEntryRights;
-    
+
     if (bNormalRights) {
         pEntry->next = pAcl->pluslist;
         pAcl->pluslist = pEntry;
@@ -814,53 +725,52 @@ void ChangeList (struct Acl *pAcl, BYTE bNormalRights, const char *entryName, LO
     }
 }
 
-enum rtype {add, destroy, deny};
-
-LONG Convert(const register char *arights, int dfs, enum rtype *rtypep)
+static LONG
+Convert(const CString& strRights, int dfs, enum rtype *rtypep)
 {
-    register int i, len;
+    int i, len;
     LONG mode;
-    register char tc;
 
     *rtypep = add;     /* add rights, by default */
 
-    if (!strcmp(arights,"read")) 
+    if (strRights == _T("read"))
         return PRSFS_READ | PRSFS_LOOKUP;
-    if (!strcmp(arights, "write")) 
+    if (strRights == _T("write"))
         return PRSFS_READ | PRSFS_LOOKUP | PRSFS_INSERT | PRSFS_DELETE | PRSFS_WRITE | PRSFS_LOCK;
-    if (!strcmp(arights, "mail")) 
+    if (strRights == _T("mail"))
         return PRSFS_INSERT | PRSFS_LOCK | PRSFS_LOOKUP;
-    if (!strcmp(arights, "all")) 
+    if (strRights == _T("all"))
         return PRSFS_READ | PRSFS_LOOKUP | PRSFS_INSERT | PRSFS_DELETE | PRSFS_WRITE | PRSFS_LOCK | PRSFS_ADMINISTER;
-    
-    if (!strcmp(arights, "none")) {
+
+    if (strRights == _T("none")) {
         *rtypep = destroy; /* Remove entire entry */
         return 0;
     }
 
-    len = strlen(arights);
+    len = strRights.GetLength();
     mode = 0;
 
     for (i = 0; i < len; i++) {
-        tc = *arights++;
-        if (tc == 'r') mode |= PRSFS_READ;
-        else if (tc == 'l') mode |= PRSFS_LOOKUP;
-        else if (tc == 'i') mode |= PRSFS_INSERT;
-        else if (tc == 'd') mode |= PRSFS_DELETE;
-        else if (tc == 'w') mode |= PRSFS_WRITE;
-        else if (tc == 'k') mode |= PRSFS_LOCK;
-        else if (tc == 'a') mode |= PRSFS_ADMINISTER;
+        TCHAR c = strRights[i];
+        if (c == _T('r')) mode |= PRSFS_READ;
+        else if (c == _T('l')) mode |= PRSFS_LOOKUP;
+        else if (c == _T('i')) mode |= PRSFS_INSERT;
+        else if (c == _T('d')) mode |= PRSFS_DELETE;
+        else if (c == _T('w')) mode |= PRSFS_WRITE;
+        else if (c == _T('k')) mode |= PRSFS_LOCK;
+        else if (c == _T('a')) mode |= PRSFS_ADMINISTER;
         else {
-            fprintf(stderr, "illegal rights character '%c'.\n", tc);
+            fprintf(stderr, "illegal rights character '%c'.\n", c);
             exit(1);
         }
-    }   
+    }
     return mode;
 }
 
-BOOL SaveACL(const CString& strCellName, const CString& strDir, const CStringArray& normal, const CStringArray& negative)
+BOOL
+SaveACL(const CString& strCellName, const CString& strDir, const CStringArray& normal, const CStringArray& negative)
 {
-    register LONG code;
+    LONG code;
     struct ViceIoctl blob;
     struct Acl *pAcl;
     LONG rights;
@@ -889,45 +799,51 @@ BOOL SaveACL(const CString& strCellName, const CString& strDir, const CStringArr
     blob.out_size = 0;
     blob.in_size = 1 + strlen((const char *)blob.in);
 
-    code = pioctl(PCCHAR(strDir), VIOCSETAL, &blob, 1);
+    code = pioctl_T(strDir, VIOCSETAL, &blob, 1);
     if (code) {
         if (errno == EINVAL)
             ShowMessageBox(IDS_SAVE_ACL_EINVAL_ERROR, MB_ICONERROR, IDS_SAVE_ACL_EINVAL_ERROR, strDir);
         else
             ShowMessageBox(IDS_SAVE_ACL_ERROR, MB_ICONERROR, IDS_SAVE_ACL_ERROR, strDir, GetAfsError(errno, strDir));
-    }       
+    }
 
     ZapAcl(pAcl);
 
     return (code == 0);
 }
 
-BOOL CopyACL(const CString& strToDir, const CStringArray& normal, const CStringArray& negative, BOOL bClear)
+BOOL
+CopyACL(const CString& strToDir, const CStringArray& normal, const CStringArray& negative, BOOL bClear)
 {
-    register LONG code;
+    LONG code;
     struct ViceIoctl blob;
     struct Acl *pToAcl;
     int idf = 0; // getidf(as, parm_copyacl_id);
-
+    char space[AFS_PIOCTL_MAXSIZE];
     HOURGLASS hourglass;
 
     // Get ACL to copy to
-    blob.out_size = MAXSIZE;
+    blob.out_size = AFS_PIOCTL_MAXSIZE;
     blob.in_size = idf;
     blob.in = blob.out = space;
-       
-    code = pioctl(PCCHAR(strToDir), VIOCGETAL, &blob, 1);
+
+    code = pioctl_T(strToDir, VIOCGETAL, &blob, 1);
     if (code) {
         ShowMessageBox(IDS_ACL_READ_ERROR, MB_ICONERROR, IDS_ACL_READ_ERROR, strToDir, GetAfsError(errno, strToDir));
         return FALSE;
     }
-       
-    if (bClear) 
+
+    if (bClear)
         pToAcl = EmptyAcl(space);
-    else 
-        pToAcl = ParseAcl(space);
+    else
+        pToAcl = ParseAcl(space, AFS_PIOCTL_MAXSIZE);
 
-    CleanAcl(pToAcl);
+    if (pToAcl == NULL) {
+        ShowMessageBox(IDS_INVALID_ACL_DATA, MB_ICONERROR, IDS_INVALID_ACL_DATA);
+        return FALSE;
+    }
+
+    CleanAcl(pToAcl, NULL);
 
     if (pToAcl->dfs) {
         ShowMessageBox(IDS_NO_DFS_COPY_ACL, MB_ICONERROR, IDS_NO_DFS_COPY_ACL, strToDir);
@@ -955,12 +871,12 @@ BOOL CopyACL(const CString& strToDir, const CStringArray& normal, const CStringA
     blob.out_size = 0;
     blob.in_size = 1 + strlen((char *)blob.in);
 
-    code = pioctl(PCCHAR(strToDir), VIOCSETAL, &blob, 1);
+    code = pioctl_T(strToDir, VIOCSETAL, &blob, 1);
     if (code) {
         ZapAcl(pToAcl);
         if (errno == EINVAL)
             ShowMessageBox(IDS_COPY_ACL_EINVAL_ERROR, MB_ICONERROR, IDS_COPY_ACL_EINVAL_ERROR, strToDir);
-        else 
+        else
             ShowMessageBox(IDS_COPY_ACL_ERROR, MB_ICONERROR, IDS_COPY_ACL_ERROR, strToDir, GetAfsError(errno, strToDir));
         return FALSE;
     }
@@ -972,7 +888,8 @@ BOOL CopyACL(const CString& strToDir, const CStringArray& normal, const CStringA
     return TRUE;
 }
 
-CString ParseMountPoint(const CString strFile, CString strMountPoint)
+CString
+ParseMountPoint(const CString strFile, CString strMountPoint)
 {
     CString strType;
     CString strVolume;
@@ -988,43 +905,75 @@ CString ParseMountPoint(const CString strFile, CString strMountPoint)
     if (nColon >= 0) {
         strCell = strMountPoint.Mid(1, nColon - 1);
         strVolume = strMountPoint.Mid(nColon + 1);
-    } else
+    } else {
         strVolume = strMountPoint.Mid(1);
+        strCell = _T("(local)");
+    }
 
-    strMountPointInfo = strFile + "\t" + strVolume + "\t" + strCell + "\t" + strType;
+    strMountPointInfo = _T("=> ") + strVolume + _T(" : ") + strCell + _T(" cell [") + strType + _T("]");
 
     return strMountPointInfo;
-}       
+}
 
-CString ParseSymlink(const CString strFile, CString strSymlink)
+CString
+ParseSymlink(const CString strFile, CString strSymlink)
 {
     CString strSymlinkInfo;
 
-    strSymlinkInfo = strFile + "\t" + strSymlink;
+    strSymlinkInfo = _T("-> ") + strSymlink;
 
     return strSymlinkInfo;
-}       
+}
 
-BOOL IsPathInAfs(const CHAR *strPath)
+BOOL
+GetFID(const CString& path, CString& fidstring, BOOL bLiteral)
 {
     struct ViceIoctl blob;
+    cm_ioctlQueryOptions_t options;
+    cm_fid_t fid;
     int code;
 
-    HOURGLASS hourglass;
-
-    char buf[512];
-    sprintf(buf, "IsPathInAfs(%s)", strPath);
-    OutputDebugString(buf);
+    memset(&options, 0, sizeof(options));
+    options.size = sizeof(options);
+    options.field_flags |= CM_IOCTL_QOPTS_FIELD_LITERAL;
+    options.literal = bLiteral ? 1 : 0;
+    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_T(path, VIOCGETFID, &blob, 1);
+    fidstring.Empty();
+    if (code == 0) {
+        fidstring.Format( TEXT("%lu.%lu.%lu"),
+                          fid.volume,
+                          fid.vnode,
+                          fid.unique);
+        return TRUE;
+    }
+    return FALSE;
+}
 
-    blob.in_size = 0;
-    blob.out_size = MAXSIZE;
-    blob.out = space;
+BOOL
+IsPathInAfs(const CString & strPath)
+{
+    struct ViceIoctl blob;
+    cm_ioctlQueryOptions_t options;
+    cm_fid_t fid;
+    int code;
 
-    code = pioctl((LPTSTR)((LPCTSTR)strPath), VIOC_FILE_CELL_NAME, &blob, 1);
+    HOURGLASS hourglass;
 
-    sprintf(buf, "VIOC_FILE_CELL_NAME=%d", code);
-    OutputDebugString(buf);
+    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_T(strPath, VIOCGETFID, &blob, 1);
     if (code) {
        if ((errno == EINVAL) || (errno == ENOENT))
         return FALSE;
@@ -1032,23 +981,25 @@ BOOL IsPathInAfs(const CHAR *strPath)
     return TRUE;
 }
 
-static int 
-IsFreelanceRoot(char *apath)
+static int
+IsFreelanceRoot(const CString& apath)
 {
     struct ViceIoctl blob;
     afs_int32 code;
+    char space[AFS_PIOCTL_MAXSIZE];
 
     blob.in_size = 0;
-    blob.out_size = MAXSIZE;
+    blob.out_size = AFS_PIOCTL_MAXSIZE;
     blob.out = space;
 
-    code = pioctl(apath, VIOC_FILE_CELL_NAME, &blob, 1);
+    code = pioctl_T(apath, VIOC_FILE_CELL_NAME, &blob, 1);
     if (code == 0)
         return !strcmp("Freelance.Local.Root",space);
     return 1;   /* assume it is because it is more restrictive that way */
 }
 
-const char * NetbiosName(void)
+static const char *
+NetbiosName(void)
 {
     static char buffer[1024] = "AFS";
     HKEY  parmKey;
@@ -1057,10 +1008,10 @@ 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,
+        code = RegQueryValueExA(parmKey, "NetbiosName", NULL, NULL,
                               (LPBYTE)buffer, &dummyLen);
         RegCloseKey (parmKey);
     } else {
@@ -1069,9 +1020,25 @@ const char * NetbiosName(void)
     return buffer;
 }
 
+static void
+FixNetbiosPath(CString& path)
+{
+    if (!IsPathInAfs(path)) {
+        CString nbroot;
+        const char * nbname = NetbiosName();
+
+        nbroot.Format(_T("\\\\%s\\"), nbname);
+
+        if (nbroot.CompareNoCase(path) == 0) {
+            path.Append(_T("all\\"));
+        }
+    }
+}
+
 #define AFSCLIENT_ADMIN_GROUPNAME "AFS Client Admins"
 
-static BOOL IsAdmin (void)
+static BOOL
+IsAdmin (void)
 {
     static BOOL fAdmin = FALSE;
     static BOOL fTested = FALSE;
@@ -1083,8 +1050,8 @@ static BOOL IsAdmin (void)
          */
         PSID psidAdmin = NULL;
         DWORD dwSize, dwSize2;
-        char pszAdminGroup[ MAX_COMPUTERNAME_LENGTH + sizeof(AFSCLIENT_ADMIN_GROUPNAME) + 2 ];
-        char *pszRefDomain = NULL;
+        TCHAR pszAdminGroup[ MAX_COMPUTERNAME_LENGTH + sizeof(AFSCLIENT_ADMIN_GROUPNAME) + 2 ];
+        TCHAR *pszRefDomain = NULL;
         SID_NAME_USE snu = SidTypeGroup;
 
         dwSize = sizeof(pszAdminGroup);
@@ -1098,8 +1065,8 @@ static BOOL IsAdmin (void)
         dwSize = 0;
         dwSize2 = 0;
 
-        strcat(pszAdminGroup,"\\");
-        strcat(pszAdminGroup, AFSCLIENT_ADMIN_GROUPNAME);
+        lstrcat(pszAdminGroup, _T("\\"));
+        lstrcat(pszAdminGroup, _T(AFSCLIENT_ADMIN_GROUPNAME));
 
         LookupAccountName(NULL, pszAdminGroup, NULL, &dwSize, NULL, &dwSize2, &snu);
         /* that should always fail. */
@@ -1117,10 +1084,10 @@ static BOOL IsAdmin (void)
         }
 
         psidAdmin = (PSID)malloc(dwSize); memset(psidAdmin,0,dwSize);
-        pszRefDomain = (char *)malloc(dwSize2);
+        pszRefDomain = (TCHAR *)malloc(dwSize2);
 
         if (!LookupAccountName(NULL, pszAdminGroup, psidAdmin, &dwSize, pszRefDomain, &dwSize2, &snu)) {
-            /* We can't lookup the group now even though we looked it up earlier.  
+            /* We can't lookup the group now even though we looked it up earlier.
                Could this happen? */
             fAdmin = TRUE;
         } else {
@@ -1204,107 +1171,126 @@ static BOOL IsAdmin (void)
     return fAdmin;
 }
 
-/* return a static pointer to a buffer */
-static char *Parent(char *apath)
+CString
+Parent(const CString& path)
 {
-    register char *tp;
+    int last_slash = path.ReverseFind(_T('\\'));
 
-    strcpy(tspace, apath);
-    tp = strrchr(tspace, '\\');
-    if (tp) {
-        *(tp+1) = 0;   /* lv trailing slash so Parent("k:\foo") is "k:\" not "k:" */
+    if (last_slash != -1) {
+        CString ret = path.Left(last_slash + 1);
+        return ret;
+    } else {
+        if (path.GetLength() >= 2 && path[1] == _T(':')) {
+            CString ret = path.Left(2);
+            ret.AppendChar(_T('.'));
+            return ret;
+        } else {
+            CString ret = _T(".");
+            return ret;
+        }
     }
-    else {
-        fs_ExtractDriveLetter(apath, tspace);
-       strcat(tspace, ".");
     }
-    
-    return tspace;
+
+CString
+LastComponent(const CString& path)
+{
+    int last_slash = path.ReverseFind(_T('\\'));
+
+    if (last_slash != -1) {
+        CString ret = path.Mid(last_slash + 1);
+        return ret;
+    } else {
+        if (path.GetLength() >= 2 && path[1] == _T(':')) {
+            CString ret = path.Mid(2);
+            return ret;
+        } else {
+            CString ret = path;
+            return ret;
+        }
+    }
 }
 
-static afs_int32
-GetCell(char *fname, char *cellname)
+static CString
+GetCell(const CString & path, BOOL bFollow = TRUE);
+
+static CString
+GetCell(const CString & path, BOOL bFollow)
 {
+    char cellname[MAXCELLCHARS];
     afs_int32 code;
     struct ViceIoctl blob;
 
     blob.in_size = 0;
-    blob.out_size = MAXCELLCHARS;
+    blob.out_size = sizeof(cellname);
     blob.out = cellname;
 
-    code = pioctl(fname, VIOC_FILE_CELL_NAME, &blob, 1);
-    return code ? errno : 0;
+    code = pioctl_T(path, VIOC_FILE_CELL_NAME, &blob, 1);
+    if (code) {
+        CString s;
+        s.Empty();
+
+        return s;
+    } else {
+        return Utf8ToCString(cellname);
+    }
 }
 
 
-BOOL ListMount(CStringArray& files)
+BOOL
+ListMount(CStringArray& files)
 {
-    register LONG code;
+    LONG code;
     struct ViceIoctl blob;
     int error;
-    char orig_name[1024];                      /* Original name, may be modified */
-    char true_name[1024];                      /* ``True'' dirname (e.g., symlink target) */
-    char parent_dir[1024];                     /* Parent directory of true name */
-    register char *last_component;     /* Last component of true name */
+
+    CString parent_dir;                /* Parent directory of true name */
+    CStringUtf8 last_component;                /* Last component of true name */
+
     CStringArray mountPoints;
-    
+
     HOURGLASS hourglass;
 
     error = 0;
 
     for (int i = 0; i < files.GetSize(); i++) {
-        strcpy(orig_name, files[i]);
-        strcpy(true_name, orig_name);
+        int last_slash = files[i].ReverseFind(_T('\\'));
+        char space[AFS_PIOCTL_MAXSIZE];
 
-        /*
-         * Find rightmost slash, if any.
-         */
-        last_component = (char *)strrchr(true_name, '\\');
-        if (last_component) {
-            /*
-             * Found it.  Designate everything before it as the parent directory,
-             * everything after it as the final component.
-             */
-            strncpy(parent_dir, true_name, last_component - true_name + 1);
-            parent_dir[last_component - true_name + 1] = 0;
-            last_component++;   /* Skip the slash */
-
-           if (!IsPathInAfs(parent_dir)) {
-               const char * nbname = NetbiosName();
-               int len = 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);
-               }
+        if (last_slash != -1) {
+            last_component.SetString( files[i].Mid(last_slash + 1) );
+            parent_dir.SetString( files[i].Left(last_slash + 1) );
+            FixNetbiosPath(parent_dir);
+        } else {
+            // The path is of the form "C:foo" or just "foo".  If
+            // there is a drive, then use the current directory of
+            // that drive.  Otherwise we just use '.'.
+
+            if (files[i].GetLength() >= 2 && files[i][1] == _T(':')) {
+                parent_dir.Format(_T("%c:."), files[i][0]);
+                last_component.SetString( files[i].Mid(2) );
+            } else {
+                parent_dir.SetString( _T("."));
+                last_component.SetString( files[i] );
            }
         }
-        else {
-            /*
-             * No slash appears in the given file name.  Set parent_dir to the current
-             * directory, and the last component as the given name.
-             */
-            fs_ExtractDriveLetter(true_name, parent_dir);
-            strcat(parent_dir, ".");
-            last_component = true_name;
-            fs_StripDriveLetter(true_name, true_name, sizeof(true_name));
-        }
 
-        blob.in = last_component;
-        blob.in_size = strlen(last_component) + 1;
-        blob.out_size = MAXSIZE;
+        blob.in_size = last_component.GetLength() + 1;
+        blob.in = last_component.GetBuffer();
+        blob.out_size = AFS_PIOCTL_MAXSIZE;
         blob.out = space;
-        memset(space, 0, MAXSIZE);
+        memset(space, 0, AFS_PIOCTL_MAXSIZE);
+
+        code = pioctl_T(parent_dir, VIOC_AFS_STAT_MT_PT, &blob, 1);
+
+        last_component.ReleaseBuffer();
 
-        code = pioctl(parent_dir, VIOC_AFS_STAT_MT_PT, &blob, 1);
         if (code == 0) {
-            int nPos = strlen(space) - 1;
+            int nPos;
+            space[AFS_PIOCTL_MAXSIZE - 1] = '\0';
+            nPos = strlen(space) - 1;
             if (space[nPos] == '.')
                 space[nPos] = 0;
-            mountPoints.Add(ParseMountPoint(StripPath(files[i]), space));
+            mountPoints.Add(ParseMountPoint(StripPath(files[i]), Utf8ToCString(space)));
         } else {
             error = 1;
             if (errno == EINVAL)
@@ -1321,329 +1307,151 @@ BOOL ListMount(CStringArray& files)
     return !error;
 }
 
-BOOL MakeMount(const CString& strDir, const CString& strVolName, const CString& strCellName, BOOL bRW)
+BOOL
+MakeMount(const CString& strDir,
+          const CString& strVolName,
+          const CString& strInCellName,
+          BOOL bRW)
 {
-    register LONG code;
-    register char *cellName;
-    char localCellName[128];
-    struct afsconf_cell info;
-#if 0
-    struct vldbentry vldbEntry;
-#endif
+    LONG code;
     struct ViceIoctl blob;
-    char * parent;
-    char path[1024] = "";
-
     HOURGLASS hourglass;
 
     ASSERT(strVolName.GetLength() < 64);
 
-    if (strCellName.GetLength() > 0)   /* cell name specified */
-        cellName = PCCHAR(strCellName);
-    else
-        cellName = (char *) 0;
-
-    parent = Parent(PCCHAR(strDir));
-    if (!IsPathInAfs(parent)) {
-       const char * nbname = NetbiosName();
-       int len = strlen(nbname);
-
-       if (parent[0] == '\\' && parent[1] == '\\' &&
-           parent[len+2] == '\\' &&
-           parent[len+3] == '\0' &&
-           !strnicmp(nbname,&parent[2],len))
-       {
-           sprintf(path,"%sall\\%s", parent, &(PCCHAR(strDir)[strlen(parent)]));
-           parent = Parent(path);
-           if (!IsPathInAfs(parent)) {
-               ShowMessageBox(IDS_MAKE_MP_NOT_AFS_ERROR, MB_ICONERROR, IDS_MAKE_MP_NOT_AFS_ERROR);
-               return FALSE;
-           }
-       } else {
+    CString strParent = Parent(strDir);
+
+    FixNetbiosPath(strParent);
+    if (!IsPathInAfs(strParent)) {
            ShowMessageBox(IDS_MAKE_MP_NOT_AFS_ERROR, MB_ICONERROR, IDS_MAKE_MP_NOT_AFS_ERROR);
            return FALSE;
        }
-    }
 
-    if ( strlen(path) == 0 )
-       strcpy(path, PCCHAR(strDir));
+    CString strPath = strParent + LastComponent(strDir);
 
-    if ( IsFreelanceRoot(parent) ) {
-       if ( !IsAdmin() ) {
-           ShowMessageBox(IDS_NOT_AFS_CLIENT_ADMIN_ERROR, MB_ICONERROR, IDS_NOT_AFS_CLIENT_ADMIN_ERROR);
+    if ( IsFreelanceRoot(strParent) && !IsAdmin() ) {
+        ShowMessageBox(IDS_NOT_AFS_CLIENT_ADMIN_ERROR, MB_ICONERROR,
+                       IDS_NOT_AFS_CLIENT_ADMIN_ERROR);
            return FALSE;
        }
 
-       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)
-           GetCell(parent,space);
-    }
-
-    code = GetCellName(cellName?cellName:space, &info);
-    if (code) {
-       return FALSE;
-    }
-
-#if 0
-    code = VLDBInit(1, &info);
-    if (code == 0) {
-       /* make the check.  Don't complain if there are problems with init */
-       code = ubik_VL_GetEntryByNameO(uclient, 0, PCCHAR(strVolName), &vldbEntry);
-       if (code == VL_NOENT) {
-           ShowMessageBox(IDS_WARNING, MB_ICONWARNING, IDS_VOLUME_NOT_IN_CELL_WARNING, 
-                           PCCHAR(strVolName), cellName ? cellName : space);
-       }
-    }
-    if (rxInitDone) 
-        rx_Finalize();
-#endif
-
-    if (bRW)   /* if -rw specified */
-        strcpy(space, "%");
-    else
-        strcpy(space, "#");
+    CString strMount;
 
-    /* If cellular mount point, prepend cell prefix */
-    if (cellName) {
-        strcat(space, info.name);
-        strcat(space, ":");
-    }   
+    strMount.Format(_T("%c%s%s%s."),
+                    ((bRW)?_T('%'):_T('#')),
+                    strInCellName,
+                    ((strInCellName.IsEmpty())?_T(""):_T(":")),
+                    strVolName);
 
-    strcat(space, strVolName); /* append volume name */
-    strcat(space, ".");                /* stupid convention; these end with a period */
+    CStringUtf8 ustrMount(strMount);
 
-    /* create symlink with a special pioctl for Windows NT, since it doesn't
-     * have a symlink system call.
-     */
     blob.out_size = 0;
-    blob.in_size = 1 + strlen(space);
-    blob.in = space;
+    blob.in_size = ustrMount.GetLength() + 1;
+    blob.in = ustrMount.GetBuffer();
     blob.out = NULL;
-    code = pioctl(path, VIOC_AFS_CREATE_MT_PT, &blob, 0);
+
+    code = pioctl_T(strPath, VIOC_AFS_CREATE_MT_PT, &blob, 0);
+
+    ustrMount.ReleaseBuffer();
 
     if (code) {
         ShowMessageBox(IDS_MOUNT_POINT_ERROR, MB_ICONERROR, IDS_MOUNT_POINT_ERROR, GetAfsError(errno, strDir));
         return FALSE;
     }
-    
+
     return TRUE;
 }
 
-/*
-*/
-long fs_ExtractDriveLetter(const char *inPathp, char *outPathp)
-{
-    if (inPathp[0] != 0 && inPathp[1] == ':') {
-        /* there is a drive letter */
-        *outPathp++ = *inPathp++;
-        *outPathp++ = *inPathp++;
-        *outPathp++ = 0;
-    }
-    else *outPathp = 0;
-
-    return 0;
-}       
-
-/* strip the drive letter from a component */
-long fs_StripDriveLetter(const char *inPathp, char *outPathp, long outSize)
-{
-    char tempBuffer[1000];
-    strcpy(tempBuffer, inPathp);
-    if (tempBuffer[0] != 0 && tempBuffer[1] == ':') {
-        /* drive letter present */
-        strcpy(outPathp, tempBuffer+2);
-    }
-    else {
-        /* no drive letter present */
-        strcpy(outPathp, tempBuffer);
-    }
-    return 0;
-}       
-
-
-BOOL RemoveSymlink(const char * linkName)
+BOOL
+RemoveSymlink(const CString& strName)
 {
     BOOL error = FALSE;
     INT code=0;
     struct ViceIoctl blob;
-    char tbuffer[1024];
     char lsbuffer[1024];
-    char tpbuffer[1024];
-    char *tp;
-    
+
     HOURGLASS hourglass;
 
-    tp = (char *) strrchr(linkName, '\\');
-    if (!tp)
-        tp = (char *) strrchr(linkName, '/');
-    if (tp) {
-        strncpy(tbuffer, linkName, code=tp-linkName+1);  /* the dir name */
-        tbuffer[code] = 0;
-        tp++;   /* skip the slash */
+    CString strParent = Parent(strName);
+    CStringUtf8 ustrLast(LastComponent(strName));
+    FixNetbiosPath(strParent);
 
-       if (!IsPathInAfs(tbuffer)) {
-           const char * nbname = NetbiosName();
-           int len = strlen(nbname);
-
-           if (tbuffer[0] == '\\' && tbuffer[1] == '\\' &&
-                tbuffer[len+2] == '\\' &&
-                tbuffer[len+3] == '\0' &&
-                !strnicmp(nbname,&tbuffer[2],len))
-           {
-               sprintf(tbuffer,"\\\\%s\\all\\", nbname);
-           }
-       }
-    }
-    else {
-        fs_ExtractDriveLetter(linkName, tbuffer);
-        strcat(tbuffer, ".");
-        fs_StripDriveLetter(tp, tpbuffer, 0);
-        tp=tpbuffer;
-    }
-
-    if ( IsFreelanceRoot(tbuffer) && !IsAdmin() ) {
+    if ( IsFreelanceRoot(strParent) && !IsAdmin() ) {
        ShowMessageBox(IDS_NOT_AFS_CLIENT_ADMIN_ERROR, MB_ICONERROR, IDS_NOT_AFS_CLIENT_ADMIN_ERROR);
        return FALSE;
     }
 
-    blob.in = tp;
-    blob.in_size = strlen(tp)+1;
+    blob.in_size = ustrLast.GetLength() + 1;
+    blob.in = ustrLast.GetBuffer();
     blob.out = lsbuffer;
     blob.out_size = sizeof(lsbuffer);
-    code = pioctl(tbuffer, VIOC_LISTSYMLINK, &blob, 0);
+    code = pioctl_T(strParent, VIOC_LISTSYMLINK, &blob, 0);
+    ustrLast.ReleaseBuffer();
     if (code)
         return FALSE;
     blob.out_size = 0;
-    blob.in = tp;
-    blob.in_size = strlen(tp)+1;
-    return (pioctl(tbuffer, VIOC_DELSYMLINK, &blob, 0)==0);
-}       
+    blob.in_size = ustrLast.GetLength() + 1;
+    blob.in = ustrLast.GetBuffer();
+
+    code = pioctl_T(strParent, VIOC_DELSYMLINK, &blob, 0);
 
-BOOL IsSymlink(const char * true_name)
+    ustrLast.ReleaseBuffer();
+
+    return (code == 0);
+}
+
+BOOL
+IsSymlink(const CString& strName)
 {
-    char parent_dir[MAXSIZE];          /*Parent directory of true name*/
-    char strip_name[MAXSIZE];
     struct ViceIoctl blob;
-    char *last_component;
     int code;
-
+    char space[AFS_PIOCTL_MAXSIZE];
     HOURGLASS hourglass;
 
-    char buf[512];
-    sprintf(buf, "IsSymlink(%s)", true_name);
-    OutputDebugString(buf);
+    CStringUtf8 ustrLast(LastComponent(strName));
+    CString strParent = Parent(strName);
 
-    last_component = (char *) strrchr(true_name, '\\');
-    if (!last_component)
-        last_component = (char *) strrchr(true_name, '/');
-    if (last_component) {
-        /*
-         * Found it.  Designate everything before it as the parent directory,
-         * everything after it as the final component.
-         */
-        strncpy(parent_dir, true_name, last_component - true_name + 1);
-        parent_dir[last_component - true_name + 1] = 0;
-        last_component++;   /*Skip the slash*/
+    FixNetbiosPath(strParent);
 
-       if (!IsPathInAfs(parent_dir)) {
-           const char * nbname = NetbiosName();
-           int len = strlen(nbname);
+    blob.in_size = ustrLast.GetLength() + 1;
+    blob.in = ustrLast.GetBuffer();
+    blob.out_size = AFS_PIOCTL_MAXSIZE;
+    blob.out = space;
+    memset(space, 0, AFS_PIOCTL_MAXSIZE);
 
-           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);
-           }
-       }
-    }
-    else {
-        /*
-         * No slash appears in the given file name.  Set parent_dir to the current
-         * directory, and the last component as the given name.
-         */
-        fs_ExtractDriveLetter(true_name, parent_dir);
-        strcat(parent_dir, ".");
-        last_component = strip_name;
-        fs_StripDriveLetter(true_name, strip_name, sizeof(strip_name));
-    }
+    code = pioctl_T(strParent, VIOC_LISTSYMLINK, &blob, 1);
 
-    sprintf(buf, "last_component=%s", last_component);
-    OutputDebugString(buf);
+    ustrLast.ReleaseBuffer();
 
-    blob.in = last_component;
-    blob.in_size = strlen(last_component)+1;
-    blob.out_size = MAXSIZE;
-    blob.out = space;
-    memset(space, 0, MAXSIZE);
-    code = pioctl(parent_dir, VIOC_LISTSYMLINK, &blob, 1);
     return (code==0);
-}       
+}
 
 
-BOOL IsMountPoint(const char * name)
+BOOL
+IsMountPoint(const CString& path)
 {
-    register LONG code = 0;
+    LONG code = 0;
     struct ViceIoctl blob;
-    char tbuffer[1024];
     char lsbuffer[1024];
-    register char *tp;
-    char szCurItem[1024];
 
     HOURGLASS hourglass;
 
-    strcpy(szCurItem, name);
-       
-    char buf[512];
-    sprintf(buf, "IsMountPoint(%s)", name);
-    OutputDebugString(buf);
+    CString parent = Parent(path);
+    FixNetbiosPath(parent);
 
-    tp = (char *)strrchr(szCurItem, '\\');
-    if (tp) {
-        strncpy(tbuffer, szCurItem, code = tp - szCurItem + 1);  /* the dir name */
-        tbuffer[code] = 0;
-        tp++;   /* skip the slash */
+    CStringUtf8 mountpoint(LastComponent(path));
 
-       if (!IsPathInAfs(tbuffer)) {
-           const char * nbname = NetbiosName();
-           int len = strlen(nbname);
-
-           if (tbuffer[0] == '\\' && tbuffer[1] == '\\' &&
-                tbuffer[len+2] == '\\' &&
-                tbuffer[len+3] == '\0' &&
-                !strnicmp(nbname,&tbuffer[2],len))
-           {
-               sprintf(tbuffer,"\\\\%s\\all\\", nbname);
-           }
-       }
-    } else {
-        fs_ExtractDriveLetter(szCurItem, tbuffer);
-        strcat(tbuffer, ".");
-        tp = szCurItem;
-        fs_StripDriveLetter(tp, tp, 0);
-    }
-
-    sprintf(buf, "last_component=%s", tp);
-    OutputDebugString(buf);
-
-    blob.in = tp;
-    blob.in_size = strlen(tp)+1;
+    blob.in_size = mountpoint.GetLength() + 1;
+    blob.in = mountpoint.GetBuffer();
     blob.out = lsbuffer;
     blob.out_size = sizeof(lsbuffer);
 
-    code = pioctl(tbuffer, VIOC_AFS_STAT_MT_PT, &blob, 0);
+    code = pioctl_T(parent, VIOC_AFS_STAT_MT_PT, &blob, 0);
+
+    mountpoint.ReleaseBuffer();
 
     return (code==0);
-}       
+}
 
 
 /*
@@ -1652,13 +1460,11 @@ BOOL IsMountPoint(const char * name)
  *         (or ``.'' if none is provided)
  *      tp: Set to point to the actual name of the mount point to nuke.
  */
-BOOL RemoveMount(CStringArray& files)
+BOOL
+RemoveMount(CStringArray& files)
 {
-    register LONG code = 0;
+    LONG code = 0;
     struct ViceIoctl blob;
-    char tbuffer[1024];
-    register char *tp;
-    char szCurItem[1024];
     BOOL error = FALSE;
     CStringArray results;
     CString str;
@@ -1676,50 +1482,30 @@ BOOL RemoveMount(CStringArray& files)
             continue;  // don't bother trying
         }
 
-        strcpy(szCurItem, files[i]);
-       
-        tp = (char *)strrchr(szCurItem, '\\');
-        if (tp) {
-            strncpy(tbuffer, szCurItem, code = tp - szCurItem + 1);  /* the dir name */
-            tbuffer[code] = 0;
-            tp++;   /* skip the slash */
-
-           if (!IsPathInAfs(tbuffer)) {
-               const char * nbname = NetbiosName();
-               int len = strlen(nbname);
-
-               if (tbuffer[0] == '\\' && tbuffer[1] == '\\' &&
-                   tbuffer[len+2] == '\\' &&
-                   tbuffer[len+3] == '\0' &&
-                   !strnicmp(nbname,&tbuffer[2],len))
-               {
-                   sprintf(tbuffer,"\\\\%s\\all\\", nbname);
-               }
-           }
-        } else {
-            fs_ExtractDriveLetter(szCurItem, tbuffer);
-            strcat(tbuffer, ".");
-            tp = szCurItem;
-            fs_StripDriveLetter(tp, tp, 0);
-        }
+        CString parent = Parent(files[i]);
+        CStringUtf8 mountpoint(LastComponent(files[i]));
+        FixNetbiosPath(parent);
 
-       if ( IsFreelanceRoot(tbuffer) && !IsAdmin() ) {
+        if ( IsFreelanceRoot(parent) && !IsAdmin() ) {
            results.Add(GetMessageString(IDS_NOT_AFS_CLIENT_ADMIN_ERROR, StripPath(files[i])));
             error = TRUE;
             continue;   /* skip */
         }
 
         blob.out_size = 0;
-        blob.in = tp;
-        blob.in_size = strlen(tp)+1;
+        blob.in_size = mountpoint.GetLength() + 1;
+        blob.in = mountpoint.GetBuffer();
+
+        code = pioctl_T(parent, VIOC_AFS_DELETE_MT_PT, &blob, 0);
+
+        mountpoint.ReleaseBuffer();
 
-        code = pioctl(tbuffer, VIOC_AFS_DELETE_MT_PT, &blob, 0);
         if (code) {
             error = TRUE;
             results.Add(GetMessageString(IDS_ERROR, GetAfsError(errno, StripPath(files[i]))));
         } else
             results.Add(GetMessageString(IDS_DELETED));
-    }   
+    }
 
     LoadString (str, IDS_REMOVE_MP);
     LoadString (str2, IDS_REMOVE_MP_COLUMN);
@@ -1730,17 +1516,19 @@ BOOL RemoveMount(CStringArray& files)
     return !error;
 }
 
-BOOL GetVolumeInfo(CString strFile, CVolInfo& volInfo)
+BOOL
+GetVolumeInfo(CString strFile, CVolInfo& volInfo, BOOL bFollow)
 {
-    register LONG code;
+    LONG code;
     struct ViceIoctl blob;
     struct VolumeStatus *status;
     char *name;
-
+    char space[AFS_PIOCTL_MAXSIZE];
     HOURGLASS hourglass;
+    CString strTarget = bFollow ? strFile : Parent(strFile);
 
-    volInfo.m_strFilePath = strFile;
-    volInfo.m_strFileName = StripPath(strFile);
+    volInfo.m_strFilePath = strTarget;
+    volInfo.m_strFileName = StripPath(strTarget);
 
     /*
        volInfo.m_strName = "VolumeName";
@@ -1754,20 +1542,20 @@ BOOL GetVolumeInfo(CString strFile, CVolInfo& volInfo)
        return TRUE;
      */
 
-    blob.out_size = MAXSIZE;
+    blob.out_size = AFS_PIOCTL_MAXSIZE;
     blob.in_size = 0;
     blob.out = space;
 
-    code = pioctl(PCCHAR(strFile), VIOCGETVOLSTAT, &blob, 1);
-    if (code) {
-        volInfo.m_strErrorMsg = GetAfsError(errno, strFile);
+    code = pioctl_T(strTarget, VIOCGETVOLSTAT, &blob, 1);
+    if (code || blob.out_size < sizeof(*status)) {
+        volInfo.m_strErrorMsg = GetAfsError(errno, strTarget);
         return FALSE;
     }
 
     status = (VolumeStatus *)space;
     name = (char *)status + sizeof(*status);
 
-    volInfo.m_strName = name;
+    volInfo.m_strName = Utf8ToCString(name);
     volInfo.m_nID = status->Vid;
     volInfo.m_nQuota = status->MaxQuota;
     volInfo.m_nNewQuota = status->MaxQuota;
@@ -1776,19 +1564,39 @@ BOOL GetVolumeInfo(CString strFile, CVolInfo& volInfo)
     volInfo.m_nPartFree = status->PartBlocksAvail;
     volInfo.m_nDup = -1;
 
+    errno = 0;
+    code = pioctl_T(strTarget, VIOC_PATH_AVAILABILITY, &blob, 1);
+    switch (errno) {
+    case 0:
+        volInfo.m_strAvail =_T("Online");
+        break;
+    case ENXIO:
+        volInfo.m_strAvail = _T("Offline");
+        break;
+    case ENOSYS:
+        volInfo.m_strAvail = _T("Unreachable");
+        break;
+    case EBUSY:
+        volInfo.m_strAvail = _T("Busy");
+        break;
+    default:
+        volInfo.m_strAvail = _T("Unknown");
+    }
+
     return TRUE;
 }
-       
-BOOL SetVolInfo(CVolInfo& volInfo)
+
+BOOL
+SetVolInfo(CVolInfo& volInfo)
 {
-    register LONG code;
+    LONG code;
     struct ViceIoctl blob;
     struct VolumeStatus *status;
     char *input;
-
+    char space[AFS_PIOCTL_MAXSIZE];
     HOURGLASS hourglass;
 
-    blob.out_size = MAXSIZE;
+    blob.out_size = AFS_PIOCTL_MAXSIZE;
     blob.in_size = sizeof(*status) + 3;        /* for the three terminating nulls */
     blob.out = space;
     blob.in = space;
@@ -1796,7 +1604,7 @@ BOOL SetVolInfo(CVolInfo& volInfo)
     status = (VolumeStatus *)space;
     status->MinQuota = -1;
     status->MaxQuota = volInfo.m_nNewQuota;
-       
+
     input = (char *)status + sizeof(*status);
     *(input++) = '\0'; /* never set name: this call doesn't change vldb */
     *(input++) = '\0'; // No offmsg
@@ -1813,12 +1621,12 @@ BOOL SetVolInfo(CVolInfo& volInfo)
         fprintf(fp, "\t\t\tOther status fields aren't set\n");
         fprintf(fp, "\t\t\t3 nulls follow the VolumeStatus structure.\n");
         fprintf(fp, "\tfollow = 1\n");
-        fclose(fp);            
+        fclose(fp);
     }
 #endif
 
-    code = pioctl(PCCHAR(volInfo.m_strFilePath), VIOCSETVOLSTAT, &blob, 1);
-    if (code) {
+    code = pioctl_T(volInfo.m_strFilePath, VIOCSETVOLSTAT, &blob, 1);
+    if (code || blob.out_size < sizeof(*status)) {
         ShowMessageBox(IDS_SET_QUOTA_ERROR, MB_ICONERROR, IDS_SET_QUOTA_ERROR, GetAfsError(errno, volInfo.m_strName));
         return FALSE;
     }
@@ -1826,34 +1634,37 @@ BOOL SetVolInfo(CVolInfo& volInfo)
     return TRUE;
 }
 
-int GetCellName(char *cellNamep, struct afsconf_cell *infop)
+void
+GetCellName(const CString& cellNamep, struct afsconf_cell *infop)
 {
-    strcpy(infop->name, cellNamep);
-    return 0;
+    CStringUtf8 uCellName(cellNamep);
+
+    StringCbCopyA(infop->name, sizeof(infop->name), uCellName);
 }
 
-BOOL CheckServers(const CString& strCellName, WHICH_CELLS nCellsToCheck, BOOL bFast)
+BOOL NO_CALLER
+CheckServers(const CString& strCellName, WHICH_CELLS nCellsToCheck, BOOL bFast)
 {
-    register LONG code;
+    LONG code;
     struct ViceIoctl blob;
-    register LONG j;
+    LONG j;
     LONG temp = 0;
     struct afsconf_cell info;
     struct chservinfo checkserv;
-
+    char space[AFS_PIOCTL_MAXSIZE];
     HOURGLASS hourglass;
 
     memset(&checkserv, 0, sizeof(struct chservinfo));
     blob.in_size = sizeof(struct chservinfo);
     blob.in = (caddr_t)&checkserv;
 
-    blob.out_size = MAXSIZE;
+    blob.out_size = AFS_PIOCTL_MAXSIZE;
     blob.out = space;
     memset(space, 0, sizeof(afs_int32));       /* so we assure zero when nothing is copied back */
 
     if (nCellsToCheck == SPECIFIC_CELL) {
        temp = 2;
-        GetCellName(PCCHAR(strCellName), &info);
+        GetCellName(strCellName, &info);
         strcpy(checkserv.tbuffer,info.name);
         checkserv.tsize = strlen(info.name) + 1;
     } else {
@@ -1864,12 +1675,12 @@ BOOL CheckServers(const CString& strCellName, WHICH_CELLS nCellsToCheck, BOOL bF
     }
     if (bFast)
         temp |= 1;     /* set fast flag */
-    
+
     checkserv.magic = 0x12345678;      /* XXX */
     checkserv.tflags = temp;
     checkserv.tinterval = -1;  /* don't change current interval */
 
-    code = pioctl(0, VIOCCKSERV, &blob, 1);
+    code = pioctl_utf8(0, VIOCCKSERV, &blob, 1);
     if (code) {
         ShowMessageBox(IDS_CHECK_SERVERS_ERROR, MB_ICONERROR, IDS_CHECK_SERVERS_ERROR, GetAfsError(errno, CString()));
         return FALSE;
@@ -1883,7 +1694,7 @@ BOOL CheckServers(const CString& strCellName, WHICH_CELLS nCellsToCheck, BOOL bF
     }
 
     CStringArray servers;
-    for (j = 0; j < MAXHOSTS; j++) {
+    for (j = 0; j < AFS_MAXHOSTS; j++) {
         memcpy(&temp, space + j * sizeof(LONG), sizeof(LONG));
         if (temp == 0)
             break;
@@ -1897,9 +1708,10 @@ BOOL CheckServers(const CString& strCellName, WHICH_CELLS nCellsToCheck, BOOL bF
     dlg.DoModal();
 
     return TRUE;
-}       
+}
 
-BOOL GetTokenInfo(CStringArray& tokenInfo)
+BOOL
+GetTokenInfo(CStringArray& tokenInfo)
 {
     int cellNum;
     int rc;
@@ -1947,7 +1759,7 @@ BOOL GetTokenInfo(CStringArray& tokenInfo)
         else {
             rc = ktc_GetToken(&serviceName, &token, sizeof(token), &clientName);
             if (rc) {
-                ShowMessageBox(IDS_GET_TOKENS_UNEXPECTED_ERROR2, MB_ICONERROR, IDS_GET_TOKENS_UNEXPECTED_ERROR2, 
+                ShowMessageBox(IDS_GET_TOKENS_UNEXPECTED_ERROR2, MB_ICONERROR, IDS_GET_TOKENS_UNEXPECTED_ERROR2,
                                 serviceName.name, serviceName.instance,        serviceName.cell, rc);
                 continue;
             }
@@ -1973,10 +1785,10 @@ BOOL GetTokenInfo(CStringArray& tokenInfo)
             else
                 strUserName = userName;
 //             printf("User %s's tokens", userName);
-                       
+
 //             printf(" for %s%s%s@%s ", serviceName.name, serviceName.instance[0] ? "." : "", serviceName.instance, serviceName.cell);
             strCellName = serviceName.cell;
-                       
+
             if (tokenExpireTime <= current_time)
                 strExpir = "[>> Expired <<]";
 //             printf("[>> Expired <<]\n");
@@ -1985,7 +1797,11 @@ BOOL GetTokenInfo(CStringArray& tokenInfo)
                 expireString += 4;      /* Skip day of week */
                 expireString[12] = '\0'; /* Omit secs & year */
 //             printf("[Expires %s]\n", expireString);
-                strExpir.Format("%s", expireString);
+#ifdef UNICODE
+                strExpir.Format(_T("%S"), expireString);
+#else
+                strExpir.Format(_T("%s"), expireString);
+#endif
             }
 
             strTokenInfo = strUserName + "\t" + strCellName + "\t" + strExpir + "\t" + strCellName;
@@ -1998,43 +1814,39 @@ BOOL GetTokenInfo(CStringArray& tokenInfo)
     return TRUE;
 }
 
-UINT MakeSymbolicLink(const char *strName, const char *strTarget)
+UINT
+MakeSymbolicLink(const CString& strName, const CString& strTarget)
 {
     struct ViceIoctl blob;
-    char space[MAXSIZE];
-    char * parent;
-    char path[1024] = "";
     UINT code;
-
     HOURGLASS hourglass;
-    static char message[2048];
 
-    strcpy(path, strName);
-    parent = Parent(path);
+    CString strParent = Parent(strName);
+    FixNetbiosPath(strParent);
 
-    sprintf(message,"MakeSymbolicLink: name = %s target = %s parent = %s\n",strName,strTarget, parent);
-    OutputDebugString(message);
-
-    if ( IsFreelanceRoot(parent) && !IsAdmin() ) {
+    if ( IsFreelanceRoot(strParent) && !IsAdmin() ) {
        ShowMessageBox(IDS_NOT_AFS_CLIENT_ADMIN_ERROR, MB_ICONERROR, IDS_NOT_AFS_CLIENT_ADMIN_ERROR);
        return FALSE;
     }
 
-    LPTSTR lpsz = new TCHAR[strlen(strTarget)+1];
-    _tcscpy(lpsz, strName);
-    strcpy(space, strTarget);
+    CStringUtf8 ustrTarget(strTarget);
+
+    blob.in_size = ustrTarget.GetLength() + 1;
+    blob.in = ustrTarget.GetBuffer();
     blob.out_size = 0;
-    blob.in_size = 1 + strlen(space);
-    blob.in = space;
     blob.out = NULL;
-    code=pioctl(lpsz, VIOC_SYMLINK, &blob, 0);
-    delete lpsz;
+
+    code = pioctl_T(strName, VIOC_SYMLINK, &blob, 0);
+
+    ustrTarget.ReleaseBuffer();
+
     if (code != 0)
         return code;
-    return FALSE;
+    return 0;
 }
 
-void ListSymbolicLinkPath(const char *strName,char *strPath,UINT nlenPath)
+void NO_CALLER
+ListSymbolicLinkPath(const char *strName,char *strPath,UINT nlenPath)
 {
     ASSERT(nlenPath<MAX_PATH);
     struct ViceIoctl blob;
@@ -2042,8 +1854,8 @@ void ListSymbolicLinkPath(const char *strName,char *strPath,UINT nlenPath)
     char true_name[MAX_PATH+1];                /*``True'' dirname (e.g., symlink target)*/
     char parent_dir[MAX_PATH+1];               /*Parent directory of true name*/
     char *last_component;      /*Last component of true name*/
-    UINT code;    
-
+    UINT code;
+    char space[AFS_PIOCTL_MAXSIZE];
     HOURGLASS hourglass;
 
     strcpy(orig_name, strName);
@@ -2088,83 +1900,59 @@ void ListSymbolicLinkPath(const char *strName,char *strPath,UINT nlenPath)
     }
     blob.in = last_component;
     blob.in_size = strlen(last_component)+1;
-    blob.out_size = MAXSIZE;
+    blob.out_size = AFS_PIOCTL_MAXSIZE;
     blob.out = space;
-    memset(space, 0, MAXSIZE);
+    memset(space, 0, AFS_PIOCTL_MAXSIZE);
     if ((code = pioctl(parent_dir, VIOC_LISTSYMLINK, &blob, 1)))
         strcpy(space,"???");
     ASSERT(strlen(space)<MAX_PATH);
     strncpy(strPath,space,nlenPath);
-}       
+}
 
-BOOL ListSymlink(CStringArray& files)
+BOOL NO_CALLER
+ListSymlink(CStringArray& files)
 {
-    register LONG code;
+    LONG code;
     struct ViceIoctl blob;
     int error;
-    char orig_name[1024];                      /* Original name, may be modified */
-    char true_name[1024];                      /* ``True'' dirname (e.g., symlink target) */
-    char parent_dir[1024];                     /* Parent directory of true name */
-    register char *last_component;     /* Last component of true name */
     CStringArray symlinks;
-    
+    char space[AFS_PIOCTL_MAXSIZE];
     HOURGLASS hourglass;
 
     error = 0;
 
     for (int i = 0; i < files.GetSize(); i++) {
-        strcpy(orig_name, files[i]);
-        strcpy(true_name, orig_name);
 
-        /*
-         * Find rightmost slash, if any.
-         */
-        last_component = (char *)strrchr(true_name, '\\');
-        if (last_component) {
-            /*
-             * Found it.  Designate everything before it as the parent directory,
-             * everything after it as the final component.
-             */
-            strncpy(parent_dir, true_name, last_component - true_name + 1);
-            parent_dir[last_component - true_name + 1] = 0;
-            last_component++;   /* Skip the slash */
-
-           if (!IsPathInAfs(parent_dir)) {
-               const char * nbname = NetbiosName();
-               int len = 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);
-               }
-           }
-        }
-        else {
-            /*
-             * No slash appears in the given file name.  Set parent_dir to the current
-             * directory, and the last component as the given name.
-             */
-            fs_ExtractDriveLetter(true_name, parent_dir);
-            strcat(parent_dir, ".");
-            last_component = true_name;
-            fs_StripDriveLetter(true_name, true_name, sizeof(true_name));
-        }
+        CString strParent = Parent(files[i]);
+        CStringUtf8 ustrLast(LastComponent(files[i]));
 
-        blob.in = last_component;
-        blob.in_size = strlen(last_component) + 1;
-        blob.out_size = MAXSIZE;
+        FixNetbiosPath(strParent);
+
+        blob.in_size = ustrLast.GetLength() + 1;
+        blob.in = ustrLast.GetBuffer();
+        blob.out_size = AFS_PIOCTL_MAXSIZE;
         blob.out = space;
-        memset(space, 0, MAXSIZE);
+        memset(space, 0, AFS_PIOCTL_MAXSIZE);
+
+        code = pioctl_T(strParent, VIOC_LISTSYMLINK, &blob, 1);
+
+        ustrLast.ReleaseBuffer();
 
-        code = pioctl(parent_dir, VIOC_LISTSYMLINK, &blob, 1);
         if (code == 0) {
-            int nPos = strlen(space) - 1;
-            if (space[nPos] == '.')
-                space[nPos] = 0;
-            symlinks.Add(ParseSymlink(StripPath(files[i]), space));
+            CString syml;
+            int len;
+
+            space[AFS_PIOCTL_MAXSIZE - 1] = '\0';
+            syml = Utf8ToCString(space);
+            len = syml.GetLength();
+
+            if (len > 0) {
+                if (syml[len - 1] == _T('.'))
+                    syml.Truncate(len - 1);
+            }
+
+            symlinks.Add(ParseSymlink(StripPath(files[i]), syml));
+
         } else {
             error = 1;
             if (errno == EINVAL)
@@ -2181,4 +1969,345 @@ BOOL ListSymlink(CStringArray& files)
     return !error;
 }
 
+CString
+GetCellName( const CString& strPath, BOOL bFollow )
+{
+    return GetCell(bFollow ? strPath : Parent(strPath));
+}
+
+CString
+GetServer( const CString& strPath, BOOL bFollow )
+{
+    LONG code;
+    struct ViceIoctl blob;
+    CString server;
+    char space[AFS_PIOCTL_MAXSIZE];
+
+    blob.out_size = AFS_PIOCTL_MAXSIZE;
+    blob.in_size = 0;
+    blob.out = space;
+    memset(space, 0, sizeof(space));
+
+    code = pioctl_T(bFollow ? strPath : Parent(strPath), VIOCWHEREIS, &blob, 1);
+    if (code) {
+        server=GetAfsError(errno);
+    } else {
+        LONG *hosts = (LONG *)space;
 
+        for (int j = 0; j < AFS_MAXHOSTS; j++) {
+            if (hosts[j] == 0)
+                break;
+            char *hostName = hostutil_GetNameByINet(hosts[j]);
+            server=hostName;
+        }
+    }
+
+    return server;
+}
+
+void
+GetServers( const CString& strPath, CStringArray& servers, BOOL bFollow )
+{
+    LONG code;
+    struct ViceIoctl blob;
+    char space[AFS_PIOCTL_MAXSIZE];
+
+    blob.out_size = AFS_PIOCTL_MAXSIZE;
+    blob.in_size = 0;
+    blob.out = space;
+    memset(space, 0, sizeof(space));
+
+    code = pioctl_T(bFollow ? strPath : Parent(strPath), VIOCWHEREIS, &blob, 1);
+    if (code) {
+        servers.Add(GetAfsError(errno));
+    } else {
+        LONG *hosts = (LONG *)space;
+
+        for (int j = 0; j < AFS_MAXHOSTS; j++) {
+            if (hosts[j] == 0)
+                break;
+            char *hostName = hostutil_GetNameByINet(hosts[j]);
+            servers.Add(hostName);
+        }
+    }
+}
+
+CString
+GetOwner( const CString& strPath, BOOL bFollow )
+{
+    LONG code;
+    struct ViceIoctl blob;
+    afs_int32 owner[2];
+    CString ret = TEXT("(unknown)");
+
+    blob.in_size = 0;
+    blob.out_size = 2 * sizeof(afs_int32);
+    blob.out = (char *) &owner;
+
+    code = pioctl_T(bFollow ? strPath : Parent(strPath), VIOCGETOWNER, &blob, 1);
+    if (code == 0 && blob.out_size == 2 * sizeof(afs_int32)) {
+        char oname[PR_MAXNAMELEN] = "(unknown)";
+        char confDir[257];
+        CStringUtf8 cell;
+
+        cell = GetCell(strPath, bFollow);
+
+        /* Go to the PRDB and see if this all number username is valid */
+        cm_GetConfigDir(confDir, sizeof(confDir));
+
+        pr_Initialize(1, confDir, PCCHAR(cell));
+        pr_SIdToName(owner[0], oname);
+
+        ret.Empty();
+        ret.Format(TEXT("%s [%d]"), (LPCTSTR)CString(oname), owner[0]);
+    }
+
+    return ret;
+}
+
+CString
+GetGroup( const CString& strPath, BOOL bFollow )
+{
+    LONG code;
+    struct ViceIoctl blob;
+    afs_int32 owner[2];
+    CString ret = TEXT("(unknown)");
+
+    blob.in_size = 0;
+    blob.out_size = 2 * sizeof(afs_int32);
+    blob.out = (char *) &owner;
+
+    code = pioctl_T(bFollow ? strPath : Parent(strPath), VIOCGETOWNER, &blob, 1);
+    if (code == 0 && blob.out_size == 2 * sizeof(afs_int32)) {
+        char gname[PR_MAXNAMELEN] = "(unknown)";
+        char confDir[257];
+        CStringUtf8 cell;
+
+        cell = GetCell(strPath, bFollow);
+
+        /* Go to the PRDB and see if this all number username is valid */
+        cm_GetConfigDir(confDir, sizeof(confDir));
+
+        pr_Initialize(1, confDir, PCCHAR(cell));
+        pr_SIdToName(owner[1], gname);
+
+        ret.Empty();
+        ret.Format(TEXT("%s [%d]"), (LPCTSTR)CString(gname), owner[1]);
+    }
+
+    return ret;
+}
+
+BOOL
+GetUnixModeBits( const CString& strPath, CString& user, CString& group, CString& other, CString& suid )
+{
+    // the strings must match the unix ls command output: "rwx" means read/write/execute permissions
+
+    LONG code;
+    struct ViceIoctl blob;
+    afs_uint32 unixModeBits;
+    CString ret = TEXT("(unknown)");
+
+    user.Empty();
+    group.Empty();
+    other.Empty();
+    suid.Empty();
+
+    blob.in_size = 0;
+    blob.out_size = sizeof(afs_int32);
+    blob.out = (char *) &unixModeBits;
+
+    code = pioctl_T(strPath, VIOC_GETUNIXMODE, &blob, 1);
+    if (code == 0 && blob.out_size == sizeof(afs_uint32)) {
+        if (unixModeBits & S_IRUSR)
+            user += _T("r");
+        if (unixModeBits & S_IWUSR)
+            user += _T("w");
+        if (unixModeBits & S_IXUSR)
+            user += _T("x");
+
+        if (unixModeBits & S_IRGRP)
+            group += _T("r");
+        if (unixModeBits & S_IWGRP)
+            group += _T("w");
+        if (unixModeBits & S_IXGRP)
+            group += _T("x");
+
+        if (unixModeBits & S_IROTH)
+            other += _T("r");
+        if (unixModeBits & S_IWOTH)
+            other += _T("w");
+        if (unixModeBits & S_IXOTH)
+            other += _T("x");
+
+        if (unixModeBits & S_ISUID)
+            suid += _T("s");
+        if (unixModeBits & S_ISGID)
+            suid += _T("g");
+        if (unixModeBits & S_ISVTX)
+            suid += _T("v");
+
+        return TRUE;
+    }
+
+    return FALSE;
+}
+
+void
+SetUnixModeBits( const CStringArray& files, const CString& user, const CString& group, const CString& other, const CString& suid )
+{
+    // set the unix file attributes for all paths in 'files'.
+    LONG code;
+    struct ViceIoctl blob;
+    struct {
+        cm_ioctlQueryOptions_t options;
+        afs_uint32 unixModeBits;
+    } inData;
+
+    memset(&inData, 0, sizeof(inData));
+    inData.options.size = sizeof(inData.options);
+    inData.options.field_flags = 0;
+    inData.options.literal = 0;            /* always applying to target */
+    blob.in_size = inData.options.size;    /* no variable length data */
+    blob.in = &inData;
+    blob.out = NULL;
+    blob.out_size = 0;
+    inData.unixModeBits = 0;
+
+    if (user.Find(_T("r")) != -1)
+        inData.unixModeBits |= S_IRUSR;
+    if (user.Find(_T("w")) != -1)
+        inData.unixModeBits |= S_IWUSR;
+    if (user.Find(_T("x")) != -1)
+        inData.unixModeBits |= S_IXUSR;
+
+    if (group.Find(_T("r")) != -1)
+        inData.unixModeBits |= S_IRGRP;
+    if (group.Find(_T("w")) != -1)
+        inData.unixModeBits |= S_IWGRP;
+    if (group.Find(_T("x")) != -1)
+        inData.unixModeBits |= S_IXGRP;
+
+    if (other.Find(_T("r")) != -1)
+        inData.unixModeBits |= S_IROTH;
+    if (other.Find(_T("w")) != -1)
+        inData.unixModeBits |= S_IWOTH;
+    if (other.Find(_T("x")) != -1)
+        inData.unixModeBits |= S_IXOTH;
+
+    if (suid.Find(_T("s")) != -1)
+        inData.unixModeBits |= S_ISUID;
+    if (suid.Find(_T("g")) != -1)
+        inData.unixModeBits |= S_ISGID;
+    if (suid.Find(_T("v")) != -1)
+        inData.unixModeBits |= S_ISVTX;
+
+    for (int i = 0; i < files.GetSize(); i++)
+        code = pioctl_T(files[i], VIOC_SETUNIXMODE, &blob, 1);
+}
+
+CString GetMountpoint( const CString& strPath )
+{
+    LONG code;
+    struct ViceIoctl blob;
+    char space[AFS_PIOCTL_MAXSIZE];
+    CString parent_dir;                /* Parent directory of true name */
+    CStringUtf8 last_component;                /* Last component of true name */
+
+    CString mountPoint;
+
+
+    int last_slash = strPath.ReverseFind(_T('\\'));
+
+    if (last_slash != -1) {
+        last_component.SetString( strPath.Mid(last_slash + 1) );
+        parent_dir.SetString( strPath.Left(last_slash + 1) );
+        FixNetbiosPath(parent_dir);
+    } else {
+        // The path is of the form "C:foo" or just "foo".  If
+        // there is a drive, then use the current directory of
+        // that drive.  Otherwise we just use '.'.
+
+        if (strPath.GetLength() >= 2 && strPath[1] == _T(':')) {
+            parent_dir.Format(_T("%c:."), strPath[0]);
+            last_component.SetString( strPath.Mid(2) );
+        } else {
+            parent_dir.SetString( _T("."));
+            last_component.SetString( strPath );
+        }
+    }
+
+    blob.in_size = last_component.GetLength() + 1;
+    blob.in = last_component.GetBuffer();
+    blob.out_size = AFS_PIOCTL_MAXSIZE;
+    blob.out = space;
+    memset(space, 0, AFS_PIOCTL_MAXSIZE);
+
+    code = pioctl_T(parent_dir, VIOC_AFS_STAT_MT_PT, &blob, 1);
+
+    last_component.ReleaseBuffer();
+
+    if (code == 0) {
+        int nPos;
+        space[AFS_PIOCTL_MAXSIZE - 1] = '\0';
+        nPos = strlen(space) - 1;
+        if (space[nPos] == '.')
+            space[nPos] = 0;
+        mountPoint = ParseMountPoint(StripPath(strPath), Utf8ToCString(space));
+    } else {
+        if (errno == EINVAL)
+            mountPoint = GetMessageString(IDS_NOT_MOUNT_POINT_ERROR, StripPath(strPath));
+        else
+            mountPoint = GetMessageString(IDS_LIST_MOUNT_POINT_ERROR, GetAfsError(errno, StripPath(strPath)));
+    }
+
+    return mountPoint;
+}
+
+CString GetSymlink( const CString& strPath )
+{
+    LONG code;
+    struct ViceIoctl blob;
+    CString symlink;
+    char space[AFS_PIOCTL_MAXSIZE];
+
+    CString strParent = Parent(strPath);
+    CStringUtf8 ustrLast(LastComponent(strPath));
+
+    FixNetbiosPath(strParent);
+
+    blob.in_size = ustrLast.GetLength() + 1;
+    blob.in = ustrLast.GetBuffer();
+    blob.out_size = AFS_PIOCTL_MAXSIZE;
+    blob.out = space;
+    memset(space, 0, AFS_PIOCTL_MAXSIZE);
+
+    code = pioctl_T(strParent, VIOC_LISTSYMLINK, &blob, 1);
+
+    ustrLast.ReleaseBuffer();
+
+    if (code == 0) {
+        CString syml;
+        int len;
+
+        space[AFS_PIOCTL_MAXSIZE - 1] = '\0';
+        syml = Utf8ToCString(space);
+        len = syml.GetLength();
+
+        if (len > 0) {
+            if (syml[len - 1] == _T('.'))
+                syml.Truncate(len - 1);
+        }
+
+        symlink = ParseSymlink(StripPath(strPath), syml);
+
+    } else {
+        if (errno == EINVAL)
+            symlink = GetMessageString(IDS_NOT_SYMLINK_ERROR, StripPath(strPath));
+        else
+            symlink = GetMessageString(IDS_LIST_MOUNT_POINT_ERROR, GetAfsError(errno, StripPath(strPath)));
+    }
+
+
+    return symlink;
+}