pastebin - collaborative debugging tool
nrubsig.kpaste.net RSS


msnfs41client_support_missing_space_used_attr20250228_001.patch
Posted by Anonymous on Fri 28th Feb 2025 13:21
raw | new post

  1. #
  2. # patch to support Windows Sever NFSv4.1 nfsd, which does not
  3. # seem to support FATTR4_WORD1_SPACE_USED
  4. #
  5. diff --git a/daemon/fileinfoutil.c b/daemon/fileinfoutil.c
  6. index be684fc..a6f1c02 100644
  7. --- a/daemon/fileinfoutil.c
  8. +++ b/daemon/fileinfoutil.c
  9. @@ -138,10 +138,16 @@ void nfs_to_standard_info(
  10.  
  11.      EASSERT(bitmap_isset(&info->attrmask, 0, FATTR4_WORD0_SIZE));
  12.      EASSERT(bitmap_isset(&info->attrmask, 1, FATTR4_WORD1_NUMLINKS));
  13. -    EASSERT(bitmap_isset(&info->attrmask, 1, FATTR4_WORD1_SPACE_USED));
  14.  
  15.      std_out->EndOfFile.QuadPart = (LONGLONG)info->size;
  16. -    std_out->AllocationSize.QuadPart = (LONGLONG)info->space_used;
  17. +    if (superblock->supports_space_used_attr) {
  18. +        EASSERT(bitmap_isset(&info->attrmask, 1,
  19. +            FATTR4_WORD1_SPACE_USED));
  20. +        std_out->AllocationSize.QuadPart = (LONGLONG)info->space_used;
  21. +    }
  22. +    else {
  23. +        std_out->AllocationSize.QuadPart = (LONGLONG)info->size;
  24. +    }
  25.      std_out->NumberOfLinks = info->numlinks;
  26.      std_out->DeletePending = FALSE;
  27.      std_out->Directory = FileAttributes & FILE_ATTRIBUTE_DIRECTORY ?
  28. @@ -194,7 +200,16 @@ void nfs_to_network_openinfo(
  29.      }
  30.  
  31.      net_out->EndOfFile.QuadPart = (LONGLONG)info->size;
  32. -    net_out->AllocationSize.QuadPart = (LONGLONG)info->space_used;
  33. +    if (superblock->supports_space_used_attr) {
  34. +        EASSERT(bitmap_isset(&info->attrmask, 1,
  35. +            FATTR4_WORD1_SPACE_USED));
  36. +        net_out->AllocationSize.QuadPart =
  37. +            (LONGLONG)info->space_used;
  38. +    }
  39. +    else {
  40. +        net_out->AllocationSize.QuadPart = (LONGLONG)info->size;
  41. +    }
  42. +
  43.      net_out->FileAttributes =
  44.          nfs_file_info_to_attributes(superblock, info);
  45.  }
  46. @@ -272,7 +287,14 @@ void nfs_to_stat_info(
  47.      }
  48.  
  49.      stat_out->EndOfFile.QuadPart = (LONGLONG)info->size;
  50. -    stat_out->AllocationSize.QuadPart = (LONGLONG)info->space_used;
  51. +    if (superblock->supports_space_used_attr) {
  52. +        EASSERT(bitmap_isset(&info->attrmask, 1,
  53. +            FATTR4_WORD1_SPACE_USED));
  54. +        stat_out->AllocationSize.QuadPart = (LONGLONG)info->space_used;
  55. +    }
  56. +    else {
  57. +        stat_out->AllocationSize.QuadPart = (LONGLONG)info->size;
  58. +    }
  59.  
  60.      stat_out->FileAttributes =
  61.          nfs_file_info_to_attributes(superblock, info);
  62. @@ -340,7 +362,15 @@ void nfs_to_stat_lx_info(
  63.      }
  64.  
  65.      stat_lx_out->EndOfFile.QuadPart = (LONGLONG)info->size;
  66. -    stat_lx_out->AllocationSize.QuadPart = (LONGLONG)info->space_used;
  67. +    if (superblock->supports_space_used_attr) {
  68. +        EASSERT(bitmap_isset(&info->attrmask, 1,
  69. +            FATTR4_WORD1_SPACE_USED));
  70. +        stat_lx_out->AllocationSize.QuadPart =
  71. +            (LONGLONG)info->space_used;
  72. +    }
  73. +    else {
  74. +        stat_lx_out->AllocationSize.QuadPart = (LONGLONG)info->size;
  75. +    }
  76.  
  77.      stat_lx_out->FileAttributes =
  78.          nfs_file_info_to_attributes(superblock, info);
  79. diff --git a/daemon/nfs41.h b/daemon/nfs41.h
  80. index 7805659..f94fd82 100644
  81. --- a/daemon/nfs41.h
  82. +++ b/daemon/nfs41.h
  83. @@ -59,6 +59,7 @@ typedef struct __nfs41_superblock {
  84.      unsigned int case_preserving : 1;
  85.      unsigned int case_insensitive : 1;
  86.      unsigned int sparse_file_support : 1;
  87. +    unsigned int supports_space_used_attr : 1;
  88.  
  89.      /* variable filesystem attributes */
  90.      uint64_t space_avail;
  91. diff --git a/daemon/nfs41_superblock.c b/daemon/nfs41_superblock.c
  92. index af94a8b..2842ff3 100644
  93. --- a/daemon/nfs41_superblock.c
  94. +++ b/daemon/nfs41_superblock.c
  95. @@ -93,6 +93,8 @@ static int get_superblock_attrs(
  96.      attr_request.arr[2] = FATTR4_WORD2_SUPPATTR_EXCLCREAT;
  97.      attr_request.count = 3;
  98.  
  99. +//    (void)memset(&superblock->supported_attrs, 0,
  100. +//        sizeof(superblock->supported_attrs));
  101.      info.supported_attrs = &superblock->supported_attrs;
  102.      info.suppattr_exclcreat = &superblock->suppattr_exclcreat;
  103.      info.time_delta = &superblock->time_delta;
  104. @@ -126,6 +128,19 @@ static int get_superblock_attrs(
  105.      superblock->case_insensitive = info.case_insensitive;
  106.      superblock->sparse_file_support = 1; /* always ON for now */
  107.  
  108. +    EASSERT(info.supported_attrs->count > 0);
  109. +    if (bitmap_isset(info.supported_attrs, 1,
  110. +        FATTR4_WORD1_SPACE_USED)) {
  111. +        superblock->supports_space_used_attr = 1;
  112. +    }
  113. +    else {
  114. +        superblock->supports_space_used_attr = 0;
  115. +    }
  116. +    DPRINTF(0, ("get_superblock_attrs(superblock=0x%p): "
  117. +        "attrsupported(FATTR4_WORD1_SPACE_USED)=%d\n",
  118. +        (void *)superblock,
  119. +        (int)superblock->supports_space_used_attr));
  120. +
  121.      if (bitmap_isset(&info.attrmask, 0, FATTR4_WORD0_CANSETTIME))
  122.          superblock->cansettime = info.cansettime;
  123.      else /* cansettime is not supported, try setting them anyway */
  124. @@ -154,14 +169,15 @@ static int get_superblock_attrs(
  125.          "maxread=%llu, maxwrite=%llu, layout_types: 0x%X, "
  126.          "cansettime=%u, time_delta={%llu,%u}, aclsupport=%u, "
  127.          "link_support=%u, symlink_support=%u, case_preserving=%u, "
  128. -        "case_insensitive=%u\n",
  129. +        "case_insensitive=%u supports_space_used_attr=%u\n",
  130.          superblock->fsid.major, superblock->fsid.minor,
  131.          superblock->maxread, superblock->maxwrite,
  132.          superblock->layout_types, superblock->cansettime,
  133.          superblock->time_delta.seconds, superblock->time_delta.nseconds,
  134.          superblock->aclsupport, superblock->link_support,
  135.          superblock->symlink_support, superblock->case_preserving,
  136. -        superblock->case_insensitive));
  137. +        superblock->case_insensitive,
  138. +        superblock->supports_space_used_attr));
  139.  out:
  140.      return status;
  141.  }
  142. diff --git a/daemon/readdir.c b/daemon/readdir.c
  143. index 75a6cf3..2a49913 100644
  144. --- a/daemon/readdir.c
  145. +++ b/daemon/readdir.c
  146. @@ -374,7 +374,16 @@ static void readdir_copy_dir_info(
  147.      }
  148.  
  149.      info->fdi.EndOfFile.QuadPart = entry->attr_info.size;
  150. -    info->fdi.AllocationSize.QuadPart = entry->attr_info.space_used;
  151. +    if (superblock->supports_space_used_attr) {
  152. +        EASSERT(bitmap_isset(&entry->attr_info.attrmask, 1,
  153. +            FATTR4_WORD1_SPACE_USED));
  154. +        info->fdi.AllocationSize.QuadPart =
  155. +            (LONGLONG)entry->attr_info.space_used;
  156. +    }
  157. +    else {
  158. +        info->fdi.AllocationSize.QuadPart =
  159. +            (LONGLONG)entry->attr_info.size;
  160. +    }
  161.  
  162.      info->fdi.FileAttributes =
  163.          nfs_file_info_to_attributes(superblock, &entry->attr_info);

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.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}




All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at