xref: /illumos-gate/usr/src/uts/common/fs/zfs/sys/zfs_acl.h (revision 4de2612967d06c4fdbf524a62556a1e8118a006f)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_SYS_FS_ZFS_ACL_H
28 #define	_SYS_FS_ZFS_ACL_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef _KERNEL
33 #include <sys/isa_defs.h>
34 #include <sys/types32.h>
35 #endif
36 #include <sys/acl.h>
37 #include <sys/dmu.h>
38 
39 #ifdef	__cplusplus
40 extern "C" {
41 #endif
42 
43 struct znode_phys;
44 
45 #define	ACCESS_UNDETERMINED	-1
46 
47 #define	ACE_SLOT_CNT	6
48 
49 typedef struct zfs_znode_acl {
50 	uint64_t	z_acl_extern_obj;	  /* ext acl pieces */
51 	uint32_t	z_acl_count;		  /* Number of ACEs */
52 	uint16_t	z_acl_version;		  /* acl version */
53 	uint16_t	z_acl_state;		  /* goop */
54 	ace_t		z_ace_data[ACE_SLOT_CNT]; /* 6 standard ACEs */
55 } zfs_znode_acl_t;
56 
57 #define	ACL_DATA_ALLOCED	0x1
58 
59 /*
60  * Max ACL size is prepended deny for all entries + the
61  * canonical six tacked on * the end.
62  */
63 #define	MAX_ACL_SIZE	(MAX_ACL_ENTRIES * 2 + 6)
64 
65 typedef struct zfs_acl {
66 	int		z_slots;	/* number of allocated slots for ACEs */
67 	int		z_acl_count;
68 	uint_t		z_state;
69 	ace_t		*z_acl;
70 } zfs_acl_t;
71 
72 #define	ZFS_ACL_SIZE(aclcnt)	(sizeof (ace_t) * (aclcnt))
73 
74 /*
75  * Property values for acl_mode and acl_inherit.
76  *
77  * acl_mode can take discard, noallow, groupmask and passthrough.
78  * whereas acl_inherit has secure instead of groupmask.
79  */
80 
81 #define	DISCARD		0
82 #define	NOALLOW		1
83 #define	GROUPMASK	2
84 #define	PASSTHROUGH	3
85 #define	SECURE		4
86 
87 struct znode;
88 
89 #ifdef _KERNEL
90 void zfs_perm_init(struct znode *, struct znode *, int, vattr_t *,
91     dmu_tx_t *, cred_t *);
92 int zfs_getacl(struct znode *, vsecattr_t *, cred_t *);
93 int zfs_mode_update(struct znode *, uint64_t, dmu_tx_t  *);
94 int zfs_setacl(struct znode *, vsecattr_t *, cred_t *);
95 void zfs_acl_rele(void *);
96 void zfs_ace_byteswap(ace_t *, int);
97 extern int zfs_zaccess(struct znode *, int, cred_t *);
98 extern int zfs_zaccess_rwx(struct znode *, mode_t, cred_t *);
99 extern int zfs_acl_access(struct znode *, int, cred_t *);
100 int zfs_acl_chmod_setattr(struct znode *, uint64_t, dmu_tx_t *);
101 int zfs_zaccess_delete(struct znode *, struct znode *, cred_t *);
102 int zfs_zaccess_rename(struct znode *, struct znode *,
103     struct znode *, struct znode *, cred_t *cr);
104 int zfs_zaccess_v4_perm(struct znode *, int, cred_t *);
105 void zfs_acl_free(zfs_acl_t *);
106 zfs_acl_t *zfs_acl_node_read(struct znode *);
107 
108 #endif
109 
110 #ifdef	__cplusplus
111 }
112 #endif
113 #endif	/* _SYS_FS_ZFS_ACL_H */
114