- diff --git a/daemon/nfs41_superblock.c b/daemon/nfs41_superblock.c
- index 977a4c1..f547e7c 100644
- --- a/daemon/nfs41_superblock.c
- +++ b/daemon/nfs41_superblock.c
- @@ -192,6 +192,9 @@ void nfs41_superblock_fs_attributes(
- FsAttrs->FileSystemAttributes = 0;
- FsAttrs->FileSystemAttributes |= FILE_SUPPORTS_SPARSE_FILES;
- +#ifdef NFS41_DRIVER_RDR_SUPPORTS_POSIX_FILEINFORMATINO_CLASSES
- + FsAttrs->FileSystemAttributes |= FILE_SUPPORTS_POSIX_UNLINK_RENAME;
- +#endif /* NFS41_DRIVER_RDR_SUPPORTS_POSIX_FILEINFORMATINO_CLASSES */
- /* NFSv4 protocol uses Unicode by default */
- FsAttrs->FileSystemAttributes |= FILE_UNICODE_ON_DISK;
- diff --git a/daemon/setattr.c b/daemon/setattr.c
- index 322e934..53fdbf7 100644
- --- a/daemon/setattr.c
- +++ b/daemon/setattr.c
- @@ -25,6 +25,7 @@
- #include <stdio.h>
- #include <strsafe.h>
- +#include "nfs41_build_features.h"
- #include "from_kernel.h"
- #include "nfs41_ops.h"
- #include "delegation.h"
- @@ -188,7 +189,31 @@ static int handle_nfs41_remove(void *daemon_context, setattr_upcall_args *args)
- {
- nfs41_open_state *state = args->state;
- int status;
- -
- + bool posixsemantics;
- +
- + switch (args->set_class) {
- + case FileDispositionInformation:
- + posixsemantics = false;
- + break;
- +#ifdef NFS41_DRIVER_RDR_SUPPORTS_POSIX_FILEINFORMATINO_CLASSES
- + case FileDispositionInformationEx:
- + posixsemantics =
- + (((PFILE_DISPOSITION_INFORMATION_EX)args->buf)->Flags &
- + FILE_DISPOSITION_POSIX_SEMANTICS)?true:false;
- + break;
- +#endif /* NFS41_DRIVER_RDR_SUPPORTS_POSIX_FILEINFORMATINO_CLASSES */
- + default:
- + eprintf("handle_nfs41_link: unhandled set_class=%d\n",
- + (int)args->set_class);
- + status = ERROR_NOT_SUPPORTED;
- + goto out;
- + }
- +
- + DPRINTF(0, ("handle_nfs41_remove(): "
- + "class=%d posix_semantics=%d\n",
- + (int)args->set_class,
- + (int)posixsemantics));
- +
- /* break any delegations and truncate before REMOVE */
- nfs41_delegation_return(state->session, &state->file,
- OPEN_DELEGATE_WRITE, TRUE);
- @@ -200,7 +225,10 @@ static int handle_nfs41_remove(void *daemon_context, setattr_upcall_args *args)
- nfs_error_string(status)));
- }
- - return nfs_to_windows_error(status, ERROR_ACCESS_DENIED);
- + status = nfs_to_windows_error(status, ERROR_ACCESS_DENIED);
- +
- +out:
- + return status;
- }
- static void open_state_rename(
- @@ -302,14 +330,42 @@ static int handle_nfs41_rename(void *daemon_context, setattr_upcall_args *args)
- nfs41_open_state *state = args->state;
- nfs41_session *dst_session;
- PFILE_RENAME_INFO rename = (PFILE_RENAME_INFO)args->buf;
- + bool replaceifexists;
- + bool posixsemantics;
- nfs41_abs_path dst_path = { 0 };
- nfs41_path_fh dst_dir, dst;
- nfs41_component dst_name, *src_name;
- uint32_t depth = 0;
- int status;
- -
- - src_name = &state->file.name;
- -
- +
- + switch (args->set_class) {
- + case FileRenameInformation:
- + replaceifexists = rename->ReplaceIfExists?true:false;
- + posixsemantics = false;
- + break;
- +#ifdef NFS41_DRIVER_RDR_SUPPORTS_POSIX_FILEINFORMATINO_CLASSES
- + case FileRenameInformationEx:
- + replaceifexists =
- + (rename->Flags & FILE_RENAME_REPLACE_IF_EXISTS)?true:false;
- + posixsemantics =
- + (rename->Flags & FILE_RENAME_POSIX_SEMANTICS)?true:false;
- + break;
- +#endif /* NFS41_DRIVER_RDR_SUPPORTS_POSIX_FILEINFORMATINO_CLASSES */
- + default:
- + eprintf("handle_nfs41_rename: unhandled set_class=%d\n",
- + (int)args->set_class);
- + status = ERROR_NOT_SUPPORTED;
- + goto out;
- + }
- +
- + src_name = &state->file.name;
- +
- + DPRINTF(0, ("handle_nfs41_rename(): "
- + "class=%d replaceifexists=%d posix_semantics=%d\n",
- + (int)args->set_class,
- + (int)replaceifexists,
- + (int)posixsemantics));
- +
- if (rename->FileNameLength == 0) {
- /* start from state->path instead of args->path, in case we got
- * the file from a referred server */
- @@ -439,7 +495,7 @@ static int handle_nfs41_rename(void *daemon_context, setattr_upcall_args *args)
- last_component(dst_path.path, dst_name.name, &dst_dir.name);
- if (status == NO_ERROR) {
- - if (!rename->ReplaceIfExists) {
- + if (!replaceifexists) {
- status = ERROR_FILE_EXISTS;
- goto out;
- }
- @@ -459,16 +515,22 @@ static int handle_nfs41_rename(void *daemon_context, setattr_upcall_args *args)
- status = ERROR_NOT_SAME_DEVICE;
- goto out;
- }
- -
- - status = is_dst_name_opened(&dst_path, dst_session);
- - if (status) {
- - /* AGLO: 03/21/2011: we can't handle rename of a file with a filename
- - * that is currently opened by this client
- - */
- - eprintf("handle_nfs41_rename: '%s' is opened\n", dst_path.path);
- - status = ERROR_FILE_EXISTS;
- - goto out;
- +
- +#if 0 /* disabled to test MariaDB */
- + if (!posixsemantics) {
- + status = is_dst_name_opened(&dst_path, dst_session);
- + if (status) {
- + /*
- + * AGLO: 03/21/2011: we can't handle rename of a file with a
- + * filename that is currently opened by this client
- + */
- + eprintf("handle_nfs41_rename: destination '%s' is opened\n",
- + dst_path.path);
- + status = ERROR_FILE_EXISTS;
- + goto out;
- + }
- }
- +#endif
- /* break any delegations on the source file */
- nfs41_delegation_return(state->session, &state->file,
- @@ -551,6 +613,8 @@ static int handle_nfs41_link(void *daemon_context, setattr_upcall_args *args)
- {
- nfs41_open_state *state = args->state;
- PFILE_LINK_INFORMATION link = (PFILE_LINK_INFORMATION)args->buf;
- + bool replaceifexists;
- + bool posixsemantics;
- nfs41_session *dst_session;
- nfs41_abs_path dst_path = { 0 };
- nfs41_path_fh dst_dir, dst;
- @@ -563,6 +627,32 @@ static int handle_nfs41_link(void *daemon_context, setattr_upcall_args *args)
- EASSERT((link->FileNameLength%sizeof(WCHAR)) == 0);
- + switch (args->set_class) {
- + case FileLinkInformation:
- + replaceifexists = link->ReplaceIfExists?true:false;
- + posixsemantics = false;
- + break;
- +#ifdef NFS41_DRIVER_RDR_SUPPORTS_POSIX_FILEINFORMATINO_CLASSES
- + case FileLinkInformationEx:
- + replaceifexists =
- + (link->Flags & FILE_LINK_REPLACE_IF_EXISTS)?true:false;
- + posixsemantics =
- + (link->Flags & FILE_LINK_POSIX_SEMANTICS)?true:false;
- + break;
- +#endif /* NFS41_DRIVER_RDR_SUPPORTS_POSIX_FILEINFORMATINO_CLASSES */
- + default:
- + eprintf("handle_nfs41_link: unhandled set_class=%d\n",
- + (int)args->set_class);
- + status = ERROR_NOT_SUPPORTED;
- + goto out;
- + }
- +
- + DPRINTF(0, ("handle_nfs41_link(): "
- + "class=%d replaceifexists=%d posix_semantics=%d\n",
- + (int)args->set_class,
- + (int)replaceifexists,
- + (int)posixsemantics));
- +
- dst_path.len = (unsigned short)WideCharToMultiByte(CP_UTF8,
- WC_ERR_INVALID_CHARS|WC_NO_BEST_FIT_CHARS,
- link->FileName, link->FileNameLength/sizeof(WCHAR),
- @@ -607,7 +697,7 @@ static int handle_nfs41_link(void *daemon_context, setattr_upcall_args *args)
- last_component(dst_path.path, dst_name.name, &dst_dir.name);
- if (status == NO_ERROR) {
- - if (!link->ReplaceIfExists) {
- + if (!replaceifexists) {
- status = ERROR_FILE_EXISTS;
- goto out;
- }
- @@ -670,16 +760,25 @@ static int handle_setattr(void *daemon_context, nfs41_upcall *upcall)
- status = handle_nfs41_setattr_basicinfo(daemon_context, args);
- break;
- case FileDispositionInformation:
- +#ifdef NFS41_DRIVER_RDR_SUPPORTS_POSIX_FILEINFORMATINO_CLASSES
- + case FileDispositionInformationEx:
- +#endif /* NFS41_DRIVER_RDR_SUPPORTS_POSIX_FILEINFORMATINO_CLASSES */
- status = handle_nfs41_remove(daemon_context, args);
- break;
- case FileRenameInformation:
- +#ifdef NFS41_DRIVER_RDR_SUPPORTS_POSIX_FILEINFORMATINO_CLASSES
- + case FileRenameInformationEx:
- +#endif /* NFS41_DRIVER_RDR_SUPPORTS_POSIX_FILEINFORMATINO_CLASSES */
- status = handle_nfs41_rename(daemon_context, args);
- break;
- case FileAllocationInformation:
- +#ifdef NFS41_DRIVER_RDR_SUPPORTS_POSIX_FILEINFORMATINO_CLASSES
- case FileEndOfFileInformation:
- +#endif /* NFS41_DRIVER_RDR_SUPPORTS_POSIX_FILEINFORMATINO_CLASSES */
- status = handle_nfs41_set_size(daemon_context, args);
- break;
- case FileLinkInformation:
- + case FileLinkInformationEx:
- status = handle_nfs41_link(daemon_context, args);
- break;
- default:
- diff --git a/include/from_kernel.h b/include/from_kernel.h
- index 7a305bc..96d4b32 100644
- --- a/include/from_kernel.h
- +++ b/include/from_kernel.h
- @@ -153,6 +153,19 @@ typedef struct _FILE_NAMES_INFORMATION {
- WCHAR FileName[1];
- } FILE_NAMES_INFORMATION, *PFILE_NAMES_INFORMATION;
- +#ifdef NFS41_DRIVER_RDR_SUPPORTS_POSIX_FILEINFORMATINO_CLASSES
- +typedef struct _FILE_DISPOSITION_INFORMATION_EX {
- + ULONG Flags;
- +} FILE_DISPOSITION_INFORMATION_EX, *PFILE_DISPOSITION_INFORMATION_EX;
- +
- +#define FILE_DISPOSITION_DO_NOT_DELETE 0x00000000
- +#define FILE_DISPOSITION_DELETE 0x00000001
- +#define FILE_DISPOSITION_POSIX_SEMANTICS 0x00000002
- +#define FILE_DISPOSITION_FORCE_IMAGE_SECTION_CHECK 0x00000004
- +#define FILE_DISPOSITION_ON_CLOSE 0x00000008
- +#define FILE_DISPOSITION_IGNORE_READONLY_ATTRIBUTE 0x00000010
- +#endif /* NFS41_DRIVER_RDR_SUPPORTS_POSIX_FILEINFORMATINO_CLASSES */
- +
- typedef struct _FILE_DIRECTORY_INFORMATION {
- ULONG NextEntryOffset;
- ULONG FileIndex;
- @@ -269,13 +282,57 @@ typedef struct _FILE_ID_EXTD_BOTH_DIR_INFORMATION {
- WCHAR FileName[1];
- } FILE_ID_EXTD_BOTH_DIR_INFORMATION, *PFILE_ID_EXTD_BOTH_DIR_INFORMATION;
- +#ifdef NFS41_DRIVER_RDR_SUPPORTS_POSIX_FILEINFORMATINO_CLASSES
- +#define FILE_RENAME_REPLACE_IF_EXISTS 0x00000001
- +#define FILE_RENAME_POSIX_SEMANTICS 0x00000002
- +#define FILE_RENAME_SUPPRESS_PIN_STATE_INHERITANCE 0x00000004
- +#define FILE_RENAME_SUPPRESS_STORAGE_RESERVE_INHERITANCE 0x00000008
- +#define FILE_RENAME_NO_INCREASE_AVAILABLE_SPACE 0x00000010
- +#define FILE_RENAME_NO_DECREASE_AVAILABLE_SPACE 0x00000020
- +#define FILE_RENAME_PRESERVE_AVAILABLE_SPACE 0x00000030
- +#define FILE_RENAME_IGNORE_READONLY_ATTRIBUTE 0x00000040
- +#define FILE_RENAME_FORCE_RESIZE_TARGET_SR 0x00000080
- +#define FILE_RENAME_FORCE_RESIZE_SOURCE_SR 0x00000100
- +#define FILE_RENAME_FORCE_RESIZE_SR 0x00000180
- +#endif /* NFS41_DRIVER_RDR_SUPPORTS_POSIX_FILEINFORMATINO_CLASSES */
- +
- typedef struct _FILE_LINK_INFORMATION {
- - BOOLEAN ReplaceIfExists;
- +#ifdef NFS41_DRIVER_RDR_SUPPORTS_POSIX_FILEINFORMATINO_CLASSES
- +#ifdef _MSC_VER
- +#pragma warning( push )
- +/*
- + * C4201: "nonstandard extension used: nameless struct/union"
- + */
- +#pragma warning (disable : 4201)
- +#endif /* _MSC_VER */
- + union {
- + BOOLEAN ReplaceIfExists; /* class==FileLinkInformation */
- + ULONG Flags; /* class==FileLinkInformationEx */
- + };
- +#ifdef _MSC_VER
- +#pragma warning( pop )
- +#endif /* _MSC_VER */
- +#else
- + BOOLEAN ReplaceIfExists; /* class==FileLinkInformation */
- +#endif /* NFS41_DRIVER_RDR_SUPPORTS_POSIX_FILEINFORMATINO_CLASSES */
- HANDLE RootDirectory;
- ULONG FileNameLength;
- WCHAR FileName[1];
- } FILE_LINK_INFORMATION, *PFILE_LINK_INFORMATION;
- +#ifdef NFS41_DRIVER_RDR_SUPPORTS_POSIX_FILEINFORMATINO_CLASSES
- +#define FILE_LINK_REPLACE_IF_EXISTS 0x00000001
- +#define FILE_LINK_POSIX_SEMANTICS 0x00000002
- +#define FILE_LINK_SUPPRESS_STORAGE_RESERVE_INHERITANCE 0x00000008
- +#define FILE_LINK_NO_INCREASE_AVAILABLE_SPACE 0x00000010
- +#define FILE_LINK_NO_DECREASE_AVAILABLE_SPACE 0x00000020
- +#define FILE_LINK_PRESERVE_AVAILABLE_SPACE 0x00000030
- +#define FILE_LINK_IGNORE_READONLY_ATTRIBUTE 0x00000040
- +#define FILE_LINK_FORCE_RESIZE_TARGET_SR 0x00000080
- +#define FILE_LINK_FORCE_RESIZE_SOURCE_SR 0x00000100
- +#define FILE_LINK_FORCE_RESIZE_SR 0x00000180
- +#endif /* NFS41_DRIVER_RDR_SUPPORTS_POSIX_FILEINFORMATINO_CLASSES */
- +
- typedef struct _FILE_EA_INFORMATION {
- ULONG EaSize;
- } FILE_EA_INFORMATION, *PFILE_EA_INFORMATION;
- diff --git a/nfs41_build_features.h b/nfs41_build_features.h
- index 38f6372..5a65953 100644
- --- a/nfs41_build_features.h
- +++ b/nfs41_build_features.h
- @@ -236,4 +236,12 @@
- */
- #define NFS41_DRIVER_HACK_LOCKING_STORAGE32_RANGELOCK_PROBING 1
- +/*
- + * |NFS41_DRIVER_RDR_SUPPORTS_POSIX_FILEINFORMATINO_CLASSES| - enable
- + * support for |FileDispositionInformationEx|, |FileRenameInformationEx|
- + * and |FileLinkInformationEx|, assuming the platforms rdbsslib.lib
- + * supports them
- + */
- +#define NFS41_DRIVER_RDR_SUPPORTS_POSIX_FILEINFORMATINO_CLASSES 1
- +
- #endif /* !_NFS41_DRIVER_BUILDFEATURES_ */
- diff --git a/sys/nfs41sys_fileinfo.c b/sys/nfs41sys_fileinfo.c
- index d7dc5e7..b175695 100644
- --- a/sys/nfs41sys_fileinfo.c
- +++ b/sys/nfs41sys_fileinfo.c
- @@ -573,6 +573,9 @@ NTSTATUS check_nfs41_setattr_args(
- switch (InfoClass) {
- case FileRenameInformation:
- +#ifdef NFS41_DRIVER_RDR_SUPPORTS_POSIX_FILEINFORMATINO_CLASSES
- + case FileRenameInformationEx:
- +#endif /* NFS41_DRIVER_RDR_SUPPORTS_POSIX_FILEINFORMATINO_CLASSES */
- {
- PFILE_RENAME_INFORMATION rinfo =
- (PFILE_RENAME_INFORMATION)RxContext->Info.Buffer;
- @@ -592,6 +595,9 @@ NTSTATUS check_nfs41_setattr_args(
- break;
- }
- case FileLinkInformation:
- +#ifdef NFS41_DRIVER_RDR_SUPPORTS_POSIX_FILEINFORMATINO_CLASSES
- + case FileLinkInformationEx:
- +#endif /* NFS41_DRIVER_RDR_SUPPORTS_POSIX_FILEINFORMATINO_CLASSES */
- {
- PFILE_LINK_INFORMATION linfo =
- (PFILE_LINK_INFORMATION)RxContext->Info.Buffer;
- @@ -621,6 +627,19 @@ NTSTATUS check_nfs41_setattr_args(
- }
- break;
- }
- +#ifdef NFS41_DRIVER_RDR_SUPPORTS_POSIX_FILEINFORMATINO_CLASSES
- + case FileDispositionInformationEx:
- + {
- + PFILE_DISPOSITION_INFORMATION_EX dinfo =
- + (PFILE_DISPOSITION_INFORMATION_EX)RxContext->Info.Buffer;
- + __notnull PNFS41_FCB nfs41_fcb = NFS41GetFcbExtension(RxContext->pFcb);
- + if ((dinfo->Flags & FILE_DISPOSITION_DELETE) && nfs41_fcb->DeletePending) {
- + status = STATUS_DELETE_PENDING;
- + goto out;
- + }
- + break;
- + }
- +#endif /* NFS41_DRIVER_RDR_SUPPORTS_POSIX_FILEINFORMATINO_CLASSES */
- case FileBasicInformation:
- case FileAllocationInformation:
- case FileEndOfFileInformation:
- @@ -694,6 +713,46 @@ NTSTATUS nfs41_SetFileInformation(
- status = STATUS_SUCCESS;
- goto out;
- }
- +#ifdef NFS41_DRIVER_RDR_SUPPORTS_POSIX_FILEINFORMATINO_CLASSES
- + case FileDispositionInformationEx:
- + {
- + PFILE_DISPOSITION_INFORMATION_EX dinfo =
- + (PFILE_DISPOSITION_INFORMATION_EX)RxContext->Info.Buffer;
- + if (dinfo->Flags & FILE_DISPOSITION_DELETE) {
- + nfs41_fcb->DeletePending = TRUE;
- +
- + /* we can delete directories right away */
- + if (nfs41_fcb->StandardInfo.Directory)
- + break;
- +
- + /* delete immediately if POSIX semantics are requested */
- + if (dinfo->Flags & FILE_DISPOSITION_POSIX_SEMANTICS)
- + break;
- +
- + nfs41_fcb->StandardInfo.DeletePending = TRUE;
- + if (RxContext->pFcb->OpenCount > 1) {
- + rinfo.ReplaceIfExists = 0;
- + rinfo.RootDirectory = INVALID_HANDLE_VALUE;
- + rinfo.FileNameLength = 0;
- + rinfo.FileName[0] = L'\0';
- + InfoClass = FileRenameInformation;
- + nfs41_fcb->Renamed = TRUE;
- + break;
- + }
- + }
- + if (dinfo->Flags & FILE_DISPOSITION_DO_NOT_DELETE) {
- + /* section 4.3.3 of [FSBO]
- + * "file system behavior in the microsoft windows environment"
- + */
- + if (nfs41_fcb->DeletePending) {
- + nfs41_fcb->DeletePending = FALSE;
- + nfs41_fcb->StandardInfo.DeletePending = 0;
- + }
- + }
- + status = STATUS_SUCCESS;
- + goto out;
- + }
- +#endif /* NFS41_DRIVER_RDR_SUPPORTS_POSIX_FILEINFORMATINO_CLASSES */
- case FileAllocationInformation:
- {
- PFILE_ALLOCATION_INFORMATION info =
- @@ -711,6 +770,9 @@ NTSTATUS nfs41_SetFileInformation(
- break;
- }
- case FileRenameInformation:
- +#ifdef NFS41_DRIVER_RDR_SUPPORTS_POSIX_FILEINFORMATINO_CLASSES
- + case FileRenameInformationEx:
- +#endif /* NFS41_DRIVER_RDR_SUPPORTS_POSIX_FILEINFORMATINO_CLASSES */
- {
- /* noop if filename and destination are the same */
- PFILE_RENAME_INFORMATION prinfo =
- @@ -734,8 +796,16 @@ NTSTATUS nfs41_SetFileInformation(
- /* original irp has infoclass for remove but we need to rename instead,
- * thus we changed the local variable infoclass */
- - if (RxContext->Info.FileInformationClass == FileDispositionInformation &&
- - InfoClass == FileRenameInformation) {
- +#ifdef NFS41_DRIVER_RDR_SUPPORTS_POSIX_FILEINFORMATINO_CLASSES
- + if (((RxContext->Info.FileInformationClass == FileDispositionInformation) ||
- + (RxContext->Info.FileInformationClass == FileDispositionInformationEx)) &&
- + ((InfoClass == FileRenameInformation) ||
- + (InfoClass == FileRenameInformationEx)))
- +#else
- + if ((RxContext->Info.FileInformationClass == FileDispositionInformation) &&
- + (InfoClass == FileRenameInformation))
- +#endif /* NFS41_DRIVER_RDR_SUPPORTS_POSIX_FILEINFORMATINO_CLASSES */
- + {
- entry->buf = &rinfo;
- entry->buf_len = sizeof(rinfo);
- } else {
posixext20250723backup_002.patch
Posted by Anonymous on Wed 23rd Jul 2025 17:41
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.