pastebin - collaborative debugging tool
rovema.kpaste.net RSS


msnfs41client: Patches for nfs41_np dbg cleanup, SEH debug output and misc, 2024-02-14
Posted by Anonymous on Wed 14th Feb 2024 16:21
raw | new post

  1. From f160bf7fdb378d5aba42682821eba51d86b9232c Mon Sep 17 00:00:00 2001
  2. From: Roland Mainz <roland.mainz@nrubsig.org>
  3. Date: Wed, 14 Feb 2024 14:42:30 +0100
  4. Subject: [PATCH 1/4] nfs41_np: Cleanup debug output for nfs41 network provider
  5.  
  6. Cleanup debug output for nfs41 network provider
  7.  
  8. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  9. ---
  10. dll/nfs41_np.c | 140 +++++++++++++++++++++++++++++--------------------
  11.  1 file changed, 82 insertions(+), 58 deletions(-)
  12.  
  13. diff --git a/dll/nfs41_np.c b/dll/nfs41_np.c
  14. index 1818653..60d6c1d 100644
  15. --- a/dll/nfs41_np.c
  16. +++ b/dll/nfs41_np.c
  17. @@ -3,6 +3,7 @@
  18.   *
  19.   * Olga Kornievskaia <aglo@umich.edu>
  20.   * Casey Bodley <cbodley@umich.edu>
  21. + * Roland Mainz <roland.mainz@nrubsig.org>
  22.   *
  23.   * This library is free software; you can redistribute it and/or modify it
  24.   * under the terms of the GNU Lesser General Public License as published by
  25. @@ -40,24 +41,29 @@
  26.  #else
  27.  #define DbgP(_x_)
  28.  #endif
  29. -#define TRACE_TAG   L"[NFS41_NP]"
  30. -#define WNNC_DRIVER( major, minor ) ( major * 0x00010000 + minor )
  31. +#define TRACE_TAG   L"[NFS41_NP] "
  32. +#define WNNC_DRIVER(major, minor) ((major * 0x00010000) + (minor))
  33.  
  34.  
  35. -ULONG _cdecl NFS41DbgPrint( __in LPTSTR Format, ... )
  36. +ULONG _cdecl NFS41DbgPrint(__in LPTSTR fmt, ...)
  37.  {
  38.      ULONG rc = 0;
  39. -#define szbuffer_SIZE 256
  40. -    TCHAR szbuffer[szbuffer_SIZE];
  41. +#define SZBUFFER_SIZE 1024
  42. +    wchar_t szbuffer[SZBUFFER_SIZE+1];
  43. +    wchar_t *szbp = szbuffer;
  44.  
  45.      va_list marker;
  46. -    va_start( marker, Format );
  47. -    {
  48. -        StringCchVPrintfW( szbuffer, szbuffer_SIZE, Format, marker );
  49. -        szbuffer[szbuffer_SIZE-1] = (TCHAR)0;
  50. -        OutputDebugString( TRACE_TAG );
  51. -        OutputDebugString( szbuffer );
  52. -    }
  53. +    va_start(marker, fmt);
  54. +
  55. +    (void)wcscpy(szbp, TRACE_TAG);
  56. +    szbp += wcslen(szbp);
  57. +
  58. +    StringCchVPrintfW(szbp, SZBUFFER_SIZE-(szbp - szbuffer), fmt, marker);
  59. +    szbuffer[SZBUFFER_SIZE-1] = L'\0';
  60. +
  61. +    OutputDebugString(szbuffer);
  62. +
  63. +    va_end(marker);
  64.  
  65.      return rc;
  66.  }
  67. @@ -201,11 +207,13 @@ static DWORD StoreConnectionInfo(
  68.      INT Index;
  69.      BOOLEAN FreeEntryFound = FALSE;
  70.  
  71. +    DbgP((L"--> StoreConnectionInfo\n"));
  72. +
  73.      status = OpenSharedMemory(&hMutex, &hMemory, &(PVOID)pSharedMemory);
  74.      if (status)
  75.          goto out;
  76.  
  77. -    DbgP((TEXT("StoreConnectionInfo: NextIndex %d, NumResources %d\n"),
  78. +    DbgP((L"StoreConnectionInfo: NextIndex %d, NumResources %d\n",
  79.          pSharedMemory->NextAvailableIndex,
  80.          pSharedMemory->NumberOfResourcesInUse));
  81.  
  82. @@ -257,6 +265,8 @@ static DWORD StoreConnectionInfo(
  83.  out_close:
  84.      CloseSharedMemory(&hMutex, &hMemory, &(PVOID)pSharedMemory);
  85.  out:
  86. +    DbgP((TEXT("<-- StoreConnectionInfo returns %d\n"), (int)status));
  87. +
  88.      return status;
  89.  }
  90.  
  91. @@ -272,8 +282,10 @@ SendTo_NFS41Driver(
  92.      BOOL    rc = FALSE;
  93.      ULONG   Status;
  94.  
  95. +    DbgP((TEXT("--> SendTo_NFS41Driver\n")));
  96. +
  97.      Status = WN_SUCCESS;
  98. -    DbgP((L"[aglo] calling CreateFile\n"));
  99. +    DbgP((L"calling CreateFile\n"));
  100.      DeviceHandle = CreateFile(
  101.          NFS41_USER_DEVICE_NAME,
  102.          GENERIC_READ | GENERIC_WRITE,
  103. @@ -283,11 +295,11 @@ SendTo_NFS41Driver(
  104.          0,
  105.          (HANDLE) NULL );
  106.  
  107. -    DbgP((L"[aglo] after CreateFile Device Handle\n"));
  108. +    DbgP((L"after CreateFile Device Handle\n"));
  109.      if ( INVALID_HANDLE_VALUE != DeviceHandle )
  110.      {
  111.          __try {
  112. -        DbgP((L"[aglo] calling DeviceIoControl\n"));
  113. +        DbgP((L"calling DeviceIoControl\n"));
  114.          rc = DeviceIoControl(
  115.              DeviceHandle,
  116.              IoctlCode,
  117. @@ -300,24 +312,24 @@ SendTo_NFS41Driver(
  118.          } __except(filter(GetExceptionCode())) {
  119.              DbgP((L"#### In except\n"));
  120.          }
  121. -        DbgP((L"[aglo] returned from DeviceIoControl %08lx\n", rc));
  122. +        DbgP((L"returned from DeviceIoControl %08lx\n", rc));
  123.              if ( !rc )
  124.              {
  125. -                DbgP((L"[aglo] SendTo_NFS41Driver: returning error from DeviceIoctl\n"));
  126. +                DbgP((L"SendTo_NFS41Driver: returning error from DeviceIoctl\n"));
  127.                  Status = GetLastError( );
  128.              }
  129.              else
  130.              {
  131. -                DbgP((L"[aglo] SendTo_NFS41Driver: The DeviceIoctl call succeded\n"));
  132. +                DbgP((L"SendTo_NFS41Driver: The DeviceIoctl call succeded\n"));
  133.              }
  134.              CloseHandle(DeviceHandle);
  135.      }
  136.      else
  137.      {
  138.          Status = GetLastError( );
  139. -        DbgP((L"[aglo] SendTo_NFS41Driver: error %08lx opening device \n", Status));
  140. +        DbgP((L"SendTo_NFS41Driver: error %08lx opening device \n", Status));
  141.      }
  142. -    DbgP((L"[aglo] returned from SendTo_NFS41Driver %08lx\n", Status));
  143. +    DbgP((TEXT("<-- SendTo_NFS41Driver returns %d\n"), Status));
  144.      return Status;
  145.  }
  146.  
  147. @@ -327,7 +339,7 @@ NPGetCaps(
  148.  {
  149.     DWORD rc = 0;
  150.  
  151. -    DbgP(( L"[aglo] GetNetCaps %d\n", nIndex ));
  152. +    DbgP(( L"GetNetCaps %d\n", nIndex ));
  153.      switch ( nIndex )
  154.      {
  155.          case WNNC_SPEC_VERSION:
  156. @@ -364,7 +376,7 @@ NPGetCaps(
  157.              rc = 0;
  158.              break;
  159.      }
  160. -    
  161. +
  162.      return rc;
  163.  }
  164.  
  165. @@ -380,7 +392,7 @@ NPLogonNotify(
  166.      __out PWSTR  *lpLogonScript)
  167.  {
  168.      *lpLogonScript = NULL;
  169. -    DbgP(( L"[aglo] NPLogonNotify: returning WN_SUCCESS\n" ));
  170. +    DbgP(( L"NPLogonNotify: returning WN_SUCCESS\n" ));
  171.      return WN_SUCCESS;
  172.  }
  173.  
  174. @@ -394,7 +406,7 @@ NPPasswordChangeNotify (
  175.      LPVOID  StationHandle,
  176.      DWORD   dwChangeInfo )
  177.  {
  178. -    DbgP(( L"[aglo] NPPasswordChangeNotify: WN_NOT_SUPPORTED\n" ));
  179. +    DbgP(( L"NPPasswordChangeNotify: WN_NOT_SUPPORTED\n" ));
  180.      SetLastError( WN_NOT_SUPPORTED );
  181.      return WN_NOT_SUPPORTED;
  182.  }
  183. @@ -426,15 +438,16 @@ NPAddConnection3(
  184.      PWCHAR p;
  185.      DWORD i;
  186.  
  187. -    DbgP(( L"[aglo] NPAddConnection3('%s', '%s')\n",
  188. -        lpNetResource->lpLocalName, lpNetResource->lpRemoteName ));
  189. -    DbgP(( L"[aglo] username = '%s', passwd = '%s'\n", lpUserName, lpPassword));
  190. +    DbgP((L"-->  NPAddConnection3(lpNetResource->lpLocalName='%s', "
  191. +        L"lpNetResource->lpRemoteName='%s', "
  192. +        L"username='%s', passwd='%s')\n",
  193. +        lpNetResource->lpLocalName, lpNetResource->lpRemoteName, lpUserName, lpPassword));
  194.  
  195.      Status = InitializeConnectionInfo(&Connection,
  196.          (PMOUNT_OPTION_BUFFER)lpNetResource->lpComment,
  197.          &ConnectionName);
  198.      if (Status)  {
  199. -        DbgP(( L"InitializeConnectionInfo failed with %d\n", Status ));
  200. +        DbgP((L"InitializeConnectionInfo failed with %d\n", Status));
  201.          goto out;
  202.      }
  203.  
  204. @@ -443,6 +456,8 @@ NPAddConnection3(
  205.      // local name, must start with "X:"
  206.      if (lstrlen(lpNetResource->lpLocalName) < 2 ||
  207.          lpNetResource->lpLocalName[1] != L':') {
  208. +        DbgP((L"lpNetResource->lpLocalName(='%s') is not a device letter\n",
  209. +            lpNetResource->lpLocalName));
  210.          Status = WN_BAD_LOCALNAME;
  211.          goto out;
  212.      }
  213. @@ -512,21 +527,24 @@ NPAddConnection3(
  214.  
  215.  #ifdef NFS41_DRIVER_MOUNT_DOES_NFS4_PREFIX
  216.      if (wcsncmp(&p[i], L"\\nfs4", 5) != 0) {
  217. -        DbgP(( L"[nfs41_np] Connection name '%s' not prefixed with '\\nfs41'\n", &p[i]));
  218. +        DbgP(( L"Connection name '%s' not prefixed with '\\nfs41'\n", &p[i]));
  219.          Status = WN_BAD_NETNAME;
  220.          goto out;
  221.      }
  222.  #endif /* NFS41_DRIVER_MOUNT_DOES_NFS4_PREFIX */
  223.  
  224.      StringCchCatW( ConnectionName, NFS41_SYS_MAX_PATH_LEN, &p[i]);
  225. -    DbgP(( L"[aglo] Full Connect Name: %s\n", ConnectionName ));
  226. -    DbgP(( L"[aglo] Full Connect Name Length: %d %d\n",
  227. +    DbgP(( L"Full Connect Name: '%s'\n", ConnectionName ));
  228. +    DbgP(( L"Full Connect Name Length: %d %d\n",
  229.          (wcslen(ConnectionName) + 1) * sizeof(WCHAR),
  230.          (lstrlen(ConnectionName) + 1) * sizeof(WCHAR)));
  231.  
  232.      if ( QueryDosDevice( LocalName, wszScratch, 128 )
  233.          || GetLastError() != ERROR_FILE_NOT_FOUND) {
  234.          Status = WN_ALREADY_CONNECTED;
  235. +        DbgP((L"QueryDosDevice(LocalName='%s',wszScratch='%s') "
  236. +            L"failed with status=%d",
  237. +            LocalName, wszScratch, (int)GetLastError()));
  238.          goto out;
  239.      }
  240.  
  241. @@ -535,18 +553,20 @@ NPAddConnection3(
  242.      Status = SendTo_NFS41Driver( IOCTL_NFS41_ADDCONN,
  243.          Connection.Buffer, Connection.BufferSize,
  244.          NULL, &CopyBytes );
  245. +    DbgP(( L"SendTo_NFS41Driver() returned %d\n", Status));
  246.      if (Status) {
  247. -        DbgP(( L"[aglo] SendTo_NFS41Driver failed with %d\n", Status));
  248.          goto out;
  249.      }
  250.  
  251. -    DbgP(( L"[aglo] calling DefineDosDevice\n"));
  252. +    DbgP((L"DefineDosDevice(lpNetResource->lpLocalName='%s',ConnectionName='%s')\n", lpNetResource->lpLocalName, ConnectionName));
  253.      if ( !DefineDosDevice( DDD_RAW_TARGET_PATH |
  254.                             DDD_NO_BROADCAST_SYSTEM,
  255.                             lpNetResource->lpLocalName,
  256.                             ConnectionName ) ) {
  257.          Status = GetLastError();
  258. -        DbgP(( L"[aglo] DefineDosDevice failed with %d\n", Status));
  259. +        DbgP(( L"DefineDosDevice(lpNetResource->lpLocalName='%s',"
  260. +            L"ConnectionName='%s') failed with %d\n",
  261. +            lpNetResource->lpLocalName, ConnectionName, Status));
  262.          goto out_delconn;
  263.      }
  264.  
  265. @@ -555,13 +575,13 @@ NPAddConnection3(
  266.      Status = StoreConnectionInfo(LocalName, ConnectionName,
  267.          Connection.Buffer->NameLength, lpNetResource);
  268.      if (Status) {
  269. -        DbgP(( L"[aglo] StoreConnectionInfo failed with %d\n", Status));
  270. +        DbgP(( L"StoreConnectionInfo failed with %d\n", Status));
  271.          goto out_undefine;
  272.      }
  273.  
  274.  out:
  275.      FreeConnectionInfo(&Connection);
  276. -    DbgP(( L"[aglo] NPAddConnection3: status %08X\n", Status));
  277. +    DbgP((TEXT("<-- NPAddConnection3 returns %d\n"), (int)Status));
  278.      return Status;
  279.  out_undefine:
  280.      DefineDosDevice(DDD_REMOVE_DEFINITION | DDD_RAW_TARGET_PATH |
  281. @@ -582,8 +602,8 @@ NPCancelConnection(
  282.      HANDLE  hMutex, hMemory;
  283.      PNFS41NP_SHARED_MEMORY  pSharedMemory;
  284.  
  285. -    DbgP((TEXT("NPCancelConnection\n")));
  286. -    DbgP((TEXT("NPCancelConnection: ConnectionName: %S\n"), lpName));
  287. +    DbgP((TEXT("--> NPCancelConnection(lpName='%s', fForce=%d)\n"),
  288. +        lpName, (int)fForce));
  289.  
  290.      Status = OpenSharedMemory( &hMutex,
  291.                                 &hMemory,
  292. @@ -605,9 +625,9 @@ NPCancelConnection(
  293.  
  294.              if (pNetResource->InUse)
  295.              {
  296. -                if ( ( (wcslen(lpName) + 1) * sizeof(WCHAR) ==
  297. +                if ( ( (wcslen(lpName) + 1) * sizeof(WCHAR) ==
  298.                          pNetResource->LocalNameLength)
  299. -                        && ( !wcscmp(lpName, pNetResource->LocalName) ))
  300. +                        && ( !wcscmp(lpName, pNetResource->LocalName) ))
  301.                  {
  302.                      ULONG CopyBytes;
  303.  
  304. @@ -645,7 +665,7 @@ NPCancelConnection(
  305.                      break;
  306.                  }
  307.  
  308. -                DbgP((TEXT("NPCancelConnection: Name %S EntryName %S\n"),
  309. +                DbgP((TEXT("NPCancelConnection: Name '%s' EntryName '%s'\n"),
  310.                              lpName,pNetResource->LocalName));
  311.                  DbgP((TEXT("NPCancelConnection: Name Length %d Entry Name Length %d\n"),
  312.                             pNetResource->LocalNameLength,pNetResource->LocalName));
  313. @@ -658,6 +678,7 @@ NPCancelConnection(
  314.                            (PVOID)&pSharedMemory);
  315.      }
  316.  
  317. +    DbgP((TEXT("<-- NPCancelConnection returns %d\n"), (int)Status));
  318.      return Status;
  319.  }
  320.  
  321. @@ -672,6 +693,8 @@ NPGetConnection(
  322.      HANDLE  hMutex, hMemory;
  323.      PNFS41NP_SHARED_MEMORY  pSharedMemory;
  324.  
  325. +    DbgP((TEXT("--> NPGetConnection(lpLocalName='%s')\n"), lpLocalName));
  326. +
  327.      Status = OpenSharedMemory( &hMutex,
  328.                                 &hMemory,
  329.                                 (PVOID)&pSharedMemory);
  330. @@ -688,9 +711,9 @@ NPGetConnection(
  331.  
  332.              if (pNetResource->InUse)
  333.              {
  334. -                if ( ( (wcslen(lpLocalName) + 1) * sizeof(WCHAR) ==
  335. +                if ( ( (wcslen(lpLocalName) + 1) * sizeof(WCHAR) ==
  336.                          pNetResource->LocalNameLength)
  337. -                        && ( !wcscmp(lpLocalName, pNetResource->LocalName) ))
  338. +                        && ( !wcscmp(lpLocalName, pNetResource->LocalName) ))
  339.                  {
  340.                      if (*lpBufferSize < pNetResource->RemoteNameLength)
  341.                      {
  342. @@ -713,6 +736,8 @@ NPGetConnection(
  343.          CloseSharedMemory( &hMutex, &hMemory, (PVOID)&pSharedMemory);
  344.      }
  345.  
  346. +    DbgP((TEXT("<-- NPGetConnection returns %d\n"), (int)Status));
  347. +
  348.      return Status;
  349.  }
  350.  
  351. @@ -726,7 +751,8 @@ NPOpenEnum(
  352.  {
  353.      DWORD   Status;
  354.  
  355. -    DbgP((L"[aglo] NPOpenEnum\n"));
  356. +    DbgP((L" --> NPOpenEnum(dwScope=%d, dwType=%d, dwUsage=%d)\n",
  357. +        (int)dwScope, (int)dwType, (int)dwUsage));
  358.  
  359.      *lphEnum = NULL;
  360.  
  361. @@ -755,7 +781,7 @@ NPOpenEnum(
  362.      }
  363.  
  364.  
  365. -    DbgP((L"[aglo] NPOpenEnum returning Status %lx\n",Status));
  366. +    DbgP((L"<-- NPOpenEnum returns %d\n", (int)Status));
  367.  
  368.      return(Status);
  369.  }
  370. @@ -778,16 +804,13 @@ NPEnumResource(
  371.      PNFS41NP_NETRESOURCE pNfsNetResource;
  372.      INT  Index = *(PULONG)hEnum;
  373.  
  374. -
  375. -    DbgP((L"[aglo] NPEnumResource\n"));
  376. -
  377. -    DbgP((L"[aglo] NPEnumResource Count Requested %d\n", *lpcCount));
  378. +    DbgP((L"--> NPEnumResource(*lpcCount=%d)\n", (int)*lpcCount));
  379.  
  380.      pNetResource = (LPNETRESOURCE) lpBuffer;
  381.      SpaceAvailable = *lpBufferSize;
  382.      EntriesCopied = 0;
  383.      StringZone = (PWCHAR) ((PBYTE)lpBuffer + *lpBufferSize);
  384. -    
  385. +
  386.      Status = OpenSharedMemory( &hMutex,
  387.                                 &hMemory,
  388.                                 (PVOID)&pSharedMemory);
  389. @@ -795,7 +818,7 @@ NPEnumResource(
  390.      if ( Status == WN_SUCCESS)
  391.      {
  392.          Status = WN_NO_MORE_ENTRIES;
  393. -        for (Index = *(PULONG)hEnum; EntriesCopied < *lpcCount &&
  394. +        for (Index = *(PULONG)hEnum; EntriesCopied < *lpcCount &&
  395.                  Index < pSharedMemory->NextAvailableIndex; Index++)
  396.          {
  397.              pNfsNetResource = &pSharedMemory->NetResources[Index];
  398. @@ -810,7 +833,7 @@ NPEnumResource(
  399.                  if ( SpaceNeeded > SpaceAvailable )
  400.                  {
  401.                      Status = WN_MORE_DATA;
  402. -                    DbgP((L"[aglo] NPEnumResource More Data Needed - %d\n", SpaceNeeded));
  403. +                    DbgP((L"NPEnumResource More Data Needed - %d\n", SpaceNeeded));
  404.                      *lpBufferSize = SpaceNeeded;
  405.                      break;
  406.                  }
  407. @@ -863,7 +886,7 @@ NPEnumResource(
  408.      *lpcCount = EntriesCopied;
  409.      *(PULONG) hEnum = Index;
  410.  
  411. -    DbgP((L"[aglo] NPEnumResource entries returned: %d\n", EntriesCopied));
  412. +    DbgP((L"<-- NPEnumResource returns: %d\n", (int)EntriesCopied));
  413.  
  414.      return Status;
  415.  }
  416. @@ -872,7 +895,7 @@ DWORD APIENTRY
  417.  NPCloseEnum(
  418.      HANDLE hEnum )
  419.  {
  420. -    DbgP((L"[aglo] NPCloseEnum\n"));
  421. +    DbgP((L"NPCloseEnum\n"));
  422.      HeapFree( GetProcessHeap( ), 0, (PVOID) hEnum );
  423.      return WN_SUCCESS;
  424.  }
  425. @@ -883,7 +906,7 @@ NPGetResourceParent(
  426.      LPVOID  lpBuffer,
  427.      LPDWORD lpBufferSize )
  428.  {
  429. -    DbgP(( L"[aglo] NPGetResourceParent: WN_NOT_SUPPORTED\n" ));
  430. +    DbgP(( L"NPGetResourceParent: WN_NOT_SUPPORTED\n" ));
  431.      return WN_NOT_SUPPORTED;
  432.  }
  433.  
  434. @@ -894,7 +917,7 @@ NPGetResourceInformation(
  435.      __inout LPDWORD lpBufferSize,
  436.      __deref_out LPWSTR *lplpSystem )
  437.  {
  438. -    DbgP(( L"[aglo] NPGetResourceInformation: WN_NOT_SUPPORTED\n" ));
  439. +    DbgP(( L"NPGetResourceInformation: WN_NOT_SUPPORTED\n" ));
  440.      return WN_NOT_SUPPORTED;
  441.  }
  442.  
  443. @@ -905,6 +928,7 @@ NPGetUniversalName(
  444.      LPVOID  lpBuffer,
  445.      LPDWORD lpBufferSize )
  446.  {
  447. -    DbgP(( L"[aglo] NPGetUniversalName: WN_NOT_SUPPORTED\n" ));
  448. +    DbgP(( L"NPGetUniversalName(lpLocalPath='%s', dwInfoLevel=%d): WN_NOT_SUPPORTED\n",
  449. +        lpLocalPath, (int)dwInfoLevel));
  450.      return WN_NOT_SUPPORTED;
  451.  }
  452. --
  453. 2.43.0
  454.  
  455. From 70f8fb445859a67181279be873b4f474c73a4125 Mon Sep 17 00:00:00 2001
  456. From: Roland Mainz <roland.mainz@nrubsig.org>
  457. Date: Wed, 14 Feb 2024 16:30:41 +0100
  458. Subject: [PATCH 2/4] nfs41_np: Workaround for mounting nfs://-URLs with
  459.  repeated slashes
  460.  
  461. Workaround for nfs://-URLs like
  462. "nfs://derfwnb4966_ipv4//////////net_tmpfs2//test2",
  463. which cause the device letter in /cygdrive/ to disappear because
  464. the internal mapping between device letter and path to device
  465. cannot handle repeated backslashes.
  466.  
  467. Reported-by: Martin Wege <martin.l.wege@gmail.com>
  468. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  469. ---
  470. dll/nfs41_np.c | 39 +++++++++++++++++++++++++++++++++------
  471.  1 file changed, 33 insertions(+), 6 deletions(-)
  472.  
  473. diff --git a/dll/nfs41_np.c b/dll/nfs41_np.c
  474. index 60d6c1d..f91f075 100644
  475. --- a/dll/nfs41_np.c
  476. +++ b/dll/nfs41_np.c
  477. @@ -429,7 +429,7 @@ NPAddConnection3(
  478.      __in DWORD          dwFlags)
  479.  {
  480.      DWORD   Status;
  481. -    WCHAR   wszScratch[128];
  482. +    WCHAR   wszScratch[1024];
  483.      WCHAR   LocalName[3];
  484.      DWORD   CopyBytes = 0;
  485.      CONNECTION_INFO Connection;
  486. @@ -525,6 +525,31 @@ NPAddConnection3(
  487.      }
  488.  #endif
  489.  
  490. +#if 1
  491. +    /*
  492. +     * Fold repeated backslash into a single backslash
  493. +     * This is a workaround for nfs://-URLs like
  494. +     * nfs://derfwnb4966_ipv4//////////net_tmpfs2//test2
  495. +     * where multiple slashes somehow prevent Windows
  496. +     * from looking up the path from the device letter
  497. +     * (e.g. device letter does not show up in /cygdrive/).
  498. +     * nfsd_daemon will still see the full path with all backslashes
  499. +     * (e.g. "msg=mount(hostport='derfwnb4966_ipv4@2049',
  500. +     * path='\\\\\\\\\net_tmpfs2\\test2')"
  501. +     */
  502. +    {
  503. +        wchar_t *q, *u;
  504. +        q = u = &p[i];
  505. +
  506. +        while(*q != L'\0') {
  507. +            while((*q == '\\') && (*(q+1) == '\\'))
  508. +                q++;
  509. +            *u++ = *q++;
  510. +        }
  511. +        *u = L'\0';
  512. +    }
  513. +#endif
  514. +
  515.  #ifdef NFS41_DRIVER_MOUNT_DOES_NFS4_PREFIX
  516.      if (wcsncmp(&p[i], L"\\nfs4", 5) != 0) {
  517.          DbgP(( L"Connection name '%s' not prefixed with '\\nfs41'\n", &p[i]));
  518. @@ -539,12 +564,14 @@ NPAddConnection3(
  519.          (wcslen(ConnectionName) + 1) * sizeof(WCHAR),
  520.          (lstrlen(ConnectionName) + 1) * sizeof(WCHAR)));
  521.  
  522. -    if ( QueryDosDevice( LocalName, wszScratch, 128 )
  523. -        || GetLastError() != ERROR_FILE_NOT_FOUND) {
  524. +    wszScratch[0] = L'\0';
  525. +    Status = QueryDosDevice(LocalName, wszScratch, 1024);
  526. +    DbgP((L"QueryDosDevice(lpDeviceName='%s',lpTargetPath='%s') "
  527. +        L"returned %d/GetLastError()=%d\n",
  528. +        LocalName, wszScratch, Status, (int)GetLastError()));
  529. +
  530. +    if (Status || (GetLastError() != ERROR_FILE_NOT_FOUND)) {
  531.          Status = WN_ALREADY_CONNECTED;
  532. -        DbgP((L"QueryDosDevice(LocalName='%s',wszScratch='%s') "
  533. -            L"failed with status=%d",
  534. -            LocalName, wszScratch, (int)GetLastError()));
  535.          goto out;
  536.      }
  537.  
  538. --
  539. 2.43.0
  540.  
  541. From 5c6680585e135ddc67e1b6c360b2d61db9c3dd5d Mon Sep 17 00:00:00 2001
  542. From: Roland Mainz <roland.mainz@nrubsig.org>
  543. Date: Wed, 14 Feb 2024 16:39:10 +0100
  544. Subject: [PATCH 3/4] nfs41_np: Cleanup debug output for nfs41 network provider
  545.  [refix]
  546.  
  547. Remove build warning caused by "nfs41_np: Cleanup debug output
  548. for nfs41 network provider".
  549.  
  550. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  551. ---
  552. dll/nfs41_np.c | 7 +++++++
  553.  1 file changed, 7 insertions(+)
  554.  
  555. diff --git a/dll/nfs41_np.c b/dll/nfs41_np.c
  556. index f91f075..e0367fc 100644
  557. --- a/dll/nfs41_np.c
  558. +++ b/dll/nfs41_np.c
  559. @@ -55,7 +55,14 @@ ULONG _cdecl NFS41DbgPrint(__in LPTSTR fmt, ...)
  560.      va_list marker;
  561.      va_start(marker, fmt);
  562.  
  563. +#pragma warning( push )
  564. +    /*
  565. +     * Disable "'wcscpy': This function or variable may be unsafe",
  566. +     * in this context it is safe to use
  567. +     */
  568. +#pragma warning (disable : 4996)
  569.      (void)wcscpy(szbp, TRACE_TAG);
  570. +#pragma warning( pop )
  571.      szbp += wcslen(szbp);
  572.  
  573.      StringCchVPrintfW(szbp, SZBUFFER_SIZE-(szbp - szbuffer), fmt, marker);
  574. --
  575. 2.43.0
  576.  
  577. From c6b608f91b08d6431c2c8332d61b8344d51c19f2 Mon Sep 17 00:00:00 2001
  578. From: Roland Mainz <roland.mainz@nrubsig.org>
  579. Date: Wed, 14 Feb 2024 17:07:38 +0100
  580. Subject: [PATCH 4/4] daemon: Add exception handler for nfsd worker threads
  581.  
  582. Add exception handler for nfsd worker threads so we can see when
  583. they crash.
  584.  
  585. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  586. ---
  587. daemon/nfs41_daemon.c | 19 +++++++++++++++++--
  588.  1 file changed, 17 insertions(+), 2 deletions(-)
  589.  
  590. diff --git a/daemon/nfs41_daemon.c b/daemon/nfs41_daemon.c
  591. index 49567c6..31241f9 100644
  592. --- a/daemon/nfs41_daemon.c
  593. +++ b/daemon/nfs41_daemon.c
  594. @@ -89,7 +89,7 @@ out:
  595.      return status;
  596.  }
  597.  
  598. -static unsigned int WINAPI thread_main(void *args)
  599. +static unsigned int nfsd_worker_thread_main(void *args)
  600.  {
  601.      nfs41_daemon_globals *nfs41dg = (nfs41_daemon_globals *)args;
  602.      DWORD status = 0;
  603. @@ -164,6 +164,21 @@ write_downcall:
  604.      return GetLastError();
  605.  }
  606.  
  607. +static unsigned int WINAPI nfsd_thread_main(void *args)
  608. +{
  609. +    unsigned int res = 120 /* fixme: semi-random value */;
  610. +
  611. +    __try {
  612. +        res = nfsd_worker_thread_main(args);
  613. +    }
  614. +    __except(EXCEPTION_EXECUTE_HANDLER ) {
  615. +        eprintf("#### FATAL: Worker thread crashed with exception ####\n");
  616. +    }
  617. +
  618. +    return res;
  619. +}
  620. +
  621. +
  622.  #ifndef STANDALONE_NFSD
  623.  VOID ServiceStop()
  624.  {
  625. @@ -595,7 +610,7 @@ VOID ServiceStart(DWORD argc, LPTSTR *argv)
  626.      DPRINTF(1, ("Starting %d worker threads...\n",
  627.          (int)nfs41_dg.num_worker_threads));
  628.      for (i = 0; i < nfs41_dg.num_worker_threads; i++) {
  629. -        tids[i].handle = (HANDLE)_beginthreadex(NULL, 0, thread_main,
  630. +        tids[i].handle = (HANDLE)_beginthreadex(NULL, 0, nfsd_thread_main,
  631.                  &nfs41_dg, 0, &tids[i].tid);
  632.          if (tids[i].handle == INVALID_HANDLE_VALUE) {
  633.              status = GetLastError();
  634. --
  635. 2.43.0

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