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