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 /* 23 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 /* 28 * basic API declarations for share management 29 */ 30 31 #ifndef _LIBSHARE_H 32 #define _LIBSHARE_H 33 34 #pragma ident "%Z%%M% %I% %E% SMI" 35 36 #ifdef __cplusplus 37 extern "C" { 38 #endif 39 40 /* 41 * Basic datatypes for most functions 42 */ 43 typedef void *sa_group_t; 44 typedef void *sa_share_t; 45 typedef void *sa_property_t; 46 typedef void *sa_optionset_t; 47 typedef void *sa_security_t; 48 typedef void *sa_protocol_properties_t; 49 50 typedef void *sa_handle_t; /* opaque handle to access core functions */ 51 52 /* 53 * defined error values 54 */ 55 56 #define SA_OK 0 57 #define SA_NO_SUCH_PATH 1 /* provided path doesn't exist */ 58 #define SA_NO_MEMORY 2 /* no memory for data structures */ 59 #define SA_DUPLICATE_NAME 3 /* object name is already in use */ 60 #define SA_BAD_PATH 4 /* not a full path */ 61 #define SA_NO_SUCH_GROUP 5 /* group is not defined */ 62 #define SA_CONFIG_ERR 6 /* system configuration error */ 63 #define SA_SYSTEM_ERR 7 /* system error, use errno */ 64 #define SA_SYNTAX_ERR 8 /* syntax error on command line */ 65 #define SA_NO_PERMISSION 9 /* no permission for operation */ 66 #define SA_BUSY 10 /* resource is busy */ 67 #define SA_NO_SUCH_PROP 11 /* property doesn't exist */ 68 #define SA_INVALID_NAME 12 /* name of object is invalid */ 69 #define SA_INVALID_PROTOCOL 13 /* specified protocol not valid */ 70 #define SA_NOT_ALLOWED 14 /* operation not allowed */ 71 #define SA_BAD_VALUE 15 /* bad value for property */ 72 #define SA_INVALID_SECURITY 16 /* invalid security type */ 73 #define SA_NO_SUCH_SECURITY 17 /* security set not found */ 74 #define SA_VALUE_CONFLICT 18 /* property value conflict */ 75 #define SA_NOT_IMPLEMENTED 19 /* plugin interface not implemented */ 76 #define SA_INVALID_PATH 20 /* path is sub-dir of existing share */ 77 #define SA_NOT_SUPPORTED 21 /* operation not supported for proto */ 78 #define SA_PROP_SHARE_ONLY 22 /* property valid on share only */ 79 #define SA_NOT_SHARED 23 /* path is not shared */ 80 81 /* API Initialization */ 82 #define SA_INIT_SHARE_API 0x0001 /* init share specific interface */ 83 #define SA_INIT_CONTROL_API 0x0002 /* init control specific interface */ 84 85 /* not part of API returns */ 86 #define SA_LEGACY_ERR 32 /* share/unshare error return */ 87 88 /* 89 * other defined values 90 */ 91 92 #define SA_MAX_NAME_LEN 100 /* must fit service instance name */ 93 94 /* Used in calls to sa_add_share() */ 95 #define SA_SHARE_TRANSIENT 0 /* shared but not across reboot */ 96 #define SA_SHARE_LEGACY 1 /* share is in dfstab only */ 97 #define SA_SHARE_PERMANENT 2 /* share goes to repository */ 98 99 /* sa_check_path() related */ 100 #define SA_CHECK_NORMAL 0 /* only check against active shares */ 101 #define SA_CHECK_STRICT 1 /* check against all shares */ 102 103 /* RBAC related */ 104 #define SA_RBAC_MANAGE "solaris.smf.manage.shares" 105 #define SA_RBAC_VALUE "solaris.smf.value.shares" 106 107 /* 108 * legacy files 109 */ 110 111 #define SA_LEGACY_DFSTAB "/etc/dfs/dfstab" 112 #define SA_LEGACY_SHARETAB "/etc/dfs/sharetab" 113 114 /* 115 * SMF related 116 */ 117 118 #define SA_SVC_FMRI_BASE "svc:/network/shares/group" 119 120 /* initialization */ 121 extern sa_handle_t sa_init(int); 122 extern void sa_fini(sa_handle_t); 123 extern int sa_update_config(sa_handle_t); 124 extern char *sa_errorstr(int); 125 126 /* protocol names */ 127 extern int sa_get_protocols(char ***); 128 extern int sa_valid_protocol(char *); 129 130 /* group control (create, remove, etc) */ 131 extern sa_group_t sa_create_group(sa_handle_t, char *, int *); 132 extern int sa_remove_group(sa_group_t); 133 extern sa_group_t sa_get_group(sa_handle_t, char *); 134 extern sa_group_t sa_get_next_group(sa_group_t); 135 extern char *sa_get_group_attr(sa_group_t, char *); 136 extern int sa_set_group_attr(sa_group_t, char *, char *); 137 extern sa_group_t sa_get_sub_group(sa_group_t); 138 extern int sa_valid_group_name(char *); 139 140 /* share control */ 141 extern sa_share_t sa_add_share(sa_group_t, char *, int, int *); 142 extern int sa_check_path(sa_group_t, char *, int); 143 extern int sa_move_share(sa_group_t, sa_share_t); 144 extern int sa_remove_share(sa_share_t); 145 extern sa_share_t sa_get_share(sa_group_t, char *); 146 extern sa_share_t sa_get_resource(sa_group_t, char *); 147 extern sa_share_t sa_find_share(sa_handle_t, char *); 148 extern sa_share_t sa_get_next_share(sa_share_t); 149 extern char *sa_get_share_attr(sa_share_t, char *); 150 extern char *sa_get_share_description(sa_share_t); 151 extern sa_group_t sa_get_parent_group(sa_share_t); 152 extern int sa_set_share_attr(sa_share_t, char *, char *); 153 extern int sa_set_share_description(sa_share_t, char *); 154 extern int sa_enable_share(sa_group_t, char *); 155 extern int sa_disable_share(sa_group_t, char *); 156 extern int sa_is_share(void *); 157 158 /* data structure free calls */ 159 extern void sa_free_attr_string(char *); 160 extern void sa_free_share_description(char *); 161 162 /* optionset control */ 163 extern sa_optionset_t sa_get_optionset(sa_group_t, char *); 164 extern sa_optionset_t sa_get_next_optionset(sa_group_t); 165 extern char *sa_get_optionset_attr(sa_optionset_t, char *); 166 extern void sa_set_optionset_attr(sa_optionset_t, char *, char *); 167 extern sa_optionset_t sa_create_optionset(sa_group_t, char *); 168 extern int sa_destroy_optionset(sa_optionset_t); 169 extern sa_optionset_t sa_get_derived_optionset(void *, char *, int); 170 extern void sa_free_derived_optionset(sa_optionset_t); 171 172 /* property functions */ 173 extern sa_optionset_t sa_get_property(sa_optionset_t, char *); 174 extern sa_optionset_t sa_get_next_property(sa_group_t); 175 extern char *sa_get_property_attr(sa_property_t, char *); 176 extern sa_property_t sa_create_property(char *, char *); 177 extern int sa_add_property(void *, sa_property_t); 178 extern int sa_update_property(sa_property_t, char *); 179 extern int sa_remove_property(sa_property_t); 180 extern int sa_commit_properties(sa_optionset_t, int); 181 extern int sa_valid_property(void *, char *, sa_property_t); 182 183 /* security control */ 184 extern sa_security_t sa_get_security(sa_group_t, char *, char *); 185 extern sa_security_t sa_get_next_security(sa_security_t); 186 extern char *sa_get_security_attr(sa_optionset_t, char *); 187 extern sa_security_t sa_create_security(sa_group_t, char *, char *); 188 extern int sa_destroy_security(sa_security_t); 189 extern void sa_set_security_attr(sa_security_t, char *, char *); 190 extern sa_optionset_t sa_get_all_security_types(void *, char *, int); 191 extern sa_security_t sa_get_derived_security(void *, char *, char *, int); 192 extern void sa_free_derived_security(sa_security_t); 193 194 /* protocol specific interfaces */ 195 extern int sa_parse_legacy_options(sa_group_t, char *, char *); 196 extern char *sa_proto_legacy_format(char *, sa_group_t, int); 197 extern int sa_is_security(char *, char *); 198 extern sa_protocol_properties_t sa_proto_get_properties(char *); 199 extern sa_property_t sa_get_protocol_property(sa_protocol_properties_t, char *); 200 extern sa_property_t sa_get_next_protocol_property(sa_property_t); 201 extern int sa_set_protocol_property(sa_property_t, char *); 202 extern char *sa_get_protocol_status(char *); 203 extern void sa_format_free(char *); 204 extern sa_protocol_properties_t sa_create_protocol_properties(char *); 205 extern int sa_add_protocol_property(sa_protocol_properties_t, sa_property_t); 206 extern int sa_proto_valid_prop(char *, sa_property_t, sa_optionset_t); 207 extern int sa_proto_valid_space(char *, char *); 208 extern char *sa_proto_space_alias(char *, char *); 209 210 /* handle legacy (dfstab/sharetab) files */ 211 extern int sa_delete_legacy(sa_share_t); 212 extern int sa_update_legacy(sa_share_t, char *); 213 extern int sa_update_sharetab(sa_share_t, char *); 214 extern int sa_delete_sharetab(char *, char *); 215 216 /* ZFS functions */ 217 extern int sa_zfs_is_shared(sa_handle_t, char *); 218 extern int sa_group_is_zfs(sa_group_t); 219 220 221 /* SA Handle specific functions */ 222 extern sa_handle_t sa_find_group_handle(sa_group_t); 223 224 #ifdef __cplusplus 225 } 226 #endif 227 228 #endif /* _LIBSHARE_H */ 229