- From ba4be7bad26b57f19707d7d95945f2e0724ff3b0 Mon Sep 17 00:00:00 2001
- From: Dan Shelton <dan.f.shelton@gmail.com>
- Date: Wed, 17 Jul 2024 16:33:41 +0200
- Subject: [PATCH 1/6] mount: Provide --long options for nfs_mount.exe
- Provide --long options for nfs_mount.exe
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- mount/mount.c | 63 +++++++++++++++++++++++++++++++--------------------
- 1 file changed, 39 insertions(+), 24 deletions(-)
- diff --git a/mount/mount.c b/mount/mount.c
- index 4fbc670..9758e1c 100644
- --- a/mount/mount.c
- +++ b/mount/mount.c
- @@ -79,18 +79,17 @@ static VOID PrintUsage(LPWSTR pProcess)
- "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-h, --help, /?\thelp\n"
- + "\t-d, --unmount\tunmount\n"
- + "\t-f, --force\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)"
- + "\t-t, --types <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"
- + "\t-p, --persistent\tmake the mount persist over reboots\n"
- + "\t-o. --options <comma-separated mount options>\n"
- + "\t-r, --read-only\tAlias for -o ro (read-only mount)\n"
- + "\t-w, --rw, --read-write\tAlias for -o rw (read-write mount)\n"
- "* Mount options:\n"
- "\tpublic\tconnect to the server using the public file handle lookup protocol.\n"
- @@ -189,20 +188,30 @@ int __cdecl wmain(int argc, wchar_t *argv[])
- {
- if (argv[i][0] == L'-')
- {
- - if (!wcscmp(argv[i], L"-h")) { /* help */
- + /* help */
- + if ((!wcscmp(argv[i], L"-h")) ||
- + (!wcscmp(argv[i], L"--help"))) {
- PrintUsage(argv[0]);
- goto out;
- }
- - else if (!wcscmp(argv[i], L"-d")) { /* unmount */
- + /* unmount */
- + else if ((!wcscmp(argv[i], L"-d")) ||
- + (!wcscmp(argv[i], L"--unmount"))) {
- bUnmount = TRUE;
- }
- - else if (!wcscmp(argv[i], L"-f")) { /* force unmount */
- + /* force unmount */
- + else if ((!wcscmp(argv[i], L"-f")) ||
- + (!wcscmp(argv[i], L"--force"))) {
- bForceUnmount = TRUE;
- }
- - else if (!wcscmp(argv[i], L"-p")) { /* persistent */
- + /* persistent */
- + else if ((!wcscmp(argv[i], L"-p")) ||
- + (!wcscmp(argv[i], L"--persistent"))) {
- bPersistent = TRUE;
- }
- - else if (!wcscmp(argv[i], L"-o")) { /* mount option */
- + /* mount option */
- + else if ((!wcscmp(argv[i], L"-o")) ||
- + (!wcscmp(argv[i], L"--options"))) {
- ++i;
- if (i >= argc)
- {
- @@ -289,7 +298,9 @@ opt_o_argv_i_again:
- goto opt_o_argv_i_again;
- }
- }
- - else if (!wcscmp(argv[i], L"-r")) { /* mount option */
- + /* mount option */
- + else if ((!wcscmp(argv[i], L"-r")) ||
- + (!wcscmp(argv[i], L"--read-only"))) {
- if (num_mntopts >= (MAX_MNTOPTS-1)) {
- result = ERROR_BAD_ARGUMENTS;
- (void)fwprintf(stderr, L"Too many options.\n\n");
- @@ -298,7 +309,10 @@ opt_o_argv_i_again:
- mntopts[num_mntopts++] = L"ro";
- }
- - else if (!wcscmp(argv[i], L"-w")) { /* mount option */
- + /* mount option */
- + else if ((!wcscmp(argv[i], L"-w")) ||
- + (!wcscmp(argv[i], L"--rw")) ||
- + (!wcscmp(argv[i], L"--read-write"))) {
- if (num_mntopts >= (MAX_MNTOPTS-1)) {
- result = ERROR_BAD_ARGUMENTS;
- (void)fwprintf(stderr, L"Too many options.\n\n");
- @@ -313,8 +327,8 @@ opt_o_argv_i_again:
- * $ mount.nfs4 -t nfs ... # compatiblity
- */
- else if ((!wcscmp(argv[i], L"-F")) ||
- - (!wcscmp(argv[i], L"-t")))
- - {
- + (!wcscmp(argv[i], L"-t")) ||
- + (!wcscmp(argv[i], L"--types"))) {
- ++i;
- if (i >= argc)
- {
- @@ -338,23 +352,24 @@ opt_o_argv_i_again:
- L"'%s', disregarding.\n",
- argv[i]);
- }
- + /* Windows-style "nfs_mount /?" help */
- else if (!wcscmp(argv[i], L"/?")) {
- - /* Windows-style "nfs_mount /?" help */
- PrintUsage(argv[0]);
- goto out;
- }
- - else if (pLocalName == NULL) /* drive letter */
- - {
- + /* drive letter */
- + else if (pLocalName == NULL) {
- pLocalName = argv[i];
- }
- - else if (pRemoteName == NULL) /* remote path */
- - {
- + /* remote path */
- + else if (pRemoteName == NULL) {
- pRemoteName = argv[i];
- }
- - else
- + else {
- (void)fwprintf(stderr, L"Unrecognized argument "
- L"'%s', disregarding.\n",
- argv[i]);
- + }
- }
- /* validate local drive letter */
- --
- 2.45.1
- From b461a0ad45b8bac26bd05638de491618dce49e3c Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Wed, 17 Jul 2024 17:10:30 +0200
- Subject: [PATCH 2/6] daemon: Increase name cache size from 8M to 32M
- Increase name cache size from 8M to 32M, to better deal
- with highly parallel workloads.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- daemon/name_cache.c | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
- diff --git a/daemon/name_cache.c b/daemon/name_cache.c
- index 9c389a6..b95ac5d 100644
- --- a/daemon/name_cache.c
- +++ b/daemon/name_cache.c
- @@ -41,8 +41,8 @@ enum {
- #define NAME_CACHE_EXPIRATION 20 /* TODO: get from configuration */
- -/* allow up to 8M of memory for name and attribute cache entries */
- -#define NAME_CACHE_MAX_SIZE (8*1024*1024L)
- +/* allow up to 32M of memory for name and attribute cache entries */
- +#define NAME_CACHE_MAX_SIZE (32*1024*1024L)
- /* negative lookup caching
- *
- --
- 2.45.1
- From 79dd9bd66ecf0dda180570ce826ac862699ddd4f Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Wed, 17 Jul 2024 17:18:21 +0200
- Subject: [PATCH 3/6] daemon: Increase default name cache timeout from 20s
- seconds to 30s.
- Increase default name cache timeout from 20 seconds to 30 seconds.
- This should really be a mount option.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- daemon/name_cache.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
- diff --git a/daemon/name_cache.c b/daemon/name_cache.c
- index b95ac5d..c73e8d5 100644
- --- a/daemon/name_cache.c
- +++ b/daemon/name_cache.c
- @@ -39,7 +39,7 @@ enum {
- };
- -#define NAME_CACHE_EXPIRATION 20 /* TODO: get from configuration */
- +#define NAME_CACHE_EXPIRATION 30 /* TODO: get from configuration */
- /* allow up to 32M of memory for name and attribute cache entries */
- #define NAME_CACHE_MAX_SIZE (32*1024*1024L)
- --
- 2.45.1
- From 2f63dcc073564e82f9ed28e38413765b0e56679d Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Thu, 18 Jul 2024 16:16:00 +0200
- Subject: [PATCH 4/6] sys: Fix |DWORD|vs|LONG| option parsing+enforce min/max
- values for numeric mount options
- Fix |DWORD|vs|LONG| option parsing, and enforce min/max values for
- numeric mount options
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- sys/nfs41_driver.c | 63 +++++++++++++++++++++++++++++++++-------------
- 1 file changed, 46 insertions(+), 17 deletions(-)
- diff --git a/sys/nfs41_driver.c b/sys/nfs41_driver.c
- index de5383f..8a92bdb 100644
- --- a/sys/nfs41_driver.c
- +++ b/sys/nfs41_driver.c
- @@ -2896,30 +2896,59 @@ NTSTATUS nfs41_MountConfig_ParseBoolean(
- return status;
- }
- -NTSTATUS nfs41_MountConfig_ParseDword(
- +
- +/* Parse |signed| integer value */
- +static
- +NTSTATUS nfs41_MountConfig_ParseINT64(
- IN PFILE_FULL_EA_INFORMATION Option,
- IN PUNICODE_STRING usValue,
- - OUT PDWORD Value,
- - IN DWORD Minimum,
- - IN DWORD Maximum)
- + OUT INT64 *outValue,
- + IN INT64 Minimum,
- + IN INT64 Maximum)
- {
- - NTSTATUS status = STATUS_INVALID_PARAMETER;
- + NTSTATUS status;
- + LONG64 Value = 0;
- LPWSTR Name = (LPWSTR)Option->EaName;
- - if (Option->EaValueLength) {
- - status = RtlUnicodeStringToInteger(usValue, 0, Value);
- + if (!Option->EaValueLength)
- + return STATUS_INVALID_PARAMETER;
- +
- + status = RtlUnicodeStringToInt64(usValue, 0, &Value, NULL);
- + if (status == STATUS_SUCCESS) {
- + if ((Value < Minimum) || (Value > Maximum))
- + status = STATUS_INVALID_PARAMETER;
- +
- if (status == STATUS_SUCCESS) {
- -#ifdef IMPOSE_MINMAX_RWSIZES
- - if (*Value < Minimum)
- - *Value = Minimum;
- - if (*Value > Maximum)
- - *Value = Maximum;
- - DbgP(" '%ls' -> '%wZ' -> %lu\n", Name, usValue, *Value);
- -#endif
- + *outValue = Value;
- }
- - else
- - print_error("Failed to convert '%s'='%wZ' to unsigned long.\n",
- - Name, usValue);
- + }
- + else {
- + print_error("nfs41_MountConfig_ParseINT64: "
- + "Failed to convert '%s'='%wZ' to unsigned long.\n",
- + Name, usValue);
- + }
- +
- + return status;
- +}
- +
- +/* Parse |unsigned| integer value */
- +static
- +NTSTATUS nfs41_MountConfig_ParseDword(
- + IN PFILE_FULL_EA_INFORMATION Option,
- + IN PUNICODE_STRING usValue,
- + OUT PDWORD outValue,
- + IN DWORD Minimum,
- + IN DWORD Maximum)
- +{
- + INT64 tmpValue;
- + NTSTATUS status;
- +
- + status = nfs41_MountConfig_ParseINT64(
- + Option, usValue,
- + &tmpValue, Minimum, Maximum);
- +
- + if (status == STATUS_SUCCESS) {
- + *outValue = (DWORD)tmpValue;
- }
- return status;
- --
- 2.45.1
- From 64416ec401405fe0adc25affd42768e9124e808a Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Thu, 18 Jul 2024 16:27:04 +0200
- Subject: [PATCH 5/6] daemon: Make some |*_cmp()| functions |static|
- Make some |*_cmp()| functions |static|
- Reported-by: Josh Hurst <joshhurst@gmail.com>
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- daemon/name_cache.c | 4 ++--
- daemon/nfs41_client.c | 2 +-
- 2 files changed, 3 insertions(+), 3 deletions(-)
- diff --git a/daemon/name_cache.c b/daemon/name_cache.c
- index c73e8d5..4b62193 100644
- --- a/daemon/name_cache.c
- +++ b/daemon/name_cache.c
- @@ -111,7 +111,7 @@ struct attr_cache {
- struct list_entry free_entries;
- };
- -int attr_cmp(struct attr_cache_entry *lhs, struct attr_cache_entry *rhs)
- +static int attr_cmp(struct attr_cache_entry *lhs, struct attr_cache_entry *rhs)
- {
- return lhs->fileid < rhs->fileid ? -1 : lhs->fileid > rhs->fileid;
- }
- @@ -412,7 +412,7 @@ struct name_cache_entry {
- };
- #define NAME_ENTRY_SIZE sizeof(struct name_cache_entry)
- -int name_cmp(struct name_cache_entry *lhs, struct name_cache_entry *rhs)
- +static int name_cmp(struct name_cache_entry *lhs, struct name_cache_entry *rhs)
- {
- const int diff = rhs->component_len - lhs->component_len;
- return diff ? diff : strncmp(lhs->component, rhs->component, lhs->component_len);
- diff --git a/daemon/nfs41_client.c b/daemon/nfs41_client.c
- index b99e545..355eb06 100644
- --- a/daemon/nfs41_client.c
- +++ b/daemon/nfs41_client.c
- @@ -254,7 +254,7 @@ struct mac_entry {
- ULONG length;
- };
- -int mac_cmp(struct mac_entry *lhs, struct mac_entry *rhs)
- +static int mac_cmp(struct mac_entry *lhs, struct mac_entry *rhs)
- {
- const int diff = rhs->length - lhs->length;
- return diff ? diff : strncmp((const char*)lhs->address,
- --
- 2.45.1
- From 79da3c97ec17d1dc59212f9be01d10392c943540 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Thu, 18 Jul 2024 16:43:02 +0200
- Subject: [PATCH 6/6] sys: Driver code should use |NTSTATUS()| to test for
- success
- Driver code should use |NTSTATUS()| to test for success, not
- |(status == STATUS_SUCCESS)|
- Reported-by: Josh Hurst <joshhurst@gmail.com>
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- sys/nfs41_driver.c | 18 ++++++++++--------
- 1 file changed, 10 insertions(+), 8 deletions(-)
- diff --git a/sys/nfs41_driver.c b/sys/nfs41_driver.c
- index 8a92bdb..50f7342 100644
- --- a/sys/nfs41_driver.c
- +++ b/sys/nfs41_driver.c
- @@ -1464,7 +1464,7 @@ NTSTATUS handle_upcall(
- #else
- status = SeImpersonateClientEx(entry->psec_ctx, NULL);
- #endif /* NFS41_DRIVER_STABILITY_HACKS */
- - if (status != STATUS_SUCCESS) {
- + if (!NT_SUCCESS(status)) {
- print_error("handle_upcall: "
- "SeImpersonateClientEx() failed 0x%x\n", status);
- goto out;
- @@ -1532,8 +1532,10 @@ NTSTATUS handle_upcall(
- print_error("Unknown nfs41 ops %d\n", entry->opcode);
- }
- - if (status == STATUS_SUCCESS)
- +#if 0
- + if (NT_SUCCESS(status))
- print_hexbuf(0, (unsigned char *)"upcall buffer", pbOut, *len);
- +#endif
- out:
- return status;
- @@ -1591,7 +1593,7 @@ NTSTATUS nfs41_UpcallCreate(
- */
- status = SeCreateClientSecurityFromSubjectContext(&sec_ctx, &sec_qos,
- FALSE, entry->psec_ctx);
- - if (status != STATUS_SUCCESS) {
- + if (!NT_SUCCESS(status)) {
- print_error("nfs41_UpcallCreate: "
- "SeCreateClientSecurityFromSubjectContext() "
- "failed with 0x%x\n",
- @@ -1711,8 +1713,8 @@ process_upcall:
- ExAcquireFastMutex(&entry->lock);
- nfs41_AddEntry(downcallLock, downcall, entry);
- status = handle_upcall(RxContext, entry, &len);
- - if (status == STATUS_SUCCESS &&
- - entry->state == NFS41_WAITING_FOR_UPCALL)
- + if (NT_SUCCESS(status) &&
- + (entry->state == NFS41_WAITING_FOR_UPCALL))
- entry->state = NFS41_WAITING_FOR_DOWNCALL;
- ExReleaseFastMutex(&entry->lock);
- if (status) {
- @@ -2142,7 +2144,7 @@ NTSTATUS nfs41_downcall(
- }
- ExReleaseFastMutex(&cur->lock);
- if (cur->async_op) {
- - if (cur->status == STATUS_SUCCESS) {
- + if (NT_SUCCESS(cur->status)) {
- cur->u.ReadWrite.rxcontext->StoredStatus = STATUS_SUCCESS;
- cur->u.ReadWrite.rxcontext->InformationToReturn =
- cur->buf_len;
- @@ -2395,7 +2397,7 @@ NTSTATUS nfs41_CreateConnection(
- status = nfs41_GetConnectionInfoFromBuffer(Buffer, BufferLen,
- &FileName, &EaBuffer, &EaLength);
- - if (status != STATUS_SUCCESS)
- + if (!NT_SUCCESS(status))
- goto out;
- status = GetConnectionHandle(&FileName, EaBuffer, EaLength, &Handle);
- @@ -2500,7 +2502,7 @@ NTSTATUS nfs41_DeleteConnection (
- FileName.MaximumLength = (USHORT) ConnectNameLen;
- status = GetConnectionHandle(&FileName, NULL, 0, &Handle);
- - if (status != STATUS_SUCCESS)
- + if (!NT_SUCCESS(status))
- goto out;
- status = ObReferenceObjectByHandle(Handle, 0L, NULL, KernelMode,
- --
- 2.45.1
msnfs41client: Patches for mount long options, bigger namecache+misc, 2024-07-18
Posted by Anonymous on Thu 18th Jul 2024 17:27
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.