xref: /titanic_51/usr/src/uts/common/sys/attr.h (revision c498d9365aa68b789215f4f356a9935f70b0fb3b)
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 2007 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _SYS_ATTR_H
27 #define	_SYS_ATTR_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #ifdef	__cplusplus
32 extern "C" {
33 #endif
34 
35 #ifdef _KERNEL
36 #include <sys/vnode.h>
37 #include <sys/vfs.h>
38 #include <nfs/nfs.h>
39 #endif
40 #include <sys/nvpair.h>
41 
42 /* Attribute names for nvlist's */
43 #define	A_CRTIME		"crtime"
44 #define	A_HIDDEN		"hidden"
45 #define	A_SYSTEM		"system"
46 #define	A_READONLY		"readonly"
47 #define	A_ARCHIVE		"archive"
48 #define	A_NOUNLINK		"nounlink"
49 #define	A_IMMUTABLE		"immutable"
50 #define	A_APPENDONLY		"appendonly"
51 #define	A_NODUMP		"nodump"
52 #define	A_OPAQUE		"opaque"
53 #define	A_AV_QUARANTINED	"av_quarantined"
54 #define	A_AV_MODIFIED		"av_modified"
55 #define	A_FSID			"fsid"
56 #define	A_AV_SCANSTAMP		"av_scanstamp"
57 #define	A_OWNERSID		"ownersid"
58 #define	A_GROUPSID		"groupsid"
59 
60 /* Attribute option for utilities */
61 #define	O_HIDDEN	 "H"
62 #define	O_SYSTEM	 "S"
63 #define	O_READONLY	 "R"
64 #define	O_ARCHIVE	 "A"
65 #define	O_NOUNLINK	 "u"
66 #define	O_IMMUTABLE	 "i"
67 #define	O_APPENDONLY	 "a"
68 #define	O_NODUMP	 "d"
69 #define	O_AV_QUARANTINED "q"
70 #define	O_AV_MODIFIED	 "m"
71 #define	O_NONE		 ""
72 
73 /* ownersid and groupsid are composed of two nvpairs */
74 #define	SID_DOMAIN		"domain"
75 #define	SID_RID			"rid"
76 
77 typedef enum {
78 	F_ATTR_INVAL = -1,
79 	F_ARCHIVE,
80 	F_HIDDEN,
81 	F_READONLY,
82 	F_SYSTEM,
83 	F_APPENDONLY,
84 	F_NODUMP,
85 	F_IMMUTABLE,
86 	F_AV_MODIFIED,
87 	F_OPAQUE,
88 	F_AV_SCANSTAMP,
89 	F_AV_QUARANTINED,
90 	F_NOUNLINK,
91 	F_CRTIME,
92 	F_OWNERSID,
93 	F_GROUPSID,
94 	F_FSID,
95 	F_ATTR_ALL
96 } f_attr_t;
97 
98 #define	VIEW_READONLY	"SUNWattr_ro"
99 #define	VIEW_READWRITE	"SUNWattr_rw"
100 
101 /*
102  * These are the supported views into the virtual sysattr directory.
103  * Additional views should be added before XATTR_VIEW_LAST.
104  */
105 typedef enum {
106 	XATTR_VIEW_INVALID = -1,
107 	XATTR_VIEW_READONLY,
108 	XATTR_VIEW_READWRITE,
109 	XATTR_VIEW_LAST
110 } xattr_view_t;
111 
112 typedef struct {
113 	char		*x_name;
114 	char		*x_option;
115 	xattr_view_t	x_xattr_view;
116 	data_type_t	x_data_type;
117 } xattr_entry_t;
118 
119 #ifdef _KERNEL
120 #define	XATTR_MAXFIDSZ	NFS_FHMAXDATA
121 
122 typedef struct {
123 	uint16_t	len;
124 	char		parent_fid[XATTR_MAXFIDSZ];
125 	uint16_t	parent_len;
126 	uint16_t	dir_offset;
127 } xattr_fid_t;
128 
129 #define	XATTR_FIDSZ (sizeof (xattr_fid_t) - sizeof (uint16_t))
130 
131 int xattr_dir_vget(vfs_t *, vnode_t **, fid_t *);
132 int xattr_sysattr_casechk(char *name);
133 #endif
134 
135 int attr_count(void);
136 const char *attr_to_name(f_attr_t);
137 const char *attr_to_option(f_attr_t);
138 f_attr_t name_to_attr(const char *name);
139 f_attr_t option_to_attr(const char *option);
140 xattr_view_t attr_to_xattr_view(f_attr_t attr);
141 data_type_t attr_to_data_type(f_attr_t attr);
142 
143 #ifdef	__cplusplus
144 }
145 #endif
146 
147 #endif	/* _SYS_ATTR_H */
148