xref: /illumos-gate/usr/src/uts/common/sys/attr.h (revision 7800901e60d340b6af88e94a2149805dcfcaaf56)
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_MDEV			"mdev"
58 #define	A_OWNERSID		"ownersid"
59 #define	A_GROUPSID		"groupsid"
60 
61 /* Attribute option for utilities */
62 #define	O_HIDDEN	 "H"
63 #define	O_SYSTEM	 "S"
64 #define	O_READONLY	 "R"
65 #define	O_ARCHIVE	 "A"
66 #define	O_NOUNLINK	 "u"
67 #define	O_IMMUTABLE	 "i"
68 #define	O_APPENDONLY	 "a"
69 #define	O_NODUMP	 "d"
70 #define	O_AV_QUARANTINED "q"
71 #define	O_AV_MODIFIED	 "m"
72 #define	O_NONE		 ""
73 
74 /* ownersid and groupsid are composed of two nvpairs */
75 #define	SID_DOMAIN		"domain"
76 #define	SID_RID			"rid"
77 
78 typedef enum {
79 	F_ATTR_INVAL = -1,
80 	F_ARCHIVE,
81 	F_HIDDEN,
82 	F_READONLY,
83 	F_SYSTEM,
84 	F_APPENDONLY,
85 	F_NODUMP,
86 	F_IMMUTABLE,
87 	F_AV_MODIFIED,
88 	F_OPAQUE,
89 	F_AV_SCANSTAMP,
90 	F_AV_QUARANTINED,
91 	F_NOUNLINK,
92 	F_CRTIME,
93 	F_OWNERSID,
94 	F_GROUPSID,
95 	F_FSID,
96 	F_MDEV,
97 	F_ATTR_ALL
98 } f_attr_t;
99 
100 #define	VIEW_READONLY	"SUNWattr_ro"
101 #define	VIEW_READWRITE	"SUNWattr_rw"
102 
103 /*
104  * These are the supported views into the virtual sysattr directory.
105  * Additional views should be added before XATTR_VIEW_LAST.
106  */
107 typedef enum {
108 	XATTR_VIEW_INVALID = -1,
109 	XATTR_VIEW_READONLY,
110 	XATTR_VIEW_READWRITE,
111 	XATTR_VIEW_LAST
112 } xattr_view_t;
113 
114 typedef struct {
115 	char		*x_name;
116 	char		*x_option;
117 	xattr_view_t	x_xattr_view;
118 	data_type_t	x_data_type;
119 } xattr_entry_t;
120 
121 #ifdef _KERNEL
122 #define	XATTR_MAXFIDSZ	NFS_FHMAXDATA
123 
124 typedef struct {
125 	uint16_t	len;
126 	char		parent_fid[XATTR_MAXFIDSZ];
127 	uint16_t	parent_len;
128 	uint16_t	dir_offset;
129 } xattr_fid_t;
130 
131 #define	XATTR_FIDSZ (sizeof (xattr_fid_t) - sizeof (uint16_t))
132 
133 int xattr_dir_vget(vfs_t *, vnode_t **, fid_t *);
134 #endif
135 
136 int attr_count(void);
137 const char *attr_to_name(f_attr_t);
138 const char *attr_to_option(f_attr_t);
139 f_attr_t name_to_attr(const char *name);
140 f_attr_t option_to_attr(const char *option);
141 xattr_view_t attr_to_xattr_view(f_attr_t attr);
142 data_type_t attr_to_data_type(f_attr_t attr);
143 
144 #ifdef	__cplusplus
145 }
146 #endif
147 
148 #endif	/* _SYS_ATTR_H */
149