+/*
+ * NFS attribute management stuff
+ */
+#define NFS_ATTR_BITMAP_LEN 2
+#define NFS_BITMAP_SET(B, I) (((uint32_t *)(B))[(I)/32] |= 1<<((I)%32))
+#define NFS_BITMAP_CLR(B, I) (((uint32_t *)(B))[(I)/32] &= ~(1<<((I)%32)))
+#define NFS_BITMAP_ISSET(B, I) (((uint32_t *)(B))[(I)/32] & (1<<((I)%32)))
+#define NFS_BITMAP_ZERO(B, L) \
+ do { \
+ int __i; \
+ for (__i=0; __i < (L); __i++) \
+ ((uint32_t*)(B))[__i] = 0; \
+ } while (0)
+
+extern uint32_t nfs_fs_attr_bitmap[NFS_ATTR_BITMAP_LEN];
+extern uint32_t nfs_object_attr_bitmap[NFS_ATTR_BITMAP_LEN];
+extern uint32_t nfs_getattr_bitmap[NFS_ATTR_BITMAP_LEN];
+
+#define NFS_CLEAR_ATTRIBUTES(A) NFS_BITMAP_ZERO((A), NFS_ATTR_BITMAP_LEN)
+#define NFS_COPY_ATTRIBUTES(SRC, DST) \
+ do { \
+ int __i; \
+ for (__i=0; __i < NFS_ATTR_BITMAP_LEN; __i++) \
+ ((uint32_t*)(DST))[__i] = ((uint32_t*)(SRC))[__i]; \
+ } while (0)
+
+/* NFS attributes */
+#define NFS_FATTR_SUPPORTED_ATTRS 0
+#define NFS_FATTR_TYPE 1
+#define NFS_FATTR_FH_EXPIRE_TYPE 2
+#define NFS_FATTR_CHANGE 3
+#define NFS_FATTR_SIZE 4
+#define NFS_FATTR_LINK_SUPPORT 5
+#define NFS_FATTR_SYMLINK_SUPPORT 6
+#define NFS_FATTR_NAMED_ATTR 7
+#define NFS_FATTR_FSID 8
+#define NFS_FATTR_UNIQUE_HANDLES 9
+#define NFS_FATTR_LEASE_TIME 10
+#define NFS_FATTR_RDATTR_ERROR 11
+#define NFS_FATTR_FILEHANDLE 19
+#define NFS_FATTR_ACL 12
+#define NFS_FATTR_ACLSUPPORT 13
+#define NFS_FATTR_ARCHIVE 14
+#define NFS_FATTR_CANSETTIME 15
+#define NFS_FATTR_CASE_INSENSITIVE 16
+#define NFS_FATTR_CASE_PRESERVING 17
+#define NFS_FATTR_CHOWN_RESTRICTED 18
+#define NFS_FATTR_FILEID 20
+#define NFS_FATTR_FILES_AVAIL 21
+#define NFS_FATTR_FILES_FREE 22
+#define NFS_FATTR_FILES_TOTAL 23
+#define NFS_FATTR_FS_LOCATIONS 24
+#define NFS_FATTR_HIDDEN 25
+#define NFS_FATTR_HOMOGENEOUS 26
+#define NFS_FATTR_MAXFILESIZE 27
+#define NFS_FATTR_MAXLINK 28
+#define NFS_FATTR_MAXNAME 29
+#define NFS_FATTR_MAXREAD 30
+#define NFS_FATTR_MAXWRITE 31
+#define NFS_FATTR_MIMETYPE 32
+#define NFS_FATTR_MODE 33
+#define NFS_FATTR_NO_TRUNC 34
+#define NFS_FATTR_NUMLINKS 35
+#define NFS_FATTR_OWNER 36
+#define NFS_FATTR_OWNER_GROUP 37
+#define NFS_FATTR_QUOTA_AVAIL_HARD 38
+#define NFS_FATTR_QUOTA_AVAIL_SOFT 39
+#define NFS_FATTR_QUOTA_USED 40
+#define NFS_FATTR_RAWDEV 41
+#define NFS_FATTR_SPACE_AVAIL 42
+#define NFS_FATTR_SPACE_FREE 43
+#define NFS_FATTR_SPACE_TOTAL 44
+#define NFS_FATTR_SPACE_USED 45
+#define NFS_FATTR_SYSTEM 46
+#define NFS_FATTR_TIME_ACCESS 47
+#define NFS_FATTR_TIME_ACCESS_SET 48
+#define NFS_FATTR_TIME_BACKUP 49
+#define NFS_FATTR_TIME_CREATE 50
+#define NFS_FATTR_TIME_DELTA 51
+#define NFS_FATTR_TIME_METADATA 52
+#define NFS_FATTR_TIME_MODIFY 53
+#define NFS_FATTR_TIME_MODIFY_SET 54
+#define NFS_FATTR_MOUNTED_ON_FILEID 55
+
+#define NFS4_ALL_ATTRIBUTES(A) \
+ do { \
+ /* required: */ \
+ NFS_BITMAP_SET((A), NFS_FATTR_SUPPORTED_ATTRS); \
+ NFS_BITMAP_SET((A), NFS_FATTR_TYPE); \
+ NFS_BITMAP_SET((A), NFS_FATTR_FH_EXPIRE_TYPE); \
+ NFS_BITMAP_SET((A), NFS_FATTR_CHANGE); \
+ NFS_BITMAP_SET((A), NFS_FATTR_SIZE); \
+ NFS_BITMAP_SET((A), NFS_FATTR_LINK_SUPPORT); \
+ NFS_BITMAP_SET((A), NFS_FATTR_SYMLINK_SUPPORT); \
+ NFS_BITMAP_SET((A), NFS_FATTR_NAMED_ATTR); \
+ NFS_BITMAP_SET((A), NFS_FATTR_FSID); \
+ NFS_BITMAP_SET((A), NFS_FATTR_UNIQUE_HANDLES); \
+ NFS_BITMAP_SET((A), NFS_FATTR_LEASE_TIME); \
+ NFS_BITMAP_SET((A), NFS_FATTR_RDATTR_ERROR); \
+ NFS_BITMAP_SET((A), NFS_FATTR_FILEHANDLE); \
+ /* optional: */ \
+ NFS_BITMAP_SET((A), NFS_FATTR_ACL); \
+ NFS_BITMAP_SET((A), NFS_FATTR_ACLSUPPORT); \
+ NFS_BITMAP_SET((A), NFS_FATTR_ARCHIVE); \
+ NFS_BITMAP_SET((A), NFS_FATTR_CANSETTIME); \
+ NFS_BITMAP_SET((A), NFS_FATTR_CASE_INSENSITIVE); \
+ NFS_BITMAP_SET((A), NFS_FATTR_CASE_PRESERVING); \
+ NFS_BITMAP_SET((A), NFS_FATTR_CHOWN_RESTRICTED); \
+ NFS_BITMAP_SET((A), NFS_FATTR_FILEID); \
+ NFS_BITMAP_SET((A), NFS_FATTR_FILES_AVAIL); \
+ NFS_BITMAP_SET((A), NFS_FATTR_FILES_FREE); \
+ NFS_BITMAP_SET((A), NFS_FATTR_FILES_TOTAL); \
+ NFS_BITMAP_SET((A), NFS_FATTR_FS_LOCATIONS); \
+ NFS_BITMAP_SET((A), NFS_FATTR_HIDDEN); \
+ NFS_BITMAP_SET((A), NFS_FATTR_HOMOGENEOUS); \
+ NFS_BITMAP_SET((A), NFS_FATTR_MAXFILESIZE); \
+ NFS_BITMAP_SET((A), NFS_FATTR_MAXLINK); \
+ NFS_BITMAP_SET((A), NFS_FATTR_MAXNAME); \
+ NFS_BITMAP_SET((A), NFS_FATTR_MAXREAD); \
+ NFS_BITMAP_SET((A), NFS_FATTR_MAXWRITE); \
+ NFS_BITMAP_SET((A), NFS_FATTR_MIMETYPE); \
+ NFS_BITMAP_SET((A), NFS_FATTR_MODE); \
+ NFS_BITMAP_SET((A), NFS_FATTR_NO_TRUNC); \
+ NFS_BITMAP_SET((A), NFS_FATTR_NUMLINKS); \
+ NFS_BITMAP_SET((A), NFS_FATTR_OWNER); \
+ NFS_BITMAP_SET((A), NFS_FATTR_OWNER_GROUP); \
+ NFS_BITMAP_SET((A), NFS_FATTR_QUOTA_AVAIL_HARD); \
+ NFS_BITMAP_SET((A), NFS_FATTR_QUOTA_AVAIL_SOFT); \
+ NFS_BITMAP_SET((A), NFS_FATTR_QUOTA_USED); \
+ NFS_BITMAP_SET((A), NFS_FATTR_RAWDEV); \
+ NFS_BITMAP_SET((A), NFS_FATTR_SPACE_AVAIL); \
+ NFS_BITMAP_SET((A), NFS_FATTR_SPACE_FREE); \
+ NFS_BITMAP_SET((A), NFS_FATTR_SPACE_TOTAL); \
+ NFS_BITMAP_SET((A), NFS_FATTR_SPACE_USED); \
+ NFS_BITMAP_SET((A), NFS_FATTR_SYSTEM); \
+ NFS_BITMAP_SET((A), NFS_FATTR_TIME_ACCESS); \
+ NFS_BITMAP_SET((A), NFS_FATTR_TIME_ACCESS_SET); \
+ NFS_BITMAP_SET((A), NFS_FATTR_TIME_BACKUP); \
+ NFS_BITMAP_SET((A), NFS_FATTR_TIME_CREATE); \
+ NFS_BITMAP_SET((A), NFS_FATTR_TIME_DELTA); \
+ NFS_BITMAP_SET((A), NFS_FATTR_TIME_METADATA); \
+ NFS_BITMAP_SET((A), NFS_FATTR_TIME_MODIFY); \
+ NFS_BITMAP_SET((A), NFS_FATTR_TIME_MODIFY_SET); \
+ NFS_BITMAP_SET((A), NFS_FATTR_MOUNTED_ON_FILEID); \
+ } while (0)
+
+#define NFS4_PER_OBJECT_ATTRIBUTES(A) \
+ do { \
+ /* required: */ \
+ NFS_BITMAP_SET((A), NFS_FATTR_TYPE); \
+ NFS_BITMAP_SET((A), NFS_FATTR_CHANGE); \
+ NFS_BITMAP_SET((A), NFS_FATTR_SIZE); \
+ NFS_BITMAP_SET((A), NFS_FATTR_NAMED_ATTR); \
+ NFS_BITMAP_SET((A), NFS_FATTR_FSID); \
+ NFS_BITMAP_SET((A), NFS_FATTR_RDATTR_ERROR); \
+ NFS_BITMAP_SET((A), NFS_FATTR_FILEHANDLE); \
+ /* optional: */ \
+ NFS_BITMAP_SET((A), NFS_FATTR_ACL); \
+ NFS_BITMAP_SET((A), NFS_FATTR_ARCHIVE); \
+ NFS_BITMAP_SET((A), NFS_FATTR_FILEID); \
+ NFS_BITMAP_SET((A), NFS_FATTR_HIDDEN); \
+ NFS_BITMAP_SET((A), NFS_FATTR_MAXLINK); \
+ NFS_BITMAP_SET((A), NFS_FATTR_MIMETYPE); \
+ NFS_BITMAP_SET((A), NFS_FATTR_MODE); \
+ NFS_BITMAP_SET((A), NFS_FATTR_NUMLINKS); \
+ NFS_BITMAP_SET((A), NFS_FATTR_OWNER); \
+ NFS_BITMAP_SET((A), NFS_FATTR_OWNER_GROUP); \
+ NFS_BITMAP_SET((A), NFS_FATTR_RAWDEV); \
+ NFS_BITMAP_SET((A), NFS_FATTR_SPACE_USED); \
+ NFS_BITMAP_SET((A), NFS_FATTR_SYSTEM); \
+ NFS_BITMAP_SET((A), NFS_FATTR_TIME_ACCESS); \
+ NFS_BITMAP_SET((A), NFS_FATTR_TIME_BACKUP); \
+ NFS_BITMAP_SET((A), NFS_FATTR_TIME_CREATE); \
+ NFS_BITMAP_SET((A), NFS_FATTR_TIME_METADATA); \
+ NFS_BITMAP_SET((A), NFS_FATTR_TIME_MODIFY); \
+ NFS_BITMAP_SET((A), NFS_FATTR_MOUNTED_ON_FILEID); \
+ } while (0)
+
+#define NFS4_PER_FS_ATTRIBUTES(A) \
+ do { \
+ /* required: */ \
+ NFS_BITMAP_SET((A), NFS_FATTR_SUPPORTED_ATTRS); \
+ NFS_BITMAP_SET((A), NFS_FATTR_FH_EXPIRE_TYPE); \
+ NFS_BITMAP_SET((A), NFS_FATTR_LINK_SUPPORT); \
+ NFS_BITMAP_SET((A), NFS_FATTR_SYMLINK_SUPPORT); \
+ NFS_BITMAP_SET((A), NFS_FATTR_UNIQUE_HANDLES); \
+ NFS_BITMAP_SET((A), NFS_FATTR_LEASE_TIME); \
+ /* optional: */ \
+ NFS_BITMAP_SET((A), NFS_FATTR_ACLSUPPORT); \
+ NFS_BITMAP_SET((A), NFS_FATTR_CANSETTIME); \
+ NFS_BITMAP_SET((A), NFS_FATTR_CASE_INSENSITIVE); \
+ NFS_BITMAP_SET((A), NFS_FATTR_CASE_PRESERVING); \
+ NFS_BITMAP_SET((A), NFS_FATTR_CHOWN_RESTRICTED); \
+ NFS_BITMAP_SET((A), NFS_FATTR_FILES_AVAIL); \
+ NFS_BITMAP_SET((A), NFS_FATTR_FILES_FREE); \
+ NFS_BITMAP_SET((A), NFS_FATTR_FILES_TOTAL); \
+ NFS_BITMAP_SET((A), NFS_FATTR_FS_LOCATIONS); \
+ NFS_BITMAP_SET((A), NFS_FATTR_HOMOGENEOUS); \
+ NFS_BITMAP_SET((A), NFS_FATTR_MAXFILESIZE); \
+ NFS_BITMAP_SET((A), NFS_FATTR_MAXNAME); \
+ NFS_BITMAP_SET((A), NFS_FATTR_MAXREAD); \
+ NFS_BITMAP_SET((A), NFS_FATTR_MAXWRITE); \
+ NFS_BITMAP_SET((A), NFS_FATTR_NO_TRUNC); \
+ NFS_BITMAP_SET((A), NFS_FATTR_SPACE_AVAIL); \
+ NFS_BITMAP_SET((A), NFS_FATTR_SPACE_FREE); \
+ NFS_BITMAP_SET((A), NFS_FATTR_SPACE_TOTAL); \
+ NFS_BITMAP_SET((A), NFS_FATTR_TIME_DELTA); \
+ } while (0)
+
+#define NFS4_DEFAULT_ATTRIBUTES(A) \
+ do { \
+ /* required: */ \
+ NFS_BITMAP_SET((A), NFS_FATTR_SUPPORTED_ATTRS); \
+ NFS_BITMAP_SET((A), NFS_FATTR_TYPE); \
+ NFS_BITMAP_SET((A), NFS_FATTR_FH_EXPIRE_TYPE); \
+ NFS_BITMAP_SET((A), NFS_FATTR_CHANGE); \
+ NFS_BITMAP_SET((A), NFS_FATTR_SIZE); \
+ NFS_BITMAP_SET((A), NFS_FATTR_LINK_SUPPORT); \
+ NFS_BITMAP_SET((A), NFS_FATTR_SYMLINK_SUPPORT); \
+ NFS_BITMAP_SET((A), NFS_FATTR_NAMED_ATTR); \
+ NFS_BITMAP_SET((A), NFS_FATTR_FSID); \
+ NFS_BITMAP_SET((A), NFS_FATTR_UNIQUE_HANDLES); \
+ NFS_BITMAP_SET((A), NFS_FATTR_LEASE_TIME); \
+ /* NFS_BITMAP_SET((A), NFS_FATTR_RDATTR_ERROR); */ \
+ /* NFS_BITMAP_SET((A), NFS_FATTR_FILEHANDLE); */ \
+ /* optional: */ \
+ /* NFS_BITMAP_SET((A), NFS_FATTR_ACL); */ \
+ NFS_BITMAP_SET((A), NFS_FATTR_ACLSUPPORT); \
+ NFS_BITMAP_SET((A), NFS_FATTR_ARCHIVE); \
+ /* NFS_BITMAP_SET((A), NFS_FATTR_CANSETTIME); */ \
+ NFS_BITMAP_SET((A), NFS_FATTR_CASE_INSENSITIVE); \
+ NFS_BITMAP_SET((A), NFS_FATTR_CASE_PRESERVING); \
+ NFS_BITMAP_SET((A), NFS_FATTR_CHOWN_RESTRICTED); \
+ NFS_BITMAP_SET((A), NFS_FATTR_FILEID); \
+ NFS_BITMAP_SET((A), NFS_FATTR_FILES_AVAIL); \
+ NFS_BITMAP_SET((A), NFS_FATTR_FILES_FREE); \
+ NFS_BITMAP_SET((A), NFS_FATTR_FILES_TOTAL); \
+ /* NFS_BITMAP_SET((A), NFS_FATTR_FS_LOCATIONS); */ \
+ NFS_BITMAP_SET((A), NFS_FATTR_HIDDEN); \
+ NFS_BITMAP_SET((A), NFS_FATTR_HOMOGENEOUS); \
+ NFS_BITMAP_SET((A), NFS_FATTR_MAXFILESIZE); \
+ NFS_BITMAP_SET((A), NFS_FATTR_MAXLINK); \
+ NFS_BITMAP_SET((A), NFS_FATTR_MAXNAME); \
+ NFS_BITMAP_SET((A), NFS_FATTR_MAXREAD); \
+ NFS_BITMAP_SET((A), NFS_FATTR_MAXWRITE); \
+ /* NFS_BITMAP_SET((A), NFS_FATTR_MIMETYPE); */ \
+ NFS_BITMAP_SET((A), NFS_FATTR_MODE); \
+ NFS_BITMAP_SET((A), NFS_FATTR_NO_TRUNC); \
+ NFS_BITMAP_SET((A), NFS_FATTR_NUMLINKS); \
+ NFS_BITMAP_SET((A), NFS_FATTR_OWNER); \
+ NFS_BITMAP_SET((A), NFS_FATTR_OWNER_GROUP); \
+ /* NFS_BITMAP_SET((A), NFS_FATTR_QUOTA_AVAIL_HARD); */ \
+ /* NFS_BITMAP_SET((A), NFS_FATTR_QUOTA_AVAIL_SOFT); */ \
+ /* NFS_BITMAP_SET((A), NFS_FATTR_QUOTA_USED); */ \
+ NFS_BITMAP_SET((A), NFS_FATTR_RAWDEV); \
+ NFS_BITMAP_SET((A), NFS_FATTR_SPACE_AVAIL); \
+ NFS_BITMAP_SET((A), NFS_FATTR_SPACE_FREE); \
+ NFS_BITMAP_SET((A), NFS_FATTR_SPACE_TOTAL); \
+ NFS_BITMAP_SET((A), NFS_FATTR_SPACE_USED); \
+ /* NFS_BITMAP_SET((A), NFS_FATTR_SYSTEM); */ \
+ NFS_BITMAP_SET((A), NFS_FATTR_TIME_ACCESS); \
+ /* NFS_BITMAP_SET((A), NFS_FATTR_TIME_ACCESS_SET); */ \
+ NFS_BITMAP_SET((A), NFS_FATTR_TIME_BACKUP); \
+ NFS_BITMAP_SET((A), NFS_FATTR_TIME_CREATE); \
+ /* NFS_BITMAP_SET((A), NFS_FATTR_TIME_DELTA); */ \
+ NFS_BITMAP_SET((A), NFS_FATTR_TIME_METADATA); \
+ NFS_BITMAP_SET((A), NFS_FATTR_TIME_MODIFY); \
+ /* NFS_BITMAP_SET((A), NFS_FATTR_TIME_MODIFY_SET); */ \
+ NFS_BITMAP_SET((A), NFS_FATTR_MOUNTED_ON_FILEID); \
+ } while (0)
+
+/* attributes requested when we want to do a "statfs" */
+#define NFS4_STATFS_ATTRIBUTES(A) \
+ do { \
+ /* optional: */ \
+ NFS_BITMAP_SET((A), NFS_FATTR_FILES_AVAIL); \
+ NFS_BITMAP_SET((A), NFS_FATTR_FILES_FREE); \
+ NFS_BITMAP_SET((A), NFS_FATTR_FILES_TOTAL); \
+ NFS_BITMAP_SET((A), NFS_FATTR_SPACE_AVAIL); \
+ NFS_BITMAP_SET((A), NFS_FATTR_SPACE_FREE); \
+ NFS_BITMAP_SET((A), NFS_FATTR_SPACE_TOTAL); \
+ } while (0)