xref: /freebsd/sys/contrib/openzfs/include/os/freebsd/spl/acl/acl_common.h (revision 61145dc2b94f12f6a47344fb9aac702321880e43)
1 // SPDX-License-Identifier: CDDL-1.0
2 /*
3  * CDDL HEADER START
4  *
5  * The contents of this file are subject to the terms of the
6  * Common Development and Distribution License (the "License").
7  * You may not use this file except in compliance with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or https://opensource.org/licenses/CDDL-1.0.
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 (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
24  * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
25  */
26 
27 #ifndef	_ACL_COMMON_H
28 #define	_ACL_COMMON_H
29 
30 #include <sys/types.h>
31 #include <sys/acl.h>
32 #include <sys/stat.h>
33 
34 #ifdef	__cplusplus
35 extern "C" {
36 #endif
37 
38 typedef struct trivial_acl {
39 	uint32_t	allow0;		/* allow mask for bits only in owner */
40 	uint32_t	deny1;		/* deny mask for bits not in owner */
41 	uint32_t	deny2;		/* deny mask for bits not in group */
42 	uint32_t	owner;		/* allow mask matching mode */
43 	uint32_t	group;		/* allow mask matching mode */
44 	uint32_t	everyone;	/* allow mask matching mode */
45 } trivial_acl_t;
46 
47 extern int acltrivial(const char *);
48 extern void adjust_ace_pair(ace_t *pair, mode_t mode);
49 extern void adjust_ace_pair_common(void *, size_t, size_t, mode_t);
50 extern int ace_trivial_common(void *, int,
51     uintptr_t (*walk)(void *, uintptr_t, int aclcnt, uint16_t *, uint16_t *,
52     uint32_t *mask));
53 #if !defined(_KERNEL)
54 extern acl_t *acl_alloc(acl_type_t);
55 extern void acl_free(acl_t *aclp);
56 extern int acl_translate(acl_t *aclp, int target_flavor, boolean_t isdir,
57     uid_t owner, gid_t group);
58 #endif	/* !_KERNEL */
59 int cmp2acls(void *a, void *b);
60 int acl_trivial_create(mode_t mode, boolean_t isdir, ace_t **acl, int *count);
61 void acl_trivial_access_masks(mode_t mode, boolean_t isdir,
62     trivial_acl_t *masks);
63 
64 #ifdef	__cplusplus
65 }
66 #endif
67 
68 #endif /* _ACL_COMMON_H */
69