FreeBSD ZFS
The Zettabyte File System

sys/zfs_acl.h

Go to the documentation of this file.
00001 /*
00002  * CDDL HEADER START
00003  *
00004  * The contents of this file are subject to the terms of the
00005  * Common Development and Distribution License (the "License").
00006  * You may not use this file except in compliance with the License.
00007  *
00008  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
00009  * or http://www.opensolaris.org/os/licensing.
00010  * See the License for the specific language governing permissions
00011  * and limitations under the License.
00012  *
00013  * When distributing Covered Code, include this CDDL HEADER in each
00014  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
00015  * If applicable, add the following below this CDDL HEADER, with the
00016  * fields enclosed by brackets "[]" replaced with your own identifying
00017  * information: Portions Copyright [yyyy] [name of copyright owner]
00018  *
00019  * CDDL HEADER END
00020  */
00021 /*
00022  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
00023  */
00024 
00025 #ifndef _SYS_FS_ZFS_ACL_H
00026 #define _SYS_FS_ZFS_ACL_H
00027 
00028 #ifdef _KERNEL
00029 #include <sys/cred.h>
00030 #endif
00031 #include <sys/acl.h>
00032 #include <sys/dmu.h>
00033 #include <sys/zfs_fuid.h>
00034 #include <sys/sa.h>
00035 
00036 #ifdef  __cplusplus
00037 extern "C" {
00038 #endif
00039 
00040 struct znode_phys;
00041 
00042 #define ACE_SLOT_CNT    6
00043 #define ZFS_ACL_VERSION_INITIAL 0ULL
00044 #define ZFS_ACL_VERSION_FUID    1ULL
00045 #define ZFS_ACL_VERSION         ZFS_ACL_VERSION_FUID
00046 
00067 typedef struct zfs_ace_hdr {
00068         uint16_t z_type;
00069         uint16_t z_flags;
00070         uint32_t z_access_mask;
00071 } zfs_ace_hdr_t;
00072 
00073 typedef zfs_ace_hdr_t zfs_ace_abstract_t;
00074 
00078 typedef struct zfs_ace {
00079         zfs_ace_hdr_t   z_hdr;
00080         uint64_t        z_fuid;
00081 } zfs_ace_t;
00082 
00088 typedef struct zfs_object_ace {
00089         zfs_ace_t       z_ace;
00090         uint8_t         z_object_type[16]; 
00091         uint8_t         z_inherit_type[16]; 
00092 } zfs_object_ace_t;
00093 
00094 typedef struct zfs_oldace {
00095         uint32_t        z_fuid;         
00096         uint32_t        z_access_mask;  
00097         uint16_t        z_flags;        
00098         uint16_t        z_type;         
00099 } zfs_oldace_t;
00100 
00101 typedef struct zfs_acl_phys_v0 {
00102         uint64_t        z_acl_extern_obj;       
00103         uint32_t        z_acl_count;            
00104         uint16_t        z_acl_version;          
00105         uint16_t        z_acl_pad;              
00106         zfs_oldace_t    z_ace_data[ACE_SLOT_CNT]; 
00107 } zfs_acl_phys_v0_t;
00108 
00109 #define ZFS_ACE_SPACE   (sizeof (zfs_oldace_t) * ACE_SLOT_CNT)
00110 
00115 #define ZFS_ACL_COUNT_SIZE      (sizeof (uint16_t))
00116 
00117 typedef struct zfs_acl_phys {
00118         uint64_t        z_acl_extern_obj;         
00119         uint32_t        z_acl_size;               
00120         uint16_t        z_acl_version;            
00121         uint16_t        z_acl_count;              
00122         uint8_t z_ace_data[ZFS_ACE_SPACE]; 
00123 } zfs_acl_phys_t;
00124 
00125 typedef struct acl_ops {
00126         uint32_t        (*ace_mask_get) (void *acep); 
00127         void            (*ace_mask_set) (void *acep,
00128                             uint32_t mask); 
00129         uint16_t        (*ace_flags_get) (void *acep);  
00130         void            (*ace_flags_set) (void *acep,
00131                             uint16_t flags); 
00132         uint16_t        (*ace_type_get)(void *acep); 
00133         void            (*ace_type_set)(void *acep,
00134                             uint16_t type); 
00135         uint64_t        (*ace_who_get)(void *acep); 
00136         void            (*ace_who_set)(void *acep,
00137                             uint64_t who); 
00138         size_t          (*ace_size)(void *acep); 
00140         size_t          (*ace_abstract_size)(void); 
00141         int             (*ace_mask_off)(void); 
00143         int             (*ace_data)(void *acep, void **datap);
00144 } acl_ops_t;
00145 
00146 
00147 typedef struct zfs_acl_node {
00148         list_node_t     z_next;         
00149         void            *z_acldata;     
00150         void            *z_allocdata;   
00151         size_t          z_allocsize;    
00152         size_t          z_size;         
00153         uint64_t        z_ace_count;    
00154         int             z_ace_idx;      
00155 } zfs_acl_node_t;
00156 
00163 typedef struct zfs_acl {
00164         uint64_t        z_acl_count;    
00165         size_t          z_acl_bytes;    
00166         uint_t          z_version;      
00167         void            *z_next_ace;    
00168         uint64_t        z_hints;        
00170         zfs_acl_node_t  *z_curr_node;   
00171         list_t          z_acl;          
00172         acl_ops_t       z_ops;          
00173 } zfs_acl_t;
00174 
00175 typedef struct acl_locator_cb {
00176         zfs_acl_t *cb_aclp;
00177         zfs_acl_node_t *cb_acl_node;
00178 } zfs_acl_locator_cb_t;
00179 
00180 #define ACL_DATA_ALLOCED        0x1
00181 #define ZFS_ACL_SIZE(aclcnt)    (sizeof (ace_t) * (aclcnt))
00182 
00183 struct zfs_fuid_info;
00184 
00185 typedef struct zfs_acl_ids {
00186         uint64_t                z_fuid;         
00187         uint64_t                z_fgid;         
00188         uint64_t                z_mode;         
00189         zfs_acl_t               *z_aclp;        
00191         struct zfs_fuid_info    *z_fuidp;       
00192 } zfs_acl_ids_t;
00193 
00194 /*
00195  * Property values for acl_mode and acl_inherit.
00196  *
00197  * acl_mode can take discard, noallow, groupmask and passthrough.
00198  * whereas acl_inherit has secure instead of groupmask.
00199  */
00200 
00201 #define ZFS_ACL_DISCARD         0
00202 #define ZFS_ACL_NOALLOW         1
00203 #define ZFS_ACL_GROUPMASK       2
00204 #define ZFS_ACL_PASSTHROUGH     3
00205 #define ZFS_ACL_RESTRICTED      4
00206 #define ZFS_ACL_PASSTHROUGH_X   5
00207 
00208 struct znode;
00209 struct zfsvfs;
00210 
00211 #ifdef _KERNEL
00212 int zfs_acl_ids_create(struct znode *, int, vattr_t *,
00213     cred_t *, vsecattr_t *, zfs_acl_ids_t *);
00214 void zfs_acl_ids_free(zfs_acl_ids_t *);
00215 boolean_t zfs_acl_ids_overquota(struct zfsvfs *, zfs_acl_ids_t *);
00216 int zfs_getacl(struct znode *, vsecattr_t *, boolean_t, cred_t *);
00217 int zfs_setacl(struct znode *, vsecattr_t *, boolean_t, cred_t *);
00218 void zfs_acl_rele(void *);
00219 void zfs_oldace_byteswap(ace_t *, int);
00220 void zfs_ace_byteswap(void *, size_t, boolean_t);
00221 extern boolean_t zfs_has_access(struct znode *zp, cred_t *cr);
00222 extern int zfs_zaccess(struct znode *, int, int, boolean_t, cred_t *);
00223 int zfs_fastaccesschk_execute(struct znode *, cred_t *);
00224 extern int zfs_zaccess_rwx(struct znode *, mode_t, int, cred_t *);
00225 extern int zfs_zaccess_unix(struct znode *, mode_t, cred_t *);
00226 extern int zfs_acl_access(struct znode *, int, cred_t *);
00227 int zfs_acl_chmod_setattr(struct znode *, zfs_acl_t **, uint64_t);
00228 int zfs_zaccess_delete(struct znode *, struct znode *, cred_t *);
00229 int zfs_zaccess_rename(struct znode *, struct znode *,
00230     struct znode *, struct znode *, cred_t *cr);
00231 void zfs_acl_free(zfs_acl_t *);
00232 int zfs_vsec_2_aclp(struct zfsvfs *, vtype_t, vsecattr_t *, cred_t *,
00233     struct zfs_fuid_info **, zfs_acl_t **);
00234 int zfs_aclset_common(struct znode *, zfs_acl_t *, cred_t *, dmu_tx_t *);
00235 uint64_t zfs_external_acl(struct znode *);
00236 int zfs_znode_acl_version(struct znode *);
00237 int zfs_acl_size(struct znode *, int *);
00238 zfs_acl_t *zfs_acl_alloc(int);
00239 zfs_acl_node_t *zfs_acl_node_alloc(size_t);
00240 void zfs_acl_xform(struct znode *, zfs_acl_t *, cred_t *);
00241 void zfs_acl_data_locator(void **, uint32_t *, uint32_t, boolean_t, void *);
00242 uint64_t zfs_mode_compute(uint64_t, zfs_acl_t *,
00243     uint64_t *, uint64_t, uint64_t);
00244 int zfs_acl_chown_setattr(struct znode *);
00245 
00246 #endif
00247 
00248 #ifdef  __cplusplus
00249 }
00250 #endif
00251 #endif  /* _SYS_FS_ZFS_ACL_H */
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines