pastebin - collaborative debugging tool
rovema.kpaste.net RSS


msnfs41client: Patches for |FileIdInformation| implementation+fix ACL regression, 2025-03-01
Posted by Anonymous on Sat 1st Mar 2025 14:09
raw | new post

  1. From e1cb1991270655e7c524a254620eea773f00931e Mon Sep 17 00:00:00 2001
  2. From: Roland Mainz <roland.mainz@nrubsig.org>
  3. Date: Sat, 1 Mar 2025 14:40:59 +0100
  4. Subject: [PATCH 1/2] daemon: Fix regression in |handle_getacl()| when
  5.  owner||owner_group is not cached
  6.  
  7. Fix regression in |handle_getacl()| when owner||owner_group is not cached.
  8.  
  9. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  10. ---
  11. daemon/acl.c | 6 ++++--
  12.  1 file changed, 4 insertions(+), 2 deletions(-)
  13.  
  14. diff --git a/daemon/acl.c b/daemon/acl.c
  15. index dbfa975..c098ba7 100644
  16. --- a/daemon/acl.c
  17. +++ b/daemon/acl.c
  18. @@ -368,8 +368,10 @@ use_nfs41_getattr:
  19.           * (usually for new files). In this case do a full
  20.           * roundtrip to the NFS server to get the data...
  21.           */
  22. -        if (bitmap_isset(&info.attrmask, 1, FATTR4_WORD1_OWNER) &&
  23. -            bitmap_isset(&info.attrmask, 1, FATTR4_WORD1_OWNER_GROUP)) {
  24. +        if ((bitmap_isset(&info.attrmask, 1,
  25. +                FATTR4_WORD1_OWNER) == false) ||
  26. +            (bitmap_isset(&info.attrmask, 1,
  27. +                FATTR4_WORD1_OWNER_GROUP) == false)) {
  28.              DPRINTF(ACLLVL2, ("handle_getattr: owner/owner_group not in cache, doing full lookup...\n"));
  29.              goto use_nfs41_getattr;
  30.          }
  31. --
  32. 2.45.1
  33.  
  34. From 1e2ac2b3fe6b0eb0b163d7190be3c9a6862deac7 Mon Sep 17 00:00:00 2001
  35. From: Roland Mainz <roland.mainz@nrubsig.org>
  36. Date: Sat, 1 Mar 2025 14:59:54 +0100
  37. Subject: [PATCH 2/2] daemon,include,sys,tests: Implement |FileIdInformation|
  38.  for PortableGit
  39.  
  40. Implement |FileIdInformation|, used by PortableGit.
  41.  
  42. Reported-by: Josh Hurst <joshhurst@gmail.com>
  43. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  44. ---
  45. daemon/getattr.c             | 15 +++++++++
  46.  daemon/upcall.h              |  1 +
  47.  include/from_kernel.h        |  5 +++
  48.  sys/nfs41sys_fileinfo.c      |  2 ++
  49.  tests/winfsinfo1/winfsinfo.c | 59 ++++++++++++++++++++++++++++++++++++
  50.  5 files changed, 82 insertions(+)
  51.  
  52. diff --git a/daemon/getattr.c b/daemon/getattr.c
  53. index c3c8741..0eb7869 100644
  54. --- a/daemon/getattr.c
  55. +++ b/daemon/getattr.c
  56. @@ -218,6 +218,14 @@ static int handle_getattr(void *daemon_context, nfs41_upcall *upcall)
  57.          nfs_to_remote_protocol_info(state,
  58.              &args->remote_protocol_info);
  59.          break;
  60. +    case FileIdInformation:
  61. +        uint64_t fileid128[2] = {
  62. +            (info.fsid.minor ^ info.fsid.major),
  63. +            info.fileid
  64. +        };
  65. +        args->id_info.VolumeSerialNumber = 0xBABAFACE; /* 64bit! */
  66. +        (void)memcpy(&args->id_info.FileId, &fileid128[0], 16);
  67. +        break;
  68.  #ifdef NFS41_DRIVER_WSL_SUPPORT
  69.      case FileStatInformation:
  70.          nfs_to_stat_info(state->file.name.name,
  71. @@ -295,6 +303,13 @@ static int marshall_getattr(unsigned char *buffer, uint32_t *length, nfs41_upcal
  72.              &args->remote_protocol_info, info_len);
  73.          if (status) goto out;
  74.          break;
  75. +    case FileIdInformation:
  76. +        info_len = sizeof(args->id_info);
  77. +        status = safe_write(&buffer, length, &info_len, sizeof(info_len));
  78. +        if (status) goto out;
  79. +        status = safe_write(&buffer, length, &args->id_info, info_len);
  80. +        if (status) goto out;
  81. +        break;
  82.  #ifdef NFS41_DRIVER_WSL_SUPPORT
  83.      case FileStatInformation:
  84.          info_len = sizeof(args->stat_info);
  85. diff --git a/daemon/upcall.h b/daemon/upcall.h
  86. index abf53ad..19e36f8 100644
  87. --- a/daemon/upcall.h
  88. +++ b/daemon/upcall.h
  89. @@ -107,6 +107,7 @@ typedef struct __getattr_upcall_args {
  90.      FILE_INTERNAL_INFORMATION intr_info;
  91.      FILE_NETWORK_OPEN_INFORMATION network_info;
  92.      FILE_REMOTE_PROTOCOL_INFORMATION remote_protocol_info;
  93. +    FILE_ID_INFORMATION id_info;
  94.  #ifdef NFS41_DRIVER_WSL_SUPPORT
  95.      FILE_STAT_INFORMATION stat_info;
  96.      FILE_STAT_LX_INFORMATION stat_lx_info;
  97. diff --git a/include/from_kernel.h b/include/from_kernel.h
  98. index 962ceef..753f31c 100644
  99. --- a/include/from_kernel.h
  100. +++ b/include/from_kernel.h
  101. @@ -440,6 +440,11 @@ typedef struct _FILE_INTERNAL_INFORMATION {
  102.      LARGE_INTEGER IndexNumber;
  103.  } FILE_INTERNAL_INFORMATION, *PFILE_INTERNAL_INFORMATION;
  104.  
  105. +typedef struct _FILE_ID_INFORMATION {
  106. +    ULONGLONG VolumeSerialNumber;
  107. +    FILE_ID_128 FileId;
  108. +} FILE_ID_INFORMATION, *PFILE_ID_INFORMATION;
  109. +
  110.  /*
  111.   * |FILE_ALLOCATED_RANGE_BUFFER| - test for
  112.   * /usr/i686-w64-mingw32/sys-root/mingw/include/winioctl.h header
  113. diff --git a/sys/nfs41sys_fileinfo.c b/sys/nfs41sys_fileinfo.c
  114. index c8ae273..07bb770 100644
  115. --- a/sys/nfs41sys_fileinfo.c
  116. +++ b/sys/nfs41sys_fileinfo.c
  117. @@ -336,6 +336,7 @@ NTSTATUS nfs41_QueryFileInformation(
  118.      case FileAttributeTagInformation:
  119.      case FileNetworkOpenInformation:
  120.      case FileRemoteProtocolInformation:
  121. +    case FileIdInformation:
  122.  #ifdef NFS41_DRIVER_WSL_SUPPORT
  123.      case FileStatInformation:
  124.      case FileStatLxInformation:
  125. @@ -432,6 +433,7 @@ NTSTATUS nfs41_QueryFileInformation(
  126.              break;
  127.          case FileNetworkOpenInformation:
  128.          case FileRemoteProtocolInformation:
  129. +        case FileIdInformation:
  130.          case FileInternalInformation:
  131.          case FileAttributeTagInformation:
  132.  #ifdef NFS41_DRIVER_WSL_SUPPORT
  133. diff --git a/tests/winfsinfo1/winfsinfo.c b/tests/winfsinfo1/winfsinfo.c
  134. index 6415476..77cc036 100644
  135. --- a/tests/winfsinfo1/winfsinfo.c
  136. +++ b/tests/winfsinfo1/winfsinfo.c
  137. @@ -981,6 +981,61 @@ done:
  138.      return res;
  139.  }
  140.  
  141. +static
  142. +bool get_fileidinfo(const char *progname, const char *filename)
  143. +{
  144. +    int res = EXIT_FAILURE;
  145. +    bool ok;
  146. +    FILE_ID_INFO idinfo;
  147. +    (void)memset(&idinfo, 0, sizeof(idinfo));
  148. +
  149. +    HANDLE fileHandle = CreateFileA(filename,
  150. +        GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING,
  151. +        FILE_FLAG_BACKUP_SEMANTICS, NULL);
  152. +    if (fileHandle == INVALID_HANDLE_VALUE) {
  153. +        (void)fprintf(stderr,
  154. +            "%s: Error opening file '%s'. Last error was %d.\n",
  155. +            progname,
  156. +            filename,
  157. +            (int)GetLastError());
  158. +        return EXIT_FAILURE;
  159. +    }
  160. +
  161. +    ok = GetFileInformationByHandleEx(fileHandle,
  162. +        FileIdInfo,
  163. +        &idinfo, sizeof(idinfo));
  164. +
  165. +    if (!ok) {
  166. +        (void)fprintf(stderr, "%s: GetFileInformationByHandleEx() "
  167. +            "error. GetLastError()==%d.\n",
  168. +            progname,
  169. +            (int)GetLastError());
  170. +        res = EXIT_FAILURE;
  171. +        goto done;
  172. +    }
  173. +
  174. +    (void)printf("(\n");
  175. +    (void)printf("\tfilename='%s'\n", filename);
  176. +
  177. +    (void)printf("\tVolumeSerialNumber=0x%llx\n",
  178. +        idinfo.VolumeSerialNumber);
  179. +    (void)printf("\ttypeset -a FileId=(\n");
  180. +    int i;
  181. +    for (i=0 ; i < 16 ; i++) {
  182. +        (void)printf("\t\t[%d]=0x%02.2x\n",
  183. +            i,
  184. +            (int)idinfo.FileId.Identifier[i]);
  185. +    }
  186. +    (void)printf("\t)\n");
  187. +
  188. +    (void)printf(")\n");
  189. +    res = EXIT_SUCCESS;
  190. +
  191. +done:
  192. +    (void)CloseHandle(fileHandle);
  193. +    return res;
  194. +}
  195. +
  196.  static
  197.  int fsctlqueryallocatedranges(const char *progname, const char *filename)
  198.  {
  199. @@ -1152,6 +1207,7 @@ void usage(void)
  200.          "getfiletime|"
  201.          "nfs3attr|"
  202.          "fileremoteprotocolinfo|"
  203. +        "fileidinfo|"
  204.          "fsctlqueryallocatedranges"
  205.          "> path\n");
  206.  }
  207. @@ -1211,6 +1267,9 @@ int main(int ac, char *av[])
  208.      else if (!strcmp(subcmd, "fileremoteprotocolinfo")) {
  209.          return get_file_remote_protocol_info(av[0], av[2]);
  210.      }
  211. +    else if (!strcmp(subcmd, "fileidinfo")) {
  212. +        return get_fileidinfo(av[0], av[2]);
  213. +    }
  214.      else if (!strcmp(subcmd, "fsctlqueryallocatedranges")) {
  215.          return fsctlqueryallocatedranges(av[0], av[2]);
  216.      }
  217. --
  218. 2.45.1

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