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 (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
25 * Copyright (c) 2016 by Delphix. All rights reserved.
26 */
27
28 /*
29 * Share control API
30 */
31 #include <stdio.h>
32 #include <string.h>
33 #include <ctype.h>
34 #include <sys/types.h>
35 #include <sys/stat.h>
36 #include <fcntl.h>
37 #include <unistd.h>
38 #include <libxml/parser.h>
39 #include <libxml/tree.h>
40 #include "libshare.h"
41 #include "libshare_impl.h"
42 #include <libscf.h>
43 #include "scfutil.h"
44 #include <ctype.h>
1135
1136 /*
1137 * If this was the last handle to release, unload the
1138 * plugins that were loaded. Use a mutex in case
1139 * another thread is reinitializing.
1140 */
1141 (void) mutex_lock(&sa_global_lock);
1142 if (sa_global_handles == NULL)
1143 (void) proto_plugin_fini();
1144 (void) mutex_unlock(&sa_global_lock);
1145
1146 sa_scf_fini(impl_handle->scfhandle);
1147 sa_zfs_fini(impl_handle);
1148
1149 /* Make sure we free the handle */
1150 free(impl_handle);
1151
1152 }
1153 }
1154
1155 /*
1156 * sa_get_protocols(char **protocol)
1157 * Get array of protocols that are supported
1158 * Returns pointer to an allocated and NULL terminated
1159 * array of strings. Caller must free.
1160 * This really should be determined dynamically.
1161 * If there aren't any defined, return -1.
1162 * Use free() to return memory.
1163 */
1164
1165 int
1166 sa_get_protocols(char ***protocols)
1167 {
1168 int numproto = -1;
1169
1170 if (protocols != NULL) {
1171 struct sa_proto_plugin *plug;
1172 for (numproto = 0, plug = sap_proto_list; plug != NULL;
1173 plug = plug->plugin_next) {
1174 numproto++;
|
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 (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Copyright 2018 Nexenta Systems, Inc. All rights reserved.
25 * Copyright (c) 2016 by Delphix. All rights reserved.
26 */
27
28 /*
29 * Share control API
30 */
31 #include <stdio.h>
32 #include <string.h>
33 #include <ctype.h>
34 #include <sys/types.h>
35 #include <sys/stat.h>
36 #include <fcntl.h>
37 #include <unistd.h>
38 #include <libxml/parser.h>
39 #include <libxml/tree.h>
40 #include "libshare.h"
41 #include "libshare_impl.h"
42 #include <libscf.h>
43 #include "scfutil.h"
44 #include <ctype.h>
1135
1136 /*
1137 * If this was the last handle to release, unload the
1138 * plugins that were loaded. Use a mutex in case
1139 * another thread is reinitializing.
1140 */
1141 (void) mutex_lock(&sa_global_lock);
1142 if (sa_global_handles == NULL)
1143 (void) proto_plugin_fini();
1144 (void) mutex_unlock(&sa_global_lock);
1145
1146 sa_scf_fini(impl_handle->scfhandle);
1147 sa_zfs_fini(impl_handle);
1148
1149 /* Make sure we free the handle */
1150 free(impl_handle);
1151
1152 }
1153 }
1154
1155 /*
1156 * sa_service(sa_handle_t handle)
1157 *
1158 * Returns the service for which the handle is currently initialized.
1159 */
1160 int
1161 sa_service(sa_handle_t handle)
1162 {
1163 if (handle == NULL)
1164 return (0);
1165
1166 return (((sa_handle_impl_t)handle)->sa_service);
1167 }
1168
1169 /*
1170 * sa_get_protocols(char **protocol)
1171 * Get array of protocols that are supported
1172 * Returns pointer to an allocated and NULL terminated
1173 * array of strings. Caller must free.
1174 * This really should be determined dynamically.
1175 * If there aren't any defined, return -1.
1176 * Use free() to return memory.
1177 */
1178
1179 int
1180 sa_get_protocols(char ***protocols)
1181 {
1182 int numproto = -1;
1183
1184 if (protocols != NULL) {
1185 struct sa_proto_plugin *plug;
1186 for (numproto = 0, plug = sap_proto_list; plug != NULL;
1187 plug = plug->plugin_next) {
1188 numproto++;
|