1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 /* 22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26 #ifndef _NFS4_ATTR_H 27 #define _NFS4_ATTR_H 28 29 #ifdef __cplusplus 30 extern "C" { 31 #endif 32 33 #define FATTR4_WORD0 32 34 #define FATTR4_WORD1 0 35 36 /* 37 * Attributes 38 */ 39 #define FATTR4_SUPPORTED_ATTRS_MASK (1ULL << (FATTR4_WORD0 + 0)) 40 #define FATTR4_TYPE_MASK (1ULL << (FATTR4_WORD0 + 1)) 41 #define FATTR4_FH_EXPIRE_TYPE_MASK (1ULL << (FATTR4_WORD0 + 2)) 42 #define FATTR4_CHANGE_MASK (1ULL << (FATTR4_WORD0 + 3)) 43 #define FATTR4_SIZE_MASK (1ULL << (FATTR4_WORD0 + 4)) 44 #define FATTR4_LINK_SUPPORT_MASK (1ULL << (FATTR4_WORD0 + 5)) 45 #define FATTR4_SYMLINK_SUPPORT_MASK (1ULL << (FATTR4_WORD0 + 6)) 46 #define FATTR4_NAMED_ATTR_MASK (1ULL << (FATTR4_WORD0 + 7)) 47 #define FATTR4_FSID_MASK (1ULL << (FATTR4_WORD0 + 8)) 48 #define FATTR4_UNIQUE_HANDLES_MASK (1ULL << (FATTR4_WORD0 + 9)) 49 #define FATTR4_LEASE_TIME_MASK (1ULL << (FATTR4_WORD0 + 10)) 50 #define FATTR4_RDATTR_ERROR_MASK (1ULL << (FATTR4_WORD0 + 11)) 51 #define FATTR4_ACL_MASK (1ULL << (FATTR4_WORD0 + 12)) 52 #define FATTR4_ACLSUPPORT_MASK (1ULL << (FATTR4_WORD0 + 13)) 53 #define FATTR4_ARCHIVE_MASK (1ULL << (FATTR4_WORD0 + 14)) 54 #define FATTR4_CANSETTIME_MASK (1ULL << (FATTR4_WORD0 + 15)) 55 #define FATTR4_CASE_INSENSITIVE_MASK (1ULL << (FATTR4_WORD0 + 16)) 56 #define FATTR4_CASE_PRESERVING_MASK (1ULL << (FATTR4_WORD0 + 17)) 57 #define FATTR4_CHOWN_RESTRICTED_MASK (1ULL << (FATTR4_WORD0 + 18)) 58 #define FATTR4_FILEHANDLE_MASK (1ULL << (FATTR4_WORD0 + 19)) 59 #define FATTR4_FILEID_MASK (1ULL << (FATTR4_WORD0 + 20)) 60 #define FATTR4_FILES_AVAIL_MASK (1ULL << (FATTR4_WORD0 + 21)) 61 #define FATTR4_FILES_FREE_MASK (1ULL << (FATTR4_WORD0 + 22)) 62 #define FATTR4_FILES_TOTAL_MASK (1ULL << (FATTR4_WORD0 + 23)) 63 #define FATTR4_FS_LOCATIONS_MASK (1ULL << (FATTR4_WORD0 + 24)) 64 #define FATTR4_HIDDEN_MASK (1ULL << (FATTR4_WORD0 + 25)) 65 #define FATTR4_HOMOGENEOUS_MASK (1ULL << (FATTR4_WORD0 + 26)) 66 #define FATTR4_MAXFILESIZE_MASK (1ULL << (FATTR4_WORD0 + 27)) 67 #define FATTR4_MAXLINK_MASK (1ULL << (FATTR4_WORD0 + 28)) 68 #define FATTR4_MAXNAME_MASK (1ULL << (FATTR4_WORD0 + 29)) 69 #define FATTR4_MAXREAD_MASK (1ULL << (FATTR4_WORD0 + 30)) 70 #define FATTR4_MAXWRITE_MASK (1ULL << (FATTR4_WORD0 + 31)) 71 72 #define FATTR4_MIMETYPE_MASK (1ULL << (FATTR4_WORD1 + 0)) 73 #define FATTR4_MODE_MASK (1ULL << (FATTR4_WORD1 + 1)) 74 #define FATTR4_NO_TRUNC_MASK (1ULL << (FATTR4_WORD1 + 2)) 75 #define FATTR4_NUMLINKS_MASK (1ULL << (FATTR4_WORD1 + 3)) 76 #define FATTR4_OWNER_MASK (1ULL << (FATTR4_WORD1 + 4)) 77 #define FATTR4_OWNER_GROUP_MASK (1ULL << (FATTR4_WORD1 + 5)) 78 #define FATTR4_QUOTA_AVAIL_HARD_MASK (1ULL << (FATTR4_WORD1 + 6)) 79 #define FATTR4_QUOTA_AVAIL_SOFT_MASK (1ULL << (FATTR4_WORD1 + 7)) 80 #define FATTR4_QUOTA_USED_MASK (1ULL << (FATTR4_WORD1 + 8)) 81 #define FATTR4_RAWDEV_MASK (1ULL << (FATTR4_WORD1 + 9)) 82 #define FATTR4_SPACE_AVAIL_MASK (1ULL << (FATTR4_WORD1 + 10)) 83 #define FATTR4_SPACE_FREE_MASK (1ULL << (FATTR4_WORD1 + 11)) 84 #define FATTR4_SPACE_TOTAL_MASK (1ULL << (FATTR4_WORD1 + 12)) 85 #define FATTR4_SPACE_USED_MASK (1ULL << (FATTR4_WORD1 + 13)) 86 #define FATTR4_SYSTEM_MASK (1ULL << (FATTR4_WORD1 + 14)) 87 #define FATTR4_TIME_ACCESS_MASK (1ULL << (FATTR4_WORD1 + 15)) 88 #define FATTR4_TIME_ACCESS_SET_MASK (1ULL << (FATTR4_WORD1 + 16)) 89 #define FATTR4_TIME_BACKUP_MASK (1ULL << (FATTR4_WORD1 + 17)) 90 #define FATTR4_TIME_CREATE_MASK (1ULL << (FATTR4_WORD1 + 18)) 91 #define FATTR4_TIME_DELTA_MASK (1ULL << (FATTR4_WORD1 + 19)) 92 #define FATTR4_TIME_METADATA_MASK (1ULL << (FATTR4_WORD1 + 20)) 93 #define FATTR4_TIME_MODIFY_MASK (1ULL << (FATTR4_WORD1 + 21)) 94 #define FATTR4_TIME_MODIFY_SET_MASK (1ULL << (FATTR4_WORD1 + 22)) 95 #define FATTR4_MOUNTED_ON_FILEID_MASK (1ULL << (FATTR4_WORD1 + 23)) 96 97 /* nfsv4.1 */ 98 99 /* Overload to fit to 64-bits bitmap4 */ 100 #define FATTR4_SUPPATTR_EXCLCREAT_MASK_LOCAL (1ULL << (FATTR4_WORD1 + 24)) 101 #define FATTR4_SEC_LABEL_MASK_LOCAL (1ULL << (FATTR4_WORD1 + 25)) 102 103 /* 104 * Common bitmap4 of file attributes to be gathered 105 */ 106 #define NFS4_NTOV_ATTR_MASK ( \ 107 FATTR4_TYPE_MASK | \ 108 FATTR4_CHANGE_MASK | \ 109 FATTR4_SIZE_MASK | \ 110 FATTR4_FSID_MASK | \ 111 FATTR4_FILEID_MASK | \ 112 FATTR4_MODE_MASK | \ 113 FATTR4_OWNER_MASK | \ 114 FATTR4_OWNER_GROUP_MASK | \ 115 FATTR4_NUMLINKS_MASK | \ 116 FATTR4_TIME_ACCESS_MASK | \ 117 FATTR4_TIME_MODIFY_MASK | \ 118 FATTR4_TIME_METADATA_MASK | \ 119 FATTR4_RAWDEV_MASK | \ 120 FATTR4_SPACE_USED_MASK | \ 121 FATTR4_MOUNTED_ON_FILEID_MASK) 122 123 #define NFS4_VATTR_MASK ( \ 124 FATTR4_TYPE_MASK | \ 125 FATTR4_CHANGE_MASK | \ 126 FATTR4_SIZE_MASK | \ 127 FATTR4_FSID_MASK | \ 128 FATTR4_FILEID_MASK | \ 129 FATTR4_MODE_MASK | \ 130 FATTR4_OWNER_MASK | \ 131 FATTR4_OWNER_GROUP_MASK | \ 132 FATTR4_NUMLINKS_MASK | \ 133 FATTR4_TIME_ACCESS_MASK | \ 134 FATTR4_TIME_MODIFY_MASK | \ 135 FATTR4_TIME_METADATA_MASK | \ 136 FATTR4_RAWDEV_MASK | \ 137 FATTR4_SPACE_USED_MASK | \ 138 FATTR4_MOUNTED_ON_FILEID_MASK) 139 140 #define NFS4_PATHCONF_MASK ( \ 141 NFS4_VATTR_MASK | \ 142 FATTR4_NO_TRUNC_MASK | \ 143 FATTR4_CHOWN_RESTRICTED_MASK | \ 144 FATTR4_CASE_INSENSITIVE_MASK | \ 145 FATTR4_CASE_PRESERVING_MASK | \ 146 FATTR4_NAMED_ATTR_MASK | \ 147 FATTR4_LINK_SUPPORT_MASK | \ 148 FATTR4_SYMLINK_SUPPORT_MASK | \ 149 FATTR4_UNIQUE_HANDLES_MASK | \ 150 FATTR4_CANSETTIME_MASK | \ 151 FATTR4_HOMOGENEOUS_MASK | \ 152 FATTR4_MAXLINK_MASK | \ 153 FATTR4_MAXNAME_MASK | \ 154 FATTR4_MAXFILESIZE_MASK) 155 156 /* 157 * The corresponding AT_MASK 158 */ 159 #define NFS4_NTOV_ATTR_AT_MASK ( \ 160 AT_TYPE | \ 161 AT_SIZE | \ 162 AT_FSID | \ 163 AT_NODEID | \ 164 AT_MODE | \ 165 AT_UID | \ 166 AT_GID | \ 167 AT_NLINK | \ 168 AT_ATIME | \ 169 AT_MTIME | \ 170 AT_CTIME | \ 171 AT_RDEV | \ 172 AT_NBLOCKS) 173 174 /* 175 * Common bitmap4 of filesystem attributes to be gathered 176 */ 177 #define NFS4_FS_ATTR_MASK ( \ 178 FATTR4_FILES_AVAIL_MASK | \ 179 FATTR4_FILES_FREE_MASK | \ 180 FATTR4_FILES_TOTAL_MASK | \ 181 FATTR4_SPACE_AVAIL_MASK | \ 182 FATTR4_SPACE_FREE_MASK | \ 183 FATTR4_SPACE_TOTAL_MASK) 184 185 #define NFS4_STATFS_ATTR_MASK ( \ 186 FATTR4_FILES_AVAIL_MASK | \ 187 FATTR4_FILES_FREE_MASK | \ 188 FATTR4_FILES_TOTAL_MASK | \ 189 FATTR4_SPACE_AVAIL_MASK | \ 190 FATTR4_SPACE_FREE_MASK | \ 191 FATTR4_SPACE_TOTAL_MASK | \ 192 FATTR4_MAXNAME_MASK) 193 194 /* 195 * The corresponding AT_MASK 196 */ 197 #define NFS4_FS_ATTR_AT_MASK 0 198 199 /* 200 * Common bitmap4 to gather attr cache state 201 */ 202 #define NFS4_NTOV_ATTR_CACHE_MASK ( \ 203 FATTR4_TIME_METADATA_MASK | \ 204 FATTR4_TIME_MODIFY_MASK | \ 205 FATTR4_SIZE_MASK) 206 207 /* 208 * The corresponding AT_MASK 209 */ 210 #define NFS4_NTOV_ATTR_CACHE_AT_MASK ( \ 211 AT_CTIME | \ 212 AT_MTIME | \ 213 AT_SIZE) 214 215 #define NFS4_VTON_ATTR_MASK ( \ 216 AT_TYPE | \ 217 AT_MODE | \ 218 AT_UID | \ 219 AT_GID | \ 220 AT_NODEID | \ 221 AT_SIZE | \ 222 AT_NLINK | \ 223 AT_ATIME | \ 224 AT_MTIME | \ 225 AT_CTIME | \ 226 AT_RDEV | \ 227 AT_NBLOCKS | \ 228 AT_FSID) 229 230 #define NFS4_VTON_ATTR_MASK_SET ( \ 231 AT_MODE | \ 232 AT_UID | \ 233 AT_GID | \ 234 AT_SIZE | \ 235 AT_ATIME | \ 236 AT_MTIME) 237 238 /* solaris-supported, non-vattr_t per-vnode scoped attrs */ 239 #define NFS4_VP_ATTR_MASK ( \ 240 FATTR4_CHANGE_MASK | \ 241 FATTR4_CHOWN_RESTRICTED_MASK | \ 242 FATTR4_FILEHANDLE_MASK | \ 243 FATTR4_MAXFILESIZE_MASK | \ 244 FATTR4_MAXLINK_MASK | \ 245 FATTR4_MAXNAME_MASK | \ 246 FATTR4_MOUNTED_ON_FILEID_MASK) 247 248 #define FATTR4_FSINFO_MASK ( \ 249 FATTR4_SUPPORTED_ATTRS_MASK | \ 250 FATTR4_TYPE_MASK | \ 251 FATTR4_FH_EXPIRE_TYPE_MASK | \ 252 FATTR4_LINK_SUPPORT_MASK | \ 253 FATTR4_SYMLINK_SUPPORT_MASK | \ 254 FATTR4_FSID_MASK | \ 255 FATTR4_MAXFILESIZE_MASK | \ 256 FATTR4_MAXREAD_MASK | \ 257 FATTR4_MAXWRITE_MASK) 258 259 /* 260 * These are the support attributes for the NFSv4 server 261 */ 262 #define NFS4_SRV_RDDIR_SUPPORTED_ATTRS ( \ 263 FATTR4_SUPPORTED_ATTRS_MASK | \ 264 FATTR4_TYPE_MASK | \ 265 FATTR4_FH_EXPIRE_TYPE_MASK | \ 266 FATTR4_CHANGE_MASK | \ 267 FATTR4_SIZE_MASK | \ 268 FATTR4_LINK_SUPPORT_MASK | \ 269 FATTR4_SYMLINK_SUPPORT_MASK | \ 270 FATTR4_NAMED_ATTR_MASK | \ 271 FATTR4_FSID_MASK | \ 272 FATTR4_UNIQUE_HANDLES_MASK | \ 273 FATTR4_LEASE_TIME_MASK | \ 274 FATTR4_RDATTR_ERROR_MASK | \ 275 FATTR4_CANSETTIME_MASK | \ 276 FATTR4_CASE_INSENSITIVE_MASK | \ 277 FATTR4_CASE_PRESERVING_MASK | \ 278 FATTR4_CHOWN_RESTRICTED_MASK | \ 279 FATTR4_FILEHANDLE_MASK | \ 280 FATTR4_FILEID_MASK | \ 281 FATTR4_FILES_AVAIL_MASK | \ 282 FATTR4_FILES_FREE_MASK | \ 283 FATTR4_FILES_TOTAL_MASK | \ 284 FATTR4_FS_LOCATIONS_MASK | \ 285 FATTR4_HOMOGENEOUS_MASK | \ 286 FATTR4_MAXFILESIZE_MASK | \ 287 FATTR4_MAXLINK_MASK | \ 288 FATTR4_MAXNAME_MASK | \ 289 FATTR4_MAXREAD_MASK | \ 290 FATTR4_MAXWRITE_MASK | \ 291 FATTR4_MODE_MASK | \ 292 FATTR4_NO_TRUNC_MASK | \ 293 FATTR4_NUMLINKS_MASK | \ 294 FATTR4_OWNER_MASK | \ 295 FATTR4_OWNER_GROUP_MASK | \ 296 FATTR4_RAWDEV_MASK | \ 297 FATTR4_SPACE_AVAIL_MASK | \ 298 FATTR4_SPACE_FREE_MASK | \ 299 FATTR4_SPACE_TOTAL_MASK | \ 300 FATTR4_SPACE_USED_MASK | \ 301 FATTR4_TIME_ACCESS_MASK | \ 302 FATTR4_TIME_DELTA_MASK | \ 303 FATTR4_TIME_METADATA_MASK | \ 304 FATTR4_TIME_MODIFY_MASK | \ 305 FATTR4_MOUNTED_ON_FILEID_MASK \ 306 ) 307 308 /* nfsv4.1 */ 309 #define RFS4_SUPPATTR_EXCLCREAT ( \ 310 FATTR4_SIZE_MASK | \ 311 FATTR4_MODE_MASK | \ 312 FATTR4_ACL_MASK | \ 313 FATTR4_OWNER_MASK | \ 314 FATTR4_OWNER_GROUP_MASK | \ 315 FATTR4_TIME_ACCESS_SET_MASK) 316 317 #define FATTR4_FSID_EQ(a, b) \ 318 ((a)->major == (b)->major && (a)->minor == (b)->minor) 319 320 #define NFS4_MAXNUM_BITWORDS 2 321 #define NFS4_MAXNUM_ATTRS 57 322 323 union nfs4_attr_u { 324 fattr4_supported_attrs supported_attrs; 325 fattr4_type type; 326 fattr4_fh_expire_type fh_expire_type; 327 fattr4_change change; 328 fattr4_size size; 329 fattr4_link_support link_support; 330 fattr4_symlink_support symlink_support; 331 fattr4_named_attr named_attr; 332 fattr4_fsid fsid; 333 fattr4_unique_handles unique_handles; 334 fattr4_lease_time lease_time; 335 fattr4_rdattr_error rdattr_error; 336 fattr4_acl acl; 337 fattr4_aclsupport aclsupport; 338 fattr4_archive archive; 339 fattr4_cansettime cansettime; 340 fattr4_case_insensitive case_insensitive; 341 fattr4_case_preserving case_preserving; 342 fattr4_chown_restricted chown_restricted; 343 fattr4_fileid fileid; 344 fattr4_files_avail files_avail; 345 fattr4_filehandle filehandle; 346 fattr4_files_free files_free; 347 fattr4_files_total files_total; 348 fattr4_fs_locations fs_locations; 349 fattr4_hidden hidden; 350 fattr4_homogeneous homogeneous; 351 fattr4_maxfilesize maxfilesize; 352 fattr4_maxlink maxlink; 353 fattr4_maxname maxname; 354 fattr4_maxread maxread; 355 fattr4_maxwrite maxwrite; 356 fattr4_mimetype mimetype; 357 fattr4_mode mode; 358 fattr4_no_trunc no_trunc; 359 fattr4_numlinks numlinks; 360 fattr4_owner owner; 361 fattr4_owner_group owner_group; 362 fattr4_quota_avail_hard quota_avail_hard; 363 fattr4_quota_avail_soft quota_avail_soft; 364 fattr4_quota_used quota_used; 365 fattr4_rawdev rawdev; 366 fattr4_space_avail space_avail; 367 fattr4_space_free space_free; 368 fattr4_space_total space_total; 369 fattr4_space_used space_used; 370 fattr4_system system; 371 fattr4_time_access time_access; 372 fattr4_time_access_set time_access_set; 373 fattr4_time_backup time_backup; 374 fattr4_time_create time_create; 375 fattr4_time_delta time_delta; 376 fattr4_time_metadata time_metadata; 377 fattr4_time_modify time_modify; 378 fattr4_time_modify_set time_modify_set; 379 fattr4_mounted_on_fileid mounted_on_fileid; 380 fattr4_suppattr_exclcreat supp_exclcreat; 381 }; 382 383 /* 384 * Error details when processing the getattr response. 385 */ 386 #define NFS4_GETATTR_OP_OK 0 387 #define NFS4_GETATTR_STATUS_ERR 1 388 #define NFS4_GETATTR_MANDATTR_ERR 2 389 #define NFS4_GETATTR_BITMAP_ERR 3 390 #define NFS4_GETATTR_ATSIZE_ERR 4 391 #define NFS4_GETATTR_ATUID_ERR 5 392 #define NFS4_GETATTR_ATGID_ERR 6 393 #define NFS4_GETATTR_ATATIME_ERR 7 394 #define NFS4_GETATTR_ATMTIME_ERR 8 395 #define NFS4_GETATTR_ATCTIME_ERR 9 396 #define NFS4_GETATTR_RAWDEV_ERR 10 397 #define NFS4_GETATTR_ATNBLOCK_ERR 11 398 #define NFS4_GETATTR_MAXFILESIZE_ERR 12 399 #define NFS4_GETATTR_FHANDLE_ERR 13 400 #define NFS4_GETATTR_MAXREAD_ERR 14 401 #define NFS4_GETATTR_MAXWRITE_ERR 15 402 #define NFS4_GETATTR_NOCACHE_OK 16 403 404 typedef struct nfs4_pathconf_info { 405 unsigned pc4_cache_valid:1; /* When in rnode4, is data valid? */ 406 unsigned pc4_no_trunc:1; 407 unsigned pc4_chown_restricted:1; 408 unsigned pc4_case_insensitive:1; 409 unsigned pc4_case_preserving:1; 410 unsigned pc4_xattr_valid:1; 411 unsigned pc4_xattr_exists:1; 412 unsigned pc4_link_support:1; 413 unsigned pc4_symlink_support:1; 414 unsigned pc4_unique_handles:1; 415 unsigned pc4_cansettime:1; 416 unsigned pc4_homogeneous:1; 417 uint_t pc4_link_max; 418 uint_t pc4_name_max; 419 uint_t pc4_filesizebits; 420 } nfs4_pathconf_info_t; 421 422 /* 423 * Used for client only to process incoming getattr results. 424 */ 425 typedef struct nfs4_ga_ext_res { 426 bitmap4 n4g_suppattrs; 427 nfsstat4 n4g_rdattr_error; 428 fattr4_fh_expire_type n4g_fet; 429 fattr4_lease_time n4g_leasetime; 430 uint64_t n4g_maxfilesize; 431 uint64_t n4g_maxread; 432 uint64_t n4g_maxwrite; 433 nfstime4 n4g_delta; 434 nfs4_pathconf_info_t n4g_pc4; 435 struct statvfs64 n4g_sb; 436 union { 437 nfs_fh4 n4g_fh; 438 struct { 439 uint_t len; 440 char *val; 441 char data[NFS4_FHSIZE]; 442 } nfs_fh4_alt; 443 } n4g_fh_u; 444 /* 445 * Bitmask with valid fields being: 446 * ACL4_SUPPORT_ALLOW_ACL 447 * ACL4_SUPPORT_DENY_ACL 448 * ACL4_SUPPORT_AUDIT_ACL 449 * ACL4_SUPPORT_ALARM_ACL 450 */ 451 fattr4_aclsupport n4g_aclsupport; 452 fattr4_fs_locations n4g_fslocations; 453 } nfs4_ga_ext_res_t; 454 455 extern bitmap4 rfs4_supported_attrs; 456 457 #ifdef __cplusplus 458 } 459 #endif 460 461 #endif /* _NFS4_ATTR_H */ 462