root / include / tap-ctl.h @ abdb293f
History | View | Annotate | Download (4.4 kB)
1 |
/*
|
---|---|
2 |
* Copyright (c) 2008, XenSource Inc.
|
3 |
* All rights reserved.
|
4 |
*
|
5 |
* Redistribution and use in source and binary forms, with or without
|
6 |
* modification, are permitted provided that the following conditions are met:
|
7 |
* * Redistributions of source code must retain the above copyright
|
8 |
* notice, this list of conditions and the following disclaimer.
|
9 |
* * Redistributions in binary form must reproduce the above copyright
|
10 |
* notice, this list of conditions and the following disclaimer in the
|
11 |
* documentation and/or other materials provided with the distribution.
|
12 |
* * Neither the name of XenSource Inc. nor the names of its contributors
|
13 |
* may be used to endorse or promote products derived from this software
|
14 |
* without specific prior written permission.
|
15 |
*
|
16 |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
17 |
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
18 |
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
19 |
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
20 |
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
21 |
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
22 |
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
23 |
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
24 |
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
25 |
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
26 |
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
27 |
*/
|
28 |
#ifndef __TAP_CTL_H__
|
29 |
#define __TAP_CTL_H__
|
30 |
|
31 |
#include <syslog.h> |
32 |
#include <errno.h> |
33 |
#include <sys/time.h> |
34 |
#include <tapdisk-message.h> |
35 |
#include <list.h> |
36 |
|
37 |
extern int tap_ctl_debug; |
38 |
|
39 |
#ifdef TAPCTL
|
40 |
#define DBG(_f, _a...) \
|
41 |
do { \
|
42 |
if (tap_ctl_debug) \
|
43 |
printf(_f, ##_a); \ |
44 |
} while (0) |
45 |
|
46 |
#define DPRINTF(_f, _a...) syslog(LOG_INFO, _f, ##_a) |
47 |
#define EPRINTF(_f, _a...) syslog(LOG_ERR, "tap-err:%s: " _f, __func__, ##_a) |
48 |
#define PERROR(_f, _a...) syslog(LOG_ERR, "tap-err:%s: " _f ": %s", __func__, ##_a, \ |
49 |
strerror(errno)) |
50 |
#endif
|
51 |
|
52 |
void tap_ctl_version(int *major, int *minor); |
53 |
int tap_ctl_kernel_version(int *major, int *minor); |
54 |
|
55 |
int tap_ctl_check_blktap(const char **message); |
56 |
int tap_ctl_check_version(const char **message); |
57 |
int tap_ctl_check(const char **message); |
58 |
|
59 |
int tap_ctl_connect(const char *path, int *socket); |
60 |
int tap_ctl_connect_id(int id, int *socket); |
61 |
int tap_ctl_read_raw(int fd, void *buf, size_t sz, struct timeval *timeout); |
62 |
int tap_ctl_read_message(int fd, tapdisk_message_t *message, |
63 |
struct timeval *timeout);
|
64 |
int tap_ctl_write_message(int fd, tapdisk_message_t *message, |
65 |
struct timeval *timeout);
|
66 |
int tap_ctl_send_and_receive(int fd, tapdisk_message_t *message, |
67 |
struct timeval *timeout);
|
68 |
int tap_ctl_connect_send_and_receive(int id, |
69 |
tapdisk_message_t *message, |
70 |
struct timeval *timeout);
|
71 |
char *tap_ctl_socket_name(int id); |
72 |
|
73 |
typedef struct { |
74 |
pid_t pid; |
75 |
int minor;
|
76 |
int state;
|
77 |
char *type;
|
78 |
char *path;
|
79 |
|
80 |
struct list_head entry;
|
81 |
} tap_list_t; |
82 |
|
83 |
#define tap_list_for_each_entry(_pos, _head) \
|
84 |
list_for_each_entry(_pos, _head, entry) |
85 |
|
86 |
#define tap_list_for_each_entry_safe(_pos, _n, _head) \
|
87 |
list_for_each_entry_safe(_pos, _n, _head, entry) |
88 |
|
89 |
int tap_ctl_list(struct list_head *list); |
90 |
int tap_ctl_list_pid(pid_t pid, struct list_head *list); |
91 |
void tap_ctl_list_free(struct list_head *list); |
92 |
|
93 |
int tap_ctl_find_minor(const char *type, const char *path); |
94 |
|
95 |
int tap_ctl_allocate(int *minor, char **devname); |
96 |
int tap_ctl_free(const int minor); |
97 |
|
98 |
int tap_ctl_create(const char *params, char **devname, int flags, |
99 |
int prt_minor, char *secondary); |
100 |
int tap_ctl_destroy(const int id, const int minor, int force, |
101 |
struct timeval *timeout);
|
102 |
|
103 |
int tap_ctl_spawn(void); |
104 |
pid_t tap_ctl_get_pid(const int id); |
105 |
|
106 |
int tap_ctl_attach(const int id, const int minor); |
107 |
int tap_ctl_detach(const int id, const int minor); |
108 |
|
109 |
int tap_ctl_open(const int id, const int minor, const char *params, int flags, |
110 |
const int prt_minor, const char *secondary); |
111 |
int tap_ctl_close(const int id, const int minor, const int force, |
112 |
struct timeval *timeout);
|
113 |
|
114 |
int tap_ctl_pause(const int id, const int minor, struct timeval *timeout); |
115 |
int tap_ctl_unpause(const int id, const int minor, const char *params); |
116 |
|
117 |
ssize_t tap_ctl_stats(pid_t pid, int minor, char *buf, size_t size); |
118 |
int tap_ctl_stats_fwrite(pid_t pid, int minor, FILE *out); |
119 |
|
120 |
int tap_ctl_blk_major(void); |
121 |
|
122 |
#endif
|