xref: /freebsd/sys/contrib/openzfs/include/sys/zfs_onexit.h (revision 61145dc2b94f12f6a47344fb9aac702321880e43)
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  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
25  * Copyright (c) 2020 by Delphix. All rights reserved.
26  */
27 
28 #ifndef	_SYS_ZFS_ONEXIT_H
29 #define	_SYS_ZFS_ONEXIT_H
30 
31 #include <sys/zfs_context.h>
32 
33 #ifdef	__cplusplus
34 extern "C" {
35 #endif
36 
37 #ifdef _KERNEL
38 
39 typedef struct zfs_onexit {
40 	kmutex_t	zo_lock;
41 	list_t		zo_actions;
42 } zfs_onexit_t;
43 
44 typedef struct zfs_onexit_action_node {
45 	list_node_t	za_link;
46 	void		(*za_func)(void *);
47 	void		*za_data;
48 } zfs_onexit_action_node_t;
49 
50 extern void zfs_onexit_init(zfs_onexit_t **zo);
51 extern void zfs_onexit_destroy(zfs_onexit_t *zo);
52 
53 #endif
54 
55 extern zfs_file_t *zfs_onexit_fd_hold(int fd, minor_t *minorp);
56 extern void zfs_onexit_fd_rele(zfs_file_t *);
57 extern int zfs_onexit_add_cb(minor_t minor, void (*func)(void *), void *data,
58     uintptr_t *action_handle);
59 
60 #ifdef	__cplusplus
61 }
62 #endif
63 
64 #endif	/* _SYS_ZFS_ONEXIT_H */
65