1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * NFSv4 file attributes supported by this implementation 4 */ 5 6 #ifndef _LINUX_NFSD_ATTR4_H 7 #define _LINUX_NFSD_ATTR4_H 8 9 #include <linux/types.h> 10 #include <linux/nfs4.h> 11 12 /* 13 * The following attributes are not implemented by NFSD: 14 * ARCHIVE (deprecated anyway) 15 * HIDDEN (unlikely to be supported any time soon) 16 * MIMETYPE (unlikely to be supported any time soon) 17 * QUOTA_* (unlikely to be supported any time soon) 18 * SYSTEM (unlikely to be supported any time soon) 19 * TIME_BACKUP (unlikely to be supported any time soon) 20 */ 21 #define NFSD4_SUPPORTED_ATTRS_WORD0 \ 22 (FATTR4_WORD0_SUPPORTED_ATTRS | FATTR4_WORD0_TYPE | FATTR4_WORD0_FH_EXPIRE_TYPE \ 23 | FATTR4_WORD0_CHANGE | FATTR4_WORD0_SIZE | FATTR4_WORD0_LINK_SUPPORT \ 24 | FATTR4_WORD0_SYMLINK_SUPPORT | FATTR4_WORD0_NAMED_ATTR | FATTR4_WORD0_FSID \ 25 | FATTR4_WORD0_UNIQUE_HANDLES | FATTR4_WORD0_LEASE_TIME | FATTR4_WORD0_RDATTR_ERROR \ 26 | FATTR4_WORD0_ACLSUPPORT | FATTR4_WORD0_CANSETTIME | FATTR4_WORD0_CASE_INSENSITIVE \ 27 | FATTR4_WORD0_CASE_PRESERVING | FATTR4_WORD0_CHOWN_RESTRICTED \ 28 | FATTR4_WORD0_FILEHANDLE | FATTR4_WORD0_FILEID | FATTR4_WORD0_FILES_AVAIL \ 29 | FATTR4_WORD0_FILES_FREE | FATTR4_WORD0_FILES_TOTAL | FATTR4_WORD0_FS_LOCATIONS | FATTR4_WORD0_HOMOGENEOUS \ 30 | FATTR4_WORD0_MAXFILESIZE | FATTR4_WORD0_MAXLINK | FATTR4_WORD0_MAXNAME \ 31 | FATTR4_WORD0_MAXREAD | FATTR4_WORD0_MAXWRITE | FATTR4_WORD0_ACL) 32 33 #define NFSD4_SUPPORTED_ATTRS_WORD1 \ 34 (FATTR4_WORD1_MODE | FATTR4_WORD1_NO_TRUNC | FATTR4_WORD1_NUMLINKS \ 35 | FATTR4_WORD1_OWNER | FATTR4_WORD1_OWNER_GROUP | FATTR4_WORD1_RAWDEV \ 36 | FATTR4_WORD1_SPACE_AVAIL | FATTR4_WORD1_SPACE_FREE | FATTR4_WORD1_SPACE_TOTAL \ 37 | FATTR4_WORD1_SPACE_USED | FATTR4_WORD1_TIME_ACCESS | FATTR4_WORD1_TIME_ACCESS_SET \ 38 | FATTR4_WORD1_TIME_DELTA | FATTR4_WORD1_TIME_METADATA | FATTR4_WORD1_TIME_CREATE \ 39 | FATTR4_WORD1_TIME_MODIFY | FATTR4_WORD1_TIME_MODIFY_SET | FATTR4_WORD1_MOUNTED_ON_FILEID) 40 41 #define NFSD4_SUPPORTED_ATTRS_WORD2 0 42 43 /* 4.1 */ 44 #ifdef CONFIG_NFSD_PNFS 45 #define PNFSD_SUPPORTED_ATTRS_WORD1 FATTR4_WORD1_FS_LAYOUT_TYPES 46 #define PNFSD_SUPPORTED_ATTRS_WORD2 \ 47 (FATTR4_WORD2_LAYOUT_BLKSIZE | FATTR4_WORD2_LAYOUT_TYPES) 48 #else 49 #define PNFSD_SUPPORTED_ATTRS_WORD1 0 50 #define PNFSD_SUPPORTED_ATTRS_WORD2 0 51 #endif /* CONFIG_NFSD_PNFS */ 52 53 #define NFSD4_1_SUPPORTED_ATTRS_WORD0 \ 54 NFSD4_SUPPORTED_ATTRS_WORD0 55 56 #define NFSD4_1_SUPPORTED_ATTRS_WORD1 \ 57 (NFSD4_SUPPORTED_ATTRS_WORD1 | PNFSD_SUPPORTED_ATTRS_WORD1) 58 59 #define NFSD4_1_SUPPORTED_ATTRS_WORD2 \ 60 (NFSD4_SUPPORTED_ATTRS_WORD2 | PNFSD_SUPPORTED_ATTRS_WORD2 | \ 61 FATTR4_WORD2_SUPPATTR_EXCLCREAT) 62 63 /* 4.2 */ 64 #ifdef CONFIG_NFSD_V4_SECURITY_LABEL 65 #define NFSD4_2_SECURITY_ATTRS FATTR4_WORD2_SECURITY_LABEL 66 #else 67 #define NFSD4_2_SECURITY_ATTRS 0 68 #endif 69 70 #ifdef CONFIG_NFSD_V4_POSIX_ACLS 71 #define NFSD4_2_POSIX_ACL_ATTRS \ 72 (FATTR4_WORD2_ACL_TRUEFORM | \ 73 FATTR4_WORD2_ACL_TRUEFORM_SCOPE | \ 74 FATTR4_WORD2_POSIX_DEFAULT_ACL | \ 75 FATTR4_WORD2_POSIX_ACCESS_ACL) 76 #else 77 #define NFSD4_2_POSIX_ACL_ATTRS 0 78 #endif 79 80 #define NFSD4_2_SUPPORTED_ATTRS_WORD2 \ 81 (NFSD4_1_SUPPORTED_ATTRS_WORD2 | \ 82 FATTR4_WORD2_MODE_UMASK | \ 83 FATTR4_WORD2_CLONE_BLKSIZE | \ 84 NFSD4_2_SECURITY_ATTRS | \ 85 FATTR4_WORD2_XATTR_SUPPORT | \ 86 FATTR4_WORD2_TIME_DELEG_ACCESS | \ 87 FATTR4_WORD2_TIME_DELEG_MODIFY | \ 88 FATTR4_WORD2_OPEN_ARGUMENTS | \ 89 NFSD4_2_POSIX_ACL_ATTRS) 90 91 /* These will return ERR_INVAL if specified in GETATTR or READDIR. */ 92 #define NFSD_WRITEONLY_ATTRS_WORD1 \ 93 (FATTR4_WORD1_TIME_ACCESS_SET | FATTR4_WORD1_TIME_MODIFY_SET) 94 95 /* 96 * These are the only attrs allowed in CREATE/OPEN/SETATTR. Don't add 97 * a writeable attribute here without also adding code to parse it to 98 * nfsd4_decode_fattr4(). 99 */ 100 #define NFSD_WRITEABLE_ATTRS_WORD0 \ 101 (FATTR4_WORD0_SIZE | FATTR4_WORD0_ACL) 102 #define NFSD_WRITEABLE_ATTRS_WORD1 \ 103 (FATTR4_WORD1_MODE | FATTR4_WORD1_OWNER | FATTR4_WORD1_OWNER_GROUP \ 104 | FATTR4_WORD1_TIME_ACCESS_SET | FATTR4_WORD1_TIME_CREATE \ 105 | FATTR4_WORD1_TIME_MODIFY_SET) 106 #ifdef CONFIG_NFSD_V4_SECURITY_LABEL 107 #define MAYBE_FATTR4_WORD2_SECURITY_LABEL \ 108 FATTR4_WORD2_SECURITY_LABEL 109 #else 110 #define MAYBE_FATTR4_WORD2_SECURITY_LABEL 0 111 #endif 112 #ifdef CONFIG_NFSD_V4_POSIX_ACLS 113 #define MAYBE_FATTR4_WORD2_POSIX_ACL_ATTRS \ 114 FATTR4_WORD2_POSIX_DEFAULT_ACL | FATTR4_WORD2_POSIX_ACCESS_ACL 115 #else 116 #define MAYBE_FATTR4_WORD2_POSIX_ACL_ATTRS 0 117 #endif 118 #define NFSD_WRITEABLE_ATTRS_WORD2 \ 119 (FATTR4_WORD2_MODE_UMASK \ 120 | MAYBE_FATTR4_WORD2_SECURITY_LABEL \ 121 | FATTR4_WORD2_TIME_DELEG_ACCESS \ 122 | FATTR4_WORD2_TIME_DELEG_MODIFY \ 123 | MAYBE_FATTR4_WORD2_POSIX_ACL_ATTRS \ 124 ) 125 126 #define NFSD_SUPPATTR_EXCLCREAT_WORD0 \ 127 NFSD_WRITEABLE_ATTRS_WORD0 128 /* 129 * we currently store the exclusive create verifier in the v_{a,m}time 130 * attributes so the client can't set these at create time using EXCLUSIVE4_1 131 */ 132 #define NFSD_SUPPATTR_EXCLCREAT_WORD1 \ 133 (NFSD_WRITEABLE_ATTRS_WORD1 & \ 134 ~(FATTR4_WORD1_TIME_ACCESS_SET | FATTR4_WORD1_TIME_MODIFY_SET)) 135 /* 136 * The FATTR4_WORD2_TIME_DELEG attributes are not to be allowed for 137 * OPEN(create) with EXCLUSIVE4_1. It doesn't make sense to set a 138 * delegated timestamp on a new file. 139 * 140 * This mask includes NFSv4.2-only attributes (e.g., POSIX ACLs). 141 * Version filtering occurs via nfsd_suppattrs[] before this mask 142 * is applied, so pre-4.2 clients never see unsupported attributes. 143 */ 144 #define NFSD_SUPPATTR_EXCLCREAT_WORD2 \ 145 (NFSD_WRITEABLE_ATTRS_WORD2 & \ 146 ~(FATTR4_WORD2_TIME_DELEG_ACCESS | FATTR4_WORD2_TIME_DELEG_MODIFY)) 147 148 extern const u32 nfsd_suppattrs[3][3]; 149 bmval_is_subset(const u32 * bm1,const u32 * bm2)150static inline bool bmval_is_subset(const u32 *bm1, const u32 *bm2) 151 { 152 return !((bm1[0] & ~bm2[0]) || 153 (bm1[1] & ~bm2[1]) || 154 (bm1[2] & ~bm2[2])); 155 } 156 nfsd_attrs_supported(u32 minorversion,const u32 * bmval)157static inline bool nfsd_attrs_supported(u32 minorversion, const u32 *bmval) 158 { 159 return bmval_is_subset(bmval, nfsd_suppattrs[minorversion]); 160 } 161 162 #endif /* _LINUX_NFSD_ATTR4_H */ 163