1168404Spjd/*
2168404Spjd * CDDL HEADER START
3168404Spjd *
4168404Spjd * The contents of this file are subject to the terms of the
5185029Spjd * Common Development and Distribution License (the "License").
6185029Spjd * You may not use this file except in compliance with the License.
7168404Spjd *
8168404Spjd * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9168404Spjd * or http://www.opensolaris.org/os/licensing.
10168404Spjd * See the License for the specific language governing permissions
11168404Spjd * and limitations under the License.
12168404Spjd *
13168404Spjd * When distributing Covered Code, include this CDDL HEADER in each
14168404Spjd * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15168404Spjd * If applicable, add the following below this CDDL HEADER, with the
16168404Spjd * fields enclosed by brackets "[]" replaced with your own identifying
17168404Spjd * information: Portions Copyright [yyyy] [name of copyright owner]
18168404Spjd *
19168404Spjd * CDDL HEADER END
20168404Spjd */
21168404Spjd/*
22219089Spjd * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
23224174Smm * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
24168404Spjd */
25168404Spjd
26185029Spjd#ifndef	_ACL_COMMON_H
27185029Spjd#define	_ACL_COMMON_H
28168404Spjd
29168404Spjd#include <sys/types.h>
30168404Spjd#include <sys/acl.h>
31168404Spjd#include <sys/stat.h>
32168404Spjd
33185029Spjd#ifdef	__cplusplus
34168404Spjdextern "C" {
35168404Spjd#endif
36168404Spjd
37224174Smmtypedef struct trivial_acl {
38224174Smm	uint32_t	allow0;		/* allow mask for bits only in owner */
39224174Smm	uint32_t	deny1;		/* deny mask for bits not in owner */
40224174Smm	uint32_t	deny2;		/* deny mask for bits not in group */
41224174Smm	uint32_t	owner;		/* allow mask matching mode */
42224174Smm	uint32_t	group;		/* allow mask matching mode */
43224174Smm	uint32_t	everyone;	/* allow mask matching mode */
44224174Smm} trivial_acl_t;
45168404Spjd
46168404Spjdextern int acltrivial(const char *);
47168404Spjdextern void adjust_ace_pair(ace_t *pair, mode_t mode);
48185029Spjdextern void adjust_ace_pair_common(void *, size_t, size_t, mode_t);
49168404Spjdextern int ace_trivial(ace_t *acep, int aclcnt);
50185029Spjdextern int ace_trivial_common(void *, int,
51185029Spjd    uint64_t (*walk)(void *, uint64_t, int aclcnt, uint16_t *, uint16_t *,
52185029Spjd    uint32_t *mask));
53192800Strasz#if !defined(_KERNEL)
54185029Spjdextern acl_t *acl_alloc(acl_type_t);
55185029Spjdextern void acl_free(acl_t *aclp);
56224174Smmextern int acl_translate(acl_t *aclp, int target_flavor, boolean_t isdir,
57224174Smm    uid_t owner, gid_t group);
58219089Spjd#endif	/* !_KERNEL */
59168404Spjdvoid ksort(caddr_t v, int n, int s, int (*f)());
60168404Spjdint cmp2acls(void *a, void *b);
61224174Smmint acl_trivial_create(mode_t mode, boolean_t isdir, ace_t **acl, int *count);
62224174Smmvoid acl_trivial_access_masks(mode_t mode, boolean_t isdir,
63224174Smm    trivial_acl_t *masks);
64168404Spjd
65185029Spjd#ifdef	__cplusplus
66168404Spjd}
67168404Spjd#endif
68168404Spjd
69185029Spjd#endif /* _ACL_COMMON_H */
70