pastebin - collaborative debugging tool
nrubsig.kpaste.net RSS


0002-daemon-nfs41_build_features.h-Implement-Win32-FILE_A.patch
Posted by Anonymous on Mon 15th Sep 2025 10:55
raw | new post

  1. From db91ea3a80b53bbc4d65477905e8c5648ffd3478 Mon Sep 17 00:00:00 2001
  2. From: Roland Mainz <roland.mainz@nrubsig.org>
  3. Date: Sat, 13 Sep 2025 15:37:08 +0200
  4. Subject: [PATCH 2/2] daemon,nfs41_build_features.h: Implement Win32
  5.  |FILE_ATTRIBUTE_OFFLINE| via |FATTR4_OFFLINE|
  6.  
  7. Implement Win32 |FILE_ATTRIBUTE_OFFLINE| via RFC9754 |FATTR4_OFFLINE|
  8. (see https://datatracker.ietf.org/doc/rfc9754/).
  9.  
  10. Reported-by: Lionel Cons <Lionelcons1972@gmail.com>
  11. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  12. ---
  13. daemon/daemon_debug.c     |  3 +++
  14.  daemon/fileinfoutil.c     |  5 ++++
  15.  daemon/lookup.c           |  3 ++-
  16.  daemon/name_cache.c       | 48 +++++++++++++++++++++++----------------
  17.  daemon/nfs41_superblock.c |  2 +-
  18.  daemon/nfs41_types.h      |  2 ++
  19.  daemon/nfs41_xdr.c        | 11 +++++++++
  20.  daemon/open.c             |  1 +
  21.  daemon/setattr.c          |  9 ++++++++
  22.  nfs41_build_features.h    | 10 ++++++++
  23.  10 files changed, 73 insertions(+), 21 deletions(-)
  24.  
  25. diff --git a/daemon/daemon_debug.c b/daemon/daemon_debug.c
  26. index 02a0aec..19d9e6e 100644
  27. --- a/daemon/daemon_debug.c
  28. +++ b/daemon/daemon_debug.c
  29. @@ -1147,6 +1147,9 @@ void print_nfs41_file_info(
  30.                  (long)info->clone_blksize);
  31.          }
  32.  
  33. +        if (info->attrmask.arr[2] & FATTR4_WORD2_OFFLINE)
  34. +            PRNFS41FI_FMT("offline=%d, ", (int)info->offline);
  35. +
  36.          p += snprintf(p, (sizeof(buf)-(p-buf)), "} ");
  37.      }
  38.  
  39. diff --git a/daemon/fileinfoutil.c b/daemon/fileinfoutil.c
  40. index 2556c87..3466cfd 100644
  41. --- a/daemon/fileinfoutil.c
  42. +++ b/daemon/fileinfoutil.c
  43. @@ -84,6 +84,8 @@ ULONG nfs_file_info_to_attributes(
  44.          attrs |= FILE_ATTRIBUTE_SYSTEM;
  45.      if (info->archive)
  46.          attrs |= FILE_ATTRIBUTE_ARCHIVE;
  47. +    if (info->offline)
  48. +        attrs |= FILE_ATTRIBUTE_OFFLINE;
  49.  
  50.      /*
  51.       * |FILE_ATTRIBUTE_NORMAL| attribute is only set if no other
  52. @@ -637,6 +639,9 @@ void nfs41_file_info_cpy(
  53.          if (attrmask->arr[2] & FATTR4_WORD2_CLONE_BLKSIZE) {
  54.              dest->clone_blksize = src->clone_blksize;
  55.          }
  56. +        if (attrmask->arr[2] & FATTR4_WORD2_OFFLINE) {
  57. +            dest->offline = src->offline;
  58. +        }
  59.      }
  60.  
  61.      if (flags & NFS41FILEINFOCPY_COPY_SYMLINK_DIR) {
  62. diff --git a/daemon/lookup.c b/daemon/lookup.c
  63. index 4eb6808..d56307d 100644
  64. --- a/daemon/lookup.c
  65. +++ b/daemon/lookup.c
  66. @@ -96,7 +96,7 @@ static void init_component_args(
  67.  {
  68.      uint32_t i;
  69.  
  70. -    args->attr_request.count = 2;
  71. +    args->attr_request.count = 3;
  72.      args->attr_request.arr[0] = FATTR4_WORD0_TYPE
  73.          | FATTR4_WORD0_CHANGE | FATTR4_WORD0_SIZE
  74.          | FATTR4_WORD0_FSID | FATTR4_WORD0_FILEID
  75. @@ -107,6 +107,7 @@ static void init_component_args(
  76.          | FATTR4_WORD1_TIME_ACCESS | FATTR4_WORD1_TIME_CREATE
  77.          | FATTR4_WORD1_TIME_MODIFY
  78.          | FATTR4_WORD1_OWNER | FATTR4_WORD1_OWNER_GROUP;
  79. +    args->attr_request.arr[2] = FATTR4_WORD2_OFFLINE;
  80.  
  81.      args->getrootattr.attr_request = &args->attr_request;
  82.      res->root.path = path;
  83. diff --git a/daemon/name_cache.c b/daemon/name_cache.c
  84. index f025983..1ef1a47 100644
  85. --- a/daemon/name_cache.c
  86. +++ b/daemon/name_cache.c
  87. @@ -77,22 +77,23 @@ static __inline bool_t is_delegation(
  88.      return type == OPEN_DELEGATE_READ || type == OPEN_DELEGATE_WRITE;
  89.  }
  90.  
  91. -#define NC_ATTR_TYPE        (1 <<  0)
  92. -#define NC_ATTR_CHANGE      (1 <<  1)
  93. -#define NC_ATTR_FSID        (1 <<  2)
  94. -#define NC_ATTR_SIZE        (1 <<  3)
  95. -#define NC_ATTR_SPACE_USED  (1 <<  4)
  96. -#define NC_ATTR_HIDDEN      (1 <<  5)
  97. -#define NC_ATTR_ARCHIVE     (1 <<  6)
  98. -#define NC_ATTR_MODE        (1 <<  7)
  99. -#define NC_ATTR_NUMLINKS    (1 <<  8)
  100. -#define NC_ATTR_OWNER       (1 <<  9)
  101. -#define NC_ATTR_OWNER_GROUP (1 << 10)
  102. -#define NC_ATTR_TIME_ACCESS (1 << 11)
  103. -#define NC_ATTR_TIME_CREATE (1 << 12)
  104. -#define NC_ATTR_TIME_MODIFY (1 << 13)
  105. -#define NC_ATTR_SYSTEM      (1 << 14)
  106. -#define NC_ATTR_CLONE_BLKSIZE (1 << 15)
  107. +#define NC_ATTR_TYPE            (1 <<  0)
  108. +#define NC_ATTR_CHANGE          (1 <<  1)
  109. +#define NC_ATTR_FSID            (1 <<  2)
  110. +#define NC_ATTR_SIZE            (1 <<  3)
  111. +#define NC_ATTR_SPACE_USED      (1 <<  4)
  112. +#define NC_ATTR_HIDDEN          (1 <<  5)
  113. +#define NC_ATTR_ARCHIVE         (1 <<  6)
  114. +#define NC_ATTR_SYSTEM          (1 <<  7)
  115. +#define NC_ATTR_OFFLINE         (1 <<  8)
  116. +#define NC_ATTR_MODE            (1 <<  9)
  117. +#define NC_ATTR_NUMLINKS        (1 << 10)
  118. +#define NC_ATTR_OWNER           (1 << 11)
  119. +#define NC_ATTR_OWNER_GROUP     (1 << 12)
  120. +#define NC_ATTR_TIME_ACCESS     (1 << 13)
  121. +#define NC_ATTR_TIME_CREATE     (1 << 14)
  122. +#define NC_ATTR_TIME_MODIFY     (1 << 15)
  123. +#define NC_ATTR_CLONE_BLKSIZE   (1 << 16)
  124.  
  125.  /* attribute cache */
  126.  struct attr_cache_entry {
  127. @@ -114,14 +115,15 @@ struct attr_cache_entry {
  128.      uint32_t                numlinks;
  129.      unsigned                mode : 30;
  130.      unsigned                hidden : 1;
  131. -    unsigned                system : 1;
  132.      unsigned                archive : 1;
  133. -    uint32_t                clone_blksize;
  134. -    util_reltimestamp       expiration;
  135. +    unsigned                system : 1;
  136. +    unsigned                offline : 1;
  137.      unsigned                ref_count : 26;
  138.      unsigned                type : 4;
  139.      unsigned                invalidated : 1;
  140.      unsigned                delegated : 1;
  141. +    uint32_t                clone_blksize;
  142. +    util_reltimestamp       expiration;
  143.      char                    owner[NFS4_FATTR4_OWNER_LIMIT+1];
  144.      char                    owner_group[NFS4_FATTR4_OWNER_LIMIT+1];
  145.  };
  146. @@ -394,6 +396,10 @@ static void attr_cache_update(
  147.              entry->nc_attrs |= NC_ATTR_CLONE_BLKSIZE;
  148.              entry->clone_blksize = info->clone_blksize;
  149.          }
  150. +        if (info->attrmask.arr[2] & FATTR4_WORD2_OFFLINE) {
  151. +            entry->nc_attrs |= NC_ATTR_OFFLINE;
  152. +            entry->offline = info->offline;
  153. +        }
  154.      }
  155.  
  156.      if (is_delegation(delegation))
  157. @@ -489,6 +495,10 @@ static void copy_attrs(
  158.          dst->attrmask.arr[2] |= FATTR4_WORD2_CLONE_BLKSIZE;
  159.          dst->clone_blksize = src->clone_blksize;
  160.      }
  161. +    if (src->nc_attrs & NC_ATTR_OFFLINE) {
  162. +        dst->attrmask.arr[2] |= FATTR4_WORD2_OFFLINE;
  163. +        dst->offline = src->offline;
  164. +    }
  165.  
  166.      if (dst->attrmask.arr[2] != 0) {
  167.          dst->attrmask.count = 3;
  168. diff --git a/daemon/nfs41_superblock.c b/daemon/nfs41_superblock.c
  169. index 23b4024..07c2bff 100644
  170. --- a/daemon/nfs41_superblock.c
  171. +++ b/daemon/nfs41_superblock.c
  172. @@ -171,7 +171,7 @@ static int get_superblock_attrs(
  173.          | FATTR4_WORD1_SYSTEM
  174.          | FATTR4_WORD1_TIME_ACCESS | FATTR4_WORD1_TIME_CREATE
  175.          | FATTR4_WORD1_TIME_MODIFY;
  176. -    superblock->default_getattr.arr[2] = 0;
  177. +    superblock->default_getattr.arr[2] = FATTR4_WORD2_OFFLINE;
  178.  
  179.      nfs41_superblock_supported_attrs(superblock, &superblock->default_getattr);
  180.  
  181. diff --git a/daemon/nfs41_types.h b/daemon/nfs41_types.h
  182. index b0dca52..bded8db 100644
  183. --- a/daemon/nfs41_types.h
  184. +++ b/daemon/nfs41_types.h
  185. @@ -4,6 +4,7 @@
  186.   *
  187.   * Olga Kornievskaia <aglo@umich.edu>
  188.   * Casey Bodley <cbodley@umich.edu>
  189. + * Roland Mainz <roland.mainz@nrubsig.org>
  190.   *
  191.   * This library is free software; you can redistribute it and/or modify it
  192.   * under the terms of the GNU Lesser General Public License as published by
  193. @@ -221,6 +222,7 @@ typedef struct __nfs41_file_info {
  194.      bool_t                  hidden;
  195.      bool_t                  system;
  196.      bool_t                  archive;
  197. +    bool_t                  offline;
  198.      uint32_t                clone_blksize;
  199.      bool_t                  case_insensitive;
  200.      bool_t                  case_preserving;
  201. diff --git a/daemon/nfs41_xdr.c b/daemon/nfs41_xdr.c
  202. index c1e22e5..62a5e81 100644
  203. --- a/daemon/nfs41_xdr.c
  204. +++ b/daemon/nfs41_xdr.c
  205. @@ -1927,6 +1927,10 @@ static bool_t decode_file_attrs(
  206.              if (!xdr_uint32_t(xdr, &info->clone_blksize))
  207.                  return FALSE;
  208.          }
  209. +        if (attrs->attrmask.arr[2] & FATTR4_WORD2_OFFLINE) {
  210. +            if (!xdr_bool(xdr, &info->offline))
  211. +                return FALSE;
  212. +        }
  213.      }
  214.      return TRUE;
  215.  }
  216. @@ -2737,6 +2741,13 @@ static bool_t encode_file_attrs(
  217.                  return FALSE;
  218.              attrs->attrmask.arr[2] |= FATTR4_WORD2_MODE_SET_MASKED;
  219.          }
  220. +#ifdef NFS41_DRIVER_ALLOW_SETTING_FATTR4_OFFLINE
  221. +        if (info->attrmask.arr[2] & FATTR4_WORD2_OFFLINE) {
  222. +            if (!xdr_bool(&localxdr, &info->offline))
  223. +                return FALSE;
  224. +            attrs->attrmask.arr[2] |= FATTR4_WORD2_OFFLINE;
  225. +        }
  226. +#endif /* NFS41_DRIVER_ALLOW_SETTING_FATTR4_OFFLINE */
  227.      }
  228.  
  229.      /* warn if we try to set attributes that aren't handled */
  230. diff --git a/daemon/open.c b/daemon/open.c
  231. index dd10c38..43f753c 100644
  232. --- a/daemon/open.c
  233. +++ b/daemon/open.c
  234. @@ -1021,6 +1021,7 @@ static int handle_open(void *daemon_context, nfs41_upcall *upcall)
  235.          createattrs.hidden = args->file_attrs & FILE_ATTRIBUTE_HIDDEN ? 1 : 0;
  236.          createattrs.system = args->file_attrs & FILE_ATTRIBUTE_SYSTEM ? 1 : 0;
  237.          createattrs.archive = args->file_attrs & FILE_ATTRIBUTE_ARCHIVE ? 1 : 0;
  238. +        /* FIXME: What about |FILE_ATTRIBUTE_OFFLINE| ? */
  239.  
  240.          map_access_2_allowdeny(args->access_mask, args->access_mode,
  241.              args->disposition, &state->share_access, &state->share_deny);
  242. diff --git a/daemon/setattr.c b/daemon/setattr.c
  243. index a47918e..5611485 100644
  244. --- a/daemon/setattr.c
  245. +++ b/daemon/setattr.c
  246. @@ -91,6 +91,9 @@ static int handle_nfs41_setattr_basicinfo(void *daemon_context, setattr_upcall_a
  247.          info.hidden = basic_info->FileAttributes & FILE_ATTRIBUTE_HIDDEN ? 1 : 0;
  248.          info.system = basic_info->FileAttributes & FILE_ATTRIBUTE_SYSTEM ? 1 : 0;
  249.          info.archive = basic_info->FileAttributes & FILE_ATTRIBUTE_ARCHIVE ? 1 : 0;
  250. +#ifdef NFS41_DRIVER_ALLOW_SETTING_FATTR4_OFFLINE
  251. +        info.offline = basic_info->FileAttributes & FILE_ATTRIBUTE_OFFLINE ? 1 : 0;
  252. +#endif /* NFS41_DRIVER_ALLOW_SETTING_FATTR4_OFFLINE */
  253.  
  254.          if (info.hidden != old_info.hidden) {
  255.              info.attrmask.arr[0] |= FATTR4_WORD0_HIDDEN;
  256. @@ -104,6 +107,12 @@ static int handle_nfs41_setattr_basicinfo(void *daemon_context, setattr_upcall_a
  257.              info.attrmask.arr[1] |= FATTR4_WORD1_SYSTEM;
  258.              info.attrmask.count = __max(info.attrmask.count, 2);
  259.          }
  260. +#ifdef NFS41_DRIVER_ALLOW_SETTING_FATTR4_OFFLINE
  261. +        if (info.offline != old_info.offline) {
  262. +            info.attrmask.arr[2] |= FATTR4_WORD2_OFFLINE;
  263. +            info.attrmask.count = __max(info.attrmask.count, 3);
  264. +        }
  265. +#endif /* NFS41_DRIVER_ALLOW_SETTING_FATTR4_OFFLINE */
  266.  
  267.          EASSERT_MSG(((basic_info->FileAttributes & FILE_ATTRIBUTE_EA) == 0),
  268.              ("handle_nfs41_setattr_basicinfo(args->path='%s)': "
  269. diff --git a/nfs41_build_features.h b/nfs41_build_features.h
  270. index 38f6372..7431cf8 100644
  271. --- a/nfs41_build_features.h
  272. +++ b/nfs41_build_features.h
  273. @@ -236,4 +236,14 @@
  274.   */
  275.  #define NFS41_DRIVER_HACK_LOCKING_STORAGE32_RANGELOCK_PROBING 1
  276.  
  277. +/*
  278. + * |NFS41_DRIVER_ALLOW_SETTING_FATTR4_OFFLINE| - allow
  279. + * setting of |FATTR4_WORD2_OFFLINE|
  280. + *
  281. + * "Off" by default, because |FATTR4_WORD2_OFFLINE| seems to be a
  282. + * read-only attribute
  283. + *
  284. + * #define NFS41_DRIVER_ALLOW_SETTING_FATTR4_OFFLINE 1
  285. + *
  286. + */
  287.  #endif /* !_NFS41_DRIVER_BUILDFEATURES_ */
  288. --
  289. 2.51.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