1c99e4bdcSChris Kirby /*
2c99e4bdcSChris Kirby  * CDDL HEADER START
3c99e4bdcSChris Kirby  *
4c99e4bdcSChris Kirby  * The contents of this file are subject to the terms of the
5c99e4bdcSChris Kirby  * Common Development and Distribution License (the "License").
6c99e4bdcSChris Kirby  * You may not use this file except in compliance with the License.
7c99e4bdcSChris Kirby  *
8c99e4bdcSChris Kirby  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9c99e4bdcSChris Kirby  * or http://www.opensolaris.org/os/licensing.
10c99e4bdcSChris Kirby  * See the License for the specific language governing permissions
11c99e4bdcSChris Kirby  * and limitations under the License.
12c99e4bdcSChris Kirby  *
13c99e4bdcSChris Kirby  * When distributing Covered Code, include this CDDL HEADER in each
14c99e4bdcSChris Kirby  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15c99e4bdcSChris Kirby  * If applicable, add the following below this CDDL HEADER, with the
16c99e4bdcSChris Kirby  * fields enclosed by brackets "[]" replaced with your own identifying
17c99e4bdcSChris Kirby  * information: Portions Copyright [yyyy] [name of copyright owner]
18c99e4bdcSChris Kirby  *
19c99e4bdcSChris Kirby  * CDDL HEADER END
20c99e4bdcSChris Kirby  */
21c99e4bdcSChris Kirby 
22c99e4bdcSChris Kirby /*
23c99e4bdcSChris Kirby  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
24c99e4bdcSChris Kirby  */
25c99e4bdcSChris Kirby 
26c99e4bdcSChris Kirby #ifndef	_SYS_ZFS_ONEXIT_H
27c99e4bdcSChris Kirby #define	_SYS_ZFS_ONEXIT_H
28c99e4bdcSChris Kirby 
29c99e4bdcSChris Kirby #include <sys/zfs_context.h>
30c99e4bdcSChris Kirby 
31c99e4bdcSChris Kirby #ifdef	__cplusplus
32c99e4bdcSChris Kirby extern "C" {
33c99e4bdcSChris Kirby #endif
34c99e4bdcSChris Kirby 
35c99e4bdcSChris Kirby #ifdef _KERNEL
36c99e4bdcSChris Kirby 
37c99e4bdcSChris Kirby typedef struct zfs_onexit {
38c99e4bdcSChris Kirby 	kmutex_t	zo_lock;
39c99e4bdcSChris Kirby 	list_t		zo_actions;
40c99e4bdcSChris Kirby } zfs_onexit_t;
41c99e4bdcSChris Kirby 
42c99e4bdcSChris Kirby typedef struct zfs_onexit_action_node {
43c99e4bdcSChris Kirby 	list_node_t	za_link;
44c99e4bdcSChris Kirby 	void		(*za_func)(void *);
45c99e4bdcSChris Kirby 	void		*za_data;
46c99e4bdcSChris Kirby } zfs_onexit_action_node_t;
47c99e4bdcSChris Kirby 
48c99e4bdcSChris Kirby extern void zfs_onexit_init(zfs_onexit_t **zo);
49c99e4bdcSChris Kirby extern void zfs_onexit_destroy(zfs_onexit_t *zo);
50c99e4bdcSChris Kirby 
51c99e4bdcSChris Kirby #endif
52c99e4bdcSChris Kirby 
53*a7f53a56SChris Kirby extern int zfs_onexit_fd_hold(int fd, minor_t *minorp);
54*a7f53a56SChris Kirby extern void zfs_onexit_fd_rele(int fd);
55*a7f53a56SChris Kirby extern int zfs_onexit_add_cb(minor_t minor, void (*func)(void *), void *data,
56c99e4bdcSChris Kirby     uint64_t *action_handle);
57*a7f53a56SChris Kirby extern int zfs_onexit_del_cb(minor_t minor, uint64_t action_handle,
58*a7f53a56SChris Kirby     boolean_t fire);
59*a7f53a56SChris Kirby extern int zfs_onexit_cb_data(minor_t minor, uint64_t action_handle,
60*a7f53a56SChris Kirby     void **data);
61c99e4bdcSChris Kirby 
62c99e4bdcSChris Kirby #ifdef	__cplusplus
63c99e4bdcSChris Kirby }
64c99e4bdcSChris Kirby #endif
65c99e4bdcSChris Kirby 
66c99e4bdcSChris Kirby #endif	/* _SYS_ZFS_ONEXIT_H */
67