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#ifndef _ZFS_IOCTL_IMPL_H_
24#define	_ZFS_IOCTL_IMPL_H_
25
26extern kmutex_t zfsdev_state_lock;
27extern zfsdev_state_t *zfsdev_state_list;
28extern unsigned long zfs_max_nvlist_src_size;
29
30typedef int zfs_ioc_legacy_func_t(zfs_cmd_t *);
31typedef int zfs_ioc_func_t(const char *, nvlist_t *, nvlist_t *);
32typedef int zfs_secpolicy_func_t(zfs_cmd_t *, nvlist_t *, cred_t *);
33
34typedef enum {
35	POOL_CHECK_NONE		= 1 << 0,
36	POOL_CHECK_SUSPENDED	= 1 << 1,
37	POOL_CHECK_READONLY	= 1 << 2,
38} zfs_ioc_poolcheck_t;
39
40typedef enum {
41	NO_NAME,
42	POOL_NAME,
43	DATASET_NAME,
44	ENTITY_NAME
45} zfs_ioc_namecheck_t;
46
47/*
48 * IOC Keys are used to document and validate user->kernel interface inputs.
49 * See zfs_keys_recv_new for an example declaration. Any key name that is not
50 * listed will be rejected as input.
51 *
52 * The keyname 'optional' is always allowed, and must be an nvlist if present.
53 * Arguments which older kernels can safely ignore can be placed under the
54 * "optional" key.
55 *
56 * When adding new keys to an existing ioc for new functionality, consider:
57 *	- adding an entry into zfs_sysfs.c zfs_features[] list
58 *	- updating the libzfs_input_check.c test utility
59 *
60 * Note: in the ZK_WILDCARDLIST case, the name serves as documentation
61 * for the expected name (bookmark, snapshot, property, etc) but there
62 * is no validation in the preflight zfs_check_input_nvpairs() check.
63 */
64typedef enum {
65	ZK_OPTIONAL = 1 << 0,		/* pair is optional */
66	ZK_WILDCARDLIST = 1 << 1,	/* one or more unspecified key names */
67} ioc_key_flag_t;
68
69typedef struct zfs_ioc_key {
70	const char	*zkey_name;
71	data_type_t	zkey_type;
72	ioc_key_flag_t	zkey_flags;
73} zfs_ioc_key_t;
74
75int zfs_secpolicy_config(zfs_cmd_t *, nvlist_t *, cred_t *);
76
77void zfs_ioctl_register_dataset_nolog(zfs_ioc_t, zfs_ioc_legacy_func_t *,
78    zfs_secpolicy_func_t *, zfs_ioc_poolcheck_t);
79
80void zfs_ioctl_register(const char *, zfs_ioc_t, zfs_ioc_func_t *,
81    zfs_secpolicy_func_t *, zfs_ioc_namecheck_t, zfs_ioc_poolcheck_t,
82    boolean_t, boolean_t, const zfs_ioc_key_t *, size_t);
83
84uint64_t zfs_max_nvlist_src_size_os(void);
85void zfs_ioctl_update_mount_cache(const char *dsname);
86void zfs_ioctl_init_os(void);
87
88boolean_t zfs_vfs_held(zfsvfs_t *);
89int zfs_vfs_ref(zfsvfs_t **);
90void zfs_vfs_rele(zfsvfs_t *);
91
92long zfsdev_ioctl_common(uint_t, zfs_cmd_t *, int);
93int zfsdev_attach(void);
94void zfsdev_detach(void);
95int zfs_kmod_init(void);
96void zfs_kmod_fini(void);
97
98#endif
99