- #
- # patch to support Windows Sever NFSv4.1 nfsd, which does not
- # seem to support FATTR4_WORD1_SPACE_USED
- #
- diff --git a/daemon/fileinfoutil.c b/daemon/fileinfoutil.c
- index be684fc..a6f1c02 100644
- --- a/daemon/fileinfoutil.c
- +++ b/daemon/fileinfoutil.c
- @@ -138,10 +138,16 @@ void nfs_to_standard_info(
- EASSERT(bitmap_isset(&info->attrmask, 0, FATTR4_WORD0_SIZE));
- EASSERT(bitmap_isset(&info->attrmask, 1, FATTR4_WORD1_NUMLINKS));
- - EASSERT(bitmap_isset(&info->attrmask, 1, FATTR4_WORD1_SPACE_USED));
- std_out->EndOfFile.QuadPart = (LONGLONG)info->size;
- - std_out->AllocationSize.QuadPart = (LONGLONG)info->space_used;
- + if (superblock->supports_space_used_attr) {
- + EASSERT(bitmap_isset(&info->attrmask, 1,
- + FATTR4_WORD1_SPACE_USED));
- + std_out->AllocationSize.QuadPart = (LONGLONG)info->space_used;
- + }
- + else {
- + std_out->AllocationSize.QuadPart = (LONGLONG)info->size;
- + }
- std_out->NumberOfLinks = info->numlinks;
- std_out->DeletePending = FALSE;
- std_out->Directory = FileAttributes & FILE_ATTRIBUTE_DIRECTORY ?
- @@ -194,7 +200,16 @@ void nfs_to_network_openinfo(
- }
- net_out->EndOfFile.QuadPart = (LONGLONG)info->size;
- - net_out->AllocationSize.QuadPart = (LONGLONG)info->space_used;
- + if (superblock->supports_space_used_attr) {
- + EASSERT(bitmap_isset(&info->attrmask, 1,
- + FATTR4_WORD1_SPACE_USED));
- + net_out->AllocationSize.QuadPart =
- + (LONGLONG)info->space_used;
- + }
- + else {
- + net_out->AllocationSize.QuadPart = (LONGLONG)info->size;
- + }
- +
- net_out->FileAttributes =
- nfs_file_info_to_attributes(superblock, info);
- }
- @@ -272,7 +287,14 @@ void nfs_to_stat_info(
- }
- stat_out->EndOfFile.QuadPart = (LONGLONG)info->size;
- - stat_out->AllocationSize.QuadPart = (LONGLONG)info->space_used;
- + if (superblock->supports_space_used_attr) {
- + EASSERT(bitmap_isset(&info->attrmask, 1,
- + FATTR4_WORD1_SPACE_USED));
- + stat_out->AllocationSize.QuadPart = (LONGLONG)info->space_used;
- + }
- + else {
- + stat_out->AllocationSize.QuadPart = (LONGLONG)info->size;
- + }
- stat_out->FileAttributes =
- nfs_file_info_to_attributes(superblock, info);
- @@ -340,7 +362,15 @@ void nfs_to_stat_lx_info(
- }
- stat_lx_out->EndOfFile.QuadPart = (LONGLONG)info->size;
- - stat_lx_out->AllocationSize.QuadPart = (LONGLONG)info->space_used;
- + if (superblock->supports_space_used_attr) {
- + EASSERT(bitmap_isset(&info->attrmask, 1,
- + FATTR4_WORD1_SPACE_USED));
- + stat_lx_out->AllocationSize.QuadPart =
- + (LONGLONG)info->space_used;
- + }
- + else {
- + stat_lx_out->AllocationSize.QuadPart = (LONGLONG)info->size;
- + }
- stat_lx_out->FileAttributes =
- nfs_file_info_to_attributes(superblock, info);
- diff --git a/daemon/nfs41.h b/daemon/nfs41.h
- index 7805659..f94fd82 100644
- --- a/daemon/nfs41.h
- +++ b/daemon/nfs41.h
- @@ -59,6 +59,7 @@ typedef struct __nfs41_superblock {
- unsigned int case_preserving : 1;
- unsigned int case_insensitive : 1;
- unsigned int sparse_file_support : 1;
- + unsigned int supports_space_used_attr : 1;
- /* variable filesystem attributes */
- uint64_t space_avail;
- diff --git a/daemon/nfs41_superblock.c b/daemon/nfs41_superblock.c
- index af94a8b..2842ff3 100644
- --- a/daemon/nfs41_superblock.c
- +++ b/daemon/nfs41_superblock.c
- @@ -93,6 +93,8 @@ static int get_superblock_attrs(
- attr_request.arr[2] = FATTR4_WORD2_SUPPATTR_EXCLCREAT;
- attr_request.count = 3;
- +// (void)memset(&superblock->supported_attrs, 0,
- +// sizeof(superblock->supported_attrs));
- info.supported_attrs = &superblock->supported_attrs;
- info.suppattr_exclcreat = &superblock->suppattr_exclcreat;
- info.time_delta = &superblock->time_delta;
- @@ -126,6 +128,19 @@ static int get_superblock_attrs(
- superblock->case_insensitive = info.case_insensitive;
- superblock->sparse_file_support = 1; /* always ON for now */
- + EASSERT(info.supported_attrs->count > 0);
- + if (bitmap_isset(info.supported_attrs, 1,
- + FATTR4_WORD1_SPACE_USED)) {
- + superblock->supports_space_used_attr = 1;
- + }
- + else {
- + superblock->supports_space_used_attr = 0;
- + }
- + DPRINTF(0, ("get_superblock_attrs(superblock=0x%p): "
- + "attrsupported(FATTR4_WORD1_SPACE_USED)=%d\n",
- + (void *)superblock,
- + (int)superblock->supports_space_used_attr));
- +
- if (bitmap_isset(&info.attrmask, 0, FATTR4_WORD0_CANSETTIME))
- superblock->cansettime = info.cansettime;
- else /* cansettime is not supported, try setting them anyway */
- @@ -154,14 +169,15 @@ static int get_superblock_attrs(
- "maxread=%llu, maxwrite=%llu, layout_types: 0x%X, "
- "cansettime=%u, time_delta={%llu,%u}, aclsupport=%u, "
- "link_support=%u, symlink_support=%u, case_preserving=%u, "
- - "case_insensitive=%u\n",
- + "case_insensitive=%u supports_space_used_attr=%u\n",
- superblock->fsid.major, superblock->fsid.minor,
- superblock->maxread, superblock->maxwrite,
- superblock->layout_types, superblock->cansettime,
- superblock->time_delta.seconds, superblock->time_delta.nseconds,
- superblock->aclsupport, superblock->link_support,
- superblock->symlink_support, superblock->case_preserving,
- - superblock->case_insensitive));
- + superblock->case_insensitive,
- + superblock->supports_space_used_attr));
- out:
- return status;
- }
- diff --git a/daemon/readdir.c b/daemon/readdir.c
- index 75a6cf3..2a49913 100644
- --- a/daemon/readdir.c
- +++ b/daemon/readdir.c
- @@ -374,7 +374,16 @@ static void readdir_copy_dir_info(
- }
- info->fdi.EndOfFile.QuadPart = entry->attr_info.size;
- - info->fdi.AllocationSize.QuadPart = entry->attr_info.space_used;
- + if (superblock->supports_space_used_attr) {
- + EASSERT(bitmap_isset(&entry->attr_info.attrmask, 1,
- + FATTR4_WORD1_SPACE_USED));
- + info->fdi.AllocationSize.QuadPart =
- + (LONGLONG)entry->attr_info.space_used;
- + }
- + else {
- + info->fdi.AllocationSize.QuadPart =
- + (LONGLONG)entry->attr_info.size;
- + }
- info->fdi.FileAttributes =
- nfs_file_info_to_attributes(superblock, &entry->attr_info);
msnfs41client_support_missing_space_used_attr20250228_001.patch
Posted by Anonymous on Fri 28th Feb 2025 13:21
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.