pastebin - collaborative debugging tool
nrubsig.kpaste.net RSS


prototype preserve mount options
Posted by Anonymous on Tue 4th Jun 2024 17:30
raw | new post

  1. diff --git a/dll/nfs41_np.c b/dll/nfs41_np.c
  2. index dfd7b88..db7fcff 100644
  3. --- a/dll/nfs41_np.c
  4. +++ b/dll/nfs41_np.c
  5. @@ -65,6 +65,12 @@ ULONG _cdecl NFS41DbgPrint(__in LPTSTR fmt, ...)
  6.  #pragma warning( pop )
  7.      szbp += wcslen(szbp);
  8.  
  9. +#if 1
  10. +    StringCchPrintfW(szbp, SZBUFFER_SIZE-(szbp - szbuffer),
  11. +        TEXT("[thr=%04x]"), (int)GetCurrentThreadId());  
  12. +    szbp += wcslen(szbp);
  13. +#endif
  14. +
  15.      StringCchVPrintfW(szbp, SZBUFFER_SIZE-(szbp - szbuffer), fmt, marker);
  16.      szbuffer[SZBUFFER_SIZE-1] = L'\0';
  17.  
  18. @@ -267,7 +273,21 @@ static DWORD StoreConnectionInfo(
  19.          pNfs41NetResource->ConnectionNameLength,
  20.          ConnectionName);
  21.  
  22. +#if 0
  23.      // TODO: copy mount options -cbodley
  24. +#else
  25. +    DbgP((TEXT("lpNetResource->lpComment='%s'\n"), lpNetResource->lpComment));
  26. +    DbgP((TEXT("lpNetResource->lpCommentIsMountOption='%d'\n"), (int)IS_MOUNT_OPTION_BUFFER(lpNetResource->lpComment) ));
  27. +    if (IS_MOUNT_OPTION_BUFFER(lpNetResource->lpComment)) {
  28. +        pNfs41NetResource->mountoptbuff_size = MOUNT_OPTION_BUFFER_SIZE(lpNetResource->lpComment);
  29. +        (void)memcpy(pNfs41NetResource->mountoptbuff, lpNetResource->lpComment, pNfs41NetResource->mountoptbuff_size);
  30. +    }
  31. +    else {
  32. +        pNfs41NetResource->mountoptbuff_size = 0;
  33. +    }
  34. +#endif
  35. +
  36. +    DbgP((TEXT("lpNetResource->lpProvider='%s'\n"), lpNetResource->lpProvider));
  37.  
  38.  out_close:
  39.      CloseSharedMemory(&hMutex, &hMemory, &(PVOID)pSharedMemory);
  40. @@ -726,8 +746,10 @@ NPGetConnection(
  41.  
  42.      HANDLE  hMutex, hMemory;
  43.      PNFS41NP_SHARED_MEMORY  pSharedMemory;
  44. +    size_t lpLocalNameLen = wcslen(lpLocalName);
  45.  
  46. -    DbgP((TEXT("--> NPGetConnection(lpLocalName='%s')\n"), lpLocalName));
  47. +    DbgP((TEXT("--> NPGetConnection(lpLocalName='%s', *lpBufferSize=%ld)\n"),
  48. +        lpLocalName, (long)*lpBufferSize));
  49.  
  50.      Status = OpenSharedMemory( &hMutex,
  51.                                 &hMemory,
  52. @@ -745,7 +767,22 @@ NPGetConnection(
  53.  
  54.              if (pNetResource->InUse)
  55.              {
  56. -                if ( ( (wcslen(lpLocalName) + 1) * sizeof(WCHAR) ==
  57. +                /*
  58. +                 * Fixme: Add |wcsbytelen()| macro
  59. +                 */
  60. +                DbgP((TEXT("Matching %d, "
  61. +                    "pNetResource->(LocalName='%s', LocalNameLength=%ld), "
  62. +                    "pNetResource->(RemoteName='%s', RemoteNameLength=%ld, "
  63. +                    "wcsbytelen(RemoteName)=%ld)"
  64. +                    "\n"),
  65. +                    Index,
  66. +                    pNetResource->LocalName,
  67. +                    (long)pNetResource->LocalNameLength,
  68. +                    pNetResource->RemoteName,
  69. +                    (long)pNetResource->RemoteNameLength,
  70. +                    (long)(wcslen(pNetResource->RemoteName)*sizeof(WCHAR))));
  71. +
  72. +                if ( ( ((lpLocalNameLen+1)*sizeof(WCHAR)) ==
  73.                          pNetResource->LocalNameLength)
  74.                          && (!wcscmp(lpLocalName, pNetResource->LocalName)))
  75.                  {
  76. @@ -769,6 +806,9 @@ NPGetConnection(
  77.  
  78.          CloseSharedMemory( &hMutex, &hMemory, (PVOID)&pSharedMemory);
  79.      }
  80. +    else {
  81. +        DbgP((TEXT("Cannot open shared memory, Status=%d\n"), Status));
  82. +    }
  83.  
  84.      DbgP((TEXT("<-- NPGetConnection returns %d\n"), (int)Status));
  85.  
  86. @@ -864,6 +904,7 @@ NPEnumResource(
  87.                  SpaceNeeded += pNfsNetResource->RemoteNameLength;
  88.                  SpaceNeeded += 5 * sizeof(WCHAR);               // comment
  89.                  SpaceNeeded += sizeof(NFS41_PROVIDER_NAME_U);  // provider name
  90. +                SpaceNeeded += pNfsNetResource->mountoptbuff_size + 1024 /* fixme */;
  91.                  if ( SpaceNeeded > SpaceAvailable )
  92.                  {
  93.                      Status = WN_MORE_DATA;
  94. @@ -895,6 +936,14 @@ NPEnumResource(
  95.                          pNfsNetResource->RemoteName );
  96.                      pNetResource->lpRemoteName = StringZone;
  97.                      StringZone += pNfsNetResource->RemoteNameLength/sizeof(WCHAR);
  98. +#if 1
  99. +                    if (pNfsNetResource->mountoptbuff_size > 0) {
  100. +                        pNetResource->lpComment = StringZone;
  101. +                        memcpy(pNetResource->lpComment, pNfsNetResource->mountoptbuff, pNfsNetResource->mountoptbuff_size);
  102. +                        StringZone+=pNfsNetResource->mountoptbuff_size+1; /* fixme */
  103. +                        DbgP((L"NPEnumResource: lpComment: copied mountoptbuff_size=%ld\n", (long)pNfsNetResource->mountoptbuff_size));
  104. +                    }
  105. +                    else {
  106.                          // copy comment
  107.                          pNetResource->lpComment = StringZone;
  108.                          *StringZone++ = L'A';
  109. @@ -902,6 +951,9 @@ NPEnumResource(
  110.                          *StringZone++ = L'O';
  111.                          *StringZone++ = L'K';
  112.                          *StringZone++ = L'\0';
  113. +                        DbgP((L"NPEnumResource: lpComment: A_OK\n"));
  114. +                    }
  115. +#endif
  116.                      // copy provider name
  117.                      pNetResource->lpProvider = StringZone;
  118.                      StringCbCopyW( StringZone, sizeof(NFS41_PROVIDER_NAME_U), NFS41_PROVIDER_NAME_U );
  119. diff --git a/dll/nfs41_np.h b/dll/nfs41_np.h
  120. index 5f3d77c..3b03e28 100644
  121. --- a/dll/nfs41_np.h
  122. +++ b/dll/nfs41_np.h
  123. @@ -39,6 +39,8 @@ typedef struct __NFS41NP_NETRESOURCE {
  124.      WCHAR   RemoteName[NFS41_SYS_MAX_PATH_LEN];
  125.      WCHAR   ConnectionName[NFS41_SYS_MAX_PATH_LEN];
  126.      WCHAR   Options[NFS41_SYS_MAX_PATH_LEN];
  127. +    char    mountoptbuff[8192];
  128. +    size_t  mountoptbuff_size;
  129.  } NFS41NP_NETRESOURCE, *PNFS41NP_NETRESOURCE;
  130.  
  131.  typedef struct __NFS41NP_SHARED_MEMORY {
  132. diff --git a/dll/options.h b/dll/options.h
  133. index b425458..5ba931b 100644
  134. --- a/dll/options.h
  135. +++ b/dll/options.h
  136. @@ -38,6 +38,11 @@ typedef struct _MOUNT_OPTION_BUFFER {
  137.         BYTE    Buffer[1];
  138.  } MOUNT_OPTION_BUFFER, *PMOUNT_OPTION_BUFFER;
  139.  
  140. +#define IS_MOUNT_OPTION_BUFFER(b) \
  141. +    (((PMOUNT_OPTION_BUFFER)(b))->Secret==MOUNT_OPTION_BUFFER_SECRET)
  142. +#define MOUNT_OPTION_BUFFER_SIZE(b) \
  143. +    (sizeof(MOUNT_OPTION_BUFFER)+((PMOUNT_OPTION_BUFFER)(b))->Length)
  144. +
  145.  /* CONNECTION_BUFFER
  146.   *   The connection information as sent to the driver via
  147.   * IOCTL_NFS41_ADDCONN. The buffer contains the connection name

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.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}




All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at