#include "afsd.h"
#include "afsd_init.h"
+#include <WINNT\afsreg.h>
#include "smb.h"
#include "cm_server.h"
#include "cm_rpc.h"
#include <strsafe.h>
+#include <winioctl.h>
+#include <WINNT\afsrdr\kif.h>
#ifdef _DEBUG
#include <crtdbg.h>
lock_ObtainMutex(&scp->mx);
scp->cbServerp = NULL;
scp->cbExpires = 0;
+ cm_dnlcPurgedp(scp);
+ cm_dnlcPurgevp(scp);
+ cm_FreeAllACLEnts(scp);
lock_ReleaseMutex(&scp->mx);
lock_ReleaseWrite(&scp->bufCreateLock);
- cm_dnlcPurgedp(scp);
-
return code;
}
int hash;
lock_ObtainWrite(&cm_scacheLock);
- for (hash=0; hash < cm_hashTableSize; hash++) {
- for (scp=cm_hashTablep[hash]; scp; scp=scp->nextp) {
+ for (hash=0; hash < cm_data.hashTableSize; hash++) {
+ for (scp=cm_data.hashTablep[hash]; scp; scp=scp->nextp) {
cm_HoldSCacheNoLock(scp);
lock_ReleaseWrite(&cm_scacheLock);
lock_ObtainMutex(&scp->mx);
long cm_ParseIoctlPath(smb_ioctl_t *ioctlp, cm_user_t *userp, cm_req_t *reqp,
cm_scache_t **scpp)
{
- long code;
+ long code, length;
cm_scache_t *substRootp;
- char * relativePath = ioctlp->inDatap;
+ char * relativePath = ioctlp->inDatap, absRoot[100];
+ wchar_t absRoot_w[100];
+ HANDLE rootDir;
/* This is usually the file name, but for StatMountPoint it is the path. */
/* ioctlp->inDatap can be either of the form:
*/
TranslateExtendedChars(relativePath);
- if (relativePath[0] == relativePath[1] &&
+#ifdef AFSIFS
+ /* we have passed the whole path, including the afs prefix (pioctl_nt.c modified) */
+ /*_asm int 3;
+ sprintf(absRoot, "%c:", relativePath[0]);
+ rootDir = CreateFile(absRoot, 0, 0, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
+
+ if (!DeviceIoControl(rootDir, IOCTL_AFSRDR_GET_PATH, NULL, 0, absRoot_w, 100*sizeof(wchar_t), &length, NULL))
+ {
+ CloseHandle(rootDir);
+ return CM_ERROR_NOSUCHPATH;
+ }
+ CloseHandle(rootDir);
+
+ ifs_ConvertFileName(absRoot_w, length/sizeof(wchar_t), absRoot, 100);*/
+
+#if 0
+ switch (relativePath[0]) /* FIXFIX */
+ {
+ case 'y':
+ case 'Y':
+ absRoot = "\\ericjw\\test"; /* should use drivemap */
+ }
+#endif
+ code = cm_NameI(cm_data.rootSCachep, relativePath,
+ CM_FLAG_CASEFOLD | CM_FLAG_FOLLOW,
+ userp, ""/*absRoot*//*ioctlp->tidPathp*/, reqp, scpp);
+
+ if (code)
+ return code;
+
+ /* # of bytes of path */
+ code = strlen(ioctlp->inDatap) + 1;
+ ioctlp->inDatap += code;
+
+ /* This is usually nothing, but for StatMountPoint it is the file name. */
+ TranslateExtendedChars(ioctlp->inDatap);
+
+ return 0;
+#endif
+
+ if (relativePath[0] == relativePath[1] &&
relativePath[1] == '\\' &&
!_strnicmp(cm_NetbiosName,relativePath+2,strlen(cm_NetbiosName)))
{
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,
+ code = cm_NameI(cm_data.rootSCachep, ioctlp->prefix->data,
CM_FLAG_CASEFOLD | CM_FLAG_FOLLOW,
userp, sharePath, reqp, &substRootp);
free(sharePath);
shareName[i] = 0; /* terminate string */
- code = cm_NameI(cm_rootSCachep, ioctlp->prefix->data,
+ code = cm_NameI(cm_data.rootSCachep, ioctlp->prefix->data,
CM_FLAG_CASEFOLD | CM_FLAG_FOLLOW,
userp, shareName, reqp, &substRootp);
if (code)
return code;
}
} else {
- code = cm_NameI(cm_rootSCachep, ioctlp->prefix->data,
+ code = cm_NameI(cm_data.rootSCachep, ioctlp->prefix->data,
CM_FLAG_CASEFOLD | CM_FLAG_FOLLOW,
userp, ioctlp->tidPathp, reqp, &substRootp);
if (code)
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,
+ code = cm_NameI(cm_data.rootSCachep, ioctlp->prefix->data,
CM_FLAG_CASEFOLD | CM_FLAG_FOLLOW,
userp, sharePath, reqp, &substRootp);
free(sharePath);
shareName[i++] = '/'; /* add trailing slash */
shareName[i] = 0; /* terminate string */
- code = cm_NameI(cm_rootSCachep, ioctlp->prefix->data,
+ code = cm_NameI(cm_data.rootSCachep, ioctlp->prefix->data,
CM_FLAG_CASEFOLD | CM_FLAG_FOLLOW,
userp, shareName, reqp, &substRootp);
if (code) return code;
if (code) return code;
}
} else {
- code = cm_NameI(cm_rootSCachep, ioctlp->prefix->data,
+ code = cm_NameI(cm_data.rootSCachep, ioctlp->prefix->data,
CM_FLAG_CASEFOLD | CM_FLAG_FOLLOW,
userp, ioctlp->tidPathp, reqp, &substRootp);
if (code) return code;
{
cellp = cm_FindCellByID(scp->fid.cell);
if (cellp) {
- StringCbCopyA(ioctlp->outDatap, 999999, cellp->namep);
+ StringCbCopyA(ioctlp->outDatap, 999999, cellp->name);
ioctlp->outDatap += strlen(ioctlp->outDatap) + 1;
code = 0;
}
cm_ReleaseSCache(scp);
lock_ObtainWrite(&cm_scacheLock);
- for (i=0; i<cm_hashTableSize; i++) {
- for (scp = cm_hashTablep[i]; scp; scp = scp->nextp) {
+ for (i=0; i<cm_data.hashTableSize; i++) {
+ for (scp = cm_data.hashTablep[i]; scp; scp = scp->nextp) {
if (scp->fid.volume == volume) {
cm_HoldSCacheNoLock(scp);
lock_ReleaseWrite(&cm_scacheLock);
memcpy(&temp, ioctlp->inDatap, sizeof(temp));
if (temp == 0)
- temp = buf_nOrigBuffers;
+ temp = cm_data.buf_nOrigBuffers;
else {
/* temp is in 1K units, convert to # of buffers */
- temp = temp / (buf_bufferSize / 1024);
+ temp = temp / (cm_data.buf_blockSize / 1024);
}
/* now adjust the cache size */
memset(&parms, 0, sizeof(parms));
/* first we get, in 1K units, the cache size */
- parms.parms[0] = buf_nbuffers * (buf_bufferSize / 1024);
+ parms.parms[0] = cm_data.buf_nbuffers * (cm_data.buf_blockSize / 1024);
/* and then the actual # of buffers in use (not in the free list, I guess,
* will be what we do).
*/
- parms.parms[1] = (buf_nbuffers - buf_CountFreeList()) * (buf_bufferSize / 1024);
+ parms.parms[1] = (cm_data.buf_nbuffers - buf_CountFreeList()) * (cm_data.buf_blockSize / 1024);
memcpy(ioctlp->outDatap, &parms, sizeof(parms));
ioctlp->outDatap += sizeof(parms);
}
lock_ObtainRead(&cm_cellLock);
- for (tcellp = cm_allCellsp; tcellp; tcellp = tcellp->nextp) {
+ for (tcellp = cm_data.allCellsp; tcellp; tcellp = tcellp->nextp) {
if (whichCell == 0) break;
whichCell--;
}
}
lock_ReleaseRead(&cm_serverLock);
cp = basep + max * sizeof(afs_int32);
- StringCbCopyA(cp, 999999, tcellp->namep);
- cp += strlen(tcellp->namep)+1;
+ StringCbCopyA(cp, 999999, tcellp->name);
+ cp += strlen(tcellp->name)+1;
ioctlp->outDatap = cp;
}
long cm_IoctlNewCell(struct smb_ioctl *ioctlp, struct cm_user *userp)
{
- /* NT cache manager will read cell information from afsdcell.ini each time
+ /* NT cache manager will read cell information from CellServDB 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
cm_SkipIoctlPath(ioctlp);
lock_ObtainWrite(&cm_cellLock);
- for (cp = cm_allCellsp; cp; cp=cp->nextp)
+ for (cp = cm_data.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);
+ code = cm_SearchCellFile(cp->name, cp->name, 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);
+ code = cm_SearchCellByDNS(cp->name, cp->name, &ttl, cm_AddCellProc, cp);
if ( code == 0 ) { /* got cell from DNS */
cp->flags |= CM_CELLFLAG_DNS;
cp->flags &= ~CM_CELLFLAG_VLSERVER_INVALID;
long cm_IoctlGetWsCell(smb_ioctl_t *ioctlp, cm_user_t *userp)
{
- /* if we don't know our default cell, return failure */
- if (cm_rootCellp == NULL) {
- return CM_ERROR_NOSUCHCELL;
+ long code = 0;
+
+ if (cm_freelanceEnabled) {
+ StringCbCopyA(ioctlp->outDatap, 999999, "Freelance.Local.Root");
+ ioctlp->outDatap += strlen(ioctlp->outDatap) +1;
+ } else if (cm_data.rootCellp) {
+ /* return the default cellname to the caller */
+ StringCbCopyA(ioctlp->outDatap, 999999, cm_data.rootCellp->name);
+ ioctlp->outDatap += strlen(ioctlp->outDatap) +1;
+ } else {
+ /* if we don't know our default cell, return failure */
+ code = CM_ERROR_NOSUCHCELL;
}
- /* return the default cellname to the caller */
- StringCbCopyA(ioctlp->outDatap, 999999, cm_rootCellp->namep);
- ioctlp->outDatap += strlen(ioctlp->outDatap) +1;
-
- /* done: success */
- return 0;
+ return code;
}
long cm_IoctlSysName(struct smb_ioctl *ioctlp, struct cm_user *userp)
{
tsp->ipRank = rank; /* no need to protect by mutex*/
- if ( type == CM_SERVER_FILE) /* fileserver */
- {
+ if (type == CM_SERVER_FILE)
+ { /* fileserver */
/* find volumes which might have RO copy
/* on server and change the ordering of
- ** their RO list */
- cm_ChangeRankVolume(tsp);
+ * their RO list
+ */
+ cm_ChangeRankVolume(tsp);
}
else
{
}
#ifdef AFS_FREELANCE_CLIENT
- if (cm_freelanceEnabled && dscp == cm_rootSCachep) {
+ if (cm_freelanceEnabled && dscp == cm_data.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");
cp = ioctlp->inDatap; /* contents of link */
#ifdef AFS_FREELANCE_CLIENT
- if (cm_freelanceEnabled && dscp == cm_rootSCachep) {
+ if (cm_freelanceEnabled && dscp == cm_data.rootSCachep) {
/* we are adding the symlink to the root dir., so call
* the freelance code to do the add. */
if (cp[0] == cp[1] && cp[1] == '\\' &&
return code;
}
-extern long cm_AssembleLink(cm_scache_t *linkScp, char *pathSuffixp,
- cm_scache_t **newRootScpp, cm_space_t **newSpaceBufferp,
- cm_user_t *userp, cm_req_t *reqp);
long cm_IoctlListlink(struct smb_ioctl *ioctlp, struct cm_user *userp)
{
if (code) return code;
/* Check that it's a real symlink */
- if (scp->fileType != CM_SCACHETYPE_SYMLINK){
+ if (scp->fileType != CM_SCACHETYPE_SYMLINK &&
+ scp->fileType != CM_SCACHETYPE_DFSLINK &&
+ scp->fileType != CM_SCACHETYPE_INVALID) {
cm_ReleaseSCache(scp);
return CM_ERROR_INVAL;
}
cm_FreeSpace(spacep);
if (newRootScp != NULL)
cm_ReleaseSCache(newRootScp);
- }
+ code = 0;
+ } else if (code == CM_ERROR_PATH_NOT_COVERED &&
+ scp->fileType == CM_SCACHETYPE_DFSLINK ||
+ code == CM_ERROR_NOSUCHPATH &&
+ scp->fileType == CM_SCACHETYPE_INVALID) {
+ cp = ioctlp->outDatap;
+ StringCbCopyA(cp, 999999, spacep->data);
+ cp += strlen(cp) + 1;
+ ioctlp->outDatap = cp;
+ cm_FreeSpace(spacep);
+ if (newRootScp != NULL)
+ cm_ReleaseSCache(newRootScp);
+ code = 0;
+ }
return code;
}
if (code) return code;
/* Check that it's a real symlink */
- if (scp->fileType != CM_SCACHETYPE_SYMLINK)
+ if (scp->fileType != CM_SCACHETYPE_SYMLINK &&
+ scp->fileType != CM_SCACHETYPE_DFSLINK &&
+ scp->fileType != CM_SCACHETYPE_INVALID)
code = CM_ERROR_INVAL;
cm_ReleaseSCache(scp);
return code;
cp = ioctlp->inDatap;
#ifdef AFS_FREELANCE_CLIENT
- if (cm_freelanceEnabled && dscp == cm_rootSCachep) {
+ if (cm_freelanceEnabled && dscp == cm_data.rootSCachep) {
/* we are adding the mount point to the root dir., so call
* the freelance code to do the add. */
osi_Log0(afsd_logp,"IoctlDeletelink from Freelance root dir");
}
/* now check that this is a real symlink */
- if (scp->fileType != CM_SCACHETYPE_SYMLINK) {
+ if (scp->fileType != CM_SCACHETYPE_SYMLINK &&
+ scp->fileType != CM_SCACHETYPE_DFSLINK &&
+ scp->fileType != CM_SCACHETYPE_INVALID) {
lock_ReleaseMutex(&scp->mx);
cm_ReleaseSCache(scp);
code = CM_ERROR_INVAL;
uname = tp;
tp += strlen(tp) + 1;
- if (flags & PIOCTL_LOGON) {
+#ifndef AFSIFS /* no SMB username */
+ 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_Log1(smb_logp,"cm_IoctlSetToken for user [%s]",
osi_LogSaveString(smb_logp,uname));
}
+#endif
#ifndef DJGPP /* for win95, session key is back in pioctl */
/* uuid */
return CM_ERROR_INVAL;
#endif /* !DJGPP */
} else {
- cellp = cm_rootCellp;
+ cellp = cm_data.rootCellp;
osi_Log0(smb_logp,"cm_IoctlSetToken - no name specified");
}
cp += sizeof(temp);
/* cell name */
- StringCbCopyA(cp, 999999, ucellp->cellp->namep);
+ StringCbCopyA(cp, 999999, ucellp->cellp->name);
cp += strlen(cp) + 1;
/* user name */
/* cell name is right here */
cellp = cm_GetCell(tp, 0);
- if (!cellp) return CM_ERROR_NOSUCHCELL;
+ if (!cellp)
+ return CM_ERROR_NOSUCHCELL;
tp += strlen(tp) + 1;
#ifndef DJGPP
cp += sizeof(temp);
/* cell name */
- StringCbCopyA(cp, 999999, ucellp->cellp->namep);
+ StringCbCopyA(cp, 999999, ucellp->cellp->name);
cp += strlen(cp) + 1;
/* user name */
*/
RegCreateKeyEx( HKEY_LOCAL_MACHINE,
- "SOFTWARE\\OpenAFS\\Client\\Submounts",
+ AFSREG_CLT_OPENAFS_SUBKEY "\\Submounts",
0,
"AFS",
REG_OPTION_NON_VOLATILE,
* 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);
+extern int cm_DumpSCache(FILE *outputFile, char *cookie, int lock);
+extern int cm_DumpBufHashTable(FILE *outputFile, char *cookie, int lock);
+extern int smb_DumpVCP(FILE *outputFile, char *cookie, int lock);
long cm_IoctlMemoryDump(struct smb_ioctl *ioctlp, struct cm_user *userp)
{
HANDLE hLogFile;
char logfileName[MAX_PATH+1];
char *cookie;
+ DWORD dwSize;
#ifdef _DEBUG
static _CrtMemState memstate;
cm_SkipIoctlPath(ioctlp);
memcpy(&inValue, ioctlp->inDatap, sizeof(long));
- if (getenv("TEMP"))
- {
- strncpy(logfileName, getenv("TEMP"), MAX_PATH);
- logfileName[MAX_PATH] = '\0';
- }
- else
+ dwSize = GetEnvironmentVariable("TEMP", logfileName, sizeof(logfileName));
+ if ( dwSize == 0 || dwSize > sizeof(logfileName) )
{
GetWindowsDirectory(logfileName, sizeof(logfileName));
}
#endif
/* dump all interesting data */
- cm_DumpSCache(hLogFile, cookie);
- cm_DumpBufHashTable(hLogFile, cookie);
- smb_DumpVCP(hLogFile, cookie);
+ cm_DumpSCache(hLogFile, cookie, 1);
+ cm_DumpBufHashTable(hLogFile, cookie, 1);
+ smb_DumpVCP(hLogFile, cookie, 1);
CloseHandle(hLogFile);