- From db91ea3a80b53bbc4d65477905e8c5648ffd3478 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Sat, 13 Sep 2025 15:37:08 +0200
- Subject: [PATCH 2/2] daemon,nfs41_build_features.h: Implement Win32
- |FILE_ATTRIBUTE_OFFLINE| via |FATTR4_OFFLINE|
- Implement Win32 |FILE_ATTRIBUTE_OFFLINE| via RFC9754 |FATTR4_OFFLINE|
- (see https://datatracker.ietf.org/doc/rfc9754/).
- Reported-by: Lionel Cons <Lionelcons1972@gmail.com>
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- daemon/daemon_debug.c | 3 +++
- daemon/fileinfoutil.c | 5 ++++
- daemon/lookup.c | 3 ++-
- daemon/name_cache.c | 48 +++++++++++++++++++++++----------------
- daemon/nfs41_superblock.c | 2 +-
- daemon/nfs41_types.h | 2 ++
- daemon/nfs41_xdr.c | 11 +++++++++
- daemon/open.c | 1 +
- daemon/setattr.c | 9 ++++++++
- nfs41_build_features.h | 10 ++++++++
- 10 files changed, 73 insertions(+), 21 deletions(-)
- diff --git a/daemon/daemon_debug.c b/daemon/daemon_debug.c
- index 02a0aec..19d9e6e 100644
- --- a/daemon/daemon_debug.c
- +++ b/daemon/daemon_debug.c
- @@ -1147,6 +1147,9 @@ void print_nfs41_file_info(
- (long)info->clone_blksize);
- }
- + if (info->attrmask.arr[2] & FATTR4_WORD2_OFFLINE)
- + PRNFS41FI_FMT("offline=%d, ", (int)info->offline);
- +
- p += snprintf(p, (sizeof(buf)-(p-buf)), "} ");
- }
- diff --git a/daemon/fileinfoutil.c b/daemon/fileinfoutil.c
- index 2556c87..3466cfd 100644
- --- a/daemon/fileinfoutil.c
- +++ b/daemon/fileinfoutil.c
- @@ -84,6 +84,8 @@ ULONG nfs_file_info_to_attributes(
- attrs |= FILE_ATTRIBUTE_SYSTEM;
- if (info->archive)
- attrs |= FILE_ATTRIBUTE_ARCHIVE;
- + if (info->offline)
- + attrs |= FILE_ATTRIBUTE_OFFLINE;
- /*
- * |FILE_ATTRIBUTE_NORMAL| attribute is only set if no other
- @@ -637,6 +639,9 @@ void nfs41_file_info_cpy(
- if (attrmask->arr[2] & FATTR4_WORD2_CLONE_BLKSIZE) {
- dest->clone_blksize = src->clone_blksize;
- }
- + if (attrmask->arr[2] & FATTR4_WORD2_OFFLINE) {
- + dest->offline = src->offline;
- + }
- }
- if (flags & NFS41FILEINFOCPY_COPY_SYMLINK_DIR) {
- diff --git a/daemon/lookup.c b/daemon/lookup.c
- index 4eb6808..d56307d 100644
- --- a/daemon/lookup.c
- +++ b/daemon/lookup.c
- @@ -96,7 +96,7 @@ static void init_component_args(
- {
- uint32_t i;
- - args->attr_request.count = 2;
- + args->attr_request.count = 3;
- args->attr_request.arr[0] = FATTR4_WORD0_TYPE
- | FATTR4_WORD0_CHANGE | FATTR4_WORD0_SIZE
- | FATTR4_WORD0_FSID | FATTR4_WORD0_FILEID
- @@ -107,6 +107,7 @@ static void init_component_args(
- | FATTR4_WORD1_TIME_ACCESS | FATTR4_WORD1_TIME_CREATE
- | FATTR4_WORD1_TIME_MODIFY
- | FATTR4_WORD1_OWNER | FATTR4_WORD1_OWNER_GROUP;
- + args->attr_request.arr[2] = FATTR4_WORD2_OFFLINE;
- args->getrootattr.attr_request = &args->attr_request;
- res->root.path = path;
- diff --git a/daemon/name_cache.c b/daemon/name_cache.c
- index f025983..1ef1a47 100644
- --- a/daemon/name_cache.c
- +++ b/daemon/name_cache.c
- @@ -77,22 +77,23 @@ static __inline bool_t is_delegation(
- return type == OPEN_DELEGATE_READ || type == OPEN_DELEGATE_WRITE;
- }
- -#define NC_ATTR_TYPE (1 << 0)
- -#define NC_ATTR_CHANGE (1 << 1)
- -#define NC_ATTR_FSID (1 << 2)
- -#define NC_ATTR_SIZE (1 << 3)
- -#define NC_ATTR_SPACE_USED (1 << 4)
- -#define NC_ATTR_HIDDEN (1 << 5)
- -#define NC_ATTR_ARCHIVE (1 << 6)
- -#define NC_ATTR_MODE (1 << 7)
- -#define NC_ATTR_NUMLINKS (1 << 8)
- -#define NC_ATTR_OWNER (1 << 9)
- -#define NC_ATTR_OWNER_GROUP (1 << 10)
- -#define NC_ATTR_TIME_ACCESS (1 << 11)
- -#define NC_ATTR_TIME_CREATE (1 << 12)
- -#define NC_ATTR_TIME_MODIFY (1 << 13)
- -#define NC_ATTR_SYSTEM (1 << 14)
- -#define NC_ATTR_CLONE_BLKSIZE (1 << 15)
- +#define NC_ATTR_TYPE (1 << 0)
- +#define NC_ATTR_CHANGE (1 << 1)
- +#define NC_ATTR_FSID (1 << 2)
- +#define NC_ATTR_SIZE (1 << 3)
- +#define NC_ATTR_SPACE_USED (1 << 4)
- +#define NC_ATTR_HIDDEN (1 << 5)
- +#define NC_ATTR_ARCHIVE (1 << 6)
- +#define NC_ATTR_SYSTEM (1 << 7)
- +#define NC_ATTR_OFFLINE (1 << 8)
- +#define NC_ATTR_MODE (1 << 9)
- +#define NC_ATTR_NUMLINKS (1 << 10)
- +#define NC_ATTR_OWNER (1 << 11)
- +#define NC_ATTR_OWNER_GROUP (1 << 12)
- +#define NC_ATTR_TIME_ACCESS (1 << 13)
- +#define NC_ATTR_TIME_CREATE (1 << 14)
- +#define NC_ATTR_TIME_MODIFY (1 << 15)
- +#define NC_ATTR_CLONE_BLKSIZE (1 << 16)
- /* attribute cache */
- struct attr_cache_entry {
- @@ -114,14 +115,15 @@ struct attr_cache_entry {
- uint32_t numlinks;
- unsigned mode : 30;
- unsigned hidden : 1;
- - unsigned system : 1;
- unsigned archive : 1;
- - uint32_t clone_blksize;
- - util_reltimestamp expiration;
- + unsigned system : 1;
- + unsigned offline : 1;
- unsigned ref_count : 26;
- unsigned type : 4;
- unsigned invalidated : 1;
- unsigned delegated : 1;
- + uint32_t clone_blksize;
- + util_reltimestamp expiration;
- char owner[NFS4_FATTR4_OWNER_LIMIT+1];
- char owner_group[NFS4_FATTR4_OWNER_LIMIT+1];
- };
- @@ -394,6 +396,10 @@ static void attr_cache_update(
- entry->nc_attrs |= NC_ATTR_CLONE_BLKSIZE;
- entry->clone_blksize = info->clone_blksize;
- }
- + if (info->attrmask.arr[2] & FATTR4_WORD2_OFFLINE) {
- + entry->nc_attrs |= NC_ATTR_OFFLINE;
- + entry->offline = info->offline;
- + }
- }
- if (is_delegation(delegation))
- @@ -489,6 +495,10 @@ static void copy_attrs(
- dst->attrmask.arr[2] |= FATTR4_WORD2_CLONE_BLKSIZE;
- dst->clone_blksize = src->clone_blksize;
- }
- + if (src->nc_attrs & NC_ATTR_OFFLINE) {
- + dst->attrmask.arr[2] |= FATTR4_WORD2_OFFLINE;
- + dst->offline = src->offline;
- + }
- if (dst->attrmask.arr[2] != 0) {
- dst->attrmask.count = 3;
- diff --git a/daemon/nfs41_superblock.c b/daemon/nfs41_superblock.c
- index 23b4024..07c2bff 100644
- --- a/daemon/nfs41_superblock.c
- +++ b/daemon/nfs41_superblock.c
- @@ -171,7 +171,7 @@ static int get_superblock_attrs(
- | FATTR4_WORD1_SYSTEM
- | FATTR4_WORD1_TIME_ACCESS | FATTR4_WORD1_TIME_CREATE
- | FATTR4_WORD1_TIME_MODIFY;
- - superblock->default_getattr.arr[2] = 0;
- + superblock->default_getattr.arr[2] = FATTR4_WORD2_OFFLINE;
- nfs41_superblock_supported_attrs(superblock, &superblock->default_getattr);
- diff --git a/daemon/nfs41_types.h b/daemon/nfs41_types.h
- index b0dca52..bded8db 100644
- --- a/daemon/nfs41_types.h
- +++ b/daemon/nfs41_types.h
- @@ -4,6 +4,7 @@
- *
- * Olga Kornievskaia <aglo@umich.edu>
- * Casey Bodley <cbodley@umich.edu>
- + * Roland Mainz <roland.mainz@nrubsig.org>
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published by
- @@ -221,6 +222,7 @@ typedef struct __nfs41_file_info {
- bool_t hidden;
- bool_t system;
- bool_t archive;
- + bool_t offline;
- uint32_t clone_blksize;
- bool_t case_insensitive;
- bool_t case_preserving;
- diff --git a/daemon/nfs41_xdr.c b/daemon/nfs41_xdr.c
- index c1e22e5..62a5e81 100644
- --- a/daemon/nfs41_xdr.c
- +++ b/daemon/nfs41_xdr.c
- @@ -1927,6 +1927,10 @@ static bool_t decode_file_attrs(
- if (!xdr_uint32_t(xdr, &info->clone_blksize))
- return FALSE;
- }
- + if (attrs->attrmask.arr[2] & FATTR4_WORD2_OFFLINE) {
- + if (!xdr_bool(xdr, &info->offline))
- + return FALSE;
- + }
- }
- return TRUE;
- }
- @@ -2737,6 +2741,13 @@ static bool_t encode_file_attrs(
- return FALSE;
- attrs->attrmask.arr[2] |= FATTR4_WORD2_MODE_SET_MASKED;
- }
- +#ifdef NFS41_DRIVER_ALLOW_SETTING_FATTR4_OFFLINE
- + if (info->attrmask.arr[2] & FATTR4_WORD2_OFFLINE) {
- + if (!xdr_bool(&localxdr, &info->offline))
- + return FALSE;
- + attrs->attrmask.arr[2] |= FATTR4_WORD2_OFFLINE;
- + }
- +#endif /* NFS41_DRIVER_ALLOW_SETTING_FATTR4_OFFLINE */
- }
- /* warn if we try to set attributes that aren't handled */
- diff --git a/daemon/open.c b/daemon/open.c
- index dd10c38..43f753c 100644
- --- a/daemon/open.c
- +++ b/daemon/open.c
- @@ -1021,6 +1021,7 @@ static int handle_open(void *daemon_context, nfs41_upcall *upcall)
- createattrs.hidden = args->file_attrs & FILE_ATTRIBUTE_HIDDEN ? 1 : 0;
- createattrs.system = args->file_attrs & FILE_ATTRIBUTE_SYSTEM ? 1 : 0;
- createattrs.archive = args->file_attrs & FILE_ATTRIBUTE_ARCHIVE ? 1 : 0;
- + /* FIXME: What about |FILE_ATTRIBUTE_OFFLINE| ? */
- map_access_2_allowdeny(args->access_mask, args->access_mode,
- args->disposition, &state->share_access, &state->share_deny);
- diff --git a/daemon/setattr.c b/daemon/setattr.c
- index a47918e..5611485 100644
- --- a/daemon/setattr.c
- +++ b/daemon/setattr.c
- @@ -91,6 +91,9 @@ static int handle_nfs41_setattr_basicinfo(void *daemon_context, setattr_upcall_a
- info.hidden = basic_info->FileAttributes & FILE_ATTRIBUTE_HIDDEN ? 1 : 0;
- info.system = basic_info->FileAttributes & FILE_ATTRIBUTE_SYSTEM ? 1 : 0;
- info.archive = basic_info->FileAttributes & FILE_ATTRIBUTE_ARCHIVE ? 1 : 0;
- +#ifdef NFS41_DRIVER_ALLOW_SETTING_FATTR4_OFFLINE
- + info.offline = basic_info->FileAttributes & FILE_ATTRIBUTE_OFFLINE ? 1 : 0;
- +#endif /* NFS41_DRIVER_ALLOW_SETTING_FATTR4_OFFLINE */
- if (info.hidden != old_info.hidden) {
- info.attrmask.arr[0] |= FATTR4_WORD0_HIDDEN;
- @@ -104,6 +107,12 @@ static int handle_nfs41_setattr_basicinfo(void *daemon_context, setattr_upcall_a
- info.attrmask.arr[1] |= FATTR4_WORD1_SYSTEM;
- info.attrmask.count = __max(info.attrmask.count, 2);
- }
- +#ifdef NFS41_DRIVER_ALLOW_SETTING_FATTR4_OFFLINE
- + if (info.offline != old_info.offline) {
- + info.attrmask.arr[2] |= FATTR4_WORD2_OFFLINE;
- + info.attrmask.count = __max(info.attrmask.count, 3);
- + }
- +#endif /* NFS41_DRIVER_ALLOW_SETTING_FATTR4_OFFLINE */
- EASSERT_MSG(((basic_info->FileAttributes & FILE_ATTRIBUTE_EA) == 0),
- ("handle_nfs41_setattr_basicinfo(args->path='%s)': "
- diff --git a/nfs41_build_features.h b/nfs41_build_features.h
- index 38f6372..7431cf8 100644
- --- a/nfs41_build_features.h
- +++ b/nfs41_build_features.h
- @@ -236,4 +236,14 @@
- */
- #define NFS41_DRIVER_HACK_LOCKING_STORAGE32_RANGELOCK_PROBING 1
- +/*
- + * |NFS41_DRIVER_ALLOW_SETTING_FATTR4_OFFLINE| - allow
- + * setting of |FATTR4_WORD2_OFFLINE|
- + *
- + * "Off" by default, because |FATTR4_WORD2_OFFLINE| seems to be a
- + * read-only attribute
- + *
- + * #define NFS41_DRIVER_ALLOW_SETTING_FATTR4_OFFLINE 1
- + *
- + */
- #endif /* !_NFS41_DRIVER_BUILDFEATURES_ */
- --
- 2.51.0
0002-daemon-nfs41_build_features.h-Implement-Win32-FILE_A.patch
Posted by Anonymous on Mon 15th Sep 2025 10:55
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.