windows-misc-20040803
[openafs.git] / src / WINNT / afsd / cm_ioctl.c
index 2de6df1..234e775 100644 (file)
 #include "afsd_init.h"
 
 #include "smb.h"
+#include "cm_server.h"
 
 #ifndef DJGPP
-#include <rxkad.h>
+#include <rx/rxkad.h>
 #include "afsrpc.h"
 #else
 #include <rx/rxkad.h>
 
 #include "cm_rpc.h"
 
+#ifdef _DEBUG
+#include <crtdbg.h>
+#endif
+
 /* Copied from afs_tokens.h */
 #define PIOCTL_LOGON   0x1
 #define MAX_PATH 260
@@ -46,6 +51,7 @@
 osi_mutex_t cm_Afsdsbmt_Lock;
 
 extern afs_int32 cryptall;
+extern char cm_NetbiosName[];
 
 void cm_InitIoctl(void)
 {
@@ -109,16 +115,18 @@ void cm_ResetACLCache(cm_user_t *userp)
  */
 void TranslateExtendedChars(char *str)
 {
-  char *p;
-  
-        if (!str || !*str)
-                return;
+#ifdef DJGPP
+    char *p;
+#endif
+
+    if (!str || !*str)
+        return;
 
 #ifndef DJGPP
-        CharToOem(str, str);
+    CharToOem(str, str);
 #else
-        p = str;
-        while (*p) *p++ &= 0x7f;  /* turn off high bit; probably not right */
+    p = str;
+    while (*p) *p++ &= 0x7f;  /* turn off high bit; probably not right */
 #endif
 }
         
@@ -130,28 +138,100 @@ long cm_ParseIoctlPath(smb_ioctl_t *ioctlp, cm_user_t *userp, cm_req_t *reqp,
 {
        long code;
        cm_scache_t *substRootp;
+    char * relativePath = ioctlp->inDatap;
+
+    /* This is usually the file name, but for StatMountPoint it is the path. */
+    /* ioctlp->inDatap can be either of the form:
+     *    \path\.
+     *    \path\file
+     *    \\netbios-name\submount\path\.
+     *    \\netbios-name\submount\path\file
+     */
+       TranslateExtendedChars(relativePath);
+
+    if (relativePath[0] == relativePath[1] &&
+         relativePath[1] == '\\' && 
+         !_strnicmp(cm_NetbiosName,relativePath+2,strlen(cm_NetbiosName))) 
+    {
+        char shareName[256];
+        char *sharePath;
+        int shareFound, i;
+
+        /* We may have found a UNC path. 
+         * If the first component is the NetbiosName,
+         * then throw out the second component (the submount)
+         * since it had better expand into the value of ioctl->tidPathp
+         */
+        char * p;
+        p = relativePath + 2 + strlen(cm_NetbiosName) + 1;
+        if ( !_strnicmp("all", p, 3) )
+            p += 4;
 
-        /* This is usually the file name, but for StatMountPoint it is the path. */
-       TranslateExtendedChars(ioctlp->inDatap);
+        for (i = 0; *p && *p != '\\'; i++,p++ ) {
+            shareName[i] = *p;
+        }
+        p++;                    /* skip past trailing slash */
+        shareName[i] = 0;       /* terminate string */
+
+        shareFound = smb_FindShare(ioctlp->fidp->vcp, ioctlp->uidp, shareName, &sharePath);
+        if ( shareFound ) {
+            /* we found a sharename, therefore use the resulting path */
+            code = cm_NameI(cm_rootSCachep, ioctlp->prefix->data,
+                             CM_FLAG_CASEFOLD | CM_FLAG_FOLLOW,
+                             userp, sharePath, reqp, &substRootp);
+            free(sharePath);
+            if (code) return code;
+
+                       code = cm_NameI(substRootp, p, CM_FLAG_CASEFOLD | CM_FLAG_FOLLOW,
+                         userp, NULL, reqp, scpp);
+                       if (code) return code;
+        } else {
+            /* otherwise, treat the name as a cellname mounted off the afs root.
+                        * This requires that we reconstruct the shareName string with 
+                        * leading and trailing slashes.
+                        */
+            p = relativePath + 2 + strlen(cm_NetbiosName) + 1;
+                       if ( !_strnicmp("all", p, 3) )
+                               p += 4;
 
-       code = cm_NameI(cm_rootSCachep, ioctlp->prefix->data,
-               CM_FLAG_CASEFOLD | CM_FLAG_FOLLOW,
-               userp, ioctlp->tidPathp, reqp, &substRootp);
-       if (code) return code;
-        
-        code = cm_NameI(substRootp, ioctlp->inDatap, CM_FLAG_FOLLOW,
-               userp, NULL, reqp, scpp);
-       if (code) return code;
+                       shareName[0] = '/';
+                       for (i = 1; *p && *p != '\\'; i++,p++ ) {
+                               shareName[i] = *p;
+                       }
+                       p++;                    /* skip past trailing slash */
+                       shareName[i++] = '/';   /* add trailing slash */
+                       shareName[i] = 0;       /* terminate string */
+
+                       
+                       code = cm_NameI(cm_rootSCachep, ioctlp->prefix->data,
+                             CM_FLAG_CASEFOLD | CM_FLAG_FOLLOW,
+                             userp, shareName, reqp, &substRootp);
+            if (code) return code;
+
+                       code = cm_NameI(substRootp, p, CM_FLAG_CASEFOLD | CM_FLAG_FOLLOW,
+                         userp, NULL, reqp, scpp);
+                       if (code) return code;
+        }
+    } else {
+        code = cm_NameI(cm_rootSCachep, ioctlp->prefix->data,
+                         CM_FLAG_CASEFOLD | CM_FLAG_FOLLOW,
+                         userp, ioctlp->tidPathp, reqp, &substRootp);
+        if (code) return code;
         
+        code = cm_NameI(substRootp, relativePath, CM_FLAG_CASEFOLD | CM_FLAG_FOLLOW,
+                         userp, NULL, reqp, scpp);
+        if (code) return code;
+    }
+
        /* # of bytes of path */
-        code = strlen(ioctlp->inDatap) + 1;
-        ioctlp->inDatap += code;
+    code = strlen(ioctlp->inDatap) + 1;
+    ioctlp->inDatap += code;
 
-        /* This is usually nothing, but for StatMountPoint it is the file name. */
-        TranslateExtendedChars(ioctlp->inDatap);
+    /* This is usually nothing, but for StatMountPoint it is the file name. */
+    TranslateExtendedChars(ioctlp->inDatap);
 
        /* and return success */
-        return 0;
+    return 0;
 }
 
 void cm_SkipIoctlPath(smb_ioctl_t *ioctlp)
@@ -173,15 +253,19 @@ void cm_SkipIoctlPath(smb_ioctl_t *ioctlp)
 void cm_NormalizeAfsPath (char *outpathp, char *inpathp)
 {
        char *cp;
-
-       if (!strnicmp (inpathp, "/afs", strlen("/afs")))
+    char bslash_mountRoot[256];
+       
+    strncpy(bslash_mountRoot, cm_mountRoot, sizeof(bslash_mountRoot) - 1);
+    bslash_mountRoot[0] = '\\';
+       
+    if (!strnicmp (inpathp, cm_mountRoot, strlen(cm_mountRoot)))
                lstrcpy (outpathp, inpathp);
-       else if (!strnicmp (inpathp, "\\afs", strlen("\\afs")))
+       else if (!strnicmp (inpathp, bslash_mountRoot, strlen(bslash_mountRoot)))
                lstrcpy (outpathp, inpathp);
        else if ((inpathp[0] == '/') || (inpathp[0] == '\\'))
-               sprintf (outpathp, "/afs%s", inpathp);
+               sprintf (outpathp, "%s%s", cm_mountRoot, inpathp);
        else // inpathp looks like "<cell>/usr"
-               sprintf (outpathp, "/afs/%s", inpathp);
+               sprintf (outpathp, "%s/%s", cm_mountRoot, inpathp);
 
        for (cp = outpathp; *cp != 0; ++cp) {
                if (*cp == '\\')
@@ -192,8 +276,8 @@ void cm_NormalizeAfsPath (char *outpathp, char *inpathp)
            outpathp[strlen(outpathp)-1] = 0;
        }
 
-       if (!strcmpi (outpathp, "/afs")) {
-           strcpy (outpathp, "/afs/");
+       if (!strcmpi (outpathp, cm_mountRoot)) {
+        strcpy (outpathp, cm_mountRoot);
        }
 }
 
@@ -204,35 +288,101 @@ long cm_ParseIoctlParent(smb_ioctl_t *ioctlp, cm_user_t *userp, cm_req_t *reqp,
                         cm_scache_t **scpp, char *leafp)
 {
        long code;
-        char tbuffer[1024];
-        char *tp, *jp;
+    char tbuffer[1024];
+    char *tp, *jp;
        cm_scache_t *substRootp;
 
        strcpy(tbuffer, ioctlp->inDatap);
-        tp = strrchr(tbuffer, '\\');
+    tp = strrchr(tbuffer, '\\');
        jp = strrchr(tbuffer, '/');
        if (!tp)
                tp = jp;
        else if (jp && (tp - tbuffer) < (jp - tbuffer))
                tp = jp;
-        if (!tp) {
-               strcpy(tbuffer, "\\");
-                if (leafp) strcpy(leafp, ioctlp->inDatap);
-       }
-        else {
-               *tp = 0;
-                if (leafp) strcpy(leafp, tp+1);
+    if (!tp) {
+        strcpy(tbuffer, "\\");
+        if (leafp) 
+            strcpy(leafp, ioctlp->inDatap);
        }
+    else {
+        *tp = 0;
+        if (leafp) 
+            strcpy(leafp, tp+1);
+       }   
+
+    if (tbuffer[0] == tbuffer[1] &&
+        tbuffer[1] == '\\' && 
+        !_strnicmp(cm_NetbiosName,tbuffer+2,strlen(cm_NetbiosName))) 
+    {
+        char shareName[256];
+        char *sharePath;
+        int shareFound, i;
+
+        /* We may have found a UNC path. 
+         * If the first component is the NetbiosName,
+         * then throw out the second component (the submount)
+         * since it had better expand into the value of ioctl->tidPathp
+         */
+        char * p;
+        p = tbuffer + 2 + strlen(cm_NetbiosName) + 1;
+        if ( !_strnicmp("all", p, 3) )
+            p += 4;
 
-       code = cm_NameI(cm_rootSCachep, ioctlp->prefix->data,
-               CM_FLAG_CASEFOLD | CM_FLAG_FOLLOW,
-               userp, ioctlp->tidPathp, reqp, &substRootp);
-       if (code) return code;
+        for (i = 0; *p && *p != '\\'; i++,p++ ) {
+            shareName[i] = *p;
+        }
+        p++;                    /* skip past trailing slash */
+        shareName[i] = 0;       /* terminate string */
+
+        shareFound = smb_FindShare(ioctlp->fidp->vcp, ioctlp->uidp, shareName, &sharePath);
+        if ( shareFound ) {
+            /* we found a sharename, therefore use the resulting path */
+            code = cm_NameI(cm_rootSCachep, ioctlp->prefix->data,
+                             CM_FLAG_CASEFOLD | CM_FLAG_FOLLOW,
+                             userp, sharePath, reqp, &substRootp);
+            free(sharePath);
+            if (code) return code;
+
+                       code = cm_NameI(substRootp, p, CM_FLAG_CASEFOLD | CM_FLAG_FOLLOW,
+                         userp, NULL, reqp, scpp);
+                       if (code) return code;
+        } else {
+            /* otherwise, treat the name as a cellname mounted off the afs root.
+                        * This requires that we reconstruct the shareName string with 
+                        * leading and trailing slashes.
+                        */
+            p = tbuffer + 2 + strlen(cm_NetbiosName) + 1;
+                       if ( !_strnicmp("all", p, 3) )
+                               p += 4;
+
+                       shareName[0] = '/';
+                       for (i = 1; *p && *p != '\\'; i++,p++ ) {
+                               shareName[i] = *p;
+                       }
+                       p++;                    /* skip past trailing slash */
+                       shareName[i++] = '/';   /* add trailing slash */
+                       shareName[i] = 0;       /* terminate string */
+                       
+                       code = cm_NameI(cm_rootSCachep, ioctlp->prefix->data,
+                             CM_FLAG_CASEFOLD | CM_FLAG_FOLLOW,
+                             userp, shareName, reqp, &substRootp);
+            if (code) return code;
+
+                       code = cm_NameI(substRootp, p, CM_FLAG_CASEFOLD | CM_FLAG_FOLLOW,
+                         userp, NULL, reqp, scpp);
+                       if (code) return code;
+        }
+    } else {
+        code = cm_NameI(cm_rootSCachep, ioctlp->prefix->data,
+                    CM_FLAG_CASEFOLD | CM_FLAG_FOLLOW,
+                    userp, ioctlp->tidPathp, reqp, &substRootp);
+        if (code) return code;
 
         code = cm_NameI(substRootp, tbuffer, CM_FLAG_FOLLOW,
-               userp, NULL, reqp, scpp);
-       if (code) return code;
-        
+                    userp, NULL, reqp, scpp);
+        if (code) return code;
+    }
+
        /* # of bytes of path */
         code = strlen(ioctlp->inDatap) + 1;
         ioctlp->inDatap += code;
@@ -269,8 +419,7 @@ long cm_IoctlGetACL(smb_ioctl_t *ioctlp, cm_user_t *userp)
                 if (code) continue;
                 
                 code = RXAFS_FetchACL(connp->callp, &fid, &acl, &fileStatus, &volSync);
-       } while (cm_Analyze(connp, userp, &req, &scp->fid,
-                           &volSync, NULL, code));
+       } while (cm_Analyze(connp, userp, &req, &scp->fid, &volSync, NULL, NULL, code));
        code = cm_MapRPCError(code, &req);
        cm_ReleaseSCache(scp);
         
@@ -335,8 +484,7 @@ long cm_IoctlSetACL(struct smb_ioctl *ioctlp, struct cm_user *userp)
                 if (code) continue;
                 
                 code = RXAFS_StoreACL(connp->callp, &fid, &acl, &fileStatus, &volSync);
-       } while (cm_Analyze(connp, userp, &req, &scp->fid,
-                           &volSync, NULL, code));
+       } while (cm_Analyze(connp, userp, &req, &scp->fid, &volSync, NULL, NULL, code));
        code = cm_MapRPCError(code, &req);
 
        /* invalidate cache info, since we just trashed the ACL cache */
@@ -461,7 +609,7 @@ long cm_IoctlSetVolumeStatus(struct smb_ioctl *ioctlp, struct cm_user *userp)
 
                code = RXAFS_SetVolumeStatus(tcp->callp, scp->fid.volume,
                        &storeStat, volName, offLineMsg, motd);
-       } while (cm_Analyze(tcp, userp, &req, &scp->fid, NULL, NULL, code));
+       } while (cm_Analyze(tcp, userp, &req, &scp->fid, NULL, NULL, NULL, code));
        code = cm_MapRPCError(code, &req);
 
        /* return on failure */
@@ -519,7 +667,7 @@ long cm_IoctlGetVolumeStatus(struct smb_ioctl *ioctlp, struct cm_user *userp)
 
                code = RXAFS_GetVolumeStatus(tcp->callp, scp->fid.volume,
                        &volStat, &Name, &OfflineMsg, &MOTD);
-       } while (cm_Analyze(tcp, userp, &req, &scp->fid, NULL, NULL, code));
+       } while (cm_Analyze(tcp, userp, &req, &scp->fid, NULL, NULL, NULL, code));
        code = cm_MapRPCError(code, &req);
 
        cm_ReleaseSCache(scp);
@@ -545,43 +693,43 @@ long cm_IoctlGetVolumeStatus(struct smb_ioctl *ioctlp, struct cm_user *userp)
 long cm_IoctlWhereIs(struct smb_ioctl *ioctlp, struct cm_user *userp)
 {
        long code;
-        cm_scache_t *scp;
-        cm_cell_t *cellp;
-        cm_volume_t *tvp;
-       cm_serverRef_t *tsrp;
-        cm_server_t *tsp;
-        unsigned long volume;
-        char *cp;
-        cm_req_t req;
+    cm_scache_t *scp;
+    cm_cell_t *cellp;
+    cm_volume_t *tvp;
+       cm_serverRef_t *tsrp, *current;
+    cm_server_t *tsp;
+    unsigned long volume;
+    char *cp;
+    cm_req_t req;
 
        cm_InitReq(&req);
 
-        code = cm_ParseIoctlPath(ioctlp, userp, &req, &scp);
-        if (code) return code;
+    code = cm_ParseIoctlPath(ioctlp, userp, &req, &scp);
+    if (code) return code;
         
        volume = scp->fid.volume;
 
        cellp = cm_FindCellByID(scp->fid.cell);
-        osi_assert(cellp);
+    osi_assert(cellp);
 
-        cm_ReleaseSCache(scp);
+    cm_ReleaseSCache(scp);
 
        code = cm_GetVolumeByID(cellp, volume, userp, &req, &tvp);
-        if (code) return code;
+    if (code) return code;
        
-        cp = ioctlp->outDatap;
+    cp = ioctlp->outDatap;
         
        lock_ObtainMutex(&tvp->mx);
        tsrp = cm_GetVolServers(tvp, volume);
        lock_ObtainRead(&cm_serverLock);
-       while(tsrp) {
-               tsp = tsrp->server;
+       for (current = tsrp; current; current = current->next) {
+               tsp = current->server;
                memcpy(cp, (char *)&tsp->addr.sin_addr.s_addr, sizeof(long));
                cp += sizeof(long);
-                tsrp = tsrp->next;
        }
        lock_ReleaseRead(&cm_serverLock);
-        lock_ReleaseMutex(&tvp->mx);
+    cm_FreeServerList(&tsrp);
+    lock_ReleaseMutex(&tvp->mx);
 
        /* still room for terminating NULL, add it on */
        volume = 0;     /* reuse vbl */
@@ -857,14 +1005,14 @@ long cm_IoctlGetCacheParms(struct smb_ioctl *ioctlp, struct cm_user *userp)
 long cm_IoctlGetCell(struct smb_ioctl *ioctlp, struct cm_user *userp)
 {
        long whichCell;
-        long magic = 0;
+    long magic = 0;
        cm_cell_t *tcellp;
        cm_serverRef_t *serverRefp;
-        cm_server_t *serverp;
+    cm_server_t *serverp;
        long i;
-        char *cp;
-        char *tp;
-        char *basep;
+    char *cp;
+    char *tp;
+    char *basep;
 
        cm_SkipIoctlPath(ioctlp);
 
@@ -878,7 +1026,7 @@ long cm_IoctlGetCell(struct smb_ioctl *ioctlp, struct cm_user *userp)
                memcpy((char *)&magic, tp, sizeof(long));
        }
 
-        lock_ObtainRead(&cm_cellLock);
+    lock_ObtainRead(&cm_cellLock);
        for(tcellp = cm_allCellsp; tcellp; tcellp = tcellp->nextp) {
                if (whichCell == 0) break;
                whichCell--;
@@ -894,15 +1042,16 @@ long cm_IoctlGetCell(struct smb_ioctl *ioctlp, struct cm_user *userp)
                        max = 13;
                }
                memset(cp, 0, max * sizeof(long));
-                basep = cp;
+        basep = cp;
                lock_ObtainRead(&cm_serverLock);        /* for going down server list */
+        /* jaltman - do the reference counts to serverRefp contents need to be increased? */
                serverRefp = tcellp->vlServersp;
                for(i=0; i<max; i++) {
                        if (!serverRefp) break;
                        serverp = serverRefp->server;
                        memcpy(cp, &serverp->addr.sin_addr.s_addr, sizeof(long));
                        cp += sizeof(long);
-                        serverRefp = serverRefp->next;
+            serverRefp = serverRefp->next;
                }
                lock_ReleaseRead(&cm_serverLock);
                cp = basep + max * sizeof(afs_int32);
@@ -915,12 +1064,58 @@ long cm_IoctlGetCell(struct smb_ioctl *ioctlp, struct cm_user *userp)
        else return CM_ERROR_NOMORETOKENS;      /* mapped to EDOM */
 }
 
+extern long cm_AddCellProc(void *rockp, struct sockaddr_in *addrp, char *namep);
+
 long cm_IoctlNewCell(struct smb_ioctl *ioctlp, struct cm_user *userp)
 {
-       /* don't need to do, since NT cache manager will re-read afsdcell.ini
-         * on every access to a new cell.
-         */
-       return CM_ERROR_INVAL;
+    /* NT cache manager will read cell information from afsdcell.ini each time
+     * cell is accessed. So, this call is necessary only if list of server for a cell 
+     * changes (or IP addresses of cell servers changes).
+     * All that needs to be done is to refresh server information for all cells that 
+     * are already loaded.
+  
+     * cell list will be cm_CellLock and cm_ServerLock will be held for write.
+    */  
+  
+    cm_cell_t *cp;
+  
+    cm_SkipIoctlPath(ioctlp);
+    lock_ObtainWrite(&cm_cellLock);
+  
+    for(cp = cm_allCellsp; cp; cp=cp->nextp) 
+    {
+        long code;
+        /* delete all previous server lists - cm_FreeServerList will ask for write on cm_ServerLock*/
+        cm_FreeServerList(&cp->vlServersp);
+        cp->vlServersp = NULL;
+        code = cm_SearchCellFile(cp->namep, cp->namep, cm_AddCellProc, cp);
+#ifdef AFS_AFSDB_ENV
+               if (code) {
+            if (cm_dnsEnabled) {
+                int ttl;
+                code = cm_SearchCellByDNS(cp->namep, cp->namep, &ttl, cm_AddCellProc, cp);
+                if ( code == 0 ) { /* got cell from DNS */
+                    cp->flags |= CM_CELLFLAG_DNS;
+                    cp->flags &= ~CM_CELLFLAG_VLSERVER_INVALID;
+                    cp->timeout = time(0) + ttl;
+                }
+            }
+        } 
+        else {
+            cp->flags &= ~CM_CELLFLAG_DNS;
+        }
+#endif /* AFS_AFSDB_ENV */
+        if (code) {
+            cp->flags |= CM_CELLFLAG_VLSERVER_INVALID;
+        }
+        else {
+            cp->flags &= ~CM_CELLFLAG_VLSERVER_INVALID;
+            cm_RandomizeServer(&cp->vlServersp);
+        }
+    }
+    
+    lock_ReleaseWrite(&cm_cellLock);
+    return 0;       
 }
 
 long cm_IoctlGetWsCell(smb_ioctl_t *ioctlp, cm_user_t *userp)
@@ -940,30 +1135,94 @@ long cm_IoctlGetWsCell(smb_ioctl_t *ioctlp, cm_user_t *userp)
 
 long cm_IoctlSysName(struct smb_ioctl *ioctlp, struct cm_user *userp)
 {
-       long setSysName;
-        char *cp;
+       long setSysName, foundname = 0;
+    char *cp, *cp2, inname[MAXSYSNAME], outname[MAXSYSNAME];
+    int t, count, num = 0;
+    char **sysnamelist[MAXSYSNAME];
         
        cm_SkipIoctlPath(ioctlp);
 
-        memcpy(&setSysName, ioctlp->inDatap, sizeof(long));
-        ioctlp->inDatap += sizeof(long);
+    memcpy(&setSysName, ioctlp->inDatap, sizeof(long));
+    ioctlp->inDatap += sizeof(long);
         
-        if (setSysName) {
-               strcpy(cm_sysName, ioctlp->inDatap);
+    if (setSysName) {
+        /* check my args */
+        if ( setSysName < 0 || setSysName > MAXNUMSYSNAMES )
+            return EINVAL;
+        cp2 = ioctlp->inDatap;
+        for ( cp=ioctlp->inDatap, count = 0; count < setSysName; count++ ) {
+            /* won't go past end of ioctlp->inDatap since maxsysname*num < ioctlp->inDatap length */
+            t = strlen(cp);
+            if (t >= MAXSYSNAME || t <= 0)
+                return EINVAL;
+            /* check for names that can shoot us in the foot */
+            if (*cp == '.' && (cp[1] == 0 || (cp[1] == '.' && cp[2] == 0)))
+                return EINVAL;
+            cp += t + 1;
         }
-        else {
+        /* args ok */
+
+        /* inname gets first entry in case we're being a translator */
+        /* (we are never a translator) */
+        t = strlen(ioctlp->inDatap);
+        memcpy(inname, ioctlp->inDatap, t + 1);
+        ioctlp->inDatap += t + 1;
+        num = count;
+    }
+
+    /* Not xlating, so local case */
+    if (!cm_sysName)
+        osi_panic("cm_IoctlSysName: !cm_sysName\n", __FILE__, __LINE__);
+
+    if (!setSysName) {      /* user just wants the info */
+        strcpy(outname, cm_sysName);
+        foundname = cm_sysNameCount;
+        *sysnamelist = cm_sysNameList;
+    } else {                /* Local guy; only root can change sysname */
+        /* clear @sys entries from the dnlc, once afs_lookup can
+         * do lookups of @sys entries and thinks it can trust them */
+        /* privs ok, store the entry, ... */
+        strcpy(cm_sysName, inname);
+        if (setSysName > 1) {       /* ... or list */
+            cp = ioctlp->inDatap;
+            for (count = 1; count < setSysName; ++count) {
+                if (!cm_sysNameList[count])
+                    osi_panic
+                        ("cm_IoctlSysName: no cm_sysNameList entry to write\n"
+                          , __FILE__, __LINE__);
+                t = strlen(cp);
+                memcpy(cm_sysNameList[count], cp, t + 1);  /* include null */
+                cp += t + 1;
+            }
+        }
+        cm_sysNameCount = setSysName;
+    }
+
+    if (!setSysName) {
                /* return the sysname to the caller */
-                setSysName = 1;        /* really means "found sys name */
                cp = ioctlp->outDatap;
-                memcpy(cp, &setSysName, sizeof(long));
-                cp += sizeof(long);    /* skip found flag */
-                strcpy(cp, cm_sysName);
-                cp += strlen(cp) + 1;  /* skip name and terminating null char */
-                ioctlp->outDatap = cp;
+        memcpy(cp, (char *)&foundname, sizeof(afs_int32));
+        cp += sizeof(afs_int32);       /* skip found flag */
+        if (foundname) {
+            strcpy(cp, outname);
+            cp += strlen(outname) + 1; /* skip name and terminating null char */
+            for ( count=1; count < foundname ; ++count) {   /* ... or list */
+                if ( !(*sysnamelist)[count] )
+                    osi_panic("cm_IoctlSysName: no cm_sysNameList entry to read\n"
+                               , __FILE__, __LINE__);
+                t = strlen((*sysnamelist)[count]);
+                if (t >= MAXSYSNAME)
+                    osi_panic("cm_IoctlSysName: sysname entry garbled\n"
+                               , __FILE__, __LINE__);
+                strcpy(cp, (*sysnamelist)[count]);
+                cp += t + 1;
+            }
         }
+        ioctlp->outDatap = cp;
+    }
         
        /* done: success */
-        return 0;
+    return 0;
 }
 
 long cm_IoctlGetCellStatus(struct smb_ioctl *ioctlp, struct cm_user *userp)
@@ -1027,7 +1286,8 @@ long cm_IoctlSetSPrefs(struct smb_ioctl *ioctlp, struct cm_user *userp)
        vlonly     = spin->flags;
        if ( vlonly )
                type = CM_SERVER_VLDB;
-       else    type = CM_SERVER_FILE;
+       else    
+        type = CM_SERVER_FILE;
 
        for ( i=0; i < noServers; i++) 
        {
@@ -1037,7 +1297,7 @@ long cm_IoctlSetSPrefs(struct smb_ioctl *ioctlp, struct cm_user *userp)
                tmp.sin_family = AF_INET;
 
                tsp = cm_FindServer(&tmp, type);
-               if ( tsp )              /* an existing server */
+               if ( tsp )              /* an existing server - ref count increased */
                {
                        tsp->ipRank = rank; /* no need to protect by mutex*/
 
@@ -1053,13 +1313,13 @@ long cm_IoctlSetSPrefs(struct smb_ioctl *ioctlp, struct cm_user *userp)
                            /* set preferences for an existing vlserver */
                            cm_ChangeRankCellVLServer(tsp);
                        }
+            cm_PutServer(tsp);  /* decrease refcount */
                }
-               else                    /* add a new server without a cell*/
+               else    /* add a new server without a cell */
                {
-                       tsp = cm_NewServer(&tmp, type, NULL);
+                       tsp = cm_NewServer(&tmp, type, NULL); /* refcount = 1 */
                        tsp->ipRank = rank;
                }
-               cm_PutServer(tsp);
        }
        return 0;
 }
@@ -1121,65 +1381,79 @@ long cm_IoctlStoreBehind(struct smb_ioctl *ioctlp, struct cm_user *userp)
 long cm_IoctlCreateMountPoint(struct smb_ioctl *ioctlp, struct cm_user *userp)
 {
        char leaf[256];
-        long code;
-        cm_scache_t *dscp;
-        cm_attr_t tattr;
-        char *cp;
+    long code;
+    cm_scache_t *dscp;
+    cm_attr_t tattr;
+    char *cp;
        cm_req_t req;
-        char mpInfo[256];
-        char fullCell[256];
+    char mpInfo[256];
+    char fullCell[256];
        char volume[256];
        char cell[256];
+       int ttl;
 
        cm_InitReq(&req);
         
-        code = cm_ParseIoctlParent(ioctlp, userp, &req, &dscp, leaf);
-        if (code) return code;
+    code = cm_ParseIoctlParent(ioctlp, userp, &req, &dscp, leaf);
+    if (code) return code;
 
-        /* Translate chars for the mount point name */
-        TranslateExtendedChars(leaf);
+    /* Translate chars for the mount point name */
+    TranslateExtendedChars(leaf);
 
-        /* 
-         * The fs command allows the user to specify partial cell names on NT.  These must
-         * be expanded to the full cell name for mount points so that the mount points will
-         * work on UNIX clients.
-         */
+    /* 
+     * The fs command allows the user to specify partial cell names on NT.  These must
+     * be expanded to the full cell name for mount points so that the mount points will
+     * work on UNIX clients.
+     */
 
        /* Extract the possibly partial cell name */
        strcpy(cell, ioctlp->inDatap + 1);      /* Skip the mp type character */
         
-        if (cp = strchr(cell, ':')) {
+    if (cp = strchr(cell, ':')) {
                /* Extract the volume name */
-               *cp = 0;
+        *cp = 0;
                strcpy(volume,  cp + 1);
        
-               /* Get the full name for this cell */
-               code = cm_SearchCellFile(cell, fullCell, 0, 0);
-               if (code)
+        /* Get the full name for this cell */
+        code = cm_SearchCellFile(cell, fullCell, 0, 0);
+#ifdef AFS_AFSDB_ENV
+               if (code && cm_dnsEnabled)
+            code = cm_SearchCellByDNS(cell, fullCell, &ttl, 0, 0);
+#endif
+        if (code)
                        return CM_ERROR_NOSUCHCELL;
        
-               sprintf(mpInfo, "%c%s:%s", *ioctlp->inDatap, fullCell, volume);
+        sprintf(mpInfo, "%c%s:%s", *ioctlp->inDatap, fullCell, volume);
        } else {
-               /* No cell name specified */
-               strcpy(mpInfo, ioctlp->inDatap);
-        }
-
+        /* No cell name specified */
+        strcpy(mpInfo, ioctlp->inDatap);
+    }
+
+#ifdef AFS_FREELANCE_CLIENT
+       if (cm_freelanceEnabled && dscp == cm_rootSCachep) {
+         /* we are adding the mount point to the root dir., so call
+            the freelance code to do the add. */
+         osi_Log0(afsd_logp,"IoctlCreateMountPoint within Freelance root dir");
+         code = cm_FreelanceAddMount(leaf, fullCell, volume, 
+                                  *ioctlp->inDatap == '%', NULL);
+         return code;
+       }
+#endif
        /* create the symlink with mode 644.  The lack of X bits tells
-         * us that it is a mount point.
-         */
+     * us that it is a mount point.
+     */
        tattr.mask = CM_ATTRMASK_UNIXMODEBITS | CM_ATTRMASK_CLIENTMODTIME;
-        tattr.unixModeBits = 0644;
+    tattr.unixModeBits = 0644;
        tattr.clientModTime = time(NULL);
 
-        code = cm_SymLink(dscp, leaf, mpInfo, 0, &tattr, userp, &req);
+    code = cm_SymLink(dscp, leaf, mpInfo, 0, &tattr, userp, &req);
        if (code == 0 && (dscp->flags & CM_SCACHEFLAG_ANYWATCH))
                smb_NotifyChange(FILE_ACTION_ADDED,
-                                FILE_NOTIFY_CHANGE_DIR_NAME,
-                                dscp, leaf, NULL, TRUE);
-
-        cm_ReleaseSCache(dscp);
+                         FILE_NOTIFY_CHANGE_DIR_NAME,
+                         dscp, leaf, NULL, TRUE);
 
-        return code;
+    cm_ReleaseSCache(dscp);
+    return code;
 }
 
 long cm_IoctlSymlink(struct smb_ioctl *ioctlp, struct cm_user *userp)
@@ -1256,7 +1530,8 @@ long cm_IoctlListlink(struct smb_ioctl *ioctlp, struct cm_user *userp)
        if (code == 0) {
                cp = ioctlp->outDatap;
                if (newRootScp != NULL) {
-                       strcpy(cp, "/afs/");
+            strcpy(cp, cm_mountRoot);
+            strcat(cp, "/");
                        cp += strlen(cp);
                }
                strcpy(cp, spacep->data);
@@ -1270,6 +1545,33 @@ long cm_IoctlListlink(struct smb_ioctl *ioctlp, struct cm_user *userp)
        return code;
 }
 
+long cm_IoctlIslink(struct smb_ioctl *ioctlp, struct cm_user *userp)
+{/*CHECK FOR VALID SYMLINK*/
+       long code;
+       cm_scache_t *dscp;
+       cm_scache_t *scp;
+       char *cp;
+       cm_req_t req;
+
+       cm_InitReq(&req);
+
+       code = cm_ParseIoctlPath(ioctlp, userp, &req, &dscp);
+       if (code) return code;
+
+       cp = ioctlp->inDatap;
+       osi_LogEvent("cm_IoctlListlink",NULL," name[%s]",cp);
+
+       code = cm_Lookup(dscp, cp, CM_FLAG_NOMOUNTCHASE, userp, &req, &scp);
+       cm_ReleaseSCache(dscp);
+       if (code) return code;
+
+       /* Check that it's a real symlink */
+       if (scp->fileType != CM_SCACHETYPE_SYMLINK)
+               code = CM_ERROR_INVAL;
+       cm_ReleaseSCache(scp);
+       return code;
+}
+
 long cm_IoctlDeletelink(struct smb_ioctl *ioctlp, struct cm_user *userp)
 {
        long code;
@@ -1340,6 +1642,7 @@ long cm_IoctlSetToken(struct smb_ioctl *ioctlp, struct cm_user *userp)
        afs_uuid_t uuid;
        int flags;
        char sessionKey[8];
+       char *smbname;
 
        saveDataPtr = ioctlp->inDatap;
 
@@ -1384,18 +1687,37 @@ long cm_IoctlSetToken(struct smb_ioctl *ioctlp, struct cm_user *userp)
                uname = tp;
                tp += strlen(tp) + 1;
 
+        if (flags & PIOCTL_LOGON) {
+                 /* SMB user name with which to associate tokens */
+                 smbname = tp;
+          osi_Log2(smb_logp,"cm_IoctlSetToken for user [%s] smbname [%s]",
+                    osi_LogSaveString(smb_logp,uname), osi_LogSaveString(smb_logp,smbname));
+          fprintf(stderr, "SMB name = %s\n", smbname);
+                 tp += strlen(tp) + 1;
+        } else {
+            osi_Log1(smb_logp,"cm_IoctlSetToken for user [%s]",
+                      osi_LogSaveString(smb_logp,uname));
+        }
+
 #ifndef DJGPP   /* for win95, session key is back in pioctl */
                /* uuid */
                memcpy(&uuid, tp, sizeof(uuid));
                if (!cm_FindTokenEvent(uuid, sessionKey))
                        return CM_ERROR_INVAL;
 #endif /* !DJGPP */
-       } else
+       } else {
                cellp = cm_rootCellp;
+        osi_Log0(smb_logp,"cm_IoctlSetToken - no name specified");
+    }
 
+       if (flags & PIOCTL_LOGON) {
+          userp = smb_FindCMUserByName(smbname, ioctlp->fidp->vcp->rname);
+       }
+       
        /* store the token */
        lock_ObtainMutex(&userp->mx);
        ucellp = cm_GetUCell(userp, cellp);
+    osi_Log1(smb_logp,"cm_IoctlSetToken ucellp %lx", ucellp);
        ucellp->ticketLen = ticketLen;
        if (ucellp->ticketp)
                free(ucellp->ticketp);  /* Discard old token if any */
@@ -1630,6 +1952,8 @@ long cm_IoctlDelToken(struct smb_ioctl *ioctlp, struct cm_user *userp)
                return CM_ERROR_NOMORETOKENS;
        }
 
+    osi_Log1(smb_logp,"cm_IoctlDelToken ucellp %lx", ucellp);
+
        if (ucellp->ticketp) {
                free(ucellp->ticketp);
                ucellp->ticketp = NULL;
@@ -1650,7 +1974,8 @@ long cm_IoctlDelAllToken(struct smb_ioctl *ioctlp, struct cm_user *userp)
 
        lock_ObtainMutex(&userp->mx);
 
-       for (ucellp = userp->cellInfop; ucellp; ucellp = ucellp->nextp) {
+    for (ucellp = userp->cellInfop; ucellp; ucellp = ucellp->nextp) {
+        osi_Log1(smb_logp,"cm_IoctlDelAllToken ucellp %lx", ucellp);
                ucellp->flags &= ~CM_UCELLFLAG_RXKAD;
                ucellp->gen++;
        }
@@ -1666,11 +1991,12 @@ long cm_IoctlMakeSubmount(smb_ioctl_t *ioctlp, cm_user_t *userp)
 {
        char afspath[MAX_PATH];
        char *submountreqp;
-       int iteration;
-       int submountDataSize;
-       char *submountData;
-       char *submountName;
        int nextAutoSubmount;
+    HKEY hkSubmounts;
+    DWORD dwType, dwSize;
+    DWORD status;
+    DWORD dwIndex;
+    DWORD dwSubmounts;
 
        cm_SkipIoctlPath(ioctlp);
 
@@ -1689,31 +2015,44 @@ long cm_IoctlMakeSubmount(smb_ioctl_t *ioctlp, cm_user_t *userp)
         * that submount name is in use... if so, the submount's path
         * has to match our path.
         */
-       if (submountreqp && *submountreqp) {
+
+    RegCreateKeyEx( HKEY_LOCAL_MACHINE, 
+                    "SOFTWARE\\OpenAFS\\Client\\Submounts",
+                    0, 
+                    "AFS", 
+                    REG_OPTION_NON_VOLATILE,
+                    KEY_READ|KEY_WRITE|KEY_QUERY_VALUE,
+                    NULL, 
+                    &hkSubmounts,
+                    NULL );
+
+    if (submountreqp && *submountreqp) {
                char submountPathNormalized[MAX_PATH];
                char submountPath[MAX_PATH];
-               int submountPathLen;
 
-               submountPathLen = GetPrivateProfileString("AFS Submounts",
-                                       submountreqp, "", submountPath,
-                                       sizeof(submountPath), "afsdsbmt.ini");
+        dwSize = sizeof(submountPath);
+        status = RegQueryValueEx( hkSubmounts, submountreqp, 0,
+                         &dwType, submountPath, &dwSize);
 
-               if ((submountPathLen == 0) ||
-                   (submountPathLen == sizeof(submountPath) - 1)) {
+               if (status != ERROR_SUCCESS) {
 
                        /* The suggested submount name isn't in use now--
                         * so we can safely map the requested submount name
                         * to the supplied path. Remember not to write the
                         * leading "/afs" when writing out the submount.
                         */
-                       WritePrivateProfileString("AFS Submounts",
-                                       submountreqp, &afspath[strlen("/afs")],
-                                       "afsdsbmt.ini");
-
+            RegSetValueEx( hkSubmounts, submountreqp, 0,
+                           REG_SZ, 
+                           (strlen(&afspath[strlen(cm_mountRoot)])) ?
+                           &afspath[strlen(cm_mountRoot)]:"/",
+                           (strlen(&afspath[strlen(cm_mountRoot)])) ?
+                           strlen(&afspath[strlen(cm_mountRoot)])+1:2);
+
+            RegCloseKey( hkSubmounts );
                        strcpy(ioctlp->outDatap, submountreqp);
                        ioctlp->outDatap += strlen(ioctlp->outDatap) +1;
                        lock_ReleaseMutex(&cm_Afsdsbmt_Lock);
-                       return 0;
+            return 0;
                }
 
                /* The suggested submount name is already in use--if the
@@ -1724,35 +2063,26 @@ long cm_IoctlMakeSubmount(smb_ioctl_t *ioctlp, cm_user_t *userp)
                if (!strcmp (submountPathNormalized, afspath)) {
                        strcpy(ioctlp->outDatap, submountreqp);
                        ioctlp->outDatap += strlen(ioctlp->outDatap) +1;
+            RegCloseKey( hkSubmounts );
                        lock_ReleaseMutex(&cm_Afsdsbmt_Lock);
-                       return 0;
+            return 0;
                }
        }
 
-       /* At this point, the user either didn't request a particular
-        * submount name, or that submount name couldn't be used.
-        * Look through afsdsbmt.ini to see if there are any submounts
-        * already associated with the specified path. The first
-        * step in doing that search is to load the AFS Submounts
-        * section of afsdsbmt.ini into memory.
-        */
-
-       submountDataSize = 1024;
-       submountData = malloc (submountDataSize);
-
-       for (iteration = 0; iteration < 5; ++iteration) {
-
-               int sectionSize;
-               sectionSize = GetPrivateProfileString("AFS Submounts",
-                                       NULL, "", submountData,
-                                       submountDataSize, "afsdsbmt.ini");
-               if (sectionSize < submountDataSize-2)
-                       break;
+    RegQueryInfoKey( hkSubmounts,
+                 NULL,  /* lpClass */
+                 NULL,  /* lpcClass */
+                 NULL,  /* lpReserved */
+                 NULL,  /* lpcSubKeys */
+                 NULL,  /* lpcMaxSubKeyLen */
+                 NULL,  /* lpcMaxClassLen */
+                 &dwSubmounts, /* lpcValues */
+                 NULL,  /* lpcMaxValueNameLen */
+                 NULL,  /* lpcMaxValueLen */
+                 NULL,  /* lpcbSecurityDescriptor */
+                 NULL   /* lpftLastWriteTime */
+                 );
 
-               free (submountData);
-               submountDataSize *= 2;
-               submountData = malloc (submountDataSize);
-       }
 
        /* Having obtained a list of all available submounts, start
         * searching that list for a path which matches the requested
@@ -1762,13 +2092,15 @@ long cm_IoctlMakeSubmount(smb_ioctl_t *ioctlp, cm_user_t *userp)
 
        nextAutoSubmount = 1;
 
-       for (submountName = submountData;
-               submountName && *submountName;
-               submountName += 1+strlen(submountName)) {
-
+    for ( dwIndex = 0; dwIndex < dwSubmounts; dwIndex ++ ) {
                char submountPathNormalized[MAX_PATH];
                char submountPath[MAX_PATH] = "";
-               int submountPathLen;
+               DWORD submountPathLen = sizeof(submountPath);
+        char submountName[256];
+        DWORD submountNameLen = sizeof(submountName);
+
+        RegEnumValue( hkSubmounts, dwIndex, submountName, &submountNameLen, NULL,
+              &dwType, submountPath, &submountPathLen);
 
                /* If this is an Auto### submount, remember its ### value */
 
@@ -1780,14 +2112,6 @@ long cm_IoctlMakeSubmount(smb_ioctl_t *ioctlp, cm_user_t *userp)
                                                thisAutoSubmount+1);
                }
 
-               /* We have the name of a submount in the AFS Submounts
-                * section; read that entry to find out what path it
-                * maps to.
-                */
-               submountPathLen = GetPrivateProfileString("AFS Submounts",
-                                       submountName, "", submountPath,
-                                       sizeof(submountPath), "afsdsbmt.ini");
-
                if ((submountPathLen == 0) ||
                    (submountPathLen == sizeof(submountPath) - 1)) {
                        continue;
@@ -1799,18 +2123,15 @@ long cm_IoctlMakeSubmount(smb_ioctl_t *ioctlp, cm_user_t *userp)
                 */
                cm_NormalizeAfsPath (submountPathNormalized, submountPath);
                if (!strcmp (submountPathNormalized, afspath)) {
-
                        strcpy(ioctlp->outDatap, submountName);
                        ioctlp->outDatap += strlen(ioctlp->outDatap) +1;
-                       free (submountData);
+            RegCloseKey(hkSubmounts);
                        lock_ReleaseMutex(&cm_Afsdsbmt_Lock);
-                       return 0;
+            return 0;
 
                }
        }
 
-       free (submountData);
-
        /* We've been through the entire list of existing submounts, and
         * didn't find any which matched the specified path. So, we'll
         * just have to add one. Remember not to write the leading "/afs"
@@ -1819,11 +2140,17 @@ long cm_IoctlMakeSubmount(smb_ioctl_t *ioctlp, cm_user_t *userp)
 
        sprintf(ioctlp->outDatap, "auto%ld", nextAutoSubmount);
 
-       WritePrivateProfileString("AFS Submounts", ioctlp->outDatap,
-                                       &afspath[lstrlen("/afs")],
-                                       "afsdsbmt.ini");
+    RegSetValueEx( hkSubmounts, 
+                   ioctlp->outDatap,
+                   0,
+                   REG_SZ, 
+                   (strlen(&afspath[strlen(cm_mountRoot)])) ?
+                   &afspath[strlen(cm_mountRoot)]:"/",
+                   (strlen(&afspath[strlen(cm_mountRoot)])) ?
+                   strlen(&afspath[strlen(cm_mountRoot)])+1:2);
 
        ioctlp->outDatap += strlen(ioctlp->outDatap) +1;
+    RegCloseKey(hkSubmounts);
        lock_ReleaseMutex(&cm_Afsdsbmt_Lock);
        return 0;
 }
@@ -1849,9 +2176,96 @@ long cm_IoctlSetRxkcrypt(smb_ioctl_t *ioctlp, cm_user_t *userp)
 extern int afsd_shutdown(int);
 extern int afs_shutdown;
 
-long cm_IoctlShutdown(smb_ioctl_t *ioctlp, cm_user_t *userp)
-{
+long cm_IoctlShutdown(smb_ioctl_t *ioctlp, cm_user_t *userp) {
   afs_shutdown = 1;   /* flag to shut down */
   return 0;
 }
 #endif /* DJGPP */
+
+long cm_IoctlGetSMBName(smb_ioctl_t *ioctlp, cm_user_t *userp)
+{
+  smb_user_t *uidp = ioctlp->uidp;
+
+  if (uidp && uidp->unp) {
+    memcpy(ioctlp->outDatap, uidp->unp->name, strlen(uidp->unp->name));
+    ioctlp->outDatap += strlen(uidp->unp->name);
+       }
+
+  return 0;
+}
+
+/* 
+ * functions to dump contents of various structures. 
+ * In debug build (linked with crt debug library) will dump allocated but not freed memory
+ */
+extern int cm_DumpSCache(FILE *outputFile, char *cookie);
+extern int cm_DumpBufHashTable(FILE *outputFile, char *cookie);
+extern int smb_DumpVCP(FILE *outputFile, char *cookie);
+
+long cm_IoctlMemoryDump(struct smb_ioctl *ioctlp, struct cm_user *userp)
+{
+    long inValue = 0;
+    HANDLE hLogFile;
+    char logfileName[MAX_PATH+1];
+    char *cookie;
+  
+#ifdef _DEBUG  
+    static _CrtMemState memstate;
+#endif
+  
+    cm_SkipIoctlPath(ioctlp);
+    memcpy(&inValue, ioctlp->inDatap, sizeof(long));
+  
+    if (getenv("TEMP"))
+    {
+        strncpy(logfileName, getenv("TEMP"), MAX_PATH);
+        logfileName[MAX_PATH] = '\0';
+    }
+    else
+    {
+        GetWindowsDirectory(logfileName, sizeof(logfileName));
+    }
+    strncat(logfileName, "\\afsd_alloc.log", sizeof(logfileName));
+
+    hLogFile = CreateFile(logfileName, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
+  
+    if (!hLogFile)
+    {
+      /* error */
+      inValue = -1;
+      memcpy(ioctlp->outDatap, &inValue, sizeof(long));
+      ioctlp->outDatap += sizeof(long);
+      
+      return 0;               
+    }
+  
+    SetFilePointer(hLogFile, 0, NULL, FILE_END);
+  
+    cookie = inValue ? "b" : "e";
+  
+#ifdef _DEBUG  
+  
+    if (inValue)
+    {
+      _CrtMemCheckpoint(&memstate);           
+    }
+    else
+    {
+        _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
+        _CrtSetReportFile(_CRT_WARN, hLogFile);
+        _CrtMemDumpAllObjectsSince(&memstate);
+    }
+#endif
+  
+    /* dump all interesting data */
+    cm_DumpSCache(hLogFile, cookie);
+    cm_DumpBufHashTable(hLogFile, cookie);
+    smb_DumpVCP(hLogFile, cookie);
+
+    CloseHandle(hLogFile);                          
+  
+    memcpy(ioctlp->outDatap, &inValue, sizeof(long));
+    ioctlp->outDatap += sizeof(long);
+  
+    return 0;
+}