pastebin - collaborative debugging tool
rovema.kpaste.net RSS


msnfs42client: Add infrastructure so Cygwin |stat()| can return local uid/gid
Posted by Anonymous on Mon 9th Oct 2023 17:45
raw | new post
modification of post by Anonymous (view diff)

  1. From fc428284ffc8e6e74946641facf6c828878e8c59 Mon Sep 17 00:00:00 2001
  2. From: Roland Mainz <roland.mainz@nrubsig.org>
  3. Date: Mon, 9 Oct 2023 17:42:23 +0200
  4. Subject: [PATCH 1/2] Add infrastructure so Cygwin |stat()| can return local
  5.  uid/gid
  6.  
  7. Add infrastructure so Cygwin |stat()| can return local uid/gid via
  8. the private "NfsV3Attributes" API (originally added by Microsoft
  9. for their NFSv3 client).
  10.  
  11. The code is currently disabled (set
  12. |NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES| to |1| in
  13. sys/nfs41_build_features.h to enable it), until we wire it into
  14. the idmap code.
  15.  
  16. Additionally we add sys/nfs41_build_features.h to enable/disable
  17. features during build time.
  18.  
  19. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  20. ---
  21. daemon/open.c              | 135 ++++++++++++++++++++++++++++++++++++-
  22.  daemon/upcall.h            |   5 ++
  23.  sys/nfs41_build_features.h |  38 +++++++++++
  24.  sys/nfs41_driver.c         | 122 +++++++++++++++++++++++----------
  25.  4 files changed, 261 insertions(+), 39 deletions(-)
  26.  create mode 100644 sys/nfs41_build_features.h
  27.  
  28. diff --git a/daemon/open.c b/daemon/open.c
  29. index c7bd412..9d564d6 100644
  30. --- a/daemon/open.c
  31. +++ b/daemon/open.c
  32. @@ -21,16 +21,17 @@
  33.  
  34.  #include <Windows.h>
  35.  #include <stdio.h>
  36. +#include <ctype.h>
  37.  #include <strsafe.h>
  38.  
  39.  #include "nfs41_ops.h"
  40. +#include "nfs41_build_features.h"
  41.  #include "delegation.h"
  42.  #include "from_kernel.h"
  43.  #include "daemon_debug.h"
  44.  #include "upcall.h"
  45.  #include "util.h"
  46.  
  47. -
  48.  static int create_open_state(
  49.      IN const char *path,
  50.      IN uint32_t open_owner_id,
  51. @@ -295,6 +296,12 @@ static int parse_open(unsigned char *buffer, uint32_t length, nfs41_upcall *upca
  52.      if (status) goto out;
  53.      status = safe_read(&buffer, &length, &args->mode, sizeof(DWORD));
  54.      if (status) goto out;
  55. +#ifdef NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES
  56. +    status = safe_read(&buffer, &length, &args->owner_local_uid, sizeof(DWORD));
  57. +    if (status) goto out;
  58. +    status = safe_read(&buffer, &length, &args->owner_group_local_gid, sizeof(DWORD));
  59. +    if (status) goto out;
  60. +#endif /* NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES */
  61.      status = safe_read(&buffer, &length, &args->srv_open, sizeof(HANDLE));
  62.      if (status) goto out;
  63.      status = parse_abs_path(&buffer, &length, &args->symlink);
  64. @@ -305,9 +312,16 @@ static int parse_open(unsigned char *buffer, uint32_t length, nfs41_upcall *upca
  65.      dprintf(1, "parsing NFS41_OPEN: filename='%s' access mask=%d "
  66.          "access mode=%d\n\tfile attrs=0x%x create attrs=0x%x "
  67.          "(kernel) disposition=%d\n\topen_owner_id=%d mode=%o "
  68. +#ifdef NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES
  69. +        "owner_local_uid=%u owner_group_local_gid=%u "
  70. +#endif /* NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES */
  71.          "srv_open=%p symlink=%s ea=%p\n", args->path, args->access_mask,
  72.          args->access_mode, args->file_attrs, args->create_opts,
  73. -        args->disposition, args->open_owner_id, args->mode, args->srv_open,
  74. +        args->disposition, args->open_owner_id, args->mode,
  75. +#ifdef NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES
  76. +        (unsigned int)args->owner_local_uid, (unsigned int)args->owner_group_local_gid,
  77. +#endif /* NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES */
  78. +        args->srv_open,
  79.          args->symlink.path, args->ea);
  80.      print_disposition(2, args->disposition);
  81.      print_access_mask(2, args->access_mask);
  82. @@ -644,6 +658,117 @@ static int handle_open(nfs41_upcall *upcall)
  83.          nfs_to_standard_info(&info, &args->std_info);
  84.          args->mode = info.mode;
  85.          args->changeattr = info.change;
  86. +
  87. +#ifdef NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES
  88. +        bitmap4 og_attr_request = { 0 };
  89. +        nfs41_file_info og_info = { 0 };
  90. +        char owner[NFS4_OPAQUE_LIMIT], group[NFS4_OPAQUE_LIMIT];
  91. +        nfsacl41 acl = { 0 };
  92. +
  93. +        /*
  94. +         * gisburn:
  95. +         * 1. We should cache owner/group information
  96. +         * 2. We should always ask for
  97. +         * FATTR4_WORD1_OWNER | FATTR4_WORD1_OWNER_GROUP with the other
  98. +         * attributes
  99. +         */
  100. +        og_attr_request.count = 2;
  101. +        og_attr_request.arr[1] = FATTR4_WORD1_OWNER | FATTR4_WORD1_OWNER_GROUP;
  102. +        og_info.owner = owner;
  103. +        og_info.owner_group = group;
  104. +        status = nfs41_getattr(state->session, &state->file, &og_attr_request, &og_info);
  105. +        if (status) {
  106. +            eprintf("get_stat_data: nfs41_cached_getattr() failed with %d\n",
  107. +            status);
  108. +        }
  109. +
  110. +#ifdef NFS41_DRIVER_FEATURE_LOCAL_UIDGID_TESTMAPPING
  111. +        /*
  112. +         * Map owner to local uid
  113. +         *
  114. +         * |owner| can be numeric string ("1616"), plain username
  115. +         *  ("gisburn") or username@domain ("gisburn@sun.com")
  116. +         */
  117. +        /* stomp over '@' */
  118. +        char *at_ch; /* pointer to '@' */
  119. +        if (at_ch = strchr(og_info.owner, '@'))
  120. +            *at_ch = '\0';
  121. +
  122. +        if (isdigit(og_info.owner[0])) {
  123. +            args->owner_local_uid = atol(og_info.owner);
  124. +        }
  125. +        else if(!strcmp(og_info.owner, "nobody")) {
  126. +            args->owner_local_uid = 65534;
  127. +        }
  128. +        else if(!strcmp(og_info.owner, "root")) {
  129. +            args->owner_local_uid = 0;
  130. +        }
  131. +        else if(!strcmp(og_info.owner, "rmainz")) {
  132. +            args->owner_local_uid = 1616;
  133. +        }
  134. +        else if(!strcmp(og_info.owner, "roland_mainz")) {
  135. +            args->owner_local_uid = 197608;
  136. +        }
  137. +        else if(!strcmp(og_info.owner, "swulsch")) {
  138. +            args->owner_local_uid = 1818;
  139. +        }
  140. +        else if(!strcmp(og_info.owner, "iam")) {
  141. +            args->owner_local_uid = 2010;
  142. +        }
  143. +        else if(!strcmp(og_info.owner, "mwenzel")) {
  144. +            args->owner_local_uid = 8239;
  145. +        }
  146. +        else if(!strcmp(og_info.owner, "test001")) {
  147. +            args->owner_local_uid = 1000;
  148. +        }
  149. +        else {
  150. +            args->owner_local_uid = 666; /* debug: number of the beast */
  151. +        }
  152. +
  153. +        /*
  154. +         * Map owner_group to local gid
  155. +         *
  156. +         * |owner_group| can be numeric string ("1616"), plain username
  157. +         * ("gisgrp") or username@domain ("gisgrp@sun.com")
  158. +         */
  159. +        if (at_ch = strchr(og_info.owner_group, '@'))
  160. +            *at_ch = '\0';
  161. +        if (isdigit(og_info.owner_group[0])) {
  162. +            args->owner_group_local_gid = atol(og_info.owner_group);
  163. +        }
  164. +        else if(!strcmp(og_info.owner_group, "nogroup")) {
  165. +            args->owner_group_local_gid = 65534;
  166. +        }
  167. +        else if(!strcmp(og_info.owner_group, "root")) {
  168. +            args->owner_group_local_gid = 0;
  169. +        }
  170. +        else if(!strcmp(og_info.owner_group, "Kein")) {
  171. +            args->owner_group_local_gid = 197121;
  172. +        }
  173. +        else if(!strcmp(og_info.owner_group, "rmainz")) {
  174. +            args->owner_group_local_gid = 1616;
  175. +        }
  176. +        else if(!strcmp(og_info.owner, "iam")) {
  177. +            args->owner_group_local_gid = 2010;
  178. +        }
  179. +        else if(!strcmp(og_info.owner_group, "swulsch")) {
  180. +            args->owner_group_local_gid = 1818;
  181. +        }
  182. +        else if(!strcmp(og_info.owner_group, "mwenzel")) {
  183. +            args->owner_group_local_gid = 8239;
  184. +        }
  185. +        else if(!strcmp(og_info.owner_group, "test001")) {
  186. +            args->owner_group_local_gid = 1000;
  187. +        }
  188. +        else {
  189. +            args->owner_group_local_gid = 666; /* debug: number of the beast */
  190. +        }
  191. +#endif /* NFS41_DRIVER_FEATURE_LOCAL_UIDGID_TESTMAPPING */
  192. +
  193. +        dprintf(1, "handle_open: stat: owner=%u/'%s', owner_group=%u/'%s'\n",
  194. +            (unsigned int)args->owner_local_uid, og_info.owner,
  195. +            (unsigned int)args->owner_group_local_gid, og_info.owner_group);
  196. +#endif /* NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES */
  197.      } else {
  198.          nfs41_file_info createattrs = { 0 };
  199.          uint32_t create = 0, createhowmode = 0, lookup_status = status;
  200. @@ -753,6 +878,12 @@ static int marshall_open(unsigned char *buffer, uint32_t *length, nfs41_upcall *
  201.      if (status) goto out;
  202.      status = safe_write(&buffer, length, &args->mode, sizeof(args->mode));
  203.      if (status) goto out;
  204. +#ifdef NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES
  205. +    status = safe_write(&buffer, length, &args->owner_local_uid, sizeof(args->owner_local_uid));
  206. +    if (status) goto out;
  207. +    status = safe_write(&buffer, length, &args->owner_group_local_gid, sizeof(args->owner_group_local_gid));
  208. +    if (status) goto out;
  209. +#endif /* NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES */
  210.      status = safe_write(&buffer, length, &args->changeattr, sizeof(args->changeattr));
  211.      if (status) goto out;
  212.      status = safe_write(&buffer, length, &args->deleg_type, sizeof(args->deleg_type));
  213. diff --git a/daemon/upcall.h b/daemon/upcall.h
  214. index d224a6d..6dad62d 100644
  215. --- a/daemon/upcall.h
  216. +++ b/daemon/upcall.h
  217. @@ -23,6 +23,7 @@
  218.  #define __NFS41_DAEMON_UPCALL_H__
  219.  
  220.  #include "nfs41_ops.h"
  221. +#include "nfs41_build_features.h"
  222.  #include "from_kernel.h"
  223.  
  224.  #define NFSD_VERSION_MISMATCH 116
  225. @@ -50,6 +51,10 @@ typedef struct __open_upcall_args {
  226.      ULONG create_opts;
  227.      LONG open_owner_id;
  228.      DWORD mode;
  229. +#ifdef NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES
  230. +    DWORD owner_local_uid;         /* owner mapped into local uid */
  231. +    DWORD owner_group_local_gid;   /* owner group mapped into local gid */
  232. +#endif /* NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES */
  233.      ULONGLONG changeattr;
  234.      HANDLE srv_open;
  235.      DWORD deleg_type;
  236. diff --git a/sys/nfs41_build_features.h b/sys/nfs41_build_features.h
  237. new file mode 100644
  238. index 0000000..4ce5976
  239. --- /dev/null
  240. +++ b/sys/nfs41_build_features.h
  241. @@ -0,0 +1,38 @@
  242. +/* NFSv4.1 client for Windows
  243. + * Copyright © 2012 The Regents of the University of Michigan
  244. + *
  245. + * Olga Kornievskaia <aglo@umich.edu>
  246. + * Casey Bodley <cbodley@umich.edu>
  247. + * Roland Mainz <roland.mainz@nrubsig.org>
  248. + *
  249. + * This library is free software; you can redistribute it and/or modify it
  250. + * under the terms of the GNU Lesser General Public License as published by
  251. + * the Free Software Foundation; either version 2.1 of the License, or (at
  252. + * your option) any later version.
  253. + *
  254. + * This library is distributed in the hope that it will be useful, but
  255. + * without any warranty; without even the implied warranty of merchantability
  256. + * or fitness for a particular purpose.  See the GNU Lesser General Public
  257. + * License for more details.
  258. + *
  259. + * You should have received a copy of the GNU Lesser General Public License
  260. + * along with this library; if not, write to the Free Software Foundation,
  261. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  262. + */
  263. +
  264. +#ifndef _NFS41_DRIVER_BUILDFEATURES_
  265. +#define _NFS41_DRIVER_BUILDFEATURES_ 1
  266. +
  267. +/*
  268. + * NFS41_DRIVER_FEATURE_* - features for this build, we use this
  269. + * for development to add new features which are "off" by default
  270. + * until they are ready
  271. + */
  272. +
  273. +/*
  274. + * NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES - return local uid/gid values
  275. + */
  276. +// #define NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES 1
  277. +// #define NFS41_DRIVER_FEATURE_LOCAL_UIDGID_TESTMAPPING 1
  278. +
  279. +#endif /* !_NFS41_DRIVER_BUILDFEATURES_ */
  280. diff --git a/sys/nfs41_driver.c b/sys/nfs41_driver.c
  281. index 6a8061d..b52a151 100644
  282. --- a/sys/nfs41_driver.c
  283. +++ b/sys/nfs41_driver.c
  284. @@ -29,6 +29,8 @@
  285.  #include "nfs41_driver.h"
  286.  #include "nfs41_np.h"
  287.  #include "nfs41_debug.h"
  288. +#include "nfs41_build_features.h"
  289. +
  290.  
  291.  #define USE_MOUNT_SEC_CONTEXT
  292.  
  293. @@ -200,6 +202,10 @@ typedef struct _updowncall_entry {
  294.              ULONG cattrs;
  295.              LONG open_owner_id;
  296.              DWORD mode;
  297. +#ifdef NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES
  298. +            DWORD owner_local_uid;
  299. +            DWORD owner_group_local_gid;
  300. +#endif /* NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES */
  301.              HANDLE srv_open;
  302.              DWORD deleg_type;
  303.              BOOLEAN symlink_embedded;
  304. @@ -385,6 +391,10 @@ typedef struct _NFS41_FCB {
  305.      BOOLEAN                 Renamed;
  306.      BOOLEAN                 DeletePending;
  307.      DWORD                   mode;
  308. +#ifdef NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES
  309. +    DWORD                   owner_local_uid;       /* owner mapped into local uid */
  310. +    DWORD                   owner_group_local_gid; /* owner group mapped into local gid */
  311. +#endif /* NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES */
  312.      ULONGLONG               changeattr;    
  313.  } NFS41_FCB, *PNFS41_FCB;
  314.  #define NFS41GetFcbExtension(pFcb)      \
  315. @@ -612,13 +622,13 @@ NTSTATUS marshal_nfs41_mount(
  316.      if (!MmIsAddressValid(entry->u.Mount.srv_name) ||
  317.              !MmIsAddressValid(entry->u.Mount.root)) {
  318.          status = STATUS_INTERNAL_ERROR;
  319. -        goto out;
  320. -    }
  321. -    header_len = *len + length_as_utf8(entry->u.Mount.srv_name) +
  322. -        length_as_utf8(entry->u.Mount.root) + 3 * sizeof(DWORD);
  323. -    if (header_len > buf_len) {
  324. -        status = STATUS_INSUFFICIENT_RESOURCES;
  325. -        goto out;
  326. +        goto out;
  327. +    }
  328. +    header_len = *len + length_as_utf8(entry->u.Mount.srv_name) +
  329. +        length_as_utf8(entry->u.Mount.root) + 3 * sizeof(DWORD);
  330. +    if (header_len > buf_len) {
  331. +        status = STATUS_INSUFFICIENT_RESOURCES;
  332. +        goto out;
  333.      }
  334.      status = marshall_unicode_as_utf8(&tmp, entry->u.Mount.srv_name);
  335.      if (status) goto out;
  336. @@ -667,7 +677,11 @@ NTSTATUS marshal_nfs41_open(
  337.      else tmp += *len;
  338.  
  339.      header_len = *len + length_as_utf8(entry->filename) +
  340. -        7 * sizeof(ULONG) + 2 * sizeof(HANDLE) +
  341. +        7 * sizeof(ULONG) +
  342. +#ifdef NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES
  343. +        2 * sizeof(DWORD) +
  344. +#endif /* NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES */
  345. +        2 * sizeof(HANDLE) +
  346.          length_as_utf8(&entry->u.Open.symlink);
  347.      if (header_len > buf_len) {
  348.          status = STATUS_INSUFFICIENT_RESOURCES;
  349. @@ -692,6 +706,12 @@ NTSTATUS marshal_nfs41_open(
  350.      tmp += sizeof(entry->u.Open.open_owner_id);
  351.      RtlCopyMemory(tmp, &entry->u.Open.mode, sizeof(DWORD));
  352.      tmp += sizeof(DWORD);
  353. +#ifdef NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES
  354. +    RtlCopyMemory(tmp, &entry->u.Open.owner_local_uid, sizeof(DWORD));
  355. +    tmp += sizeof(DWORD);
  356. +    RtlCopyMemory(tmp, &entry->u.Open.owner_group_local_gid, sizeof(DWORD));
  357. +    tmp += sizeof(DWORD);
  358. +#endif /* NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES */
  359.      RtlCopyMemory(tmp, &entry->u.Open.srv_open, sizeof(HANDLE));
  360.      tmp += sizeof(HANDLE);
  361.      status = marshall_unicode_as_utf8(&tmp, &entry->u.Open.symlink);
  362. @@ -718,10 +738,17 @@ NTSTATUS marshal_nfs41_open(
  363.  
  364.  #ifdef DEBUG_MARSHAL_DETAIL
  365.      DbgP("marshal_nfs41_open: name=%wZ mask=0x%x access=0x%x attrs=0x%x "
  366. -         "opts=0x%x dispo=0x%x open_owner_id=0x%x mode=%o srv_open=%p ea=%p\n",
  367. +         "opts=0x%x dispo=0x%x open_owner_id=0x%x mode=%o "
  368. +#ifdef NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES
  369. +         "owner_local_uid=%lu owner_group_local_gid=%lu "
  370. +#endif /* NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES */
  371. +         "srv_open=%p ea=%p\n",
  372.           entry->filename, entry->u.Open.access_mask,
  373.           entry->u.Open.access_mode, entry->u.Open.attrs, entry->u.Open.copts,
  374.           entry->u.Open.disp, entry->u.Open.open_owner_id, entry->u.Open.mode,
  375. +#ifdef NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES
  376. +         entry->u.Open.owner_local_uid,entry->u.Open.owner_group_local_gid,
  377. +#endif /* NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES */
  378.           entry->u.Open.srv_open, entry->u.Open.EaBuffer);
  379.  #endif
  380.  out:
  381. @@ -1647,6 +1674,12 @@ NTSTATUS unmarshal_nfs41_open(
  382.      *buf += sizeof(HANDLE);
  383.      RtlCopyMemory(&cur->u.Open.mode, *buf, sizeof(DWORD));
  384.      *buf += sizeof(DWORD);
  385. +#ifdef NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES
  386. +    RtlCopyMemory(&cur->u.Open.owner_local_uid, *buf, sizeof(DWORD));
  387. +    *buf += sizeof(DWORD);
  388. +    RtlCopyMemory(&cur->u.Open.owner_group_local_gid, *buf, sizeof(DWORD));
  389. +    *buf += sizeof(DWORD);
  390. +#endif /* NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES */
  391.      RtlCopyMemory(&cur->ChangeTime, *buf, sizeof(ULONGLONG));
  392.      *buf += sizeof(ULONGLONG);
  393.      RtlCopyMemory(&cur->u.Open.deleg_type, *buf, sizeof(DWORD));
  394. @@ -1673,10 +1706,17 @@ NTSTATUS unmarshal_nfs41_open(
  395.  #endif
  396.      }
  397.  #ifdef DEBUG_MARSHAL_DETAIL
  398. -    DbgP("unmarshal_nfs41_open: open_state 0x%x mode %o changeattr %llu "
  399. -        "deleg_type %d\n", cur->open_state, cur->u.Open.mode,
  400. +    DbgP("unmarshal_nfs41_open: open_state 0x%x mode %o "
  401. +#ifdef NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES
  402. +        "owner_local_uid %u owner_group_local_gid %u "
  403. +#endif /* NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES */
  404. +        "changeattr %llu "
  405. +        "deleg_type %d\n", cur->open_state, cur->u.Open.mode,
  406. +#ifdef NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES
  407. +        cur->u.Open.owner_local_uid, cur->u.Open.owner_group_local_gid,
  408. +#endif /* NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES */
  409.          cur->ChangeTime, cur->u.Open.deleg_type);
  410. -#endif
  411. +#endif /* DEBUG_MARSHAL_DETAIL */
  412.  out:
  413.      return status;
  414.  }
  415. @@ -3500,15 +3540,15 @@ NTSTATUS check_nfs41_create_args(
  416.      }
  417.  
  418.      /* rdbss seems miss this sharing_violation check */
  419. -    if (Fcb->OpenCount && params->Disposition == FILE_SUPERSEDE) {
  420. -        if ((!RxContext->CurrentIrpSp->FileObject->SharedRead &&
  421. -                (params->DesiredAccess & FILE_READ_DATA)) ||
  422. -            ((!RxContext->CurrentIrpSp->FileObject->SharedWrite &&
  423. -                (params->DesiredAccess & (FILE_WRITE_DATA | FILE_APPEND_DATA |
  424. -                    FILE_WRITE_ATTRIBUTES))) ||
  425. -            (!RxContext->CurrentIrpSp->FileObject->SharedDelete &&
  426. -                (params->DesiredAccess & DELETE)))) {
  427. -            status = STATUS_SHARING_VIOLATION;
  428. +    if (Fcb->OpenCount && params->Disposition == FILE_SUPERSEDE) {
  429. +        if ((!RxContext->CurrentIrpSp->FileObject->SharedRead &&
  430. +                (params->DesiredAccess & FILE_READ_DATA)) ||
  431. +            ((!RxContext->CurrentIrpSp->FileObject->SharedWrite &&
  432. +                (params->DesiredAccess & (FILE_WRITE_DATA | FILE_APPEND_DATA |
  433. +                    FILE_WRITE_ATTRIBUTES))) ||
  434. +            (!RxContext->CurrentIrpSp->FileObject->SharedDelete &&
  435. +                (params->DesiredAccess & DELETE)))) {
  436. +            status = STATUS_SHARING_VIOLATION;
  437.              goto out;
  438.          }
  439.      }
  440. @@ -3754,6 +3794,10 @@ retry_on_link:
  441.          RtlCopyMemory(&nfs41_fcb->StandardInfo, &entry->u.Open.sinfo,
  442.              sizeof(entry->u.Open.sinfo));
  443.          nfs41_fcb->mode = entry->u.Open.mode;
  444. +#ifdef NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES
  445. +        nfs41_fcb->owner_local_uid = entry->u.Open.owner_local_uid;
  446. +        nfs41_fcb->owner_group_local_gid = entry->u.Open.owner_group_local_gid;
  447. +#endif /* NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES */
  448.          nfs41_fcb->changeattr = entry->ChangeTime;
  449.          if (((params->CreateOptions & FILE_DELETE_ON_CLOSE) &&
  450.                  !pVNetRootContext->read_only) || oldDeletePending)
  451. @@ -4311,14 +4355,14 @@ NTSTATUS nfs41_QueryVolumeInformation(
  452.      print_queryvolume_args(RxContext);
  453.  #endif
  454.  
  455. -    status = check_nfs41_dirquery_args(RxContext);
  456. -    if (status) goto out;
  457. -
  458. -    RtlZeroMemory(RxContext->Info.Buffer, RxContext->Info.LengthRemaining);
  459. -
  460. -    switch (InfoClass) {
  461. -    case FileFsVolumeInformation:
  462. -        if ((ULONG)RxContext->Info.LengthRemaining >= DevExt->VolAttrsLen) {
  463. +    status = check_nfs41_dirquery_args(RxContext);
  464. +    if (status) goto out;
  465. +
  466. +    RtlZeroMemory(RxContext->Info.Buffer, RxContext->Info.LengthRemaining);
  467. +
  468. +    switch (InfoClass) {
  469. +    case FileFsVolumeInformation:
  470. +        if ((ULONG)RxContext->Info.LengthRemaining >= DevExt->VolAttrsLen) {
  471.              RtlCopyMemory(RxContext->Info.Buffer, DevExt->VolAttrs,
  472.                  DevExt->VolAttrsLen);
  473.              RxContext->Info.LengthRemaining -= DevExt->VolAttrsLen;
  474. @@ -4502,6 +4546,10 @@ void create_nfs3_attrs(
  475.      else
  476.          attrs->type = NF3REG;
  477.      attrs->mode = nfs41_fcb->mode;
  478. +#ifdef NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES
  479. +    attrs->uid = nfs41_fcb->owner_local_uid;
  480. +    attrs->gid = nfs41_fcb->owner_group_local_gid;
  481. +#endif /* NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES */
  482.      attrs->nlink = nfs41_fcb->StandardInfo.NumberOfLinks;
  483.      attrs->size.QuadPart = attrs->used.QuadPart =
  484.          nfs41_fcb->StandardInfo.EndOfFile.QuadPart;
  485. @@ -6085,14 +6133,14 @@ NTSTATUS nfs41_Lock(
  486.      LARGE_INTEGER poll_delay = {0};
  487.  #ifdef ENABLE_TIMINGS
  488.      LARGE_INTEGER t1, t2;
  489. -    t1 = KeQueryPerformanceCounter(NULL);
  490. -#endif
  491. -
  492. -    poll_delay.QuadPart = 0;
  493. -
  494. -#ifdef DEBUG_LOCK
  495. -    DbgEn();
  496. -    print_lock_args(RxContext);
  497. +    t1 = KeQueryPerformanceCounter(NULL);
  498. +#endif
  499. +
  500. +    poll_delay.QuadPart = 0;
  501. +
  502. +#ifdef DEBUG_LOCK
  503. +    DbgEn();
  504. +    print_lock_args(RxContext);
  505.  #endif
  506.  
  507.  /*  RxReleaseFcbResourceForThreadInMRx(RxContext, RxContext->pFcb,
  508. --
  509. 2.39.0

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