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 2006 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 /* 28 * basic declarations for implementation of the share management 29 * libraries. 30 */ 31 32 #ifndef _LIBSHARE_IMPL_H 33 #define _LIBSHARE_IMPL_H 34 35 #pragma ident "%Z%%M% %I% %E% SMI" 36 37 #include <libshare.h> 38 #include <libscf.h> 39 #include <scfutil.h> 40 41 #ifdef __cplusplus 42 extern "C" { 43 #endif 44 45 /* directory to find plugin modules in */ 46 #define SA_LIB_DIR "/usr/lib/fs" 47 48 /* default group name for dfstab file */ 49 #define SA_DEFAULT_FILE_GRP "sys" 50 51 typedef void *sa_phandle_t; 52 53 #define SA_PLUGIN_VERSION 1 54 struct sa_plugin_ops { 55 int sa_version; 56 char *sa_protocol; /* protocol name */ 57 int (*sa_init)(); 58 void (*sa_fini)(); 59 int (*sa_share)(sa_share_t); /* start sharing */ 60 int (*sa_unshare)(char *); /* stop sharing */ 61 int (*sa_valid_prop)(sa_property_t, sa_optionset_t); 62 int (*sa_valid_space)(char *); /* is name valid optionspace? */ 63 int (*sa_security_prop)(char *); /* property is security */ 64 int (*sa_legacy_opts)(sa_group_t, char *); /* parse legacy opts */ 65 char *(*sa_legacy_format)(sa_group_t, int); 66 int (*sa_set_proto_prop)(sa_property_t); 67 sa_protocol_properties_t (*sa_get_proto_set)(); 68 char *(*sa_get_proto_status)(); 69 char *(*sa_space_alias)(char *); 70 int (*sa_update_legacy)(sa_share_t); 71 int (*sa_delete_legacy)(sa_share_t); 72 int (*sa_run_command)(int, int, char **); /* proto specific */ 73 int (*sa_command_help)(); 74 }; 75 76 struct sa_proto_handle { 77 int sa_num_proto; 78 char **sa_proto; 79 struct sa_plugin_ops **sa_ops; 80 }; 81 82 typedef struct propertylist { 83 struct propertylist *pl_next; 84 int pl_type; 85 union propval { 86 sa_optionset_t pl_optionset; 87 sa_security_t pl_security; 88 void *pl_void; 89 } pl_value; 90 } property_list_t; 91 92 extern int sa_proto_share(char *, sa_share_t); 93 extern int sa_proto_unshare(char *, char *); 94 extern int sa_proto_valid_prop(char *, sa_property_t, sa_optionset_t); 95 extern int sa_proto_security_prop(char *, char *); 96 extern int sa_proto_legacy_opts(char *, sa_group_t, char *); 97 98 /* internal utility functions */ 99 extern sa_optionset_t sa_get_derived_optionset(sa_group_t, char *, int); 100 extern void sa_free_derived_optionset(sa_optionset_t); 101 extern sa_optionset_t sa_get_all_security_types(void *, char *, int); 102 extern sa_security_t sa_get_derived_security(void *, char *, char *, int); 103 extern void sa_free_derived_security(sa_security_t); 104 extern sa_protocol_properties_t sa_create_protocol_properties(char *); 105 extern int sa_start_transaction(scfutilhandle_t *, char *); 106 extern int sa_end_transaction(scfutilhandle_t *); 107 extern void sa_abort_transaction(scfutilhandle_t *); 108 extern int sa_commit_share(scfutilhandle_t *, sa_group_t, sa_share_t); 109 extern int sa_set_property(scfutilhandle_t *, char *, char *); 110 extern void sa_free_fstype(char *fstyp); 111 extern int sa_delete_share(scfutilhandle_t *, sa_group_t, sa_share_t); 112 extern int sa_delete_instance(scfutilhandle_t *, char *); 113 extern int sa_create_pgroup(scfutilhandle_t *, char *); 114 extern int sa_delete_pgroup(scfutilhandle_t *, char *); 115 116 /* ZFS functions */ 117 extern int sa_get_zfs_shares(char *); 118 extern int sa_zfs_update(sa_share_t); 119 120 /* plugin specific functions */ 121 extern int proto_plugin_init(); 122 extern int sa_proto_set_property(char *, sa_property_t); 123 extern int sa_proto_delete_legacy(char *, sa_share_t); 124 extern int sa_proto_update_legacy(char *, sa_share_t); 125 126 #define PL_TYPE_PROPERTY 0 127 #define PL_TYPE_SECURITY 1 128 129 /* values only used by the internal dfstab/sharetab parser */ 130 #define SA_SHARE_PARSER 0x1000 131 132 /* plugin handler only */ 133 struct sa_proto_plugin { 134 struct sa_proto_plugin *plugin_next; 135 struct sa_plugin_ops *plugin_ops; 136 void *plugin_handle; 137 }; 138 139 #ifdef __cplusplus 140 } 141 #endif 142 143 #endif /* _LIBSHARE_IMPL_H */ 144