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/isa_defs.h> 33 #include <sys/types32.h> 34 #endif 35 #include <sys/acl.h> 36 #include <sys/dmu.h> 37 38 #ifdef __cplusplus 39 extern "C" { 40 #endif 41 42 struct znode_phys; 43 44 #define ACCESS_UNDETERMINED -1 45 46 #define ACE_SLOT_CNT 6 47 48 typedef struct zfs_znode_acl { 49 uint64_t z_acl_extern_obj; /* ext acl pieces */ 50 uint32_t z_acl_count; /* Number of ACEs */ 51 uint16_t z_acl_version; /* acl version */ 52 uint16_t z_acl_pad; /* pad */ 53 ace_t z_ace_data[ACE_SLOT_CNT]; /* 6 standard ACEs */ 54 } zfs_znode_acl_t; 55 56 #define ACL_DATA_ALLOCED 0x1 57 58 /* 59 * Max ACL size is prepended deny for all entries + the 60 * canonical six tacked on * the end. 61 */ 62 #define MAX_ACL_SIZE (MAX_ACL_ENTRIES * 2 + 6) 63 64 typedef struct zfs_acl { 65 int z_slots; /* number of allocated slots for ACEs */ 66 int z_acl_count; 67 uint_t z_state; 68 ace_t *z_acl; 69 } zfs_acl_t; 70 71 #define ZFS_ACL_SIZE(aclcnt) (sizeof (ace_t) * (aclcnt)) 72 73 /* 74 * Property values for acl_mode and acl_inherit. 75 * 76 * acl_mode can take discard, noallow, groupmask and passthrough. 77 * whereas acl_inherit has secure instead of groupmask. 78 */ 79 80 #define DISCARD 0 81 #define NOALLOW 1 82 #define GROUPMASK 2 83 #define PASSTHROUGH 3 84 #define SECURE 4 85 86 struct znode; 87 88 #ifdef _KERNEL 89 void zfs_perm_init(struct znode *, struct znode *, int, vattr_t *, 90 dmu_tx_t *, cred_t *); 91 int zfs_getacl(struct znode *, vsecattr_t *, cred_t *); 92 int zfs_mode_update(struct znode *, uint64_t, dmu_tx_t *); 93 int zfs_setacl(struct znode *, vsecattr_t *, cred_t *); 94 void zfs_acl_rele(void *); 95 void zfs_ace_byteswap(ace_t *, int); 96 extern int zfs_zaccess(struct znode *, int, cred_t *); 97 extern int zfs_zaccess_rwx(struct znode *, mode_t, cred_t *); 98 extern int zfs_acl_access(struct znode *, int, cred_t *); 99 int zfs_acl_chmod_setattr(struct znode *, uint64_t, dmu_tx_t *); 100 int zfs_zaccess_delete(struct znode *, struct znode *, cred_t *); 101 int zfs_zaccess_rename(struct znode *, struct znode *, 102 struct znode *, struct znode *, cred_t *cr); 103 int zfs_zaccess_v4_perm(struct znode *, int, cred_t *); 104 void zfs_acl_free(zfs_acl_t *); 105 106 #endif 107 108 #ifdef __cplusplus 109 } 110 #endif 111 #endif /* _SYS_FS_ZFS_ACL_H */ 112