- diff --git a/cygwin/devel/msnfs41client.bash b/cygwin/devel/msnfs41client.bash
- index cf4c516..2a74a44 100644
- --- a/cygwin/devel/msnfs41client.bash
- +++ b/cygwin/devel/msnfs41client.bash
- @@ -212,7 +212,7 @@ function nfsclient_rundeamon
- "${nfsd_args[@]:1}"
- )
- "${nfsd_args[@]}"
- - elif false ; then
- + elif true ; then
- #
- # test nfsd_debug.exe with Dr. Memory (version 2.6.0 -- build 0)
- #
- @@ -323,7 +323,7 @@ function nfsclient_system_rundeamon
- )
- "${nfsd_args[@]}"
- - elif false ; then
- + elif true ; then
- #
- # test nfsd_debug.exe with Dr. Memory (version 2.6.0 -- build 0)
- #
- diff --git a/daemon/nfs41_daemon.c b/daemon/nfs41_daemon.c
- index 56a960e..b617334 100644
- --- a/daemon/nfs41_daemon.c
- +++ b/daemon/nfs41_daemon.c
- @@ -134,7 +134,8 @@ static unsigned int nfsd_worker_thread_main(void *args)
- // if we ever need to handle non-cached IO, need to make it dynamic
- unsigned char outbuf[UPCALL_BUF_SIZE], inbuf[UPCALL_BUF_SIZE];
- DWORD inbuf_len = UPCALL_BUF_SIZE, outbuf_len;
- - nfs41_upcall upcall;
- + nfs41_upcall upcall_buf;
- + nfs41_upcall *upcall;
- pipe = CreateFileA(NFS41_USER_DEVICE_NAME_A, GENERIC_READ | GENERIC_WRITE,
- FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING,
- @@ -146,6 +147,13 @@ static unsigned int nfsd_worker_thread_main(void *args)
- }
- while(1) {
- +#define DRMEMORY_INSTRUMENTATION 1
- +#ifdef DRMEMORY_INSTRUMENTATION
- + upcall = malloc(sizeof(nfs41_upcall));
- +#else
- + upcall = &upcall_buf;
- +#endif /* DRMEMORY_INSTRUMENTATION */
- +
- status = DeviceIoControl(pipe, IOCTL_NFS41_READ, NULL, 0,
- outbuf, UPCALL_BUF_SIZE, (LPDWORD)&outbuf_len, NULL);
- if (!status) {
- @@ -153,16 +161,22 @@ static unsigned int nfsd_worker_thread_main(void *args)
- continue;
- }
- - status = upcall_parse(outbuf, (uint32_t)outbuf_len, &upcall);
- +#ifdef DRMEMORY_INSTRUMENTATION
- + unsigned char *outbuf_malloced = malloc(outbuf_len);
- + (void)memcpy(outbuf_malloced, outbuf, outbuf_len);
- + status = upcall_parse(outbuf_malloced, (uint32_t)outbuf_len, upcall);
- +#else
- + status = upcall_parse(outbuf, (uint32_t)outbuf_len, upcall);
- +#endif /* DRMEMORY_INSTRUMENTATION */
- if (status) {
- - upcall.status = status;
- + upcall->status = status;
- goto write_downcall;
- }
- if (!OpenThreadToken(GetCurrentThread(),
- TOKEN_QUERY/*|TOKEN_IMPERSONATE*/, FALSE,
- - &upcall.currentthread_token)) {
- - upcall.currentthread_token = INVALID_HANDLE_VALUE;
- + &upcall->currentthread_token)) {
- + upcall->currentthread_token = INVALID_HANDLE_VALUE;
- DPRINTF(0, ("nfsd_worker_thread_main: "
- "OpenThreadToken() failed, lasterr=%d.\n",
- (int)GetLastError()));
- @@ -173,45 +187,55 @@ static unsigned int nfsd_worker_thread_main(void *args)
- * Each thread can handle a different user
- */
- status = map_current_user_to_ids(nfs41dg->idmapper,
- - upcall.currentthread_token,
- - &upcall.uid, &upcall.gid);
- + upcall->currentthread_token,
- + &upcall->uid, &upcall->gid);
- if (status) {
- - upcall.status = status;
- + upcall->status = status;
- goto write_downcall;
- }
- - if (upcall.opcode == NFS41_SHUTDOWN) {
- + if (upcall->opcode == NFS41_SHUTDOWN) {
- printf("Shutting down...\n");
- exit(0);
- }
- - status = upcall_handle(&nfs41_dg, &upcall);
- + status = upcall_handle(&nfs41_dg, upcall);
- write_downcall:
- DPRINTF(1, ("writing downcall: xid=%lld opcode='%s' status=%d "
- - "get_last_error=%d\n", upcall.xid, opcode2string(upcall.opcode),
- - upcall.status, upcall.last_error));
- + "get_last_error=%d\n", upcall->xid,
- + opcode2string(upcall->opcode), upcall->status,
- + upcall->last_error));
- - upcall_marshall(&upcall, inbuf, (uint32_t)inbuf_len, (uint32_t*)&outbuf_len);
- + upcall_marshall(upcall, inbuf, (uint32_t)inbuf_len, (uint32_t*)&outbuf_len);
- /*
- * Note: Caller impersonation ends with |IOCTL_NFS41_WRITE| -
- * nfs41_driver.sys |IOCTL_NFS41_WRITE| calls
- * |SeStopImpersonatingClient()|
- */
- - (void)CloseHandle(upcall.currentthread_token);
- - upcall.currentthread_token = INVALID_HANDLE_VALUE;
- + (void)CloseHandle(upcall->currentthread_token);
- + upcall->currentthread_token = INVALID_HANDLE_VALUE;
- DPRINTF(2, ("making a downcall: outbuf_len %ld\n\n", outbuf_len));
- status = DeviceIoControl(pipe, IOCTL_NFS41_WRITE,
- inbuf, inbuf_len, NULL, 0, (LPDWORD)&outbuf_len, NULL);
- if (!status) {
- - eprintf("IOCTL_NFS41_WRITE failed with %d xid=%lld opcode='%s'\n",
- - GetLastError(), upcall.xid, opcode2string(upcall.opcode));
- - upcall_cancel(&upcall);
- - }
- - if (upcall.status != NFSD_VERSION_MISMATCH)
- - upcall_cleanup(&upcall);
- + eprintf("IOCTL_NFS41_WRITE failed "
- + "with %d xid=%lld opcode='%s'\n",
- + GetLastError(), upcall->xid,
- + opcode2string(upcall->opcode));
- + upcall_cancel(upcall);
- + }
- + if (upcall->status != NFSD_VERSION_MISMATCH)
- + upcall_cleanup(upcall);
- +
- +#ifdef DRMEMORY_INSTRUMENTATION
- + free(outbuf_malloced);
- + outbuf_malloced = NULL;
- + free(upcall);
- + upcall = NULL;
- +#endif /* DRMEMORY_INSTRUMENTATION */
- }
- CloseHandle(pipe);
- diff --git a/daemon/setattr.c b/daemon/setattr.c
- index 5540d87..03e9ff1 100644
- --- a/daemon/setattr.c
- +++ b/daemon/setattr.c
- @@ -353,6 +353,13 @@ static int handle_nfs41_set_size(void *daemon_context, setattr_upcall_args *args
- nfs41_open_state *state = args->state;
- int status;
- + EASSERT_MSG(args->buf_len == sizeof(size->QuadPart),
- + ("args->buf_len=%ld\n", (long)args->buf_len));
- +
- + DPRINTF(0,
- + ("handle_nfs41_set_size: args->set_class=%d, new_file=%lld\n",
- + (int)args->set_class, (long long)size->QuadPart));
- +
- /* break read delegations before SETATTR */
- nfs41_delegation_return(state->session, &state->file,
- OPEN_DELEGATE_READ, FALSE);
- diff --git a/sys/nfs41_driver.c b/sys/nfs41_driver.c
- index f35793d..3400cf0 100644
- --- a/sys/nfs41_driver.c
- +++ b/sys/nfs41_driver.c
- @@ -5896,6 +5896,7 @@ NTSTATUS nfs41_SetFileInformation(
- status = STATUS_SUCCESS;
- goto out;
- }
- +// case FileAllocationInformation:
- case FileEndOfFileInformation:
- {
- PFILE_END_OF_FILE_INFORMATION info =
Dr Memory upcall buffers experiment
Posted by Anonymous on Thu 16th May 2024 13:58
raw | new post
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.