Initial Linux ZFS GIT Repo
[zfs.git] / zfs / lib / libdmu-ctl / include / sys / dmu_ctl.h
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
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  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26
27 #ifndef _SYS_DMU_CTL_H
28 #define _SYS_DMU_CTL_H
29
30 #include <sys/types.h>
31
32 /* Default directory where the clients search for sockets to connect */
33 #define DMU_CTL_DEFAULT_DIR "/var/run/zfs/udmu"
34
35 /*
36  * These functions are called by the server process.
37  *
38  * kernel_init() must be called before dctl_server_init().
39  * kernel_fini() must not be called before dctl_server_fini().
40  *
41  * All objsets must be closed and object references be released before calling
42  * dctl_server_fini(), otherwise it will return EBUSY.
43  *
44  * Note: On Solaris, it is highly recommended to either catch or ignore the
45  * SIGPIPE signal, otherwise the server process will die if the client is
46  * killed.
47  */
48 int dctl_server_init(const char *cfg_dir, int min_threads,
49     int max_free_threads);
50 int dctl_server_fini();
51
52 /*
53  * The following functions are called by the DMU from the server process context
54  * (in the worker threads).
55  */
56 int dctls_copyin(const void *src, void *dest, size_t size);
57 int dctls_copyinstr(const char *from, char *to, size_t max,
58     size_t *len);
59 int dctls_copyout(const void *src, void *dest, size_t size);
60 int dctls_fd_read(int fd, void *buf, ssize_t len, ssize_t *residp);
61 int dctls_fd_write(int fd, const void *src, ssize_t len);
62
63 /*
64  * These functions are called by the client process (libzfs).
65  */
66 int dctlc_connect(const char *dir, boolean_t check_subdirs);
67 void dctlc_disconnect(int fd);
68
69 int dctlc_ioctl(int fd, int32_t request, void *arg);
70
71 #endif