xref: /titanic_41/usr/src/uts/common/sys/attr.h (revision edafac1f8203a7de1490688213c118b03215c89d)
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 _SYS_ATTR_H
27 #define	_SYS_ATTR_H
28 
29 #ifdef	__cplusplus
30 extern "C" {
31 #endif
32 
33 #ifdef _KERNEL
34 #include <sys/vnode.h>
35 #include <sys/vfs.h>
36 #include <nfs/nfs.h>
37 #endif
38 #include <sys/nvpair.h>
39 
40 /* Attribute names for nvlist's */
41 #define	A_CRTIME		"crtime"
42 #define	A_HIDDEN		"hidden"
43 #define	A_SYSTEM		"system"
44 #define	A_READONLY		"readonly"
45 #define	A_ARCHIVE		"archive"
46 #define	A_NOUNLINK		"nounlink"
47 #define	A_IMMUTABLE		"immutable"
48 #define	A_APPENDONLY		"appendonly"
49 #define	A_NODUMP		"nodump"
50 #define	A_OPAQUE		"opaque"
51 #define	A_AV_QUARANTINED	"av_quarantined"
52 #define	A_AV_MODIFIED		"av_modified"
53 #define	A_FSID			"fsid"
54 #define	A_AV_SCANSTAMP		"av_scanstamp"
55 #define	A_OWNERSID		"ownersid"
56 #define	A_GROUPSID		"groupsid"
57 #define	A_REPARSE_POINT		"reparse"
58 
59 /* Attribute option for utilities */
60 #define	O_HIDDEN	 "H"
61 #define	O_SYSTEM	 "S"
62 #define	O_READONLY	 "R"
63 #define	O_ARCHIVE	 "A"
64 #define	O_NOUNLINK	 "u"
65 #define	O_IMMUTABLE	 "i"
66 #define	O_APPENDONLY	 "a"
67 #define	O_NODUMP	 "d"
68 #define	O_AV_QUARANTINED "q"
69 #define	O_AV_MODIFIED	 "m"
70 #define	O_REPARSE_POINT	 "r"
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_REPARSE,
96 	F_ATTR_ALL
97 } f_attr_t;
98 
99 #define	VIEW_READONLY	"SUNWattr_ro"
100 #define	VIEW_READWRITE	"SUNWattr_rw"
101 
102 /*
103  * These are the supported views into the virtual sysattr directory.
104  * Additional views should be added before XATTR_VIEW_LAST.
105  */
106 typedef enum {
107 	XATTR_VIEW_INVALID = -1,
108 	XATTR_VIEW_READONLY,
109 	XATTR_VIEW_READWRITE,
110 	XATTR_VIEW_LAST
111 } xattr_view_t;
112 
113 typedef struct {
114 	char		*x_name;
115 	char		*x_option;
116 	xattr_view_t	x_xattr_view;
117 	data_type_t	x_data_type;
118 } xattr_entry_t;
119 
120 #ifdef _KERNEL
121 #define	XATTR_MAXFIDSZ	NFS_FHMAXDATA
122 
123 typedef struct {
124 	uint16_t	len;
125 	char		parent_fid[XATTR_MAXFIDSZ];
126 	uint16_t	parent_len;
127 	uint16_t	dir_offset;
128 } xattr_fid_t;
129 
130 #define	XATTR_FIDSZ (sizeof (xattr_fid_t) - sizeof (uint16_t))
131 
132 int xattr_dir_vget(vfs_t *, vnode_t **, fid_t *);
133 int xattr_sysattr_casechk(char *name);
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