- diff --git a/daemon/getattr.c b/daemon/getattr.c
 - index 7c5f241..7621dba 100644
 - --- a/daemon/getattr.c
 - +++ b/daemon/getattr.c
 - @@ -59,8 +59,19 @@ int nfs41_cached_getattr(
 - static int parse_getattr(unsigned char *buffer, uint32_t length, nfs41_upcall *upcall)
 - {
 - int status;
 - +#if 1
 - + EASSERT(length > 4);
 - + if (length <= 4) {
 - + status = ERROR_INVALID_PARAMETER;
 - + goto out;
 - + }
 - + EASSERT(upcall->state_ref != NULL);
 - + if (upcall->state_ref == NULL) {
 - + status = ERROR_INVALID_PARAMETER;
 - + goto out;
 - + }
 - +#endif
 - getattr_upcall_args *args = &upcall->args.getattr;
 - -
 - status = safe_read(&buffer, &length, &args->query_class, sizeof(args->query_class));
 - if (status) goto out;
 - status = safe_read(&buffer, &length, &args->buf_len, sizeof(args->buf_len));
 - @@ -80,6 +91,21 @@ static int handle_getattr(void *daemon_context, nfs41_upcall *upcall)
 - nfs41_open_state *state = upcall->state_ref;
 - nfs41_file_info info = { 0 };
 - +#if 1
 - + if (((char *)state->session) == ((char *)0xdddddddddddddddd)) {
 - + eprintf("handle_getattr: Invalid session pointer 0xdddddddddddddddd\n");
 - + status = ERROR_INVALID_PARAMETER;
 - + goto out;
 - + }
 - +
 - + EASSERT(state->file.fh.superblock != NULL);
 - + if (state->file.fh.superblock == NULL) {
 - + /* gisburn: fixme: maybe this should be |ERROR_INTERNAL_ERROR| ? */
 - + status = ERROR_INVALID_PARAMETER;
 - + goto out;
 - + }
 - +#endif
 - +
 - status = nfs41_cached_getattr(state->session, &state->file, &info);
 - if (status) {
 - eprintf("nfs41_cached_getattr() failed with %d\n", status);
 - diff --git a/daemon/nfs41_ops.c b/daemon/nfs41_ops.c
 - index bcca070..f2a4f22 100644
 - --- a/daemon/nfs41_ops.c
 - +++ b/daemon/nfs41_ops.c
 - @@ -400,6 +400,9 @@ int nfs41_open(
 - bool_t already_delegated = delegation->type == OPEN_DELEGATE_READ
 - || delegation->type == OPEN_DELEGATE_WRITE;
 - + EASSERT(parent);
 - + EASSERT(parent->fh.superblock);
 - +
 - /* depending on the claim type, OPEN expects CURRENT_FH set
 - * to either the parent directory, or to the file itself */
 - switch (claim->claim) {
 - diff --git a/daemon/open.c b/daemon/open.c
 - index 4b2a335..487c341 100644
 - --- a/daemon/open.c
 - +++ b/daemon/open.c
 - @@ -99,6 +99,24 @@ static void open_state_free(
 - void nfs41_open_state_ref(
 - IN nfs41_open_state *state)
 - {
 - +#if 1
 - + /*
 - + * gisburn: fixme: sometimes this happens under high parallel
 - + * usage with multiple mounts - but why ?
 - + * 0:038> kp
 - + * Child-SP RetAddr Call Site
 - + * 0000006d`431fde10 00007ff7`32f7d905 nfsd!nfs41_open_state_ref(struct __nfs41_open_state * state = 0x00000000`00000000)+0x31
 - + * 0000006d`431fdf30 00007ff7`32f4d284 nfsd!upcall_parse(unsigned char * buffer = 0x0000006d`431fe180 "???", unsigned int length = 8, struct __nfs41_upcall * upcall = 0x0000006d`431ff1e0)+0x2e5
 - + * 0000006d`431fe0b0 00007ffc`1ca24c7c nfsd!thread_main(void * args = 0x00007ff7`32fb6080)+0x144
 - + * 0000006d`431ffe00 00007ffc`4d4b7344 ucrtbased!thread_start<unsigned int (void * parameter = 0x0000025d`a9c6def0)+0x9c
 - + * 0000006d`431ffe60 00007ffc`4efc26b1 KERNEL32!BaseThreadInitThunk+0x14
 - + * 0000006d`431ffe90 00000000`00000000 ntdll!RtlUserThreadStart+0x21
 - + */
 - + EASSERT(state != NULL);
 - + if (state == NULL)
 - + return;
 - +#endif
 - +
 - const LONG count = InterlockedIncrement(&state->ref_count);
 - dprintf(2, "nfs41_open_state_ref(%s) count %d\n", state->path.path, count);
 - diff --git a/daemon/upcall.c b/daemon/upcall.c
 - index bd13c61..7778429 100644
 - --- a/daemon/upcall.c
 - +++ b/daemon/upcall.c
 - @@ -121,6 +121,7 @@ int upcall_parse(
 - /* parse the operation's arguments */
 - op = g_upcall_op_table[upcall->opcode];
 - if (op && op->parse) {
 - + EASSERT(length > 0);
 - status = op->parse(buffer, length, upcall);
 - if (status) {
 - eprintf("parsing of upcall '%s' failed with %d.\n",
 - diff --git a/dll/nfs41_np.c b/dll/nfs41_np.c
 - index 8b259bb..6d3429f 100644
 - --- a/dll/nfs41_np.c
 - +++ b/dll/nfs41_np.c
 - @@ -28,6 +28,8 @@
 - #include "nfs41_np.h"
 - #include "options.h"
 - +#define DBG 1
 - +
 - #ifdef DBG
 - #define DbgP(_x_) NFS41DbgPrint _x_
 - #else
 - diff --git a/sys/nfs41_build_features.h b/sys/nfs41_build_features.h
 - index 93ee7a9..d43334a 100644
 - --- a/sys/nfs41_build_features.h
 - +++ b/sys/nfs41_build_features.h
 - @@ -32,19 +32,19 @@
 - /*
 - * NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES - return local uid/gid values
 - */
 - -// #define NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES 1
 - +#define NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES 1
 - /*
 - * NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID - give NFS
 - * files which do not map to a local account a SID in the
 - * Unix_User+x/Unix_Group+x range
 - */
 - -// #define NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID 1
 - +#define NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID 1
 - /*
 - * NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN - use Cygwin /usr/bin/getent
 - * as "name service"
 - */
 - -// #define NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN 1
 - +#define NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN 1
 - #endif /* !_NFS41_DRIVER_BUILDFEATURES_ */
 - diff --git a/sys/nfs41_driver.c b/sys/nfs41_driver.c
 - index 526b064..db62b56 100644
 - --- a/sys/nfs41_driver.c
 - +++ b/sys/nfs41_driver.c
 - @@ -54,7 +54,7 @@
 - //#define DEBUG_LOCK
 - //#define DEBUG_MISC
 - #define DEBUG_TIME_BASED_COHERENCY
 - -//#define DEBUG_MOUNT
 - +#define DEBUG_MOUNT
 - //#define DEBUG_VOLUME_QUERY
 - //#define ENABLE_TIMINGS
 - @@ -260,6 +260,40 @@ typedef struct _updowncall_list {
 - } nfs41_updowncall_list;
 - nfs41_updowncall_list upcall, downcall;
 - +
 - +
 - +/* In order to cooperate with other network providers,
 - + * we only claim paths of the format '\\server\nfs4\path' */
 - +DECLARE_CONST_UNICODE_STRING(NfsPrefix, L"\\nfs4");
 - +DECLARE_CONST_UNICODE_STRING(AUTH_SYS_NAME, L"sys");
 - +DECLARE_CONST_UNICODE_STRING(AUTHGSS_KRB5_NAME, L"krb5");
 - +DECLARE_CONST_UNICODE_STRING(AUTHGSS_KRB5I_NAME, L"krb5i");
 - +DECLARE_CONST_UNICODE_STRING(AUTHGSS_KRB5P_NAME, L"krb5p");
 - +DECLARE_CONST_UNICODE_STRING(SLASH, L"\\");
 - +DECLARE_CONST_UNICODE_STRING(EMPTY_STRING, L"");
 - +
 - +#define SERVER_NAME_BUFFER_SIZE 1024
 - +#define MOUNT_CONFIG_RW_SIZE_MIN 1024
 - +#define MOUNT_CONFIG_RW_SIZE_DEFAULT 1048576
 - +#define MOUNT_CONFIG_RW_SIZE_MAX 1048576
 - +#define MAX_SEC_FLAVOR_LEN 12
 - +#define UPCALL_TIMEOUT_DEFAULT 50 /* in seconds */
 - +
 - +typedef struct _NFS41_MOUNT_CONFIG {
 - + DWORD ReadSize;
 - + DWORD WriteSize;
 - + BOOLEAN ReadOnly;
 - + BOOLEAN write_thru;
 - + BOOLEAN nocache;
 - + WCHAR srv_buffer[SERVER_NAME_BUFFER_SIZE];
 - + UNICODE_STRING SrvName; /* hostname, or hostname@port */
 - + WCHAR mntpt_buffer[MAX_PATH];
 - + UNICODE_STRING MntPt;
 - + WCHAR sec_flavor[MAX_SEC_FLAVOR_LEN];
 - + UNICODE_STRING SecFlavor;
 - + DWORD timeout;
 - +} NFS41_MOUNT_CONFIG, *PNFS41_MOUNT_CONFIG;
 - +
 - typedef struct _nfs41_mount_entry {
 - LIST_ENTRY next;
 - LUID login_id;
 - @@ -267,6 +301,7 @@ typedef struct _nfs41_mount_entry {
 - HANDLE gss_session;
 - HANDLE gssi_session;
 - HANDLE gssp_session;
 - + NFS41_MOUNT_CONFIG Config;
 - } nfs41_mount_entry;
 - typedef struct _nfs41_mount_list {
 - @@ -310,37 +345,6 @@ typedef struct _nfs41_mount_list {
 - next))); \
 - ExReleaseFastMutex(&lock);
 - -/* In order to cooperate with other network providers,
 - - * we only claim paths of the format '\\server\nfs4\path' */
 - -DECLARE_CONST_UNICODE_STRING(NfsPrefix, L"\\nfs4");
 - -DECLARE_CONST_UNICODE_STRING(AUTH_SYS_NAME, L"sys");
 - -DECLARE_CONST_UNICODE_STRING(AUTHGSS_KRB5_NAME, L"krb5");
 - -DECLARE_CONST_UNICODE_STRING(AUTHGSS_KRB5I_NAME, L"krb5i");
 - -DECLARE_CONST_UNICODE_STRING(AUTHGSS_KRB5P_NAME, L"krb5p");
 - -DECLARE_CONST_UNICODE_STRING(SLASH, L"\\");
 - -DECLARE_CONST_UNICODE_STRING(EMPTY_STRING, L"");
 - -
 - -#define SERVER_NAME_BUFFER_SIZE 1024
 - -#define MOUNT_CONFIG_RW_SIZE_MIN 1024
 - -#define MOUNT_CONFIG_RW_SIZE_DEFAULT 1048576
 - -#define MOUNT_CONFIG_RW_SIZE_MAX 1048576
 - -#define MAX_SEC_FLAVOR_LEN 12
 - -#define UPCALL_TIMEOUT_DEFAULT 50 /* in seconds */
 - -
 - -typedef struct _NFS41_MOUNT_CONFIG {
 - - DWORD ReadSize;
 - - DWORD WriteSize;
 - - BOOLEAN ReadOnly;
 - - BOOLEAN write_thru;
 - - BOOLEAN nocache;
 - - WCHAR srv_buffer[SERVER_NAME_BUFFER_SIZE];
 - - UNICODE_STRING SrvName; /* hostname, or hostname@port */
 - - WCHAR mntpt_buffer[MAX_PATH];
 - - UNICODE_STRING MntPt;
 - - WCHAR sec_flavor[MAX_SEC_FLAVOR_LEN];
 - - UNICODE_STRING SecFlavor;
 - - DWORD timeout;
 - -} NFS41_MOUNT_CONFIG, *PNFS41_MOUNT_CONFIG;
 - typedef struct _NFS41_NETROOT_EXTENSION {
 - NODE_TYPE_CODE NodeTypeCode;
 - @@ -475,6 +479,14 @@ nfs41_start_driver_state nfs41_start_state = NFS41_START_DRIVER_STARTABLE;
 - NTSTATUS map_readwrite_errors(DWORD status);
 - +
 - +void copy_nfs41_mount_config(NFS41_MOUNT_CONFIG *dest, NFS41_MOUNT_CONFIG *src)
 - +{
 - + RtlCopyMemory(dest, src, sizeof(NFS41_MOUNT_CONFIG));
 - + dest->SrvName.Buffer = dest->srv_buffer;
 - + dest->MntPt.Buffer = dest->mntpt_buffer;
 - +}
 - +
 - void print_debug_header(
 - PRX_CONTEXT RxContext)
 - {
 - @@ -2739,6 +2751,10 @@ NTSTATUS nfs41_MountConfig_ParseOptions(
 - IN ULONG EaLength,
 - IN OUT PNFS41_MOUNT_CONFIG Config)
 - {
 - + DbgP("----> nfs41_MountConfig_ParseOptions(EaBuffer=%p,EaLength=%ld)\n",
 - + (void *)EaBuffer,
 - + (long)EaLength);
 - + DbgP("max_address=%p\n", (void *)(((char *)EaBuffer)+EaLength));
 - NTSTATUS status = STATUS_SUCCESS;
 - PFILE_FULL_EA_INFORMATION Option;
 - LPWSTR Name;
 - @@ -2746,13 +2762,20 @@ NTSTATUS nfs41_MountConfig_ParseOptions(
 - UNICODE_STRING usValue;
 - Option = EaBuffer;
 - while (status == STATUS_SUCCESS) {
 - + DbgP("Option=%p\n", (void *)Option);
 - Name = (LPWSTR)Option->EaName;
 - NameLen = Option->EaNameLength/sizeof(WCHAR);
 - + DbgP("nfs41_MountConfig_ParseOptions: Name='%*S'/NameLen=%d\n",
 - + (int)NameLen, Name, (int)NameLen);
 - +
 - usValue.Length = usValue.MaximumLength = Option->EaValueLength;
 - usValue.Buffer = (PWCH)(Option->EaName +
 - Option->EaNameLength + sizeof(WCHAR));
 - + DbgP("nfs41_MountConfig_ParseOptions: option/usValue='%wZ'/%ld\n",
 - + &usValue, (long)usValue.Length);
 - +
 - if (wcsncmp(L"ro", Name, NameLen) == 0) {
 - status = nfs41_MountConfig_ParseBoolean(Option, &usValue,
 - FALSE, &Config->ReadOnly);
 - @@ -2834,6 +2857,7 @@ NTSTATUS nfs41_MountConfig_ParseOptions(
 - ((PBYTE)Option + Option->NextEntryOffset);
 - }
 - + DbgP("<---- nfs41_MountConfig_ParseOptions, status=%ld\n", (long)status);
 - return status;
 - }
 - @@ -2996,6 +3020,9 @@ NTSTATUS nfs41_CreateVNetRoot(
 - if (pCreateNetRootContext->RxContext->Create.EaLength) {
 - /* Codepath for nfs_mount.exe */
 - + DbgP("Codepath for nfs_mount.exe, %p/%ld\n",
 - + pCreateNetRootContext->RxContext->Create.EaBuffer,
 - + (long)pCreateNetRootContext->RxContext->Create.EaLength);
 - /* parse the extended attributes for mount options */
 - status = nfs41_MountConfig_ParseOptions(
 - @@ -3009,6 +3036,7 @@ NTSTATUS nfs41_CreateVNetRoot(
 - pVNetRootContext->nocache = Config->nocache;
 - } else {
 - /* Codepath for \\server:port\nfs4\path */
 - + DbgP("Codepath for \\\\server:port\\nfs4\\path\n");
 - /* use the SRV_CALL name (without leading \) as the hostname */
 - Config->SrvName.Buffer = pSrvCall->pSrvCallName->Buffer + 1;
 - @@ -3016,16 +3044,73 @@ NTSTATUS nfs41_CreateVNetRoot(
 - pSrvCall->pSrvCallName->Length - sizeof(WCHAR);
 - Config->SrvName.MaximumLength =
 - pSrvCall->pSrvCallName->MaximumLength - sizeof(WCHAR);
 - +#define MNTXXX 1
 - +#ifdef MNTXXX
 - + status = nfs41_GetLUID(&luid);
 - + if (status)
 - + goto out_free;
 - +
 - + PLIST_ENTRY pEntry;
 - +
 - + ExAcquireFastMutex(&pNetRootContext->mountLock);
 - + pEntry = &pNetRootContext->mounts.head;
 - + pEntry = pEntry->Flink;
 - + while (pEntry != NULL) {
 - + existing_mount = (nfs41_mount_entry *)CONTAINING_RECORD(pEntry,
 - + nfs41_mount_entry, next);
 - +
 - + if (RtlEqualLuid(&luid, &existing_mount->login_id)) {
 - + DbgP("MNTXXX: Found a matching LUID entry\n");
 - +
 - + /* found existing mount */
 - + copy_nfs41_mount_config(Config, &existing_mount->Config);
 - +#if 0
 - + RtlCopyMemory(Config->mntpt_buffer, existing_mount->mntpt_buffer, sizeof(Config->mntpt_buffer));
 - + Config->MntPt.Buffer = Config->mntpt_buffer;
 - + Config->MntPt.MaximumLength = MAX_PATH;
 - + Config->MntPt.Length = wcslen(Config->mntpt_buffer)*2;
 - +#endif
 - + DbgP("MNTXXX: Found entry Config->MntPt='%wZ', bytelen=%ld\n",
 - + &Config->MntPt,
 - + (long)Config->MntPt.Length);
 - + status = STATUS_SUCCESS;
 - + break;
 - + }
 - + if (pEntry->Flink == &pNetRootContext->mounts.head)
 - + break;
 - + pEntry = pEntry->Flink;
 - + }
 - + ExReleaseFastMutex(&pNetRootContext->mountLock);
 - +
 - + DbgP("MNTXXX: mark #1\n");
 - +
 - + if (status != STATUS_SUCCESS)
 - + goto out_free;
 - + pVNetRootContext->read_only = Config->ReadOnly;
 - + pVNetRootContext->write_thru = Config->write_thru;
 - + pVNetRootContext->nocache = Config->nocache;
 - +
 - + DbgP("MNTXXX: mark #2\n");
 - + DbgP("Codepath for \\\\server:port\\nfs4\\path: Config->MntPt='%wZ'\n",
 - + &Config->MntPt);
 - +
 - + DbgP("Codepath for \\\\server:port\\nfs4\\path: Config->SrvName='%wZ'\n",
 - + &Config->SrvName);
 - + DbgP("MNTXXX: mark #3\n");
 - +#endif /* MNTXXX */
 - }
 - pVNetRootContext->MountPathLen = Config->MntPt.Length;
 - pVNetRootContext->timeout = Config->timeout;
 - status = map_sec_flavor(&Config->SecFlavor, &pVNetRootContext->sec_flavor);
 - if (status != STATUS_SUCCESS) {
 - + DbgP("map_sec_flavor() failed\n");
 - DbgP("Invalid rpcsec security flavor %wZ\n", &Config->SecFlavor);
 - goto out_free;
 - }
 - +DbgP("MNTXXX: mark #4\n");
 - +
 - status = nfs41_GetLUID(&luid);
 - if (status)
 - goto out_free;
 - @@ -3090,10 +3175,12 @@ NTSTATUS nfs41_CreateVNetRoot(
 - #endif
 - }
 - +DbgP("MNTXXX: mark #5\n");
 - /* send the mount upcall */
 - status = nfs41_mount(Config, pVNetRootContext->sec_flavor,
 - &pVNetRootContext->session, &nfs41d_version,
 - &pVNetRootContext->FsAttrs);
 - +DbgP("status(=%ld) = nfs41_mount()\n", (long)status);
 - if (status != STATUS_SUCCESS) {
 - BOOLEAN MountsEmpty;
 - nfs41_IsListEmpty(pNetRootContext->mountLock,
 - @@ -3127,6 +3214,12 @@ NTSTATUS nfs41_CreateVNetRoot(
 - entry->gssp_session = pVNetRootContext->session; break;
 - }
 - RtlCopyLuid(&entry->login_id, &luid);
 - + copy_nfs41_mount_config(&entry->Config, Config);
 - +#if 0
 - + RtlCopyMemory(entry->mntpt_buffer, Config->mntpt_buffer, sizeof(entry->mntpt_buffer));
 - + entry->mntpt_buffer[Config->MntPt.Length] = L'\0';
 - +#endif
 - + DbgP("NEW MOUNT '%wZ'\n", &entry->Config.MntPt);
 - nfs41_AddEntry(pNetRootContext->mountLock,
 - pNetRootContext->mounts, entry);
 - } else if (!found_matching_flavor) {
 - diff --git a/tests/winlocktest1/winlocktest1.ksh b/tests/winlocktest1/winlocktest1.ksh
 - old mode 100644
 - new mode 100755
 
UNC mount path prototype
Posted by Anonymous on Thu 30th Nov 2023 02:57
raw | new post
view followups (newest first): UNC mount path prototype by Anonymous
modification of post by Anonymous (view diff)
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.
 nrubsig.kpaste.net RSS