xref: /titanic_51/usr/src/uts/common/sys/attr.h (revision 7a286c471efbab8562f7655a82931904703fffe0)
1da6c28aaSamw /*
2da6c28aaSamw  * CDDL HEADER START
3da6c28aaSamw  *
4da6c28aaSamw  * The contents of this file are subject to the terms of the
5da6c28aaSamw  * Common Development and Distribution License (the "License").
6da6c28aaSamw  * You may not use this file except in compliance with the License.
7da6c28aaSamw  *
8da6c28aaSamw  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9da6c28aaSamw  * or http://www.opensolaris.org/os/licensing.
10da6c28aaSamw  * See the License for the specific language governing permissions
11da6c28aaSamw  * and limitations under the License.
12da6c28aaSamw  *
13da6c28aaSamw  * When distributing Covered Code, include this CDDL HEADER in each
14da6c28aaSamw  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15da6c28aaSamw  * If applicable, add the following below this CDDL HEADER, with the
16da6c28aaSamw  * fields enclosed by brackets "[]" replaced with your own identifying
17da6c28aaSamw  * information: Portions Copyright [yyyy] [name of copyright owner]
18da6c28aaSamw  *
19da6c28aaSamw  * CDDL HEADER END
20da6c28aaSamw  */
21da6c28aaSamw /*
22*7a286c47SDai Ngo  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23da6c28aaSamw  * Use is subject to license terms.
24da6c28aaSamw  */
25da6c28aaSamw 
26da6c28aaSamw #ifndef _SYS_ATTR_H
27da6c28aaSamw #define	_SYS_ATTR_H
28da6c28aaSamw 
29da6c28aaSamw #ifdef	__cplusplus
30da6c28aaSamw extern "C" {
31da6c28aaSamw #endif
32da6c28aaSamw 
33da6c28aaSamw #ifdef _KERNEL
34da6c28aaSamw #include <sys/vnode.h>
35da6c28aaSamw #include <sys/vfs.h>
36da6c28aaSamw #include <nfs/nfs.h>
37da6c28aaSamw #endif
38da6c28aaSamw #include <sys/nvpair.h>
39da6c28aaSamw 
40da6c28aaSamw /* Attribute names for nvlist's */
41da6c28aaSamw #define	A_CRTIME		"crtime"
42da6c28aaSamw #define	A_HIDDEN		"hidden"
43da6c28aaSamw #define	A_SYSTEM		"system"
44da6c28aaSamw #define	A_READONLY		"readonly"
45da6c28aaSamw #define	A_ARCHIVE		"archive"
46da6c28aaSamw #define	A_NOUNLINK		"nounlink"
47da6c28aaSamw #define	A_IMMUTABLE		"immutable"
48da6c28aaSamw #define	A_APPENDONLY		"appendonly"
49da6c28aaSamw #define	A_NODUMP		"nodump"
50da6c28aaSamw #define	A_OPAQUE		"opaque"
51da6c28aaSamw #define	A_AV_QUARANTINED	"av_quarantined"
52da6c28aaSamw #define	A_AV_MODIFIED		"av_modified"
53da6c28aaSamw #define	A_FSID			"fsid"
54da6c28aaSamw #define	A_AV_SCANSTAMP		"av_scanstamp"
55da6c28aaSamw #define	A_OWNERSID		"ownersid"
56da6c28aaSamw #define	A_GROUPSID		"groupsid"
57*7a286c47SDai Ngo #define	A_REPARSE_POINT		"reparse"
58da6c28aaSamw 
59da6c28aaSamw /* Attribute option for utilities */
60da6c28aaSamw #define	O_HIDDEN	 "H"
61da6c28aaSamw #define	O_SYSTEM	 "S"
62da6c28aaSamw #define	O_READONLY	 "R"
63da6c28aaSamw #define	O_ARCHIVE	 "A"
64da6c28aaSamw #define	O_NOUNLINK	 "u"
65da6c28aaSamw #define	O_IMMUTABLE	 "i"
66da6c28aaSamw #define	O_APPENDONLY	 "a"
67da6c28aaSamw #define	O_NODUMP	 "d"
68da6c28aaSamw #define	O_AV_QUARANTINED "q"
69da6c28aaSamw #define	O_AV_MODIFIED	 "m"
70*7a286c47SDai Ngo #define	O_REPARSE_POINT	 "r"
71da6c28aaSamw #define	O_NONE		 ""
72da6c28aaSamw 
73da6c28aaSamw /* ownersid and groupsid are composed of two nvpairs */
74da6c28aaSamw #define	SID_DOMAIN		"domain"
75da6c28aaSamw #define	SID_RID			"rid"
76da6c28aaSamw 
77da6c28aaSamw typedef enum {
78da6c28aaSamw 	F_ATTR_INVAL = -1,
79da6c28aaSamw 	F_ARCHIVE,
80da6c28aaSamw 	F_HIDDEN,
81da6c28aaSamw 	F_READONLY,
82da6c28aaSamw 	F_SYSTEM,
83da6c28aaSamw 	F_APPENDONLY,
84da6c28aaSamw 	F_NODUMP,
85da6c28aaSamw 	F_IMMUTABLE,
86da6c28aaSamw 	F_AV_MODIFIED,
87da6c28aaSamw 	F_OPAQUE,
88da6c28aaSamw 	F_AV_SCANSTAMP,
89da6c28aaSamw 	F_AV_QUARANTINED,
90da6c28aaSamw 	F_NOUNLINK,
91da6c28aaSamw 	F_CRTIME,
92da6c28aaSamw 	F_OWNERSID,
93da6c28aaSamw 	F_GROUPSID,
94da6c28aaSamw 	F_FSID,
95*7a286c47SDai Ngo 	F_REPARSE,
96da6c28aaSamw 	F_ATTR_ALL
97da6c28aaSamw } f_attr_t;
98da6c28aaSamw 
99da6c28aaSamw #define	VIEW_READONLY	"SUNWattr_ro"
100da6c28aaSamw #define	VIEW_READWRITE	"SUNWattr_rw"
101da6c28aaSamw 
102da6c28aaSamw /*
103da6c28aaSamw  * These are the supported views into the virtual sysattr directory.
104da6c28aaSamw  * Additional views should be added before XATTR_VIEW_LAST.
105da6c28aaSamw  */
106da6c28aaSamw typedef enum {
107da6c28aaSamw 	XATTR_VIEW_INVALID = -1,
108da6c28aaSamw 	XATTR_VIEW_READONLY,
109da6c28aaSamw 	XATTR_VIEW_READWRITE,
110da6c28aaSamw 	XATTR_VIEW_LAST
111da6c28aaSamw } xattr_view_t;
112da6c28aaSamw 
113da6c28aaSamw typedef struct {
114da6c28aaSamw 	char		*x_name;
115da6c28aaSamw 	char		*x_option;
116da6c28aaSamw 	xattr_view_t	x_xattr_view;
117da6c28aaSamw 	data_type_t	x_data_type;
118da6c28aaSamw } xattr_entry_t;
119da6c28aaSamw 
120da6c28aaSamw #ifdef _KERNEL
121da6c28aaSamw #define	XATTR_MAXFIDSZ	NFS_FHMAXDATA
122da6c28aaSamw 
123da6c28aaSamw typedef struct {
124da6c28aaSamw 	uint16_t	len;
125da6c28aaSamw 	char		parent_fid[XATTR_MAXFIDSZ];
126da6c28aaSamw 	uint16_t	parent_len;
127da6c28aaSamw 	uint16_t	dir_offset;
128da6c28aaSamw } xattr_fid_t;
129da6c28aaSamw 
130da6c28aaSamw #define	XATTR_FIDSZ (sizeof (xattr_fid_t) - sizeof (uint16_t))
131da6c28aaSamw 
132da6c28aaSamw int xattr_dir_vget(vfs_t *, vnode_t **, fid_t *);
133b38f0970Sck153898 int xattr_sysattr_casechk(char *name);
134da6c28aaSamw #endif
135da6c28aaSamw 
136da6c28aaSamw int attr_count(void);
137da6c28aaSamw const char *attr_to_name(f_attr_t);
138da6c28aaSamw const char *attr_to_option(f_attr_t);
139da6c28aaSamw f_attr_t name_to_attr(const char *name);
140da6c28aaSamw f_attr_t option_to_attr(const char *option);
141da6c28aaSamw xattr_view_t attr_to_xattr_view(f_attr_t attr);
142da6c28aaSamw data_type_t attr_to_data_type(f_attr_t attr);
143da6c28aaSamw 
144da6c28aaSamw #ifdef	__cplusplus
145da6c28aaSamw }
146da6c28aaSamw #endif
147da6c28aaSamw 
148da6c28aaSamw #endif	/* _SYS_ATTR_H */
149