xref: /onnv-gate/usr/src/uts/common/sys/attr.h (revision 13082:81ec56bf6147)
15331Samw /*
25331Samw  * CDDL HEADER START
35331Samw  *
45331Samw  * The contents of this file are subject to the terms of the
55331Samw  * Common Development and Distribution License (the "License").
65331Samw  * You may not use this file except in compliance with the License.
75331Samw  *
85331Samw  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
95331Samw  * or http://www.opensolaris.org/os/licensing.
105331Samw  * See the License for the specific language governing permissions
115331Samw  * and limitations under the License.
125331Samw  *
135331Samw  * When distributing Covered Code, include this CDDL HEADER in each
145331Samw  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
155331Samw  * If applicable, add the following below this CDDL HEADER, with the
165331Samw  * fields enclosed by brackets "[]" replaced with your own identifying
175331Samw  * information: Portions Copyright [yyyy] [name of copyright owner]
185331Samw  *
195331Samw  * CDDL HEADER END
205331Samw  */
215331Samw /*
2213043STim.Haley@Sun.COM  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
235331Samw  */
245331Samw 
255331Samw #ifndef _SYS_ATTR_H
265331Samw #define	_SYS_ATTR_H
275331Samw 
285331Samw #ifdef	__cplusplus
295331Samw extern "C" {
305331Samw #endif
315331Samw 
325331Samw #ifdef _KERNEL
335331Samw #include <sys/vnode.h>
345331Samw #include <sys/vfs.h>
355331Samw #include <nfs/nfs.h>
365331Samw #endif
375331Samw #include <sys/nvpair.h>
385331Samw 
395331Samw /* Attribute names for nvlist's */
405331Samw #define	A_CRTIME		"crtime"
415331Samw #define	A_HIDDEN		"hidden"
425331Samw #define	A_SYSTEM		"system"
435331Samw #define	A_READONLY		"readonly"
445331Samw #define	A_ARCHIVE		"archive"
455331Samw #define	A_NOUNLINK		"nounlink"
465331Samw #define	A_IMMUTABLE		"immutable"
475331Samw #define	A_APPENDONLY		"appendonly"
485331Samw #define	A_NODUMP		"nodump"
495331Samw #define	A_OPAQUE		"opaque"
505331Samw #define	A_AV_QUARANTINED	"av_quarantined"
515331Samw #define	A_AV_MODIFIED		"av_modified"
525331Samw #define	A_FSID			"fsid"
535331Samw #define	A_AV_SCANSTAMP		"av_scanstamp"
545331Samw #define	A_OWNERSID		"ownersid"
555331Samw #define	A_GROUPSID		"groupsid"
5610793Sdai.ngo@sun.com #define	A_REPARSE_POINT		"reparse"
5713043STim.Haley@Sun.COM #define	A_GEN			"generation"
58*13082SJoyce.McIntosh@Sun.COM #define	A_OFFLINE		"offline"
59*13082SJoyce.McIntosh@Sun.COM #define	A_SPARSE		"sparse"
605331Samw 
615331Samw /* Attribute option for utilities */
625331Samw #define	O_HIDDEN	 "H"
635331Samw #define	O_SYSTEM	 "S"
645331Samw #define	O_READONLY	 "R"
655331Samw #define	O_ARCHIVE	 "A"
665331Samw #define	O_NOUNLINK	 "u"
675331Samw #define	O_IMMUTABLE	 "i"
685331Samw #define	O_APPENDONLY	 "a"
695331Samw #define	O_NODUMP	 "d"
705331Samw #define	O_AV_QUARANTINED "q"
715331Samw #define	O_AV_MODIFIED	 "m"
7210793Sdai.ngo@sun.com #define	O_REPARSE_POINT	 "r"
73*13082SJoyce.McIntosh@Sun.COM #define	O_OFFLINE	 "O"
74*13082SJoyce.McIntosh@Sun.COM #define	O_SPARSE	 "s"
755331Samw #define	O_NONE		 ""
765331Samw 
775331Samw /* ownersid and groupsid are composed of two nvpairs */
785331Samw #define	SID_DOMAIN		"domain"
795331Samw #define	SID_RID			"rid"
805331Samw 
815331Samw typedef enum {
825331Samw 	F_ATTR_INVAL = -1,
835331Samw 	F_ARCHIVE,
845331Samw 	F_HIDDEN,
855331Samw 	F_READONLY,
865331Samw 	F_SYSTEM,
875331Samw 	F_APPENDONLY,
885331Samw 	F_NODUMP,
895331Samw 	F_IMMUTABLE,
905331Samw 	F_AV_MODIFIED,
915331Samw 	F_OPAQUE,
925331Samw 	F_AV_SCANSTAMP,
935331Samw 	F_AV_QUARANTINED,
945331Samw 	F_NOUNLINK,
955331Samw 	F_CRTIME,
965331Samw 	F_OWNERSID,
975331Samw 	F_GROUPSID,
985331Samw 	F_FSID,
9910793Sdai.ngo@sun.com 	F_REPARSE,
10013043STim.Haley@Sun.COM 	F_GEN,
101*13082SJoyce.McIntosh@Sun.COM 	F_OFFLINE,
102*13082SJoyce.McIntosh@Sun.COM 	F_SPARSE,
1035331Samw 	F_ATTR_ALL
1045331Samw } f_attr_t;
1055331Samw 
1065331Samw #define	VIEW_READONLY	"SUNWattr_ro"
1075331Samw #define	VIEW_READWRITE	"SUNWattr_rw"
1085331Samw 
1095331Samw /*
1105331Samw  * These are the supported views into the virtual sysattr directory.
1115331Samw  * Additional views should be added before XATTR_VIEW_LAST.
1125331Samw  */
1135331Samw typedef enum {
1145331Samw 	XATTR_VIEW_INVALID = -1,
1155331Samw 	XATTR_VIEW_READONLY,
1165331Samw 	XATTR_VIEW_READWRITE,
1175331Samw 	XATTR_VIEW_LAST
1185331Samw } xattr_view_t;
1195331Samw 
1205331Samw typedef struct {
1215331Samw 	char		*x_name;
1225331Samw 	char		*x_option;
1235331Samw 	xattr_view_t	x_xattr_view;
1245331Samw 	data_type_t	x_data_type;
1255331Samw } xattr_entry_t;
1265331Samw 
1275331Samw #ifdef _KERNEL
1285331Samw #define	XATTR_MAXFIDSZ	NFS_FHMAXDATA
1295331Samw 
1305331Samw typedef struct {
1315331Samw 	uint16_t	len;
1325331Samw 	char		parent_fid[XATTR_MAXFIDSZ];
1335331Samw 	uint16_t	parent_len;
1345331Samw 	uint16_t	dir_offset;
1355331Samw } xattr_fid_t;
1365331Samw 
1375331Samw #define	XATTR_FIDSZ (sizeof (xattr_fid_t) - sizeof (uint16_t))
1385331Samw 
1395331Samw int xattr_dir_vget(vfs_t *, vnode_t **, fid_t *);
1405663Sck153898 int xattr_sysattr_casechk(char *name);
1415331Samw #endif
1425331Samw 
1435331Samw int attr_count(void);
1445331Samw const char *attr_to_name(f_attr_t);
1455331Samw const char *attr_to_option(f_attr_t);
1465331Samw f_attr_t name_to_attr(const char *name);
1475331Samw f_attr_t option_to_attr(const char *option);
1485331Samw xattr_view_t attr_to_xattr_view(f_attr_t attr);
1495331Samw data_type_t attr_to_data_type(f_attr_t attr);
1505331Samw 
1515331Samw #ifdef	__cplusplus
1525331Samw }
1535331Samw #endif
1545331Samw 
1555331Samw #endif	/* _SYS_ATTR_H */
156