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