xref: /freebsd/sys/contrib/openzfs/lib/libshare/libshare_impl.h (revision eda14cbc264d6969b02f2b1994cef11148e914f1)
1*eda14cbcSMatt Macy /*
2*eda14cbcSMatt Macy  * CDDL HEADER START
3*eda14cbcSMatt Macy  *
4*eda14cbcSMatt Macy  * The contents of this file are subject to the terms of the
5*eda14cbcSMatt Macy  * Common Development and Distribution License (the "License").
6*eda14cbcSMatt Macy  * You may not use this file except in compliance with the License.
7*eda14cbcSMatt Macy  *
8*eda14cbcSMatt Macy  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*eda14cbcSMatt Macy  * or http://www.opensolaris.org/os/licensing.
10*eda14cbcSMatt Macy  * See the License for the specific language governing permissions
11*eda14cbcSMatt Macy  * and limitations under the License.
12*eda14cbcSMatt Macy  *
13*eda14cbcSMatt Macy  * When distributing Covered Code, include this CDDL HEADER in each
14*eda14cbcSMatt Macy  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*eda14cbcSMatt Macy  * If applicable, add the following below this CDDL HEADER, with the
16*eda14cbcSMatt Macy  * fields enclosed by brackets "[]" replaced with your own identifying
17*eda14cbcSMatt Macy  * information: Portions Copyright [yyyy] [name of copyright owner]
18*eda14cbcSMatt Macy  *
19*eda14cbcSMatt Macy  * CDDL HEADER END
20*eda14cbcSMatt Macy  */
21*eda14cbcSMatt Macy 
22*eda14cbcSMatt Macy /*
23*eda14cbcSMatt Macy  * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
24*eda14cbcSMatt Macy  * Copyright (c) 2011 Gunnar Beutner
25*eda14cbcSMatt Macy  * Copyright (c) 2019, 2020 by Delphix. All rights reserved.
26*eda14cbcSMatt Macy  */
27*eda14cbcSMatt Macy 
28*eda14cbcSMatt Macy typedef struct sa_share_fsinfo {
29*eda14cbcSMatt Macy 	char *shareopts;
30*eda14cbcSMatt Macy } sa_share_fsinfo_t;
31*eda14cbcSMatt Macy 
32*eda14cbcSMatt Macy typedef struct sa_share_impl {
33*eda14cbcSMatt Macy 	char *sa_mountpoint;
34*eda14cbcSMatt Macy 	char *sa_zfsname;
35*eda14cbcSMatt Macy 
36*eda14cbcSMatt Macy 	sa_share_fsinfo_t *sa_fsinfo; /* per-fstype information */
37*eda14cbcSMatt Macy } *sa_share_impl_t;
38*eda14cbcSMatt Macy 
39*eda14cbcSMatt Macy #define	FSINFO(impl_share, fstype) \
40*eda14cbcSMatt Macy 	(&(impl_share->sa_fsinfo[fstype->fsinfo_index]))
41*eda14cbcSMatt Macy 
42*eda14cbcSMatt Macy typedef struct sa_share_ops {
43*eda14cbcSMatt Macy 	int (*enable_share)(sa_share_impl_t share);
44*eda14cbcSMatt Macy 	int (*disable_share)(sa_share_impl_t share);
45*eda14cbcSMatt Macy 	boolean_t (*is_shared)(sa_share_impl_t share);
46*eda14cbcSMatt Macy 	int (*validate_shareopts)(const char *shareopts);
47*eda14cbcSMatt Macy 	int (*update_shareopts)(sa_share_impl_t impl_share,
48*eda14cbcSMatt Macy 	    const char *shareopts);
49*eda14cbcSMatt Macy 	void (*clear_shareopts)(sa_share_impl_t impl_share);
50*eda14cbcSMatt Macy 	int (*commit_shares)(void);
51*eda14cbcSMatt Macy } sa_share_ops_t;
52*eda14cbcSMatt Macy 
53*eda14cbcSMatt Macy typedef struct sa_fstype {
54*eda14cbcSMatt Macy 	struct sa_fstype *next;
55*eda14cbcSMatt Macy 
56*eda14cbcSMatt Macy 	const char *name;
57*eda14cbcSMatt Macy 	const sa_share_ops_t *ops;
58*eda14cbcSMatt Macy 	int fsinfo_index;
59*eda14cbcSMatt Macy } sa_fstype_t;
60*eda14cbcSMatt Macy 
61*eda14cbcSMatt Macy sa_fstype_t *register_fstype(const char *name, const sa_share_ops_t *ops);
62