summaryrefslogtreecommitdiff
path: root/usr/src/uts/common/sys/attr.h
blob: 57c579bc5b2fa4a591a768d6849238a24138b847 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
 */

#ifndef _SYS_ATTR_H
#define	_SYS_ATTR_H

#ifdef	__cplusplus
extern "C" {
#endif

#ifdef _KERNEL
#include <sys/vnode.h>
#include <sys/vfs.h>
#include <nfs/nfs.h>
#endif
#include <sys/nvpair.h>

/* Attribute names for nvlist's */
#define	A_CRTIME		"crtime"
#define	A_HIDDEN		"hidden"
#define	A_SYSTEM		"system"
#define	A_READONLY		"readonly"
#define	A_ARCHIVE		"archive"
#define	A_NOUNLINK		"nounlink"
#define	A_IMMUTABLE		"immutable"
#define	A_APPENDONLY		"appendonly"
#define	A_NODUMP		"nodump"
#define	A_OPAQUE		"opaque"
#define	A_AV_QUARANTINED	"av_quarantined"
#define	A_AV_MODIFIED		"av_modified"
#define	A_FSID			"fsid"
#define	A_AV_SCANSTAMP		"av_scanstamp"
#define	A_OWNERSID		"ownersid"
#define	A_GROUPSID		"groupsid"
#define	A_REPARSE_POINT		"reparse"
#define	A_GEN			"generation"
#define	A_OFFLINE		"offline"
#define	A_SPARSE		"sparse"

/* Attribute option for utilities */
#define	O_HIDDEN	 "H"
#define	O_SYSTEM	 "S"
#define	O_READONLY	 "R"
#define	O_ARCHIVE	 "A"
#define	O_NOUNLINK	 "u"
#define	O_IMMUTABLE	 "i"
#define	O_APPENDONLY	 "a"
#define	O_NODUMP	 "d"
#define	O_AV_QUARANTINED "q"
#define	O_AV_MODIFIED	 "m"
#define	O_REPARSE_POINT	 "r"
#define	O_OFFLINE	 "O"
#define	O_SPARSE	 "s"
#define	O_NONE		 ""

/* ownersid and groupsid are composed of two nvpairs */
#define	SID_DOMAIN		"domain"
#define	SID_RID			"rid"

typedef enum {
	F_ATTR_INVAL = -1,
	F_ARCHIVE,
	F_HIDDEN,
	F_READONLY,
	F_SYSTEM,
	F_APPENDONLY,
	F_NODUMP,
	F_IMMUTABLE,
	F_AV_MODIFIED,
	F_OPAQUE,
	F_AV_SCANSTAMP,
	F_AV_QUARANTINED,
	F_NOUNLINK,
	F_CRTIME,
	F_OWNERSID,
	F_GROUPSID,
	F_FSID,
	F_REPARSE,
	F_GEN,
	F_OFFLINE,
	F_SPARSE,
	F_ATTR_ALL
} f_attr_t;

#define	VIEW_READONLY	"SUNWattr_ro"
#define	VIEW_READWRITE	"SUNWattr_rw"

/*
 * These are the supported views into the virtual sysattr directory.
 * Additional views should be added before XATTR_VIEW_LAST.
 */
typedef enum {
	XATTR_VIEW_INVALID = -1,
	XATTR_VIEW_READONLY,
	XATTR_VIEW_READWRITE,
	XATTR_VIEW_LAST
} xattr_view_t;

typedef struct {
	char		*x_name;
	char		*x_option;
	xattr_view_t	x_xattr_view;
	data_type_t	x_data_type;
} xattr_entry_t;

#ifdef _KERNEL
#define	XATTR_MAXFIDSZ	NFS_FHMAXDATA

typedef struct {
	uint16_t	len;
	char		parent_fid[XATTR_MAXFIDSZ];
	uint16_t	parent_len;
	uint16_t	dir_offset;
} xattr_fid_t;

#define	XATTR_FIDSZ (sizeof (xattr_fid_t) - sizeof (uint16_t))

int xattr_dir_vget(vfs_t *, vnode_t **, fid_t *);
int xattr_sysattr_casechk(char *name);
#endif

int attr_count(void);
const char *attr_to_name(f_attr_t);
const char *attr_to_option(f_attr_t);
f_attr_t name_to_attr(const char *name);
f_attr_t option_to_attr(const char *option);
xattr_view_t attr_to_xattr_view(f_attr_t attr);
data_type_t attr_to_data_type(f_attr_t attr);

#ifdef	__cplusplus
}
#endif

#endif	/* _SYS_ATTR_H */