FreeBSD ZFS
The Zettabyte File System
|
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 2010 Sun Microsystems, Inc. All rights reserved. 00023 * Use is subject to license terms. 00024 */ 00025 00026 #ifndef _SYS_FS_ZFS_FUID_H 00027 #define _SYS_FS_ZFS_FUID_H 00028 00029 #include <sys/types.h> 00030 #ifdef _KERNEL 00031 #include <sys/kidmap.h> 00032 #include <sys/dmu.h> 00033 #include <sys/zfs_vfsops.h> 00034 #endif 00035 #include <sys/avl.h> 00036 #include <sys/list.h> 00037 00038 #ifdef __cplusplus 00039 extern "C" { 00040 #endif 00041 00042 typedef enum { 00043 ZFS_OWNER, 00044 ZFS_GROUP, 00045 ZFS_ACE_USER, 00046 ZFS_ACE_GROUP 00047 } zfs_fuid_type_t; 00048 00053 #define FUID_SIZE_ESTIMATE(z) ((z)->z_fuid_size + (SPA_MINBLOCKSIZE << 1)) 00054 00055 #define FUID_INDEX(x) ((x) >> 32) 00056 #define FUID_RID(x) ((x) & 0xffffffff) 00057 #define FUID_ENCODE(idx, rid) (((uint64_t)(idx) << 32) | (rid)) 00058 00075 typedef struct zfs_fuid { 00076 list_node_t z_next; 00077 uint64_t z_id; 00078 uint64_t z_domidx; 00079 uint64_t z_logfuid; 00080 } zfs_fuid_t; 00081 00083 typedef struct zfs_fuid_domain { 00084 list_node_t z_next; 00085 uint64_t z_domidx; 00086 const char *z_domain; 00087 } zfs_fuid_domain_t; 00088 00092 typedef struct zfs_fuid_info { 00093 list_t z_fuids; 00094 list_t z_domains; 00095 uint64_t z_fuid_owner; 00096 uint64_t z_fuid_group; 00097 char **z_domain_table; 00098 uint32_t z_fuid_cnt; 00099 uint32_t z_domain_cnt; 00100 size_t z_domain_str_sz; 00101 } zfs_fuid_info_t; 00102 00103 #ifdef _KERNEL 00104 struct znode; 00105 extern uid_t zfs_fuid_map_id(zfsvfs_t *, uint64_t, cred_t *, zfs_fuid_type_t); 00106 extern void zfs_fuid_node_add(zfs_fuid_info_t **, const char *, uint32_t, 00107 uint64_t, uint64_t, zfs_fuid_type_t); 00108 extern void zfs_fuid_destroy(zfsvfs_t *); 00109 extern uint64_t zfs_fuid_create_cred(zfsvfs_t *, zfs_fuid_type_t, 00110 cred_t *, zfs_fuid_info_t **); 00111 extern uint64_t zfs_fuid_create(zfsvfs_t *, uint64_t, cred_t *, zfs_fuid_type_t, 00112 zfs_fuid_info_t **); 00113 extern void zfs_fuid_map_ids(struct znode *zp, cred_t *cr, 00114 uid_t *uid, uid_t *gid); 00115 extern zfs_fuid_info_t *zfs_fuid_info_alloc(void); 00116 extern void zfs_fuid_info_free(zfs_fuid_info_t *); 00117 extern boolean_t zfs_groupmember(zfsvfs_t *, uint64_t, cred_t *); 00118 void zfs_fuid_sync(zfsvfs_t *, dmu_tx_t *); 00119 extern int zfs_fuid_find_by_domain(zfsvfs_t *, const char *domain, 00120 char **retdomain, boolean_t addok); 00121 extern const char *zfs_fuid_find_by_idx(zfsvfs_t *zfsvfs, uint32_t idx); 00122 extern void zfs_fuid_txhold(zfsvfs_t *zfsvfs, dmu_tx_t *tx); 00123 #endif 00124 00125 char *zfs_fuid_idx_domain(avl_tree_t *, uint32_t); 00126 void zfs_fuid_avl_tree_create(avl_tree_t *, avl_tree_t *); 00127 uint64_t zfs_fuid_table_load(objset_t *, uint64_t, avl_tree_t *, avl_tree_t *); 00128 void zfs_fuid_table_destroy(avl_tree_t *, avl_tree_t *); 00129 00130 #ifdef __cplusplus 00131 } 00132 #endif 00133 00134 #endif /* _SYS_FS_ZFS_FUID_H */