1 // SPDX-License-Identifier: CDDL-1.0 2 /* 3 * This file and its contents are supplied under the terms of the 4 * Common Development and Distribution License ("CDDL"), version 1.0. 5 * You may only use this file in accordance with the terms of version 6 * 1.0 of the CDDL. 7 * 8 * A full copy of the text of the CDDL should have accompanied this 9 * source. A copy of the CDDL is also available via the Internet at 10 * https://opensource.org/license/CDDL-1.0. 11 */ 12 13 14 #ifndef _ZFS_IOCTL_IMPL_H_ 15 #define _ZFS_IOCTL_IMPL_H_ 16 17 extern kmutex_t zfsdev_state_lock; 18 extern uint64_t zfs_max_nvlist_src_size; 19 20 typedef int zfs_ioc_legacy_func_t(zfs_cmd_t *); 21 typedef int zfs_ioc_func_t(const char *, nvlist_t *, nvlist_t *); 22 typedef int zfs_secpolicy_func_t(zfs_cmd_t *, nvlist_t *, cred_t *); 23 24 typedef enum { 25 POOL_CHECK_NONE = 1 << 0, 26 POOL_CHECK_SUSPENDED = 1 << 1, 27 POOL_CHECK_READONLY = 1 << 2, 28 } zfs_ioc_poolcheck_t; 29 30 typedef enum { 31 NO_NAME, 32 POOL_NAME, 33 DATASET_NAME, 34 ENTITY_NAME 35 } zfs_ioc_namecheck_t; 36 37 /* 38 * IOC Keys are used to document and validate user->kernel interface inputs. 39 * See zfs_keys_recv_new for an example declaration. Any key name that is not 40 * listed will be rejected as input. 41 * 42 * The keyname 'optional' is always allowed, and must be an nvlist if present. 43 * Arguments which older kernels can safely ignore can be placed under the 44 * "optional" key. 45 * 46 * When adding new keys to an existing ioc for new functionality, consider: 47 * - adding an entry into zfs_sysfs.c zfs_features[] list 48 * - updating the libzfs_input_check.c test utility 49 * 50 * Note: in the ZK_WILDCARDLIST case, the name serves as documentation 51 * for the expected name (bookmark, snapshot, property, etc) but there 52 * is no validation in the preflight zfs_check_input_nvpairs() check. 53 */ 54 typedef enum { 55 ZK_OPTIONAL = 1 << 0, /* pair is optional */ 56 ZK_WILDCARDLIST = 1 << 1, /* one or more unspecified key names */ 57 } ioc_key_flag_t; 58 59 typedef struct zfs_ioc_key { 60 const char *zkey_name; 61 data_type_t zkey_type; 62 ioc_key_flag_t zkey_flags; 63 } zfs_ioc_key_t; 64 65 int zfs_secpolicy_config(zfs_cmd_t *, nvlist_t *, cred_t *); 66 67 void zfs_ioctl_register_dataset_nolog(zfs_ioc_t, zfs_ioc_legacy_func_t *, 68 zfs_secpolicy_func_t *, zfs_ioc_poolcheck_t); 69 70 void zfs_ioctl_register(const char *, zfs_ioc_t, zfs_ioc_func_t *, 71 zfs_secpolicy_func_t *, zfs_ioc_namecheck_t, zfs_ioc_poolcheck_t, 72 boolean_t, boolean_t, const zfs_ioc_key_t *, size_t); 73 74 uint64_t zfs_max_nvlist_src_size_os(void); 75 void zfs_ioctl_update_mount_cache(const char *dsname); 76 void zfs_ioctl_init_os(void); 77 78 boolean_t zfs_vfs_held(zfsvfs_t *); 79 int zfs_vfs_ref(zfsvfs_t **); 80 void zfs_vfs_rele(zfsvfs_t *); 81 82 long zfsdev_ioctl_common(uint_t, zfs_cmd_t *, int); 83 int zfsdev_attach(void); 84 void zfsdev_detach(void); 85 void zfsdev_private_set_state(void *, zfsdev_state_t *); 86 zfsdev_state_t *zfsdev_private_get_state(void *); 87 int zfsdev_state_init(void *); 88 void zfsdev_state_destroy(void *); 89 int zfs_kmod_init(void); 90 void zfs_kmod_fini(void); 91 92 #endif 93