1 // SPDX-License-Identifier: CDDL-1.0 2 /* 3 * CDDL HEADER START 4 * 5 * The contents of this file are subject to the terms of the 6 * Common Development and Distribution License (the "License"). 7 * You may not use this file except in compliance with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or https://opensource.org/licenses/CDDL-1.0. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 23 24 #ifndef _ZFS_IOCTL_IMPL_H_ 25 #define _ZFS_IOCTL_IMPL_H_ 26 27 extern kmutex_t zfsdev_state_lock; 28 extern uint64_t zfs_max_nvlist_src_size; 29 30 typedef int zfs_ioc_legacy_func_t(zfs_cmd_t *); 31 typedef int zfs_ioc_func_t(const char *, nvlist_t *, nvlist_t *); 32 typedef int zfs_secpolicy_func_t(zfs_cmd_t *, nvlist_t *, cred_t *); 33 34 typedef 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 40 typedef 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 */ 64 typedef 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 69 typedef 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 75 int zfs_secpolicy_config(zfs_cmd_t *, nvlist_t *, cred_t *); 76 77 void zfs_ioctl_register_dataset_nolog(zfs_ioc_t, zfs_ioc_legacy_func_t *, 78 zfs_secpolicy_func_t *, zfs_ioc_poolcheck_t); 79 80 void 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 84 uint64_t zfs_max_nvlist_src_size_os(void); 85 void zfs_ioctl_update_mount_cache(const char *dsname); 86 void zfs_ioctl_init_os(void); 87 88 boolean_t zfs_vfs_held(zfsvfs_t *); 89 int zfs_vfs_ref(zfsvfs_t **); 90 void zfs_vfs_rele(zfsvfs_t *); 91 92 long zfsdev_ioctl_common(uint_t, zfs_cmd_t *, int); 93 int zfsdev_attach(void); 94 void zfsdev_detach(void); 95 void zfsdev_private_set_state(void *, zfsdev_state_t *); 96 zfsdev_state_t *zfsdev_private_get_state(void *); 97 int zfsdev_state_init(void *); 98 void zfsdev_state_destroy(void *); 99 int zfs_kmod_init(void); 100 void zfs_kmod_fini(void); 101 102 #endif 103