- From 4ac90a5878be7ed0e90b8ee6fa5a4ce1ddc1e199 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Fri, 12 Jul 2024 11:50:01 +0200
- Subject: [PATCH 01/11] daemon: Add support for |OP_PUTPUBFH|
- encoding/decoding/handling
- Add support for |OP_PUTPUBFH| encoding/decoding/handling.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- daemon/lookup.c | 4 ++++
- daemon/nfs41_compound.c | 12 +++++++-----
- daemon/nfs41_ops.c | 18 ++++++++++++++++--
- daemon/nfs41_ops.h | 6 ++++++
- daemon/nfs41_xdr.c | 29 ++++++++++++++++++++++++++++-
- 5 files changed, 61 insertions(+), 8 deletions(-)
- diff --git a/daemon/lookup.c b/daemon/lookup.c
- index 0cddbde..f747e8a 100644
- --- a/daemon/lookup.c
- +++ b/daemon/lookup.c
- @@ -141,7 +141,11 @@ static int lookup_rpc(
- nfs41_session_sequence(&args->sequence, session, 0);
- if (dir == &res->root) {
- +#ifdef USE_PUBFH
- + compound_add_op(&compound, OP_PUTPUBFH, NULL, &res->putfh);
- +#else
- compound_add_op(&compound, OP_PUTROOTFH, NULL, &res->putfh);
- +#endif
- compound_add_op(&compound, OP_GETFH, NULL, &res->getrootfh);
- compound_add_op(&compound, OP_GETATTR, &args->getrootattr,
- &res->getrootattr);
- diff --git a/daemon/nfs41_compound.c b/daemon/nfs41_compound.c
- index 6aaea45..933ca6d 100644
- --- a/daemon/nfs41_compound.c
- +++ b/daemon/nfs41_compound.c
- @@ -335,6 +335,7 @@ retry:
- case OP_RESTOREFH:
- case OP_LINK:
- case OP_RENAME:
- + case OP_PUTPUBFH:
- case OP_PUTROOTFH:
- case OP_LOOKUP:
- case OP_OPEN:
- @@ -349,11 +350,12 @@ retry:
- * from SECINFO or SECINFO_NO_NAME.
- */
- if (op1 == OP_SEQUENCE &&
- - (argarray[1].op == OP_PUTFH ||
- - argarray[1].op == OP_PUTROOTFH) &&
- - (argarray[2].op == OP_SECINFO_NO_NAME ||
- - argarray[2].op == OP_SECINFO)) {
- - DPRINTF(1, ("SECINFO: BROKEN SERVER\n"));
- + ((argarray[1].op == OP_PUTFH) ||
- + (argarray[1].op == OP_PUTPUBFH) ||
- + (argarray[1].op == OP_PUTROOTFH)) &&
- + ((argarray[2].op == OP_SECINFO_NO_NAME) ||
- + (argarray[2].op == OP_SECINFO))) {
- + eprintf("SECINFO: BROKEN SERVER\n");
- goto out;
- }
- if (!try_recovery)
- diff --git a/daemon/nfs41_ops.c b/daemon/nfs41_ops.c
- index 6aa2ff7..9ab7cef 100644
- --- a/daemon/nfs41_ops.c
- +++ b/daemon/nfs41_ops.c
- @@ -1154,7 +1154,11 @@ int nfs41_getattr(
- putfh_args.file = file;
- putfh_args.in_recovery = 0;
- } else {
- +#ifdef USE_PUBFH
- + compound_add_op(&compound, OP_PUTPUBFH, NULL, &putfh_res);
- +#else
- compound_add_op(&compound, OP_PUTROOTFH, NULL, &putfh_res);
- +#endif
- }
- compound_add_op(&compound, OP_GETATTR, &getattr_args, &getattr_res);
- @@ -1896,8 +1900,13 @@ int nfs41_secinfo(
- compound_add_op(&compound, OP_SEQUENCE, &sequence_args, &sequence_res);
- nfs41_session_sequence(&sequence_args, session, 0);
- - if (file == NULL)
- + if (file == NULL) {
- +#ifdef USE_PUBFH
- + compound_add_op(&compound, OP_PUTPUBFH, NULL, &putfh_res);
- +#else
- compound_add_op(&compound, OP_PUTROOTFH, NULL, &putfh_res);
- +#endif
- + }
- else {
- compound_add_op(&compound, OP_PUTFH, &putfh_args, &putfh_res);
- putfh_args.file = file;
- @@ -1938,8 +1947,13 @@ int nfs41_secinfo_noname(
- compound_add_op(&compound, OP_SEQUENCE, &sequence_args, &sequence_res);
- nfs41_session_sequence(&sequence_args, session, 0);
- - if (file == NULL)
- + if (file == NULL) {
- +#ifdef USE_PUBFH
- + compound_add_op(&compound, OP_PUTPUBFH, NULL, &putfh_res);
- +#else
- compound_add_op(&compound, OP_PUTROOTFH, NULL, &putfh_res);
- +#endif
- + }
- else {
- compound_add_op(&compound, OP_PUTFH, &putfh_args, &putfh_res);
- putfh_args.file = file;
- diff --git a/daemon/nfs41_ops.h b/daemon/nfs41_ops.h
- index 4c8f7d0..230dfa4 100644
- --- a/daemon/nfs41_ops.h
- +++ b/daemon/nfs41_ops.h
- @@ -516,6 +516,12 @@ typedef struct __nfs41_putfh_res {
- } nfs41_putfh_res;
- +/* OP_PUTPUBFH */
- +typedef struct __nfs41_putpubfh_res {
- + uint32_t status;
- +} nfs41_putpubfh_res;
- +
- +
- /* OP_PUTROOTFH */
- typedef struct __nfs41_putrootfh_res {
- uint32_t status;
- diff --git a/daemon/nfs41_xdr.c b/daemon/nfs41_xdr.c
- index 903b2b5..09cc523 100644
- --- a/daemon/nfs41_xdr.c
- +++ b/daemon/nfs41_xdr.c
- @@ -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
- @@ -1102,6 +1103,32 @@ static bool_t decode_op_putfh(
- }
- +/*
- + * OP_PUTPUBFH
- + */
- +static bool_t encode_op_putpubfh(
- + XDR *xdr,
- + nfs_argop4* argop)
- +{
- + if (unexpected_op(argop->op, OP_PUTPUBFH))
- + return FALSE;
- + /* void */
- + return TRUE;
- +}
- +
- +static bool_t decode_op_putpubfh(
- + XDR *xdr,
- + nfs_resop4 *resop)
- +{
- + nfs41_putpubfh_res *res = (nfs41_putpubfh_res*)resop->res;
- +
- + if (unexpected_op(resop->op, OP_PUTPUBFH))
- + return FALSE;
- +
- + return xdr_u_int32_t(xdr, &res->status);
- +}
- +
- +
- /*
- * OP_PUTROOTFH
- */
- @@ -3553,7 +3580,7 @@ static const op_table_entry g_op_table[] = {
- { NULL, NULL }, /* OP_OPEN_CONFIRM = 20 */
- { NULL, NULL }, /* OP_OPEN_DOWNGRADE = 21 */
- { encode_op_putfh, decode_op_putfh }, /* OP_PUTFH = 22 */
- - { NULL, NULL }, /* OP_PUTPUBFH = 23 */
- + { encode_op_putpubfh, decode_op_putpubfh }, /* OP_PUTPUBFH = 23 */
- { encode_op_putrootfh, decode_op_putrootfh }, /* OP_PUTROOTFH = 24 */
- { encode_op_read, decode_op_read }, /* OP_READ = 25 */
- { encode_op_readdir, decode_op_readdir }, /* OP_READDIR = 26 */
- --
- 2.45.1
- From 2c517c6573405993076e82251ac0bdd777e785a3 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Mon, 15 Jul 2024 11:21:39 +0200
- Subject: [PATCH 02/11] cygwin,daemon,dll,mount,sys: Add support for public
- filehandles (PUTPUBFH)
- Add support for public filehandles (PUTPUBFH)
- Example:
- ---- snip ----
- $ nfs_mount -o sec=sys,rw,public '*' nfs://derfwnb4966_ipv4//bigdisk
- Successfully mounted 'derfwnb4966_ipv4@2049' to drive 'Y:'
- $ nfs_mount | grep -F '/pubnfs4/'
- (null) \\derfwnb4966_ipv4@2049\pubnfs4\bigdisk //derfwnb4966_ipv4@2049/pubnfs4/bigdisk nfs://derfwnb4966_ipv4:2049//bigdisk?public=1
- $ cd '//derfwnb4966_ipv4@2049/pubnfs4/bigdisk'
- ---- snip ----
- Reported-by: Dan Shelton <dan.f.shelton@gmail.com>
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- cygwin/README.bintarball.txt | 3 ++
- daemon/lookup.c | 12 +++--
- daemon/mount.c | 27 +++++++----
- daemon/namespace.c | 5 +-
- daemon/nfs41.h | 3 ++
- daemon/nfs41_client.c | 8 ++++
- daemon/nfs41_ops.c | 33 +++++++------
- daemon/upcall.h | 2 +
- dll/nfs41_np.c | 6 ++-
- mount/enum.c | 35 +++++++++++++-
- mount/mount.c | 31 ++++++++++--
- sys/nfs41_driver.c | 92 ++++++++++++++++++++++++++++--------
- 12 files changed, 201 insertions(+), 56 deletions(-)
- diff --git a/cygwin/README.bintarball.txt b/cygwin/README.bintarball.txt
- index edd1c55..1596066 100644
- --- a/cygwin/README.bintarball.txt
- +++ b/cygwin/README.bintarball.txt
- @@ -35,6 +35,9 @@ NFSv4.1 client and filesystem driver for Windows 10/11
- tunnel
- - Support for long paths (up to 4096 bytes), no Windows MAXPATH limit
- +- Support for NFSv4 public mounts (i.e. use the NFSv4 public file handle
- + lookup protocol via $ nfs_mount -o public ... #)
- +
- - Unicode support
- - UNC paths
- diff --git a/daemon/lookup.c b/daemon/lookup.c
- index f747e8a..eebb71e 100644
- --- a/daemon/lookup.c
- +++ b/daemon/lookup.c
- @@ -141,11 +141,13 @@ static int lookup_rpc(
- nfs41_session_sequence(&args->sequence, session, 0);
- if (dir == &res->root) {
- -#ifdef USE_PUBFH
- - compound_add_op(&compound, OP_PUTPUBFH, NULL, &res->putfh);
- -#else
- - compound_add_op(&compound, OP_PUTROOTFH, NULL, &res->putfh);
- -#endif
- + if (session->client->root->use_nfspubfh) {
- + compound_add_op(&compound, OP_PUTPUBFH, NULL, &res->putfh);
- + }
- + else {
- + compound_add_op(&compound, OP_PUTROOTFH, NULL, &res->putfh);
- + }
- +
- compound_add_op(&compound, OP_GETFH, NULL, &res->getrootfh);
- compound_add_op(&compound, OP_GETATTR, &args->getrootattr,
- &res->getrootattr);
- diff --git a/daemon/mount.c b/daemon/mount.c
- index cc9053b..8d756c5 100644
- --- a/daemon/mount.c
- +++ b/daemon/mount.c
- @@ -50,11 +50,13 @@ static int parse_mount(unsigned char *buffer, uint32_t length, nfs41_upcall *upc
- if (status) goto out;
- status = safe_read(&buffer, &length, &args->wsize, sizeof(DWORD));
- if (status) goto out;
- + status = safe_read(&buffer, &length, &args->use_nfspubfh, sizeof(DWORD));
- + if (status) goto out;
- DPRINTF(1, ("parsing NFS41_MOUNT: hostport='%s' root='%s' "
- - "sec_flavor='%s' rsize=%d wsize=%d\n",
- + "sec_flavor='%s' rsize=%d wsize=%d use_nfspubfh=%d\n",
- args->hostport, args->path, secflavorop2name(args->sec_flavor),
- - args->rsize, args->wsize));
- + args->rsize, args->wsize, args->use_nfspubfh));
- return status;
- out:
- DPRINTF(1, ("parsing NFS41_MOUNT: failed %d\n", status));
- @@ -83,9 +85,11 @@ static int handle_mount(void *daemon_context, nfs41_upcall *upcall)
- (void)get_token_authenticationid(upcall->currentthread_token,
- &authenticationid);
- - logprintf("mount(hostport='%s', path='%s', "
- + logprintf("mount(hostport='%s', "
- + "use_nfspubfh=%d, path='%s', "
- "authid=(0x%lx.0x%lx)) request\n",
- args->hostport?args->hostport:"<NULL>",
- + (int)args->use_nfspubfh,
- args->path?args->path:"<NULL>",
- (long)authenticationid.HighPart,
- (long)authenticationid.LowPart);
- @@ -143,7 +147,8 @@ static int handle_mount(void *daemon_context, nfs41_upcall *upcall)
- root = upcall->root_ref;
- } else {
- // create root
- - status = nfs41_root_create(hostname, port, args->sec_flavor,
- + status = nfs41_root_create(hostname, port,
- + args->use_nfspubfh?true:false, args->sec_flavor,
- args->wsize + WRITE_OVERHEAD, args->rsize + READ_OVERHEAD, &root);
- if (status) {
- eprintf("nfs41_root_create(hostname='%s', port=%d) failed %d\n",
- @@ -187,32 +192,38 @@ static int handle_mount(void *daemon_context, nfs41_upcall *upcall)
- out:
- if (status == 0) {
- #ifdef NFS41_DRIVER_USE_AUTHENTICATIONID_FOR_MOUNT_NAMESPACE
- - logprintf("mount(hostport='%s', path='%s', "
- + logprintf("mount(hostport='%s', use_nfspubfh=%d, path='%s', "
- "authid=(0x%lx.0x%lx)) success, root=0x%p\n",
- args->hostport?args->hostport:"<NULL>",
- + (int)args->use_nfspubfh,
- args->path?args->path:"<NULL>",
- (long)authenticationid.HighPart,
- (long)authenticationid.LowPart,
- root);
- #else
- - logprintf("mount(hostport='%s', path='%s') success, root=0x%p\n",
- + logprintf("mount(hostport='%s', use_nfspubfh=%d, path='%s') success, "
- + "root=0x%p\n",
- args->hostport?args->hostport:"<NULL>",
- + (int)args->use_nfspubfh,
- args->path?args->path:"<NULL>",
- root);
- #endif /* NFS41_DRIVER_USE_AUTHENTICATIONID_FOR_MOUNT_NAMESPACE */
- }
- else {
- #ifdef NFS41_DRIVER_USE_AUTHENTICATIONID_FOR_MOUNT_NAMESPACE
- - logprintf("mount(hostport='%s', path='%s', "
- + logprintf("mount(hostport='%s', use_nfspubfh=%d, path='%s', "
- "authid=(0x%lx.0x%lx))) failed, status=%d\n",
- args->hostport?args->hostport:"<NULL>",
- + (int)args->use_nfspubfh,
- args->path?args->path:"<NULL>",
- (long)authenticationid.HighPart,
- (long)authenticationid.LowPart,
- (int)status);
- #else
- - logprintf("mount(hostport='%s', path='%s') failed, status=%d\n",
- + logprintf("mount(hostport='%s', use_nfspubfh=%d, path='%s') "
- + "failed, status=%d\n",
- args->hostport?args->hostport:"<NULL>",
- + (int)args->use_nfspubfh,
- args->path?args->path:"<NULL>",
- (int)status);
- #endif /* NFS41_DRIVER_USE_AUTHENTICATIONID_FOR_MOUNT_NAMESPACE */
- diff --git a/daemon/namespace.c b/daemon/namespace.c
- index e490aad..7391854 100644
- --- a/daemon/namespace.c
- +++ b/daemon/namespace.c
- @@ -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
- @@ -37,6 +38,7 @@
- int nfs41_root_create(
- IN const char *name,
- IN uint32_t port,
- + IN bool use_nfspubfh,
- IN uint32_t sec_flavor,
- IN uint32_t wsize,
- IN uint32_t rsize,
- @@ -54,6 +56,7 @@ int nfs41_root_create(
- }
- list_init(&root->clients);
- + root->use_nfspubfh = use_nfspubfh;
- root->wsize = wsize;
- root->rsize = rsize;
- InitializeCriticalSection(&root->lock);
- @@ -61,7 +64,7 @@ int nfs41_root_create(
- root->sec_flavor = sec_flavor;
- /* generate a unique client_owner */
- - status = nfs41_client_owner(name, port, sec_flavor, &root->client_owner);
- + status = nfs41_client_owner(name, port, use_nfspubfh, sec_flavor, &root->client_owner);
- if (status) {
- eprintf("nfs41_client_owner() failed with %d\n", status);
- free(root);
- diff --git a/daemon/nfs41.h b/daemon/nfs41.h
- index f1617a9..5956d86 100644
- --- a/daemon/nfs41.h
- +++ b/daemon/nfs41.h
- @@ -299,6 +299,7 @@ typedef struct __nfs41_root {
- client_owner4 client_owner;
- CRITICAL_SECTION lock;
- struct list_entry clients;
- + bool use_nfspubfh;
- uint32_t wsize;
- uint32_t rsize;
- #pragma warning( push )
- @@ -316,6 +317,7 @@ typedef struct __nfs41_root {
- int nfs41_root_create(
- IN const char *name,
- IN uint32_t port,
- + IN bool use_nfspubfh,
- IN uint32_t sec_flavor,
- IN uint32_t wsize,
- IN uint32_t rsize,
- @@ -434,6 +436,7 @@ void nfs41_server_addrs(
- int nfs41_client_owner(
- IN const char *name,
- IN uint32_t port,
- + IN bool use_nfspubfh,
- IN uint32_t sec_flavor,
- OUT client_owner4 *owner);
- diff --git a/daemon/nfs41_client.c b/daemon/nfs41_client.c
- index 847aa0c..6a1f04a 100644
- --- a/daemon/nfs41_client.c
- +++ b/daemon/nfs41_client.c
- @@ -362,6 +362,7 @@ out:
- int nfs41_client_owner(
- IN const char *name,
- IN uint32_t port,
- + IN bool use_nfspubfh,
- IN uint32_t sec_flavor,
- OUT client_owner4 *owner)
- {
- @@ -420,6 +421,13 @@ int nfs41_client_owner(
- goto out_context;
- }
- + if (!CryptHashData(hash,
- + (const BYTE*)&use_nfspubfh, (DWORD)sizeof(bool), 0)) {
- + status = GetLastError();
- + eprintf("CryptHashData() failed with %d\n", status);
- + goto out_hash;
- + }
- +
- if (!CryptHashData(hash, (const BYTE*)&sec_flavor, (DWORD)sizeof(sec_flavor), 0)) {
- status = GetLastError();
- eprintf("CryptHashData() failed with %d\n", status);
- diff --git a/daemon/nfs41_ops.c b/daemon/nfs41_ops.c
- index 9ab7cef..11578cb 100644
- --- a/daemon/nfs41_ops.c
- +++ b/daemon/nfs41_ops.c
- @@ -1154,11 +1154,12 @@ int nfs41_getattr(
- putfh_args.file = file;
- putfh_args.in_recovery = 0;
- } else {
- -#ifdef USE_PUBFH
- - compound_add_op(&compound, OP_PUTPUBFH, NULL, &putfh_res);
- -#else
- - compound_add_op(&compound, OP_PUTROOTFH, NULL, &putfh_res);
- -#endif
- + if (session->client->root->use_nfspubfh) {
- + compound_add_op(&compound, OP_PUTPUBFH, NULL, &putfh_res);
- + }
- + else {
- + compound_add_op(&compound, OP_PUTROOTFH, NULL, &putfh_res);
- + }
- }
- compound_add_op(&compound, OP_GETATTR, &getattr_args, &getattr_res);
- @@ -1901,11 +1902,12 @@ int nfs41_secinfo(
- nfs41_session_sequence(&sequence_args, session, 0);
- if (file == NULL) {
- -#ifdef USE_PUBFH
- - compound_add_op(&compound, OP_PUTPUBFH, NULL, &putfh_res);
- -#else
- - compound_add_op(&compound, OP_PUTROOTFH, NULL, &putfh_res);
- -#endif
- + if (session->client->root->use_nfspubfh) {
- + compound_add_op(&compound, OP_PUTPUBFH, NULL, &putfh_res);
- + }
- + else {
- + compound_add_op(&compound, OP_PUTROOTFH, NULL, &putfh_res);
- + }
- }
- else {
- compound_add_op(&compound, OP_PUTFH, &putfh_args, &putfh_res);
- @@ -1948,11 +1950,12 @@ int nfs41_secinfo_noname(
- nfs41_session_sequence(&sequence_args, session, 0);
- if (file == NULL) {
- -#ifdef USE_PUBFH
- - compound_add_op(&compound, OP_PUTPUBFH, NULL, &putfh_res);
- -#else
- - compound_add_op(&compound, OP_PUTROOTFH, NULL, &putfh_res);
- -#endif
- + if (session->client->root->use_nfspubfh) {
- + compound_add_op(&compound, OP_PUTPUBFH, NULL, &putfh_res);
- + }
- + else {
- + compound_add_op(&compound, OP_PUTROOTFH, NULL, &putfh_res);
- + }
- }
- else {
- compound_add_op(&compound, OP_PUTFH, &putfh_args, &putfh_res);
- diff --git a/daemon/upcall.h b/daemon/upcall.h
- index 50b62be..48b1631 100644
- --- a/daemon/upcall.h
- +++ b/daemon/upcall.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
- @@ -35,6 +36,7 @@ typedef struct __mount_upcall_args {
- DWORD sec_flavor;
- DWORD rsize;
- DWORD wsize;
- + DWORD use_nfspubfh;
- DWORD lease_time;
- FILE_FS_ATTRIBUTE_INFORMATION FsAttrs;
- } mount_upcall_args;
- diff --git a/dll/nfs41_np.c b/dll/nfs41_np.c
- index 1720558..6e24e21 100644
- --- a/dll/nfs41_np.c
- +++ b/dll/nfs41_np.c
- @@ -638,8 +638,10 @@ NPAddConnection3(
- #endif
- #ifdef NFS41_DRIVER_MOUNT_DOES_NFS4_PREFIX
- - if (wcsncmp(&p[i], L"\\nfs4", 5) != 0) {
- - DbgP((L"Connection name '%s' not prefixed with '\\nfs41'\n",
- + if (wcsncmp(&p[i], L"\\nfs4", 5) &&
- + wcsncmp(&p[i], L"\\pubnfs4", 8)) {
- + DbgP((L"Connection name '%s' not prefixed with "
- + "'\\nfs41' or '\\pubnfs41'\n",
- &p[i]));
- Status = WN_BAD_NETNAME;
- goto out;
- diff --git a/mount/enum.c b/mount/enum.c
- index 8a30260..97043dd 100644
- --- a/mount/enum.c
- +++ b/mount/enum.c
- @@ -21,6 +21,7 @@
- #include <Windows.h>
- #include <tchar.h>
- +#include <stdbool.h>
- #include <stdio.h>
- #include <malloc.h>
- @@ -38,13 +39,17 @@ void PrintMountLine(
- LPCTSTR remote)
- {
- TCHAR *cygwin_unc_buffer = alloca((_tcslen(remote)+32)*sizeof(TCHAR));
- - char *cygwin_nfsurl_buffer = alloca(((_tcslen(remote)+32)*3)+8);
- + char *cygwin_nfsurl_buffer = alloca(
- + ((_tcslen(remote)+32)*3)+8 +
- + 9 /* "?public=1" */
- + );
- TCHAR *b;
- LPCTSTR s;
- TCHAR sc;
- #ifndef NFS41_DRIVER_MOUNT_DOES_NFS4_PREFIX
- unsigned int backslash_counter;
- #endif
- + bool is_pubfh = false;
- for(b = cygwin_unc_buffer, s = remote
- #ifndef NFS41_DRIVER_MOUNT_DOES_NFS4_PREFIX
- @@ -127,7 +132,22 @@ void PrintMountLine(
- */
- if (slash_counter == 1) {
- *us++ = uc;
- - utf8unc_p+=4;
- + if (*utf8unc_p == 'p') {
- + /* Skip "pubnfs4" */
- + utf8unc_p += 7;
- + is_pubfh = true;
- + }
- + else if (*utf8unc_p == 'n') {
- + /* Skip "nfs4" */
- + utf8unc_p += 4;
- + }
- + else {
- + (void)fwprintf(stderr,
- + L"PrintMountLine: ## Internal error, "
- + "unknown provider prefix\n");
- + return;
- + }
- +
- continue;
- }
- @@ -150,6 +170,17 @@ void PrintMountLine(
- }
- }
- *us = '\0';
- +
- + if (is_pubfh) {
- +#pragma warning( push )
- + /*
- + * Disable "'strcat': This function or variable may be unsafe",
- + * in this context it is safe to use
- + */
- +#pragma warning (disable : 4996)
- + (void)strcat(cygwin_nfsurl_buffer, "?public=1");
- +#pragma warning( pop )
- + }
- (void)_tprintf(TEXT("%-8s\t%-50s\t%-50s\t%-50S\n"),
- local, remote, cygwin_unc_buffer, cygwin_nfsurl_buffer);
- diff --git a/mount/mount.c b/mount/mount.c
- index c4d8170..f0c41e9 100644
- --- a/mount/mount.c
- +++ b/mount/mount.c
- @@ -30,6 +30,7 @@
- #include <strsafe.h>
- #include <Winnetwk.h> /* for WNet*Connection */
- #include <stdlib.h>
- +#include <stdbool.h>
- #include <stdio.h>
- #include "nfs41_build_features.h"
- @@ -51,6 +52,7 @@ DWORD EnumMounts(
- IN LPNETRESOURCE pContainer);
- static DWORD ParseRemoteName(
- + IN bool use_nfspubfh,
- IN LPTSTR pRemoteName,
- IN OUT PMOUNT_OPTION_LIST pOptions,
- OUT LPTSTR pParsedRemoteName,
- @@ -91,6 +93,8 @@ static VOID PrintUsage(LPTSTR pProcess)
- TEXT("\t-w\tAlias for -o rw (read-write mount)\n")
- TEXT("* Mount options:\n")
- + TEXT("\tpublic\tconnect to the server using the public file handle lookup protocol.\n")
- + TEXT("\t\t(See WebNFS Client Specification, RFC 2054).\n")
- TEXT("\tro\tmount as read-only\n")
- TEXT("\trw\tmount as read-write (default)\n")
- TEXT("\tport=#\tTCP port to use (defaults to 2049)\n")
- @@ -176,6 +180,8 @@ DWORD __cdecl _tmain(DWORD argc, LPTSTR argv[])
- goto out;
- }
- + bool use_nfspubfh = false;
- +
- /* parse command line */
- for (i = 1; i < argc; i++)
- {
- @@ -218,6 +224,20 @@ DWORD __cdecl _tmain(DWORD argc, LPTSTR argv[])
- }
- mntopts[num_mntopts++] = argv[i];
- +
- + /*
- + * Extract "public" option here, as we need this for
- + * |ParseRemoteName()|. General parsing of -o options
- + * happens *AFTER* |ParseRemoteName()|, so any
- + * settings from a nfs://-URL can be overridden
- + * via -o options.
- + */
- + if (wcsstr(argv[i], L"public=0")) {
- + use_nfspubfh = false;
- + }
- + else if (wcsstr(argv[i], L"public")) {
- + use_nfspubfh = true;
- + }
- }
- else if (_tcscmp(argv[i], TEXT("-r")) == 0) /* mount option */
- {
- @@ -333,7 +353,7 @@ DWORD __cdecl _tmain(DWORD argc, LPTSTR argv[])
- * options for a NFS mount point, which can be overridden via
- * -o below.
- */
- - result = ParseRemoteName(pRemoteName, &Options,
- + result = ParseRemoteName(use_nfspubfh, pRemoteName, &Options,
- szParsedRemoteName, szRemoteName, NFS41_SYS_MAX_PATH_LEN);
- if (result)
- goto out;
- @@ -411,6 +431,7 @@ wchar_t *utf8str2wcs(const char *utf8str)
- }
- static DWORD ParseRemoteName(
- + IN bool use_nfspubfh,
- IN LPTSTR pRemoteName,
- IN OUT PMOUNT_OPTION_LIST pOptions,
- OUT LPTSTR pParsedRemoteName,
- @@ -712,7 +733,8 @@ static DWORD ParseRemoteName(
- if (FAILED(result))
- goto out;
- #ifdef NFS41_DRIVER_MOUNT_DOES_NFS4_PREFIX
- - result = StringCbCat(pConnectionName, cchConnectionLen, TEXT("\\nfs4"));
- + result = StringCbCat(pConnectionName, cchConnectionLen,
- + (use_nfspubfh?(TEXT("\\pubnfs4")):(TEXT("\\nfs4"))));
- if (FAILED(result))
- goto out;
- #endif /* NFS41_DRIVER_MOUNT_DOES_NFS4_PREFIX */
- @@ -723,9 +745,10 @@ static DWORD ParseRemoteName(
- #ifdef DEBUG_MOUNT
- (void)_ftprintf(stderr,
- - TEXT("pConnectionName='%s', pParsedRemoteName='%s'\n"),
- + TEXT("pConnectionName='%s', pParsedRemoteName='%s', use_nfspubfh='%d'\n"),
- pConnectionName,
- - pParsedRemoteName);
- + pParsedRemoteName,
- + (int)use_nfspubfh);
- #endif
- out:
- diff --git a/sys/nfs41_driver.c b/sys/nfs41_driver.c
- index 613f7df..9d16b5d 100644
- --- a/sys/nfs41_driver.c
- +++ b/sys/nfs41_driver.c
- @@ -189,6 +189,7 @@ typedef struct _updowncall_entry {
- DWORD rsize;
- DWORD wsize;
- DWORD lease_time;
- + DWORD use_nfspubfh;
- } Mount;
- struct {
- PMDL MdlAddress;
- @@ -276,9 +277,13 @@ nfs41_updowncall_list upcall, downcall;
- -/* In order to cooperate with other network providers,
- - * we only claim paths of the format '\\server\nfs4\path' */
- +/*
- + * In order to cooperate with other network providers,
- + * we only claim paths of the format '\\server\nfs4\path' or
- + * '\\server\pubnfs4\path'
- + */
- DECLARE_CONST_UNICODE_STRING(NfsPrefix, L"\\nfs4");
- +DECLARE_CONST_UNICODE_STRING(PubNfsPrefix, L"\\pubnfs4");
- 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");
- @@ -294,6 +299,7 @@ DECLARE_CONST_UNICODE_STRING(EMPTY_STRING, L"");
- #define UPCALL_TIMEOUT_DEFAULT 50 /* in seconds */
- typedef struct _NFS41_MOUNT_CONFIG {
- + BOOLEAN use_nfspubfh;
- DWORD ReadSize;
- DWORD WriteSize;
- BOOLEAN ReadOnly;
- @@ -682,7 +688,7 @@ NTSTATUS marshal_nfs41_mount(
- goto out;
- }
- header_len = *len + length_as_utf8(entry->u.Mount.srv_name) +
- - length_as_utf8(entry->u.Mount.root) + 3 * sizeof(DWORD);
- + length_as_utf8(entry->u.Mount.root) + 4 * sizeof(DWORD);
- if (header_len > buf_len) {
- status = STATUS_INSUFFICIENT_RESOURCES;
- goto out;
- @@ -696,15 +702,18 @@ NTSTATUS marshal_nfs41_mount(
- RtlCopyMemory(tmp, &entry->u.Mount.rsize, sizeof(DWORD));
- tmp += sizeof(DWORD);
- RtlCopyMemory(tmp, &entry->u.Mount.wsize, sizeof(DWORD));
- + tmp += sizeof(DWORD);
- + RtlCopyMemory(tmp, &entry->u.Mount.use_nfspubfh, sizeof(DWORD));
- *len = header_len;
- #ifdef DEBUG_MARSHAL_DETAIL
- DbgP("marshal_nfs41_mount: server name='%wZ' mount point='%wZ' "
- - "sec_flavor='%s' rsize=%d wsize=%d\n",
- + "sec_flavor='%s' rsize=%d wsize=%d use_nfspubfh=%d\n",
- entry->u.Mount.srv_name, entry->u.Mount.root,
- - secflavorop2name(entry->u.Mount.sec_flavor), entry->u.Mount.rsize,
- - entry->u.Mount.wsize);
- + secflavorop2name(entry->u.Mount.sec_flavor),
- + (int)entry->u.Mount.rsize, (int)entry->u.Mount.wsize,
- + (int)entry->u.Mount.use_nfspubfh);
- #endif
- out:
- return status;
- @@ -2812,6 +2821,7 @@ NTSTATUS nfs41_mount(
- entry->u.Mount.root = &config->MntPt;
- entry->u.Mount.rsize = config->ReadSize;
- entry->u.Mount.wsize = config->WriteSize;
- + entry->u.Mount.use_nfspubfh = config->use_nfspubfh;
- entry->u.Mount.sec_flavor = sec_flavor;
- entry->u.Mount.FsAttrs = FsAttrs;
- @@ -2846,6 +2856,7 @@ void nfs41_MountConfig_InitDefaults(
- Config->ReadSize = MOUNT_CONFIG_RW_SIZE_DEFAULT;
- Config->WriteSize = MOUNT_CONFIG_RW_SIZE_DEFAULT;
- + Config->use_nfspubfh = FALSE;
- Config->ReadOnly = FALSE;
- Config->write_thru = FALSE;
- Config->nocache = FALSE;
- @@ -2992,6 +3003,15 @@ NTSTATUS nfs41_MountConfig_ParseOptions(
- &Config->WriteSize, MOUNT_CONFIG_RW_SIZE_MIN,
- MOUNT_CONFIG_RW_SIZE_MAX);
- }
- + else if (wcsncmp(L"public", Name, NameLen) == 0) {
- + /*
- + + We ignore this value here, and instead rely on the
- + * /pubnfs4 prefix
- + */
- + BOOLEAN dummy;
- + status = nfs41_MountConfig_ParseBoolean(Option, &usValue,
- + FALSE, &dummy);
- + }
- else if (wcsncmp(L"srvname", Name, NameLen) == 0) {
- if (usValue.Length > Config->SrvName.MaximumLength)
- status = STATUS_NAME_TOO_LONG;
- @@ -3107,7 +3127,8 @@ out:
- NTSTATUS has_nfs_prefix(
- IN PUNICODE_STRING SrvCallName,
- - IN PUNICODE_STRING NetRootName)
- + IN PUNICODE_STRING NetRootName,
- + OUT BOOLEAN *pubfh_prefix)
- {
- NTSTATUS status = STATUS_BAD_NETWORK_NAME;
- @@ -3140,20 +3161,42 @@ NTSTATUS has_nfs_prefix(
- }
- }
- - if ((state == 3) &&
- - (!memcmp(&NetRootName->Buffer[i], L"\\nfs4",
- + if (state == 3) {
- + if (!memcmp(&NetRootName->Buffer[i], L"\\nfs4",
- (4*sizeof(wchar_t))))) {
- - status = STATUS_SUCCESS;
- + *pubfh_prefix = FALSE;
- + status = STATUS_SUCCESS;
- + }
- + if ((NetRootName->Length >=
- + (SrvCallName->Length + PubNfsPrefix.Length)) &&
- + (!memcmp(&NetRootName->Buffer[i], L"\\pubnfs4",
- + (4*sizeof(wchar_t))))) {
- + *pubfh_prefix = TRUE;
- + status = STATUS_SUCCESS;
- + }
- }
- }
- #else
- - if (NetRootName->Length == SrvCallName->Length + NfsPrefix.Length) {
- + if (NetRootName->Length ==
- + (SrvCallName->Length + NfsPrefix.Length)) {
- const UNICODE_STRING NetRootPrefix = {
- NfsPrefix.Length,
- NetRootName->MaximumLength - SrvCallName->Length,
- &NetRootName->Buffer[SrvCallName->Length/2]
- };
- - if (RtlCompareUnicodeString(&NetRootPrefix, &NfsPrefix, FALSE) == 0)
- + if (!RtlCompareUnicodeString(&NetRootPrefix, &NfsPrefix, FALSE))
- + *pubfh_prefix = FALSE;
- + status = STATUS_SUCCESS;
- + }
- + else if (NetRootName->Length ==
- + (SrvCallName->Length + PubNfsPrefix.Length)) {
- + const UNICODE_STRING PubNetRootPrefix = {
- + PubNfsPrefix.Length,
- + NetRootName->MaximumLength - SrvCallName->Length,
- + &NetRootName->Buffer[SrvCallName->Length/2]
- + };
- + if (!RtlCompareUnicodeString(&PubNetRootPrefix, &PubNfsPrefix, FALSE))
- + *pubfh_prefix = TRUE;
- status = STATUS_SUCCESS;
- }
- #endif
- @@ -3296,12 +3339,16 @@ NTSTATUS nfs41_CreateVNetRoot(
- pVNetRootContext->session = INVALID_HANDLE_VALUE;
- - /* In order to cooperate with other network providers, we must
- - * only claim paths of the form '\\server\nfs4\path' */
- - status = has_nfs_prefix(pSrvCall->pSrvCallName, pNetRoot->pNetRootName);
- + /*
- + * In order to cooperate with other network providers, we
- + * must only claim paths of the form '\\server\nfs4\path'
- + * or '\\server\pubnfs4\path'
- + */
- + BOOLEAN pubfh_prefix = FALSE;
- + status = has_nfs_prefix(pSrvCall->pSrvCallName, pNetRoot->pNetRootName, &pubfh_prefix);
- if (status) {
- print_error("nfs41_CreateVNetRoot: NetRootName '%wZ' doesn't match "
- - "'\\nfs4'!\n", pNetRoot->pNetRootName);
- + "'\\nfs4' or '\\pubnfs4'!\n", pNetRoot->pNetRootName);
- goto out;
- }
- pNetRoot->MRxNetRootState = MRX_NET_ROOT_STATE_GOOD;
- @@ -3335,8 +3382,11 @@ NTSTATUS nfs41_CreateVNetRoot(
- pVNetRootContext->write_thru = Config->write_thru;
- pVNetRootContext->nocache = Config->nocache;
- } else {
- - /* Codepath for \\server@port\nfs4\path */
- - DbgP("Codepath for \\\\server@port\\nfs4\\path\n");
- + /*
- + * Codepath for \\server@port\nfs4\path or
- + * \\server@port\pubnfs4\path
- + */
- + DbgP("Codepath for \\\\server@port\\@(pubnfs4|nfs4)\\path\n");
- /*
- * STATUS_NFS_SHARE_NOT_MOUNTED - status code for the case
- @@ -3427,9 +3477,12 @@ NTSTATUS nfs41_CreateVNetRoot(
- pVNetRootContext->nocache = Config->nocache;
- }
- + Config->use_nfspubfh = pubfh_prefix;
- +
- DbgP("Config->{ "
- "MntPt='%wZ', "
- "SrvName='%wZ', "
- + "use_nfspubfh=%d, "
- "ReadOnly=%d, "
- "write_thru=%d, "
- "nocache=%d "
- @@ -3439,6 +3492,7 @@ NTSTATUS nfs41_CreateVNetRoot(
- "}\n",
- &Config->MntPt,
- &Config->SrvName,
- + Config->use_nfspubfh?1:0,
- Config->ReadOnly?1:0,
- Config->write_thru?1:0,
- Config->nocache?1:0,
- @@ -3564,7 +3618,7 @@ NTSTATUS nfs41_CreateVNetRoot(
- RtlCopyLuid(&entry->login_id, &luid);
- /*
- * Save mount config so we can use it for
- - * \\server@port\nfs4\path mounts later
- + * \\server@port\@(pubnfs4|nfs4)\path mounts later
- */
- copy_nfs41_mount_config(&entry->Config, Config);
- nfs41_AddEntry(pNetRootContext->mountLock,
- --
- 2.45.1
- From 2e981771fad01253e1389a3c97b9086d8b01d935 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Mon, 15 Jul 2024 11:28:15 +0200
- Subject: [PATCH 03/11] daemon,sys: Map |NFS4ERR_NOTSUPP| to
- |ERROR_NOT_SUPPORTED|/|STATUS_NOT_SUPPORTED|
- Map |NFS4ERR_NOTSUPP| to |ERROR_NOT_SUPPORTED|/|STATUS_NOT_SUPPORTED|,
- e.g. so nfs_mount.exe can report to the user if a specific mount
- option is not supported by the NFS server.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- daemon/util.c | 1 +
- sys/nfs41_driver.c | 1 +
- 2 files changed, 2 insertions(+)
- diff --git a/daemon/util.c b/daemon/util.c
- index c764303..c22bc6e 100644
- --- a/daemon/util.c
- +++ b/daemon/util.c
- @@ -345,6 +345,7 @@ int nfs_to_windows_error(int status, int default_error)
- case NFS4ERR_STALE: return ERROR_NETNAME_DELETED;
- case NFS4ERR_NOTEMPTY: return ERROR_NOT_EMPTY;
- case NFS4ERR_DENIED: return ERROR_LOCK_FAILED;
- + case NFS4ERR_NOTSUPP: return ERROR_NOT_SUPPORTED;
- case NFS4ERR_TOOSMALL: return ERROR_BUFFER_OVERFLOW;
- case NFS4ERR_LOCKED: return ERROR_LOCK_VIOLATION;
- case NFS4ERR_SHARE_DENIED: return ERROR_SHARING_VIOLATION;
- diff --git a/sys/nfs41_driver.c b/sys/nfs41_driver.c
- index 9d16b5d..aedd80d 100644
- --- a/sys/nfs41_driver.c
- +++ b/sys/nfs41_driver.c
- @@ -2789,6 +2789,7 @@ NTSTATUS map_mount_errors(
- case ERROR_BAD_NET_RESP: return STATUS_UNEXPECTED_NETWORK_ERROR;
- case ERROR_BAD_NET_NAME: return STATUS_BAD_NETWORK_NAME;
- case ERROR_BAD_NETPATH: return STATUS_BAD_NETWORK_PATH;
- + case ERROR_NOT_SUPPORTED: return STATUS_NOT_SUPPORTED;
- case ERROR_INTERNAL_ERROR: return STATUS_INTERNAL_ERROR;
- default:
- print_error("map_mount_errors: "
- --
- 2.45.1
- From 55cd519f5cb409adc62d3fb1ee4700f4b65bd738 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Mon, 15 Jul 2024 12:03:32 +0200
- Subject: [PATCH 04/11] mount: DEBUG_MOUNT: Print mount options
- DEBUG_MOUNT: Print mount options
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- mount/mount.c | 10 +++++++---
- mount/options.c | 2 +-
- mount/options.h | 3 +++
- 3 files changed, 11 insertions(+), 4 deletions(-)
- diff --git a/mount/mount.c b/mount/mount.c
- index f0c41e9..6a39064 100644
- --- a/mount/mount.c
- +++ b/mount/mount.c
- @@ -773,16 +773,20 @@ static DWORD DoMount(
- DWORD dwLength;
- NETRESOURCE NetResource;
- -
- if (pOptions->Buffer->Length) {
- if (pOptions->Current)
- pOptions->Current->NextEntryOffset = 0;
- NetResource.lpComment = (LPTSTR)&pOptions->Buffer[0];
- }
- -#if 0
- +#ifdef DEBUG_MOUNT
- + (void)_ftprintf(stderr,
- + TEXT("DoMount(pLocalName='%s', pRemoteName='%s', pParsedRemoteName='%s')\n"),
- + pLocalName,
- + pRemoteName,
- + pParsedRemoteName);
- RecursivePrintEaInformation((PFILE_FULL_EA_INFORMATION)pOptions->Buffer->Buffer);
- -#endif
- +#endif /* DEBUG_MOUNT */
- /* fail if the connection already exists */
- dwLength = NFS41_SYS_MAX_PATH_LEN;
- diff --git a/mount/options.c b/mount/options.c
- index 1655162..8910eb7 100644
- --- a/mount/options.c
- +++ b/mount/options.c
- @@ -158,7 +158,7 @@ BOOL InsertOption(
- return TRUE;
- }
- -static void RecursivePrintEaInformation(
- +void RecursivePrintEaInformation(
- IN PFILE_FULL_EA_INFORMATION EA)
- {
- _tprintf(
- diff --git a/mount/options.h b/mount/options.h
- index 5132615..ea6d9c6 100644
- --- a/mount/options.h
- +++ b/mount/options.h
- @@ -89,4 +89,7 @@ BOOL InsertOption(
- IN LPCTSTR Value,
- IN OUT PMOUNT_OPTION_LIST Options);
- +void RecursivePrintEaInformation(
- + IN PFILE_FULL_EA_INFORMATION EA);
- +
- #endif /* !__NFS41_MOUNT_OPTIONS_H__ */
- --
- 2.45.1
- From e0fce3e9aceead065d23c21cb8617ce54f70e2af Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Mon, 15 Jul 2024 13:34:44 +0200
- Subject: [PATCH 05/11] mount: nfs_mount -o port=1234 should override the port
- number in an nfs://-URL
- nfs_mount.exe -o port=1234 should override the port number in an nfs://-URL
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- mount/mount.c | 83 +++++++++++++++++++++++++++++++++++++++------------
- 1 file changed, 64 insertions(+), 19 deletions(-)
- diff --git a/mount/mount.c b/mount/mount.c
- index 6a39064..119d46b 100644
- --- a/mount/mount.c
- +++ b/mount/mount.c
- @@ -53,6 +53,7 @@ DWORD EnumMounts(
- static DWORD ParseRemoteName(
- IN bool use_nfspubfh,
- + IN int override_portnum,
- IN LPTSTR pRemoteName,
- IN OUT PMOUNT_OPTION_LIST pOptions,
- OUT LPTSTR pParsedRemoteName,
- @@ -151,6 +152,7 @@ DWORD __cdecl _tmain(DWORD argc, LPTSTR argv[])
- BOOL bUnmount = FALSE;
- BOOL bForceUnmount = FALSE;
- BOOL bPersistent = FALSE;
- + int port_num = -1;
- MOUNT_OPTION_LIST Options;
- #define MAX_MNTOPTS 128
- TCHAR *mntopts[MAX_MNTOPTS] = { 0 };
- @@ -225,18 +227,70 @@ DWORD __cdecl _tmain(DWORD argc, LPTSTR argv[])
- mntopts[num_mntopts++] = argv[i];
- + wchar_t *argv_i = argv[i];
- + bool found_opt;
- +
- +opt_o_argv_i_again:
- /*
- - * Extract "public" option here, as we need this for
- + * Extract options here, which are needed by
- * |ParseRemoteName()|. General parsing of -o options
- * happens *AFTER* |ParseRemoteName()|, so any
- * settings from a nfs://-URL can be overridden
- * via -o options.
- */
- - if (wcsstr(argv[i], L"public=0")) {
- + found_opt = false;
- +
- + /*
- + * Extract "public" option
- + */
- + if (wcsstr(argv_i, L"public=0")) {
- use_nfspubfh = false;
- + argv_i += 8;
- + found_opt = true;
- }
- - else if (wcsstr(argv[i], L"public")) {
- + else if (wcsstr(argv_i, L"public")) {
- use_nfspubfh = true;
- + argv_i += 6;
- + found_opt = true;
- + }
- +
- + /*
- + * Extract port number
- + */
- + wchar_t *pns; /* port number string */
- + pns = wcsstr(argv_i, L"port=");
- + if (pns) {
- + wchar_t *db;
- + wchar_t digit_buff[20];
- +
- + pns += 5; /* skip "port=" */
- +
- + /* Copy digits... */
- + for(db = digit_buff ;
- + iswdigit(*pns) &&
- + ((db-digit_buff) < sizeof(digit_buff)) ; )
- + *db++ = *pns++;
- + *db = L'\0';
- +
- + /* ... and convert them to a port number */
- + port_num = wcstol(digit_buff, NULL, 0);
- + if ((port_num < 1) || (port_num > 65535)) {
- + (void)_ftprintf(stderr, TEXT("NFSv4 TCP port number out of range.\n"));
- + result = ERROR_BAD_ARGUMENTS;
- + goto out;
- + }
- +
- + argv_i = pns-1;
- + found_opt = true;
- + }
- +
- + /*
- + * Try again with the remainder of the |argv[i]| string,
- + * so "port=666,port=888" will result in the port number
- + * "888"
- + */
- + if (found_opt) {
- + goto opt_o_argv_i_again;
- }
- }
- else if (_tcscmp(argv[i], TEXT("-r")) == 0) /* mount option */
- @@ -353,8 +407,10 @@ DWORD __cdecl _tmain(DWORD argc, LPTSTR argv[])
- * options for a NFS mount point, which can be overridden via
- * -o below.
- */
- - result = ParseRemoteName(use_nfspubfh, pRemoteName, &Options,
- - szParsedRemoteName, szRemoteName, NFS41_SYS_MAX_PATH_LEN);
- + result = ParseRemoteName(use_nfspubfh, port_num,
- + pRemoteName, &Options,
- + szParsedRemoteName, szRemoteName,
- + NFS41_SYS_MAX_PATH_LEN);
- if (result)
- goto out;
- @@ -432,6 +488,7 @@ wchar_t *utf8str2wcs(const char *utf8str)
- static DWORD ParseRemoteName(
- IN bool use_nfspubfh,
- + IN int override_portnum,
- IN LPTSTR pRemoteName,
- IN OUT PMOUNT_OPTION_LIST pOptions,
- OUT LPTSTR pParsedRemoteName,
- @@ -442,7 +499,6 @@ static DWORD ParseRemoteName(
- LPTSTR pEnd;
- wchar_t *mountstrmem = NULL;
- int port = MOUNT_CONFIG_NFS_PORT_DEFAULT;
- - PFILE_FULL_EA_INFORMATION port_option_val;
- wchar_t remotename[NFS41_SYS_MAX_PATH_LEN];
- wchar_t *premotename = remotename;
- /* sizeof(hostname+'@'+integer) */
- @@ -618,19 +674,8 @@ static DWORD ParseRemoteName(
- * Override the NFSv4 TCP port with the -o port=<num> option,
- * inclding for nfs://-URLs with port numbers
- */
- - if (FindOptionByName(TEXT("port"), pOptions,
- - &port_option_val)) {
- - wchar_t *port_value_wstr =
- - (PTCH)(port_option_val->EaName +
- - port_option_val->EaNameLength + sizeof(TCHAR));
- -
- - port = _wtoi(port_value_wstr);
- - }
- -
- - if ((port < 1) || (port > 65535)) {
- - (void)_ftprintf(stderr, TEXT("NFSv4 TCP port number out of range.\n"));
- - result = ERROR_BAD_ARGUMENTS;
- - goto out;
- + if (override_portnum != -1) {
- + port = override_portnum;
- }
- /*
- --
- 2.45.1
- From f40205f70cf33041aea9eae88013bce632ee0ceb Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Mon, 15 Jul 2024 13:52:34 +0200
- Subject: [PATCH 06/11] mount,sys: nfs_mount should no longer send "port"
- option, obsoleted by hostport
- nfs_mount.exe should no longer send "port" option, the port number
- is already encoded in the hostport value.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- mount/options.c | 8 ++++++++
- sys/nfs41_driver.c | 11 -----------
- 2 files changed, 8 insertions(+), 11 deletions(-)
- diff --git a/mount/options.c b/mount/options.c
- index 8910eb7..73d92ce 100644
- --- a/mount/options.c
- +++ b/mount/options.c
- @@ -108,6 +108,14 @@ BOOL InsertOption(
- USHORT ValueLen = (USHORT)_tcslen(Value) * sizeof(TCHAR);
- ULONG SpaceRequired = EaBufferSize(NameLen, ValueLen);
- + /*
- + * Filter "port" option, as it's value has already been encoded
- + * in the hostname as hostport
- + */
- + if (!_tcscmp(Name, L"port")) {
- + return TRUE;
- + }
- +
- /*
- * FIXME: Some duplicates are wanted, e.g. "rw" overriding "ro" etc
- * So better just let the kernel do the work
- diff --git a/sys/nfs41_driver.c b/sys/nfs41_driver.c
- index aedd80d..ad71496 100644
- --- a/sys/nfs41_driver.c
- +++ b/sys/nfs41_driver.c
- @@ -3019,17 +3019,6 @@ NTSTATUS nfs41_MountConfig_ParseOptions(
- else
- RtlCopyUnicodeString(&Config->SrvName, &usValue);
- }
- - /*
- - * gisburn: fixme: for now we accept "port=" as dummy here
- - * Technically nfs_mount.exe should filter this out. We leave
- - * this in for backwards-compatibilty with our internal test
- - * suite
- - */
- - else if (wcsncmp(L"port", Name, NameLen) == 0) {
- - DWORD dummy;
- - status = nfs41_MountConfig_ParseDword(Option, &usValue,
- - &dummy, 1, 65535);
- - }
- else if (wcsncmp(L"mntpt", Name, NameLen) == 0) {
- if (usValue.Length > Config->MntPt.MaximumLength)
- status = STATUS_NAME_TOO_LONG;
- --
- 2.45.1
- From c60bb5ac0d32a4afd6a11c022c4c0857baa36d9b Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Mon, 15 Jul 2024 15:39:21 +0200
- Subject: [PATCH 07/11] daemon,mount,sys: Remove <tchar.h> usage
- Remove <tchar.h> usage per review feedback.
- Reported-by: Josh Hurst <joshhurst@gmail.com>
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- daemon/nfs41_daemon.c | 45 ++---
- mount/enum.c | 50 ++---
- mount/mount.c | 428 +++++++++++++++++++++---------------------
- mount/options.c | 80 ++++----
- sys/nfs41_driver.h | 1 -
- 5 files changed, 302 insertions(+), 302 deletions(-)
- diff --git a/daemon/nfs41_daemon.c b/daemon/nfs41_daemon.c
- index 70979ef..73cfe4c 100644
- --- a/daemon/nfs41_daemon.c
- +++ b/daemon/nfs41_daemon.c
- @@ -26,7 +26,6 @@
- #include <Windows.h>
- #include <process.h>
- -#include <tchar.h>
- #include <stdio.h>
- #include <devioctl.h>
- @@ -273,7 +272,9 @@ static void PrintUsage()
- #endif /* _DEBUG */
- "\n", MAX_NUM_THREADS);
- }
- -static bool_t parse_cmdlineargs(int argc, TCHAR *argv[], nfsd_args *out)
- +
- +static
- +bool_t parse_cmdlineargs(int argc, wchar_t *argv[], nfsd_args *out)
- {
- int i;
- @@ -283,24 +284,24 @@ static bool_t parse_cmdlineargs(int argc, TCHAR *argv[], nfsd_args *out)
- /* parse command line */
- for (i = 1; i < argc; i++) {
- - if (argv[i][0] == TEXT('-')) {
- - if (_tcscmp(argv[i], TEXT("-h")) == 0) { /* help */
- + if (argv[i][0] == L'-') {
- + if (!wcscmp(argv[i], L"-h")) { /* help */
- PrintUsage();
- return FALSE;
- }
- - else if (_tcscmp(argv[i], TEXT("-d")) == 0) { /* debug level */
- + else if (!wcscmp(argv[i], L"-d")) { /* debug level */
- ++i;
- if (i >= argc) {
- fprintf(stderr, "Missing debug level value\n");
- PrintUsage();
- return FALSE;
- }
- - out->debug_level = _ttoi(argv[i]);
- + out->debug_level = wcstol(argv[i], NULL, 0);
- }
- #ifdef _DEBUG
- - else if (_tcscmp(argv[i], TEXT("--crtdbgmem")) == 0) {
- + else if (!wcscmp(argv[i], L"--crtdbgmem")) {
- ++i;
- - const TCHAR *memdbgoptions = argv[i];
- + const wchar_t *memdbgoptions = argv[i];
- if (i >= argc) {
- fprintf(stderr, "Missing options\n");
- PrintUsage();
- @@ -312,62 +313,62 @@ static bool_t parse_cmdlineargs(int argc, TCHAR *argv[], nfsd_args *out)
- nfs41_dg.crtdbgmem_flags = 0;
- nfs41_dg.crtdbgmem_flags |=
- - (_tcsstr(memdbgoptions, TEXT("allocmem")) != NULL)?
- + (wcsstr(memdbgoptions, L"allocmem") != NULL)?
- _CRTDBG_ALLOC_MEM_DF:0;
- nfs41_dg.crtdbgmem_flags |=
- - (_tcsstr(memdbgoptions, TEXT("leakcheck")) != NULL)?
- + (wcsstr(memdbgoptions, L"leakcheck") != NULL)?
- _CRTDBG_LEAK_CHECK_DF:0;
- nfs41_dg.crtdbgmem_flags |=
- - (_tcsstr(memdbgoptions, TEXT("delayfree")) != NULL)?
- + (wcsstr(memdbgoptions, L"delayfree") != NULL)?
- _CRTDBG_DELAY_FREE_MEM_DF:0;
- nfs41_dg.crtdbgmem_flags |=
- - (_tcsstr(memdbgoptions, TEXT("all")) != NULL)?
- + (wcsstr(memdbgoptions, L"all") != NULL)?
- (_CRTDBG_ALLOC_MEM_DF|_CRTDBG_LEAK_CHECK_DF|_CRTDBG_DELAY_FREE_MEM_DF):0;
- - if (_tcsstr(memdbgoptions, TEXT("none")) != NULL) {
- + if (wcsstr(memdbgoptions, L"none") != NULL) {
- nfs41_dg.crtdbgmem_flags = 0;
- }
- - if (_tcsstr(memdbgoptions, TEXT("default")) != NULL) {
- + if (wcsstr(memdbgoptions, L"default") != NULL) {
- nfs41_dg.crtdbgmem_flags =
- NFS41D_GLOBALS_CRTDBGMEM_FLAGS_NOT_SET;
- }
- }
- #endif /* _DEBUG */
- - else if (_tcscmp(argv[i], TEXT("--noldap")) == 0) { /* no LDAP */
- + else if (!wcscmp(argv[i], L"--noldap")) { /* no LDAP */
- out->ldap_enable = FALSE;
- }
- - else if (_tcscmp(argv[i], TEXT("--uid")) == 0) { /* no LDAP, setting default uid */
- + else if (!wcscmp(argv[i], L"--uid")) { /* no LDAP, setting default uid */
- ++i;
- if (i >= argc) {
- fprintf(stderr, "Missing uid value\n");
- PrintUsage();
- return FALSE;
- }
- - nfs41_dg.default_uid = _ttoi(argv[i]);
- + nfs41_dg.default_uid = wcstol(argv[i], NULL, 0);
- if (!nfs41_dg.default_uid) {
- fprintf(stderr, "Invalid (or missing) anonymous uid value of %d\n",
- nfs41_dg.default_uid);
- return FALSE;
- }
- }
- - else if (_tcscmp(argv[i], TEXT("--gid")) == 0) { /* no LDAP, setting default gid */
- + else if (!wcscmp(argv[i], L"--gid")) { /* no LDAP, setting default gid */
- ++i;
- if (i >= argc) {
- fprintf(stderr, "Missing gid value\n");
- PrintUsage();
- return FALSE;
- }
- - nfs41_dg.default_gid = _ttoi(argv[i]);
- + nfs41_dg.default_gid = wcstol(argv[i], NULL, 0);
- }
- - else if (_tcscmp(argv[i], TEXT("--numworkerthreads")) == 0) {
- + else if (!wcscmp(argv[i], L"--numworkerthreads")) {
- ++i;
- if (i >= argc) {
- fprintf(stderr, "Missing value for num_worker_threads\n");
- PrintUsage();
- return FALSE;
- }
- - nfs41_dg.num_worker_threads = _ttoi(argv[i]);
- + nfs41_dg.num_worker_threads = wcstol(argv[i], NULL, 0);
- if (nfs41_dg.num_worker_threads < 16) {
- fprintf(stderr, "--numworkerthreads requires at least 16 worker threads\n");
- PrintUsage();
- @@ -705,7 +706,7 @@ void set_nfs_daemon_privileges(void)
- #ifdef STANDALONE_NFSD
- -void __cdecl _tmain(int argc, TCHAR *argv[])
- +void __cdecl wmain(int argc, wchar_t *argv[])
- #else
- VOID ServiceStart(DWORD argc, LPTSTR *argv)
- #endif
- diff --git a/mount/enum.c b/mount/enum.c
- index 97043dd..9a74bca 100644
- --- a/mount/enum.c
- +++ b/mount/enum.c
- @@ -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
- @@ -20,13 +21,12 @@
- */
- #include <Windows.h>
- -#include <tchar.h>
- #include <stdbool.h>
- #include <stdio.h>
- #include <malloc.h>
- #include "nfs41_build_features.h"
- -#include "nfs41_driver.h" /* NFS41_PROVIDER_NAME_A */
- +#include "nfs41_driver.h" /* |NFS41_PROVIDER_NAME_U| */
- /* prototypes */
- char *wcs2utf8str(const wchar_t *wstr);
- @@ -35,17 +35,19 @@ void PrintErrorMessage(IN DWORD dwError);
- /* fixme: this function needs a cleanup */
- static __inline
- void PrintMountLine(
- - LPCTSTR local,
- - LPCTSTR remote)
- + LPCWSTR local,
- + LPCWSTR remote)
- {
- - TCHAR *cygwin_unc_buffer = alloca((_tcslen(remote)+32)*sizeof(TCHAR));
- - char *cygwin_nfsurl_buffer = alloca(
- - ((_tcslen(remote)+32)*3)+8 +
- + size_t remote_len = wcslen(remote);
- + wchar_t *cygwin_unc_buffer =
- + alloca((remote_len+32)*sizeof(wchar_t));
- + char *cygwin_nfsurl_buffer =
- + alloca(((remote_len+32)*3)+8 +
- 9 /* "?public=1" */
- );
- - TCHAR *b;
- - LPCTSTR s;
- - TCHAR sc;
- + wchar_t *b;
- + LPCWSTR s;
- + wchar_t sc;
- #ifndef NFS41_DRIVER_MOUNT_DOES_NFS4_PREFIX
- unsigned int backslash_counter;
- #endif
- @@ -56,13 +58,13 @@ void PrintMountLine(
- , backslash_counter = 0
- #endif
- ;
- - (sc = *s++) != TEXT('\0') ; ) {
- + (sc = *s++) != L'\0' ; ) {
- switch(sc) {
- - case TEXT('\\'):
- - *b++ = TEXT('/');
- + case L'\\':
- + *b++ = L'/';
- #ifndef NFS41_DRIVER_MOUNT_DOES_NFS4_PREFIX
- if (backslash_counter++ == 2) {
- - (void)wcscpy_s(b, 6, TEXT("nfs4/"));
- + (void)wcscpy_s(b, 6, L"nfs4/");
- b+=5;
- }
- #endif
- @@ -72,7 +74,7 @@ void PrintMountLine(
- break;
- }
- }
- - *b = TEXT('\0');
- + *b = L'\0';
- /*
- @@ -182,7 +184,7 @@ void PrintMountLine(
- #pragma warning( pop )
- }
- - (void)_tprintf(TEXT("%-8s\t%-50s\t%-50s\t%-50S\n"),
- + (void)wprintf(L"%-8s\t%-50s\t%-50s\t%-50S\n",
- local, remote, cygwin_unc_buffer, cygwin_nfsurl_buffer);
- free(utf8unc);
- @@ -217,10 +219,10 @@ DWORD EnumMounts(
- if (result)
- goto out_free;
- - (void)_tprintf(TEXT("Listing '%s' mounts:\n\n"),
- - TEXT(NFS41_PROVIDER_NAME_A));
- - (void)_tprintf(TEXT("%-8s\t%-50s\t%-50s\t%-50S\n"),
- - TEXT("Volume"), TEXT("Remote path"), TEXT("Cygwin UNC path"), "URL");
- + (void)wprintf(L"Listing '%s' mounts:\n\n",
- + NFS41_PROVIDER_NAME_U);
- + (void)wprintf(L"%-8s\t%-50s\t%-50s\t%-50s\n",
- + L"Volume", L"Remote path", L"Cygwin UNC path", L"URL");
- do
- {
- @@ -232,8 +234,8 @@ DWORD EnumMounts(
- {
- for (i = 0; i < dwCount; i++)
- {
- - if (_tcscmp(pResources[i].lpProvider,
- - TEXT(NFS41_PROVIDER_NAME_A)) == 0)
- + if (!wcscmp(pResources[i].lpProvider,
- + NFS41_PROVIDER_NAME_U))
- {
- PrintMountLine(pResources[i].lpLocalName,
- pResources[i].lpRemoteName);
- @@ -248,8 +250,8 @@ DWORD EnumMounts(
- result = WNetCloseEnum(hEnum);
- - _tprintf(TEXT("\nFound %d share%s.\n"), dwTotal,
- - dwTotal == 1 ? TEXT("") : TEXT("s"));
- + (void)wprintf(L"\nFound %d share%s.\n", dwTotal,
- + (dwTotal == 1) ? L"" : L"s");
- out_free:
- GlobalFree((HGLOBAL)pResources);
- diff --git a/mount/mount.c b/mount/mount.c
- index 119d46b..d4a6680 100644
- --- a/mount/mount.c
- +++ b/mount/mount.c
- @@ -26,7 +26,6 @@
- #include <crtdbg.h>
- #include <Windows.h>
- -#include <tchar.h>
- #include <strsafe.h>
- #include <Winnetwk.h> /* for WNet*Connection */
- #include <stdlib.h>
- @@ -34,7 +33,7 @@
- #include <stdio.h>
- #include "nfs41_build_features.h"
- -#include "nfs41_driver.h" /* NFS41_PROVIDER_NAME_A */
- +#include "nfs41_driver.h" /* |NFS41_PROVIDER_NAME_U| */
- #include "options.h"
- #include "urlparser1.h"
- @@ -54,109 +53,110 @@ DWORD EnumMounts(
- static DWORD ParseRemoteName(
- IN bool use_nfspubfh,
- IN int override_portnum,
- - IN LPTSTR pRemoteName,
- + IN LPWSTR pRemoteName,
- IN OUT PMOUNT_OPTION_LIST pOptions,
- - OUT LPTSTR pParsedRemoteName,
- - OUT LPTSTR pConnectionName,
- + OUT LPWSTR pParsedRemoteName,
- + OUT LPWSTR pConnectionName,
- IN size_t cchConnectionLen);
- static DWORD DoMount(
- - IN LPTSTR pLocalName,
- - IN LPTSTR pRemoteName,
- - IN LPTSTR pParsedRemoteName,
- + IN LPWSTR pLocalName,
- + IN LPWSTR pRemoteName,
- + IN LPWSTR pParsedRemoteName,
- IN BOOL bPersistent,
- IN PMOUNT_OPTION_LIST pOptions);
- static DWORD DoUnmount(
- - IN LPTSTR pLocalName,
- + IN LPWSTR pLocalName,
- IN BOOL bForce);
- static BOOL ParseDriveLetter(
- - IN LPTSTR pArg,
- + IN LPWSTR pArg,
- OUT PTCH pDriveLetter);
- void PrintErrorMessage(
- IN DWORD dwError);
- -static VOID PrintUsage(LPTSTR pProcess)
- +static VOID PrintUsage(LPWSTR pProcess)
- {
- - (void)_tprintf(
- - TEXT("Usage: %s [options] <drive letter|*> <hostname>:<path>\n")
- -
- - TEXT("* Options:\n")
- - TEXT("\t-h\thelp\n")
- - TEXT("\t/?\thelp\n")
- - TEXT("\t-d\tunmount\n")
- - TEXT("\t-f\tforce unmount if the drive is in use\n")
- - TEXT("\t-F <type>\tFilesystem type to use (only 'nfs' supported)"
- - " (Solaris/Illumos compat)\n")
- - TEXT("\t-t <type>\tFilesystem type to use (only 'nfs' supported)"
- - " (Linux compat)\n")
- - TEXT("\t-p\tmake the mount persist over reboots\n")
- - TEXT("\t-o <comma-separated mount options>\n")
- - TEXT("\t-r\tAlias for -o ro (read-only mount)\n")
- - TEXT("\t-w\tAlias for -o rw (read-write mount)\n")
- -
- - TEXT("* Mount options:\n")
- - TEXT("\tpublic\tconnect to the server using the public file handle lookup protocol.\n")
- - TEXT("\t\t(See WebNFS Client Specification, RFC 2054).\n")
- - TEXT("\tro\tmount as read-only\n")
- - TEXT("\trw\tmount as read-write (default)\n")
- - TEXT("\tport=#\tTCP port to use (defaults to 2049)\n")
- - TEXT("\trsize=#\tread buffer size in bytes\n")
- - TEXT("\twsize=#\twrite buffer size in bytes\n")
- - TEXT("\tsec=sys:krb5:krb5i:krb5p\tspecify (gss) security flavor\n")
- - TEXT("\twritethru\tturns off rdbss caching for writes\n")
- - TEXT("\tnowritethru\tturns on rdbss caching for writes (default)\n")
- - TEXT("\tcache\tturns on rdbss caching (default)\n")
- - TEXT("\tnocache\tturns off rdbss caching\n")
- - TEXT("\twsize=#\twrite buffer size in bytes\n")
- - TEXT("\tcreatemode=\tspecify default POSIX permission mode\n"
- + (void)fprintf(stderr,
- + "Usage: %S [options] <drive letter|*> <hostname>:<path>\n"
- +
- + "* Options:\n"
- + "\t-h\thelp\n"
- + "\t/?\thelp\n"
- + "\t-d\tunmount\n"
- + "\t-f\tforce unmount if the drive is in use\n"
- + "\t-F <type>\tFilesystem type to use (only 'nfs' supported)"
- + " (Solaris/Illumos compat)\n"
- + "\t-t <type>\tFilesystem type to use (only 'nfs' supported)"
- + " (Linux compat)\n"
- + "\t-p\tmake the mount persist over reboots\n"
- + "\t-o <comma-separated mount options>\n"
- + "\t-r\tAlias for -o ro (read-only mount)\n"
- + "\t-w\tAlias for -o rw (read-write mount)\n"
- +
- + "* Mount options:\n"
- + "\tpublic\tconnect to the server using the public file handle lookup protocol.\n"
- + "\t\t(See WebNFS Client Specification, RFC 2054).\n"
- + "\tro\tmount as read-only\n"
- + "\trw\tmount as read-write (default)\n"
- + "\tport=#\tTCP port to use (defaults to 2049)\n"
- + "\trsize=#\tread buffer size in bytes\n"
- + "\twsize=#\twrite buffer size in bytes\n"
- + "\tsec=sys:krb5:krb5i:krb5p\tspecify (gss) security flavor\n"
- + "\twritethru\tturns off rdbss caching for writes\n"
- + "\tnowritethru\tturns on rdbss caching for writes (default)\n"
- + "\tcache\tturns on rdbss caching (default)\n"
- + "\tnocache\tturns off rdbss caching\n"
- + "\twsize=#\twrite buffer size in bytes\n"
- + "\tcreatemode=\tspecify default POSIX permission mode\n"
- "\t\tfor new files created on the NFS share.\n"
- "\t\tArgument is an octal value prefixed with '0o',\n"
- "\t\tif this value is prefixed with 'nfsv3attrmode+'\n"
- "\t\tthe mode value from a \"NfsV3Attributes\" EA will be used\n"
- - "\t\t(defaults \"nfsv3attrmode+0o%o\").\n")
- -
- - TEXT("* URL parameters:\n")
- - TEXT("\tro=1\tmount as read-only\n")
- - TEXT("\trw=1\tmount as read-write (default)\n")
- -
- - TEXT("* Hostname:\n")
- - TEXT("\tDNS name, or hostname in domain\n")
- - TEXT("\tentry in C:\\Windows\\System32\\drivers\\etc\\hosts\n")
- - TEXT("\tIPv4 address\n")
- - TEXT("\tIPv6 address within '[', ']' "
- - "(will be converted to *.ipv6-literal.net)\n")
- -
- - TEXT("* Examples:\n")
- - TEXT("\tnfs_mount.exe -p -o rw 'H' derfwpc5131_ipv4:/export/home2/rmainz\n")
- - TEXT("\tnfs_mount.exe -o rw '*' bigramhost:/tmp\n")
- - TEXT("\tnfs_mount.exe -o ro '*' archive1:/tmp\n")
- - TEXT("\tnfs_mount.exe '*' archive1:/tmp?ro=1\n")
- - TEXT("\tnfs_mount.exe -o rw,sec=sys,port=30000 T grendel:/net_tmpfs2\n")
- - TEXT("\tnfs_mount.exe -o sec=sys,rw S nfs://myhost1//net_tmpfs2/test2\n")
- - TEXT("\tnfs_mount.exe -o sec=sys S nfs://myhost1//net_tmpfs2/test2?rw=1\n")
- - TEXT("\tnfs_mount.exe -o sec=sys,rw S nfs://myhost1:1234//net_tmpfs2/test2\n")
- - TEXT("\tnfs_mount.exe -o sec=sys,rw,port=1234 S nfs://myhost1//net_tmpfs2/test2\n")
- - TEXT("\tnfs_mount.exe -o sec=sys,rw '*' [fe80::21b:1bff:fec3:7713]://net_tmpfs2/test2\n")
- - TEXT("\tnfs_mount.exe -o sec=sys,rw '*' nfs://[fe80::21b:1bff:fec3:7713]//net_tmpfs2/test2\n")
- - TEXT("\tnfs_mount.exe -o sec=sys,rw S nfs://myhost1//dirwithspace/dir%%20space/test2\n")
- - TEXT("\tnfs_mount.exe -o sec=sys,rw S nfs://myhost1//dirwithspace/dir+space/test2\n")
- - TEXT("\tnfs_mount.exe -o sec=sys S nfs://myhost1//dirwithspace/dir+space/test2?rw=1\n"),
- + "\t\t(defaults \"nfsv3attrmode+0o%o\").\n"
- +
- + "* URL parameters:\n"
- + "\tro=1\tmount as read-only\n"
- + "\trw=1\tmount as read-write (default)\n"
- +
- + "* Hostname:\n"
- + "\tDNS name, or hostname in domain\n"
- + "\tentry in C:\\Windows\\System32\\drivers\\etc\\hosts\n"
- + "\tIPv4 address\n"
- + "\tIPv6 address within '[', ']' "
- + "(will be converted to *.ipv6-literal.net)\n"
- +
- + "* Examples:\n"
- + "\tnfs_mount.exe -p -o rw 'H' derfwpc5131_ipv4:/export/home2/rmainz\n"
- + "\tnfs_mount.exe -o rw '*' bigramhost:/tmp\n"
- + "\tnfs_mount.exe -o ro '*' archive1:/tmp\n"
- + "\tnfs_mount.exe '*' archive1:/tmp?ro=1\n"
- + "\tnfs_mount.exe -o rw,sec=sys,port=30000 T grendel:/net_tmpfs2\n"
- + "\tnfs_mount.exe -o sec=sys,rw S nfs://myhost1//net_tmpfs2/test2\n"
- + "\tnfs_mount.exe -o sec=sys S nfs://myhost1//net_tmpfs2/test2?rw=1\n"
- + "\tnfs_mount.exe -o sec=sys,rw S nfs://myhost1:1234//net_tmpfs2/test2\n"
- + "\tnfs_mount.exe -o sec=sys,rw,port=1234 S nfs://myhost1//net_tmpfs2/test2\n"
- + "\tnfs_mount.exe -o sec=sys,rw '*' [fe80::21b:1bff:fec3:7713]://net_tmpfs2/test2\n"
- + "\tnfs_mount.exe -o sec=sys,rw '*' nfs://[fe80::21b:1bff:fec3:7713]//net_tmpfs2/test2\n"
- + "\tnfs_mount.exe -o sec=sys,rw S nfs://myhost1//dirwithspace/dir%%20space/test2\n"
- + "\tnfs_mount.exe -o sec=sys,rw S nfs://myhost1//dirwithspace/dir+space/test2\n"
- + "\tnfs_mount.exe -o sec=sys S nfs://myhost1//dirwithspace/dir+space/test2?rw=1\n",
- pProcess, (int)NFS41_DRIVER_DEFAULT_CREATE_MODE);
- }
- -DWORD __cdecl _tmain(DWORD argc, LPTSTR argv[])
- +int __cdecl wmain(int argc, wchar_t *argv[])
- {
- - DWORD i, result = NO_ERROR;
- - TCHAR szLocalName[] = TEXT("C:\0");
- - LPTSTR pLocalName = NULL;
- - LPTSTR pRemoteName = NULL;
- + int i;
- + DWORD result = NO_ERROR;
- + wchar_t szLocalName[] = L"C:\0";
- + LPWSTR pLocalName = NULL;
- + LPWSTR pRemoteName = NULL;
- BOOL bUnmount = FALSE;
- BOOL bForceUnmount = FALSE;
- BOOL bPersistent = FALSE;
- int port_num = -1;
- MOUNT_OPTION_LIST Options;
- #define MAX_MNTOPTS 128
- - TCHAR *mntopts[MAX_MNTOPTS] = { 0 };
- - size_t num_mntopts = 0;
- + wchar_t *mntopts[MAX_MNTOPTS] = { 0 };
- + int num_mntopts = 0;
- int crtsetdbgflags = 0;
- crtsetdbgflags |= _CRTDBG_ALLOC_MEM_DF; /* use debug heap */
- @@ -187,41 +187,36 @@ DWORD __cdecl _tmain(DWORD argc, LPTSTR argv[])
- /* parse command line */
- for (i = 1; i < argc; i++)
- {
- - if (argv[i][0] == TEXT('-'))
- + if (argv[i][0] == L'-')
- {
- - if (_tcscmp(argv[i], TEXT("-h")) == 0) /* help */
- - {
- + if (!wcscmp(argv[i], L"-h")) { /* help */
- PrintUsage(argv[0]);
- goto out;
- }
- - else if (_tcscmp(argv[i], TEXT("-d")) == 0) /* unmount */
- - {
- + else if (!wcscmp(argv[i], L"-d")) { /* unmount */
- bUnmount = TRUE;
- }
- - else if (_tcscmp(argv[i], TEXT("-f")) == 0) /* force unmount */
- - {
- + else if (!wcscmp(argv[i], L"-f")) { /* force unmount */
- bForceUnmount = TRUE;
- }
- - else if (_tcscmp(argv[i], TEXT("-p")) == 0) /* persistent */
- - {
- + else if (!wcscmp(argv[i], L"-p")) { /* persistent */
- bPersistent = TRUE;
- }
- - else if (_tcscmp(argv[i], TEXT("-o")) == 0) /* mount option */
- - {
- + else if (!wcscmp(argv[i], L"-o")) { /* mount option */
- ++i;
- if (i >= argc)
- {
- result = ERROR_BAD_ARGUMENTS;
- - _ftprintf(stderr, TEXT("Mount options missing ")
- - TEXT("after '-o'.\n\n"));
- + (void)fwprintf(stderr,
- + L"Mount options missing after '-o'.\n\n");
- PrintUsage(argv[0]);
- goto out_free;
- }
- if (num_mntopts >= (MAX_MNTOPTS-1)) {
- result = ERROR_BAD_ARGUMENTS;
- - _ftprintf(stderr, TEXT("Too many -o ")
- - TEXT("options.\n\n"));
- + (void)fwprintf(stderr,
- + L"Too many -o options.\n\n");
- goto out_free;
- }
- @@ -275,7 +270,8 @@ opt_o_argv_i_again:
- /* ... and convert them to a port number */
- port_num = wcstol(digit_buff, NULL, 0);
- if ((port_num < 1) || (port_num > 65535)) {
- - (void)_ftprintf(stderr, TEXT("NFSv4 TCP port number out of range.\n"));
- + (void)fwprintf(stderr,
- + L"NFSv4 TCP port number out of range.\n");
- result = ERROR_BAD_ARGUMENTS;
- goto out;
- }
- @@ -293,59 +289,56 @@ opt_o_argv_i_again:
- goto opt_o_argv_i_again;
- }
- }
- - else if (_tcscmp(argv[i], TEXT("-r")) == 0) /* mount option */
- - {
- + else if (!wcscmp(argv[i], L"-r")) { /* mount option */
- if (num_mntopts >= (MAX_MNTOPTS-1)) {
- result = ERROR_BAD_ARGUMENTS;
- - (void)_ftprintf(stderr, TEXT("Too many options.\n\n"));
- + (void)fwprintf(stderr, L"Too many options.\n\n");
- goto out_free;
- }
- - mntopts[num_mntopts++] = TEXT("ro");
- + mntopts[num_mntopts++] = L"ro";
- }
- - else if (_tcscmp(argv[i], TEXT("-w")) == 0) /* mount option */
- - {
- + else if (!wcscmp(argv[i], L"-w")) { /* mount option */
- if (num_mntopts >= (MAX_MNTOPTS-1)) {
- result = ERROR_BAD_ARGUMENTS;
- - (void)_ftprintf(stderr, TEXT("Too many options.\n\n"));
- + (void)fwprintf(stderr, L"Too many options.\n\n");
- goto out_free;
- }
- - mntopts[num_mntopts++] = TEXT("rw");
- + mntopts[num_mntopts++] = L"rw";
- }
- /*
- * Filesystem type, we use this for Solaris
- * $ mount(1M) -F nfs ... # and Linux
- * $ mount.nfs4 -t nfs ... # compatiblity
- */
- - else if ((_tcscmp(argv[i], TEXT("-F")) == 0) ||
- - (_tcscmp(argv[i], TEXT("-t")) == 0))
- + else if ((!wcscmp(argv[i], L"-F")) ||
- + (!wcscmp(argv[i], L"-t")))
- {
- ++i;
- if (i >= argc)
- {
- result = ERROR_BAD_ARGUMENTS;
- - _ftprintf(stderr, TEXT("Filesystem type missing ")
- - TEXT("after '-t'/'-F'.\n\n"));
- + (void)fwprintf(stderr, L"Filesystem type missing "
- + L"after '-t'/'-F'.\n\n");
- PrintUsage(argv[0]);
- goto out_free;
- }
- - if (_tcscmp(argv[i], TEXT("nfs")) != 0)
- - {
- + if (!wcscmp(argv[i], L"nfs")) {
- result = ERROR_BAD_ARGUMENTS;
- - _ftprintf(stderr, TEXT("Filesystem type '%s' ")
- - TEXT("not supported.\n\n"), argv[i]);
- + (void)fwprintf(stderr, L"Filesystem type '%s' "
- + L"not supported.\n\n", argv[i]);
- PrintUsage(argv[0]);
- goto out_free;
- }
- }
- else
- - _ftprintf(stderr, TEXT("Unrecognized option ")
- - TEXT("'%s', disregarding.\n"), argv[i]);
- + (void)fwprintf(stderr, L"Unrecognized option "
- + L"'%s', disregarding.\n",
- + argv[i]);
- }
- - else if (_tcscmp(argv[i], TEXT("/?")) == 0)
- - {
- + else if (!wcscmp(argv[i], L"/?")) {
- /* Windows-style "nfs_mount /?" help */
- PrintUsage(argv[0]);
- goto out;
- @@ -359,23 +352,25 @@ opt_o_argv_i_again:
- pRemoteName = argv[i];
- }
- else
- - _ftprintf(stderr, TEXT("Unrecognized argument ")
- - TEXT("'%s', disregarding.\n"), argv[i]);
- + (void)fwprintf(stderr, L"Unrecognized argument "
- + L"'%s', disregarding.\n",
- + argv[i]);
- }
- /* validate local drive letter */
- if (pLocalName == NULL)
- {
- result = ERROR_BAD_ARGUMENTS;
- - _ftprintf(stderr, TEXT("Missing argument for drive letter.\n\n"));
- + (void)fwprintf(stderr, L"Missing argument for drive letter.\n\n");
- PrintUsage(argv[0]);
- goto out_free;
- }
- if (FALSE == ParseDriveLetter(pLocalName, szLocalName))
- {
- result = ERROR_BAD_ARGUMENTS;
- - _ftprintf(stderr, TEXT("Invalid drive letter '%s'. ")
- - TEXT("Expected 'C' or 'C:'.\n\n"), pLocalName);
- + (void)fwprintf(stderr, L"Invalid drive letter '%s'. "
- + L"Expected 'C' or 'C:'.\n\n",
- + pLocalName);
- PrintUsage(argv[0]);
- goto out_free;
- }
- @@ -388,15 +383,15 @@ opt_o_argv_i_again:
- }
- else /* mount */
- {
- - TCHAR szRemoteName[NFS41_SYS_MAX_PATH_LEN];
- - TCHAR szParsedRemoteName[NFS41_SYS_MAX_PATH_LEN];
- + wchar_t szRemoteName[NFS41_SYS_MAX_PATH_LEN];
- + wchar_t szParsedRemoteName[NFS41_SYS_MAX_PATH_LEN];
- - *szRemoteName = TEXT('\0');
- + *szRemoteName = L'\0';
- if (pRemoteName == NULL)
- {
- result = ERROR_BAD_NET_NAME;
- - _ftprintf(stderr, TEXT("Missing argument for remote path.\n\n"));
- + (void)fwprintf(stderr, L"Missing argument for remote path.\n\n");
- PrintUsage(argv[0]);
- goto out_free;
- }
- @@ -437,12 +432,12 @@ out:
- }
- static void ConvertUnixSlashes(
- - IN OUT LPTSTR pRemoteName)
- + IN OUT LPWSTR pRemoteName)
- {
- - LPTSTR pos = pRemoteName;
- + LPWSTR pos = pRemoteName;
- for (pos = pRemoteName; *pos; pos++)
- - if (*pos == TEXT('/'))
- - *pos = TEXT('\\');
- + if (*pos == L'/')
- + *pos = L'\\';
- }
- @@ -489,14 +484,14 @@ wchar_t *utf8str2wcs(const char *utf8str)
- static DWORD ParseRemoteName(
- IN bool use_nfspubfh,
- IN int override_portnum,
- - IN LPTSTR pRemoteName,
- + IN LPWSTR pRemoteName,
- IN OUT PMOUNT_OPTION_LIST pOptions,
- - OUT LPTSTR pParsedRemoteName,
- - OUT LPTSTR pConnectionName,
- + OUT LPWSTR pParsedRemoteName,
- + OUT LPWSTR pConnectionName,
- IN size_t cchConnectionLen)
- {
- DWORD result = NO_ERROR;
- - LPTSTR pEnd;
- + LPWSTR pEnd;
- wchar_t *mountstrmem = NULL;
- int port = MOUNT_CONFIG_NFS_PORT_DEFAULT;
- wchar_t remotename[NFS41_SYS_MAX_PATH_LEN];
- @@ -513,7 +508,7 @@ static DWORD ParseRemoteName(
- * SCHEME", see https://www.rfc-editor.org/rfc/rfc2224.html),
- * including port support (nfs://hostname@port/path/...)
- */
- - if (!wcsncmp(premotename, TEXT("nfs://"), 6)) {
- + if (!wcsncmp(premotename, L"nfs://", 6)) {
- char *premotename_utf8;
- wchar_t *hostname_wstr;
- @@ -542,13 +537,14 @@ static DWORD ParseRemoteName(
- if (url_parser_parse(uctx) < 0) {
- result = ERROR_BAD_ARGUMENTS;
- - (void)_ftprintf(stderr, TEXT("Error parsing nfs://-URL.\n"));
- + (void)fwprintf(stderr, L"Error parsing nfs://-URL.\n");
- goto out;
- }
- if (uctx->login.username || uctx->login.passwd) {
- result = ERROR_BAD_ARGUMENTS;
- - (void)_ftprintf(stderr, TEXT("Username/Password are not defined for nfs://-URL.\n"));
- + (void)fwprintf(stderr,
- + L"Username/Password are not defined for nfs://-URL.\n");
- goto out;
- }
- @@ -572,40 +568,41 @@ static DWORD ParseRemoteName(
- if (!strcmp(pname, "rw")) {
- if ((pvalue == NULL) || (!strcmp(pvalue, "1"))) {
- - (void)InsertOption(TEXT("rw"), TEXT("1"), pOptions);
- + (void)InsertOption(L"rw", L"1", pOptions);
- }
- else if (!strcmp(pvalue, "0")) {
- - (void)InsertOption(TEXT("ro"), TEXT("1"), pOptions);
- + (void)InsertOption(L"ro", L"1", pOptions);
- }
- else {
- result = ERROR_BAD_ARGUMENTS;
- - (void)_ftprintf(stderr,
- - TEXT("Unsupported nfs://-URL parameter ")
- - TEXT("'%S' value '%S'.\n"),
- + (void)fwprintf(stderr,
- + L"Unsupported nfs://-URL parameter "
- + L"'%S' value '%S'.\n",
- pname, pvalue);
- goto out;
- }
- }
- else if (!strcmp(pname, "ro")) {
- if ((pvalue == NULL) || (!strcmp(pvalue, "1"))) {
- - (void)InsertOption(TEXT("ro"), TEXT("1"), pOptions);
- + (void)InsertOption(L"ro", L"1", pOptions);
- }
- else if (!strcmp(pvalue, "0")) {
- - (void)InsertOption(TEXT("rw"), TEXT("1"), pOptions);
- + (void)InsertOption(L"rw", L"1", pOptions);
- }
- else {
- result = ERROR_BAD_ARGUMENTS;
- - (void)_ftprintf(stderr,
- - TEXT("Unsupported nfs://-URL parameter ")
- - TEXT("'%S' value '%S'.\n"),
- + (void)fwprintf(stderr,
- + L"Unsupported nfs://-URL parameter "
- + L"'%S' value '%S'.\n",
- pname, pvalue);
- goto out;
- }
- }
- else {
- result = ERROR_BAD_ARGUMENTS;
- - (void)_ftprintf(stderr,
- - TEXT("Unsupported nfs://-URL parameter '%S'.\n"), pname);
- + (void)fwprintf(stderr,
- + L"Unsupported nfs://-URL parameter '%S'.\n",
- + pname);
- goto out;
- }
- }
- @@ -625,13 +622,13 @@ static DWORD ParseRemoteName(
- if (!uctx->path) {
- result = ERROR_BAD_ARGUMENTS;
- - (void)_ftprintf(stderr, TEXT("Path missing in nfs://-URL\n"));
- + (void)fwprintf(stderr, L"Path missing in nfs://-URL\n");
- goto out;
- }
- if (uctx->path[0] != '/') {
- result = ERROR_BAD_ARGUMENTS;
- - (void)_ftprintf(stderr, TEXT("Relative nfs://-URLs are not supported\n"));
- + (void)fwprintf(stderr, L"Relative nfs://-URLs are not supported\n");
- goto out;
- }
- @@ -651,23 +648,23 @@ static DWORD ParseRemoteName(
- * users, but we explicitly allow the nfs://-URLs to have a
- * port number, and -o port=<num> to override that.
- */
- - if (_tcsrchr(premotename, TEXT('@'))) {
- - (void)_ftprintf(stderr,
- - TEXT("Remote path should not contain '@', ")
- - TEXT("use -o port=tcpportnum.\n"));
- + if (wcsrchr(premotename, L'@')) {
- + (void)fwprintf(stderr,
- + L"Remote path should not contain '@', "
- + L"use -o port=tcpportnum.\n");
- result = ERROR_BAD_ARGUMENTS;
- goto out;
- }
- /* fail if the server name doesn't end with :\ */
- - pEnd = _tcsrchr(premotename, TEXT(':'));
- - if (pEnd == NULL || pEnd[1] != TEXT('\\')) {
- - (void)_ftprintf(stderr, TEXT("Failed to parse the remote path. ")
- - TEXT("Expected 'hostname:\\path'.\n"));
- + pEnd = wcsrchr(premotename, L':');
- + if (pEnd == NULL || pEnd[1] != L'\\') {
- + (void)fwprintf(stderr, L"Failed to parse the remote path. "
- + L"Expected 'hostname:\\path'.\n");
- result = ERROR_BAD_ARGUMENTS;
- goto out;
- }
- - *pEnd++ = TEXT('\0');
- + *pEnd++ = L'\0';
- }
- /*
- @@ -693,31 +690,31 @@ static DWORD ParseRemoteName(
- * See https://en.wikipedia.org/wiki/IPv6_address#Literal_IPv6_addresses_in_UNC_path_names
- * for details
- */
- - if (premotename[0] == TEXT('[')) {
- + if (premotename[0] == L'[') {
- size_t len = wcslen(premotename);
- size_t i;
- wchar_t c;
- /* Check for minimum length and trailing ']' */
- - if ((len < 4) || (premotename[len-1] != TEXT(']'))) {
- - _ftprintf(stderr, TEXT("Failed to parse raw IPv6 address,")
- - TEXT(" trailing ']' is missing, ")
- - TEXT("or address string too short.\n"));
- + if ((len < 4) || (premotename[len-1] != L']')) {
- + fwprintf(stderr, L"Failed to parse raw IPv6 address,"
- + L" trailing ']' is missing, "
- + L"or address string too short.\n");
- result = ERROR_BAD_ARGUMENTS;
- goto out;
- }
- /* Skip '[', stomp ']' */
- - premotename[len-1] = TEXT('\0');
- + premotename[len-1] = L'\0';
- premotename++;
- len -= 2;
- /* Check whether this is a valid IPv6 address */
- for (i=0 ; i < len ; i++) {
- c = premotename[i];
- - if (!(iswxdigit(c) || (c == TEXT(':')))) {
- - _ftprintf(stderr, TEXT("Failed to parse raw IPv6 ")
- - TEXT("address, illegal character '%c' found.\n"),
- + if (!(iswxdigit(c) || (c == L':'))) {
- + fwprintf(stderr, L"Failed to parse raw IPv6 "
- + L"address, illegal character '%c' found.\n",
- c);
- result = ERROR_BAD_ARGUMENTS;
- goto out;
- @@ -726,11 +723,11 @@ static DWORD ParseRemoteName(
- for (i = 0 ; i < len ; i++) {
- /* IPv6 separator */
- - if (premotename[i] == TEXT(':'))
- - premotename[i] = TEXT('-');
- + if (premotename[i] == L':')
- + premotename[i] = L'-';
- /* zone index */
- - else if (premotename[i] == TEXT('%'))
- - premotename[i] = TEXT('s');
- + else if (premotename[i] == L'%')
- + premotename[i] = L's';
- }
- /*
- @@ -739,11 +736,11 @@ static DWORD ParseRemoteName(
- * too
- */
- (void)swprintf(srvname, SRVNAME_LEN,
- - TEXT("%s.ipv6-literal.net@%d"), premotename, port);
- + L"%s.ipv6-literal.net@%d", premotename, port);
- }
- else {
- /* ALWAYS add port number to hostname, so UNC paths use it too */
- - (void)swprintf(srvname, SRVNAME_LEN, TEXT("%s@%d"),
- + (void)swprintf(srvname, SRVNAME_LEN, L"%s@%d",
- premotename, port);
- }
- @@ -751,27 +748,27 @@ static DWORD ParseRemoteName(
- * Safeguard against ':' in UNC paths, e.g if we pass raw IPv6
- * address without ':', or just random garbage
- */
- - if (wcschr(srvname, TEXT(':'))) {
- - _ftprintf(stderr,
- - TEXT("Illegal ':' character hostname '%s'.\n"), srvname);
- + if (wcschr(srvname, L':')) {
- + fwprintf(stderr,
- + L"Illegal ':' character hostname '%s'.\n", srvname);
- result = ERROR_BAD_ARGUMENTS;
- goto out;
- }
- #ifdef DEBUG_MOUNT
- - (void)_ftprintf(stderr,
- - TEXT("srvname='%s', mntpt='%s'\n"),
- + (void)fwprintf(stderr,
- + L"srvname='%s', mntpt='%s'\n",
- srvname,
- pEnd);
- #endif
- - if (!InsertOption(TEXT("srvname"), srvname, pOptions) ||
- - !InsertOption(TEXT("mntpt"), *pEnd ? pEnd : TEXT("\\"), pOptions)) {
- + if (!InsertOption(L"srvname", srvname, pOptions) ||
- + !InsertOption(L"mntpt", (*pEnd ? pEnd : L"\\"), pOptions)) {
- result = ERROR_BAD_ARGUMENTS;
- goto out;
- }
- - result = StringCchCopy(pConnectionName, cchConnectionLen, TEXT("\\\\"));
- + result = StringCchCopy(pConnectionName, cchConnectionLen, L"\\\\");
- if (FAILED(result))
- goto out;
- result = StringCbCat(pConnectionName, cchConnectionLen, srvname);
- @@ -779,7 +776,7 @@ static DWORD ParseRemoteName(
- goto out;
- #ifdef NFS41_DRIVER_MOUNT_DOES_NFS4_PREFIX
- result = StringCbCat(pConnectionName, cchConnectionLen,
- - (use_nfspubfh?(TEXT("\\pubnfs4")):(TEXT("\\nfs4"))));
- + (use_nfspubfh?(L"\\pubnfs4"):(L"\\nfs4")));
- if (FAILED(result))
- goto out;
- #endif /* NFS41_DRIVER_MOUNT_DOES_NFS4_PREFIX */
- @@ -789,8 +786,8 @@ static DWORD ParseRemoteName(
- result = StringCchCopy(pParsedRemoteName, cchConnectionLen, srvname);
- #ifdef DEBUG_MOUNT
- - (void)_ftprintf(stderr,
- - TEXT("pConnectionName='%s', pParsedRemoteName='%s', use_nfspubfh='%d'\n"),
- + (void)fwprintf(stderr,
- + L"pConnectionName='%s', pParsedRemoteName='%s', use_nfspubfh='%d'\n",
- pConnectionName,
- pParsedRemoteName,
- (int)use_nfspubfh);
- @@ -807,26 +804,26 @@ out:
- }
- static DWORD DoMount(
- - IN LPTSTR pLocalName,
- - IN LPTSTR pRemoteName,
- - IN LPTSTR pParsedRemoteName,
- + IN LPWSTR pLocalName,
- + IN LPWSTR pRemoteName,
- + IN LPWSTR pParsedRemoteName,
- IN BOOL bPersistent,
- IN PMOUNT_OPTION_LIST pOptions)
- {
- DWORD result = NO_ERROR;
- - TCHAR szExisting[NFS41_SYS_MAX_PATH_LEN];
- + wchar_t szExisting[NFS41_SYS_MAX_PATH_LEN];
- DWORD dwLength;
- NETRESOURCE NetResource;
- if (pOptions->Buffer->Length) {
- if (pOptions->Current)
- pOptions->Current->NextEntryOffset = 0;
- - NetResource.lpComment = (LPTSTR)&pOptions->Buffer[0];
- + NetResource.lpComment = (LPWSTR)&pOptions->Buffer[0];
- }
- #ifdef DEBUG_MOUNT
- - (void)_ftprintf(stderr,
- - TEXT("DoMount(pLocalName='%s', pRemoteName='%s', pParsedRemoteName='%s')\n"),
- + (void)fwprintf(stderr,
- + L"DoMount(pLocalName='%s', pRemoteName='%s', pParsedRemoteName='%s')\n",
- pLocalName,
- pRemoteName,
- pParsedRemoteName);
- @@ -835,29 +832,29 @@ static DWORD DoMount(
- /* fail if the connection already exists */
- dwLength = NFS41_SYS_MAX_PATH_LEN;
- - result = WNetGetConnection(pLocalName, (LPTSTR)szExisting, &dwLength);
- + result = WNetGetConnection(pLocalName, (LPWSTR)szExisting, &dwLength);
- if (result == NO_ERROR)
- {
- result = ERROR_ALREADY_ASSIGNED;
- - _ftprintf(stderr, TEXT("Mount failed, drive %s is ")
- - TEXT("already assigned to '%s'.\n"),
- + (void)fwprintf(stderr, L"Mount failed, drive %s is "
- + L"already assigned to '%s'.\n",
- pLocalName, szExisting);
- }
- else
- {
- - TCHAR szConnection[NFS41_SYS_MAX_PATH_LEN];
- + wchar_t szConnection[NFS41_SYS_MAX_PATH_LEN];
- DWORD ConnectSize = NFS41_SYS_MAX_PATH_LEN, ConnectResult, Flags = 0;
- ZeroMemory(&NetResource, sizeof(NETRESOURCE));
- NetResource.dwType = RESOURCETYPE_DISK;
- /* drive letter is chosen automatically if lpLocalName == NULL */
- - NetResource.lpLocalName = *pLocalName == TEXT('*') ? NULL : pLocalName;
- + NetResource.lpLocalName = *pLocalName == L'*' ? NULL : pLocalName;
- NetResource.lpRemoteName = pRemoteName;
- /* ignore other network providers */
- - NetResource.lpProvider = TEXT(NFS41_PROVIDER_NAME_A);
- + NetResource.lpProvider = NFS41_PROVIDER_NAME_U;
- /* pass mount options via lpComment */
- if (pOptions->Buffer->Length) {
- - NetResource.lpComment = (LPTSTR)pOptions->Buffer;
- + NetResource.lpComment = (LPWSTR)pOptions->Buffer;
- }
- if (bPersistent)
- @@ -868,11 +865,11 @@ static DWORD DoMount(
- szConnection, &ConnectSize, &ConnectResult);
- if (result == NO_ERROR)
- - _tprintf(TEXT("Successfully mounted '%s' to drive '%s'\n"),
- + (void)wprintf(L"Successfully mounted '%s' to drive '%s'\n",
- pParsedRemoteName, szConnection);
- else
- - _ftprintf(stderr, TEXT("WNetUseConnection(%s, %s) ")
- - TEXT("failed with error code %u.\n"),
- + (void)fwprintf(stderr, L"WNetUseConnection(%s, %s) "
- + L"failed with error code %u.\n",
- pLocalName, pRemoteName, result);
- }
- @@ -880,7 +877,7 @@ static DWORD DoMount(
- }
- static DWORD DoUnmount(
- - IN LPTSTR pLocalName,
- + IN LPWSTR pLocalName,
- IN BOOL bForce)
- {
- DWORD result;
- @@ -891,35 +888,36 @@ static DWORD DoUnmount(
- switch (result)
- {
- case NO_ERROR:
- - _tprintf(TEXT("Drive %s unmounted successfully.\n"), pLocalName);
- + (void)wprintf(L"Drive %s unmounted successfully.\n",
- + pLocalName);
- break;
- case ERROR_NOT_CONNECTED:
- - _ftprintf(stderr, TEXT("Drive %s is not currently ")
- - TEXT("connected.\n"), pLocalName);
- + (void)fwprintf(stderr, L"Drive %s is not currently "
- + L"connected.\n", pLocalName);
- break;
- default:
- - _ftprintf(stderr, TEXT("WNetCancelConnection2(%s) failed ")
- - TEXT("with error code %u.\n"), pLocalName, result);
- + (void)fwprintf(stderr, L"WNetCancelConnection2(%s) failed "
- + L"with error code %u.\n", pLocalName, result);
- break;
- }
- return result;
- }
- static BOOL ParseDriveLetter(
- - IN LPTSTR pArg,
- + IN LPWSTR pArg,
- OUT PTCH pDriveLetter)
- {
- /* accept 'C' or 'C:' */
- - switch (_tcslen(pArg))
- + switch (wcslen(pArg))
- {
- case 2:
- - if (pArg[1] != TEXT(':'))
- + if (pArg[1] != L':')
- return FALSE;
- /* break intentionally missing */
- case 1:
- - if (_istlower(*pArg))
- - *pArg = (TCHAR)_totupper(*pArg);
- - else if (!_istupper(*pArg) && *pArg != TEXT('*'))
- + if (iswlower(*pArg))
- + *pArg = (wchar_t)towupper(*pArg);
- + else if (!iswupper(*pArg) && *pArg != L'*')
- return FALSE;
- *pDriveLetter = *pArg;
- @@ -931,10 +929,10 @@ static BOOL ParseDriveLetter(
- void PrintErrorMessage(
- IN DWORD dwError)
- {
- - LPTSTR lpMsgBuf = NULL;
- + LPWSTR lpMsgBuf = NULL;
- FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
- NULL, dwError, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
- - (LPTSTR)&lpMsgBuf, 0, NULL);
- - _fputts(lpMsgBuf, stderr);
- + (LPWSTR)&lpMsgBuf, 0, NULL);
- + (void)fputws(lpMsgBuf, stderr);
- LocalFree(lpMsgBuf);
- }
- diff --git a/mount/options.c b/mount/options.c
- index 73d92ce..eb2d84a 100644
- --- a/mount/options.c
- +++ b/mount/options.c
- @@ -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
- @@ -21,7 +22,6 @@
- #include <crtdbg.h>
- #include <Windows.h>
- -#include <tchar.h>
- #include <strsafe.h>
- #include <stdio.h>
- @@ -55,19 +55,18 @@ void FreeMountOptions(
- }
- BOOL FindOptionByName(
- - IN LPCTSTR Name,
- + IN LPCWSTR Name,
- IN PMOUNT_OPTION_LIST Options,
- OUT PFILE_FULL_EA_INFORMATION* ppOption)
- {
- PFILE_FULL_EA_INFORMATION Current =
- (PFILE_FULL_EA_INFORMATION)Options->Buffer->Buffer;
- - ULONG NameLength = (ULONG)_tcslen(Name) * sizeof(TCHAR);
- + ULONG NameLength = (ULONG)wcslen(Name) * sizeof(wchar_t);
- for (;;)
- {
- - if (Current->EaNameLength == NameLength &&
- - _tcscmp((LPTSTR)Current->EaName, Name) == 0)
- - {
- + if ((Current->EaNameLength == NameLength) &&
- + (!wcscmp((LPTSTR)Current->EaName, Name))) {
- *ppOption = Current;
- return TRUE;
- }
- @@ -84,7 +83,7 @@ static FORCEINLINE ULONG EaBufferSize(
- IN USHORT ValueSize)
- {
- ULONG Size = sizeof(ULONG) + 2 * sizeof(UCHAR) + sizeof(USHORT)
- - + NameSize + ValueSize + sizeof(TCHAR);
- + + NameSize + ValueSize + sizeof(wchar_t);
- /* extended attributes require ULONG alignment;
- * see documentation for IoCheckEaBufferValidity() */
- return ( (Size + (sizeof(ULONG)-1)) / sizeof(ULONG) ) * sizeof(ULONG);
- @@ -99,20 +98,20 @@ static FORCEINLINE ULONG EaBufferNextOffset(
- }
- BOOL InsertOption(
- - IN LPCTSTR Name,
- - IN LPCTSTR Value,
- + IN LPCWSTR Name,
- + IN LPCWSTR Value,
- IN OUT PMOUNT_OPTION_LIST Options)
- {
- PFILE_FULL_EA_INFORMATION Current;
- - UCHAR NameLen = (UCHAR)_tcslen(Name) * sizeof(TCHAR);
- - USHORT ValueLen = (USHORT)_tcslen(Value) * sizeof(TCHAR);
- + UCHAR NameLen = (UCHAR)wcslen(Name) * sizeof(wchar_t);
- + USHORT ValueLen = (USHORT)wcslen(Value) * sizeof(wchar_t);
- ULONG SpaceRequired = EaBufferSize(NameLen, ValueLen);
- /*
- * Filter "port" option, as it's value has already been encoded
- * in the hostname as hostport
- */
- - if (!_tcscmp(Name, L"port")) {
- + if (!wcscmp(Name, L"port")) {
- return TRUE;
- }
- @@ -123,19 +122,19 @@ BOOL InsertOption(
- #if 0
- /* don't allow duplicate options */
- if (FindOptionByName(Name, Options, &Current)) {
- - _ftprintf(stderr, TEXT("Found a duplicate option ")
- - TEXT("'%s%s%s' while parsing '%s%s%s'.\n"),
- + (void)fwprintf(stderr, L"Found a duplicate option "
- + L"'%s%s%s' while parsing '%s%s%s'.\n",
- (PTCH)Current->EaName,
- - Current->EaValueLength ? TEXT("=") : TEXT(""),
- - (PTCH)(Current->EaName + Current->EaNameLength + sizeof(TCHAR)),
- - Name, ValueLen ? TEXT("=") : Value, Value);
- + Current->EaValueLength ? L"=" : L"",
- + (PTCH)(Current->EaName + Current->EaNameLength + sizeof(wchar_t)),
- + Name, ValueLen ? L"=" : Value, Value);
- return FALSE;
- }
- #endif
- /* fail if we're out of space */
- if (SpaceRequired > Options->Remaining) {
- - _ftprintf(stderr, TEXT("Out of space for options!\n"));
- + (void)fwprintf(stderr, L"Out of space for options!\n");
- return FALSE;
- }
- @@ -149,18 +148,18 @@ BOOL InsertOption(
- Current->EaNameLength = NameLen;
- if (NameLen) /* copy attribute name */
- StringCbCopy((LPTSTR)Current->EaName,
- - NameLen + sizeof(TCHAR), Name);
- + NameLen + sizeof(wchar_t), Name);
- Current->EaValueLength = ValueLen;
- if (ValueLen) /* copy attribute value */
- - StringCbCopy((LPTSTR)(Current->EaName + NameLen + sizeof(TCHAR)),
- - ValueLen + sizeof(TCHAR), Value);
- + StringCbCopy((LPTSTR)(Current->EaName + NameLen + sizeof(wchar_t)),
- + ValueLen + sizeof(wchar_t), Value);
- Current->Flags = 0;
- Current->NextEntryOffset = EaBufferNextOffset(Options->Current);
- Options->Buffer->Length = (ULONG)(
- - (Current->EaName + NameLen + ValueLen + 2 * sizeof(TCHAR))
- + (Current->EaName + NameLen + ValueLen + 2 * sizeof(wchar_t))
- - Options->Buffer->Buffer );
- Options->Remaining -= SpaceRequired;
- return TRUE;
- @@ -169,30 +168,30 @@ BOOL InsertOption(
- void RecursivePrintEaInformation(
- IN PFILE_FULL_EA_INFORMATION EA)
- {
- - _tprintf(
- - TEXT("----------------------\n")
- - TEXT("Alignment: %5lu\n")
- - TEXT("NextEntryOffset: %5lu\n")
- - TEXT("Flags: %5u\n")
- - TEXT("EaNameLength: %5u\n")
- - TEXT("EaValueLength: %5u\n")
- - TEXT("EaName: %16ls\n")
- - TEXT("EaValue: %16ls\n\n"),
- + (void)wprintf(
- + L"----------------------\n"
- + L"Alignment: %5lu\n"
- + L"NextEntryOffset: %5lu\n"
- + L"Flags: %5u\n"
- + L"EaNameLength: %5u\n"
- + L"EaValueLength: %5u\n"
- + L"EaName: %16ls\n"
- + L"EaValue: %16ls\n\n",
- (unsigned long)((ULONG_PTR)EA % sizeof(ULONG)),
- EA->NextEntryOffset,
- EA->Flags,
- EA->EaNameLength,
- EA->EaValueLength,
- (LPTSTR)EA->EaName,
- - (LPTSTR)(EA->EaName + EA->EaNameLength + sizeof(TCHAR)));
- + (LPTSTR)(EA->EaName + EA->EaNameLength + sizeof(wchar_t)));
- if (EA->NextEntryOffset)
- RecursivePrintEaInformation((PFILE_FULL_EA_INFORMATION)
- ((PBYTE)EA + EA->NextEntryOffset));
- }
- -static const TCHAR COMMA_T = TEXT(',');
- -static const TCHAR EQUAL_T = TEXT('=');
- +static const wchar_t COMMA_T = L',';
- +static const wchar_t EQUAL_T = L'=';
- BOOL ParseMountOptions(
- IN LPTSTR Arg,
- @@ -203,18 +202,18 @@ BOOL ParseMountOptions(
- pos = Arg;
- for (;;)
- {
- - comma = _tcschr(pos, COMMA_T);
- + comma = wcschr(pos, COMMA_T);
- if (comma)
- {
- if (comma == pos)
- goto out_empty_option;
- *comma = 0;
- }
- - else if (_tcslen(pos) == 0)
- + else if (wcslen(pos) == 0)
- goto out_empty_option;
- /* accept 'option=value' or 'option' */
- - equals = _tcschr(pos, EQUAL_T);
- + equals = wcschr(pos, EQUAL_T);
- if (equals)
- {
- if (equals == pos)
- @@ -223,7 +222,7 @@ BOOL ParseMountOptions(
- if (!InsertOption(pos, equals + 1, Options))
- return FALSE;
- }
- - else if (!InsertOption(pos, TEXT(""), Options))
- + else if (!InsertOption(pos, L"", Options))
- return FALSE;
- if (comma == NULL)
- @@ -237,7 +236,8 @@ BOOL ParseMountOptions(
- return TRUE;
- out_empty_option:
- - _ftprintf(stderr, TEXT("Found an empty option while ")
- - TEXT("reading mount options at '%s'.\n"), pos);
- + (void)fwprintf(stderr, L"Found an empty option while "
- + L"reading mount options at '%s'.\n",
- + pos);
- return FALSE;
- }
- diff --git a/sys/nfs41_driver.h b/sys/nfs41_driver.h
- index 01e34e2..6f62300 100644
- --- a/sys/nfs41_driver.h
- +++ b/sys/nfs41_driver.h
- @@ -26,7 +26,6 @@
- #define NFS41_SHADOW_DEVICE_NAME L"\\??\\nfs41_driver"
- #define NFS41_USER_DEVICE_NAME L"\\\\.\\nfs41_driver"
- #define NFS41_USER_DEVICE_NAME_A "\\\\.\\nfs41_driver"
- -#define NFS41_PROVIDER_NAME_A "NFS41 Network"
- #define NFS41_PROVIDER_NAME_U L"NFS41 Network"
- #define NFS41_PIPE_NAME L"\\Device\\nfs41_pipe"
- --
- 2.45.1
- From 8566e5ef231b73945ac77450a8bedd93f6d56f6d Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Mon, 15 Jul 2024 15:43:27 +0200
- Subject: [PATCH 08/11] mount: Put single-quotes around '%s' in output
- Put single-quotes around '%s' in output.
- Reported-by: Josh Hurst <joshhurst@gmail.com>
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- mount/mount.c | 10 +++++-----
- 1 file changed, 5 insertions(+), 5 deletions(-)
- diff --git a/mount/mount.c b/mount/mount.c
- index d4a6680..a649641 100644
- --- a/mount/mount.c
- +++ b/mount/mount.c
- @@ -836,7 +836,7 @@ static DWORD DoMount(
- if (result == NO_ERROR)
- {
- result = ERROR_ALREADY_ASSIGNED;
- - (void)fwprintf(stderr, L"Mount failed, drive %s is "
- + (void)fwprintf(stderr, L"Mount failed, drive '%s' is "
- L"already assigned to '%s'.\n",
- pLocalName, szExisting);
- }
- @@ -868,7 +868,7 @@ static DWORD DoMount(
- (void)wprintf(L"Successfully mounted '%s' to drive '%s'\n",
- pParsedRemoteName, szConnection);
- else
- - (void)fwprintf(stderr, L"WNetUseConnection(%s, %s) "
- + (void)fwprintf(stderr, L"WNetUseConnection('%s', '%s') "
- L"failed with error code %u.\n",
- pLocalName, pRemoteName, result);
- }
- @@ -888,15 +888,15 @@ static DWORD DoUnmount(
- switch (result)
- {
- case NO_ERROR:
- - (void)wprintf(L"Drive %s unmounted successfully.\n",
- + (void)wprintf(L"Drive '%s' unmounted successfully.\n",
- pLocalName);
- break;
- case ERROR_NOT_CONNECTED:
- - (void)fwprintf(stderr, L"Drive %s is not currently "
- + (void)fwprintf(stderr, L"Drive '%s' is not currently "
- L"connected.\n", pLocalName);
- break;
- default:
- - (void)fwprintf(stderr, L"WNetCancelConnection2(%s) failed "
- + (void)fwprintf(stderr, L"WNetCancelConnection2('%s') failed "
- L"with error code %u.\n", pLocalName, result);
- break;
- }
- --
- 2.45.1
- From 830f5a140c459aa157b9f47726f52bcc50e94eba Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Mon, 15 Jul 2024 15:50:36 +0200
- Subject: [PATCH 09/11] mount: Remove "FIXME" comment about -o overriding
- defaults from nfs://-URLs.
- Remove obsolete "FIXME" comment about -o overriding defaults from
- nfs://-URLs.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- mount/mount.c | 8 ++------
- 1 file changed, 2 insertions(+), 6 deletions(-)
- diff --git a/mount/mount.c b/mount/mount.c
- index a649641..694ef0f 100644
- --- a/mount/mount.c
- +++ b/mount/mount.c
- @@ -554,13 +554,9 @@ static DWORD ParseRemoteName(
- const char *pvalue;
- /*
- - * FIXME: Values added here based on URL parameters
- - * should be added at the front of the list of options,
- + * Values added here based on URL parameters
- + * are added at the front of the list of options,
- * so users can override the nfs://-URL given default.
- - * Right now this does not work, e.g.
- - * $ nfs_mount.exe -o rw nfs://foo//bar?ro=1 # will
- - * result in a read-only mount, while the expectation
- - * is that -o overrides URL settings.
- */
- for (pi = 0; pi < uctx->num_parameters ; pi++) {
- pname = uctx->parameters[pi].name;
- --
- 2.45.1
- From fa252ec057414db0d7e97ec4c6c1f7b5cbd20930 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Mon, 15 Jul 2024 16:06:12 +0200
- Subject: [PATCH 10/11] cygwin: Update README.bintarball.txt
- Update README.bintarball.txt
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- cygwin/README.bintarball.txt | 38 +++++++++++++++++++++---------------
- 1 file changed, 22 insertions(+), 16 deletions(-)
- diff --git a/cygwin/README.bintarball.txt b/cygwin/README.bintarball.txt
- index 1596066..8101f2b 100644
- --- a/cygwin/README.bintarball.txt
- +++ b/cygwin/README.bintarball.txt
- @@ -24,7 +24,7 @@ NFSv4.1 client and filesystem driver for Windows 10/11
- - Support for custom ports (NFSv4 defaults to TCP port 2049, this
- client can use different ports per mount)
- -- Support for nfs://-URL
- +- Support for nfs://-URLs
- * Why ? nfs://-URLs are crossplatform, portable and Character-Encoding
- independent descriptions of NFSv4 server resources (exports).
- - including custom ports and raw IPv6 addresses
- @@ -33,12 +33,14 @@ NFSv4.1 client and filesystem driver for Windows 10/11
- - Support ssh forwarding, e.g. mounting NFSv4 filesystems via ssh
- tunnel
- -- Support for long paths (up to 4096 bytes), no Windows MAXPATH limit
- -- Support for NFSv4 public mounts (i.e. use the NFSv4 public file handle
- - lookup protocol via $ nfs_mount -o public ... #)
- +- Support for long paths (up to 4096 bytes), no Windows MAXPATH limit
- - Unicode support
- + - File names can use any Unicode character supported by
- + the NFS server's filesystem.
- + - nfs://-URLs can be used to mount filesystems with non-ASCII
- + characters in the mount path, independent of current locale.
- - UNC paths
- - IPv6 support in UNC paths
- @@ -50,11 +52,14 @@ NFSv4.1 client and filesystem driver for Windows 10/11
- - IPv6 address within '[', ']'
- (will be converted to *.ipv6-literal.net)
- -- Windows ACLs
- +- Windows ACLs <---> NFSv4 ACL translation
- - Win32 C:\Windows\system32\icacls.exe
- - Cygwin /usr/bin/setfacl+/usr/bin/getfacl
- - Windows Explorer ACL dialog
- +- Support for NFSv4 public mounts (i.e. use the NFSv4 public file handle
- + lookup protocol via $ nfs_mount -o public ... #)
- +
- - SFU/Cygwin support, including:
- - uid/gid
- - Cygwin symlinks
- @@ -137,24 +142,25 @@ echo %PROCESSOR_ARCHITECTURE%
- # If you get any other value then this is a (documentation) bug.
- - Cygwin 64bit can be installed like this:
- ----- snip ----
- +# ---- snip ----
- # Install Cygwin 64bit on Windows 64bit with packages required by "ms-nfs41-client"
- # (Windows NFSv4.1 client):
- # 1. Get installer from https://cygwin.com/setup-x86_64.exe
- curl --remote-name "https://www.cygwin.com/setup-x86_64.exe"
- # 2. Run installer with these arguments:
- setup-x86_64.exe -q --site "https://mirrors.kernel.org/sourceware/cygwin" -P cygwin,cygwin-devel,cygrunsrv,cygutils,cygutils-extra,bash,bzip2,coreutils,getent,gdb,grep,hostname,less,libiconv,libiconv2,pax,pbzip2,procps-ng,sed,tar,time,util-linux,wget,libnfs-utils,make,git,dos2unix,unzip
- +# ---- snip ----
- - Cygwin 32bit can be installed like this:
- ----- snip ----
- +# ---- snip ----
- # Install Cygwin 32bit on Windows 32bit with packages required by "ms-nfs41-client"
- # (Windows NFSv4.1 client):
- # 1. Get installer from https://www.cygwin.com/setup-x86.exe
- curl --remote-name "https://www.cygwin.com/setup-x86.exe"
- # 2. Run installer with these arguments:
- setup-x86.exe --allow-unsupported-windows -q --no-verify --site "http://ctm.crouchingtigerhiddenfruitbat.org/pub/cygwin/circa/2022/11/23/063457" -P cygwin,cygwin-devel,cygrunsrv,cygutils,cygutils-extra,bash,bzip2,coreutils,getent,gdb,grep,hostname,less,libiconv,libiconv2,pax,pbzip2,procps-ng,sed,tar,time,util-linux,wget,libnfs-utils,make,git,dos2unix,unzip
- ----- snip ----
- +# ---- snip ----
- #
- @@ -307,26 +313,26 @@ $ /sbin/nfs_mount
- - On Windows on a NFSv4 filesystem:
- $ icacls myhorribledata.txt /grant "siegfried_wulsch:WD" #
- - On Linux NFSv4 clients you will then see this:
- - ---- snip ----
- + # ---- snip ----
- $ nfs4_getfacl myhorribledata.txt
- A::OWNER@:rwatTcCy
- A::siegfried_wulsch@global.loc:rwatcy
- A::GROUP@:rtcy
- A::EVERYONE@:rtcy
- - ---- snip ----
- + # ---- snip ----
- * Example 2 (assuming that Windows, Linux NFSv4 client and NFSv4
- server have a group "cygwingrp2"):
- - On Windows on a NFSv4 filesystem:
- $ icacls myhorribledata.txt /grant "cygwingrp2:(WDAC)" /t /c #
- - On Linux NFSv4 clients you will then see this:
- - ---- snip ----
- + # ---- snip ----
- $ nfs4_getfacl myhorribledata.txt
- A::OWNER@:rwatTcCy
- A::GROUP@:rtcy
- A:g:cygwingrp2@global.loc:rtcy
- A::EVERYONE@:rtcy
- - ---- snip ----
- + # ---- snip ----
- - nfs_mount.exe vs. reserved ports:
- By default the NFSv4 server on Solaris, Illumos, Linux
- @@ -396,7 +402,7 @@ $ /sbin/nfs_mount
- - Bug: Subversion checkout can fail with
- "sqlite[S11]: database disk image is malformed" like this:
- - ---- snip ----
- + # ---- snip ----
- $ svn checkout https://svn.FreeBSD.org/base/head/share/man
- A man/man4
- A man/man4/tcp.4
- @@ -419,7 +425,7 @@ $ /sbin/nfs_mount
- svn: E200030: sqlite[S11]: database disk image is malformed
- svn: E200030: sqlite[S11]: database disk image is malformed
- svn: E200030: sqlite[S11]: database disk image is malformed
- - ---- snip ----
- + # ---- snip ----
- Workaround is to mount the NFS filesystem with the "writethru"
- option, e.g.
- $ /sbin/nfs_mount -o rw,writethru 'j' derfwpc5131:/export/home/rmainz #
- @@ -450,10 +456,10 @@ $ /sbin/nfs_mount
- (for NFSv4 default TCP port "2049", replace "2049" with the
- desired port if you use a custom port ; use "ipconfig" to find the
- correct interface name, in this case "Ethernet0"):
- - ---- snip ----
- + # ---- snip ----
- $ nfsv4port=2049 ; /cygdrive/c/Program\ Files/Wireshark/tshark \
- -f "port $nfsv4port" -d "tcp.port==${nfsv4port},rpc" -i Ethernet0
- - ---- snip ----
- + # ---- snip ----
- If you are running inside a VMware VM on a Linux host it
- might require $ chmod a+rw /dev/vmnet0 # on VMware host, so that
- --
- 2.45.1
- From 7dd9ab5cd47b6866bc1353aefeed99f62dd75fc3 Mon Sep 17 00:00:00 2001
- From: Cedric Blancher <cedric.blancher@gmail.com>
- Date: Mon, 15 Jul 2024 16:56:34 +0200
- Subject: [PATCH 11/11] daemon,libtirpc: Put #define(arg) arg into brackets
- Put #define(arg) arg into brackets.
- Signed-off-by: Roland Mainz <roland.mainz@nrubsig.org>
- ---
- daemon/ea.c | 3 ++-
- daemon/nfs41_const.h | 6 +++---
- libtirpc/src/svc.c | 2 +-
- libtirpc/src/xdr_float.c | 2 +-
- libtirpc/tirpc/wintirpc.h | 4 ++--
- 5 files changed, 9 insertions(+), 8 deletions(-)
- diff --git a/daemon/ea.c b/daemon/ea.c
- index 2c94530..17b14c7 100644
- --- a/daemon/ea.c
- +++ b/daemon/ea.c
- @@ -317,7 +317,8 @@ out_free:
- goto out;
- }
- -#define ALIGNED_EASIZE(len) (align4(sizeof(FILE_GET_EA_INFORMATION) + len))
- +#define ALIGNED_EASIZE(len) \
- + (align4(sizeof(FILE_GET_EA_INFORMATION) + (len)))
- static uint32_t calculate_ea_list_length(
- IN const unsigned char *position,
- diff --git a/daemon/nfs41_const.h b/daemon/nfs41_const.h
- index 9326d5c..c63931d 100644
- --- a/daemon/nfs41_const.h
- +++ b/daemon/nfs41_const.h
- @@ -227,9 +227,9 @@ enum nfsstat4 {
- NFS4ERR_XATTR2BIG = 10096
- };
- -#define MAKE_WORD0(XXX) (1 << XXX)
- -#define MAKE_WORD1(XXX) (1 << (XXX-32))
- -#define MAKE_WORD2(XXX) (1 << (XXX-64))
- +#define MAKE_WORD0(XXX) (1 << (XXX))
- +#define MAKE_WORD1(XXX) (1 << ((XXX)-32))
- +#define MAKE_WORD2(XXX) (1 << ((XXX)-64))
- enum {
- /*
- diff --git a/libtirpc/src/svc.c b/libtirpc/src/svc.c
- index c975286..7bfc1cc 100644
- --- a/libtirpc/src/svc.c
- +++ b/libtirpc/src/svc.c
- @@ -60,7 +60,7 @@
- #define version_keepquiet(xp) ((u_long)(xp)->xp_p3 & SVC_VERSQUIET)
- #ifndef max
- -#define max(a, b) (a > b ? a : b)
- +#define max(a, b) ((a) > (b) ? (a) : (b))
- #endif
- /*
- diff --git a/libtirpc/src/xdr_float.c b/libtirpc/src/xdr_float.c
- index 8f2426f..18551f2 100644
- --- a/libtirpc/src/xdr_float.c
- +++ b/libtirpc/src/xdr_float.c
- @@ -178,7 +178,7 @@ struct vax_double {
- #define VAX_DBL_BIAS 0x81
- #define IEEE_DBL_BIAS 0x3ff
- -#define MASK(nbits) ((1 << nbits) - 1)
- +#define MASK(nbits) ((1 << (nbits)) - 1)
- static struct dbl_limits {
- struct vax_double d;
- diff --git a/libtirpc/tirpc/wintirpc.h b/libtirpc/tirpc/wintirpc.h
- index 62142ca..31df285 100644
- --- a/libtirpc/tirpc/wintirpc.h
- +++ b/libtirpc/tirpc/wintirpc.h
- @@ -70,8 +70,8 @@
- #define getpid _getpid
- #define bcmp memcmp
- -#define bcopy(d,s,l) memcpy(d,s,l)
- -#define bzero(d,s) memset(d,0,s)
- +#define bcopy(d,s,l) memcpy((d),(s),(l))
- +#define bzero(d,s) memset((d),0,(s))
- #define strtok_r strtok_s
- #define poll WSAPoll
- --
- 2.45.1
msnfs41client: PUBFH support, cleanup+docs+misc, 2024-07-15
Posted by Anonymous on Mon 15th Jul 2024 16:19
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.