]> CyberLeo.Net >> Repos - FreeBSD/releng/7.2.git/blob - sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_acl.h
Create releng/7.2 from stable/7 in preparation for 7.2-RELEASE.
[FreeBSD/releng/7.2.git] / sys / cddl / contrib / opensolaris / uts / common / fs / zfs / sys / zfs_acl.h
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 2006 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25
26 #ifndef _SYS_FS_ZFS_ACL_H
27 #define _SYS_FS_ZFS_ACL_H
28
29 #pragma ident   "%Z%%M% %I%     %E% SMI"
30
31 #ifdef _KERNEL
32 #include <sys/cred.h>
33 #endif
34 #include <sys/acl.h>
35 #include <sys/dmu.h>
36
37 #ifdef  __cplusplus
38 extern "C" {
39 #endif
40
41 struct znode_phys;
42
43 #define ACCESS_UNDETERMINED     -1
44
45 #define ACE_SLOT_CNT    6
46
47 typedef struct zfs_znode_acl {
48         uint64_t        z_acl_extern_obj;         /* ext acl pieces */
49         uint32_t        z_acl_count;              /* Number of ACEs */
50         uint16_t        z_acl_version;            /* acl version */
51         uint16_t        z_acl_pad;                /* pad */
52         ace_t           z_ace_data[ACE_SLOT_CNT]; /* 6 standard ACEs */
53 } zfs_znode_acl_t;
54
55 #define ACL_DATA_ALLOCED        0x1
56
57 /*
58  * Max ACL size is prepended deny for all entries + the
59  * canonical six tacked on * the end.
60  */
61 #define MAX_ACL_SIZE    (MAX_ACL_ENTRIES * 2 + 6)
62
63 typedef struct zfs_acl {
64         int             z_slots;        /* number of allocated slots for ACEs */
65         int             z_acl_count;
66         uint_t          z_state;
67         ace_t           *z_acl;
68 } zfs_acl_t;
69
70 #define ZFS_ACL_SIZE(aclcnt)    (sizeof (ace_t) * (aclcnt))
71
72 /*
73  * Property values for acl_mode and acl_inherit.
74  *
75  * acl_mode can take discard, noallow, groupmask and passthrough.
76  * whereas acl_inherit has secure instead of groupmask.
77  */
78
79 #define ZFS_ACL_DISCARD         0
80 #define ZFS_ACL_NOALLOW         1
81 #define ZFS_ACL_GROUPMASK       2
82 #define ZFS_ACL_PASSTHROUGH     3
83 #define ZFS_ACL_SECURE          4
84
85 struct znode;
86
87 #ifdef _KERNEL
88 void zfs_perm_init(struct znode *, struct znode *, int, vattr_t *,
89     dmu_tx_t *, cred_t *);
90 #ifdef TODO
91 int zfs_getacl(struct znode *, vsecattr_t *, cred_t *);
92 #endif
93 int zfs_mode_update(struct znode *, uint64_t, dmu_tx_t  *);
94 #ifdef TODO
95 int zfs_setacl(struct znode *, vsecattr_t *, cred_t *);
96 #endif
97 void zfs_acl_rele(void *);
98 void zfs_ace_byteswap(ace_t *, int);
99 extern int zfs_zaccess(struct znode *, int, cred_t *);
100 extern int zfs_zaccess_rwx(struct znode *, mode_t, cred_t *);
101 extern int zfs_acl_access(struct znode *, int, cred_t *);
102 int zfs_acl_chmod_setattr(struct znode *, uint64_t, dmu_tx_t *);
103 int zfs_zaccess_delete(struct znode *, struct znode *, cred_t *);
104 int zfs_zaccess_rename(struct znode *, struct znode *,
105     struct znode *, struct znode *, cred_t *cr);
106 int zfs_zaccess_v4_perm(struct znode *, int, cred_t *);
107 void zfs_acl_free(zfs_acl_t *);
108
109 #endif
110
111 #ifdef  __cplusplus
112 }
113 #endif
114
115 #endif  /* !ZFS_NO_ACL */