xref: /titanic_44/usr/src/uts/common/sys/attr.h (revision 598f4ceed9327d2d6c2325dd67cae3aa06f7fea6)
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 (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
23  */
24 
25 #ifndef _SYS_ATTR_H
26 #define	_SYS_ATTR_H
27 
28 #ifdef	__cplusplus
29 extern "C" {
30 #endif
31 
32 #ifdef _KERNEL
33 #include <sys/vnode.h>
34 #include <sys/vfs.h>
35 #include <nfs/nfs.h>
36 #endif
37 #include <sys/nvpair.h>
38 
39 /* Attribute names for nvlist's */
40 #define	A_CRTIME		"crtime"
41 #define	A_HIDDEN		"hidden"
42 #define	A_SYSTEM		"system"
43 #define	A_READONLY		"readonly"
44 #define	A_ARCHIVE		"archive"
45 #define	A_NOUNLINK		"nounlink"
46 #define	A_IMMUTABLE		"immutable"
47 #define	A_APPENDONLY		"appendonly"
48 #define	A_NODUMP		"nodump"
49 #define	A_OPAQUE		"opaque"
50 #define	A_AV_QUARANTINED	"av_quarantined"
51 #define	A_AV_MODIFIED		"av_modified"
52 #define	A_FSID			"fsid"
53 #define	A_AV_SCANSTAMP		"av_scanstamp"
54 #define	A_OWNERSID		"ownersid"
55 #define	A_GROUPSID		"groupsid"
56 #define	A_REPARSE_POINT		"reparse"
57 #define	A_GEN			"generation"
58 #define	A_OFFLINE		"offline"
59 #define	A_SPARSE		"sparse"
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_REPARSE_POINT	 "r"
73 #define	O_OFFLINE	 "O"
74 #define	O_SPARSE	 "s"
75 #define	O_NONE		 ""
76 
77 /* ownersid and groupsid are composed of two nvpairs */
78 #define	SID_DOMAIN		"domain"
79 #define	SID_RID			"rid"
80 
81 typedef enum {
82 	F_ATTR_INVAL = -1,
83 	F_ARCHIVE,
84 	F_HIDDEN,
85 	F_READONLY,
86 	F_SYSTEM,
87 	F_APPENDONLY,
88 	F_NODUMP,
89 	F_IMMUTABLE,
90 	F_AV_MODIFIED,
91 	F_OPAQUE,
92 	F_AV_SCANSTAMP,
93 	F_AV_QUARANTINED,
94 	F_NOUNLINK,
95 	F_CRTIME,
96 	F_OWNERSID,
97 	F_GROUPSID,
98 	F_FSID,
99 	F_REPARSE,
100 	F_GEN,
101 	F_OFFLINE,
102 	F_SPARSE,
103 	F_ATTR_ALL
104 } f_attr_t;
105 
106 #define	VIEW_READONLY	"SUNWattr_ro"
107 #define	VIEW_READWRITE	"SUNWattr_rw"
108 
109 /*
110  * These are the supported views into the virtual sysattr directory.
111  * Additional views should be added before XATTR_VIEW_LAST.
112  */
113 typedef enum {
114 	XATTR_VIEW_INVALID = -1,
115 	XATTR_VIEW_READONLY,
116 	XATTR_VIEW_READWRITE,
117 	XATTR_VIEW_LAST
118 } xattr_view_t;
119 
120 typedef struct {
121 	char		*x_name;
122 	char		*x_option;
123 	xattr_view_t	x_xattr_view;
124 	data_type_t	x_data_type;
125 } xattr_entry_t;
126 
127 #ifdef _KERNEL
128 #define	XATTR_MAXFIDSZ	NFS_FHMAXDATA
129 
130 typedef struct {
131 	uint16_t	len;
132 	char		parent_fid[XATTR_MAXFIDSZ];
133 	uint16_t	parent_len;
134 	uint16_t	dir_offset;
135 } xattr_fid_t;
136 
137 #define	XATTR_FIDSZ (sizeof (xattr_fid_t) - sizeof (uint16_t))
138 
139 int xattr_dir_vget(vfs_t *, vnode_t **, fid_t *);
140 int xattr_sysattr_casechk(char *name);
141 #endif
142 
143 int attr_count(void);
144 const char *attr_to_name(f_attr_t);
145 const char *attr_to_option(f_attr_t);
146 f_attr_t name_to_attr(const char *name);
147 f_attr_t option_to_attr(const char *option);
148 xattr_view_t attr_to_xattr_view(f_attr_t attr);
149 data_type_t attr_to_data_type(f_attr_t attr);
150 
151 #ifdef	__cplusplus
152 }
153 #endif
154 
155 #endif	/* _SYS_ATTR_H */
156