HANDLE hAFSDWorkerThread[WORKER_THREADS];
#endif
-/* for the IFS version, set the event DoTerminate, on which all
- worker threads wait. they will exit, and then everything else
- can uninitialize. */
-HANDLE WaitToTerminate, DoTerminate;
+HANDLE WaitToTerminate;
int GlobalStatus;
DebugBreak();
#endif
-#ifndef AFSIFS
SetEvent(WaitToTerminate);
-#else
- SetEvent(DoTerminate);
+#ifdef AFSIFS
WaitForMultipleObjects(WORKER_THREADS, hAFSDWorkerThread, TRUE, INFINITE);
for (i = 0; i < WORKER_THREADS; i++)
CloseHandle(hAFSDWorkerThread[i]);
}
doneTrace:
-#ifndef AFSIFS
SetEvent(WaitToTerminate);
-#else
- SetEvent(DoTerminate);
-#endif
break;
case SERVICE_CONTROL_INTERROGATE:
}
doneTrace:
-#ifndef AFSIFS
SetEvent(WaitToTerminate);
-#else
- SetEvent(DoTerminate);
-#endif
dwRet = NO_ERROR;
break;
#define MAX_RETRIES 30
static void MountGlobalDrives(void)
{
+#ifndef AFSIFS
char szAfsPath[_MAX_PATH];
+#endif
char szDriveToMapTo[5];
DWORD dwResult;
char szKeyName[256];
static void DismountGlobalDrives()
{
+#ifndef AFSIFS
char szAfsPath[_MAX_PATH];
char szDriveToMapTo[5];
- DWORD dwResult;
- char szKeyName[256];
- HKEY hKey;
- DWORD dwIndex = 0;
DWORD dwDriveSize;
DWORD dwSubMountSize;
char szSubMount[256];
DWORD dwType;
+#endif
+ DWORD dwResult;
+ char szKeyName[256];
+ HKEY hKey;
+ DWORD dwIndex = 0;
sprintf(szKeyName, "%s\\GlobalAutoMapper", AFSREG_CLT_SVC_PARAM_SUBKEY);
if (dwResult != ERROR_SUCCESS)
return;
-#ifndef AFSIFS
+#ifdef AFSIFS
+ /* FIXFIX: implement */
+#else
while (1) {
dwDriveSize = sizeof(szDriveToMapTo);
dwSubMountSize = sizeof(szSubMount);
afsi_log("Disconnect from GlobalAutoMap of %s to %s %s", szDriveToMapTo, szSubMount, dwResult ? "succeeded" : "failed");
}
-#else
- /* FIXFIX: implement */
#endif
RegCloseKey(hKey);
if ( GetLastError() == ERROR_ALREADY_EXISTS )
afsi_log("Event Object Already Exists: %s", TEXT("afsd_service_WaitToTerminate"));
-#ifdef AFSIFS
- DoTerminate = CreateEvent(NULL, TRUE, FALSE, TEXT("afsd_service_DoTerminate"));
- if ( GetLastError() == ERROR_ALREADY_EXISTS )
- afsi_log("Event Object Already Exists: %s", TEXT("afsd_service_DoTerminate"));
-#endif
-
#ifndef NOTSERVICE
hAdvApi32 = LoadLibrary("advapi32.dll");
if (hAdvApi32 == NULL)
printf("Hit <Enter> to terminate OpenAFS Client Service\n");
getchar();
-#ifndef AFSIFS
SetEvent(WaitToTerminate);
-#else
- SetEvent(DoTerminate);
- dc_release_hooks();
+#ifdef AFSIFS
+ dc_release_hooks();
#endif
}
}
CRITICAL_SECTION mapLock, scp_list_lock;
-/* an event set by the controlling program to cause worker threads to terminate */
-extern HANDLE DoTerminate;
-
scp_status_t *scp_list_head = NULL;
/****************************/
/* upcalls */
/****************************/
-uc_namei(WCHAR *name, ULONG *fid) /* performs name<->fid mapping, and enters it into table */
+long uc_namei(WCHAR *name, ULONG *fid) /* performs name<->fid mapping, and enters it into table */
{
char *buffer; /* we support semi-infinite path lengths */
long code;
/* this should only be called right after open, so we do not need to stat file.
* we only check the server's restrictions. sharing violations are handled in the
* kernel. the access mode we grant sticks with the file_object until its death. */
-uc_check_access(ULONG fid, ULONG access, ULONG *granted)
+long uc_check_access(ULONG fid, ULONG access, ULONG *granted)
{
ULONG afs_acc, afs_gr;
cm_scache_t *scp;
return 0;
}
-uc_create(WCHAR *name, ULONG attribs, LARGE_INTEGER alloc, ULONG access, ULONG *granted, ULONG *fid)
+long uc_create(WCHAR *name, ULONG attribs, LARGE_INTEGER alloc, ULONG access, ULONG *granted, ULONG *fid)
{
char *buffer; /* we support semi-infinite path lengths */
long code;
/* this does not fill the attribs member completely. additional flags must
be added in the kernel, such as read-only. */
-uc_stat(ULONG fid, ULONG *attribs, LARGE_INTEGER *size, LARGE_INTEGER *creation,
+long uc_stat(ULONG fid, ULONG *attribs, LARGE_INTEGER *size, LARGE_INTEGER *creation,
LARGE_INTEGER *access, LARGE_INTEGER *change, LARGE_INTEGER *written)
{
cm_scache_t *scp;
}
/* set atime, mtime, etc. */
-uc_setinfo(ULONG fid, ULONG attribs, LARGE_INTEGER creation, LARGE_INTEGER access,
+long uc_setinfo(ULONG fid, ULONG attribs, LARGE_INTEGER creation, LARGE_INTEGER access,
LARGE_INTEGER change, LARGE_INTEGER written)
{
return IFSL_GENERIC_FAILURE;
/* FIXFIX: this does not catch all overquota errors, because the file
* is not necessarily written to the server when this returns. */
/* write data to a file */
-uc_write(ULONG fid, LARGE_INTEGER offset, ULONG length, ULONG *written, char *data)
+long uc_write(ULONG fid, LARGE_INTEGER offset, ULONG length, ULONG *written, char *data)
{
ULONG code;
cm_scache_t *scp;
return 0;
}
-uc_rename(ULONG fid, WCHAR *curr, WCHAR *new_dir, WCHAR *new_name, ULONG *new_fid)
+long uc_rename(ULONG fid, WCHAR *curr, WCHAR *new_dir, WCHAR *new_name, ULONG *new_fid)
{
int code;
cm_req_t req;
char *curdir, *curfile, *newdir, *newfile;
cm_scache_t *dscp1, *dscp2, *scp;
char b1[MAX_PATH], b2[MAX_PATH], b3[MAX_PATH];
+ wchar_t b3_w[MAX_PATH];
code = !(scp = ifs_FindScp(fid));
if (!code)
{
strcat(b3, "\\");
strcat(b3, b2);
- // TODO: Must convert b3 to type WCHAR*
- uc_namei(b3, new_fid);
+ mbstowcs(b3_w, b3, MAX_PATH);
+ uc_namei(b3_w, new_fid);
}
else
{
ULONG code;
char buffer[2048];
cm_req_t req;
- cm_scache_t *scp, *child_scp;
+ cm_scache_t *scp;
readdir_context_t context;
LARGE_INTEGER cookie;
return code;
}
-uc_close(ULONG fid)
+long uc_close(ULONG fid)
{
cm_scache_t *scp;
cm_req_t req;
return 0;
}
-uc_unlink(WCHAR *name)
+long uc_unlink(WCHAR *name)
{
char buffer[2048];
long code;
}
-int uc_ioctl_write(ULONG length, char *data, ULONG_PTR *key)
+long uc_ioctl_write(ULONG length, char *data, ULONG_PTR *key)
{
smb_ioctl_t *iop;
return 0;
}
-int uc_ioctl_read(ULONG_PTR key, ULONG *length, char *data)
+long uc_ioctl_read(ULONG_PTR key, ULONG *length, char *data)
{
smb_ioctl_t *iop;
- iop = key;
+ iop = (smb_ioctl_t *)key;
osi_assert(iop);
cm_HoldUser(userp);
while (1)
{
/* just check if the event is already signalled, do not wait */
- if (WaitForSingleObject(DoTerminate, 0) == WAIT_OBJECT_0)
- break;
+ if (WaitForSingleObject(WaitToTerminate, 0) == WAIT_OBJECT_0)
+ break;
/* read request... */
st = ReadFile(pipe, bufIn, TRANSFER_BUF_SIZE, &lenIn, NULL);
cm_scache_t **scpp)
{
long code;
+#ifndef AFSIFS
cm_scache_t *substRootp;
- char * relativePath = ioctlp->inDatap;
-#ifdef AFSIFS
- char * absRoot[MAX_PATH];
- long length;
- wchar_t absRoot_w[MAX_PATH];
- HANDLE rootDir;
#endif
+ char * relativePath = ioctlp->inDatap;
+
osi_Log1(afsd_logp, "cm_ParseIoctlPath %s", osi_LogSaveString(afsd_logp,relativePath));
/* This is usually the file name, but for StatMountPoint it is the path. */
#ifdef AFSIFS
/* we have passed the whole path, including the afs prefix.
- when the pioctl call is made, we perform an ioctl to afsrdr
- and it returns the correct (full) path. therefore, there is
- no drive letter, and the path is absolute. */
+ when the pioctl call is made, we perform an ioctl to afsrdr
+ and it returns the correct (full) path. therefore, there is
+ no drive letter, and the path is absolute. */
code = cm_NameI(cm_data.rootSCachep, relativePath,
CM_FLAG_CASEFOLD | CM_FLAG_FOLLOW,
userp, "", 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 /* AFSIFS */
-
+#else /* AFSIFS */
if (relativePath[0] == relativePath[1] &&
relativePath[1] == '\\' &&
!_strnicmp(cm_NetbiosName,relativePath+2,strlen(cm_NetbiosName)))
if (code)
return code;
}
+#endif /* AFSIFS */
/* # of bytes of path */
code = (long)strlen(ioctlp->inDatap) + 1;
afs_uuid_t uuid;
int flags;
char sessionKey[8];
+#ifndef AFSIFS
char *smbname;
+#endif
int release_userp = 0;
char * wdir = NULL;
uname = tp;
tp += strlen(tp) + 1;
-#ifndef AFSIFS /* no SMB username, so we cannot log based on this */
+#ifndef AFSIFS /* no SMB username, so we cannot logon based on this */
if (flags & PIOCTL_LOGON) {
/* SMB user name with which to associate tokens */
smbname = tp;
tp += strlen(tp) + 1;
} else {
osi_Log1(smb_logp,"cm_IoctlSetToken for user [%s]",
- osi_LogSaveString(smb_logp,uname));
+ osi_LogSaveString(smb_logp, uname));
}
#endif
osi_Log0(smb_logp,"cm_IoctlSetToken - no name specified");
}
+#ifndef AFSIFS
if (flags & PIOCTL_LOGON) {
userp = smb_FindCMUserByName(smbname, ioctlp->fidp->vcp->rname,
SMB_FLAG_CREATE|SMB_FLAG_AFSLOGON);
release_userp = 1;
}
+#endif /* AFSIFS */
/* store the token */
lock_ObtainMutex(&userp->mx);
}
#ifdef AFSIFS
- /* for the IFS version, we bulkstat the dirents because this
- routine is used in place of smb_ReceiveCoreSearchDir. our
- other option is to modify smb_ReceiveCoreSearchDir itself,
- but this seems to be the proper use for cm_ApplyDir. */
+ /* for the IFS version, we bulkstat the dirents because this
+ routine is used in place of smb_ReceiveCoreSearchDir. our
+ other option is to modify smb_ReceiveCoreSearchDir itself,
+ but this seems to be the proper use for cm_ApplyDir. */
lock_ObtainMutex(&scp->mx);
if ((scp->flags & CM_SCACHEFLAG_BULKSTATTING) == 0
&& (scp->bulkStatProgress.QuadPart <= thyper.QuadPart))
#define CM_IOCTLCACHEPARMS 16
typedef struct cm_cacheParms {
- long parms[CM_IOCTLCACHEPARMS];
+ afs_uint64 parms[CM_IOCTLCACHEPARMS];
} cm_cacheParms_t;
/* set cell flags */
return CM_ERROR_TOOBIG;
/* check for no such proc */
- if (fidp->flags & SMB_FID_IOCTL)
- procp = smb_ioctlProcsp[opcode];
- else
- procp = NULL;
-
+ procp = smb_ioctlProcsp[opcode];
if (procp == NULL)
return CM_ERROR_BADOP;
}
StringCbCatN(str, len, IrpSp->FileObject->FileName.Buffer, IrpSp->FileObject->FileName.Length);
- /* request to open heirarchical parent of specified path */
+ /* request to open hierarchical parent of specified path */
/* remove last path component */
if (IrpSp->Flags & SL_OPEN_TARGET_DIRECTORY)
{
{
ULONG size;
rpc_t *rpc;
- ULONG status;
size = sizeof(rpc_t) + 2*RPC_BUF_SIZE;
rpc = malloc(size);
rpc_transact(rpc_t *rpc)
{
- HANDLE hf;
- int ret;
ULONG header_len;
- DWORD err, read = 0;
+ DWORD read = 0;
if (!rpc)
return IFSL_GENERIC_FAILURE;
/* downcall stubs */
#ifndef RPC_KERN
-dc_break_callback(ULONG fid)
+long dc_break_callback(ULONG fid)
{
rpc_t *rpc;
ULONG status;
return status;
}
-dc_release_hooks()
+long dc_release_hooks(void)
{
rpc_t *rpc;
ULONG status;
break;
case RPC_UNLINK:
{
- ULONG fid, unlink;
rpc_unmarshal_wstr(rpc, name);
status = uc_unlink(name);
rpc_marshal_long(rpc, status);
/* maximum number of users, based on SID, that can access AFS at one time */
-#define MAX_AFS_USERS 20
+#define MAX_AFS_USERS 256
/* maximum number of threads that can make simultaneous calls into afsrdr,
because we maintain a credential set for each thread in a single table. */
-#define MAX_CRED_MAPS 32
+#define MAX_CRED_MAPS 64
/* size if outgoing/incoming RPC buffer (for parameters only, not bulk data) */
#define RPC_BUF_SIZE 2048
/* this is based on BUF_FILEHASH, but we were not getting unique hashes */
-#define FID_HASH_FN(fidp) ((((fidp)->vnode + \
- ((fidp)->unique << 13) + ((fidp)->unique >> (32-13)) + \
- (fidp)->volume + \
- (fidp)->cell)))
+#define FID_HASH_FN(fidp) \
+ ((((fidp)->vnode + \
+ ((fidp)->unique << 13) + ((fidp)->unique >> (32-13)) + \
+ (fidp)->volume + \
+ (fidp)->cell)))
/* dirent information */
struct readdir_data
- {
- LARGE_INTEGER cookie;
- long offset;
- LARGE_INTEGER creation, access, write, change, size;
- ULONG attribs, name_length; /* chars */
- CCHAR short_name_length; /* chars */
- WCHAR short_name[14];
- WCHAR name[];
- };
+{
+ LARGE_INTEGER cookie;
+ long offset;
+ LARGE_INTEGER creation, access, write, change, size;
+ ULONG attribs, name_length; /* chars */
+ CCHAR short_name_length; /* chars */
+ WCHAR short_name[14];
+ WCHAR name[];
+};
typedef struct readdir_data readdir_data_t;
#define IFSL_SUCCESS (IFSL_SUCCESS_BASE + 0)
#define IFSL_DOES_NOT_EXIST (IFSL_FAIL_BASE + 1)
-#define IFSL_NOT_IMPLEMENTED (IFSL_FAIL_BASE + 2)
+#define IFSL_NOT_IMPLEMENTED (IFSL_FAIL_BASE + 2)
#define IFSL_END_OF_ENUM (IFSL_SUCCESS_BASE + 3)
#define IFSL_CANNOT_MAKE (IFSL_FAIL_BASE + 4)
#define IFSL_END_OF_FILE (IFSL_SUCCESS_BASE + 5)
#define IFSL_NO_ACCESS (IFSL_FAIL_BASE + 6)
-#define IFSL_BUFFER_TOO_SMALL (IFSL_FAIL_BASE + 7)
-#define IFSL_SHARING_VIOLATION (IFSL_FAIL_BASE + 8)
+#define IFSL_BUFFER_TOO_SMALL (IFSL_FAIL_BASE + 7)
+#define IFSL_SHARING_VIOLATION (IFSL_FAIL_BASE + 8)
#define IFSL_BAD_INPUT (IFSL_FAIL_BASE + 9)
-#define IFSL_GENERIC_FAILURE (IFSL_FAIL_BASE + 10)
+#define IFSL_GENERIC_FAILURE (IFSL_FAIL_BASE + 10)
#define IFSL_OPEN_CREATED (IFSL_SUCCESS_BASE + 11)
#define IFSL_OPEN_EXISTS (IFSL_FAIL_BASE + 12)
#define IFSL_OPEN_OPENED (IFSL_SUCCESS_BASE + 13)
-#define IFSL_OPEN_OVERWRITTEN (IFSL_SUCCESS_BASE + 14)
-#define IFSL_OPEN_SUPERSCEDED (IFSL_SUCCESS_BASE + 15)
+#define IFSL_OPEN_OVERWRITTEN (IFSL_SUCCESS_BASE + 14)
+#define IFSL_OPEN_SUPERSCEDED (IFSL_SUCCESS_BASE + 15)
#define IFSL_BADFILENAME (IFSL_FAIL_BASE + 16)
#define IFSL_READONLY (IFSL_FAIL_BASE + 17)
#define IFSL_IS_A_DIR (IFSL_FAIL_BASE + 18)
-#define IFSL_PATH_DOES_NOT_EXIST (IFSL_FAIL_BASE + 19)
+#define IFSL_PATH_DOES_NOT_EXIST (IFSL_FAIL_BASE + 19)
#define IFSL_IS_A_FILE (IFSL_FAIL_BASE + 20)
#define IFSL_NO_FILE (IFSL_FAIL_BASE + 21)
#define IFSL_NOT_EMPTY (IFSL_FAIL_BASE + 22)
#define IFSL_RPC_TIMEOUT (IFSL_FAIL_BASE + 23)
#define IFSL_OVERQUOTA (IFSL_FAIL_BASE + 24)
-#define IFSL_MEMORY (IFSL_FAIL_BASE + 25)
-#define IFSL_UNSPEC (IFSL_FAIL_BASE + 26)
+#define IFSL_MEMORY (IFSL_FAIL_BASE + 25)
+#define IFSL_UNSPEC (IFSL_FAIL_BASE + 26)
/* ioctl codes */
-#define IOCTL_AFSRDR_IOCTL CTL_CODE(IOCTL_DISK_BASE, 0x007, METHOD_OUT_DIRECT, FILE_ANY_ACCESS)
+#define IOCTL_AFSRDR_IOCTL CTL_CODE(IOCTL_DISK_BASE, 0x007, METHOD_OUT_DIRECT, FILE_ANY_ACCESS)
#define IOCTL_AFSRDR_DOWNCALL CTL_CODE(IOCTL_DISK_BASE, 0x008, METHOD_OUT_DIRECT, FILE_ANY_ACCESS)
#define IOCTL_AFSRDR_GET_PATH CTL_CODE(IOCTL_DISK_BASE, 0x009, METHOD_OUT_DIRECT, FILE_ANY_ACCESS)
if (error) return 0;
return 1;
}
-
+#if defined(_IA64_) || defined(_AMD64_)
+#define KERB5DLL "krb5_64.dll"
+#else
#define KERB5DLL "krb5_32.dll"
+#endif
static BOOL
IsKrb5Available()
{
}
#endif
- if (fh == INVALID_HANDLE_VALUE) {
+ if (fh == INVALID_HANDLE_VALUE) {
int gonext = 0;
gle = GetLastError();
if (!pathp)
return CM_ERROR_NOSUCHPATH;
- //sprintf(tpath, "%c:\\", pathp[0]);
rootDir = CreateFile(pathp, 0, 0, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
if (rootDir == INVALID_HANDLE_VALUE)
return CM_ERROR_NOSUCHPATH;
code = WideCharToMultiByte(CP_UTF8, 0/*WC_NO_BEST_FIT_CHARS*/, wpath, length/sizeof(wchar_t), outPathp, outSize/sizeof(wchar_t), NULL, NULL);
-// strcpy(outPathp, tpath);
return 0;
-#endif
-
+#else
if (pathp[0] != 0 && pathp[1] == ':') {
/* there's a drive letter there */
firstp = pathp + 2;
*p = '\\';
}
return 0;
+#endif
}
long