13034Sdougm /* 23034Sdougm * CDDL HEADER START 33034Sdougm * 43034Sdougm * The contents of this file are subject to the terms of the 53034Sdougm * Common Development and Distribution License (the "License"). 63034Sdougm * You may not use this file except in compliance with the License. 73034Sdougm * 83034Sdougm * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 93034Sdougm * or http://www.opensolaris.org/os/licensing. 103034Sdougm * See the License for the specific language governing permissions 113034Sdougm * and limitations under the License. 123034Sdougm * 133034Sdougm * When distributing Covered Code, include this CDDL HEADER in each 143034Sdougm * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 153034Sdougm * If applicable, add the following below this CDDL HEADER, with the 163034Sdougm * fields enclosed by brackets "[]" replaced with your own identifying 173034Sdougm * information: Portions Copyright [yyyy] [name of copyright owner] 183034Sdougm * 193034Sdougm * CDDL HEADER END 203034Sdougm */ 213034Sdougm 223034Sdougm /* 23*8845Samw@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 243034Sdougm * Use is subject to license terms. 253034Sdougm */ 263034Sdougm 273034Sdougm /* 283034Sdougm * basic declarations for implementation of the share management 293034Sdougm * libraries. 303034Sdougm */ 313034Sdougm 323034Sdougm #ifndef _LIBSHARE_IMPL_H 333034Sdougm #define _LIBSHARE_IMPL_H 343034Sdougm 353034Sdougm #include <libshare.h> 363034Sdougm #include <libscf.h> 373034Sdougm #include <scfutil.h> 383910Sdougm #include <libzfs.h> 394543Smarks #include <sharefs/share.h> 404544Smarks #include <sharefs/sharetab.h> 413034Sdougm 423034Sdougm #ifdef __cplusplus 433034Sdougm extern "C" { 443034Sdougm #endif 453034Sdougm 463034Sdougm /* directory to find plugin modules in */ 473034Sdougm #define SA_LIB_DIR "/usr/lib/fs" 483034Sdougm 493034Sdougm /* default group name for dfstab file */ 503034Sdougm #define SA_DEFAULT_FILE_GRP "sys" 513034Sdougm 523034Sdougm typedef void *sa_phandle_t; 533034Sdougm 543034Sdougm #define SA_PLUGIN_VERSION 1 553034Sdougm struct sa_plugin_ops { 566007Sthurlow int sa_version; /* version number */ 573034Sdougm char *sa_protocol; /* protocol name */ 583034Sdougm int (*sa_init)(); 593034Sdougm void (*sa_fini)(); 603034Sdougm int (*sa_share)(sa_share_t); /* start sharing */ 61*8845Samw@Sun.COM int (*sa_unshare)(sa_share_t, char *); /* stop sharing */ 626214Sdougm int (*sa_valid_prop)(sa_handle_t, sa_property_t, 636214Sdougm sa_optionset_t); /* validate */ 643034Sdougm int (*sa_valid_space)(char *); /* is name valid optionspace? */ 653034Sdougm int (*sa_security_prop)(char *); /* property is security */ 663034Sdougm int (*sa_legacy_opts)(sa_group_t, char *); /* parse legacy opts */ 673034Sdougm char *(*sa_legacy_format)(sa_group_t, int); 686007Sthurlow int (*sa_set_proto_prop)(sa_property_t); /* set a property */ 696007Sthurlow sa_protocol_properties_t (*sa_get_proto_set)(); /* get properties */ 703034Sdougm char *(*sa_get_proto_status)(); 713034Sdougm char *(*sa_space_alias)(char *); 723034Sdougm int (*sa_update_legacy)(sa_share_t); 733034Sdougm int (*sa_delete_legacy)(sa_share_t); 745331Samw int (*sa_change_notify)(sa_share_t); 755331Samw int (*sa_enable_resource)(sa_resource_t); 765331Samw int (*sa_disable_resource)(sa_resource_t); 775331Samw uint64_t (*sa_features)(void); 785331Samw int (*sa_get_transient_shares)(sa_handle_t); /* add transients */ 795331Samw int (*sa_notify_resource)(sa_resource_t); 805331Samw int (*sa_rename_resource)(sa_handle_t, sa_resource_t, char *); 813034Sdougm int (*sa_run_command)(int, int, char **); /* proto specific */ 823034Sdougm int (*sa_command_help)(); 836007Sthurlow int (*sa_delete_proto_section)(char *); 843034Sdougm }; 853034Sdougm 863034Sdougm struct sa_proto_handle { 873034Sdougm int sa_num_proto; 883034Sdougm char **sa_proto; 893034Sdougm struct sa_plugin_ops **sa_ops; 903034Sdougm }; 913034Sdougm 923034Sdougm typedef struct propertylist { 933034Sdougm struct propertylist *pl_next; 943034Sdougm int pl_type; 953034Sdougm union propval { 963034Sdougm sa_optionset_t pl_optionset; 973034Sdougm sa_security_t pl_security; 983034Sdougm void *pl_void; 993034Sdougm } pl_value; 1003034Sdougm } property_list_t; 1013034Sdougm 1025951Sdougm /* internal version of sa_handle_t */ 1035951Sdougm typedef struct sa_handle_impl { 1045951Sdougm uint64_t flags; 1055951Sdougm scfutilhandle_t *scfhandle; 1065951Sdougm libzfs_handle_t *zfs_libhandle; 1075951Sdougm zfs_handle_t **zfs_list; 1085951Sdougm size_t zfs_list_count; 1095951Sdougm xmlNodePtr tree; 1105951Sdougm xmlDocPtr doc; 1115951Sdougm uint64_t tssharetab; 1125951Sdougm uint64_t tstrans; 1135951Sdougm } *sa_handle_impl_t; 1145951Sdougm 1153034Sdougm extern int sa_proto_share(char *, sa_share_t); 1164543Smarks extern int sa_proto_unshare(sa_share_t, char *, char *); 1176214Sdougm extern int sa_proto_valid_prop(sa_handle_t, char *, sa_property_t, 1186214Sdougm sa_optionset_t); 1193034Sdougm extern int sa_proto_security_prop(char *, char *); 1203034Sdougm extern int sa_proto_legacy_opts(char *, sa_group_t, char *); 1215331Samw extern int sa_proto_share_resource(char *, sa_resource_t); 1225331Samw extern int sa_proto_unshare_resource(char *, sa_resource_t); 1233034Sdougm 1243034Sdougm /* internal utility functions */ 1253034Sdougm extern sa_optionset_t sa_get_derived_optionset(sa_group_t, char *, int); 1263034Sdougm extern void sa_free_derived_optionset(sa_optionset_t); 1273034Sdougm extern sa_optionset_t sa_get_all_security_types(void *, char *, int); 1283034Sdougm extern sa_security_t sa_get_derived_security(void *, char *, char *, int); 1293034Sdougm extern void sa_free_derived_security(sa_security_t); 1303034Sdougm extern sa_protocol_properties_t sa_create_protocol_properties(char *); 1313034Sdougm extern int sa_start_transaction(scfutilhandle_t *, char *); 1325951Sdougm extern int sa_end_transaction(scfutilhandle_t *, sa_handle_impl_t); 1333034Sdougm extern void sa_abort_transaction(scfutilhandle_t *); 1343034Sdougm extern int sa_commit_share(scfutilhandle_t *, sa_group_t, sa_share_t); 1353034Sdougm extern int sa_set_property(scfutilhandle_t *, char *, char *); 1363034Sdougm extern void sa_free_fstype(char *fstyp); 1373034Sdougm extern int sa_delete_share(scfutilhandle_t *, sa_group_t, sa_share_t); 1383034Sdougm extern int sa_delete_instance(scfutilhandle_t *, char *); 1393034Sdougm extern int sa_create_pgroup(scfutilhandle_t *, char *); 1403034Sdougm extern int sa_delete_pgroup(scfutilhandle_t *, char *); 1414543Smarks extern void sa_fillshare(sa_share_t share, char *proto, struct share *sh); 1424543Smarks extern void sa_emptyshare(struct share *sh); 1433034Sdougm 1443034Sdougm /* ZFS functions */ 1453910Sdougm extern int sa_get_zfs_shares(sa_handle_t, char *); 1463034Sdougm extern int sa_zfs_update(sa_share_t); 147*8845Samw@Sun.COM extern int sa_share_zfs(sa_share_t, sa_resource_t, char *, share_t *, 148*8845Samw@Sun.COM void *, zfs_share_op_t); 1494543Smarks extern int sa_sharetab_fill_zfs(sa_share_t share, struct share *sh, 1504543Smarks char *proto); 1513034Sdougm 1523034Sdougm /* plugin specific functions */ 1533034Sdougm extern int proto_plugin_init(); 1543910Sdougm extern void proto_plugin_fini(); 1553034Sdougm extern int sa_proto_set_property(char *, sa_property_t); 1563034Sdougm extern int sa_proto_delete_legacy(char *, sa_share_t); 1573034Sdougm extern int sa_proto_update_legacy(char *, sa_share_t); 1585331Samw extern int sa_proto_rename_resource(sa_handle_t, char *, 1595331Samw sa_resource_t, char *); 1603034Sdougm 1613034Sdougm #define PL_TYPE_PROPERTY 0 1623034Sdougm #define PL_TYPE_SECURITY 1 1633034Sdougm 1643034Sdougm /* values only used by the internal dfstab/sharetab parser */ 1653034Sdougm #define SA_SHARE_PARSER 0x1000 1663034Sdougm 1673034Sdougm /* plugin handler only */ 1683034Sdougm struct sa_proto_plugin { 1693034Sdougm struct sa_proto_plugin *plugin_next; 1703034Sdougm struct sa_plugin_ops *plugin_ops; 1713034Sdougm void *plugin_handle; 1723034Sdougm }; 1733034Sdougm 1745951Sdougm #define TSTAMP(tm) (uint64_t)(((uint64_t)tm.tv_sec << 32) | \ 1755951Sdougm (tm.tv_nsec & 0xffffffff)) 1765951Sdougm 1773910Sdougm 1783034Sdougm #ifdef __cplusplus 1793034Sdougm } 1803034Sdougm #endif 1813034Sdougm 1823034Sdougm #endif /* _LIBSHARE_IMPL_H */ 183