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