- From 454b7c01fd24bea247087c4cf1e270d779efe553 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Tue, 26 Nov 2024 10:56:33 +0100
- Subject: [PATCH 1/6] mount: Listing shares prints %ff for all Japanese
- characters in nfs://-URL
- Listing shares prints %ff for all Japanese characters in nfs://-URL
- Reported-by: Takeshi Nishimura <takeshi.nishimura.linux@gmail.com>
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- mount/enum.c | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
- diff --git a/mount/enum.c b/mount/enum.c
- index df377a8..b31d019 100644
- --- a/mount/enum.c
- +++ b/mount/enum.c
- @@ -122,7 +122,7 @@ void PrintMountLine(
- utf8unc_p += 2;
- for ( ; *utf8unc_p != '\0' ; ) {
- - char uc = *utf8unc_p++;
- + unsigned char uc = *utf8unc_p++;
- if (uc == '/')
- slash_counter++;
- @@ -166,7 +166,7 @@ void PrintMountLine(
- * in this context it is safe to use
- */
- #pragma warning (disable : 4996)
- - (void)sprintf(us, "%%%2.2x", uc);
- + (void)sprintf(us, "%%%2.2x", (int)uc);
- #pragma warning( pop )
- us+=3;
- }
- --
- 2.45.1
- From c51947e5caea5d5fc167193d11aae26135d131b5 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Tue, 26 Nov 2024 11:01:51 +0100
- Subject: [PATCH 2/6] mount: Always encode '+' in nfs://-URLs
- mount: Always encode '+' in nfs://-URLs, because plain '+' characters
- are decoded into a <space>.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- mount/enum.c | 6 ++++--
- 1 file changed, 4 insertions(+), 2 deletions(-)
- diff --git a/mount/enum.c b/mount/enum.c
- index b31d019..2033c9c 100644
- --- a/mount/enum.c
- +++ b/mount/enum.c
- @@ -89,7 +89,9 @@ void PrintMountLine(
- * characters which must be encoded because they have a special meaning:
- * ";", "/", "?", ":", "@", "=" and "&"
- * Only alphanumerics, "$-_.+!*'()," and reserved characters
- - * ("/" for nfs://-URLS) are allowed
- + * ("/" for nfs://-URLS) are allowed.
- + * Note that '+' must always be encoded because urldecoding
- + * turns it into a <space>.
- */
- #define ISVALIDURLCHAR(c) \
- ( \
- @@ -97,7 +99,7 @@ void PrintMountLine(
- ((c) >= 'a' && (c) <= 'z') || \
- ((c) >= 'A' && (c) <= 'Z') || \
- ((c) == '$') || ((c) == '-') || ((c) == '_') || ((c) == '.') || \
- - ((c) == '+') || ((c) == '!') || ((c) == '*') || ((c) == '\'') || \
- + ((c) == '!') || ((c) == '*') || ((c) == '\'') || \
- ((c) == '(') || ((c) == ')') || ((c) == ',') || ((c) == '/') \
- )
- --
- 2.45.1
- From 7be55feda09f6e251c879411cfb4259172e59ffd Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Tue, 26 Nov 2024 11:09:06 +0100
- Subject: [PATCH 3/6] mount: Encode POSIX/bash/ksh93 special characters in
- nfs://-URLs to make them "safe" for shells
- Encode POSIX/bash/ksh93 special characters in nfs://-URLs to make
- them "safe" for shells to use without quotes, e.g. no globbing ('*'),
- no subshell ('(', ')'), no history ('!') characters etc.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- mount/enum.c | 17 +++++++++++++++++
- 1 file changed, 17 insertions(+)
- diff --git a/mount/enum.c b/mount/enum.c
- index 2033c9c..176f135 100644
- --- a/mount/enum.c
- +++ b/mount/enum.c
- @@ -93,6 +93,22 @@ void PrintMountLine(
- * Note that '+' must always be encoded because urldecoding
- * turns it into a <space>.
- */
- +/*
- + * SHELL_SAFE_URLS - urlencode characters which are special words
- + * in POSIX shells, e.g. '!', '(', ')', '*', "'", "$".
- + * Fixme: This should be a command-line option
- + */
- +#define SHELL_SAFE_URLS 1
- +#ifdef SHELL_SAFE_URLS
- +#define ISVALIDURLCHAR(c) \
- + ( \
- + ((c) >= '0' && (c) <= '9') || \
- + ((c) >= 'a' && (c) <= 'z') || \
- + ((c) >= 'A' && (c) <= 'Z') || \
- + ((c) == '-') || ((c) == '_') || ((c) == '.') || \
- + ((c) == '/') \
- + )
- +#else
- #define ISVALIDURLCHAR(c) \
- ( \
- ((c) >= '0' && (c) <= '9') || \
- @@ -102,6 +118,7 @@ void PrintMountLine(
- ((c) == '!') || ((c) == '*') || ((c) == '\'') || \
- ((c) == '(') || ((c) == ')') || ((c) == ',') || ((c) == '/') \
- )
- +#endif /* SHELL_SAFE_URLS */
- unsigned int slash_counter = 0;
- char *utf8unc = wcs2utf8str(cygwin_unc_buffer);
- --
- 2.45.1
- From ef92495d1fae0227dc656dc9c3e2f43f0899825f Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Tue, 26 Nov 2024 12:52:19 +0100
- Subject: [PATCH 4/6] mount: Fix Japanese character output in UNC path field
- Fix Japanese character output in UNC path field
- Reported-by: Takeshi Nishimura <takeshi.nishimura.linux@gmail.com>
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- mount/mount.c | 9 ++++++++-
- 1 file changed, 8 insertions(+), 1 deletion(-)
- diff --git a/mount/mount.c b/mount/mount.c
- index 8c6b008..717f46c 100644
- --- a/mount/mount.c
- +++ b/mount/mount.c
- @@ -31,6 +31,9 @@
- #include <stdlib.h>
- #include <stdbool.h>
- #include <stdio.h>
- +#include <locale.h>
- +#include <io.h>
- +#include <fcntl.h>
- #include "nfs41_build_features.h"
- #include "nfs41_driver.h" /* |NFS41_PROVIDER_NAME_U| */
- @@ -562,8 +565,12 @@ int list_nfs_mounts_main(int argc, wchar_t *argv[])
- int __cdecl wmain(int argc, wchar_t *argv[])
- {
- DWORD result = NO_ERROR;
- -
- int crtsetdbgflags = 0;
- +
- + (void)setlocale(LC_ALL, "");
- + (void)_setmode(_fileno(stdout), _O_WTEXT);
- + (void)_setmode(_fileno(stderr), _O_WTEXT);
- +
- crtsetdbgflags |= _CRTDBG_ALLOC_MEM_DF; /* use debug heap */
- crtsetdbgflags |= _CRTDBG_LEAK_CHECK_DF; /* report leaks on exit */
- crtsetdbgflags |= _CRTDBG_DELAY_FREE_MEM_DF;
- --
- 2.45.1
- From 34eb11090d2d34e15be59520095894d15a7c0304 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Tue, 26 Nov 2024 13:12:49 +0100
- Subject: [PATCH 5/6] daemon,dll,mount: Fix |GetLastError()| handing
- Fix |GetLastError()| handing: Callers should always call |GetLastError()|
- first BEFORE calling debug printf or similar functinos, or
- save the lasterror code and restore it after the debug code.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- daemon/daemon_debug.c | 11 +++++++----
- daemon/nfs41_daemon.c | 5 +++--
- dll/nfs41_np.c | 16 ++++++++++++----
- mount/mount.c | 4 ++--
- 4 files changed, 24 insertions(+), 12 deletions(-)
- diff --git a/daemon/daemon_debug.c b/daemon/daemon_debug.c
- index 15a3855..21b29e6 100644
- --- a/daemon/daemon_debug.c
- +++ b/daemon/daemon_debug.c
- @@ -47,20 +47,23 @@ void open_log_files()
- const char dfile[] = "nfsddbg.log";
- const char efile[] = "nfsderr.log";
- const char mode[] = "w";
- + DWORD lasterr;
- (void)remove(efile);
- (void)remove(dfile);
- elog_file = fopen(efile, mode);
- if (elog_file == NULL) {
- - ReportStatusToSCMgr(SERVICE_STOPPED, GetLastError(), 0);
- - exit (GetLastError());
- + lasterr = GetLastError();
- + ReportStatusToSCMgr(SERVICE_STOPPED, lasterr, 0);
- + exit(lasterr);
- }
- dlog_file = fopen(dfile, mode);
- if (dlog_file == NULL) {
- - ReportStatusToSCMgr(SERVICE_STOPPED, GetLastError(), 0);
- - exit (GetLastError());
- + lasterr = GetLastError();
- + ReportStatusToSCMgr(SERVICE_STOPPED, lasterr, 0);
- + exit(lasterr);
- }
- }
- diff --git a/daemon/nfs41_daemon.c b/daemon/nfs41_daemon.c
- index e9fec3a..d442fd2 100644
- --- a/daemon/nfs41_daemon.c
- +++ b/daemon/nfs41_daemon.c
- @@ -154,8 +154,9 @@ static unsigned int nfsd_worker_thread_main(void *args)
- 0, NULL);
- if (pipe == INVALID_HANDLE_VALUE)
- {
- - eprintf("Unable to open upcall pipe %d\n", GetLastError());
- - return GetLastError();
- + DWORD lasterr = GetLastError();
- + eprintf("Unable to open upcall pipe %d\n", (int)lasterr);
- + return lasterr;
- }
- while(1) {
- diff --git a/dll/nfs41_np.c b/dll/nfs41_np.c
- index 07f2984..5bce2cd 100644
- --- a/dll/nfs41_np.c
- +++ b/dll/nfs41_np.c
- @@ -61,11 +61,14 @@ static DWORD is_unc_path_mounted(__in LPWSTR lpRemoteName);
- ULONG _cdecl NFS41DbgPrint(__in LPTSTR fmt, ...)
- {
- + DWORD saved_lasterr;
- ULONG rc = 0;
- #define SZBUFFER_SIZE 1024
- wchar_t szbuffer[SZBUFFER_SIZE+1];
- wchar_t *szbp = szbuffer;
- + saved_lasterr = GetLastError();
- +
- va_list marker;
- va_start(marker, fmt);
- @@ -81,6 +84,8 @@ ULONG _cdecl NFS41DbgPrint(__in LPTSTR fmt, ...)
- va_end(marker);
- + SetLastError(saved_lasterr);
- +
- return rc;
- }
- @@ -695,13 +700,16 @@ NPAddConnection3(
- }
- }
- else {
- + DWORD lasterr;
- +
- wszScratch[0] = L'\0';
- Status = QueryDosDevice(LocalName, wszScratch, 1024);
- + lasterr = GetLastError();
- DbgP((L"QueryDosDevice(lpDeviceName='%s',lpTargetPath='%s') "
- L"returned %d/GetLastError()=%d\n",
- - LocalName, wszScratch, Status, (int)GetLastError()));
- + LocalName, wszScratch, Status, (int)lasterr));
- - if (Status || (GetLastError() != ERROR_FILE_NOT_FOUND)) {
- + if (Status || (lasterr != ERROR_FILE_NOT_FOUND)) {
- Status = WN_ALREADY_CONNECTED;
- goto out;
- }
- @@ -887,9 +895,9 @@ NPCancelConnection(
- DDD_RAW_TARGET_PATH | DDD_EXACT_MATCH_ON_REMOVE,
- lpName,
- pNetResource->ConnectionName) == FALSE) {
- - DbgP((L"DefineDosDevice error: %d\n",
- - GetLastError()));
- Status = GetLastError();
- + DbgP((L"DefineDosDevice error: %d\n",
- + (int)Status));
- }
- else {
- pNetResource->InUse = FALSE;
- diff --git a/mount/mount.c b/mount/mount.c
- index 717f46c..1ad62a6 100644
- --- a/mount/mount.c
- +++ b/mount/mount.c
- @@ -710,10 +710,10 @@ static DWORD ParseRemoteName(
- */
- premotename_utf8 = wcs2utf8str(premotename);
- if (!premotename_utf8) {
- + result = GetLastError();
- (void)fwprintf(stderr,
- L"wcs2utf8str() failed, lasterr=%d\n.",
- - (int)GetLastError());
- - result = GetLastError();
- + (int)result);
- goto out;
- }
- --
- 2.45.1
- From ec322d3e60a13a050730013c316cec3c53baa6c9 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Tue, 26 Nov 2024 13:58:52 +0100
- Subject: [PATCH 6/6] dll,mount: Explicitly use the |*W()| (widechar) APIs
- instead of the TCHAR ones
- Cleanup: Explicitly use the |*W()| (widechar) APIs instead of the TCHAR ones
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- dll/nfs41_np.c | 34 +++++++++++++++++-----------------
- mount/enum.c | 8 ++++----
- mount/mount.c | 32 ++++++++++++++++----------------
- mount/options.c | 12 ++++++------
- mount/options.h | 9 +++++----
- 5 files changed, 48 insertions(+), 47 deletions(-)
- diff --git a/dll/nfs41_np.c b/dll/nfs41_np.c
- index 5bce2cd..fb25f5c 100644
- --- a/dll/nfs41_np.c
- +++ b/dll/nfs41_np.c
- @@ -59,7 +59,7 @@ const LUID SystemLuid = SYSTEM_LUID;
- static DWORD is_unc_path_mounted(__in LPWSTR lpRemoteName);
- -ULONG _cdecl NFS41DbgPrint(__in LPTSTR fmt, ...)
- +ULONG _cdecl NFS41DbgPrint(__in LPWSTR fmt, ...)
- {
- DWORD saved_lasterr;
- ULONG rc = 0;
- @@ -80,7 +80,7 @@ ULONG _cdecl NFS41DbgPrint(__in LPTSTR fmt, ...)
- fmt, marker);
- szbuffer[SZBUFFER_SIZE-1] = L'\0';
- - OutputDebugString(szbuffer);
- + OutputDebugStringW(szbuffer);
- va_end(marker);
- @@ -326,13 +326,13 @@ static DWORD StoreConnectionInfo(
- (USHORT)(wcslen(lpNetResource->lpRemoteName)+1)*sizeof(WCHAR);
- pNfs41NetResource->ConnectionNameLength = ConnectionNameLength;
- - (void)StringCchCopy(pNfs41NetResource->LocalName,
- + (void)StringCchCopyW(pNfs41NetResource->LocalName,
- pNfs41NetResource->LocalNameLength,
- LocalName);
- - (void)StringCchCopy(pNfs41NetResource->RemoteName,
- + (void)StringCchCopyW(pNfs41NetResource->RemoteName,
- pNfs41NetResource->RemoteNameLength,
- lpNetResource->lpRemoteName);
- - (void)StringCchCopy(pNfs41NetResource->ConnectionName,
- + (void)StringCchCopyW(pNfs41NetResource->ConnectionName,
- pNfs41NetResource->ConnectionNameLength,
- ConnectionName);
- @@ -555,7 +555,7 @@ NPAddConnection3(
- // \device\miniredirector\;<DriveLetter>:\Server\Share
- // local name, must start with "X:"
- - if (lstrlen(lpLocalName) < 2 ||
- + if (wcslen(lpLocalName) < 2 ||
- lpLocalName[1] != L':') {
- DbgP((L"lpLocalName(='%s') "
- "is not a device letter\n",
- @@ -676,7 +676,7 @@ NPAddConnection3(
- DbgP((L"Full Connect Name: '%s'\n", ConnectionName));
- DbgP((L"Full Connect Name Length: %d %d\n",
- (wcslen(ConnectionName) + 1) * sizeof(WCHAR),
- - (lstrlen(ConnectionName) + 1) * sizeof(WCHAR)));
- + (wcslen(ConnectionName) + 1) * sizeof(WCHAR)));
- if (lpNetResource->lpLocalName == NULL) {
- DWORD gc_status;
- @@ -703,9 +703,9 @@ NPAddConnection3(
- DWORD lasterr;
- wszScratch[0] = L'\0';
- - Status = QueryDosDevice(LocalName, wszScratch, 1024);
- + Status = QueryDosDeviceW(LocalName, wszScratch, 1024);
- lasterr = GetLastError();
- - DbgP((L"QueryDosDevice(lpDeviceName='%s',lpTargetPath='%s') "
- + DbgP((L"QueryDosDeviceW(lpDeviceName='%s',lpTargetPath='%s') "
- L"returned %d/GetLastError()=%d\n",
- LocalName, wszScratch, Status, (int)lasterr));
- @@ -726,15 +726,15 @@ NPAddConnection3(
- }
- if (lpNetResource->lpLocalName != NULL) {
- - DbgP((L"DefineDosDevice(lpLocalName='%s', "
- + DbgP((L"DefineDosDeviceW(lpLocalName='%s', "
- L"ConnectionName='%s')\n",
- lpLocalName, ConnectionName));
- - if (!DefineDosDevice(DDD_RAW_TARGET_PATH |
- + if (!DefineDosDeviceW(DDD_RAW_TARGET_PATH |
- DDD_NO_BROADCAST_SYSTEM,
- lpLocalName,
- ConnectionName)) {
- Status = GetLastError();
- - DbgP((L"DefineDosDevice(lpLocalName='%s',"
- + DbgP((L"DefineDosDeviceW(lpLocalName='%s',"
- L"ConnectionName='%s') failed with %d\n",
- lpLocalName, ConnectionName, Status));
- goto out_delconn;
- @@ -756,7 +756,7 @@ out:
- return Status;
- out_undefine:
- if (lpNetResource->lpLocalName != NULL) {
- - (void)DefineDosDevice(DDD_REMOVE_DEFINITION |
- + (void)DefineDosDeviceW(DDD_REMOVE_DEFINITION |
- DDD_RAW_TARGET_PATH |
- DDD_EXACT_MATCH_ON_REMOVE,
- LocalName, ConnectionName);
- @@ -891,12 +891,12 @@ NPCancelConnection(
- break;
- }
- - if (DefineDosDevice(DDD_REMOVE_DEFINITION |
- + if (DefineDosDeviceW(DDD_REMOVE_DEFINITION |
- DDD_RAW_TARGET_PATH | DDD_EXACT_MATCH_ON_REMOVE,
- lpName,
- pNetResource->ConnectionName) == FALSE) {
- Status = GetLastError();
- - DbgP((L"DefineDosDevice error: %d\n",
- + DbgP((L"DefineDosDeviceW error: %d\n",
- (int)Status));
- }
- else {
- @@ -1244,13 +1244,13 @@ NPEnumResource(
- SpaceNeeded -= sizeof(NETRESOURCE);
- StringZone = (PWCHAR)( (PBYTE) StringZone - SpaceNeeded);
- // copy local name
- - (void)StringCchCopy(StringZone,
- + (void)StringCchCopyW(StringZone,
- pNfsNetResource->LocalNameLength,
- pNfsNetResource->LocalName);
- pNetResource->lpLocalName = StringZone;
- StringZone += pNfsNetResource->LocalNameLength/sizeof(WCHAR);
- // copy remote name
- - (void)StringCchCopy(StringZone,
- + (void)StringCchCopyW(StringZone,
- pNfsNetResource->RemoteNameLength,
- pNfsNetResource->RemoteName);
- pNetResource->lpRemoteName = StringZone;
- diff --git a/mount/enum.c b/mount/enum.c
- index 176f135..00f2b34 100644
- --- a/mount/enum.c
- +++ b/mount/enum.c
- @@ -219,21 +219,21 @@ void PrintMountLine(
- #define ENUM_RESOURCE_BUFFER_SIZE (16*1024)
- DWORD EnumMounts(
- - IN LPNETRESOURCE pContainer)
- + IN LPNETRESOURCEW pContainer)
- {
- DWORD result = NO_ERROR;
- - LPNETRESOURCE pResources;
- + LPNETRESOURCEW pResources;
- DWORD i, dwCount, dwTotal = 0;
- DWORD dwBufferSize = ENUM_RESOURCE_BUFFER_SIZE;
- HANDLE hEnum;
- - pResources = (LPNETRESOURCE)GlobalAlloc(0, ENUM_RESOURCE_BUFFER_SIZE);
- + pResources = (LPNETRESOURCEW)GlobalAlloc(0, ENUM_RESOURCE_BUFFER_SIZE);
- if (pResources == NULL) {
- result = WN_OUT_OF_MEMORY;
- goto out;
- }
- - result = WNetOpenEnum(RESOURCE_CONNECTED,
- + result = WNetOpenEnumW(RESOURCE_CONNECTED,
- RESOURCETYPE_DISK, 0, pContainer, &hEnum);
- if (result)
- goto out_free;
- diff --git a/mount/mount.c b/mount/mount.c
- index 1ad62a6..7c8b0db 100644
- --- a/mount/mount.c
- +++ b/mount/mount.c
- @@ -51,7 +51,7 @@
- #define MOUNT_CONFIG_NFS_PORT_DEFAULT 2049
- DWORD EnumMounts(
- - IN LPNETRESOURCE pContainer);
- + IN LPNETRESOURCEW pContainer);
- static DWORD ParseRemoteName(
- IN bool use_nfspubfh,
- @@ -72,7 +72,7 @@ static DWORD DoUnmount(
- IN BOOL bForce);
- static BOOL ParseDriveLetter(
- IN LPWSTR pArg,
- - OUT PTCH pDriveLetter);
- + OUT PWCH pDriveLetter);
- void PrintErrorMessage(
- IN DWORD dwError);
- @@ -687,7 +687,7 @@ static DWORD ParseRemoteName(
- wchar_t srvname[SRVNAME_LEN];
- url_parser_context *uctx = NULL;
- - result = StringCchCopy(premotename, NFS41_SYS_MAX_PATH_LEN, pRemoteName);
- + result = StringCchCopyW(premotename, NFS41_SYS_MAX_PATH_LEN, pRemoteName);
- /*
- * Support nfs://-URLS per RFC 2224 ("NFS URL
- @@ -962,22 +962,22 @@ static DWORD ParseRemoteName(
- goto out;
- }
- - result = StringCchCopy(pConnectionName, cchConnectionLen, L"\\\\");
- + result = StringCchCopyW(pConnectionName, cchConnectionLen, L"\\\\");
- if (FAILED(result))
- goto out;
- - result = StringCbCat(pConnectionName, cchConnectionLen, srvname);
- + result = StringCbCatW(pConnectionName, cchConnectionLen, srvname);
- if (FAILED(result))
- goto out;
- #ifdef NFS41_DRIVER_MOUNT_DOES_NFS4_PREFIX
- - result = StringCbCat(pConnectionName, cchConnectionLen,
- + result = StringCbCatW(pConnectionName, cchConnectionLen,
- (use_nfspubfh?(L"\\pubnfs4"):(L"\\nfs4")));
- if (FAILED(result))
- goto out;
- #endif /* NFS41_DRIVER_MOUNT_DOES_NFS4_PREFIX */
- if (*pEnd)
- - result = StringCchCat(pConnectionName, cchConnectionLen, pEnd);
- + result = StringCchCatW(pConnectionName, cchConnectionLen, pEnd);
- - result = StringCchCopy(pParsedRemoteName, cchConnectionLen, srvname);
- + result = StringCchCopyW(pParsedRemoteName, cchConnectionLen, srvname);
- #ifdef DEBUG_MOUNT
- (void)fwprintf(stderr,
- @@ -1007,7 +1007,7 @@ static DWORD DoMount(
- DWORD result = NO_ERROR;
- wchar_t szExisting[NFS41_SYS_MAX_PATH_LEN];
- DWORD dwLength;
- - NETRESOURCE NetResource;
- + NETRESOURCEW NetResource;
- if (pOptions->Buffer->Length) {
- if (pOptions->Current)
- @@ -1027,7 +1027,7 @@ static DWORD DoMount(
- if (pLocalName) {
- /* fail if the connection already exists */
- dwLength = NFS41_SYS_MAX_PATH_LEN;
- - result = WNetGetConnection(pLocalName, (LPWSTR)szExisting, &dwLength);
- + result = WNetGetConnectionW(pLocalName, (LPWSTR)szExisting, &dwLength);
- if (result == NO_ERROR) {
- result = ERROR_ALREADY_ASSIGNED;
- (void)fwprintf(stderr, L"Mount failed, drive '%s' is "
- @@ -1042,7 +1042,7 @@ static DWORD DoMount(
- DWORD ConnectResult;
- DWORD Flags = 0;
- - (void)memset(&NetResource, 0, sizeof(NETRESOURCE));
- + (void)memset(&NetResource, 0, sizeof(NETRESOURCEW));
- NetResource.dwType = RESOURCETYPE_DISK;
- if (pLocalName) {
- /* drive letter is chosen automatically if lpLocalName == "*" */
- @@ -1062,7 +1062,7 @@ static DWORD DoMount(
- if (bPersistent)
- Flags |= CONNECT_UPDATE_PROFILE;
- - result = WNetUseConnection(NULL,
- + result = WNetUseConnectionW(NULL,
- &NetResource, NULL, NULL, Flags,
- szConnection, &ConnectSize, &ConnectResult);
- @@ -1071,7 +1071,7 @@ static DWORD DoMount(
- pParsedRemoteName, szConnection);
- }
- else {
- - (void)fwprintf(stderr, L"WNetUseConnection('%s', '%s') "
- + (void)fwprintf(stderr, L"WNetUseConnectionW('%s', '%s') "
- L"failed with error code %u.\n",
- pLocalName, pRemoteName, result);
- }
- @@ -1086,7 +1086,7 @@ static DWORD DoUnmount(
- DWORD result;
- /* disconnect the specified local drive */
- - result = WNetCancelConnection2(pLocalName, CONNECT_UPDATE_PROFILE, bForce);
- + result = WNetCancelConnection2W(pLocalName, CONNECT_UPDATE_PROFILE, bForce);
- /* TODO: verify that this connection uses the nfs41 provider -cbodley */
- switch (result)
- {
- @@ -1099,7 +1099,7 @@ static DWORD DoUnmount(
- L"connected.\n", pLocalName);
- break;
- default:
- - (void)fwprintf(stderr, L"WNetCancelConnection2('%s') failed "
- + (void)fwprintf(stderr, L"WNetCancelConnection2W('%s') failed "
- L"with error code %u.\n", pLocalName, result);
- break;
- }
- @@ -1139,7 +1139,7 @@ void PrintErrorMessage(
- IN DWORD dwError)
- {
- LPWSTR lpMsgBuf = NULL;
- - FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
- + FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
- NULL, dwError, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
- (LPWSTR)&lpMsgBuf, 0, NULL);
- (void)fputws(lpMsgBuf, stderr);
- diff --git a/mount/options.c b/mount/options.c
- index 9f20bae..af48428 100644
- --- a/mount/options.c
- +++ b/mount/options.c
- @@ -66,7 +66,7 @@ BOOL FindOptionByName(
- for (;;)
- {
- if ((Current->EaNameLength == NameLength) &&
- - (!wcscmp((LPTSTR)Current->EaName, Name))) {
- + (!wcscmp((LPWSTR)Current->EaName, Name))) {
- *ppOption = Current;
- return TRUE;
- }
- @@ -147,12 +147,12 @@ BOOL InsertOption(
- Current->EaNameLength = NameLen;
- if (NameLen) /* copy attribute name */
- - StringCbCopy((LPTSTR)Current->EaName,
- + StringCbCopyW((LPWSTR)Current->EaName,
- NameLen + sizeof(wchar_t), Name);
- Current->EaValueLength = ValueLen;
- if (ValueLen) /* copy attribute value */
- - StringCbCopy((LPTSTR)(Current->EaName + NameLen + sizeof(wchar_t)),
- + StringCbCopyW((LPWSTR)(Current->EaName + NameLen + sizeof(wchar_t)),
- ValueLen + sizeof(wchar_t), Value);
- Current->Flags = 0;
- @@ -182,8 +182,8 @@ void RecursivePrintEaInformation(
- EA->Flags,
- EA->EaNameLength,
- EA->EaValueLength,
- - (LPTSTR)EA->EaName,
- - (LPTSTR)(EA->EaName + EA->EaNameLength + sizeof(wchar_t)));
- + (LPWSTR)EA->EaName,
- + (LPWSTR)(EA->EaName + EA->EaNameLength + sizeof(wchar_t)));
- if (EA->NextEntryOffset)
- RecursivePrintEaInformation((PFILE_FULL_EA_INFORMATION)
- @@ -194,7 +194,7 @@ static const wchar_t COMMA_T = L',';
- static const wchar_t EQUAL_T = L'=';
- BOOL ParseMountOptions(
- - IN LPTSTR Arg,
- + IN LPWSTR Arg,
- IN OUT PMOUNT_OPTION_LIST Options)
- {
- PTCH pos, comma, equals;
- diff --git a/mount/options.h b/mount/options.h
- index 408a82b..9af2c1c 100644
- --- a/mount/options.h
- +++ b/mount/options.h
- @@ -3,6 +3,7 @@
- *
- * Olga Kornievskaia <aglo@umich.edu>
- * Casey Bodley <cbodley@umich.edu>
- + * Roland Mainz <roland.mainz@nrubsig.org>
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published by
- @@ -76,17 +77,17 @@ void FreeMountOptions(
- IN OUT PMOUNT_OPTION_LIST Options);
- BOOL FindOptionByName(
- - IN LPCTSTR Name,
- + IN LPCWSTR Name,
- IN PMOUNT_OPTION_LIST Options,
- OUT PFILE_FULL_EA_INFORMATION* ppOption);
- BOOL ParseMountOptions(
- - IN LPTSTR Arg,
- + IN LPWSTR Arg,
- IN OUT PMOUNT_OPTION_LIST Options);
- BOOL InsertOption(
- - IN LPCTSTR Name,
- - IN LPCTSTR Value,
- + IN LPCWSTR Name,
- + IN LPCWSTR Value,
- IN OUT PMOUNT_OPTION_LIST Options);
- void RecursivePrintEaInformation(
- --
- 2.45.1
msnfs41client: Patches for mount paths with Japanese characters, nfs_mount nfs://-URL shell-safe encoding, cleanup+misc, 2024-11-26
Posted by Anonymous on Tue 26th Nov 2024 13:26
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.