]>
Commit | Line | Data |
---|---|---|
92e35018 CB |
1 | /* liblxcapi |
2 | * | |
3 | * Copyright © 2017 Christian Brauner <christian.brauner@ubuntu.com>. | |
4 | * Copyright © 2017 Canonical Ltd. | |
5 | * | |
6 | * This program is free software; you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License version 2, as | |
8 | * published by the Free Software Foundation. | |
9 | * | |
10 | * This program is distributed in the hope that it will be useful, | |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | * GNU General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU General Public License along | |
16 | * with this program; if not, write to the Free Software Foundation, Inc., | |
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 | */ | |
19 | ||
20 | #ifndef __LXC_COMMANDS_UTILS_H | |
21 | #define __LXC_COMMANDS_UTILS_H | |
22 | ||
23 | #include <stdio.h> | |
24 | ||
25 | #include "state.h" | |
c01c2be6 | 26 | #include "commands.h" |
92e35018 | 27 | |
5b46db1a | 28 | int lxc_make_abstract_socket_name(char *path, size_t pathlen, |
29 | const char *lxcname, | |
bbf5cf35 CB |
30 | const char *lxcpath, |
31 | const char *hashed_sock_name, | |
32 | const char *suffix); | |
33 | ||
92e35018 CB |
34 | /* lxc_cmd_sock_get_state Register a new state client fd in the container's |
35 | * in-memory handler and retrieve the requested | |
36 | * states. | |
37 | * | |
38 | * @param[in] name Name of container to connect to. | |
39 | * @param[in] lxcpath The lxcpath in which the container is running. | |
40 | * @param[in] states The states to wait for. | |
41 | * @return Return < 0 on error | |
42 | * < MAX_STATE current container state | |
43 | */ | |
44 | extern int lxc_cmd_sock_get_state(const char *name, const char *lxcpath, | |
45 | lxc_state_t states[MAX_STATE], int timeout); | |
46 | ||
47 | /* lxc_cmd_sock_rcv_state Retrieve the requested state from a state client | |
48 | * fd registerd in the container's in-memory | |
49 | * handler. | |
50 | * | |
51 | * @param[int] state_client_fd The state client fd from which the state can be | |
52 | * received. | |
53 | * @return Return < 0 on error | |
54 | * < MAX_STATE current container state | |
55 | */ | |
56 | extern int lxc_cmd_sock_rcv_state(int state_client_fd, int timeout); | |
57 | ||
c01c2be6 CB |
58 | /* lxc_add_state_client Add a new state client to the container's |
59 | * in-memory handler. | |
60 | * | |
61 | * @param[int] state_client_fd The state client fd to add. | |
62 | * @param[int] handler The container's in-memory handler. | |
63 | * @param[in] states The states to wait for. | |
64 | * | |
65 | * @return Return < 0 on error | |
66 | * 0 on success | |
67 | */ | |
68 | extern int lxc_add_state_client(int state_client_fd, | |
69 | struct lxc_handler *handler, | |
70 | lxc_state_t states[MAX_STATE]); | |
71 | ||
72 | /* lxc_cmd_connect Connect to the container's command socket. | |
73 | * | |
74 | * @param[in] name Name of container to connect to. | |
75 | * @param[in] lxcpath The lxcpath in which the container is running. | |
76 | * @param[in] hashed_sock_name The hashed name of the socket (optional). Can be | |
77 | * NULL. | |
78 | * | |
79 | * @return Return < 0 on error | |
80 | * >= 0 client fd | |
81 | */ | |
82 | extern int lxc_cmd_connect(const char *name, const char *lxcpath, | |
9dfa4041 | 83 | const char *hashed_sock_name, const char *suffix); |
c01c2be6 | 84 | |
92e35018 | 85 | #endif /* __LXC_COMMANDS_UTILS_H */ |