From: Chuck Lever <cel@kernel.org>
To: Calum Mackay <calum.mackay@oracle.com>
Cc: <linux-nfs@vger.kernel.org>, Chuck Lever <chuck.lever@oracle.com>
Subject: [RFC PATCH 03/10] Add helper to format attribute bitmaps
Date: Sun, 23 Nov 2025 10:56:11 -0500 [thread overview]
Message-ID: <20251123155623.514129-4-cel@kernel.org> (raw)
In-Reply-To: <20251123155623.514129-1-cel@kernel.org>
From: Chuck Lever <chuck.lever@oracle.com>
I'm about to add several new attribute-related tests. Introduce
attr_bitmap_to_str() in nfs4lib.py to convert attribute bitmaps to
human-readable symbolic strings.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
nfs4.1/nfs4lib.py | 69 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 69 insertions(+)
diff --git a/nfs4.1/nfs4lib.py b/nfs4.1/nfs4lib.py
index d3a1550f1ce1..5c2149002a27 100644
--- a/nfs4.1/nfs4lib.py
+++ b/nfs4.1/nfs4lib.py
@@ -564,6 +564,75 @@ def attr_name(bitnum):
"""Returns string corresponding to attr bitnum"""
return bitnum2attr.get(bitnum, "unknown_%r" % bitnum)
+def attr_bitmap_to_str(bitmap):
+ """Convert an attribute bitmap to a symbolic string representation"""
+ attrs = [
+ (xdrdef.nfs4_const.FATTR4_SUPPORTED_ATTRS, "SUPPORTED_ATTRS"),
+ (xdrdef.nfs4_const.FATTR4_TYPE, "TYPE"),
+ (xdrdef.nfs4_const.FATTR4_FH_EXPIRE_TYPE, "FH_EXPIRE_TYPE"),
+ (xdrdef.nfs4_const.FATTR4_CHANGE, "CHANGE"),
+ (xdrdef.nfs4_const.FATTR4_SIZE, "SIZE"),
+ (xdrdef.nfs4_const.FATTR4_LINK_SUPPORT, "LINK_SUPPORT"),
+ (xdrdef.nfs4_const.FATTR4_SYMLINK_SUPPORT, "SYMLINK_SUPPORT"),
+ (xdrdef.nfs4_const.FATTR4_NAMED_ATTR, "NAMED_ATTR"),
+ (xdrdef.nfs4_const.FATTR4_FSID, "FSID"),
+ (xdrdef.nfs4_const.FATTR4_UNIQUE_HANDLES, "UNIQUE_HANDLES"),
+ (xdrdef.nfs4_const.FATTR4_LEASE_TIME, "LEASE_TIME"),
+ (xdrdef.nfs4_const.FATTR4_RDATTR_ERROR, "RDATTR_ERROR"),
+ (xdrdef.nfs4_const.FATTR4_ACL, "ACL"),
+ (xdrdef.nfs4_const.FATTR4_ACLSUPPORT, "ACLSUPPORT"),
+ (xdrdef.nfs4_const.FATTR4_ARCHIVE, "ARCHIVE"),
+ (xdrdef.nfs4_const.FATTR4_CANSETTIME, "CANSETTIME"),
+ (xdrdef.nfs4_const.FATTR4_CASE_INSENSITIVE, "CASE_INSENSITIVE"),
+ (xdrdef.nfs4_const.FATTR4_CASE_PRESERVING, "CASE_PRESERVING"),
+ (xdrdef.nfs4_const.FATTR4_CHOWN_RESTRICTED, "CHOWN_RESTRICTED"),
+ (xdrdef.nfs4_const.FATTR4_FILEHANDLE, "FILEHANDLE"),
+ (xdrdef.nfs4_const.FATTR4_FILEID, "FILEID"),
+ (xdrdef.nfs4_const.FATTR4_FILES_AVAIL, "FILES_AVAIL"),
+ (xdrdef.nfs4_const.FATTR4_FILES_FREE, "FILES_FREE"),
+ (xdrdef.nfs4_const.FATTR4_FILES_TOTAL, "FILES_TOTAL"),
+ (xdrdef.nfs4_const.FATTR4_FS_LOCATIONS, "FS_LOCATIONS"),
+ (xdrdef.nfs4_const.FATTR4_HIDDEN, "HIDDEN"),
+ (xdrdef.nfs4_const.FATTR4_HOMOGENEOUS, "HOMOGENEOUS"),
+ (xdrdef.nfs4_const.FATTR4_MAXFILESIZE, "MAXFILESIZE"),
+ (xdrdef.nfs4_const.FATTR4_MAXLINK, "MAXLINK"),
+ (xdrdef.nfs4_const.FATTR4_MAXNAME, "MAXNAME"),
+ (xdrdef.nfs4_const.FATTR4_MAXREAD, "MAXREAD"),
+ (xdrdef.nfs4_const.FATTR4_MAXWRITE, "MAXWRITE"),
+ (xdrdef.nfs4_const.FATTR4_MIMETYPE, "MIMETYPE"),
+ (xdrdef.nfs4_const.FATTR4_MODE, "MODE"),
+ (xdrdef.nfs4_const.FATTR4_NO_TRUNC, "NO_TRUNC"),
+ (xdrdef.nfs4_const.FATTR4_NUMLINKS, "NUMLINKS"),
+ (xdrdef.nfs4_const.FATTR4_OWNER, "OWNER"),
+ (xdrdef.nfs4_const.FATTR4_OWNER_GROUP, "OWNER_GROUP"),
+ (xdrdef.nfs4_const.FATTR4_QUOTA_AVAIL_HARD, "QUOTA_AVAIL_HARD"),
+ (xdrdef.nfs4_const.FATTR4_QUOTA_AVAIL_SOFT, "QUOTA_AVAIL_SOFT"),
+ (xdrdef.nfs4_const.FATTR4_QUOTA_USED, "QUOTA_USED"),
+ (xdrdef.nfs4_const.FATTR4_RAWDEV, "RAWDEV"),
+ (xdrdef.nfs4_const.FATTR4_SPACE_AVAIL, "SPACE_AVAIL"),
+ (xdrdef.nfs4_const.FATTR4_SPACE_FREE, "SPACE_FREE"),
+ (xdrdef.nfs4_const.FATTR4_SPACE_TOTAL, "SPACE_TOTAL"),
+ (xdrdef.nfs4_const.FATTR4_SPACE_USED, "SPACE_USED"),
+ (xdrdef.nfs4_const.FATTR4_SYSTEM, "SYSTEM"),
+ (xdrdef.nfs4_const.FATTR4_TIME_ACCESS, "TIME_ACCESS"),
+ (xdrdef.nfs4_const.FATTR4_TIME_ACCESS_SET, "TIME_ACCESS_SET"),
+ (xdrdef.nfs4_const.FATTR4_TIME_BACKUP, "TIME_BACKUP"),
+ (xdrdef.nfs4_const.FATTR4_TIME_CREATE, "TIME_CREATE"),
+ (xdrdef.nfs4_const.FATTR4_TIME_DELTA, "TIME_DELTA"),
+ (xdrdef.nfs4_const.FATTR4_TIME_METADATA, "TIME_METADATA"),
+ (xdrdef.nfs4_const.FATTR4_TIME_MODIFY, "TIME_MODIFY"),
+ (xdrdef.nfs4_const.FATTR4_TIME_MODIFY_SET, "TIME_MODIFY_SET"),
+ (xdrdef.nfs4_const.FATTR4_MOUNTED_ON_FILEID, "MOUNTED_ON_FILEID"),
+ (xdrdef.nfs4_const.FATTR4_SUPPATTR_EXCLCREAT, "SUPPATTR_EXCLCREAT"),
+ (xdrdef.nfs4_const.FATTR4_SEC_LABEL, "SEC_LABEL"),
+ (xdrdef.nfs4_const.FATTR4_XATTR_SUPPORT, "XATTR_SUPPORT"),
+ ]
+ result = []
+ for bit, name in attrs:
+ if bitmap & (1 << bit):
+ result.append(name)
+ return ", ".join(result) if result else "(none)"
+
class NFS4Error(Exception):
def __init__(self, status, attrs=0, lock_denied=None, tag=None, check_msg=None):
self.status = status
--
2.51.1
next prev parent reply other threads:[~2025-11-23 15:56 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-23 15:56 [RFC PATCH 00/10] pynfs tests for setting ACL+MODE Chuck Lever
2025-11-23 15:56 ` [RFC PATCH 01/10] Add helper to report unsupported protocol features Chuck Lever
2025-11-23 15:56 ` [RFC PATCH 02/10] Add helper to format ACE access masks Chuck Lever
2025-11-23 15:56 ` Chuck Lever [this message]
2025-11-23 15:56 ` [RFC PATCH 04/10] Add a helper to compute POSIX mode bits from NFSv4 ACLs Chuck Lever
2025-11-23 15:56 ` [RFC PATCH 05/10] Add make_test_acl() helper to nfs4acl modules Chuck Lever
2025-11-23 16:04 ` Chuck Lever
2025-11-23 15:56 ` [RFC PATCH 06/10] Add access_mask_to_str() helper to nfs4.0/nfs4acl.py Chuck Lever
2025-11-23 15:56 ` [RFC PATCH 07/10] Add verify_acl() helper to nfs4acl modules Chuck Lever
2025-11-23 15:56 ` [RFC PATCH 08/10] Add verify_mode_and_acl() " Chuck Lever
2025-11-23 15:56 ` [RFC PATCH 09/10] Add tests for SETATTR with MODE and ACL Chuck Lever
2025-11-23 15:56 ` [RFC PATCH 10/10] Add tests for OPEN(create) with ACLs Chuck Lever
2025-11-23 17:20 ` [RFC PATCH 00/10] pynfs tests for setting ACL+MODE Calum Mackay
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251123155623.514129-4-cel@kernel.org \
--to=cel@kernel.org \
--cc=calum.mackay@oracle.com \
--cc=chuck.lever@oracle.com \
--cc=linux-nfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox